Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App Pass-through #188

Merged
merged 48 commits into from
Jun 6, 2024
Merged
Changes from 40 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
c9896f7
Push new workflow
kschrief Feb 23, 2024
0372e6e
Remove scary github actions
kschrief Feb 23, 2024
82f409f
Update
kschrief Feb 23, 2024
fa37994
Trigger
kschrief Feb 23, 2024
b1fe3bd
Trigger
kschrief Feb 23, 2024
f5ac990
Trigger
kschrief Feb 23, 2024
806e737
Introduce conflict
kschrief Feb 23, 2024
b423f5c
Yes. Good.
kschrief Feb 23, 2024
2aa497c
Get version number
kschrief Feb 27, 2024
337d36e
Get version number
kschrief Feb 27, 2024
90895c6
Get version number
kschrief Feb 27, 2024
d829527
Commit version change
kschrief Feb 27, 2024
3cdbd3c
Commit version change
kschrief Feb 27, 2024
814e1b5
Commit version change
kschrief Feb 27, 2024
37a11a0
Exit 0
kschrief Feb 27, 2024
a6bd102
Versions
kschrief Feb 27, 2024
70025d4
Versions
kschrief Feb 27, 2024
39fe788
Versions
kschrief Feb 27, 2024
9849b7c
Versions
kschrief Feb 27, 2024
63c4013
Conflict
kschrief Feb 27, 2024
cf09ec1
Conflict
kschrief Feb 27, 2024
dddf189
Conflict
kschrief Feb 27, 2024
0848c86
Conflict
kschrief Feb 27, 2024
e6171a9
Conflict
kschrief Feb 27, 2024
fa25feb
Finishing touches
kschrief Feb 28, 2024
b2a5c5f
Finishing touches
kschrief Feb 28, 2024
d4690ba
Merge to main
kschrief Feb 28, 2024
e67ba1f
Change next->main script
kschrief Feb 28, 2024
682a750
Better commit message
kschrief Feb 28, 2024
8aab3df
Better commit message
kschrief Feb 28, 2024
3b81a54
Reverse temporary changes
kschrief Mar 8, 2024
b126834
feat: App Pass-through
jlacivita Mar 19, 2024
40c70b6
Reverse versioning override
kschrief Mar 25, 2024
5ebcecc
Silly change
kschrief Mar 25, 2024
2ca3e70
Forgot to checkout next-major
kschrief Mar 25, 2024
23bc305
Merge branch 'next' into next
kschrief Apr 2, 2024
23ea7c9
Merge pull request #175 from kschrief/next
kschrief Apr 2, 2024
8e11541
Merge branch 'next' into feature/app-pass-through
jlacivita May 9, 2024
dd544f7
fix: Merge #186
jlacivita May 9, 2024
76db0a4
fix: Provider interface parameters are generic objects
jlacivita May 9, 2024
3820cad
fix: Handle cross-module x-provided-by
jlacivita May 16, 2024
6d0ea39
fix: Simplify RPC method generation
jlacivita May 22, 2024
7dfdf7d
fix: Added validation to ensure x-provided-by methods have matching s…
jlacivita May 23, 2024
3cde328
fix: Use x-response-name to disambiguate pass-through schemas
jlacivita May 23, 2024
ed4258c
fix: Documentation
jlacivita May 28, 2024
f6aaef5
Resolved conflicts
kevinshahfws Jun 4, 2024
feddfbd
chore: Corrected package-lock.json
kevinshahfws Jun 4, 2024
e1380a5
fix: Support type: [null, ...] in getPropertySchema
jlacivita Jun 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .github/workflows/merge-to-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Attempt to merge next to main
on:
workflow_dispatch:

jobs:
# Check if next can merge into main
check_merge:
name: Check if "next" can merge into "main"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
repo-token: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }}
persist-credentials: true

# Set user identity
- name: Set-Identity
run: |
git config --global user.email "${{ secrets.GLOBAL_GITHUB_EMAIL }}"
git config --global user.name "${{ secrets.GLOBAL_GITHUB_USER }}"

# Checkout "main"
- name: Checkout main
run: git checkout "main"

# Attempt a dry-run merge
- name: Attempt a dry-run merge
run: |
git merge --no-commit --no-ff origin/${{github.ref_name}}
exit $?

# Attempt to merge to main if our dry-run succeeded
process_merge_on_success:
name: Perform merge from "next" to "main"
needs: check_merge
runs-on: ubuntu-latest
if: ${{ success() }}

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
repo-token: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }}
persist-credentials: true

# Set user identity
- name: Set-Identity
run: |
git config --global user.email "${{ secrets.GLOBAL_GITHUB_EMAIL }}"
git config --global user.name "${{ secrets.GLOBAL_GITHUB_USER }}"

# Checkout "main"
- name: Checkout main
run: git checkout "main"

