diff --git a/NOTICE b/NOTICE index 25fc7bbf..6db36d20 100644 --- a/NOTICE +++ b/NOTICE @@ -20,3 +20,5 @@ The component may include material which is licensed under other licenses / copy listed below. Your use of this material within the component is also subject to the terms and conditions of these licenses. The LICENSE file contains the text of all the licenses which apply within this component.. + +npm is a registered trademark of npm, Inc. diff --git a/src/openrpc/index.mjs b/src/openrpc/index.mjs index e0819b7f..571429c6 100644 --- a/src/openrpc/index.mjs +++ b/src/openrpc/index.mjs @@ -17,7 +17,7 @@ */ import { readJson, readFiles, readDir, writeJson } from "../shared/filesystem.mjs" -import { addExternalMarkdown, addExternalSchemas, fireboltize } from "../shared/modules.mjs" +import { addExternalMarkdown, addExternalSchemas, fireboltize, fireboltizeMerged } from "../shared/modules.mjs" import path from "path" import { logHeader, logSuccess } from "../shared/io.mjs" @@ -87,6 +87,8 @@ const run = async ({ } + + // add methods from this module openrpc.methods.push(...json.methods) @@ -101,6 +103,8 @@ const run = async ({ logSuccess(`Generated the ${json.info.title} module.`) }) + openrpc = fireboltizeMerged(openrpc) + await writeJson(output, openrpc) console.log() diff --git a/src/shared/modules.mjs b/src/shared/modules.mjs index 45592fee..02490c18 100644 --- a/src/shared/modules.mjs +++ b/src/shared/modules.mjs @@ -740,6 +740,18 @@ const createResponseFromProvider = (provider, type, json) => { return response } +const copyAllowFocusTags = (json) => { + // for each allow focus provider method, set the value on any `use` methods that share the same capability + json.methods.filter(m => m.tags.find(t => t['x-allow-focus'] && t['x-provides'])).forEach(method => { + const cap = method.tags.find(t => t.name === "capabilities")['x-provides'] + json.methods.filter(m => m.tags.find(t => t['x-uses'] && t['x-uses'].includes(cap))).forEach(useMethod => { + useMethod.tags.find(t => t.name === "capabilities")['x-allow-focus'] = true + }) + }) + + return json +} + const generatePropertyEvents = json => { const properties = json.methods.filter( m => m.tags && m.tags.find( t => t.name == 'property')) || [] const readonlies = json.methods.filter( m => m.tags && m.tags.find( t => t.name == 'property:readonly')) || [] @@ -1065,6 +1077,12 @@ const fireboltize = (json) => { return json } +const fireboltizeMerged = (json) => { + json = copyAllowFocusTags(json) + + return json +} + const getExternalMarkdownPaths = obj => { return getExternalSchemaPaths(obj) .filter(x => /^file:/.test(getPathOr(null, x, obj))) @@ -1356,6 +1374,7 @@ export { getSchemas, getParamsFromMethod, fireboltize, + fireboltizeMerged, getPayloadFromEvent, getPathFromModule, providerHasNoParameters,