Skip to content

Commit

Permalink
Merge branch 'fix/copy-allow-focus' into features/cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul committed Dec 15, 2023
2 parents 4c9e870 + c2cc7e5 commit 80d95ee
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -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.
6 changes: 5 additions & 1 deletion src/openrpc/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -87,6 +87,8 @@ const run = async ({
}




// add methods from this module
openrpc.methods.push(...json.methods)

Expand All @@ -101,6 +103,8 @@ const run = async ({
logSuccess(`Generated the ${json.info.title} module.`)
})

openrpc = fireboltizeMerged(openrpc)

await writeJson(output, openrpc)

console.log()
Expand Down
19 changes: 19 additions & 0 deletions src/shared/modules.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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')) || []
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -1356,6 +1374,7 @@ export {
getSchemas,
getParamsFromMethod,
fireboltize,
fireboltizeMerged,
getPayloadFromEvent,
getPathFromModule,
providerHasNoParameters,
Expand Down

0 comments on commit 80d95ee

Please sign in to comment.