From 756e88a92782c8d65ec481182c31c8edb218c9d6 Mon Sep 17 00:00:00 2001 From: Jeremy LaCivita Date: Wed, 21 Aug 2024 12:58:43 -0400 Subject: [PATCH 1/9] fix: Add provider-selection tag to validation schema --- src/firebolt-openrpc.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/firebolt-openrpc.json b/src/firebolt-openrpc.json index 4146ea75..aac66665 100644 --- a/src/firebolt-openrpc.json +++ b/src/firebolt-openrpc.json @@ -1011,6 +1011,13 @@ }, "x-provided-by": { "type": "string" + }, + "x-provider-selection": { + "type": "string", + "enum": [ + "focus", + "appId" + ] } }, "if": { From 28f8dd5015e1d661c5d0ae53d4bf61e234efb85d Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 21 Aug 2024 17:00:26 +0000 Subject: [PATCH 2/9] chore(release): 3.1.1-next.1 [skip ci] ## [3.1.1-next.1](https://github.com/rdkcentral/firebolt-openrpc/compare/v3.1.0...v3.1.1-next.1) (2024-08-21) ### Bug Fixes * Add provider-selection tag to validation schema ([756e88a](https://github.com/rdkcentral/firebolt-openrpc/commit/756e88a92782c8d65ec481182c31c8edb218c9d6)) --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71170e34..2b8d7ee9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [3.1.1-next.1](https://github.com/rdkcentral/firebolt-openrpc/compare/v3.1.0...v3.1.1-next.1) (2024-08-21) + + +### Bug Fixes + +* Add provider-selection tag to validation schema ([756e88a](https://github.com/rdkcentral/firebolt-openrpc/commit/756e88a92782c8d65ec481182c31c8edb218c9d6)) + # [3.1.0](https://github.com/rdkcentral/firebolt-openrpc/compare/v3.0.0...v3.1.0) (2024-08-08) diff --git a/package-lock.json b/package-lock.json index bd8515c2..60876532 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@firebolt-js/openrpc", - "version": "3.1.0", + "version": "3.1.1-next.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@firebolt-js/openrpc", - "version": "3.1.0", + "version": "3.1.1-next.1", "license": "Apache-2.0", "dependencies": { "ajv": "^8.12.0", diff --git a/package.json b/package.json index 2ac0e2d3..d91ed79c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/openrpc", - "version": "3.1.0", + "version": "3.1.1-next.1", "description": "The Firebolt SDK Code & Doc Generator", "main": "languages/javascript/src/sdk.mjs", "type": "module", From 647043d59ea0399b725d32e4a2e48ee017965288 Mon Sep 17 00:00:00 2001 From: Jeremy LaCivita Date: Wed, 21 Aug 2024 13:28:10 -0400 Subject: [PATCH 3/9] fix: Quote unsafe property names in languages that support it --- languages/javascript/language.config.json | 1 + src/macrofier/types.mjs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/languages/javascript/language.config.json b/languages/javascript/language.config.json index 19b4659d..6c5452f5 100644 --- a/languages/javascript/language.config.json +++ b/languages/javascript/language.config.json @@ -5,6 +5,7 @@ "/index.mjs", "/defaults.mjs" ], + "enableStringPropertyKeys": true, "createModuleDirectories": true, "copySchemasIntoModules": true, "aggregateFiles": [ diff --git a/src/macrofier/types.mjs b/src/macrofier/types.mjs index acfb0d9b..cba78534 100644 --- a/src/macrofier/types.mjs +++ b/src/macrofier/types.mjs @@ -317,6 +317,8 @@ const insertObjectPatternPropertiesMacros = (content, schema, module, title, opt } const getIndents = level => level ? ' ' : '' +const wrapProp = name => name.match(/[/\.\+]/) ? `"${name}"` : name +const safePropName = name => config.enableStringPropertyKeys ? wrapProp(name) : getSafeEnumKeyName(name) const insertObjectMacros = (content, schema, module, title, property, options) => { const options2 = options ? JSON.parse(JSON.stringify(options)) : {} options2.parent = title @@ -348,8 +350,8 @@ const insertObjectMacros = (content, schema, module, title, property, options) = const description = getSchemaDescription(prop, module) let replacedTemplate = template .replace(/(^\s+)/g, '$1'.repeat(options2.level)) - .replace(/\$\{property\}/g, name) - .replace(/\$\{Property\}/g, capitalize(name)) + .replace(/\$\{property\}/g, safePropName(name)) + .replace(/\$\{Property\}/g, capitalize(safePropName(name))) .replace(/\$\{parent\.title\}/g, title) .replace(/\$\{title\}/g, type) .replace(/\$\{shape\}/g, schemaShape) From f02aadcb57f3936f1dcebfe570e418c1d04f626d Mon Sep 17 00:00:00 2001 From: Jeremy LaCivita Date: Fri, 23 Aug 2024 10:44:25 -0400 Subject: [PATCH 4/9] fix: Return empty config, not null --- src/shared/configLoader.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/configLoader.mjs b/src/shared/configLoader.mjs index 644a7f4e..ca9f8fb5 100644 --- a/src/shared/configLoader.mjs +++ b/src/shared/configLoader.mjs @@ -12,7 +12,7 @@ export const loadConfig = async (language) => { export const getConfig = () => { if (!config) { - return null; + return {}; } return config } From 51de8d95a039cb9f62c3ddde7df9ca471592c0d5 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 23 Aug 2024 14:45:10 +0000 Subject: [PATCH 5/9] chore(release): 3.1.1-next.2 [skip ci] ## [3.1.1-next.2](https://github.com/rdkcentral/firebolt-openrpc/compare/v3.1.1-next.1...v3.1.1-next.2) (2024-08-23) ### Bug Fixes * Quote unsafe property names in languages that support it ([647043d](https://github.com/rdkcentral/firebolt-openrpc/commit/647043d59ea0399b725d32e4a2e48ee017965288)) * Return empty config, not null ([f02aadc](https://github.com/rdkcentral/firebolt-openrpc/commit/f02aadcb57f3936f1dcebfe570e418c1d04f626d)) --- CHANGELOG.md | 8 ++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b8d7ee9..18349d9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## [3.1.1-next.2](https://github.com/rdkcentral/firebolt-openrpc/compare/v3.1.1-next.1...v3.1.1-next.2) (2024-08-23) + + +### Bug Fixes + +* Quote unsafe property names in languages that support it ([647043d](https://github.com/rdkcentral/firebolt-openrpc/commit/647043d59ea0399b725d32e4a2e48ee017965288)) +* Return empty config, not null ([f02aadc](https://github.com/rdkcentral/firebolt-openrpc/commit/f02aadcb57f3936f1dcebfe570e418c1d04f626d)) + ## [3.1.1-next.1](https://github.com/rdkcentral/firebolt-openrpc/compare/v3.1.0...v3.1.1-next.1) (2024-08-21) diff --git a/package-lock.json b/package-lock.json index 60876532..c9b8b954 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@firebolt-js/openrpc", - "version": "3.1.1-next.1", + "version": "3.1.1-next.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@firebolt-js/openrpc", - "version": "3.1.1-next.1", + "version": "3.1.1-next.2", "license": "Apache-2.0", "dependencies": { "ajv": "^8.12.0", diff --git a/package.json b/package.json index d91ed79c..3a63fead 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/openrpc", - "version": "3.1.1-next.1", + "version": "3.1.1-next.2", "description": "The Firebolt SDK Code & Doc Generator", "main": "languages/javascript/src/sdk.mjs", "type": "module", From 16b4e6eb5a8739a7715eb975104d7bb33053b28c Mon Sep 17 00:00:00 2001 From: Keaton Sentak <54916859+ksentak@users.noreply.github.com> Date: Mon, 26 Aug 2024 09:44:48 -0400 Subject: [PATCH 6/9] fix: Update getSuffix to properly work in pipeline (#209) --- src/macrofier/engine.mjs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/macrofier/engine.mjs b/src/macrofier/engine.mjs index aedcc4e9..51f469a8 100644 --- a/src/macrofier/engine.mjs +++ b/src/macrofier/engine.mjs @@ -1161,7 +1161,33 @@ function generateMethods(json = {}, examples = {}, templates = {}, languages = [ event: isEventMethod(methodObj) } - const suffix = state.destination && config.templateExtensionMap ? state.destination.split(state.destination.includes('_') ? '_' : '.').pop() : '' + + /** + * Extracts the suffix from a given file path. + * + * The suffix is determined by the last underscore or period in the filename. + * If the filename contains an underscore, the portion after the last underscore + * is considered the suffix. If no underscore is found but there is a period, + * the portion after the last period (typically the file extension) is considered the suffix. + * If neither an underscore nor a period is found, an empty string is returned. + * + * @param {string} path - The full file path from which to extract the suffix. + * @returns {string} - The extracted suffix or an empty string if no suffix is found. + */ + const getSuffix = (path) => { + // Extract the last part of the path (the filename) + const filename = path.split('/').pop() // Get the last part of the path + // Check for underscores or periods in the filename and handle accordingly + if (filename.includes('_')) { + return filename.split('_').pop() // Return the last part after the last underscore + } else if (filename.includes('.')) { + return filename.split('.').pop() // Return the extension after the last period + } else { + return '' // Return empty if no suffix can be determined + } + } + + const suffix = state.destination && config.templateExtensionMap ? getSuffix(state.destination) : '' // Generate implementation of methods/events for both dynamic and static configured templates Array.from(new Set(['methods'].concat(config.additionalMethodTemplates))).filter(dir => dir).forEach(dir => { From 665aad3ece7e8b3e196c1a1bafa34181c646c26e Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 26 Aug 2024 13:45:29 +0000 Subject: [PATCH 7/9] chore(release): 3.1.1-next.3 [skip ci] ## [3.1.1-next.3](https://github.com/rdkcentral/firebolt-openrpc/compare/v3.1.1-next.2...v3.1.1-next.3) (2024-08-26) ### Bug Fixes * Update getSuffix to properly work in pipeline ([#209](https://github.com/rdkcentral/firebolt-openrpc/issues/209)) ([16b4e6e](https://github.com/rdkcentral/firebolt-openrpc/commit/16b4e6eb5a8739a7715eb975104d7bb33053b28c)) --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18349d9a..0e552f33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [3.1.1-next.3](https://github.com/rdkcentral/firebolt-openrpc/compare/v3.1.1-next.2...v3.1.1-next.3) (2024-08-26) + + +### Bug Fixes + +* Update getSuffix to properly work in pipeline ([#209](https://github.com/rdkcentral/firebolt-openrpc/issues/209)) ([16b4e6e](https://github.com/rdkcentral/firebolt-openrpc/commit/16b4e6eb5a8739a7715eb975104d7bb33053b28c)) + ## [3.1.1-next.2](https://github.com/rdkcentral/firebolt-openrpc/compare/v3.1.1-next.1...v3.1.1-next.2) (2024-08-23) diff --git a/package-lock.json b/package-lock.json index c9b8b954..b9d7c76f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@firebolt-js/openrpc", - "version": "3.1.1-next.2", + "version": "3.1.1-next.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@firebolt-js/openrpc", - "version": "3.1.1-next.2", + "version": "3.1.1-next.3", "license": "Apache-2.0", "dependencies": { "ajv": "^8.12.0", diff --git a/package.json b/package.json index 3a63fead..495c15c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/openrpc", - "version": "3.1.1-next.2", + "version": "3.1.1-next.3", "description": "The Firebolt SDK Code & Doc Generator", "main": "languages/javascript/src/sdk.mjs", "type": "module", From eb768fb5f0d8ce4c123daab428bd53ca7225333c Mon Sep 17 00:00:00 2001 From: Keaton Sentak <54916859+ksentak@users.noreply.github.com> Date: Fri, 30 Aug 2024 13:37:35 -0400 Subject: [PATCH 8/9] fix: CPP Enum/AnyOf (#210) * fix: Safe name issue reverted from javascript * fix: Adjust anyOf templates for events * fix: Make anyOf templates strings * fix: Revert debug change * fix: Add enum changes into this branch * fix: Remove unneeded changes --------- Co-authored-by: Shah, Kevin Co-authored-by: kschri201_comcast --- languages/cpp/templates/callback-initialization/anyOf.cpp | 2 +- .../cpp/templates/callback-result-instantiation/anyOf.cpp | 2 +- languages/cpp/templates/json-types/anyOf.h | 2 +- languages/cpp/templates/json-types/property-assign.cpp | 2 +- languages/cpp/templates/json-types/property-register.cpp | 2 +- src/macrofier/types.mjs | 6 ++++-- src/shared/json-schema.mjs | 5 +++++ 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/languages/cpp/templates/callback-initialization/anyOf.cpp b/languages/cpp/templates/callback-initialization/anyOf.cpp index 30f233a7..92a17554 100644 --- a/languages/cpp/templates/callback-initialization/anyOf.cpp +++ b/languages/cpp/templates/callback-initialization/anyOf.cpp @@ -1 +1 @@ -{property}; + std::string ${property}; diff --git a/languages/cpp/templates/callback-result-instantiation/anyOf.cpp b/languages/cpp/templates/callback-result-instantiation/anyOf.cpp index 120561dd..6d8fa873 100644 --- a/languages/cpp/templates/callback-result-instantiation/anyOf.cpp +++ b/languages/cpp/templates/callback-result-instantiation/anyOf.cpp @@ -1 +1 @@ - ${property}; \ No newline at end of file + ${property} = proxyResponse->Value(); \ No newline at end of file diff --git a/languages/cpp/templates/json-types/anyOf.h b/languages/cpp/templates/json-types/anyOf.h index fc121f63..2d60a3c8 100644 --- a/languages/cpp/templates/json-types/anyOf.h +++ b/languages/cpp/templates/json-types/anyOf.h @@ -1 +1 @@ -WPEFramework::Core::JSON::VariantContainer \ No newline at end of file +FireboltSDK::JSON::String \ No newline at end of file diff --git a/languages/cpp/templates/json-types/property-assign.cpp b/languages/cpp/templates/json-types/property-assign.cpp index 36bdbf83..ffdad03d 100644 --- a/languages/cpp/templates/json-types/property-assign.cpp +++ b/languages/cpp/templates/json-types/property-assign.cpp @@ -1,2 +1,2 @@ - Add(_T("${property}"), &${Property}); + Add(_T("${property.raw}"), &${Property}); ${Property} = other.${Property}; diff --git a/languages/cpp/templates/json-types/property-register.cpp b/languages/cpp/templates/json-types/property-register.cpp index 01e2a7e0..e4f9a2b2 100644 --- a/languages/cpp/templates/json-types/property-register.cpp +++ b/languages/cpp/templates/json-types/property-register.cpp @@ -1 +1 @@ - Add(_T("${property}"), &${Property}); \ No newline at end of file + Add(_T("${property.raw}"), &${Property}); \ No newline at end of file diff --git a/src/macrofier/types.mjs b/src/macrofier/types.mjs index cba78534..5fa445f5 100644 --- a/src/macrofier/types.mjs +++ b/src/macrofier/types.mjs @@ -17,7 +17,7 @@ */ import deepmerge from 'deepmerge' -import { getPath, localizeDependencies, getSafeEnumKeyName } from '../shared/json-schema.mjs' +import { getPath, localizeDependencies, getSafeEnumKeyName, getSafeKeyName } from '../shared/json-schema.mjs' import path from "path" import { getConfig } from '../shared/configLoader.mjs' @@ -318,7 +318,7 @@ const insertObjectPatternPropertiesMacros = (content, schema, module, title, opt const getIndents = level => level ? ' ' : '' const wrapProp = name => name.match(/[/\.\+]/) ? `"${name}"` : name -const safePropName = name => config.enableStringPropertyKeys ? wrapProp(name) : getSafeEnumKeyName(name) +const safePropName = name => config.enableStringPropertyKeys ? wrapProp(name) : getSafeKeyName(name) const insertObjectMacros = (content, schema, module, title, property, options) => { const options2 = options ? JSON.parse(JSON.stringify(options)) : {} options2.parent = title @@ -350,6 +350,8 @@ const insertObjectMacros = (content, schema, module, title, property, options) = const description = getSchemaDescription(prop, module) let replacedTemplate = template .replace(/(^\s+)/g, '$1'.repeat(options2.level)) + .replace(/\$\{property.raw\}/g, name) //Gives the raw RPC propery name, even if it's unsafe + .replace(/\$\{Property.raw\}/g, capitalize(name)) .replace(/\$\{property\}/g, safePropName(name)) .replace(/\$\{Property\}/g, capitalize(safePropName(name))) .replace(/\$\{parent\.title\}/g, title) diff --git a/src/shared/json-schema.mjs b/src/shared/json-schema.mjs index f140cfd2..db13a833 100644 --- a/src/shared/json-schema.mjs +++ b/src/shared/json-schema.mjs @@ -520,6 +520,10 @@ function mergeOneOf(schema) { return union(schema.oneOf) } +const getSafeKeyName = (value) => value.split(':').pop() + .replace(/[\.\-]/g, '_') // replace dots and dashes + .replace(/\+/g, '_plus') // change + to _plus + const getSafeEnumKeyName = (value) => value.split(':').pop() // use last portion of urn:style:values .replace(/[\.\-]/g, '_') // replace dots and dashes .replace(/\+/g, '_plus') // change + to _plus @@ -529,6 +533,7 @@ const getSafeEnumKeyName = (value) => value.split(':').pop() export { getSchemaConstraints, + getSafeKeyName, getSafeEnumKeyName, getExternalSchemaPaths, getLocalSchemas, From f4cbecd26482fc189733a75fe6ad80bd0b5ef8dd Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 30 Aug 2024 17:38:14 +0000 Subject: [PATCH 9/9] chore(release): 3.1.1-next.4 [skip ci] ## [3.1.1-next.4](https://github.com/rdkcentral/firebolt-openrpc/compare/v3.1.1-next.3...v3.1.1-next.4) (2024-08-30) ### Bug Fixes * CPP Enum/AnyOf ([#210](https://github.com/rdkcentral/firebolt-openrpc/issues/210)) ([eb768fb](https://github.com/rdkcentral/firebolt-openrpc/commit/eb768fb5f0d8ce4c123daab428bd53ca7225333c)) --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e552f33..8ad03536 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [3.1.1-next.4](https://github.com/rdkcentral/firebolt-openrpc/compare/v3.1.1-next.3...v3.1.1-next.4) (2024-08-30) + + +### Bug Fixes + +* CPP Enum/AnyOf ([#210](https://github.com/rdkcentral/firebolt-openrpc/issues/210)) ([eb768fb](https://github.com/rdkcentral/firebolt-openrpc/commit/eb768fb5f0d8ce4c123daab428bd53ca7225333c)) + ## [3.1.1-next.3](https://github.com/rdkcentral/firebolt-openrpc/compare/v3.1.1-next.2...v3.1.1-next.3) (2024-08-26) diff --git a/package-lock.json b/package-lock.json index b9d7c76f..14676f1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@firebolt-js/openrpc", - "version": "3.1.1-next.3", + "version": "3.1.1-next.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@firebolt-js/openrpc", - "version": "3.1.1-next.3", + "version": "3.1.1-next.4", "license": "Apache-2.0", "dependencies": { "ajv": "^8.12.0", diff --git a/package.json b/package.json index 495c15c2..8b766e9f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@firebolt-js/openrpc", - "version": "3.1.1-next.3", + "version": "3.1.1-next.4", "description": "The Firebolt SDK Code & Doc Generator", "main": "languages/javascript/src/sdk.mjs", "type": "module",