- name: Perform the merge from next to main
run: |
git merge origin/next
merge_status=$?

git push origin "main"
push_status=$?

if [ "$merge_status" -eq 0 ] && [ "$push_status" -eq 0 ]; then
echo "Push to main succeeded"
exit 0
else
exit 1
fi

# If the merge cannot be performed, let stakeholders know
process_merge_on_failure:
name: Merge dry-run failure
needs: check_merge
runs-on: ubuntu-latest
if: ${{ failure() }}

steps:
- name: Post error message (To-Do)
run: echo "Next cannot be merged into main cleanly"

# If we attempted to merge/push to next-main but there was a failure
process_push_failure:
name: Merge failure
needs: process_merge_on_success
runs-on: ubuntu-latest
if: ${{ failure() && needs.process_merge_on_success.result != 'skipped' }}

steps:
- name: Post error message (To-Do)
run: echo "There was a failure when merging next into main"
149 changes: 149 additions & 0 deletions .github/workflows/merge-to-next-major.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Attempt to merge next to next-major
on:
workflow_dispatch:
push:
branches:
- "next"

jobs:
# Check if next can merge into next-major
check_merge:
name: Check if "next" can merge into "next-major"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
repo-token: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }}
persist-credentials: true

# Set user identity
- name: Set-Identity
run: |
git config --global user.email "${{ secrets.GLOBAL_GITHUB_EMAIL }}"
git config --global user.name "${{ secrets.GLOBAL_GITHUB_USER }}"

# Checkout "next-major"
- name: Checkout next-major
run: git checkout "next-major"

# Get the "next-major" version number
- name: Extract next-major version
id: extract_version
run: echo "::set-output name=version::$(node -e 'console.log(require("./package.json").version)')"

# Checkout "next"
- name: Checkout next
run: git checkout "next"

# Update "next" version to match "next-major"
- name: Update "next" version to match "next-major"
run: |
jq '.version = "${{ steps.extract_version.outputs.version }}"' package.json > temp.json

if diff -q "package.json" "temp.json" >/dev/null; then
echo "Versions are identical. No change required."
rm temp.json
else
mv temp.json package.json
git add package.json && git commit -m "Sync version to ${{ steps.extract_version.outputs.version }}"
fi

# Checkout "next-major"
- name: Checkout next-major
run: git checkout "next-major"

# Attempt a dry-run merge
- name: Attempt a dry-run merge
run: |
git merge --no-commit --no-ff ${{github.ref_name}}
exit $?

# Attempt to merge to next-major if our dry-run succeeded
process_merge_on_success:
name: Perform merge from "next" to "next-major"
needs: check_merge
runs-on: ubuntu-latest
if: ${{ success() }}

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
repo-token: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }}
persist-credentials: true

# Set user identity
- name: Set-Identity
run: |
git config --global user.email "${{ secrets.GLOBAL_GITHUB_EMAIL }}"
git config --global user.name "${{ secrets.GLOBAL_GITHUB_USER }}"

# Checkout "next-major"
- name: Checkout next-major
run: git checkout "next-major"

# Get the "next-major" version number
- name: Extract next-major version
id: extract_version
run: echo "::set-output name=version::$(node -e 'console.log(require("./package.json").version)')"

# Checkout "next"
- name: Checkout next
run: git checkout "next"

# Update "next" version to match "next-major"
- name: Update "next" version to match "next-major"
run: |
jq '.version = "${{ steps.extract_version.outputs.version }}"' package.json > temp.json

if diff -q "package.json" "temp.json" >/dev/null; then
echo "Versions are identical. No change required."
rm temp.json
else
mv temp.json package.json
git add package.json && git commit -m "Sync version to ${{ steps.extract_version.outputs.version }}"
fi

# Checkout "next-major"
- name: Checkout next-major
run: git checkout "next-major"

- name: Perform the merge from next to next-major
run: |
git merge next
merge_status=$?

git push origin "next-major"
push_status=$?

if [ "$merge_status" -eq 0 ] && [ "$push_status" -eq 0 ]; then
echo "Push to next-major succeeded"
exit 0
else
exit 1
fi

# If the merge cannot be performed, let stakeholders know
process_merge_on_failure:
name: Merge dry-run failure
needs: check_merge
runs-on: ubuntu-latest
if: ${{ failure() }}

steps:
- name: Post error message (To-Do)
run: echo "Next cannot be merged into next-major cleanly"

# If we attempted to merge/push to next-main but there was a failure
process_push_failure:
name: Merge failure
needs: process_merge_on_success
runs-on: ubuntu-latest
if: ${{ failure() && needs.process_merge_on_success.result != 'skipped' }}

