diff --git a/.github/workflows/bounty-program-commands.yml b/.github/workflows/bounty-program-commands.yml
new file mode 100644
index 000000000..433f7d953
--- /dev/null
+++ b/.github/workflows/bounty-program-commands.yml
@@ -0,0 +1,90 @@
+# This workflow is centrally managed at https://github.com/asyncapi/.github/
+# Don't make changes to this file in this repository, as they will be overwritten with
+# changes made to the same file in the abovementioned repository.
+
+# The purpose of this workflow is to allow Bounty Team members
+# (https://github.com/orgs/asyncapi/teams/bounty_team) to issue commands to the
+# organization's global AsyncAPI bot related to the Bounty Program, while at the
+# same time preventing unauthorized users from misusing them.
+
+name: Bounty Program commands
+
+on:
+ issue_comment:
+ types:
+ - created
+
+jobs:
+ guard-against-unauthorized-use:
+ if: >
+ github.actor != ('aeworxet' || 'thulieblack') &&
+ (
+ contains(github.event.comment.body, '/bounty' )
+ )
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: ❌ @${{github.actor}} made an unauthorized attempt to use a Bounty Program's command
+ uses: actions/github-script@v6
+
+ with:
+ github-token: ${{ secrets.GH_TOKEN }}
+ script: |
+ const commentText = `❌ @${{github.actor}} is not authorized to use the Bounty Program's commands.
+ These commands can only be used by members of the [Bounty Team](https://github.com/orgs/asyncapi/teams/bounty_team).`;
+
+ console.log(`❌ @${{github.actor}} made an unauthorized attempt to use a Bounty Program's command.`);
+ github.rest.issues.createComment({
+ issue_number: context.issue.number,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ body: commentText
+ })
+
+ add-label-bounty:
+ if: >
+ github.actor == ('aeworxet' || 'thulieblack') &&
+ (
+ contains(github.event.comment.body, '/bounty' )
+ )
+
+ runs-on: ubuntu-latest
+ env:
+ BOUNTY_PROGRAM_LABELS_JSON: |
+ [
+ {"name": "bounty", "color": "0e8a16", "description": "Participation in the Bounty Program"}
+ ]
+
+ steps:
+ - name: Add label `bounty`
+ uses: actions/github-script@v6
+
+ with:
+ github-token: ${{ secrets.GH_TOKEN }}
+ script: |
+ const BOUNTY_PROGRAM_LABELS = JSON.parse(process.env.BOUNTY_PROGRAM_LABELS_JSON);
+ let LIST_OF_LABELS_FOR_REPO = await github.rest.issues.listLabelsForRepo({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ });
+
+ LIST_OF_LABELS_FOR_REPO = LIST_OF_LABELS_FOR_REPO.data.map(key => key.name);
+
+ if (!LIST_OF_LABELS_FOR_REPO.includes(BOUNTY_PROGRAM_LABELS[0].name)) {
+ await github.rest.issues.createLabel({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ name: BOUNTY_PROGRAM_LABELS[0].name,
+ color: BOUNTY_PROGRAM_LABELS[0].color,
+ description: BOUNTY_PROGRAM_LABELS[0].description
+ });
+ }
+
+ console.log('Adding label `bounty`...');
+ github.rest.issues.addLabels({
+ issue_number: context.issue.number,
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ labels: [BOUNTY_PROGRAM_LABELS[0].name]
+ })
diff --git a/.sonarcloud.properties b/.sonarcloud.properties
index 298f574f2..ad0891100 100644
--- a/.sonarcloud.properties
+++ b/.sonarcloud.properties
@@ -1,4 +1,4 @@
# Disable specific file since it would introduce more complexity to reduce it - mainly code complexity and complex template literals
sonar.exclusions=apps/studio/public/js/monaco/**,apps/studio/src/tailwind.css,apps/studio/src/components/SplitPane/**
# Disable duplicate code in tests since it would introduce more complexity to reduce it.
-sonar.cpd.exclusions=apps/studio/public/js/monaco/**,apps/studio/src/components/Template/HTMLWrapper.tsx,apps/studio/src/components/Visualiser/Visualiser.tsx,apps/studio/src/components/Navigationv3.tsx,apps/studio/src/components/Navigation.tsx
\ No newline at end of file
+sonar.cpd.exclusions=apps/studio/**
diff --git a/apps/design-system/src/components/DropdownMenu.stories.tsx b/apps/design-system/src/components/DropdownMenu.stories.tsx
index 7002e98a8..0e3500859 100644
--- a/apps/design-system/src/components/DropdownMenu.stories.tsx
+++ b/apps/design-system/src/components/DropdownMenu.stories.tsx
@@ -35,7 +35,7 @@ const items = [
export const Default = {
args: {
- trigger: ,
+ trigger: ,
items,
side: 'bottom',
align: 'start'
diff --git a/apps/design-system/src/components/SlideOver.stories.tsx b/apps/design-system/src/components/SlideOver.stories.tsx
index 24b9e4634..bb03d028c 100644
--- a/apps/design-system/src/components/SlideOver.stories.tsx
+++ b/apps/design-system/src/components/SlideOver.stories.tsx
@@ -19,7 +19,7 @@ export const Example = () => {
return (
-
+
Content of the SlideOver
diff --git a/apps/studio-next/package.json b/apps/studio-next/package.json
index c6179f90c..d05f188cc 100644
--- a/apps/studio-next/package.json
+++ b/apps/studio-next/package.json
@@ -10,6 +10,11 @@
},
"dependencies": {
"@codemirror/state": "^6.4.1",
+ "@codemirror/commands": "^6.3.3",
+ "@codemirror/lang-json": "^6.0.1",
+ "@codemirror/lang-yaml": "^6.0.0",
+ "@codemirror/language": "^6.10.1",
+ "@codemirror/theme-one-dark": "^6.1.2",
"@types/node": "20.4.6",
"@types/react": "18.2.18",
"@types/react-dom": "18.2.7",
diff --git a/apps/studio/CHANGELOG.md b/apps/studio/CHANGELOG.md
index 982c6c528..48cfee55c 100644
--- a/apps/studio/CHANGELOG.md
+++ b/apps/studio/CHANGELOG.md
@@ -1,5 +1,17 @@
# @asyncapi/studio
+## 0.20.2
+
+### Patch Changes
+
+- 5c7b4c1: scrollTo navigation to right code block in yaml.
+
+## 0.20.1
+
+### Patch Changes
+
+- 6995cdf: bump dependencies
+
## 0.20.0
### Minor Changes
diff --git a/apps/studio/package.json b/apps/studio/package.json
index 3b224015e..75e85ec41 100644
--- a/apps/studio/package.json
+++ b/apps/studio/package.json
@@ -1,6 +1,6 @@
{
"name": "@asyncapi/studio",
- "version": "0.20.0",
+ "version": "0.20.2",
"description": "One place that allows you to develop an AsyncAPI document, validate it, convert it to the latest version, preview the documentation and visualize the events flow.",
"license": "Apache-2.0",
"bugs": {
@@ -23,9 +23,9 @@
],
"dependencies": {
"@asyncapi/avro-schema-parser": "^3.0.18",
- "@asyncapi/converter": "^1.4.13",
- "@asyncapi/openapi-schema-parser": "^3.0.17",
- "@asyncapi/parser": "^3.0.9",
+ "@asyncapi/converter": "^1.4.15",
+ "@asyncapi/openapi-schema-parser": "^3.0.18",
+ "@asyncapi/parser": "^3.0.10",
"@asyncapi/protobuf-schema-parser": "^3.2.8",
"@asyncapi/react-component": "^1.2.2",
"@asyncapi/specs": "^6.5.3",
diff --git a/apps/studio/src/services/navigation.service.ts b/apps/studio/src/services/navigation.service.ts
index b81521f52..b0180e935 100644
--- a/apps/studio/src/services/navigation.service.ts
+++ b/apps/studio/src/services/navigation.service.ts
@@ -28,9 +28,12 @@ export class NavigationService extends AbstractService {
hash: string,
) {
try {
- const range = this.svcs.parserSvc.getRangeForJsonPath('asyncapi', jsonPointer);
+ const doc = this.svcs.editorSvc;
+ const methodType = doc.value.startsWith('asyncapi') ? 'getRangeForYamlPath' : 'getRangeForJsonPath';
+ const range = this.svcs.parserSvc[methodType]('asyncapi', jsonPointer);
+
if (range) {
- await this.scrollToEditorLine(range.start.line + 1);
+ await this.scrollToEditorLine(range.start.line+1);
}
await this.scrollToHash(hash);
diff --git a/apps/studio/src/services/parser.service.ts b/apps/studio/src/services/parser.service.ts
index 3797d48ca..4ade21f36 100644
--- a/apps/studio/src/services/parser.service.ts
+++ b/apps/studio/src/services/parser.service.ts
@@ -12,6 +12,7 @@ import { filesState, documentsState, settingsState } from '../state';
import type { Diagnostic, ParseOptions } from '@asyncapi/parser/cjs';
import type { DocumentDiagnostics } from '../state/documents.state';
import { SchemaParser } from '@asyncapi/parser';
+import { getLocationForJsonPath, parseWithPointers } from '@stoplight/yaml';
export class ParserService extends AbstractService {
private parser!: Parser;
@@ -71,14 +72,36 @@ export class ParserService extends AbstractService {
getRangeForJsonPath(uri: string, jsonPath: string | Array) {
try {
const { documents } = documentsState.getState();
+
+ const extras = documents[String(uri)]?.extras;
+
+ if (extras) {
+ jsonPath = Array.isArray(jsonPath) ? jsonPath : jsonPath.split('/').map(untilde);
+ if (jsonPath[0] === '') jsonPath.shift();
+
+ return extras.document.getRangeForJsonPath(jsonPath);
+ }
+ } catch (err) {
+ console.error(err);
+ }
+ }
+
+ getRangeForYamlPath(uri: string, jsonPath: string | Array) {
+ try {
+ const { documents } = documentsState.getState();
+
const extras = documents[String(uri)]?.extras;
+
if (extras) {
jsonPath = Array.isArray(jsonPath) ? jsonPath : jsonPath.split('/').map(untilde);
if (jsonPath[0] === '') jsonPath.shift();
- return extras.document.getRangeForJsonPath(jsonPath, true);
+ const yamlDoc = parseWithPointers(this.svcs.editorSvc.value);
+
+ const location = getLocationForJsonPath(yamlDoc, jsonPath, true);
+ return location?.range || { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } };
}
- } catch (err: any) {
- return;
+ } catch (err) {
+ console.error(err);
}
}
diff --git a/package-lock.json b/package-lock.json
index 9c540ea01..69cc9b45e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,5 +1,5 @@
{
- "name": "studio",
+ "name": "master",
"lockfileVersion": 2,
"requires": true,
"packages": {
@@ -544,7 +544,7 @@
"dependencies": {
"@asyncapi/avro-schema-parser": "^3.0.18",
"@asyncapi/converter": "^1.4.13",
- "@asyncapi/openapi-schema-parser": "^3.0.17",
+ "@asyncapi/openapi-schema-parser": "^3.0.18",
"@asyncapi/parser": "^3.0.9",
"@asyncapi/protobuf-schema-parser": "^3.2.8",
"@asyncapi/react-component": "^1.2.2",
@@ -1941,11 +1941,11 @@
}
},
"node_modules/@asyncapi/openapi-schema-parser": {
- "version": "3.0.17",
- "resolved": "https://registry.npmjs.org/@asyncapi/openapi-schema-parser/-/openapi-schema-parser-3.0.17.tgz",
- "integrity": "sha512-TBFtM8oFkwkWw7CrXoPm/u1RBJBOtvnBcDOrd4GbTtmQ/kuTZwUL7zQTn7yaat2w+4l8+E7UCfwGYAaTgGj23A==",
+ "version": "3.0.18",
+ "resolved": "https://registry.npmjs.org/@asyncapi/openapi-schema-parser/-/openapi-schema-parser-3.0.18.tgz",
+ "integrity": "sha512-azKEwm9wel7QS/Fz0y1C9eCUIfUEZE/JrQlGybPmQKHS213RKyo5Rjpzo9nqGc4VT7o1URDIMaYTnYdgfMitew==",
"dependencies": {
- "@asyncapi/parser": "^3.0.9",
+ "@asyncapi/parser": "^3.0.10",
"@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0",
"ajv": "^8.11.0",
"ajv-errors": "^3.0.0",
@@ -1953,11 +1953,11 @@
}
},
"node_modules/@asyncapi/openapi-schema-parser/node_modules/@asyncapi/parser": {
- "version": "3.0.9",
- "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-3.0.9.tgz",
- "integrity": "sha512-xsuW8UHWwQD8zbGCYirA6gjRkVUL9+RxboQY1Fm+AFlRo9cL9kMQr7OvfduJErI0PEsp/KdkuP56s7izlt5/+A==",
+ "version": "3.0.10",
+ "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-3.0.10.tgz",
+ "integrity": "sha512-x9qo7SHGzPWbC1XCRyilcI+Z6UZsWZ9uRl05h9j4G/v+3IjNG3krwngiAbt59nbLlYZD/nBS7Hc03GayoocnQw==",
"dependencies": {
- "@asyncapi/specs": "^6.5.2",
+ "@asyncapi/specs": "^6.5.3",
"@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0",
"@stoplight/json": "^3.20.2",
"@stoplight/json-ref-readers": "^1.2.2",
@@ -22354,9 +22354,9 @@
}
},
"node_modules/follow-redirects": {
- "version": "1.15.4",
- "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz",
- "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==",
+ "version": "1.15.6",
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
+ "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
"dev": true,
"funding": [
{
@@ -39184,11 +39184,11 @@
}
},
"@asyncapi/openapi-schema-parser": {
- "version": "3.0.17",
- "resolved": "https://registry.npmjs.org/@asyncapi/openapi-schema-parser/-/openapi-schema-parser-3.0.17.tgz",
- "integrity": "sha512-TBFtM8oFkwkWw7CrXoPm/u1RBJBOtvnBcDOrd4GbTtmQ/kuTZwUL7zQTn7yaat2w+4l8+E7UCfwGYAaTgGj23A==",
+ "version": "3.0.18",
+ "resolved": "https://registry.npmjs.org/@asyncapi/openapi-schema-parser/-/openapi-schema-parser-3.0.18.tgz",
+ "integrity": "sha512-azKEwm9wel7QS/Fz0y1C9eCUIfUEZE/JrQlGybPmQKHS213RKyo5Rjpzo9nqGc4VT7o1URDIMaYTnYdgfMitew==",
"requires": {
- "@asyncapi/parser": "^3.0.9",
+ "@asyncapi/parser": "^3.0.10",
"@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0",
"ajv": "^8.11.0",
"ajv-errors": "^3.0.0",
@@ -39196,11 +39196,11 @@
},
"dependencies": {
"@asyncapi/parser": {
- "version": "3.0.9",
- "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-3.0.9.tgz",
- "integrity": "sha512-xsuW8UHWwQD8zbGCYirA6gjRkVUL9+RxboQY1Fm+AFlRo9cL9kMQr7OvfduJErI0PEsp/KdkuP56s7izlt5/+A==",
+ "version": "3.0.10",
+ "resolved": "https://registry.npmjs.org/@asyncapi/parser/-/parser-3.0.10.tgz",
+ "integrity": "sha512-x9qo7SHGzPWbC1XCRyilcI+Z6UZsWZ9uRl05h9j4G/v+3IjNG3krwngiAbt59nbLlYZD/nBS7Hc03GayoocnQw==",
"requires": {
- "@asyncapi/specs": "^6.5.2",
+ "@asyncapi/specs": "^6.5.3",
"@openapi-contrib/openapi-schema-to-json-schema": "~3.2.0",
"@stoplight/json": "^3.20.2",
"@stoplight/json-ref-readers": "^1.2.2",
@@ -39509,7 +39509,7 @@
"@asyncapi/markdown-template": "^1.5.0",
"@asyncapi/nodejs-template": "^1.0.0",
"@asyncapi/nodejs-ws-template": "^0.9.33",
- "@asyncapi/openapi-schema-parser": "^3.0.17",
+ "@asyncapi/openapi-schema-parser": "^3.0.18",
"@asyncapi/parser": "^3.0.9",
"@asyncapi/protobuf-schema-parser": "^3.2.8",
"@asyncapi/python-paho-template": "^0.2.13",
@@ -53155,9 +53155,9 @@
"dev": true
},
"follow-redirects": {
- "version": "1.15.4",
- "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz",
- "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==",
+ "version": "1.15.6",
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
+ "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
"dev": true
},
"for-each": {
diff --git a/package.json b/package.json
index 3c34ca096..4495c300b 100644
--- a/package.json
+++ b/package.json
@@ -30,11 +30,6 @@
],
"packageManager": "npm@8.19.3",
"dependencies": {
- "@changesets/cli": "^2.26.2",
- "@codemirror/commands": "^6.3.3",
- "@codemirror/lang-json": "^6.0.1",
- "@codemirror/lang-yaml": "^6.0.0",
- "@codemirror/language": "^6.10.1",
- "@codemirror/theme-one-dark": "^6.1.2"
+ "@changesets/cli": "^2.26.2"
}
}
\ No newline at end of file