diff --git a/languages/cpp/templates/callback-context-instantiation/sub-property/anyOfSchemaShape.cpp b/languages/cpp/templates/callback-context-instantiation/sub-property/anyOfSchemaShape.cpp index f8d48279..c1981c75 100644 --- a/languages/cpp/templates/callback-context-instantiation/sub-property/anyOfSchemaShape.cpp +++ b/languages/cpp/templates/callback-context-instantiation/sub-property/anyOfSchemaShape.cpp @@ -1,3 +1,3 @@ string ${property}Str; - response.${Property.dependency}${Property}.ToString(${property}Str); + response${Property.dependency}.${Property}.ToString(${property}Str); ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = ${property}Str; diff --git a/languages/cpp/templates/callback-context-instantiation/sub-property/const.cpp b/languages/cpp/templates/callback-context-instantiation/sub-property/const.cpp index 41bc1feb..fe8fb5a0 100644 --- a/languages/cpp/templates/callback-context-instantiation/sub-property/const.cpp +++ b/languages/cpp/templates/callback-context-instantiation/sub-property/const.cpp @@ -1 +1 @@ - ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = response.${Property.dependency}${Property}; + ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = response${Property.dependency}.${Property}; diff --git a/languages/cpp/templates/callback-context-instantiation/sub-property/generic.cpp b/languages/cpp/templates/callback-context-instantiation/sub-property/generic.cpp index 41bc1feb..fe8fb5a0 100644 --- a/languages/cpp/templates/callback-context-instantiation/sub-property/generic.cpp +++ b/languages/cpp/templates/callback-context-instantiation/sub-property/generic.cpp @@ -1 +1 @@ - ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = response.${Property.dependency}${Property}; + ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = response${Property.dependency}.${Property}; diff --git a/languages/cpp/templates/callback-context-instantiation/sub-property/property.cpp b/languages/cpp/templates/callback-context-instantiation/sub-property/property.cpp index 4276ebc4..1616b444 100644 --- a/languages/cpp/templates/callback-context-instantiation/sub-property/property.cpp +++ b/languages/cpp/templates/callback-context-instantiation/sub-property/property.cpp @@ -1 +1 @@ -${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = response.${Property.dependency}${Property};${end.if.non.object}${end.if.non.array}${end.if.non.anyOf}${end.if.non.const} \ No newline at end of file +${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = response${Property.dependency}.${Property};${end.if.non.object}${end.if.non.array}${end.if.non.anyOf}${end.if.non.const} \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/sub-property/anyOfSchemaShape.cpp b/languages/cpp/templates/callback-result-instantiation/sub-property/anyOfSchemaShape.cpp index 0c62eef4..25269b21 100644 --- a/languages/cpp/templates/callback-result-instantiation/sub-property/anyOfSchemaShape.cpp +++ b/languages/cpp/templates/callback-result-instantiation/sub-property/anyOfSchemaShape.cpp @@ -1,7 +1,7 @@ - ${if.optional}if (proxyResponse->${Property.dependency}${Property}.IsSet()) { + ${if.optional}if ((*proxyResponse)${Property.dependency}.${Property}.IsSet()) { string ${property}Str; - proxyResponse->${Property.dependency}${Property}.ToString(${property}Str); + (*proxyResponse)${Property.dependency}.${Property}.ToString(${property}Str); ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = ${property}Str; }${end.if.optional}${if.non.optional}string ${property}Str; - proxyResponse->${Property.dependency}${Property}.ToString(${property}Str); + (*proxyResponse)${Property.dependency}.${Property}.ToString(${property}Str); ${base.title}${property.dependency}.${property} = ${property}Str;${end.if.non.optional} diff --git a/languages/cpp/templates/callback-result-instantiation/sub-property/const.cpp b/languages/cpp/templates/callback-result-instantiation/sub-property/const.cpp index b005a326..d7969951 100644 --- a/languages/cpp/templates/callback-result-instantiation/sub-property/const.cpp +++ b/languages/cpp/templates/callback-result-instantiation/sub-property/const.cpp @@ -1,3 +1,3 @@ - ${if.optional}if (proxyResponse->${Property.dependency}${Property}.IsSet()) { - ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = proxyResponse->${Property.dependency}${Property}; - }${end.if.optional}${if.non.optional}${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = proxyResponse->${Property.dependency}${Property};${end.if.non.optional} \ No newline at end of file + ${if.optional}if ((*proxyResponse)${Property.dependency}.${Property}.IsSet()) { + ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = (*proxyResponse)${Property.dependency}.${Property}; + }${end.if.optional}${if.non.optional}${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = (*proxyResponse)${Property.dependency}.${Property};${end.if.non.optional} \ No newline at end of file diff --git a/languages/cpp/templates/callback-result-instantiation/sub-property/object.cpp b/languages/cpp/templates/callback-result-instantiation/sub-property/object.cpp index cd86ff1a..f41b4a30 100644 --- a/languages/cpp/templates/callback-result-instantiation/sub-property/object.cpp +++ b/languages/cpp/templates/callback-result-instantiation/sub-property/object.cpp @@ -1,4 +1,4 @@ -${if.optional} if (proxyResponse->${Property.dependency}IsSet()) { +${if.optional} if ((*proxyResponse)${Property.dependency}.IsSet()) { ${base.title}${property.dependency} = std::make_optional<${type}>(); ${properties} }${end.if.optional}${if.non.optional} { diff --git a/languages/cpp/templates/callback-result-instantiation/sub-property/property.cpp b/languages/cpp/templates/callback-result-instantiation/sub-property/property.cpp index f8bfa268..8cd83ce0 100644 --- a/languages/cpp/templates/callback-result-instantiation/sub-property/property.cpp +++ b/languages/cpp/templates/callback-result-instantiation/sub-property/property.cpp @@ -1,3 +1,3 @@ -${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${if.optional}if (proxyResponse->${Property.dependency}${Property}.IsSet()) { - ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = proxyResponse->${Property.dependency}${Property}; - }${end.if.optional}${if.non.optional}${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = proxyResponse->${Property.dependency}${Property};${end.if.non.optional}${end.if.non.object}${end.if.non.array}${end.if.non.anyOf}${end.if.non.const} +${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${if.optional}if ((*proxyResponse)${Property.dependency}.${Property}.IsSet()) { + ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = (*proxyResponse)${Property.dependency}.${Property}; + }${end.if.optional}${if.non.optional}${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = (*proxyResponse)${Property.dependency}.${Property};${end.if.non.optional}${end.if.non.object}${end.if.non.array}${end.if.non.anyOf}${end.if.non.const} diff --git a/languages/cpp/templates/declarations-override/calls-metrics.h b/languages/cpp/templates/declarations-override/calls-metrics.h index e69de29b..47554196 100644 --- a/languages/cpp/templates/declarations-override/calls-metrics.h +++ b/languages/cpp/templates/declarations-override/calls-metrics.h @@ -0,0 +1,5 @@ + /* + ${method.name} + ${method.description} + */ + ${method.signature.result} ${method.name}( ${method.signature.params}${if.params}, ${end.if.params}Firebolt::Error *err = nullptr )${if.result.nonvoid}${if.params.empty} const${end.if.params.empty}${end.if.result.nonvoid} override; diff --git a/languages/cpp/templates/declarations/calls-metrics.h b/languages/cpp/templates/declarations/calls-metrics.h index e69de29b..fa1890c5 100644 --- a/languages/cpp/templates/declarations/calls-metrics.h +++ b/languages/cpp/templates/declarations/calls-metrics.h @@ -0,0 +1,6 @@ + /* + ${method.name} + ${method.description} + ${method.params.annotations}${if.deprecated} * @deprecated ${method.deprecation}${end.if.deprecated} + */ + virtual ${method.signature.result} ${method.name}( ${method.signature.params}${if.params}, ${end.if.params}Firebolt::Error *err = nullptr )${if.result.nonvoid}${if.params.empty} const${end.if.params.empty}${end.if.result.nonvoid} = 0; diff --git a/languages/cpp/templates/imports/calls-metrics.impl b/languages/cpp/templates/imports/calls-metrics.impl new file mode 100644 index 00000000..75fd87c6 --- /dev/null +++ b/languages/cpp/templates/imports/calls-metrics.impl @@ -0,0 +1 @@ +#include "metrics_impl.h" diff --git a/languages/cpp/templates/methods/calls-metrics.cpp b/languages/cpp/templates/methods/calls-metrics.cpp index e69de29b..67b67d22 100644 --- a/languages/cpp/templates/methods/calls-metrics.cpp +++ b/languages/cpp/templates/methods/calls-metrics.cpp @@ -0,0 +1,29 @@ + /* ${method.rpc.name} - ${method.description} */ + static void ${method.name}Dispatcher(const void* result) { + Metrics::MetricsImpl::${method.name}(${if.result.nonboolean}${if.result.nonvoid}(static_cast<${method.result.json.type}>(const_cast(result)))${end.if.result.nonvoid}${end.if.result.nonboolean}); + } + /* ${method.rpc.name} - ${method.description} */ + ${method.signature.result} ${info.Title}Impl::${method.name}( ${method.signature.params}${if.params}, ${end.if.params}Firebolt::Error *err ) ${if.result.nonvoid}${if.params.empty} const${end.if.params.empty}${end.if.result.nonvoid} + { + Firebolt::Error status = Firebolt::Error::NotConnected; +${if.result.nonvoid}${method.result.initialization}${end.if.result.nonvoid} + FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); + if (transport != nullptr) { + + JsonObject jsonParameters; + ${method.params.serialization.with.indent} + ${method.result.json.type} jsonResult; + status = transport->Invoke("${info.title.lowercase}.${method.rpc.name}", jsonParameters, jsonResult); + if (status == Firebolt::Error::None) { + FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "${info.Title}.${method.rpc.name} is successfully invoked"); + ${if.result.nonvoid}${method.result.instantiation.with.indent}${end.if.result.nonvoid} + WPEFramework::Core::ProxyType job = WPEFramework::Core::ProxyType(WPEFramework::Core::ProxyType::Create(${method.name}Dispatcher, nullptr)); + WPEFramework::Core::IWorkerPool::Instance().Submit(job); + } + + } else { + FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); + } + + return${if.result.nonvoid} ${method.result.name}${end.if.result.nonvoid}; + } diff --git a/languages/cpp/templates/modules/src/module_impl.h b/languages/cpp/templates/modules/src/module_impl.h index 33e6e005..ce2837f4 100644 --- a/languages/cpp/templates/modules/src/module_impl.h +++ b/languages/cpp/templates/modules/src/module_impl.h @@ -16,6 +16,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#pragma once + #include "FireboltSDK.h" #include "IModule.h" /* ${IMPORTS} */ diff --git a/languages/cpp/templates/parameter-serialization/sub-property/anyOfSchemaShape.cpp b/languages/cpp/templates/parameter-serialization/sub-property/anyOfSchemaShape.cpp index 7ac47b35..5e750f10 100644 --- a/languages/cpp/templates/parameter-serialization/sub-property/anyOfSchemaShape.cpp +++ b/languages/cpp/templates/parameter-serialization/sub-property/anyOfSchemaShape.cpp @@ -1,3 +1,3 @@ ${if.optional}if (element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.has_value()) { - ${base.title}Container.${Property.dependency}${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.value(); - }${end.if.optional}${if.non.optional}${base.title}Container.${Property.dependency}${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property};${end.if.non.optional} \ No newline at end of file + ${base.title}Container${Property.dependency}.${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.value(); + }${end.if.optional}${if.non.optional}${base.title}Container${Property.dependency}.${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property};${end.if.non.optional} \ No newline at end of file diff --git a/languages/cpp/templates/parameter-serialization/sub-property/array.cpp b/languages/cpp/templates/parameter-serialization/sub-property/array.cpp index cf5bb5f2..331d59a8 100644 --- a/languages/cpp/templates/parameter-serialization/sub-property/array.cpp +++ b/languages/cpp/templates/parameter-serialization/sub-property/array.cpp @@ -4,10 +4,10 @@ for (auto& element : ${property}) { ${if.object}${items.with.indent}${end.if.object}${if.non.object} ${property}Array.Add() = element;${end.if.non.object} } - ${base.title}Container.${Property.dependency}Add(_T("${property}"), &${property}Array); + ${base.title}Container${Property.dependency}.${Property} = ${property}Array; }${end.if.impl.array.optional}${if.impl.array.non.optional}WPEFramework::Core::JSON::ArrayType<${json.type}> ${property}Array; ${type} ${property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}; for (auto& element : ${property}) { ${if.object}${items.with.indent}${end.if.object}${if.non.object} ${property}Array.Add() = element;${end.if.non.object} } - ${base.title}Container.${Property.dependency}Add(_T("${property}"), &${property}Array);${end.if.impl.array.non.optional} + ${base.title}Container${Property.dependency}.${Property} = ${property}Array;${end.if.impl.array.non.optional} diff --git a/languages/cpp/templates/parameter-serialization/sub-property/const.cpp b/languages/cpp/templates/parameter-serialization/sub-property/const.cpp index fa81c8f4..0d25c572 100644 --- a/languages/cpp/templates/parameter-serialization/sub-property/const.cpp +++ b/languages/cpp/templates/parameter-serialization/sub-property/const.cpp @@ -1,3 +1,3 @@ ${if.optional}if (element${property.dependency}.${property}.has_value()) { - ${base.title}Container.${Property.dependency}${Property} = element${property.dependency}.${property}.value(); - }${end.if.optional}${if.non.optional}${base.title}Container.${Property.dependency}${Property} = element${property.dependency}.${property};${end.if.non.optional} \ No newline at end of file + ${base.title}Container${Property.dependency}.${Property} = element${property.dependency}.${property}.value(); + }${end.if.optional}${if.non.optional}${base.title}Container${Property.dependency}.${Property} = element${property.dependency}.${property};${end.if.non.optional} \ No newline at end of file diff --git a/languages/cpp/templates/parameter-serialization/sub-property/property.cpp b/languages/cpp/templates/parameter-serialization/sub-property/property.cpp index b7341e97..e52679d3 100644 --- a/languages/cpp/templates/parameter-serialization/sub-property/property.cpp +++ b/languages/cpp/templates/parameter-serialization/sub-property/property.cpp @@ -1,3 +1,3 @@ ${shape} ${if.non.const}${if.non.anyOf}${if.non.array}${if.non.object}${if.optional}if (element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.has_value()) { - ${base.title}Container.${Property.dependency}${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.value(); - }${end.if.optional}${if.non.optional}${base.title}Container.${Property.dependency}${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property};${end.if.non.optional}${end.if.non.object}${end.if.non.array}${end.if.non.anyOf}${end.if.non.const} \ No newline at end of file + ${base.title}Container${Property.dependency}.${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.value(); + }${end.if.optional}${if.non.optional}${base.title}Container${Property.dependency}.${Property} = element${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property};${end.if.non.optional}${end.if.non.object}${end.if.non.array}${end.if.non.anyOf}${end.if.non.const} \ No newline at end of file diff --git a/languages/cpp/templates/result-instantiation/sub-property/anyOfSchemaShape.cpp b/languages/cpp/templates/result-instantiation/sub-property/anyOfSchemaShape.cpp index 75d9be83..4398ae8b 100644 --- a/languages/cpp/templates/result-instantiation/sub-property/anyOfSchemaShape.cpp +++ b/languages/cpp/templates/result-instantiation/sub-property/anyOfSchemaShape.cpp @@ -1,7 +1,7 @@ - ${if.optional}if (jsonResult.${Property.dependency}${Property}.IsSet()) { + ${if.optional}if (jsonResult${Property.dependency}.${Property}.IsSet()) { string ${property}Str; - jsonResult.${Property.dependency}${Property}.ToString(${property}Str); + jsonResult${Property.dependency}.${Property}.ToString(${property}Str); ${base.title}Result${level}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = ${property}Str; }${end.if.optional}${if.non.optional}string ${property}Str; - jsonResult.${Property.dependency}${Property}.ToString(${property}Str); + jsonResult${Property.dependency}.${Property}.ToString(${property}Str); ${base.title}Result${level}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = ${property}Str;${end.if.non.optional} diff --git a/languages/cpp/templates/result-instantiation/sub-property/object.cpp b/languages/cpp/templates/result-instantiation/sub-property/object.cpp index bb793a66..4d789f75 100644 --- a/languages/cpp/templates/result-instantiation/sub-property/object.cpp +++ b/languages/cpp/templates/result-instantiation/sub-property/object.cpp @@ -1,4 +1,4 @@ -${if.optional} if (jsonResult.${Property.dependency}IsSet()) { +${if.optional} if (jsonResult${Property.dependency}.IsSet()) { ${base.title}Result${level}${property.dependency} = std::make_optional<${type}>(); ${properties} }${end.if.optional}${if.non.optional} { diff --git a/languages/cpp/templates/result-instantiation/sub-property/property.cpp b/languages/cpp/templates/result-instantiation/sub-property/property.cpp index 83d14805..98f5fbb4 100644 --- a/languages/cpp/templates/result-instantiation/sub-property/property.cpp +++ b/languages/cpp/templates/result-instantiation/sub-property/property.cpp @@ -1,3 +1,3 @@ -${shape} ${if.non.anyOf}${if.non.array}${if.non.object}${if.optional}if (jsonResult.${Property.dependency}${Property}.IsSet()) { - ${base.title}Result${level}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = jsonResult.${Property.dependency}${Property}; - }${end.if.optional}${if.non.optional}${base.title}Result${level}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = jsonResult.${Property.dependency}${Property};${end.if.non.optional}${end.if.non.object}${end.if.non.array}${end.if.non.anyOf} +${shape} ${if.non.anyOf}${if.non.array}${if.non.object}${if.optional}if (jsonResult${Property.dependency}.${Property}.IsSet()) { + ${base.title}Result${level}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = jsonResult${Property.dependency}.${Property}; + }${end.if.optional}${if.non.optional}${base.title}Result${level}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property} = jsonResult${Property.dependency}.${Property};${end.if.non.optional}${end.if.non.object}${end.if.non.array}${end.if.non.anyOf} diff --git a/src/macrofier/engine.mjs b/src/macrofier/engine.mjs index 70023eb1..f1f4e984 100644 --- a/src/macrofier/engine.mjs +++ b/src/macrofier/engine.mjs @@ -980,6 +980,20 @@ function getRelatedSchemaLinks(schema = {}, json = {}, templates = {}, options = return links } +function getTemplateFromDestination(destination, templateName, templates) { + const destinationArray = destination.split('/').pop().split(/[_.]+/) + + let template = '' + destinationArray.filter(value => value).every((suffix) => { + template = getTemplate(templateName +`.${suffix}`, templates) + return template ? false: true + }) + if (!template) { + template = getTemplate(templateName, templates) + } + return template +} + const generateImports = (json, templates, options = { destination: '' }) => { let imports = '' @@ -1011,21 +1025,11 @@ const generateImports = (json, templates, options = { destination: '' }) => { imports += getTemplate('/imports/x-method', templates) } - const suffix = options.destination.split('.').pop() if (callsMetrics(json).length) { - imports += getTemplate(suffix ? `/imports/calls-metrics.${suffix}` : '/imports/calls-metrics', templates) - } - - const destinationArray = options.destination.split('/').pop().split(/[_.]+/) - let template = '' - destinationArray.filter(value => value).every((suffix) => { - template = getTemplate(`/imports/default.${suffix}`, templates) - return template ? false: true - }) - if (!template) { - template = getTemplate('/imports/default', templates) + imports += getTemplateFromDestination(options.destination, '/imports/calls-metrics', templates) } + let template = getTemplateFromDestination(options.destination, '/imports/default', templates) if (json['x-schemas'] && Object.keys(json['x-schemas']).length > 0 && !json.info['x-uri-titles']) { imports += Object.keys(json['x-schemas']).map(shared => template.replace(/\$\{info.title.lowercase\}/g, shared.toLowerCase())).join('') } @@ -1312,6 +1316,7 @@ function insertMethodMacros(template, methodObj, json, templates, examples = {}) // hmm... how is this different from callbackSerializedList? i guess they get merged? const callbackResponseInst = event ? (event.params && event.params.length ? (event.params.map(param => types.getSchemaShape(param.schema, json, { templateDir: 'callback-response-instantiation', property: param.name, required: param.required, destination: state.destination, section: state.section, primitive: true, skipTitleOnce: true })).join(', ')) + ', ' : '' ) + (types.getSchemaShape(event.result.schema, json, { templateDir: 'callback-response-instantiation', property: result.name, destination: state.destination, section: state.section, primitive: true, skipTitleOnce: true })) : '' const resultType = result.schema ? types.getSchemaType(result.schema, json, { templateDir: state.typeTemplateDir }) : '' + const resultSchemaType = result.schema.type const resultJsonType = result.schema ? types.getSchemaType(result.schema, json, { templateDir: 'json-types' }) : '' const resultParams = generateResultParams(result.schema, json, templates, { name: result.name}) @@ -1357,6 +1362,7 @@ function insertMethodMacros(template, methodObj, json, templates, examples = {}) .replace(/\$\{if\.params\}(.*?)\$\{end\.if\.params\}/gms, method.params.length ? '$1' : '') .replace(/\$\{if\.result\}(.*?)\$\{end\.if\.result\}/gms, resultType ? '$1' : '') .replace(/\$\{if\.result.nonvoid\}(.*?)\$\{end\.if\.result.nonvoid\}/gms, resultType && resultType !== 'void' ? '$1' : '') + .replace(/\$\{if\.result.nonboolean\}(.*?)\$\{end\.if\.result.nonboolean\}/gms, resultSchemaType && resultSchemaType !== 'boolean' ? '$1' : '') .replace(/\$\{if\.result\.properties\}(.*?)\$\{end\.if\.result\.properties\}/gms, resultParams ? '$1' : '') .replace(/\$\{if\.params\.empty\}(.*?)\$\{end\.if\.params\.empty\}/gms, method.params.length === 0 ? '$1' : '') .replace(/\$\{if\.signature\.empty\}(.*?)\$\{end\.if\.signature\.empty\}/gms, (method.params.length === 0 && resultType === '') ? '$1' : '') diff --git a/src/macrofier/index.mjs b/src/macrofier/index.mjs index f2923717..c6cf1595 100644 --- a/src/macrofier/index.mjs +++ b/src/macrofier/index.mjs @@ -133,7 +133,7 @@ const macrofy = async ( const staticCodeList = staticContent ? await readDir(staticContent, { recursive: true }) : [] const staticModules = staticModuleNames.map(name => ( { info: { title: name } } )) - + let modules if (hidePrivate) { modules = moduleList.map(name => getModule(name, openrpc, copySchemasIntoModules, extractSubSchemas)).filter(hasPublicAPIs) diff --git a/src/macrofier/types.mjs b/src/macrofier/types.mjs index b8b76016..435db418 100644 --- a/src/macrofier/types.mjs +++ b/src/macrofier/types.mjs @@ -319,7 +319,7 @@ const insertObjectMacros = (content, schema, module, title, property, options) = .replace(/\$\{if\.impl.optional\}(.*?)\$\{end\.if\.impl.optional\}/gms, schema.required && schema.required.includes(name) ? '' : '$1') .replace(/\$\{if\.impl.non.optional\}(.*?)\$\{end\.if\.impl.non.optional\}/gms, schema.required && schema.required.includes(name) ? '$1' : '') .replace(/\$\{property.dependency\}/g, ((options.level > 0) ? '${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}' : '') + objSeparator + name) - .replace(/\$\{Property.dependency\}/g, ((options.level > 0) ? '${Property.dependency}' : '') + capitalize(name) + (objSeparator)) + .replace(/\$\{Property.dependency\}/g, ((options.level > 0) ? '${Property.dependency}' : '') + (objSeparator) + capitalize(name)) } else { if (options2.level <= 1) {