steps:
- name: Post error message (To-Do)
run: echo "There was a failure when merging next into next-major"
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -47,8 +47,8 @@
],
"license": "Apache-2.0",
"dependencies": {
"ajv": "^8.3.0",
"ajv-formats": "^2.1.0",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"array.prototype.groupby": "^1.1.0",
"crocks": "^0.12.4",
"deepmerge": "^4.2.2",
37 changes: 37 additions & 0 deletions src/firebolt-openrpc.json
Original file line number Diff line number Diff line change
@@ -1007,8 +1007,45 @@
},
"x-error-for": {
"type": "string"
},
"x-provided-by": {
"type": "string"
}
},
"if": {
"required": [
"x-provided-by"
]
},
"then": {
"not": {
"required": [
"x-provides"
]
},
"oneOf": [
{
"required": [ "x-manages"],
"properties": {
"x-manages": {
"type": "array",
"minItems": 1,
"maxItems": 1
}
}
},
{
"required": [ "x-uses"],
"properties": {
"x-uses": {
"type": "array",
"minItems": 1,
"maxItems": 1
}
}
}
]
},
"anyOf": [
{
"required": [ "x-uses"]
6 changes: 3 additions & 3 deletions src/macrofier/engine.mjs
Original file line number Diff line number Diff line change
@@ -920,7 +920,7 @@ function generateSchemas(json, templates, options) {
const schemas = JSON.parse(JSON.stringify(json.definitions || (json.components && json.components.schemas) || {}))

const generate = (name, schema, uri, { prefix = '' } = {}) => {
// these are internal schemas used by the firebolt-openrpc tooling, and not meant to be used in code/doc generation
// these are internal schemas used by the fireboltize-openrpc tooling, and not meant to be used in code/doc generation
if (['ListenResponse', 'ProviderRequest', 'ProviderResponse', 'FederatedResponse', 'FederatedRequest'].includes(name)) {
return
}
@@ -1312,7 +1312,7 @@ function insertMethodMacros(template, methodObj, json, templates, type = '', exa
const subscriber = json.methods.find(method => method.tags.find(tag => tag['x-alternative'] === methodObj.name))
const subscriberTemplate = (subscriber ? insertMethodMacros(getTemplate('/codeblocks/subscriber', templates), subscriber, json, templates, type, examples) : '')
const setterFor = methodObj.tags.find(t => t.name === 'setter') && methodObj.tags.find(t => t.name === 'setter')['x-setter-for'] || ''
const pullsResult = (puller || pullsFor) ? localizeDependencies(pullsFor || methodObj, json).params[1].schema : null
const pullsResult = (puller || pullsFor) ? localizeDependencies(pullsFor || methodObj, json).params.findLast(x=>true).schema : null
const pullsParams = (puller || pullsFor) ? localizeDependencies(getPayloadFromEvent(puller || methodObj), json, null, { mergeAllOfs: true }).properties.parameters : null

const pullsResultType = (pullsResult && (type === 'methods')) ? types.getSchemaShape(pullsResult, json, { destination: state.destination, templateDir: state.typeTemplateDir, section: state.section }) : ''
@@ -1771,7 +1771,7 @@ function generateProviderInterfaces(json, templates) {
}

function getProviderInterfaceName(iface, capability, moduleJson = {}) {
const uglyName = capability.split(":").slice(-2).map(capitalize).reverse().join('') + "Provider"
const uglyName = capability.split(':').slice(-2).map(capitalize).map(x => x.split('-').map(capitalize).join('')).reverse().join('') + "Provider"
let name = iface.length === 1 ? iface[0].name.charAt(0).toUpperCase() + iface[0].name.substr(1) + "Provider" : uglyName

if (moduleJson.info['x-interface-names']) {
15 changes: 14 additions & 1 deletion src/openrpc/index.mjs
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ const run = async ({
json = addExternalMarkdown(json, markdown)

// put module name in front of each method
json.methods.forEach(method => method.name = json.info.title + '.' + method.name)
json.methods.forEach(method => method.name = method.name.includes('\.') ? method.name : json.info.title + '.' + method.name)

// merge any info['x-'] extension values (maps & arrays only..)
Object.keys(json.info).filter(key => key.startsWith('x-')).forEach(extension => {
@@ -101,6 +101,19 @@ const run = async ({
logSuccess(`Generated the ${json.info.title} module.`)
})

// make sure all provided-by APIs point to a real provider method
const appProvided = openrpc.methods.filter(m => m.tags.find(t=>t['x-provided-by'])) || []
appProvided.forEach(m => {
const providedBy = m.tags.find(t=>t['x-provided-by'])['x-provided-by']
const provider = openrpc.methods.find(m => m.name === providedBy)
if (!provider) {
throw `Method ${m.name} is provided by an undefined method (${providedBy})`
}
else {
console.log(`Method ${m.name} is provided by ${providedBy}`)
}
})

openrpc = fireboltizeMerged(openrpc)

await writeJson(output, openrpc)
Loading