├── .all-contributorsrc ├── .asyncapi-tool ├── .eslintignore ├── .eslintrc ├── .github └── workflows │ ├── add-good-first-issue-labels.yml │ ├── automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml │ ├── automerge-for-humans-merging.yml │ ├── automerge-for-humans-remove-ready-to-merge-label-on-edit.yml │ ├── automerge-orphans.yml │ ├── automerge.yml │ ├── autoupdate.yml │ ├── bounty-program-commands.yml │ ├── bump.yml │ ├── help-command.yml │ ├── if-nodejs-pr-testing.yml │ ├── if-nodejs-release.yml │ ├── if-nodejs-version-bump.yml │ ├── issues-prs-notifications.yml │ ├── lint-pr-title.yml │ ├── notify-tsc-members-mention.yml │ ├── please-take-a-look-command.yml │ ├── release-announcements.yml │ ├── scripts │ ├── README.md │ └── mailchimp │ │ ├── htmlContent.js │ │ ├── index.js │ │ ├── package-lock.json │ │ └── package.json │ ├── stale-issues-prs.yml │ ├── transfer-issue.yml │ ├── update-maintainers-trigger.yaml │ ├── update-pr.yml │ └── welcome-first-time-contrib.yml ├── .gitignore ├── .releaserc ├── .sonarcloud.properties ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── assets └── logo.png ├── docs ├── .nojekyll ├── README.md ├── classes │ └── asyncapidiff.AsyncAPIDiff.md ├── interfaces │ ├── index.AsyncAPIDiffOptions.md │ ├── index.ChangeMarkdownGenerationConfig.md │ ├── index.Classifier.md │ ├── index.Config.md │ ├── index.DiffOutput.md │ ├── index.FormatterConfig.md │ ├── index.JSONOutput.md │ ├── index.MarkdownDropdownGenerationConfig.md │ └── index.OverrideObject.md └── modules │ ├── asyncapidiff.md │ └── index.md ├── jest.config.js ├── package-lock.json ├── package.json ├── src ├── asyncapidiff.ts ├── categorizeChanges.ts ├── classifier.ts ├── constants.ts ├── generateDiff.ts ├── helpers │ ├── ClassifierHelpers.ts │ ├── DiffHelpers.ts │ ├── MarkdownHelpers.ts │ └── output │ │ ├── convertToMarkdown.ts │ │ ├── convertToYAML.ts │ │ └── toProperFormat.ts ├── index.ts ├── main.ts ├── mergeStandard.ts ├── standard.ts ├── standards │ ├── v2.ts │ └── v3.ts └── types.ts ├── standard-format.md ├── test ├── ClassifierHelpers.spec.ts ├── asycnapidiff.spec.ts ├── categorizeChanges.spec.ts ├── classifier.spec.ts ├── fixtures │ ├── ClassifierHelpers.fixtures.ts │ ├── DiffHelpers.fixtures.ts │ ├── asyncapidiff.fixtures.ts │ ├── categorizeChanges.fixtures.ts │ ├── classifier.fixtures.ts │ ├── diff.fixtures.ts │ ├── main.fixtures.ts │ ├── mergeStandard.fixture.ts │ └── parser.fixtures.ts ├── generateDiff.spec.ts ├── helpers │ ├── DiffHelpers.spec.ts │ └── output │ │ └── convertToYAML.spec.ts ├── main.spec.ts ├── mergeStandard.spec.ts └── spec │ ├── asyncapi-v3-diff.yml │ ├── asyncapi-v3.yml │ ├── asyncapi.yml │ └── diffSpec.yml ├── tsconfig.json └── typedoc.json /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "projectName": "diff", 3 | "projectOwner": "asyncapi", 4 | "repoType": "github", 5 | "repoHost": "https://github.com", 6 | "files": [ 7 | "README.md" 8 | ], 9 | "imageSize": 100, 10 | "commit": false, 11 | "commitConvention": "none", 12 | "contributors": [ 13 | { 14 | "login": "aayushmau5", 15 | "name": "Aayush Kumar Sahu", 16 | "avatar_url": "https://avatars.githubusercontent.com/u/54525741?v=4", 17 | "profile": "https://aayushsahu.com/", 18 | "contributions": [ 19 | "code", 20 | "doc", 21 | "maintenance", 22 | "ideas", 23 | "review", 24 | "test" 25 | ] 26 | }, 27 | { 28 | "login": "derberg", 29 | "name": "Lukasz Gornicki", 30 | "avatar_url": "https://avatars.githubusercontent.com/u/6995927?v=4", 31 | "profile": "https://www.brainfart.dev/", 32 | "contributions": [ 33 | "ideas", 34 | "review", 35 | "maintenance" 36 | ] 37 | }, 38 | { 39 | "login": "magicmatatjahu", 40 | "name": "Maciej Urbańczyk", 41 | "avatar_url": "https://avatars.githubusercontent.com/u/20404945?v=4", 42 | "profile": "https://github.com/magicmatatjahu", 43 | "contributions": [ 44 | "review" 45 | ] 46 | }, 47 | { 48 | "login": "jonaslagoni", 49 | "name": "Jonas Lagoni", 50 | "avatar_url": "https://avatars.githubusercontent.com/u/13396189?v=4", 51 | "profile": "https://github.com/jonaslagoni", 52 | "contributions": [ 53 | "review" 54 | ] 55 | }, 56 | { 57 | "login": "vinitshahdeo", 58 | "name": "Vinit Shahdeo", 59 | "avatar_url": "https://avatars.githubusercontent.com/u/20594326?v=4", 60 | "profile": "https://github.com/vinitshahdeo", 61 | "contributions": [ 62 | "review" 63 | ] 64 | }, 65 | { 66 | "login": "onbit-uchenik", 67 | "name": "Anubhav Vats", 68 | "avatar_url": "https://avatars.githubusercontent.com/u/46771418?v=4", 69 | "profile": "https://www.linkedin.com/in/anubhav-vats-0688b5187/", 70 | "contributions": [ 71 | "review" 72 | ] 73 | }, 74 | { 75 | "login": "shivensinha4", 76 | "name": "Shiven Sinha", 77 | "avatar_url": "https://avatars.githubusercontent.com/u/19777714?v=4", 78 | "profile": "https://github.com/shivensinha4", 79 | "contributions": [ 80 | "code", 81 | "test" 82 | ] 83 | }, 84 | { 85 | "login": "ron-debajyoti", 86 | "name": "Debajyoti Halder", 87 | "avatar_url": "https://avatars.githubusercontent.com/u/22571664?v=4", 88 | "profile": "https://github.com/ron-debajyoti", 89 | "contributions": [ 90 | "doc" 91 | ] 92 | } 93 | ], 94 | "contributorsPerLine": 7, 95 | "skipCi": false 96 | } 97 | -------------------------------------------------------------------------------- /.asyncapi-tool: -------------------------------------------------------------------------------- 1 | title: AsyncAPI Diff 2 | filters: 3 | language: TypeScript 4 | technology: 5 | - TypeScript 6 | categories: 7 | - compare-tool 8 | hasCommercial: false 9 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | docs 2 | dist 3 | node_modules 4 | .vscode 5 | .idea 6 | coverage 7 | lib 8 | *.DS_Store -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "@typescript-eslint/parser", 3 | "plugins": [ 4 | "@typescript-eslint", 5 | "sonarjs", 6 | "security", 7 | "github" 8 | ], 9 | "extends": [ 10 | "eslint:recommended", 11 | "plugin:@typescript-eslint/recommended", 12 | "plugin:sonarjs/recommended", 13 | "plugin:security/recommended" 14 | ], 15 | "rules": { 16 | "strict": 0, 17 | "github/array-foreach": 2, 18 | "eol-last": [ 19 | "error", 20 | "always" 21 | ], 22 | "@typescript-eslint/no-explicit-any": 0, 23 | "require-await": "error", 24 | "@typescript-eslint/explicit-module-boundary-types": [ 25 | "error", 26 | { 27 | "allowArgumentsExplicitlyTypedAsAny": true 28 | } 29 | ], 30 | "sonarjs/no-small-switch": "off", 31 | "no-underscore-dangle": "error", 32 | "no-process-exit": "error", 33 | "no-warning-comments": "error", 34 | "no-loop-func": "error", 35 | "curly": [ 36 | "error" 37 | ], 38 | "no-multi-spaces": "error", 39 | "consistent-return": 0, 40 | "consistent-this": [ 41 | 0, 42 | "self" 43 | ], 44 | "func-style": 0, 45 | "max-nested-callbacks": [ 46 | "error", 47 | 3 48 | ], 49 | "camelcase": 0, 50 | "no-debugger": 1, 51 | "no-empty": 1, 52 | "no-invalid-regexp": 1, 53 | "no-unused-expressions": 1, 54 | "no-native-reassign": 1, 55 | "no-fallthrough": 1, 56 | "sonarjs/cognitive-complexity": 1, 57 | "eqeqeq": 2, 58 | "no-undef": 2, 59 | "no-dupe-keys": 2, 60 | "no-empty-character-class": 2, 61 | "no-self-compare": 2, 62 | "valid-typeof": 2, 63 | "no-unused-vars": [ 64 | 2, 65 | { 66 | "args": "none" 67 | } 68 | ], 69 | "handle-callback-err": 2, 70 | "no-shadow-restricted-names": 2, 71 | "no-new-require": 2, 72 | "no-mixed-spaces-and-tabs": 2, 73 | "block-scoped-var": 2, 74 | "no-else-return": 2, 75 | "no-throw-literal": 2, 76 | "no-void": 2, 77 | "radix": 2, 78 | "wrap-iife": [ 79 | 2, 80 | "outside" 81 | ], 82 | "no-shadow": 0, 83 | "no-use-before-define": [ 84 | 2, 85 | "nofunc" 86 | ], 87 | "no-path-concat": 2, 88 | "valid-jsdoc": [ 89 | 0, 90 | { 91 | "requireReturn": false, 92 | "requireParamDescription": false, 93 | "requireReturnDescription": false 94 | } 95 | ], 96 | "no-spaced-func": 2, 97 | "semi-spacing": 2, 98 | "quotes": [ 99 | 2, 100 | "single" 101 | ], 102 | "key-spacing": [ 103 | 2, 104 | { 105 | "beforeColon": false, 106 | "afterColon": true 107 | } 108 | ], 109 | "indent": [ 110 | 2, 111 | 2 112 | ], 113 | "no-lonely-if": 2, 114 | "no-floating-decimal": 2, 115 | "brace-style": [ 116 | 2, 117 | "1tbs", 118 | { 119 | "allowSingleLine": true 120 | } 121 | ], 122 | "comma-style": [ 123 | 2, 124 | "last" 125 | ], 126 | "no-multiple-empty-lines": [ 127 | 2, 128 | { 129 | "max": 1 130 | } 131 | ], 132 | "no-nested-ternary": 2, 133 | "operator-assignment": [ 134 | 2, 135 | "always" 136 | ], 137 | "padded-blocks": [ 138 | 2, 139 | "never" 140 | ], 141 | "quote-props": [ 142 | 2, 143 | "as-needed" 144 | ], 145 | "keyword-spacing": [ 146 | 2, 147 | { 148 | "before": true, 149 | "after": true, 150 | "overrides": {} 151 | } 152 | ], 153 | "space-before-blocks": [ 154 | 2, 155 | "always" 156 | ], 157 | "array-bracket-spacing": [ 158 | 2, 159 | "never" 160 | ], 161 | "computed-property-spacing": [ 162 | 2, 163 | "never" 164 | ], 165 | "space-in-parens": [ 166 | 2, 167 | "never" 168 | ], 169 | "space-unary-ops": [ 170 | 2, 171 | { 172 | "words": true, 173 | "nonwords": false 174 | } 175 | ], 176 | "no-console": "error", 177 | "wrap-regex": 2, 178 | //"linebreak-style": ["error", "unix"], 179 | "linebreak-style": 0, 180 | "semi": [ 181 | 2, 182 | "always" 183 | ], 184 | "arrow-spacing": [ 185 | 2, 186 | { 187 | "before": true, 188 | "after": true 189 | } 190 | ], 191 | "no-class-assign": 2, 192 | "no-const-assign": 2, 193 | "no-this-before-super": 2, 194 | "no-var": 2, 195 | "object-shorthand": [ 196 | 2, 197 | "always" 198 | ], 199 | "prefer-arrow-callback": 2, 200 | "prefer-const": 2, 201 | "prefer-spread": 2, 202 | "prefer-template": 2 203 | }, 204 | "overrides": [ 205 | { 206 | "files": "*.spec.ts", 207 | "rules": { 208 | "no-undef": "off", 209 | "security/detect-non-literal-fs-filename": "off", 210 | "sonarjs/no-duplicate-string": "off", 211 | "security/detect-object-injection": "off", 212 | "max-nested-callbacks": "off", 213 | "sonarjs/no-identical-functions": "off", 214 | "@typescript-eslint/no-non-null-assertion": "off", 215 | "@typescript-eslint/no-unused-vars": "off" 216 | } 217 | } 218 | ] 219 | } -------------------------------------------------------------------------------- /.github/workflows/add-good-first-issue-labels.yml: -------------------------------------------------------------------------------- 1 | # This workflow is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | # Purpose of this workflow is to enable anyone to label issue with 'Good First Issue' and 'area/*' with a single command. 5 | name: Add 'Good First Issue' and 'area/*' labels # if proper comment added 6 | 7 | on: 8 | issue_comment: 9 | types: 10 | - created 11 | 12 | jobs: 13 | add-labels: 14 | if: ${{(!github.event.issue.pull_request && github.event.issue.state != 'closed' && github.actor != 'asyncapi-bot') && (contains(github.event.comment.body, '/good-first-issue') || contains(github.event.comment.body, '/gfi' ))}} 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Add label 18 | uses: actions/github-script@v7 19 | with: 20 | github-token: ${{ secrets.GH_TOKEN }} 21 | script: | 22 | const areas = ['javascript', 'typescript', 'java' , 'go', 'docs', 'ci-cd', 'design']; 23 | const words = context.payload.comment.body.trim().split(" "); 24 | const areaIndex = words.findIndex((word)=> word === '/gfi' || word === '/good-first-issue') + 1 25 | let area = words[areaIndex]; 26 | switch(area){ 27 | case 'ts': 28 | area = 'typescript'; 29 | break; 30 | case 'js': 31 | area = 'javascript'; 32 | break; 33 | case 'markdown': 34 | area = 'docs'; 35 | break; 36 | } 37 | if(!areas.includes(area)){ 38 | const message = `Hey @${context.payload.sender.login}, your message doesn't follow the requirements, you can try \`/help\`.` 39 | 40 | await github.rest.issues.createComment({ 41 | issue_number: context.issue.number, 42 | owner: context.repo.owner, 43 | repo: context.repo.repo, 44 | body: message 45 | }) 46 | } else { 47 | 48 | // remove area if there is any before adding new labels. 49 | const currentLabels = (await github.rest.issues.listLabelsOnIssue({ 50 | issue_number: context.issue.number, 51 | owner: context.repo.owner, 52 | repo: context.repo.repo, 53 | })).data.map(label => label.name); 54 | 55 | const shouldBeRemoved = currentLabels.filter(label => (label.startsWith('area/') && !label.endsWith(area))); 56 | shouldBeRemoved.forEach(label => { 57 | github.rest.issues.deleteLabel({ 58 | owner: context.repo.owner, 59 | repo: context.repo.repo, 60 | name: label, 61 | }); 62 | }); 63 | 64 | // Add new labels. 65 | github.rest.issues.addLabels({ 66 | issue_number: context.issue.number, 67 | owner: context.repo.owner, 68 | repo: context.repo.repo, 69 | labels: ['good first issue', `area/${area}`] 70 | }); 71 | } 72 | -------------------------------------------------------------------------------- /.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml: -------------------------------------------------------------------------------- 1 | # This workflow is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | # Purpose of this workflow is to enable anyone to label PR with the following labels: 5 | # `ready-to-merge` and `do-not-merge` labels to get stuff merged or blocked from merging 6 | # `autoupdate` to keep a branch up-to-date with the target branch 7 | 8 | name: Label PRs # if proper comment added 9 | 10 | on: 11 | issue_comment: 12 | types: 13 | - created 14 | 15 | jobs: 16 | add-ready-to-merge-label: 17 | if: > 18 | github.event.issue.pull_request && 19 | github.event.issue.state != 'closed' && 20 | github.actor != 'asyncapi-bot' && 21 | ( 22 | contains(github.event.comment.body, '/ready-to-merge') || 23 | contains(github.event.comment.body, '/rtm' ) 24 | ) 25 | 26 | runs-on: ubuntu-latest 27 | steps: 28 | - name: Add ready-to-merge label 29 | uses: actions/github-script@v7 30 | with: 31 | github-token: ${{ secrets.GH_TOKEN }} 32 | script: | 33 | const prDetailsUrl = context.payload.issue.pull_request.url; 34 | const { data: pull } = await github.request(prDetailsUrl); 35 | const { draft: isDraft} = pull; 36 | if(!isDraft) { 37 | console.log('adding ready-to-merge label...'); 38 | github.rest.issues.addLabels({ 39 | issue_number: context.issue.number, 40 | owner: context.repo.owner, 41 | repo: context.repo.repo, 42 | labels: ['ready-to-merge'] 43 | }) 44 | } 45 | 46 | const { data: comparison } = 47 | await github.rest.repos.compareCommitsWithBasehead({ 48 | owner: pull.head.repo.owner.login, 49 | repo: pull.head.repo.name, 50 | basehead: `${pull.base.label}...${pull.head.label}`, 51 | }); 52 | if (comparison.behind_by !== 0 && pull.mergeable_state === 'behind') { 53 | console.log(`This branch is behind the target by ${comparison.behind_by} commits`) 54 | console.log('adding out-of-date comment...'); 55 | github.rest.issues.createComment({ 56 | issue_number: context.issue.number, 57 | owner: context.repo.owner, 58 | repo: context.repo.repo, 59 | body: `Hello, @${{ github.actor }}! 👋🏼 60 | This PR is not up to date with the base branch and can't be merged. 61 | Please update your branch manually with the latest version of the base branch. 62 | PRO-TIP: To request an update from the upstream branch, simply comment \`/u\` or \`/update\` and our bot will handle the update operation promptly. 63 | 64 | The only requirement for this to work is to enable [Allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) option in your PR. Also the update will not work if your fork is located in an organization, not under your personal profile. 65 | Thanks 😄` 66 | }) 67 | } 68 | 69 | add-do-not-merge-label: 70 | if: > 71 | github.event.issue.pull_request && 72 | github.event.issue.state != 'closed' && 73 | github.actor != 'asyncapi-bot' && 74 | ( 75 | contains(github.event.comment.body, '/do-not-merge') || 76 | contains(github.event.comment.body, '/dnm' ) 77 | ) 78 | runs-on: ubuntu-latest 79 | steps: 80 | - name: Add do-not-merge label 81 | uses: actions/github-script@v7 82 | with: 83 | github-token: ${{ secrets.GH_TOKEN }} 84 | script: | 85 | github.rest.issues.addLabels({ 86 | issue_number: context.issue.number, 87 | owner: context.repo.owner, 88 | repo: context.repo.repo, 89 | labels: ['do-not-merge'] 90 | }) 91 | add-autoupdate-label: 92 | if: > 93 | github.event.issue.pull_request && 94 | github.event.issue.state != 'closed' && 95 | github.actor != 'asyncapi-bot' && 96 | ( 97 | contains(github.event.comment.body, '/autoupdate') || 98 | contains(github.event.comment.body, '/au' ) 99 | ) 100 | runs-on: ubuntu-latest 101 | steps: 102 | - name: Add autoupdate label 103 | uses: actions/github-script@v7 104 | with: 105 | github-token: ${{ secrets.GH_TOKEN }} 106 | script: | 107 | github.rest.issues.addLabels({ 108 | issue_number: context.issue.number, 109 | owner: context.repo.owner, 110 | repo: context.repo.repo, 111 | labels: ['autoupdate'] 112 | }) 113 | -------------------------------------------------------------------------------- /.github/workflows/automerge-for-humans-merging.yml: -------------------------------------------------------------------------------- 1 | # This workflow is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | # Purpose of this workflow is to allow people to merge PR without a need of maintainer doing it. If all checks are in place (including maintainers approval) - JUST MERGE IT! 5 | name: Automerge For Humans 6 | 7 | on: 8 | pull_request_target: 9 | types: 10 | - labeled 11 | - unlabeled 12 | - synchronize 13 | - opened 14 | - edited 15 | - ready_for_review 16 | - reopened 17 | - unlocked 18 | 19 | jobs: 20 | automerge-for-humans: 21 | # it runs only if PR actor is not a bot, at least not a bot that we know 22 | if: | 23 | github.event.pull_request.draft == false && 24 | (github.event.pull_request.user.login != 'asyncapi-bot' || 25 | github.event.pull_request.user.login != 'dependabot[bot]' || 26 | github.event.pull_request.user.login != 'dependabot-preview[bot]') 27 | runs-on: ubuntu-latest 28 | steps: 29 | - name: Get PR authors 30 | id: authors 31 | uses: actions/github-script@v7 32 | with: 33 | script: | 34 | // Get paginated list of all commits in the PR 35 | try { 36 | const commitOpts = github.rest.pulls.listCommits.endpoint.merge({ 37 | owner: context.repo.owner, 38 | repo: context.repo.repo, 39 | pull_number: context.issue.number 40 | }); 41 | 42 | const commits = await github.paginate(commitOpts); 43 | 44 | if (commits.length === 0) { 45 | core.setFailed('No commits found in the PR'); 46 | return ''; 47 | } 48 | 49 | // Get unique authors from the commits list 50 | const authors = commits.reduce((acc, commit) => { 51 | const username = commit.author?.login || commit.commit.author?.name; 52 | if (username && !acc[username]) { 53 | acc[username] = { 54 | name: commit.commit.author?.name, 55 | email: commit.commit.author?.email, 56 | } 57 | } 58 | 59 | return acc; 60 | }, {}); 61 | 62 | return authors; 63 | } catch (error) { 64 | core.setFailed(error.message); 65 | return []; 66 | } 67 | 68 | - name: Create commit message 69 | id: create-commit-message 70 | uses: actions/github-script@v7 71 | with: 72 | script: | 73 | const authors = ${{ steps.authors.outputs.result }}; 74 | 75 | if (Object.keys(authors).length === 0) { 76 | core.setFailed('No authors found in the PR'); 77 | return ''; 78 | } 79 | 80 | // Create a string of the form "Co-authored-by: Name " 81 | // ref: https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors 82 | const coAuthors = Object.values(authors).map(author => { 83 | return `Co-authored-by: ${author.name} <${author.email}>`; 84 | }).join('\n'); 85 | 86 | core.debug(coAuthors);; 87 | 88 | return coAuthors; 89 | 90 | - name: Automerge PR 91 | uses: pascalgn/automerge-action@22948e0bc22f0aa673800da838595a3e7347e584 #v0.15.6 https://github.com/pascalgn/automerge-action/releases/tag/v0.15.6 92 | env: 93 | GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" 94 | MERGE_LABELS: "!do-not-merge,ready-to-merge" 95 | MERGE_METHOD: "squash" 96 | # Using the output of the previous step (`Co-authored-by: ...` lines) as commit description. 97 | # Important to keep 2 empty lines as https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors#creating-co-authored-commits-on-the-command-line mentions 98 | MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})\n\n\n${{ fromJSON(steps.create-commit-message.outputs.result) }}" 99 | MERGE_RETRIES: "20" 100 | MERGE_RETRY_SLEEP: "30000" 101 | -------------------------------------------------------------------------------- /.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml: -------------------------------------------------------------------------------- 1 | # This workflow is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | # Defence from evil contributor that after adding `ready-to-merge` all suddenly makes evil commit or evil change in PR title 5 | # Label is removed once above action is detected 6 | name: Remove ready-to-merge label 7 | 8 | on: 9 | pull_request_target: 10 | types: 11 | - synchronize 12 | - edited 13 | 14 | jobs: 15 | remove-ready-label: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Remove label 19 | uses: actions/github-script@v7 20 | with: 21 | github-token: ${{ secrets.GH_TOKEN }} 22 | script: | 23 | const labelToRemove = 'ready-to-merge'; 24 | const labels = context.payload.pull_request.labels; 25 | const isLabelPresent = labels.some(label => label.name === labelToRemove) 26 | if(!isLabelPresent) return; 27 | github.rest.issues.removeLabel({ 28 | issue_number: context.issue.number, 29 | owner: context.repo.owner, 30 | repo: context.repo.repo, 31 | name: labelToRemove 32 | }) 33 | -------------------------------------------------------------------------------- /.github/workflows/automerge-orphans.yml: -------------------------------------------------------------------------------- 1 | # This action is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | name: 'Notify on failing automerge' 5 | 6 | on: 7 | schedule: 8 | - cron: "0 0 * * *" 9 | 10 | jobs: 11 | identify-orphans: 12 | if: startsWith(github.repository, 'asyncapi/') 13 | name: Find orphans and notify 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout repository 17 | uses: actions/checkout@v4 18 | - name: Get list of orphans 19 | uses: actions/github-script@v7 20 | id: orphans 21 | with: 22 | github-token: ${{ secrets.GITHUB_TOKEN }} 23 | script: | 24 | const query = `query($owner:String!, $name:String!) { 25 | repository(owner:$owner, name:$name){ 26 | pullRequests(first: 100, states: OPEN){ 27 | nodes{ 28 | title 29 | url 30 | author { 31 | resourcePath 32 | } 33 | } 34 | } 35 | } 36 | }`; 37 | const variables = { 38 | owner: context.repo.owner, 39 | name: context.repo.repo 40 | }; 41 | const { repository: { pullRequests: { nodes } } } = await github.graphql(query, variables); 42 | 43 | let orphans = nodes.filter( (pr) => pr.author.resourcePath === '/asyncapi-bot' || pr.author.resourcePath === '/apps/dependabot') 44 | 45 | if (orphans.length) { 46 | core.setOutput('found', 'true'); 47 | //Yes, this is very naive approach to assume there is just one PR causing issues, there can be a case that more PRs are affected the same day 48 | //The thing is that handling multiple PRs will increase a complexity in this PR that in my opinion we should avoid 49 | //The other PRs will be reported the next day the action runs, or person that checks first url will notice the other ones 50 | core.setOutput('url', orphans[0].url); 51 | core.setOutput('title', orphans[0].title); 52 | } 53 | - if: steps.orphans.outputs.found == 'true' 54 | name: Convert markdown to slack markdown 55 | uses: asyncapi/.github/.github/actions/slackify-markdown@master 56 | id: issuemarkdown 57 | with: 58 | markdown: "-> [${{steps.orphans.outputs.title}}](${{steps.orphans.outputs.url}})" 59 | - if: steps.orphans.outputs.found == 'true' 60 | name: Send info about orphan to slack 61 | uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # Using v2.3.2 62 | env: 63 | SLACK_WEBHOOK: ${{secrets.SLACK_CI_FAIL_NOTIFY}} 64 | SLACK_TITLE: 🚨 Not merged PR that should be automerged 🚨 65 | SLACK_MESSAGE: ${{steps.issuemarkdown.outputs.text}} 66 | MSG_MINIMAL: true -------------------------------------------------------------------------------- /.github/workflows/automerge.yml: -------------------------------------------------------------------------------- 1 | # This action is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo. 3 | 4 | name: Automerge PRs from bots 5 | 6 | on: 7 | pull_request_target: 8 | types: 9 | - opened 10 | - synchronize 11 | 12 | jobs: 13 | autoapprove-for-bot: 14 | name: Autoapprove PR comming from a bot 15 | if: > 16 | contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]"]'), github.event.pull_request.user.login) && 17 | contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]"]'), github.actor) && 18 | !contains(github.event.pull_request.labels.*.name, 'released') 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: Autoapproving 22 | uses: hmarr/auto-approve-action@44888193675f29a83e04faf4002fa8c0b537b1e4 # v3.2.1 is used https://github.com/hmarr/auto-approve-action/releases/tag/v3.2.1 23 | with: 24 | github-token: "${{ secrets.GH_TOKEN_BOT_EVE }}" 25 | 26 | - name: Label autoapproved 27 | uses: actions/github-script@v7 28 | with: 29 | github-token: ${{ secrets.GH_TOKEN }} 30 | script: | 31 | github.rest.issues.addLabels({ 32 | issue_number: context.issue.number, 33 | owner: context.repo.owner, 34 | repo: context.repo.repo, 35 | labels: ['autoapproved', 'autoupdate'] 36 | }) 37 | 38 | automerge-for-bot: 39 | name: Automerge PR autoapproved by a bot 40 | needs: [autoapprove-for-bot] 41 | runs-on: ubuntu-latest 42 | steps: 43 | - name: Automerging 44 | uses: pascalgn/automerge-action@22948e0bc22f0aa673800da838595a3e7347e584 #v0.15.6 https://github.com/pascalgn/automerge-action/releases/tag/v0.15.6 45 | env: 46 | GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" 47 | GITHUB_LOGIN: asyncapi-bot 48 | MERGE_LABELS: "!do-not-merge" 49 | MERGE_METHOD: "squash" 50 | MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})" 51 | MERGE_RETRIES: "20" 52 | MERGE_RETRY_SLEEP: "30000" 53 | -------------------------------------------------------------------------------- /.github/workflows/autoupdate.yml: -------------------------------------------------------------------------------- 1 | # This action is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | # This workflow is designed to work with: 5 | # - autoapprove and automerge workflows for dependabot and asyncapibot. 6 | # - special release branches that we from time to time create in upstream repos. If we open up PRs for them from the very beginning of the release, the release branch will constantly update with new things from the destination branch they are opened against 7 | 8 | # It uses GitHub Action that auto-updates pull requests branches, whenever changes are pushed to their destination branch. 9 | # Autoupdating to latest destination branch works only in the context of upstream repo and not forks 10 | 11 | name: autoupdate 12 | 13 | on: 14 | push: 15 | branches-ignore: 16 | - 'version-bump/**' 17 | - 'dependabot/**' 18 | - 'bot/**' 19 | - 'all-contributors/**' 20 | 21 | jobs: 22 | autoupdate-for-bot: 23 | if: startsWith(github.repository, 'asyncapi/') 24 | name: Autoupdate autoapproved PR created in the upstream 25 | runs-on: ubuntu-latest 26 | steps: 27 | - name: Autoupdating 28 | uses: docker://chinthakagodawita/autoupdate-action:v1 29 | env: 30 | GITHUB_TOKEN: '${{ secrets.GH_TOKEN_BOT_EVE }}' 31 | PR_FILTER: "labelled" 32 | PR_LABELS: "autoupdate" 33 | PR_READY_STATE: "ready_for_review" 34 | MERGE_CONFLICT_ACTION: "ignore" 35 | -------------------------------------------------------------------------------- /.github/workflows/bounty-program-commands.yml: -------------------------------------------------------------------------------- 1 | # This workflow is centrally managed at https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repository, as they will be overwritten with 3 | # changes made to the same file in the abovementioned repository. 4 | 5 | # The purpose of this workflow is to allow Bounty Team members 6 | # (https://github.com/orgs/asyncapi/teams/bounty_team) to issue commands to the 7 | # organization's global AsyncAPI bot related to the Bounty Program, while at the 8 | # same time preventing unauthorized users from misusing them. 9 | 10 | name: Bounty Program commands 11 | 12 | on: 13 | issue_comment: 14 | types: 15 | - created 16 | 17 | env: 18 | BOUNTY_PROGRAM_LABELS_JSON: | 19 | [ 20 | {"name": "bounty", "color": "0e8a16", "description": "Participation in the Bounty Program"} 21 | ] 22 | 23 | jobs: 24 | guard-against-unauthorized-use: 25 | if: > 26 | github.actor != ('aeworxet' || 'thulieblack') && 27 | ( 28 | startsWith(github.event.comment.body, '/bounty' ) 29 | ) 30 | 31 | runs-on: ubuntu-latest 32 | 33 | steps: 34 | - name: ❌ @${{github.actor}} made an unauthorized attempt to use a Bounty Program's command 35 | uses: actions/github-script@v7 36 | with: 37 | github-token: ${{ secrets.GH_TOKEN }} 38 | script: | 39 | const commentText = `❌ @${{github.actor}} is not authorized to use the Bounty Program's commands. 40 | These commands can only be used by members of the [Bounty Team](https://github.com/orgs/asyncapi/teams/bounty_team).`; 41 | 42 | console.log(`❌ @${{github.actor}} made an unauthorized attempt to use a Bounty Program's command.`); 43 | github.rest.issues.createComment({ 44 | issue_number: context.issue.number, 45 | owner: context.repo.owner, 46 | repo: context.repo.repo, 47 | body: commentText 48 | }) 49 | 50 | add-label-bounty: 51 | if: > 52 | github.actor == ('aeworxet' || 'thulieblack') && 53 | ( 54 | startsWith(github.event.comment.body, '/bounty' ) 55 | ) 56 | 57 | runs-on: ubuntu-latest 58 | 59 | steps: 60 | - name: Add label `bounty` 61 | uses: actions/github-script@v7 62 | with: 63 | github-token: ${{ secrets.GH_TOKEN }} 64 | script: | 65 | const BOUNTY_PROGRAM_LABELS = JSON.parse(process.env.BOUNTY_PROGRAM_LABELS_JSON); 66 | let LIST_OF_LABELS_FOR_REPO = await github.rest.issues.listLabelsForRepo({ 67 | owner: context.repo.owner, 68 | repo: context.repo.repo, 69 | }); 70 | 71 | LIST_OF_LABELS_FOR_REPO = LIST_OF_LABELS_FOR_REPO.data.map(key => key.name); 72 | 73 | if (!LIST_OF_LABELS_FOR_REPO.includes(BOUNTY_PROGRAM_LABELS[0].name)) { 74 | await github.rest.issues.createLabel({ 75 | owner: context.repo.owner, 76 | repo: context.repo.repo, 77 | name: BOUNTY_PROGRAM_LABELS[0].name, 78 | color: BOUNTY_PROGRAM_LABELS[0].color, 79 | description: BOUNTY_PROGRAM_LABELS[0].description 80 | }); 81 | } 82 | 83 | console.log('Adding label `bounty`...'); 84 | github.rest.issues.addLabels({ 85 | issue_number: context.issue.number, 86 | owner: context.repo.owner, 87 | repo: context.repo.repo, 88 | labels: [BOUNTY_PROGRAM_LABELS[0].name] 89 | }) 90 | 91 | remove-label-bounty: 92 | if: > 93 | github.actor == ('aeworxet' || 'thulieblack') && 94 | ( 95 | startsWith(github.event.comment.body, '/unbounty' ) 96 | ) 97 | 98 | runs-on: ubuntu-latest 99 | 100 | steps: 101 | - name: Remove label `bounty` 102 | uses: actions/github-script@v7 103 | with: 104 | github-token: ${{ secrets.GH_TOKEN }} 105 | script: | 106 | const BOUNTY_PROGRAM_LABELS = JSON.parse(process.env.BOUNTY_PROGRAM_LABELS_JSON); 107 | let LIST_OF_LABELS_FOR_ISSUE = await github.rest.issues.listLabelsOnIssue({ 108 | owner: context.repo.owner, 109 | repo: context.repo.repo, 110 | issue_number: context.issue.number, 111 | }); 112 | 113 | LIST_OF_LABELS_FOR_ISSUE = LIST_OF_LABELS_FOR_ISSUE.data.map(key => key.name); 114 | 115 | if (LIST_OF_LABELS_FOR_ISSUE.includes(BOUNTY_PROGRAM_LABELS[0].name)) { 116 | console.log('Removing label `bounty`...'); 117 | github.rest.issues.removeLabel({ 118 | issue_number: context.issue.number, 119 | owner: context.repo.owner, 120 | repo: context.repo.repo, 121 | name: [BOUNTY_PROGRAM_LABELS[0].name] 122 | }) 123 | } 124 | -------------------------------------------------------------------------------- /.github/workflows/bump.yml: -------------------------------------------------------------------------------- 1 | # This action is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | # Purpose of this action is to update npm package in libraries that use it. It is like dependabot for asyncapi npm modules only. 5 | # It runs in a repo after merge of release commit and searches for other packages that use released package. Every found package gets updated with lates version 6 | 7 | name: Bump package version in dependent repos - if Node project 8 | 9 | on: 10 | # It cannot run on release event as when release is created then version is not yet bumped in package.json 11 | # This means we cannot extract easily latest version and have a risk that package is not yet on npm 12 | push: 13 | branches: 14 | - master 15 | 16 | jobs: 17 | bump-in-dependent-projects: 18 | name: Bump this package in repositories that depend on it 19 | if: startsWith(github.event.commits[0].message, 'chore(release):') 20 | runs-on: ubuntu-latest 21 | steps: 22 | - name: Checkout repo 23 | uses: actions/checkout@v4 24 | - name: Check if Node.js project and has package.json 25 | id: packagejson 26 | run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT 27 | - if: steps.packagejson.outputs.exists == 'true' 28 | name: Bumping latest version of this package in other repositories 29 | uses: derberg/npm-dependency-manager-for-your-github-org@1eafd3bf3974f21d395c1abac855cb04b295d570 # using v6.-.- https://github.com/derberg/npm-dependency-manager-for-your-github-org/releases/tag/v6 30 | with: 31 | github_token: ${{ secrets.GH_TOKEN }} 32 | committer_username: asyncapi-bot 33 | committer_email: info@asyncapi.io 34 | repos_to_ignore: spec,bindings,saunter,server-api 35 | custom_id: "dependency update from asyncapi bot" 36 | -------------------------------------------------------------------------------- /.github/workflows/help-command.yml: -------------------------------------------------------------------------------- 1 | # This workflow is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | name: Create help comment 5 | 6 | on: 7 | issue_comment: 8 | types: 9 | - created 10 | 11 | jobs: 12 | create_help_comment_pr: 13 | if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '/help') && github.actor != 'asyncapi-bot' }} 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Add comment to PR 17 | uses: actions/github-script@v7 18 | with: 19 | github-token: ${{ secrets.GH_TOKEN }} 20 | script: | 21 | //Yes to add comment to PR the same endpoint is use that we use to create a comment in issue 22 | //For more details http://developer.github.com/v3/issues/comments/ 23 | //Also proved by this action https://github.com/actions-ecosystem/action-create-comment/blob/main/src/main.ts 24 | github.rest.issues.createComment({ 25 | issue_number: context.issue.number, 26 | owner: context.repo.owner, 27 | repo: context.repo.repo, 28 | body: `Hello, @${{ github.actor }}! 👋🏼 29 | 30 | I'm 🧞🧞🧞 Genie 🧞🧞🧞 from the magic lamp. Looks like somebody needs a hand! 31 | 32 | At the moment the following comments are supported in pull requests: 33 | 34 | - \`/please-take-a-look\` or \`/ptal\` - This comment will add a comment to the PR asking for attention from the reviewrs who have not reviewed the PR yet. 35 | - \`/ready-to-merge\` or \`/rtm\` - This comment will trigger automerge of PR in case all required checks are green, approvals in place and do-not-merge label is not added 36 | - \`/do-not-merge\` or \`/dnm\` - This comment will block automerging even if all conditions are met and ready-to-merge label is added 37 | - \`/autoupdate\` or \`/au\` - This comment will add \`autoupdate\` label to the PR and keeps your PR up-to-date to the target branch's future changes. Unless there is a merge conflict or it is a draft PR. (Currently only works for upstream branches.) 38 | - \`/update\` or \`/u\` - This comment will update the PR with the latest changes from the target branch. Unless there is a merge conflict or it is a draft PR. NOTE: this only updates the PR once, so if you need to update again, you need to call the command again.` 39 | }) 40 | 41 | create_help_comment_issue: 42 | if: ${{ !github.event.issue.pull_request && startsWith(github.event.comment.body, '/help') && github.actor != 'asyncapi-bot' }} 43 | runs-on: ubuntu-latest 44 | steps: 45 | - name: Add comment to Issue 46 | uses: actions/github-script@v7 47 | with: 48 | github-token: ${{ secrets.GH_TOKEN }} 49 | script: | 50 | github.rest.issues.createComment({ 51 | issue_number: context.issue.number, 52 | owner: context.repo.owner, 53 | repo: context.repo.repo, 54 | body: `Hello, @${{ github.actor }}! 👋🏼 55 | 56 | I'm 🧞🧞🧞 Genie 🧞🧞🧞 from the magic lamp. Looks like somebody needs a hand! 57 | 58 | At the moment the following comments are supported in issues: 59 | 60 | - \`/good-first-issue {js | ts | java | go | docs | design | ci-cd}\` or \`/gfi {js | ts | java | go | docs | design | ci-cd}\` - label an issue as a \`good first issue\`. 61 | example: \`/gfi js\` or \`/good-first-issue ci-cd\` 62 | - \`/transfer-issue {repo-name}\` or \`/ti {repo-name}\` - transfer issue from the source repository to the other repository passed by the user. example: \`/ti cli\` or \`/transfer-issue cli\`.` 63 | }) -------------------------------------------------------------------------------- /.github/workflows/if-nodejs-pr-testing.yml: -------------------------------------------------------------------------------- 1 | # This action is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | # It does magic only if there is package.json file in the root of the project 5 | name: PR testing - if Node project 6 | 7 | on: 8 | pull_request: 9 | types: [opened, reopened, synchronize, ready_for_review] 10 | 11 | jobs: 12 | test-nodejs-pr: 13 | name: Test NodeJS PR - ${{ matrix.os }} 14 | runs-on: ${{ matrix.os }} 15 | strategy: 16 | matrix: 17 | # Using macos-13 instead of latest (macos-14) due to an issue with Puppeteer and such runner. 18 | # See: https://github.com/puppeteer/puppeteer/issues/12327 and https://github.com/asyncapi/parser-js/issues/1001 19 | os: [ubuntu-latest, macos-13, windows-latest] 20 | steps: 21 | - if: > 22 | !github.event.pull_request.draft && !( 23 | (github.actor == 'asyncapi-bot' && ( 24 | startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') || 25 | startsWith(github.event.pull_request.title, 'chore(release):') 26 | )) || 27 | (github.actor == 'asyncapi-bot-eve' && ( 28 | startsWith(github.event.pull_request.title, 'ci: update of files from global .github repo') || 29 | startsWith(github.event.pull_request.title, 'chore(release):') 30 | )) || 31 | (github.actor == 'allcontributors[bot]' && 32 | startsWith(github.event.pull_request.title, 'docs: add') 33 | ) 34 | ) 35 | id: should_run 36 | name: Should Run 37 | run: echo "shouldrun=true" >> $GITHUB_OUTPUT 38 | shell: bash 39 | - if: steps.should_run.outputs.shouldrun == 'true' 40 | name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows 41 | run: | 42 | git config --global core.autocrlf false 43 | git config --global core.eol lf 44 | shell: bash 45 | - if: steps.should_run.outputs.shouldrun == 'true' 46 | name: Checkout repository 47 | uses: actions/checkout@v4 48 | - if: steps.should_run.outputs.shouldrun == 'true' 49 | name: Check if Node.js project and has package.json 50 | id: packagejson 51 | run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT 52 | shell: bash 53 | - if: steps.packagejson.outputs.exists == 'true' 54 | name: Check package-lock version 55 | uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master 56 | id: lockversion 57 | - if: steps.packagejson.outputs.exists == 'true' 58 | name: Setup Node.js 59 | uses: actions/setup-node@v4 60 | with: 61 | node-version: "${{ steps.lockversion.outputs.version }}" 62 | - if: steps.lockversion.outputs.version == '18' && matrix.os == 'windows-latest' 63 | #npm cli 10 is buggy because of some cache issue 64 | name: Install npm cli 8 65 | shell: bash 66 | run: npm install -g npm@8.19.4 67 | - if: steps.packagejson.outputs.exists == 'true' 68 | name: Install dependencies 69 | shell: bash 70 | run: npm ci 71 | - if: steps.packagejson.outputs.exists == 'true' 72 | name: Test 73 | run: npm test --if-present 74 | - if: steps.packagejson.outputs.exists == 'true' && matrix.os == 'ubuntu-latest' 75 | #linting should run just one and not on all possible operating systems 76 | name: Run linter 77 | run: npm run lint --if-present 78 | - if: steps.packagejson.outputs.exists == 'true' 79 | name: Run release assets generation to make sure PR does not break it 80 | shell: bash 81 | run: npm run generate:assets --if-present 82 | -------------------------------------------------------------------------------- /.github/workflows/if-nodejs-release.yml: -------------------------------------------------------------------------------- 1 | # This action is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | # It does magic only if there is package.json file in the root of the project 5 | name: Release - if Node project 6 | 7 | on: 8 | push: 9 | branches: 10 | - master 11 | # below lines are not enough to have release supported for these branches 12 | # make sure configuration of `semantic-release` package mentions these branches 13 | - next-spec 14 | - next-major 15 | - next-major-spec 16 | - beta 17 | - alpha 18 | - next 19 | 20 | jobs: 21 | 22 | test-nodejs: 23 | # We just check the message of first commit as there is always just one commit because we squash into one before merging 24 | # "commits" contains array of objects where one of the properties is commit "message" 25 | # Release workflow will be skipped if release conventional commits are not used 26 | if: | 27 | startsWith( github.repository, 'asyncapi/' ) && 28 | (startsWith( github.event.commits[0].message , 'fix:' ) || 29 | startsWith( github.event.commits[0].message, 'fix!:' ) || 30 | startsWith( github.event.commits[0].message, 'feat:' ) || 31 | startsWith( github.event.commits[0].message, 'feat!:' )) 32 | name: Test NodeJS release on ${{ matrix.os }} 33 | runs-on: ${{ matrix.os }} 34 | strategy: 35 | matrix: 36 | # Using macos-13 instead of latest (macos-14) due to an issue with Puppeteer and such runner. 37 | # See: https://github.com/puppeteer/puppeteer/issues/12327 and https://github.com/asyncapi/parser-js/issues/1001 38 | os: [ubuntu-latest, macos-13, windows-latest] 39 | steps: 40 | - name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows 41 | run: | 42 | git config --global core.autocrlf false 43 | git config --global core.eol lf 44 | shell: bash 45 | - name: Checkout repository 46 | uses: actions/checkout@v4 47 | - name: Check if Node.js project and has package.json 48 | id: packagejson 49 | run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT 50 | shell: bash 51 | - if: steps.packagejson.outputs.exists == 'true' 52 | name: Check package-lock version 53 | uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master 54 | id: lockversion 55 | - if: steps.packagejson.outputs.exists == 'true' 56 | name: Setup Node.js 57 | uses: actions/setup-node@v4 58 | with: 59 | node-version: "${{ steps.lockversion.outputs.version }}" 60 | - if: steps.lockversion.outputs.version == '18' && matrix.os == 'windows-latest' 61 | name: Install npm cli 8 62 | shell: bash 63 | #npm cli 10 is buggy because of some cache issues 64 | run: npm install -g npm@8.19.4 65 | - if: steps.packagejson.outputs.exists == 'true' 66 | name: Install dependencies 67 | shell: bash 68 | run: npm ci 69 | - if: steps.packagejson.outputs.exists == 'true' 70 | name: Run test 71 | run: npm test --if-present 72 | - if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel 73 | name: Report workflow run status to Slack 74 | uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 #using https://github.com/8398a7/action-slack/releases/tag/v3.16.2 75 | with: 76 | status: ${{ job.status }} 77 | fields: repo,action,workflow 78 | text: 'Release workflow failed in testing job' 79 | env: 80 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} 81 | 82 | release: 83 | needs: [test-nodejs] 84 | name: Publish to any of NPM, Github, or Docker Hub 85 | runs-on: ubuntu-latest 86 | steps: 87 | - name: Set git to use LF #to once and for all finish neverending fight between Unix and Windows 88 | run: | 89 | git config --global core.autocrlf false 90 | git config --global core.eol lf 91 | - name: Checkout repository 92 | uses: actions/checkout@v4 93 | - name: Check if Node.js project and has package.json 94 | id: packagejson 95 | run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT 96 | shell: bash 97 | - if: steps.packagejson.outputs.exists == 'true' 98 | name: Check package-lock version 99 | uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master 100 | id: lockversion 101 | - if: steps.packagejson.outputs.exists == 'true' 102 | name: Setup Node.js 103 | uses: actions/setup-node@v4 104 | with: 105 | node-version: "${{ steps.lockversion.outputs.version }}" 106 | - if: steps.packagejson.outputs.exists == 'true' 107 | name: Install dependencies 108 | shell: bash 109 | run: npm ci 110 | - if: steps.packagejson.outputs.exists == 'true' 111 | name: Add plugin for conventional commits for semantic-release 112 | run: npm install --save-dev conventional-changelog-conventionalcommits@5.0.0 113 | - if: steps.packagejson.outputs.exists == 'true' 114 | name: Publish to any of NPM, Github, and Docker Hub 115 | id: release 116 | env: 117 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} 118 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 119 | DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} 120 | DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} 121 | GIT_AUTHOR_NAME: asyncapi-bot 122 | GIT_AUTHOR_EMAIL: info@asyncapi.io 123 | GIT_COMMITTER_NAME: asyncapi-bot 124 | GIT_COMMITTER_EMAIL: info@asyncapi.io 125 | run: npx semantic-release@19.0.4 126 | - if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel 127 | name: Report workflow run status to Slack 128 | uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 #using https://github.com/8398a7/action-slack/releases/tag/v3.16.2 129 | with: 130 | status: ${{ job.status }} 131 | fields: repo,action,workflow 132 | text: 'Release workflow failed in release job' 133 | env: 134 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} 135 | -------------------------------------------------------------------------------- /.github/workflows/if-nodejs-version-bump.yml: -------------------------------------------------------------------------------- 1 | # This action is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | # It does magic only if there is package.json file in the root of the project 5 | name: Version bump - if Node.js project 6 | 7 | on: 8 | release: 9 | types: 10 | - published 11 | 12 | jobs: 13 | version_bump: 14 | name: Generate assets and bump NodeJS 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout repository 18 | uses: actions/checkout@v4 19 | with: 20 | # target branch of release. More info https://docs.github.com/en/rest/reference/repos#releases 21 | # in case release is created from release branch then we need to checkout from given branch 22 | # if @semantic-release/github is used to publish, the minimum version is 7.2.0 for proper working 23 | ref: ${{ github.event.release.target_commitish }} 24 | - name: Check if Node.js project and has package.json 25 | id: packagejson 26 | run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT 27 | - if: steps.packagejson.outputs.exists == 'true' 28 | name: Check package-lock version 29 | uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master 30 | id: lockversion 31 | - if: steps.packagejson.outputs.exists == 'true' 32 | name: Setup Node.js 33 | uses: actions/setup-node@v4 34 | with: 35 | node-version: "${{ steps.lockversion.outputs.version }}" 36 | cache: 'npm' 37 | cache-dependency-path: '**/package-lock.json' 38 | - if: steps.packagejson.outputs.exists == 'true' 39 | name: Install dependencies 40 | run: npm ci 41 | - if: steps.packagejson.outputs.exists == 'true' 42 | name: Assets generation 43 | run: npm run generate:assets --if-present 44 | - if: steps.packagejson.outputs.exists == 'true' 45 | name: Bump version in package.json 46 | # There is no need to substract "v" from the tag as version script handles it 47 | # When adding "bump:version" script in package.json, make sure no tags are added by default (--no-git-tag-version) as they are already added by release workflow 48 | # When adding "bump:version" script in package.json, make sure --allow-same-version is set in case someone forgot and updated package.json manually and we want to avoide this action to fail and raise confusion 49 | run: VERSION=${{github.event.release.tag_name}} npm run bump:version 50 | - if: steps.packagejson.outputs.exists == 'true' 51 | name: Create Pull Request with updated asset files including package.json 52 | uses: peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54 # use 4.2.4 https://github.com/peter-evans/create-pull-request/releases/tag/v4.2.4 53 | with: 54 | token: ${{ secrets.GH_TOKEN }} 55 | commit-message: 'chore(release): ${{github.event.release.tag_name}}' 56 | committer: asyncapi-bot 57 | author: asyncapi-bot 58 | title: 'chore(release): ${{github.event.release.tag_name}}' 59 | body: 'Version bump in package.json for release [${{github.event.release.tag_name}}](${{github.event.release.html_url}})' 60 | branch: version-bump/${{github.event.release.tag_name}} 61 | - if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel 62 | name: Report workflow run status to Slack 63 | uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 #using https://github.com/8398a7/action-slack/releases/tag/v3.16.2 64 | with: 65 | status: ${{ job.status }} 66 | fields: repo,action,workflow 67 | text: 'Unable to bump the version in package.json after the release' 68 | env: 69 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} -------------------------------------------------------------------------------- /.github/workflows/issues-prs-notifications.yml: -------------------------------------------------------------------------------- 1 | # This action is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | # This action notifies community on slack whenever there is a new issue, PR or discussion started in given repository 5 | name: Notify slack 6 | 7 | on: 8 | issues: 9 | types: [opened, reopened] 10 | 11 | pull_request_target: 12 | types: [opened, reopened, ready_for_review] 13 | 14 | discussion: 15 | types: [created] 16 | 17 | jobs: 18 | issue: 19 | if: github.event_name == 'issues' && github.actor != 'asyncapi-bot' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' 20 | name: Notify slack on every new issue 21 | runs-on: ubuntu-latest 22 | steps: 23 | - name: Convert markdown to slack markdown for issue 24 | uses: asyncapi/.github/.github/actions/slackify-markdown@master 25 | id: issuemarkdown 26 | with: 27 | markdown: "[${{github.event.issue.title}}](${{github.event.issue.html_url}}) \n ${{github.event.issue.body}}" 28 | - name: Send info about issue 29 | uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # Using v2.3.2 30 | env: 31 | SLACK_WEBHOOK: ${{secrets.SLACK_GITHUB_NEWISSUEPR}} 32 | SLACK_TITLE: 🐛 New Issue in ${{github.repository}} 🐛 33 | SLACK_MESSAGE: ${{steps.issuemarkdown.outputs.text}} 34 | MSG_MINIMAL: true 35 | 36 | pull_request: 37 | if: github.event_name == 'pull_request_target' && github.actor != 'asyncapi-bot' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' 38 | name: Notify slack on every new pull request 39 | runs-on: ubuntu-latest 40 | steps: 41 | - name: Convert markdown to slack markdown for pull request 42 | uses: asyncapi/.github/.github/actions/slackify-markdown@master 43 | id: prmarkdown 44 | with: 45 | markdown: "[${{github.event.pull_request.title}}](${{github.event.pull_request.html_url}}) \n ${{github.event.pull_request.body}}" 46 | - name: Send info about pull request 47 | uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # Using v2.3.2 48 | env: 49 | SLACK_WEBHOOK: ${{secrets.SLACK_GITHUB_NEWISSUEPR}} 50 | SLACK_TITLE: 💪 New Pull Request in ${{github.repository}} 💪 51 | SLACK_MESSAGE: ${{steps.prmarkdown.outputs.text}} 52 | MSG_MINIMAL: true 53 | 54 | discussion: 55 | if: github.event_name == 'discussion' && github.actor != 'asyncapi-bot' && github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' 56 | name: Notify slack on every new pull request 57 | runs-on: ubuntu-latest 58 | steps: 59 | - name: Convert markdown to slack markdown for pull request 60 | uses: asyncapi/.github/.github/actions/slackify-markdown@master 61 | id: discussionmarkdown 62 | with: 63 | markdown: "[${{github.event.discussion.title}}](${{github.event.discussion.html_url}}) \n ${{github.event.discussion.body}}" 64 | - name: Send info about pull request 65 | uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # Using v2.3.2 66 | env: 67 | SLACK_WEBHOOK: ${{secrets.SLACK_GITHUB_NEWISSUEPR}} 68 | SLACK_TITLE: 💬 New Discussion in ${{github.repository}} 💬 69 | SLACK_MESSAGE: ${{steps.discussionmarkdown.outputs.text}} 70 | MSG_MINIMAL: true 71 | -------------------------------------------------------------------------------- /.github/workflows/lint-pr-title.yml: -------------------------------------------------------------------------------- 1 | # This action is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | name: Lint PR title 5 | 6 | on: 7 | pull_request_target: 8 | types: [opened, reopened, synchronize, edited, ready_for_review] 9 | 10 | jobs: 11 | lint-pr-title: 12 | name: Lint PR title 13 | runs-on: ubuntu-latest 14 | steps: 15 | # Since this workflow is REQUIRED for a PR to be mergable, we have to have this 'if' statement in step level instead of job level. 16 | - if: ${{ !contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors[bot]"]'), github.actor) }} 17 | uses: amannn/action-semantic-pull-request@c3cd5d1ea3580753008872425915e343e351ab54 #version 5.2.0 https://github.com/amannn/action-semantic-pull-request/releases/tag/v5.2.0 18 | id: lint_pr_title 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN}} 21 | with: 22 | subjectPattern: ^(?![A-Z]).+$ 23 | subjectPatternError: | 24 | The subject "{subject}" found in the pull request title "{title}" should start with a lowercase character. 25 | 26 | # Comments the error message from the above lint_pr_title action 27 | - if: ${{ always() && steps.lint_pr_title.outputs.error_message != null && !contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors[bot]"]'), github.actor)}} 28 | name: Comment on PR 29 | uses: marocchino/sticky-pull-request-comment@3d60a5b2dae89d44e0c6ddc69dd7536aec2071cd #use 2.5.0 https://github.com/marocchino/sticky-pull-request-comment/releases/tag/v2.5.0 30 | with: 31 | header: pr-title-lint-error 32 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN}} 33 | message: | 34 | 35 | We require all PRs to follow [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). 36 | More details 👇🏼 37 | ``` 38 | ${{ steps.lint_pr_title.outputs.error_message}} 39 | ``` 40 | # deletes the error comment if the title is correct 41 | - if: ${{ steps.lint_pr_title.outputs.error_message == null }} 42 | name: delete the comment 43 | uses: marocchino/sticky-pull-request-comment@3d60a5b2dae89d44e0c6ddc69dd7536aec2071cd #use 2.5.0 https://github.com/marocchino/sticky-pull-request-comment/releases/tag/v2.5.0 44 | with: 45 | header: pr-title-lint-error 46 | delete: true 47 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN}} 48 | -------------------------------------------------------------------------------- /.github/workflows/please-take-a-look-command.yml: -------------------------------------------------------------------------------- 1 | # This action is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | # It uses Github actions to listen for comments on issues and pull requests and 5 | # if the comment contains /please-take-a-look or /ptal it will add a comment pinging 6 | # the code-owners who are reviewers for PR 7 | 8 | name: Please take a Look 9 | 10 | on: 11 | issue_comment: 12 | types: [created] 13 | 14 | jobs: 15 | ping-for-attention: 16 | if: > 17 | github.event.issue.pull_request && 18 | github.event.issue.state != 'closed' && 19 | github.actor != 'asyncapi-bot' && 20 | ( 21 | contains(github.event.comment.body, '/please-take-a-look') || 22 | contains(github.event.comment.body, '/ptal') || 23 | contains(github.event.comment.body, '/PTAL') 24 | ) 25 | runs-on: ubuntu-latest 26 | steps: 27 | - name: Check for Please Take a Look Command 28 | uses: actions/github-script@v7 29 | with: 30 | github-token: ${{ secrets.GH_TOKEN }} 31 | script: | 32 | const prDetailsUrl = context.payload.issue.pull_request.url; 33 | const { data: pull } = await github.request(prDetailsUrl); 34 | const reviewers = pull.requested_reviewers.map(reviewer => reviewer.login); 35 | 36 | const { data: reviews } = await github.rest.pulls.listReviews({ 37 | owner: context.repo.owner, 38 | repo: context.repo.repo, 39 | pull_number: context.issue.number 40 | }); 41 | 42 | const reviewersWhoHaveReviewed = reviews.map(review => review.user.login); 43 | 44 | const reviewersWhoHaveNotReviewed = reviewers.filter(reviewer => !reviewersWhoHaveReviewed.includes(reviewer)); 45 | 46 | if (reviewersWhoHaveNotReviewed.length > 0) { 47 | const comment = reviewersWhoHaveNotReviewed.filter(reviewer => reviewer !== 'asyncapi-bot-eve' ).map(reviewer => `@${reviewer}`).join(' '); 48 | await github.rest.issues.createComment({ 49 | issue_number: context.issue.number, 50 | owner: context.repo.owner, 51 | repo: context.repo.repo, 52 | body: `${comment} Please take a look at this PR. Thanks! :wave:` 53 | }); 54 | } 55 | -------------------------------------------------------------------------------- /.github/workflows/release-announcements.yml: -------------------------------------------------------------------------------- 1 | # This action is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | name: 'Announce releases in different channels' 5 | 6 | on: 7 | release: 8 | types: 9 | - published 10 | 11 | jobs: 12 | 13 | slack-announce: 14 | name: Slack - notify on every release 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout repository 18 | uses: actions/checkout@v4 19 | - name: Convert markdown to slack markdown for issue 20 | uses: asyncapi/.github/.github/actions/slackify-markdown@master 21 | id: markdown 22 | with: 23 | markdown: "[${{github.event.release.tag_name}}](${{github.event.release.html_url}}) \n ${{ github.event.release.body }}" 24 | - name: Send info about release to Slack 25 | uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # Using v2.3.2 26 | env: 27 | SLACK_WEBHOOK: ${{ secrets.SLACK_RELEASES }} 28 | SLACK_TITLE: Release ${{github.event.release.tag_name}} for ${{github.repository}} is out in the wild 😱💪🍾🎂 29 | SLACK_MESSAGE: ${{steps.markdown.outputs.text}} 30 | MSG_MINIMAL: true 31 | 32 | twitter-announce: 33 | name: Twitter - notify on minor and major releases 34 | runs-on: ubuntu-latest 35 | steps: 36 | - name: Checkout repo 37 | uses: actions/checkout@v4 38 | - name: Get version of last and previous release 39 | uses: actions/github-script@v7 40 | id: versions 41 | with: 42 | github-token: ${{ secrets.GITHUB_TOKEN }} 43 | script: | 44 | const query = `query($owner:String!, $name:String!) { 45 | repository(owner:$owner, name:$name){ 46 | releases(first: 2, orderBy: {field: CREATED_AT, direction: DESC}) { 47 | nodes { 48 | name 49 | } 50 | } 51 | } 52 | }`; 53 | const variables = { 54 | owner: context.repo.owner, 55 | name: context.repo.repo 56 | }; 57 | const { repository: { releases: { nodes } } } = await github.graphql(query, variables); 58 | core.setOutput('lastver', nodes[0].name); 59 | // In case of first release in the package, there is no such thing as previous error, so we set info about previous version only once we have it 60 | // We should tweet about the release no matter of the type as it is initial release 61 | if (nodes.length != 1) core.setOutput('previousver', nodes[1].name); 62 | - name: Identify release type 63 | id: releasetype 64 | # if previousver is not provided then this steps just logs information about missing version, no errors 65 | run: echo "type=$(npx -q -p semver-diff-cli semver-diff ${{steps.versions.outputs.previousver}} ${{steps.versions.outputs.lastver}})" >> $GITHUB_OUTPUT 66 | - name: Get name of the person that is behind the newly released version 67 | id: author 68 | run: echo "name=$(git log -1 --pretty=format:'%an')" >> $GITHUB_OUTPUT 69 | - name: Publish information about the release to Twitter # tweet only if detected version change is not a patch 70 | # tweet goes out even if the type is not major or minor but "You need provide version number to compare." 71 | # it is ok, it just means we did not identify previous version as we are tweeting out information about the release for the first time 72 | if: steps.releasetype.outputs.type != 'null' && steps.releasetype.outputs.type != 'patch' # null means that versions are the same 73 | uses: m1ner79/Github-Twittction@d1e508b6c2170145127138f93c49b7c46c6ff3a7 # using 2.0.0 https://github.com/m1ner79/Github-Twittction/releases/tag/v2.0.0 74 | with: 75 | twitter_status: "Release ${{github.event.release.tag_name}} for ${{github.repository}} is out in the wild 😱💪🍾🎂\n\nThank you for the contribution ${{ steps.author.outputs.name }} ${{github.event.release.html_url}}" 76 | twitter_consumer_key: ${{ secrets.TWITTER_CONSUMER_KEY }} 77 | twitter_consumer_secret: ${{ secrets.TWITTER_CONSUMER_SECRET }} 78 | twitter_access_token_key: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }} 79 | twitter_access_token_secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} -------------------------------------------------------------------------------- /.github/workflows/scripts/README.md: -------------------------------------------------------------------------------- 1 | The entire `scripts` directory is centrally managed in [.github](https://github.com/asyncapi/.github/) repository. Any changes in this folder should be done in central repository. -------------------------------------------------------------------------------- /.github/workflows/scripts/mailchimp/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This code is centrally managed in https://github.com/asyncapi/.github/ 3 | * Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 4 | */ 5 | const mailchimp = require('@mailchimp/mailchimp_marketing'); 6 | const core = require('@actions/core'); 7 | const htmlContent = require('./htmlContent.js'); 8 | 9 | /** 10 | * Sending API request to mailchimp to schedule email to subscribers 11 | * Input is the URL to issue/discussion or other resource 12 | */ 13 | module.exports = async (link, title) => { 14 | 15 | let newCampaign; 16 | 17 | mailchimp.setConfig({ 18 | apiKey: process.env.MAILCHIMP_API_KEY, 19 | server: 'us12' 20 | }); 21 | 22 | /* 23 | * First we create campaign 24 | */ 25 | try { 26 | newCampaign = await mailchimp.campaigns.create({ 27 | type: 'regular', 28 | recipients: { 29 | list_id: '6e3e437abe', 30 | segment_opts: { 31 | match: 'any', 32 | conditions: [{ 33 | condition_type: 'Interests', 34 | field: 'interests-2801e38b9f', 35 | op: 'interestcontains', 36 | value: ['f7204f9b90'] 37 | }] 38 | } 39 | }, 40 | settings: { 41 | subject_line: `TSC attention required: ${ title }`, 42 | preview_text: 'Check out the latest topic that TSC members have to be aware of', 43 | title: `New topic info - ${ new Date(Date.now()).toUTCString()}`, 44 | from_name: 'AsyncAPI Initiative', 45 | reply_to: 'info@asyncapi.io', 46 | } 47 | }); 48 | } catch (error) { 49 | return core.setFailed(`Failed creating campaign: ${ JSON.stringify(error) }`); 50 | } 51 | 52 | /* 53 | * Content of the email is added separately after campaign creation 54 | */ 55 | try { 56 | await mailchimp.campaigns.setContent(newCampaign.id, { html: htmlContent(link, title) }); 57 | } catch (error) { 58 | return core.setFailed(`Failed adding content to campaign: ${ JSON.stringify(error) }`); 59 | } 60 | 61 | /* 62 | * We schedule an email to send it immediately 63 | */ 64 | try { 65 | //schedule for next hour 66 | //so if this code was created by new issue creation at 9:46, the email is scheduled for 10:00 67 | //is it like this as schedule has limitiations and you cannot schedule email for 9:48 68 | const scheduleDate = new Date(Date.parse(new Date(Date.now()).toISOString()) + 1 * 1 * 60 * 60 * 1000); 69 | scheduleDate.setUTCMinutes(00); 70 | 71 | await mailchimp.campaigns.schedule(newCampaign.id, { 72 | schedule_time: scheduleDate.toISOString(), 73 | }); 74 | } catch (error) { 75 | return core.setFailed(`Failed scheduling email: ${ JSON.stringify(error) }`); 76 | } 77 | 78 | core.info(`New email campaign created`); 79 | } -------------------------------------------------------------------------------- /.github/workflows/scripts/mailchimp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "schedule-email", 3 | "description": "This code is responsible for scheduling an email campaign. This file is centrally managed in https://github.com/asyncapi/.github/", 4 | "license": "Apache 2.0", 5 | "dependencies": { 6 | "@actions/core": "1.6.0", 7 | "@mailchimp/mailchimp_marketing": "3.0.74" 8 | } 9 | } -------------------------------------------------------------------------------- /.github/workflows/stale-issues-prs.yml: -------------------------------------------------------------------------------- 1 | # This action is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | name: Manage stale issues and PRs 5 | 6 | on: 7 | schedule: 8 | - cron: "0 0 * * *" 9 | 10 | jobs: 11 | stale: 12 | if: startsWith(github.repository, 'asyncapi/') 13 | name: Mark issue or PR as stale 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 #v9.1.0 but pointing to commit for security reasons 17 | with: 18 | repo-token: ${{ secrets.GITHUB_TOKEN }} 19 | stale-issue-message: | 20 | This issue has been automatically marked as stale because it has not had recent activity :sleeping: 21 | 22 | It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. 23 | 24 | There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under [open governance model](https://github.com/asyncapi/community/blob/master/CHARTER.md). 25 | 26 | Let us figure out together how to push this issue forward. Connect with us through [one of many communication channels](https://github.com/asyncapi/community/issues/1) we established here. 27 | 28 | Thank you for your patience :heart: 29 | stale-pr-message: | 30 | This pull request has been automatically marked as stale because it has not had recent activity :sleeping: 31 | 32 | It will be closed in 120 days if no further activity occurs. To unstale this pull request, add a comment with detailed explanation. 33 | 34 | There can be many reasons why some specific pull request has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under [open governance model](https://github.com/asyncapi/community/blob/master/CHARTER.md). 35 | 36 | Let us figure out together how to push this pull request forward. Connect with us through [one of many communication channels](https://github.com/asyncapi/community/issues/1) we established here. 37 | 38 | Thank you for your patience :heart: 39 | days-before-stale: 120 40 | days-before-close: 120 41 | stale-issue-label: stale 42 | stale-pr-label: stale 43 | exempt-issue-labels: keep-open 44 | exempt-pr-labels: keep-open 45 | close-issue-reason: not_planned 46 | -------------------------------------------------------------------------------- /.github/workflows/transfer-issue.yml: -------------------------------------------------------------------------------- 1 | # This action is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | name: Transfer Issues between repositories 5 | 6 | on: 7 | issue_comment: 8 | types: 9 | - created 10 | 11 | permissions: 12 | issues: write 13 | 14 | jobs: 15 | transfer: 16 | if: ${{(!github.event.issue.pull_request && github.event.issue.state != 'closed' && github.actor != 'asyncapi-bot') && (startsWith(github.event.comment.body, '/transfer-issue') || startsWith(github.event.comment.body, '/ti'))}} 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Checkout Repository 20 | uses: actions/checkout@v4 21 | - name: Extract Input 22 | id: extract_step 23 | env: 24 | COMMENT: "${{ github.event.comment.body }}" 25 | run: | 26 | REPO=$(echo $COMMENT | awk '{print $2}') 27 | echo repo=$REPO >> $GITHUB_OUTPUT 28 | - name: Check Repo 29 | uses: actions/github-script@v7 30 | with: 31 | github-token: ${{secrets.GH_TOKEN}} 32 | script: | 33 | const r = "${{github.repository}}" 34 | const [owner, repo] = r.split('/') 35 | const repoToMove = process.env.REPO_TO_MOVE 36 | const issue_number = context.issue.number 37 | try { 38 | const {data} = await github.rest.repos.get({ 39 | owner, 40 | repo: repoToMove 41 | }) 42 | }catch (e) { 43 | const body = `${repoToMove} is not a repo under ${owner}. You can only transfer issue to repos that belong to the same organization.` 44 | await github.rest.issues.createComment({ 45 | owner, 46 | repo, 47 | issue_number, 48 | body 49 | }) 50 | process.exit(1) 51 | } 52 | env: 53 | REPO_TO_MOVE: ${{steps.extract_step.outputs.repo}} 54 | - name: Transfer Issue 55 | id: transferIssue 56 | working-directory: ./ 57 | run: | 58 | gh issue transfer ${{github.event.issue.number}} asyncapi/${{steps.extract_step.outputs.repo}} 59 | env: 60 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 61 | 62 | -------------------------------------------------------------------------------- /.github/workflows/update-maintainers-trigger.yaml: -------------------------------------------------------------------------------- 1 | # This action is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | name: Trigger MAINTAINERS.yaml file update 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | paths: 10 | # Check all valid CODEOWNERS locations: 11 | # https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-file-location 12 | - 'CODEOWNERS' 13 | - '.github/CODEOWNERS' 14 | - '.docs/CODEOWNERS' 15 | 16 | jobs: 17 | trigger-maintainers-update: 18 | name: Trigger updating MAINTAINERS.yaml because of CODEOWNERS change 19 | runs-on: ubuntu-latest 20 | 21 | steps: 22 | - name: Repository Dispatch 23 | uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # https://github.com/peter-evans/repository-dispatch/releases/tag/v3.0.0 24 | with: 25 | # The PAT with the 'public_repo' scope is required 26 | token: ${{ secrets.GH_TOKEN }} 27 | repository: ${{ github.repository_owner }}/community 28 | event-type: trigger-maintainers-update 29 | -------------------------------------------------------------------------------- /.github/workflows/update-pr.yml: -------------------------------------------------------------------------------- 1 | # This workflow is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | # This workflow will run on every comment with /update or /u. And will create merge-commits for the PR. 5 | # This also works with forks, not only with branches in the same repository/organization. 6 | # Currently, does not work with forks in different organizations. 7 | 8 | # This workflow will be distributed to all repositories in the AsyncAPI organization 9 | 10 | name: Update PR branches from fork 11 | 12 | on: 13 | issue_comment: 14 | types: [created] 15 | 16 | jobs: 17 | update-pr: 18 | if: > 19 | startsWith(github.repository, 'asyncapi/') && 20 | github.event.issue.pull_request && 21 | github.event.issue.state != 'closed' && ( 22 | contains(github.event.comment.body, '/update') || 23 | contains(github.event.comment.body, '/u') 24 | ) 25 | runs-on: ubuntu-latest 26 | steps: 27 | - name: Get Pull Request Details 28 | id: pr 29 | uses: actions/github-script@v7 30 | with: 31 | github-token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }} 32 | previews: 'merge-info-preview' # https://docs.github.com/en/graphql/overview/schema-previews#merge-info-preview-more-detailed-information-about-a-pull-requests-merge-state-preview 33 | script: | 34 | const prNumber = context.payload.issue.number; 35 | core.debug(`PR Number: ${prNumber}`); 36 | const { data: pr } = await github.rest.pulls.get({ 37 | owner: context.repo.owner, 38 | repo: context.repo.repo, 39 | pull_number: prNumber 40 | }); 41 | 42 | // If the PR has conflicts, we don't want to update it 43 | const updateable = ['behind', 'blocked', 'unknown', 'draft', 'clean'].includes(pr.mergeable_state); 44 | console.log(`PR #${prNumber} is ${pr.mergeable_state} and is ${updateable ? 'updateable' : 'not updateable'}`); 45 | core.setOutput('updateable', updateable); 46 | 47 | core.debug(`Updating PR #${prNumber} with head ${pr.head.sha}`); 48 | 49 | return { 50 | id: pr.node_id, 51 | number: prNumber, 52 | head: pr.head.sha, 53 | } 54 | - name: Update the Pull Request 55 | if: steps.pr.outputs.updateable == 'true' 56 | uses: actions/github-script@v7 57 | with: 58 | github-token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }} 59 | script: | 60 | const mutation = `mutation update($input: UpdatePullRequestBranchInput!) { 61 | updatePullRequestBranch(input: $input) { 62 | pullRequest { 63 | mergeable 64 | } 65 | } 66 | }`; 67 | 68 | const pr_details = ${{ steps.pr.outputs.result }}; 69 | 70 | try { 71 | const { data } = await github.graphql(mutation, { 72 | input: { 73 | pullRequestId: pr_details.id, 74 | expectedHeadOid: pr_details.head, 75 | } 76 | }); 77 | } catch (GraphQLError) { 78 | core.debug(GraphQLError); 79 | if ( 80 | GraphQLError.name === 'GraphqlResponseError' && 81 | GraphQLError.errors.some( 82 | error => error.type === 'FORBIDDEN' || error.type === 'UNAUTHORIZED' 83 | ) 84 | ) { 85 | // Add comment to PR if the bot doesn't have permissions to update the PR 86 | const comment = `Hi @${context.actor}. Update of PR has failed. It can be due to one of the following reasons: 87 | - I don't have permissions to update this PR. To update your fork with upstream using bot you need to enable [Allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) option in the PR. 88 | - The fork is located in an organization, not under your personal profile. No solution for that. You are on your own with manual update. 89 | - There may be a conflict in the PR. Please resolve the conflict and try again.`; 90 | 91 | await github.rest.issues.createComment({ 92 | owner: context.repo.owner, 93 | repo: context.repo.repo, 94 | issue_number: context.issue.number, 95 | body: comment 96 | }); 97 | 98 | core.setFailed('Bot does not have permissions to update the PR'); 99 | } else { 100 | core.setFailed(GraphQLError.message); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /.github/workflows/welcome-first-time-contrib.yml: -------------------------------------------------------------------------------- 1 | # This action is centrally managed in https://github.com/asyncapi/.github/ 2 | # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo 3 | 4 | name: Welcome first time contributors 5 | 6 | on: 7 | pull_request_target: 8 | types: 9 | - opened 10 | issues: 11 | types: 12 | - opened 13 | 14 | jobs: 15 | welcome: 16 | name: Post welcome message 17 | if: ${{ !contains(fromJson('["asyncapi-bot", "dependabot[bot]", "dependabot-preview[bot]", "allcontributors[bot]"]'), github.actor) }} 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/github-script@v7 21 | with: 22 | github-token: ${{ secrets.GITHUB_TOKEN }} 23 | script: | 24 | const issueMessage = `Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our [contributors guide](https://github.com/asyncapi/community/blob/master/CONTRIBUTING.md) and the instructions about a [basic recommended setup](https://github.com/asyncapi/community/blob/master/git-workflow.md) useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out [this issue](https://github.com/asyncapi/asyncapi/issues/115).`; 25 | const prMessage = `Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our [contributors guide](https://github.com/asyncapi/community/blob/master/CONTRIBUTING.md) useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out [this issue](https://github.com/asyncapi/asyncapi/issues/115).`; 26 | if (!issueMessage && !prMessage) { 27 | throw new Error('Action must have at least one of issue-message or pr-message set'); 28 | } 29 | const isIssue = !!context.payload.issue; 30 | let isFirstContribution; 31 | if (isIssue) { 32 | const query = `query($owner:String!, $name:String!, $contributer:String!) { 33 | repository(owner:$owner, name:$name){ 34 | issues(first: 1, filterBy: {createdBy:$contributer}){ 35 | totalCount 36 | } 37 | } 38 | }`; 39 | const variables = { 40 | owner: context.repo.owner, 41 | name: context.repo.repo, 42 | contributer: context.payload.sender.login 43 | }; 44 | const { repository: { issues: { totalCount } } } = await github.graphql(query, variables); 45 | isFirstContribution = totalCount === 1; 46 | } else { 47 | const query = `query($qstr: String!) { 48 | search(query: $qstr, type: ISSUE, first: 1) { 49 | issueCount 50 | } 51 | }`; 52 | const variables = { 53 | "qstr": `repo:${context.repo.owner}/${context.repo.repo} type:pr author:${context.payload.sender.login}`, 54 | }; 55 | const { search: { issueCount } } = await github.graphql(query, variables); 56 | isFirstContribution = issueCount === 1; 57 | } 58 | 59 | if (!isFirstContribution) { 60 | console.log(`Not the users first contribution.`); 61 | return; 62 | } 63 | const message = isIssue ? issueMessage : prMessage; 64 | // Add a comment to the appropriate place 65 | if (isIssue) { 66 | const issueNumber = context.payload.issue.number; 67 | console.log(`Adding message: ${message} to issue #${issueNumber}`); 68 | await github.rest.issues.createComment({ 69 | owner: context.payload.repository.owner.login, 70 | repo: context.payload.repository.name, 71 | issue_number: issueNumber, 72 | body: message 73 | }); 74 | } 75 | else { 76 | const pullNumber = context.payload.pull_request.number; 77 | console.log(`Adding message: ${message} to pull request #${pullNumber}`); 78 | await github.rest.pulls.createReview({ 79 | owner: context.payload.repository.owner.login, 80 | repo: context.payload.repository.name, 81 | pull_number: pullNumber, 82 | body: message, 83 | event: 'COMMENT' 84 | }); 85 | } 86 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | .vscode 4 | .idea 5 | coverage 6 | lib 7 | *.DS_Store -------------------------------------------------------------------------------- /.releaserc: -------------------------------------------------------------------------------- 1 | --- 2 | branches: 3 | - master 4 | # by default release workflow reacts on push not only to master. 5 | #This is why out of the box sematic release is configured for all these branches 6 | - name: next-spec 7 | prerelease: true 8 | - name: next-major 9 | prerelease: true 10 | - name: next-major-spec 11 | prerelease: true 12 | - name: beta 13 | prerelease: true 14 | - name: alpha 15 | prerelease: true 16 | - name: next 17 | prerelease: true 18 | plugins: 19 | - - "@semantic-release/commit-analyzer" 20 | - preset: conventionalcommits 21 | - - "@semantic-release/release-notes-generator" 22 | - preset: conventionalcommits 23 | - "@semantic-release/npm" 24 | - "@semantic-release/github" 25 | -------------------------------------------------------------------------------- /.sonarcloud.properties: -------------------------------------------------------------------------------- 1 | # Disable specific duplicate code since it would introduce more complexity to reduce it. 2 | sonar.cpd.exclusions=src/standards/v2.ts, src/standards/v3.ts, test/fixtures/main.fixtures.ts 3 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This file provides an overview of code owners in this repository. 2 | 3 | # Each line is a file pattern followed by one or more owners. 4 | # The last matching pattern has the most precedence. 5 | # For more details, read the following article on GitHub: https://help.github.com/articles/about-codeowners/. 6 | 7 | # The default owners are automatically added as reviewers when you open a pull request unless different owners are specified in the file. 8 | * @aayushmau5 @magicmatatjahu @derberg @asyncapi-bot-eve 9 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | - Using welcoming and inclusive language 12 | - Being respectful of differing viewpoints and experiences 13 | - Gracefully accepting constructive criticism 14 | - Focusing on what is best for the community 15 | - Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | - The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | - Trolling, insulting/derogatory comments, and personal or political attacks 21 | - Public or private harassment 22 | - Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | - Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at fmvilas@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to AsyncAPI 2 | We love your input! We want to make contributing to this project as easy and transparent as possible. 3 | 4 | ## Contribution recogniton 5 | 6 | We use [All Contributors](https://allcontributors.org/docs/en/specification) specification to handle recognitions. For more details read [this](https://github.com/asyncapi/community/blob/master/recognize-contributors.md) document. 7 | 8 | ## Summary of the contribution flow 9 | 10 | The following is a summary of the ideal contribution flow. Please, note that Pull Requests can also be rejected by the maintainers when appropriate. 11 | 12 | ``` 13 | ┌───────────────────────┐ 14 | │ │ 15 | │ Open an issue │ 16 | │ (a bug report or a │ 17 | │ feature request) │ 18 | │ │ 19 | └───────────────────────┘ 20 | ⇩ 21 | ┌───────────────────────┐ 22 | │ │ 23 | │ Open a Pull Request │ 24 | │ (only after issue │ 25 | │ is approved) │ 26 | │ │ 27 | └───────────────────────┘ 28 | ⇩ 29 | ┌───────────────────────┐ 30 | │ │ 31 | │ Your changes will │ 32 | │ be merged and │ 33 | │ published on the next │ 34 | │ release │ 35 | │ │ 36 | └───────────────────────┘ 37 | ``` 38 | 39 | ## Code of Conduct 40 | AsyncAPI has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](./CODE_OF_CONDUCT.md) so that you can understand what sort of behaviour is expected. 41 | 42 | ## Our Development Process 43 | We use Github to host code, to track issues and feature requests, as well as accept pull requests. 44 | 45 | ## Issues 46 | [Open an issue](https://github.com/asyncapi/asyncapi/issues/new) **only** if you want to report a bug or a feature. Don't open issues for questions or support, instead join our [Slack workspace](https://www.asyncapi.com/slack-invite) and ask there. Don't forget to follow our [Slack Etiquette](https://github.com/asyncapi/community/blob/master/slack-etiquette.md) while interacting with community members! It's more likely you'll get help, and much faster! 47 | 48 | ## Bug Reports and Feature Requests 49 | 50 | Please use our issues templates that provide you with hints on what information we need from you to help you out. 51 | 52 | ## Pull Requests 53 | 54 | **Please, make sure you open an issue before starting with a Pull Request, unless it's a typo or a really obvious error.** Pull requests are the best way to propose changes to the specification. Get familiar with our document that explains [Git workflow](https://github.com/asyncapi/community/blob/master/git-workflow.md) used in our repositories. 55 | 56 | ## Conventional commits 57 | 58 | Our repositories follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) specification. Releasing to GitHub and NPM is done with the support of [semantic-release](https://semantic-release.gitbook.io/semantic-release/). 59 | 60 | Pull requests should have a title that follows the specification, otherwise, merging is blocked. If you are not familiar with the specification simply ask maintainers to modify. You can also use this cheatsheet if you want: 61 | 62 | - `fix: ` prefix in the title indicates that PR is a bug fix and PATCH release must be triggered. 63 | - `feat: ` prefix in the title indicates that PR is a feature and MINOR release must be triggered. 64 | - `docs: ` prefix in the title indicates that PR is only related to the documentation and there is no need to trigger release. 65 | - `chore: ` prefix in the title indicates that PR is only related to cleanup in the project and there is no need to trigger release. 66 | - `test: ` prefix in the title indicates that PR is only related to tests and there is no need to trigger release. 67 | - `refactor: ` prefix in the title indicates that PR is only related to refactoring and there is no need to trigger release. 68 | 69 | What about MAJOR release? just add `!` to the prefix, like `fix!: ` or `refactor!: ` 70 | 71 | Prefix that follows specification is not enough though. Remember that the title must be clear and descriptive with usage of [imperative mood](https://chris.beams.io/posts/git-commit/#imperative). 72 | 73 | Happy contributing :heart: 74 | 75 | ## License 76 | When you submit changes, your submissions are understood to be under the same [Apache 2.0 License](https://github.com/asyncapi/asyncapi/blob/master/LICENSE) that covers the project. Feel free to [contact the maintainers](https://www.asyncapi.com/slack-invite) if that's a concern. 77 | 78 | ## References 79 | This document was adapted from the open-source contribution guidelines for [Facebook's Draft](https://github.com/facebook/draft-js/blob/master/CONTRIBUTING.md). -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![AsyncAPI Diff](/assets/logo.png)](https://www.asyncapi.com) 2 | 3 | AsyncDiff is a library that compares two AsyncAPI files and provides information about the differences by pointing out explicitly information like breaking changes. 4 | 5 | ![npm](https://img.shields.io/npm/v/@asyncapi/diff?style=for-the-badge) ![npm](https://img.shields.io/npm/dt/@asyncapi/diff?style=for-the-badge) 6 | 7 | 8 | 9 | 10 | 11 | - [Features](#features) 12 | - [Installation](#installation) 13 | - [Usage](#usage) 14 | - [Standard object](#standard-object) 15 | * [Overriding the standard](#overriding-the-standard) 16 | - [Example](#example) 17 | - [Output](#output) 18 | - [API](#api) 19 | - [Develop](#develop) 20 | - [Contributing](#contributing) 21 | - [Contributors](#contributors) 22 | 23 | 24 | 25 | ## Features 26 | 27 | - Get explicit information about the changes you make to your AsyncAPI files, such as breaking, non-breaking and unclassified changes. 28 | - Different types of output such as JSON, YAML and Markdown. 29 | 30 | ## Installation 31 | 32 | ``` 33 | npm install @asyncapi/diff 34 | ``` 35 | 36 | ## Usage 37 | 38 | **NOTE:** The library doesn't have a built-in parser to parse the given AsyncAPI document. Thus, you have to make sure they provide the valid & dereferenced AsyncAPI document as an input. You can use the [AsyncAPI parser](https://github.com/asyncapi/parser-js) to parse and validate the AsyncAPI file first. You can use other tools, but you **must** make sure that the document is valid and dereferenced. 39 | 40 | ```js 41 | import { diff } from "@asyncapi/diff"; // const { diff } = require('@asyncapi/diff'); 42 | 43 | const output = diff(firstDocument, secondDocument, { 44 | override: { 45 | // object to override the standard 46 | }, 47 | }); 48 | ``` 49 | 50 | ## Standard object 51 | 52 | This library has a pre-configured standard which marks a change as `breaking`, `non-breaking` or `unclassified`. This standard data is stored as an object inside the [`standard.ts`](https://github.com/asyncapi/diff/blob/master/src/standard.ts) file. 53 | 54 | The format of this standard object is explained in [this](standard-format.md) document. 55 | 56 | ### Overriding the standard 57 | 58 | To understand the format of overriding object, take a look at [this](standard-format.md) document. 59 | 60 | The overrides object must be passed in the following format: 61 | 62 | ``` 63 | { 64 | [jsonPointer]: { 65 | add: 'breaking' | 'non-breaking' | 'unclassified' 66 | remove: 'breaking' | 'non-breaking' | 'unclassified' 67 | edit: 'breaking' | 'non-breaking' | 'unclassified' 68 | } 69 | } 70 | ``` 71 | 72 | ## Example 73 | 74 | See the [index](./docs/modules/index.md) document to get all the helper methods this library offers. 75 | 76 | 1. Without any overrides 77 | 78 | ```js 79 | const output = diff(firstDocument, secondDocument); 80 | 81 | output.getOutput(); // the whole output data 82 | output.breaking(); // the breaking changes 83 | output.nonBreaking(); // the non-breaking changes 84 | output.unclassified(); // the unclassified changes 85 | ``` 86 | 87 | 2. With overrides 88 | 89 | ```js 90 | const output = diff(firstDocument, secondDocument, { 91 | override: { 92 | "/servers/*/protocol": { 93 | add: "non-breaking", 94 | remove: "breaking", 95 | edit: "unclassified", 96 | }, 97 | }, 98 | }); 99 | ``` 100 | 101 | ## Output 102 | 103 | This library supports outputs: 104 | 105 | - JSON: `json` 106 | - YAML: `yaml` or `yml` 107 | - Markdown: `markdown` or `md` 108 | 109 | ```js 110 | const jsonOutput = diff(firstDocument, secondDocument, { 111 | outputType: "json", 112 | }); 113 | 114 | const yamlOutput = diff(firstDocument, secondDocument, { 115 | outputType: "yaml" | "yml", 116 | }); 117 | 118 | const markdownOutput = diff(firstDocument, secondDocument, { 119 | outputType: "markdown" | "md", 120 | }); 121 | ``` 122 | 123 | With markdown output, you can also choose subtypes of the changes as JSON(`json`) or YAML(`yaml` or `yml`). 124 | 125 | ```js 126 | const markdownOutput = diff(firstDocument, secondDocument, { 127 | outputType: "markdown" | "md", 128 | markdownSubtype: "json" | "yaml" | "yml", 129 | }); 130 | ``` 131 | 132 | ## API 133 | 134 | Checkout the [index](./docs/modules/index.md) document to see all the APIs this library offers. 135 | 136 | ## Develop 137 | 138 | 1. Write code and tests 139 | 2. Make sure all tests pass `npm run test` 140 | 3. Make sure code is well formatted and secure `npm run lint` 141 | 142 | ## Contributing 143 | 144 | Help us make this library more robust. Read [CONTRIBUTING](https://github.com/asyncapi/.github/blob/master/CONTRIBUTING.md) guide & start contributing. 145 | 146 | ## Contributors 147 | 148 | Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 |

Aayush Kumar Sahu

💻 📖 🚧 🤔 👀 ⚠️

Lukasz Gornicki

🤔 👀 🚧

Maciej Urbańczyk

👀

Jonas Lagoni

👀

Vinit Shahdeo

👀

Anubhav Vats

👀

Shiven Sinha

💻 ⚠️

Debajyoti Halder

📖
167 | 168 | 169 | 170 | 171 | 172 | 173 | This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! 174 | -------------------------------------------------------------------------------- /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/asyncapi/diff/14dc747c8be734e3899a4d358e02afe4de4e2c2b/assets/logo.png -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- 1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | @asyncapi/diff 2 | 3 | # @asyncapi/diff 4 | 5 | ## Table of contents 6 | 7 | ### Modules 8 | 9 | - [asyncapidiff](modules/asyncapidiff.md) 10 | - [index](modules/index.md) 11 | -------------------------------------------------------------------------------- /docs/classes/asyncapidiff.AsyncAPIDiff.md: -------------------------------------------------------------------------------- 1 | [@asyncapi/diff](../README.md) / [asyncapidiff](../modules/asyncapidiff.md) / AsyncAPIDiff 2 | 3 | # Class: AsyncAPIDiff 4 | 5 | [asyncapidiff](../modules/asyncapidiff.md).AsyncAPIDiff 6 | 7 | Implements methods to deal with diff output. 8 | 9 | **`returns`** AsyncAPIDiff 10 | 11 | ## Table of contents 12 | 13 | ### Constructors 14 | 15 | - [constructor](asyncapidiff.AsyncAPIDiff.md#constructor) 16 | 17 | ### Properties 18 | 19 | - [markdownSubtype](asyncapidiff.AsyncAPIDiff.md#markdownsubtype) 20 | - [output](asyncapidiff.AsyncAPIDiff.md#output) 21 | - [outputType](asyncapidiff.AsyncAPIDiff.md#outputtype) 22 | 23 | ### Methods 24 | 25 | - [breaking](asyncapidiff.AsyncAPIDiff.md#breaking) 26 | - [getOutput](asyncapidiff.AsyncAPIDiff.md#getoutput) 27 | - [nonBreaking](asyncapidiff.AsyncAPIDiff.md#nonbreaking) 28 | - [unclassified](asyncapidiff.AsyncAPIDiff.md#unclassified) 29 | 30 | ## Constructors 31 | 32 | ### constructor 33 | 34 | • **new AsyncAPIDiff**(`output`, `options`) 35 | 36 | #### Parameters 37 | 38 | | Name | Type | 39 | | :------ | :------ | 40 | | `output` | `string` | 41 | | `options` | [`AsyncAPIDiffOptions`](../interfaces/index.AsyncAPIDiffOptions.md) | 42 | 43 | #### Defined in 44 | 45 | [asyncapidiff.ts:23](https://github.com/asyncapi/diff/blob/6fcfb89/src/asyncapidiff.ts#L23) 46 | 47 | ## Properties 48 | 49 | ### markdownSubtype 50 | 51 | • `Private` **markdownSubtype**: [`MarkdownSubtype`](../modules/index.md#markdownsubtype) 52 | 53 | #### Defined in 54 | 55 | [asyncapidiff.ts:21](https://github.com/asyncapi/diff/blob/6fcfb89/src/asyncapidiff.ts#L21) 56 | 57 | ___ 58 | 59 | ### output 60 | 61 | • `Private` **output**: [`JSONOutput`](../interfaces/index.JSONOutput.md) 62 | 63 | #### Defined in 64 | 65 | [asyncapidiff.ts:19](https://github.com/asyncapi/diff/blob/6fcfb89/src/asyncapidiff.ts#L19) 66 | 67 | ___ 68 | 69 | ### outputType 70 | 71 | • `Private` **outputType**: [`OutputType`](../modules/index.md#outputtype) 72 | 73 | #### Defined in 74 | 75 | [asyncapidiff.ts:20](https://github.com/asyncapi/diff/blob/6fcfb89/src/asyncapidiff.ts#L20) 76 | 77 | ## Methods 78 | 79 | ### breaking 80 | 81 | ▸ **breaking**(): [`Changes`](../modules/index.md#changes) 82 | 83 | #### Returns 84 | 85 | [`Changes`](../modules/index.md#changes) 86 | 87 | All the breaking changes 88 | 89 | #### Defined in 90 | 91 | [asyncapidiff.ts:33](https://github.com/asyncapi/diff/blob/6fcfb89/src/asyncapidiff.ts#L33) 92 | 93 | ___ 94 | 95 | ### getOutput 96 | 97 | ▸ **getOutput**(): [`Output`](../modules/index.md#output) 98 | 99 | #### Returns 100 | 101 | [`Output`](../modules/index.md#output) 102 | 103 | The full output 104 | 105 | #### Defined in 106 | 107 | [asyncapidiff.ts:66](https://github.com/asyncapi/diff/blob/6fcfb89/src/asyncapidiff.ts#L66) 108 | 109 | ___ 110 | 111 | ### nonBreaking 112 | 113 | ▸ **nonBreaking**(): [`Changes`](../modules/index.md#changes) 114 | 115 | #### Returns 116 | 117 | [`Changes`](../modules/index.md#changes) 118 | 119 | All the non-breaking changes 120 | 121 | #### Defined in 122 | 123 | [asyncapidiff.ts:44](https://github.com/asyncapi/diff/blob/6fcfb89/src/asyncapidiff.ts#L44) 124 | 125 | ___ 126 | 127 | ### unclassified 128 | 129 | ▸ **unclassified**(): [`Changes`](../modules/index.md#changes) 130 | 131 | #### Returns 132 | 133 | [`Changes`](../modules/index.md#changes) 134 | 135 | All the unclassified changes 136 | 137 | #### Defined in 138 | 139 | [asyncapidiff.ts:55](https://github.com/asyncapi/diff/blob/6fcfb89/src/asyncapidiff.ts#L55) 140 | -------------------------------------------------------------------------------- /docs/interfaces/index.AsyncAPIDiffOptions.md: -------------------------------------------------------------------------------- 1 | [@asyncapi/diff](../README.md) / [index](../modules/index.md) / AsyncAPIDiffOptions 2 | 3 | # Interface: AsyncAPIDiffOptions 4 | 5 | [index](../modules/index.md).AsyncAPIDiffOptions 6 | 7 | ## Table of contents 8 | 9 | ### Properties 10 | 11 | - [markdownSubtype](index.AsyncAPIDiffOptions.md#markdownsubtype) 12 | - [outputType](index.AsyncAPIDiffOptions.md#outputtype) 13 | 14 | ## Properties 15 | 16 | ### markdownSubtype 17 | 18 | • `Optional` **markdownSubtype**: [`MarkdownSubtype`](../modules/index.md#markdownsubtype) 19 | 20 | #### Defined in 21 | 22 | [types.ts:73](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L73) 23 | 24 | ___ 25 | 26 | ### outputType 27 | 28 | • **outputType**: [`OutputType`](../modules/index.md#outputtype) 29 | 30 | #### Defined in 31 | 32 | [types.ts:72](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L72) 33 | -------------------------------------------------------------------------------- /docs/interfaces/index.ChangeMarkdownGenerationConfig.md: -------------------------------------------------------------------------------- 1 | [@asyncapi/diff](../README.md) / [index](../modules/index.md) / ChangeMarkdownGenerationConfig 2 | 3 | # Interface: ChangeMarkdownGenerationConfig 4 | 5 | [index](../modules/index.md).ChangeMarkdownGenerationConfig 6 | 7 | ## Table of contents 8 | 9 | ### Properties 10 | 11 | - [change](index.ChangeMarkdownGenerationConfig.md#change) 12 | - [markdownSubtype](index.ChangeMarkdownGenerationConfig.md#markdownsubtype) 13 | 14 | ## Properties 15 | 16 | ### change 17 | 18 | • **change**: `Object` 19 | 20 | #### Type declaration 21 | 22 | | Name | Type | 23 | | :------ | :------ | 24 | | `any` | `any` | 25 | | `path` | `string` | 26 | 27 | #### Defined in 28 | 29 | [types.ts:61](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L61) 30 | 31 | ___ 32 | 33 | ### markdownSubtype 34 | 35 | • **markdownSubtype**: [`MarkdownSubtype`](../modules/index.md#markdownsubtype) 36 | 37 | #### Defined in 38 | 39 | [types.ts:62](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L62) 40 | -------------------------------------------------------------------------------- /docs/interfaces/index.Classifier.md: -------------------------------------------------------------------------------- 1 | [@asyncapi/diff](../README.md) / [index](../modules/index.md) / Classifier 2 | 3 | # Interface: Classifier 4 | 5 | [index](../modules/index.md).Classifier 6 | 7 | ## Table of contents 8 | 9 | ### Properties 10 | 11 | - [add](index.Classifier.md#add) 12 | - [edit](index.Classifier.md#edit) 13 | - [remove](index.Classifier.md#remove) 14 | 15 | ## Properties 16 | 17 | ### add 18 | 19 | • **add**: [`ChangeType`](../modules/index.md#changetype) 20 | 21 | #### Defined in 22 | 23 | [types.ts:15](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L15) 24 | 25 | ___ 26 | 27 | ### edit 28 | 29 | • **edit**: [`ChangeType`](../modules/index.md#changetype) 30 | 31 | #### Defined in 32 | 33 | [types.ts:17](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L17) 34 | 35 | ___ 36 | 37 | ### remove 38 | 39 | • **remove**: [`ChangeType`](../modules/index.md#changetype) 40 | 41 | #### Defined in 42 | 43 | [types.ts:16](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L16) 44 | -------------------------------------------------------------------------------- /docs/interfaces/index.Config.md: -------------------------------------------------------------------------------- 1 | [@asyncapi/diff](../README.md) / [index](../modules/index.md) / Config 2 | 3 | # Interface: Config 4 | 5 | [index](../modules/index.md).Config 6 | 7 | ## Table of contents 8 | 9 | ### Properties 10 | 11 | - [markdownSubtype](index.Config.md#markdownsubtype) 12 | - [outputType](index.Config.md#outputtype) 13 | - [override](index.Config.md#override) 14 | 15 | ## Properties 16 | 17 | ### markdownSubtype 18 | 19 | • `Optional` **markdownSubtype**: [`MarkdownSubtype`](../modules/index.md#markdownsubtype) 20 | 21 | #### Defined in 22 | 23 | [types.ts:79](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L79) 24 | 25 | ___ 26 | 27 | ### outputType 28 | 29 | • `Optional` **outputType**: [`OutputType`](../modules/index.md#outputtype) 30 | 31 | #### Defined in 32 | 33 | [types.ts:78](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L78) 34 | 35 | ___ 36 | 37 | ### override 38 | 39 | • `Optional` **override**: [`OverrideObject`](index.OverrideObject.md) 40 | 41 | #### Defined in 42 | 43 | [types.ts:77](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L77) 44 | -------------------------------------------------------------------------------- /docs/interfaces/index.DiffOutput.md: -------------------------------------------------------------------------------- 1 | [@asyncapi/diff](../README.md) / [index](../modules/index.md) / DiffOutput 2 | 3 | # Interface: DiffOutput 4 | 5 | [index](../modules/index.md).DiffOutput 6 | 7 | ## Table of contents 8 | 9 | ### Properties 10 | 11 | - [action](index.DiffOutput.md#action) 12 | - [after](index.DiffOutput.md#after) 13 | - [before](index.DiffOutput.md#before) 14 | - [isArrayIndex](index.DiffOutput.md#isarrayindex) 15 | - [path](index.DiffOutput.md#path) 16 | 17 | ## Properties 18 | 19 | ### action 20 | 21 | • **action**: [`ActionType`](../modules/index.md#actiontype) 22 | 23 | #### Defined in 24 | 25 | [types.ts:21](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L21) 26 | 27 | ___ 28 | 29 | ### after 30 | 31 | • `Optional` **after**: `any` 32 | 33 | #### Defined in 34 | 35 | [types.ts:25](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L25) 36 | 37 | ___ 38 | 39 | ### before 40 | 41 | • `Optional` **before**: `any` 42 | 43 | #### Defined in 44 | 45 | [types.ts:24](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L24) 46 | 47 | ___ 48 | 49 | ### isArrayIndex 50 | 51 | • `Optional` **isArrayIndex**: `boolean` 52 | 53 | #### Defined in 54 | 55 | [types.ts:23](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L23) 56 | 57 | ___ 58 | 59 | ### path 60 | 61 | • **path**: `string` 62 | 63 | #### Defined in 64 | 65 | [types.ts:22](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L22) 66 | -------------------------------------------------------------------------------- /docs/interfaces/index.FormatterConfig.md: -------------------------------------------------------------------------------- 1 | [@asyncapi/diff](../README.md) / [index](../modules/index.md) / FormatterConfig 2 | 3 | # Interface: FormatterConfig 4 | 5 | [index](../modules/index.md).FormatterConfig 6 | 7 | ## Type parameters 8 | 9 | | Name | 10 | | :------ | 11 | | `T` | 12 | 13 | ## Table of contents 14 | 15 | ### Properties 16 | 17 | - [data](index.FormatterConfig.md#data) 18 | - [markdownSubtype](index.FormatterConfig.md#markdownsubtype) 19 | - [outputType](index.FormatterConfig.md#outputtype) 20 | 21 | ## Properties 22 | 23 | ### data 24 | 25 | • **data**: `T` 26 | 27 | #### Defined in 28 | 29 | [types.ts:55](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L55) 30 | 31 | ___ 32 | 33 | ### markdownSubtype 34 | 35 | • **markdownSubtype**: [`MarkdownSubtype`](../modules/index.md#markdownsubtype) 36 | 37 | #### Defined in 38 | 39 | [types.ts:57](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L57) 40 | 41 | ___ 42 | 43 | ### outputType 44 | 45 | • **outputType**: [`OutputType`](../modules/index.md#outputtype) 46 | 47 | #### Defined in 48 | 49 | [types.ts:56](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L56) 50 | -------------------------------------------------------------------------------- /docs/interfaces/index.JSONOutput.md: -------------------------------------------------------------------------------- 1 | [@asyncapi/diff](../README.md) / [index](../modules/index.md) / JSONOutput 2 | 3 | # Interface: JSONOutput 4 | 5 | [index](../modules/index.md).JSONOutput 6 | 7 | ## Table of contents 8 | 9 | ### Properties 10 | 11 | - [changes](index.JSONOutput.md#changes) 12 | 13 | ## Properties 14 | 15 | ### changes 16 | 17 | • **changes**: [`DiffOutputItem`](../modules/index.md#diffoutputitem)[] 18 | 19 | #### Defined in 20 | 21 | [types.ts:35](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L35) 22 | -------------------------------------------------------------------------------- /docs/interfaces/index.MarkdownDropdownGenerationConfig.md: -------------------------------------------------------------------------------- 1 | [@asyncapi/diff](../README.md) / [index](../modules/index.md) / MarkdownDropdownGenerationConfig 2 | 3 | # Interface: MarkdownDropdownGenerationConfig 4 | 5 | [index](../modules/index.md).MarkdownDropdownGenerationConfig 6 | 7 | ## Table of contents 8 | 9 | ### Properties 10 | 11 | - [data](index.MarkdownDropdownGenerationConfig.md#data) 12 | - [label](index.MarkdownDropdownGenerationConfig.md#label) 13 | - [markdownSubtype](index.MarkdownDropdownGenerationConfig.md#markdownsubtype) 14 | 15 | ## Properties 16 | 17 | ### data 18 | 19 | • **data**: `Object` 20 | 21 | #### Type declaration 22 | 23 | | Name | Type | 24 | | :------ | :------ | 25 | | `string` | `any` | 26 | 27 | #### Defined in 28 | 29 | [types.ts:67](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L67) 30 | 31 | ___ 32 | 33 | ### label 34 | 35 | • **label**: `string` 36 | 37 | #### Defined in 38 | 39 | [types.ts:66](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L66) 40 | 41 | ___ 42 | 43 | ### markdownSubtype 44 | 45 | • **markdownSubtype**: [`MarkdownSubtype`](../modules/index.md#markdownsubtype) 46 | 47 | #### Defined in 48 | 49 | [types.ts:68](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L68) 50 | -------------------------------------------------------------------------------- /docs/interfaces/index.OverrideObject.md: -------------------------------------------------------------------------------- 1 | [@asyncapi/diff](../README.md) / [index](../modules/index.md) / OverrideObject 2 | 3 | # Interface: OverrideObject 4 | 5 | [index](../modules/index.md).OverrideObject 6 | 7 | ## Indexable 8 | 9 | ▪ [key: `string`]: [`Classifier`](index.Classifier.md) 10 | -------------------------------------------------------------------------------- /docs/modules/asyncapidiff.md: -------------------------------------------------------------------------------- 1 | [@asyncapi/diff](../README.md) / asyncapidiff 2 | 3 | # Module: asyncapidiff 4 | 5 | ## Table of contents 6 | 7 | ### Classes 8 | 9 | - [AsyncAPIDiff](../classes/asyncapidiff.AsyncAPIDiff.md) 10 | -------------------------------------------------------------------------------- /docs/modules/index.md: -------------------------------------------------------------------------------- 1 | [@asyncapi/diff](../README.md) / index 2 | 3 | # Module: index 4 | 5 | ## Table of contents 6 | 7 | ### Interfaces 8 | 9 | - [AsyncAPIDiffOptions](../interfaces/index.AsyncAPIDiffOptions.md) 10 | - [ChangeMarkdownGenerationConfig](../interfaces/index.ChangeMarkdownGenerationConfig.md) 11 | - [Classifier](../interfaces/index.Classifier.md) 12 | - [Config](../interfaces/index.Config.md) 13 | - [DiffOutput](../interfaces/index.DiffOutput.md) 14 | - [FormatterConfig](../interfaces/index.FormatterConfig.md) 15 | - [JSONOutput](../interfaces/index.JSONOutput.md) 16 | - [MarkdownDropdownGenerationConfig](../interfaces/index.MarkdownDropdownGenerationConfig.md) 17 | - [OverrideObject](../interfaces/index.OverrideObject.md) 18 | 19 | ### Type aliases 20 | 21 | - [ActionType](index.md#actiontype) 22 | - [ChangeType](index.md#changetype) 23 | - [Changes](index.md#changes) 24 | - [DiffOutputItem](index.md#diffoutputitem) 25 | - [MarkdownSubtype](index.md#markdownsubtype) 26 | - [Output](index.md#output) 27 | - [OutputType](index.md#outputtype) 28 | - [OverrideStandard](index.md#overridestandard) 29 | - [StandardType](index.md#standardtype) 30 | - [ValueOperation](index.md#valueoperation) 31 | 32 | ### Functions 33 | 34 | - [diff](index.md#diff) 35 | 36 | ## Type aliases 37 | 38 | ### ActionType 39 | 40 | Ƭ **ActionType**: ``"add"`` \| ``"remove"`` \| ``"edit"`` 41 | 42 | #### Defined in 43 | 44 | [types.ts:7](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L7) 45 | 46 | ___ 47 | 48 | ### ChangeType 49 | 50 | Ƭ **ChangeType**: typeof `breaking` \| typeof `nonBreaking` \| typeof `unclassified` 51 | 52 | #### Defined in 53 | 54 | [types.ts:9](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L9) 55 | 56 | ___ 57 | 58 | ### Changes 59 | 60 | Ƭ **Changes**: [`DiffOutputItem`](index.md#diffoutputitem)[] \| `string` 61 | 62 | #### Defined in 63 | 64 | [types.ts:32](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L32) 65 | 66 | ___ 67 | 68 | ### DiffOutputItem 69 | 70 | Ƭ **DiffOutputItem**: [`DiffOutput`](../interfaces/index.DiffOutput.md) & { `type`: [`ChangeType`](index.md#changetype) } 71 | 72 | #### Defined in 73 | 74 | [types.ts:28](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L28) 75 | 76 | ___ 77 | 78 | ### MarkdownSubtype 79 | 80 | Ƭ **MarkdownSubtype**: ``"json"`` \| ``"yaml"`` \| ``"yml"`` 81 | 82 | #### Defined in 83 | 84 | [types.ts:52](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L52) 85 | 86 | ___ 87 | 88 | ### Output 89 | 90 | Ƭ **Output**: [`JSONOutput`](../interfaces/index.JSONOutput.md) \| `string` 91 | 92 | #### Defined in 93 | 94 | [types.ts:38](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L38) 95 | 96 | ___ 97 | 98 | ### OutputType 99 | 100 | Ƭ **OutputType**: ``"json"`` \| ``"yaml"`` \| ``"yml"`` \| ``"markdown"`` \| ``"md"`` 101 | 102 | #### Defined in 103 | 104 | [types.ts:50](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L50) 105 | 106 | ___ 107 | 108 | ### OverrideStandard 109 | 110 | Ƭ **OverrideStandard**: [`StandardType`](index.md#standardtype) & [`OverrideObject`](../interfaces/index.OverrideObject.md) 111 | 112 | #### Defined in 113 | 114 | [types.ts:48](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L48) 115 | 116 | ___ 117 | 118 | ### StandardType 119 | 120 | Ƭ **StandardType**: typeof `v2Standard` \| typeof `v3Standard` 121 | 122 | #### Defined in 123 | 124 | [types.ts:42](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L42) 125 | 126 | ___ 127 | 128 | ### ValueOperation 129 | 130 | Ƭ **ValueOperation**: `ReplaceOperation`<`any`\> \| `AddOperation`<`any`\> 131 | 132 | #### Defined in 133 | 134 | [types.ts:40](https://github.com/asyncapi/diff/blob/6fcfb89/src/types.ts#L40) 135 | 136 | ## Functions 137 | 138 | ### diff 139 | 140 | ▸ **diff**(`firstDocument`, `secondDocument`, `config?`): [`AsyncAPIDiff`](../classes/asyncapidiff.AsyncAPIDiff.md) 141 | 142 | Generates diff between two AsyncAPI documents 143 | 144 | **`example`** 145 | ``` 146 | const output = diff(firstDocument, secondDocument, { 147 | override: { 148 | '/servers': { 149 | add: 'non-breaking', // when a property has been added in the AsyncAPI document 150 | remove: 'breaking', // when a property has been removed from the AsyncAPI document 151 | edit: 'unclassified' // when a property has been edited in the AsyncAPI document 152 | } 153 | }, 154 | outputType: "yaml" 155 | }) 156 | ``` 157 | 158 | #### Parameters 159 | 160 | | Name | Type | Description | 161 | | :------ | :------ | :------ | 162 | | `firstDocument` | `any` | The parsed AsyncAPI document | 163 | | `secondDocument` | `any` | The parsed AsyncAPI document | 164 | | `config` | [`Config`](../interfaces/index.Config.md) | Configuration options | 165 | 166 | #### Returns 167 | 168 | [`AsyncAPIDiff`](../classes/asyncapidiff.AsyncAPIDiff.md) 169 | 170 | The diff data 171 | 172 | #### Defined in 173 | 174 | [main.ts:32](https://github.com/asyncapi/diff/blob/6fcfb89/src/main.ts#L32) 175 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | // eslint-disable-next-line no-undef 2 | module.exports = { 3 | coverageReporters: ['json-summary', 'lcov', 'text'], 4 | preset: 'ts-jest', 5 | // The root of your source code, typically /src 6 | // `` is a token Jest substitutes 7 | roots: [''], 8 | 9 | // Test spec file resolution pattern 10 | // Matches parent folder `__tests__` and filename 11 | // should contain `test` or `spec`. 12 | testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$', 13 | // Module file extensions for importing 14 | moduleFileExtensions: ['ts', 'js', 'json', 'node'], 15 | testTimeout: 10000, 16 | }; 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@asyncapi/diff", 3 | "version": "0.5.0", 4 | "description": "AsyncDiff is a library which compares two AsyncAPI Documents and provides information about the differences by pointing out explicitly informations like breaking changes.", 5 | "main": "./lib/index.js", 6 | "types": "./lib/index.d.ts", 7 | "files": [ 8 | "/lib", 9 | "./README.md", 10 | "./LICENSE" 11 | ], 12 | "scripts": { 13 | "start": "tsc --watch", 14 | "build": "tsc", 15 | "docs": "typedoc --entryPointStrategy expand --options typedoc.json", 16 | "test": "jest", 17 | "test:coverage": "jest --coverage", 18 | "test:watch": "jest --watch", 19 | "lint": "eslint --max-warnings 0 --config .eslintrc .", 20 | "lint:fix": "eslint --max-warnings 0 --config .eslintrc . --fix", 21 | "get:version": "echo $npm_package_version", 22 | "get:name": "echo $npm_package_name", 23 | "generate:readme:toc": "markdown-toc -i README.md", 24 | "generate:assets": "npm run build && npm run docs && npm run generate:readme:toc", 25 | "bump:version": "npm --no-git-tag-version --allow-same-version version $VERSION", 26 | "prepublishOnly": "npm run build" 27 | }, 28 | "repository": { 29 | "type": "git", 30 | "url": "git+https://github.com/asyncapi/diff.git" 31 | }, 32 | "keywords": [ 33 | "asyncapi", 34 | "diff" 35 | ], 36 | "author": "aayushmau5", 37 | "license": "Apache-2.0", 38 | "bugs": { 39 | "url": "https://github.com/asyncapi/diff/issues" 40 | }, 41 | "homepage": "https://github.com/asyncapi/diff#readme", 42 | "dependencies": { 43 | "fast-json-patch": "^3.0.0-1", 44 | "js-yaml": "^4.1.0", 45 | "json2md": "^1.12.0" 46 | }, 47 | "devDependencies": { 48 | "@asyncapi/parser": "^3.1.0", 49 | "@types/jest": "^29.5.1", 50 | "@types/js-yaml": "^4.0.5", 51 | "@types/json2md": "^1.5.1", 52 | "@types/node": "^15.12.1", 53 | "@typescript-eslint/eslint-plugin": "^4.26.0", 54 | "@typescript-eslint/parser": "^4.26.0", 55 | "eslint": "^7.28.0", 56 | "eslint-plugin-github": "^4.1.3", 57 | "eslint-plugin-security": "^1.4.0", 58 | "eslint-plugin-sonarjs": "^0.8.0-125", 59 | "jest": "^29.5.0", 60 | "markdown-toc": "^1.2.0", 61 | "ts-jest": "^29.1.0", 62 | "typedoc": "^0.22.11", 63 | "typedoc-plugin-markdown": "^3.11.12", 64 | "typedoc-plugin-rename-defaults": "^0.4.0", 65 | "typescript": "^4.3.2" 66 | }, 67 | "publishConfig": { 68 | "access": "public" 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/asyncapidiff.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Output, 3 | OutputType, 4 | JSONOutput, 5 | Changes, 6 | AsyncAPIDiffOptions, 7 | MarkdownSubtype, 8 | } from './types'; 9 | import { breaking, nonBreaking, unclassified } from './constants'; 10 | import toProperFormat from './helpers/output/toProperFormat'; 11 | 12 | /** 13 | * Implements methods to deal with diff output. 14 | * @class 15 | * 16 | * @returns {AsyncAPIDiff} AsyncAPIDiff 17 | */ 18 | export default class AsyncAPIDiff { 19 | private output: JSONOutput; 20 | private outputType: OutputType; 21 | private markdownSubtype: MarkdownSubtype; 22 | 23 | constructor(output: string, options: AsyncAPIDiffOptions) { 24 | // output is a stringified JSON 25 | this.output = JSON.parse(output); 26 | this.outputType = options.outputType; 27 | this.markdownSubtype = options.markdownSubtype || 'json'; 28 | } 29 | 30 | /** 31 | * @returns {Changes} All the breaking changes 32 | */ 33 | breaking(): Changes { 34 | const breakingChanges = this.output.changes.filter( 35 | (diff) => diff.type === breaking 36 | ); 37 | 38 | return toProperFormat({data: breakingChanges, outputType: this.outputType, markdownSubtype: this.markdownSubtype}); 39 | } 40 | 41 | /** 42 | * @returns {Changes} All the non-breaking changes 43 | */ 44 | nonBreaking(): Changes { 45 | const nonBreakingChanges = this.output.changes.filter( 46 | (diff) => diff.type === nonBreaking 47 | ); 48 | 49 | return toProperFormat({data: nonBreakingChanges, outputType: this.outputType, markdownSubtype: this.markdownSubtype}); 50 | } 51 | 52 | /** 53 | * @returns {Changes} All the unclassified changes 54 | */ 55 | unclassified(): Changes { 56 | const unclassifiedChanges = this.output.changes.filter( 57 | (diff) => diff.type === unclassified 58 | ); 59 | 60 | return toProperFormat({data: unclassifiedChanges, outputType: this.outputType, markdownSubtype: this.markdownSubtype}); 61 | } 62 | 63 | /** 64 | * @returns {Output} The full output 65 | */ 66 | getOutput(): Output { 67 | return toProperFormat({data: this.output, outputType: this.outputType, markdownSubtype: this.markdownSubtype}); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/categorizeChanges.ts: -------------------------------------------------------------------------------- 1 | import classifier from './classifier'; 2 | import { Output, DiffOutput, DiffOutputItem, OverrideStandard } from './types'; 3 | 4 | /** 5 | * Categorize the changes 6 | * @param standard The standard object 7 | * @param diffs The array of diff changes 8 | * @returns The final output containing the diff changes as well as the type of change 9 | * 10 | * @private 11 | */ 12 | export default function categorizeChanges( 13 | standard: OverrideStandard, 14 | diffs: DiffOutput[] 15 | ): Output { 16 | // the final output 17 | const output: Output = { 18 | changes: [], 19 | }; 20 | 21 | for (const diff of diffs) { 22 | const newDiffObject = { ...diff } as DiffOutputItem; 23 | const classifierObject = classifier(standard, diff.path); 24 | newDiffObject.type = classifierObject[diff.action] || 'unclassified'; 25 | output.changes.push(newDiffObject); 26 | } 27 | 28 | return output; 29 | } 30 | -------------------------------------------------------------------------------- /src/classifier.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable security/detect-object-injection */ 2 | // Disabling this since the property we are accessing will always have `/` as the prefix 3 | // Thus preventing the prototype chain attacks 4 | 5 | import { unclassified } from './constants'; 6 | import { generateClassifierPath } from './helpers/ClassifierHelpers'; 7 | import { Classifier, OverrideStandard } from './types'; 8 | 9 | /** 10 | * Gets the classifier object from the standard object using the provided path 11 | * @param standard The standard object 12 | * @param path The JSONpointer path provided by the diff 13 | * @returns The classifier object containing `add`, `remove` & `edit` properties 14 | * 15 | * @private 16 | */ 17 | export default function classifier( 18 | standard: OverrideStandard, 19 | path: string 20 | ): Classifier { 21 | const classifierPath = generateClassifierPath(standard, path); 22 | if (!classifierPath) { 23 | return { 24 | add: unclassified, 25 | remove: unclassified, 26 | edit: unclassified, 27 | }; 28 | } 29 | return standard[classifierPath]; 30 | } 31 | -------------------------------------------------------------------------------- /src/constants.ts: -------------------------------------------------------------------------------- 1 | export const breaking = 'breaking'; 2 | export const nonBreaking = 'non-breaking'; 3 | export const unclassified = 'unclassified'; 4 | -------------------------------------------------------------------------------- /src/generateDiff.ts: -------------------------------------------------------------------------------- 1 | import { compare } from 'fast-json-patch'; 2 | 3 | import { formatDiffOutput } from './helpers/DiffHelpers'; 4 | import { DiffOutput } from './types'; 5 | 6 | /** 7 | * Generates the diff 8 | * @param {*} firstDocument The first document in JSON format 9 | * @param {*} secondDocument The second document in JSON format 10 | * @returns {DiffOutput[]} An array containing all the diffs 11 | * 12 | * @private 13 | */ 14 | export default function generateDiff( 15 | firstDocument: any, 16 | secondDocument: any 17 | ): DiffOutput[] { 18 | const diffOutput = compare(firstDocument, secondDocument); 19 | return formatDiffOutput(diffOutput, firstDocument); 20 | } 21 | -------------------------------------------------------------------------------- /src/helpers/ClassifierHelpers.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable security/detect-object-injection */ 2 | // Disabling this since the property we are accessing will always have `/` as the prefix 3 | // Thus preventing the prototype chain attacks 4 | 5 | import { OverrideStandard } from '../types'; 6 | 7 | /** 8 | * Changes the last element of array to `*` 9 | * @param path The path in form of an array 10 | * @returns The path in form of a string with `*` at the end 11 | * 12 | * @example 13 | * changeLastElementToPlaceholder(['', 'servers', 'production']); // '/servers/*' 14 | * 15 | * @private 16 | */ 17 | export function changeLastElementToPlaceholder(path: string[]): string { 18 | path.pop(); 19 | path.push('*'); 20 | return path.join('/'); 21 | } 22 | 23 | /** 24 | * Generates the correct path to get the classification data from standard 25 | * @param standard The standard object 26 | * @param path The JSONpointer path to find 27 | * @returns The path found 28 | * 29 | * @private 30 | */ 31 | export function generateClassifierPath( 32 | standard: OverrideStandard, 33 | path: string 34 | ): string | undefined { 35 | // See this PR for a detailed walkthrough of this code with an example: https://github.com/asyncapi/diff/pull/19 36 | const pathArray = path.split('/'); 37 | for (let i = 0; i < pathArray.length; i++) { 38 | const slicedPathSegment = pathArray.slice(0, i + 1); 39 | const pathSegment = slicedPathSegment.join('/'); 40 | if (pathSegment === '') { 41 | continue; 42 | } 43 | if (standard[pathSegment]) { 44 | // if the property is found, skip the steps and move onto next iteration 45 | continue; 46 | } 47 | const newPathSegment = changeLastElementToPlaceholder(slicedPathSegment); 48 | if (!standard[newPathSegment]) { 49 | // path with * not found 50 | return undefined; 51 | } 52 | pathArray[i] = '*'; 53 | } 54 | return pathArray.join('/'); 55 | } 56 | -------------------------------------------------------------------------------- /src/helpers/DiffHelpers.ts: -------------------------------------------------------------------------------- 1 | import { Operation, getValueByPointer } from 'fast-json-patch'; 2 | 3 | import { DiffOutput, ValueOperation, ActionType } from '../types'; 4 | 5 | /** 6 | * Formats the action to have one of `add`, `remove` or `edit` values 7 | * @param {String} action The action performed by the diff library 8 | * @returns {String} The formatted action output 9 | * 10 | * @private 11 | */ 12 | export function formatAction(action: string): ActionType { 13 | if (action === 'replace') { 14 | return 'edit'; 15 | } 16 | // since `add` and `remove` are already provided by the library, we don't need to change that. 17 | return action as ActionType; 18 | } 19 | 20 | /** 21 | * Get the `before` value from the first document 22 | * @param firstDocument The first document which we will get the before value from 23 | * @param {String} path The path from where we can get the value 24 | * @returns The value from the first document 25 | * 26 | * @private 27 | */ 28 | export function getBeforeValue(firstDocument: any, path: string): any { 29 | // since our current diffing library doesn't provide the `before` value 30 | // we have to get it manually from the first document 31 | return getValueByPointer(firstDocument, path); 32 | } 33 | 34 | /** 35 | * Get the `after` value 36 | * @param diffObject A single diff object 37 | * @returns The value that is present inside the second document 38 | * 39 | * @private 40 | */ 41 | export function getAfterValue(diffObject: Operation): any { 42 | // The diffing library already provides the `after` value for `add` or `edit` actions 43 | return (diffObject as ValueOperation).value; 44 | } 45 | 46 | /** 47 | * Sets the index property in case of an array change 48 | * @param changeObject The change object 49 | * @param {String} path The original path 50 | * 51 | * @private 52 | */ 53 | export function setIndex( 54 | changeObject: DiffOutput, 55 | firstDocument: any, 56 | path: string 57 | ): void { 58 | const splittedPath = path.split('/'); 59 | const lastPathElement = splittedPath[splittedPath.length - 1]; 60 | const lastElementNumber = Number(lastPathElement); 61 | splittedPath.pop(); 62 | const assembledPath = splittedPath.join('/'); 63 | if ( 64 | !Number.isNaN(lastElementNumber) && 65 | Array.isArray(getValueByPointer(firstDocument, assembledPath)) 66 | ) { 67 | // if the last element is a Number 68 | // and the path before the last element is an array 69 | // then the change has been made inside an array, therefore set index as true 70 | changeObject.isArrayIndex = true; 71 | } 72 | } 73 | 74 | /** 75 | * Formats the original diff output 76 | * @param {Operation[]} diff The original diff array 77 | * @param {*} firstDocument The first document 78 | * @returns {DiffOutput[]} The modified diffs array 79 | * 80 | * @private 81 | */ 82 | export function formatDiffOutput( 83 | diffInput: Operation[], 84 | firstDocument: any 85 | ): DiffOutput[] { 86 | const output: DiffOutput[] = []; 87 | for (const value of diffInput) { 88 | const changeObject = {} as DiffOutput; 89 | changeObject.action = formatAction(value.op); 90 | changeObject.path = value.path; 91 | setIndex(changeObject, firstDocument, value.path); 92 | if (value.op === 'remove' || value.op === 'replace') { 93 | changeObject.before = getBeforeValue(firstDocument, value.path); 94 | } 95 | if (value.op === 'replace' || value.op === 'add') { 96 | changeObject.after = getAfterValue(value); 97 | } 98 | output.push(changeObject); 99 | } 100 | return output; 101 | } 102 | 103 | export function getDocumentMajorVersion(document: any): string { 104 | const asyncapiVersion: string = document.asyncapi; 105 | return asyncapiVersion.split('.')[0]; 106 | } 107 | 108 | export function incompatibleDocuments( 109 | firstDocument: any, 110 | secondDocument: any 111 | ): boolean { 112 | const firstDocumentMajorVersion = getDocumentMajorVersion(firstDocument); 113 | const secondDocumentMajorVersion = getDocumentMajorVersion(secondDocument); 114 | if (firstDocumentMajorVersion !== secondDocumentMajorVersion) { 115 | return true; 116 | } 117 | return false; 118 | } 119 | -------------------------------------------------------------------------------- /src/helpers/MarkdownHelpers.ts: -------------------------------------------------------------------------------- 1 | import {ChangeMarkdownGenerationConfig, MarkdownDropdownGenerationConfig} from '../types'; 2 | import convertToYAML from './output/convertToYAML'; 3 | 4 | /** 5 | * Groups an array of changes by their 'type' property 6 | * @param object The input object 7 | * @returns The grouped object 8 | */ 9 | export function groupChangesByType(object: any): { string: [{ path: string, any: any }] } { 10 | return object.reduce((objectsByKeyValue: { [x: string]: any; }, obj: { [x: string]: any; }) => { 11 | const value = obj['type']; 12 | // eslint-disable-next-line security/detect-object-injection 13 | objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj); 14 | return objectsByKeyValue; 15 | }, {}); 16 | } 17 | 18 | /** 19 | * Sets the first letter of a string to uppercase 20 | * @param s The input string 21 | * @returns The string with the first letter capitalised 22 | */ 23 | export function capitaliseFirstLetter(s: string): string { 24 | return s[0].toUpperCase() + s.slice(1); 25 | } 26 | 27 | /** 28 | * Generates the Markdown list items for a single change 29 | * @param: config Configuration options for the generated markdown 30 | * @param config.change The object describing the change 31 | * @param config.markdownSubtype the format to display the dropdown data in 32 | * @returns The Markdown list describing the change 33 | */ 34 | export function generateMarkdownForChange(config: ChangeMarkdownGenerationConfig): any { 35 | const toAppend: any[] = [`**Path**: \`${config.change.path}\``]; 36 | const listItem = {ul: [] as any[]}; 37 | 38 | for (const [label, value] of Object.entries(config.change)) { 39 | if (label !== 'path' && label !== 'type') { 40 | // if the value is an object, display within a dropdown 41 | if (typeof value === 'object') { 42 | listItem.ul.push(convertDataToDropdown({ 43 | label: capitaliseFirstLetter(label), 44 | data: value, 45 | markdownSubtype: config.markdownSubtype 46 | })); 47 | } else { 48 | listItem.ul.push(`**${capitaliseFirstLetter(label)}**: ${value}`); 49 | } 50 | } 51 | } 52 | 53 | toAppend.push(listItem); 54 | return toAppend; 55 | } 56 | 57 | /** 58 | * Converts the label and data to a markdown dropdown 59 | * @param config: Configuration options for the generated dropdown 60 | * @param config.label The summary / title 61 | * @param config.data The data to hide in dropdown 62 | * @param config.markdownSubtype the format to display the dropdown data in 63 | * @returns Markdown string with the label as a summary and the data formatted as JSON code 64 | */ 65 | export function convertDataToDropdown(config: MarkdownDropdownGenerationConfig): string { 66 | const displayData = config.markdownSubtype === 'json' ? JSON.stringify(config.data, null, 2) : convertToYAML(config.data); 67 | 68 | return `
69 | ${config.label} 70 | 71 | \`\`\`${config.markdownSubtype} 72 | ${displayData} 73 | \`\`\` 74 |
75 | `; 76 | } 77 | -------------------------------------------------------------------------------- /src/helpers/output/convertToMarkdown.ts: -------------------------------------------------------------------------------- 1 | import json2md from 'json2md'; 2 | import { 3 | capitaliseFirstLetter, 4 | generateMarkdownForChange, 5 | groupChangesByType 6 | } from '../MarkdownHelpers'; 7 | import {MarkdownSubtype} from '../../types'; 8 | 9 | /** 10 | * Converts the diff to Markdown 11 | * @param object The input object 12 | * @param markdownSubtype the format to display the dropdown data in 13 | * @returns Markdown output 14 | */ 15 | export default function convertToMarkdown(object: any, markdownSubtype: MarkdownSubtype): string { 16 | if (Object.prototype.hasOwnProperty.call(object, 'changes')) { 17 | object = object.changes; 18 | } 19 | 20 | const changeTypeGroups = groupChangesByType(object); 21 | 22 | const markdownStructure = []; 23 | 24 | for (const [changeType, changes] of Object.entries(changeTypeGroups)) { 25 | markdownStructure.push({h2: capitaliseFirstLetter(changeType)}); 26 | const outerList = {ul: [] as any[]}; 27 | 28 | for (const change of changes) { 29 | outerList.ul.push(...generateMarkdownForChange({change, markdownSubtype})); 30 | } 31 | 32 | markdownStructure.push(outerList); 33 | } 34 | 35 | return json2md(markdownStructure); 36 | } 37 | -------------------------------------------------------------------------------- /src/helpers/output/convertToYAML.ts: -------------------------------------------------------------------------------- 1 | import yaml from 'js-yaml'; 2 | 3 | /** 4 | * Converts an object to YAML 5 | * @param object The input object 6 | * @returns YAML output 7 | */ 8 | export default function convertToYAML(object: any): string { 9 | return yaml.dump(object); 10 | } 11 | -------------------------------------------------------------------------------- /src/helpers/output/toProperFormat.ts: -------------------------------------------------------------------------------- 1 | import {FormatterConfig} from '../../types'; 2 | import convertToYAML from './convertToYAML'; 3 | import convertToMarkdown from './convertToMarkdown'; 4 | 5 | /** 6 | * Converts diff data to the specified format 7 | * @param config: Configuration options for the target format 8 | * @param config.data The diff data 9 | * @param config.outputType The intended type of the output 10 | * @param config.markdownSubtype the format to display the dropdown data in 11 | * @returns formatted diff output 12 | */ 13 | export default function toProperFormat(config: FormatterConfig): T | string { 14 | if (config.outputType === 'yaml' || config.outputType === 'yml') { 15 | return convertToYAML(config.data); 16 | } else if (config.outputType === 'markdown' || config.outputType === 'md') { 17 | return convertToMarkdown(config.data, config.markdownSubtype); 18 | } 19 | 20 | return config.data; 21 | } 22 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './main'; 2 | export * from './types'; 3 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { Config, OverrideStandard } from './types'; 2 | import generateDiff from './generateDiff'; 3 | import { getStandardFromVersion } from './standard'; 4 | import categorizeChanges from './categorizeChanges'; 5 | import AsyncAPIDiff from './asyncapidiff'; 6 | import { mergeStandard } from './mergeStandard'; 7 | import { incompatibleDocuments } from './helpers/DiffHelpers'; 8 | 9 | /** 10 | * Generates diff between two AsyncAPI documents 11 | * @param firstDocument The parsed AsyncAPI document 12 | * @param secondDocument The parsed AsyncAPI document 13 | * @param config Configuration options 14 | * @param {object} [config.override] Object to override the standard 15 | * @param {string} [config.outputType] The type of output 16 | * @returns {AsyncAPIDiff} The diff data 17 | * 18 | * @example 19 | * ``` 20 | * const output = diff(firstDocument, secondDocument, { 21 | * override: { 22 | * '/servers': { 23 | * add: 'non-breaking', // when a property has been added in the AsyncAPI document 24 | * remove: 'breaking', // when a property has been removed from the AsyncAPI document 25 | * edit: 'unclassified' // when a property has been edited in the AsyncAPI document 26 | * } 27 | * }, 28 | * outputType: "yaml" 29 | * }) 30 | * ``` 31 | */ 32 | export function diff( 33 | firstDocument: any, 34 | secondDocument: any, 35 | config: Config = {} 36 | ): AsyncAPIDiff { 37 | if (incompatibleDocuments(firstDocument, secondDocument)) { 38 | throw new TypeError('diff between different AsyncAPI version is not allowed'); 39 | } 40 | 41 | const standard = getStandardFromVersion(firstDocument); 42 | 43 | if (config.override) { 44 | if (typeof config.override !== 'object') { 45 | throw new TypeError('Override data must be an object'); 46 | } 47 | mergeStandard(standard, config.override); 48 | } 49 | 50 | const diffOutput = generateDiff(firstDocument, secondDocument); 51 | const output = categorizeChanges(standard as OverrideStandard, diffOutput); 52 | return new AsyncAPIDiff(JSON.stringify(output), { 53 | outputType: config.outputType ?? 'json', 54 | markdownSubtype: config.markdownSubtype ?? 'json', 55 | }); 56 | } 57 | -------------------------------------------------------------------------------- /src/mergeStandard.ts: -------------------------------------------------------------------------------- 1 | import { OverrideObject, StandardType } from './types'; 2 | 3 | /** 4 | * Merges two standard objects 5 | * @param standard The original standard object 6 | * @param overrides The object containing the overrides 7 | * 8 | * @private 9 | */ 10 | export function mergeStandard( 11 | standard: StandardType, 12 | overrides: OverrideObject 13 | ): void { 14 | // modifies the passed standard object 15 | Object.assign(standard, overrides); 16 | } 17 | -------------------------------------------------------------------------------- /src/standard.ts: -------------------------------------------------------------------------------- 1 | import { getDocumentMajorVersion } from './helpers/DiffHelpers'; 2 | import { standard as v2Standard } from './standards/v2'; 3 | import { standard as v3Standard } from './standards/v3'; 4 | import { StandardType } from 'types'; 5 | 6 | export function getStandardFromVersion(document: any): StandardType { 7 | const majorVersion = getDocumentMajorVersion(document); 8 | if (majorVersion === '2') { 9 | return v2Standard; 10 | } 11 | return v3Standard; 12 | } 13 | -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | import {ReplaceOperation, AddOperation} from 'fast-json-patch'; 2 | 3 | import {standard as v2Standard} from './standards/v2'; 4 | import {standard as v3Standard} from './standards/v3'; 5 | import {breaking, nonBreaking, unclassified} from './constants'; 6 | 7 | export type ActionType = 'add' | 'remove' | 'edit'; 8 | 9 | export type ChangeType = 10 | | typeof breaking 11 | | typeof nonBreaking 12 | | typeof unclassified; 13 | 14 | export interface Classifier { 15 | add: ChangeType; 16 | remove: ChangeType; 17 | edit: ChangeType; 18 | } 19 | 20 | export interface DiffOutput { 21 | action: ActionType; 22 | path: string; 23 | isArrayIndex?: boolean; 24 | before?: any; 25 | after?: any; 26 | } 27 | 28 | export type DiffOutputItem = DiffOutput & { 29 | type: ChangeType; 30 | }; 31 | 32 | export type Changes = DiffOutputItem[] | string; 33 | 34 | export interface JSONOutput { 35 | changes: DiffOutputItem[]; 36 | } 37 | 38 | export type Output = JSONOutput | string; 39 | 40 | export type ValueOperation = ReplaceOperation | AddOperation; 41 | 42 | export type StandardType = typeof v2Standard | typeof v3Standard; 43 | 44 | export interface OverrideObject { 45 | [key: string]: Classifier; 46 | } 47 | 48 | export type OverrideStandard = StandardType & OverrideObject; 49 | 50 | export type OutputType = 'json' | 'yaml' | 'yml' | 'markdown' | 'md'; 51 | 52 | export type MarkdownSubtype = 'json' | 'yaml' | 'yml'; 53 | 54 | export interface FormatterConfig { 55 | data: T, 56 | outputType: OutputType, 57 | markdownSubtype: MarkdownSubtype 58 | } 59 | 60 | export interface ChangeMarkdownGenerationConfig { 61 | change: { path: string, any: any }, 62 | markdownSubtype: MarkdownSubtype 63 | } 64 | 65 | export interface MarkdownDropdownGenerationConfig { 66 | label: string, 67 | data: { string: any }, 68 | markdownSubtype: MarkdownSubtype 69 | } 70 | 71 | export interface AsyncAPIDiffOptions { 72 | outputType: OutputType; 73 | markdownSubtype?: MarkdownSubtype; 74 | } 75 | 76 | export interface Config { 77 | override?: OverrideObject; 78 | outputType?: OutputType; 79 | markdownSubtype?: MarkdownSubtype; 80 | } 81 | -------------------------------------------------------------------------------- /standard-format.md: -------------------------------------------------------------------------------- 1 | # Understanding the format of standard 2 | 3 | This library depends on a "standard" which classifies a certain change as `breaking`, `non-breaking` or `unclassified`. 4 | 5 | This object has the following structure: 6 | 7 | ``` 8 | { 9 | [jsonPointerPath]: { 10 | add: 'breaking' | 'non-breaking' | 'unclassified', 11 | remove: 'breaking' | 'non-breaking' | 'unclassified', 12 | edit: 'breaking' | 'non-breaking' | 'unclassified', 13 | } 14 | } 15 | ``` 16 | 17 | `jsonPointerPath` is a path that points to a certain property from the AsyncAPI specification. 18 | 19 | Example: 20 | 21 | ```yml 22 | info: 23 | license: 24 | name: Apache 2.0 25 | ``` 26 | 27 | The jsonPointer to the `name` will be `/info/license/name`. 28 | 29 | And each `jsonPointerPath` will have 3 properties. `add`, `remove` and `edit`, these points to three operations that can occur when modifying a AsyncAPI document. 30 | 31 | 1. `add` - A new property has been added. 32 | 2. `remove` - An existing property has been deleted. 33 | 3. `edit` - An existing property has been modified. 34 | 35 | and each property can be `breaking`, `non-breaking` or `unclassified`. 36 | 37 | 1. `breaking` to consider a change as breaking change. 38 | 2. `non-breaking` to consider a change as non-breaking change. 39 | 3. `unclassified` to consider a change as an unclassified change. 40 | 41 | Here's an example from the `standard.ts` file: 42 | 43 | ```js 44 | { 45 | '/info/license/name': { 46 | add: 'breaking', 47 | remove: 'breaking', 48 | edit: 'breaking' 49 | } 50 | } 51 | ``` 52 | 53 | ## Working with patterned fields 54 | 55 | Since the AsyncAPI specifications allow the use of patterned fields, and these patterned fields differ from spec to spec. 56 | 57 | Therefore, to overcome this issue, we came up `*` wildcard. The `*` will match any pattern it will get. 58 | 59 | For example, 60 | 61 | ```yml 62 | servers: 63 | google: 64 | protocol: https 65 | ``` 66 | 67 | The AsyncAPI spec says that the server name(in this case `google`) is a patterned field. It can be `google`, `bing` or whatever the user wants. 68 | 69 | To match this patterned fields, the `jsonPointerPath` for this is `/servers/*/protocol`. This path can match `/servers/google/protocol` as well as `/servers/bing/protocol`. 70 | 71 | ## Working with array indexes 72 | 73 | Since a change can also occur inside an array, the diff generates a path having the `index` of the array where the change has been occured. 74 | 75 | For example, 76 | 77 | ```yml 78 | servers: 79 | google: 80 | ports: [3000, 8000] # This is an example. Such property doesn't exist in the spec at this time 81 | ``` 82 | 83 | Removing `8000` from `ports` will result in change path as `/servers/google/ports/2`. 84 | 85 | This array index can vary, so for array indexes we again use the `*`. 86 | 87 | In the standard, we can map this path as `/servers/*/ports/*`. This can match `/servers/google/ports/100` as well as `/servers/bing/ports/99`. 88 | 89 | This concludes our understanding of the format in which the standard is written. This format is also used in overriding the standard. 90 | -------------------------------------------------------------------------------- /test/ClassifierHelpers.spec.ts: -------------------------------------------------------------------------------- 1 | import { 2 | changeLastElementToPlaceholder, 3 | generateClassifierPath, 4 | } from '../src/helpers/ClassifierHelpers'; 5 | import { OverrideStandard } from '../src/types'; 6 | 7 | import { demoStandard } from './fixtures/classifier.fixtures'; 8 | import { pathAsArray } from './fixtures/ClassifierHelpers.fixtures'; 9 | 10 | describe('changeLastElementToPlaceholder function', () => { 11 | test('when passed an empty array', () => { 12 | expect(changeLastElementToPlaceholder([])).toBe('*'); 13 | }); 14 | 15 | test('should return correct output', () => { 16 | expect(changeLastElementToPlaceholder(pathAsArray)).toBe('/servers/*'); 17 | }); 18 | }); 19 | 20 | describe('generateClassifierPath function', () => { 21 | test('should return undefined when passed an empty standard', () => { 22 | expect(generateClassifierPath({} as OverrideStandard, '/')).toEqual( 23 | undefined 24 | ); 25 | }); 26 | 27 | test('should return correct path', () => { 28 | expect( 29 | generateClassifierPath(demoStandard as OverrideStandard, '/servers') 30 | ).toBe('/servers'); 31 | }); 32 | 33 | test('should return correct path', () => { 34 | expect( 35 | generateClassifierPath( 36 | demoStandard as OverrideStandard, 37 | '/servers/google' 38 | ) 39 | ).toBe('/servers/*'); 40 | }); 41 | 42 | test('shold return undefined for non-existing path', () => { 43 | expect( 44 | generateClassifierPath( 45 | demoStandard as OverrideStandard, 46 | '/servers/google/someProperty' 47 | ) 48 | ).toEqual(undefined); 49 | }); 50 | 51 | test('shold return correct path', () => { 52 | expect( 53 | generateClassifierPath( 54 | demoStandard as OverrideStandard, 55 | '/servers/google/protocol' 56 | ) 57 | ).toBe('/servers/*/protocol'); 58 | }); 59 | }); 60 | -------------------------------------------------------------------------------- /test/asycnapidiff.spec.ts: -------------------------------------------------------------------------------- 1 | import AsyncAPIDiff from '../src/asyncapidiff'; 2 | 3 | import { 4 | breakingChanges, 5 | inputDiff, 6 | nonbreakingChanges, 7 | unclassifiedChanges, 8 | YAMLBreakingChanges, 9 | YAMLNonbreakingChanges, 10 | YAMLOutputDiff, 11 | YAMLUnclassifiedChanges, 12 | MarkdownBreakingChanges, 13 | MarkdownNonbreakingChanges, 14 | MarkdownOutputDiff, 15 | MarkdownUnclassifiedChanges, 16 | MarkdownJSONSubtypeChanges, 17 | MarkdownYAMLSubtypeChanges, 18 | } from './fixtures/asyncapidiff.fixtures'; 19 | 20 | import { 21 | diffOutput 22 | } from './fixtures/main.fixtures'; 23 | 24 | describe('AsyncAPIDiff wrapper', () => { 25 | test('checks the instance', () => { 26 | expect( 27 | new AsyncAPIDiff(JSON.stringify(inputDiff), {outputType: 'json'}) 28 | ).toBeInstanceOf(AsyncAPIDiff); 29 | }); 30 | 31 | test('JSON: checks the original output', () => { 32 | const diff = new AsyncAPIDiff(JSON.stringify(inputDiff), { 33 | outputType: 'json', 34 | }); 35 | expect(diff.getOutput()).toEqual(inputDiff); 36 | }); 37 | 38 | test('JSON: returns breaking changes', () => { 39 | const diff = new AsyncAPIDiff(JSON.stringify(inputDiff), { 40 | outputType: 'json', 41 | }); 42 | expect(diff.breaking()).toEqual(breakingChanges); 43 | }); 44 | 45 | test('JSON: returns non-breaking changes', () => { 46 | const diff = new AsyncAPIDiff(JSON.stringify(inputDiff), { 47 | outputType: 'json', 48 | }); 49 | expect(diff.nonBreaking()).toEqual(nonbreakingChanges); 50 | }); 51 | 52 | test('JSON: returns unclassified changes', () => { 53 | const diff = new AsyncAPIDiff(JSON.stringify(inputDiff), { 54 | outputType: 'json', 55 | }); 56 | expect(diff.unclassified()).toEqual(unclassifiedChanges); 57 | }); 58 | 59 | test('YAML: checks the original output', () => { 60 | const diff = new AsyncAPIDiff(JSON.stringify(inputDiff), { 61 | outputType: 'yaml', 62 | }); 63 | expect(diff.getOutput()).toEqual(YAMLOutputDiff); 64 | }); 65 | 66 | test('YAML: returns breaking changes', () => { 67 | const diff = new AsyncAPIDiff(JSON.stringify(inputDiff), { 68 | outputType: 'yaml', 69 | }); 70 | expect(diff.breaking()).toEqual(YAMLBreakingChanges); 71 | }); 72 | 73 | test('YAML: returns non-breaking changes', () => { 74 | const diff = new AsyncAPIDiff(JSON.stringify(inputDiff), { 75 | outputType: 'yaml', 76 | }); 77 | expect(diff.nonBreaking()).toEqual(YAMLNonbreakingChanges); 78 | }); 79 | 80 | test('YAML: returns unclassified changes', () => { 81 | const diff = new AsyncAPIDiff(JSON.stringify(inputDiff), { 82 | outputType: 'yaml', 83 | }); 84 | expect(diff.unclassified()).toEqual(YAMLUnclassifiedChanges); 85 | }); 86 | 87 | test('Markdown: returns the original full output', () => { 88 | const diff = new AsyncAPIDiff(JSON.stringify(inputDiff), { 89 | outputType: 'markdown', 90 | }); 91 | expect(diff.getOutput()).toEqual(MarkdownOutputDiff); 92 | }); 93 | 94 | test('Markdown: returns breaking changes', () => { 95 | const diff = new AsyncAPIDiff(JSON.stringify(inputDiff), { 96 | outputType: 'markdown', 97 | }); 98 | expect(diff.breaking()).toEqual(MarkdownBreakingChanges); 99 | }); 100 | 101 | test('Markdown: returns non-breaking changes', () => { 102 | const diff = new AsyncAPIDiff(JSON.stringify(inputDiff), { 103 | outputType: 'markdown', 104 | }); 105 | expect(diff.nonBreaking()).toEqual(MarkdownNonbreakingChanges); 106 | }); 107 | 108 | test('Markdown: returns unclassified changes', () => { 109 | const diff = new AsyncAPIDiff(JSON.stringify(inputDiff), { 110 | outputType: 'markdown', 111 | }); 112 | expect(diff.unclassified()).toEqual(MarkdownUnclassifiedChanges); 113 | }); 114 | 115 | test('Markdown: returns changes using subtype JSON as the default', () => { 116 | const diff = new AsyncAPIDiff(JSON.stringify(diffOutput), { 117 | outputType: 'markdown', 118 | }); 119 | expect(diff.getOutput()).toEqual(MarkdownJSONSubtypeChanges); 120 | }); 121 | 122 | test('Markdown: returns changes using subtype YAML', () => { 123 | const diff = new AsyncAPIDiff(JSON.stringify(diffOutput), { 124 | outputType: 'markdown', 125 | markdownSubtype: 'yaml', 126 | }); 127 | expect(diff.getOutput()).toEqual(MarkdownYAMLSubtypeChanges); 128 | }); 129 | }); 130 | -------------------------------------------------------------------------------- /test/categorizeChanges.spec.ts: -------------------------------------------------------------------------------- 1 | import categorizeChanges from '../src/categorizeChanges'; 2 | import { DiffOutput, OverrideStandard } from '../src/types'; 3 | 4 | import { 5 | standard, 6 | inputDiffOutput, 7 | finalDiffOutput, 8 | finalDiffOutputAsUnclassified, 9 | } from './fixtures/categorizeChanges.fixtures'; 10 | 11 | describe('categorizeChanges', () => { 12 | test('checks the final output', () => { 13 | expect( 14 | categorizeChanges( 15 | standard as OverrideStandard, 16 | inputDiffOutput as DiffOutput[] 17 | ) 18 | ).toStrictEqual(finalDiffOutput); 19 | }); 20 | 21 | test('returns unclassified when passed with empty standard', () => { 22 | expect( 23 | categorizeChanges({} as OverrideStandard, inputDiffOutput as DiffOutput[]) 24 | ).toStrictEqual(finalDiffOutputAsUnclassified); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /test/classifier.spec.ts: -------------------------------------------------------------------------------- 1 | import classifier from '../src/classifier'; 2 | import { OverrideStandard } from '../src/types'; 3 | 4 | import { 5 | correctClassification, 6 | demoStandard, 7 | unclassifiedChange, 8 | } from './fixtures/classifier.fixtures'; 9 | 10 | describe('classifier', () => { 11 | test('should return unclassified in case of empty standard', () => { 12 | expect(classifier({} as OverrideStandard, '/some/path')).toStrictEqual( 13 | unclassifiedChange 14 | ); 15 | }); 16 | 17 | test('should return the correct classification with correct path', () => { 18 | expect( 19 | classifier(demoStandard as OverrideStandard, '/servers') 20 | ).toStrictEqual(correctClassification); 21 | }); 22 | 23 | test('should return the correct classification with placeholder path', () => { 24 | expect( 25 | classifier(demoStandard as OverrideStandard, '/servers/google') 26 | ).toStrictEqual(correctClassification); 27 | }); 28 | 29 | test('should return the correct classification with placeholder path', () => { 30 | expect( 31 | classifier(demoStandard as OverrideStandard, '/servers/google/protocol') 32 | ).toStrictEqual(correctClassification); 33 | }); 34 | }); 35 | -------------------------------------------------------------------------------- /test/fixtures/ClassifierHelpers.fixtures.ts: -------------------------------------------------------------------------------- 1 | export const pathAsArray = ['', 'servers', 'google']; 2 | -------------------------------------------------------------------------------- /test/fixtures/DiffHelpers.fixtures.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable sonarjs/no-duplicate-string */ 2 | export const firstDocument = { 3 | servers: { 4 | production: { 5 | name: 'production', 6 | enum: [1, 2, 3], 7 | }, 8 | }, 9 | }; 10 | 11 | export const modifyDiffInput = { 12 | servers: { 13 | production: { 14 | protocol: 'http', 15 | }, 16 | }, 17 | }; 18 | 19 | export const diffAdd = [ 20 | { 21 | op: 'add', 22 | path: '/servers/production/protocol', 23 | value: 'https', 24 | }, 25 | ]; 26 | 27 | export const diffAddOutput = [ 28 | { action: 'add', path: '/servers/production/protocol', after: 'https' }, 29 | ]; 30 | 31 | export const diffRemove = [ 32 | { 33 | op: 'remove', 34 | path: '/servers/production/protocol', 35 | }, 36 | ]; 37 | 38 | export const diffRemoveOutput = [ 39 | { 40 | action: 'remove', 41 | path: '/servers/production/protocol', 42 | before: 'http', 43 | }, 44 | ]; 45 | 46 | export const diffEdit = [ 47 | { 48 | op: 'replace', 49 | path: '/servers/production/protocol', 50 | value: 'https', 51 | }, 52 | ]; 53 | 54 | export const diffEditOutput = [ 55 | { 56 | action: 'edit', 57 | path: '/servers/production/protocol', 58 | before: 'http', 59 | after: 'https', 60 | }, 61 | ]; 62 | -------------------------------------------------------------------------------- /test/fixtures/asyncapidiff.fixtures.ts: -------------------------------------------------------------------------------- 1 | export const inputDiff = { 2 | changes: [ 3 | { 4 | type: 'breaking', 5 | path: '/servers', 6 | }, 7 | { 8 | type: 'non-breaking', 9 | path: '/channels', 10 | }, 11 | { 12 | type: 'unclassified', 13 | path: '/info', 14 | }, 15 | ], 16 | }; 17 | 18 | export const breakingChanges = [ 19 | { 20 | type: 'breaking', 21 | path: '/servers', 22 | }, 23 | ]; 24 | 25 | export const nonbreakingChanges = [ 26 | { 27 | type: 'non-breaking', 28 | path: '/channels', 29 | }, 30 | ]; 31 | 32 | export const unclassifiedChanges = [ 33 | { 34 | type: 'unclassified', 35 | path: '/info', 36 | }, 37 | ]; 38 | 39 | export const YAMLOutputDiff = `changes: 40 | - type: breaking 41 | path: /servers 42 | - type: non-breaking 43 | path: /channels 44 | - type: unclassified 45 | path: /info 46 | `; 47 | 48 | export const YAMLBreakingChanges = `- type: breaking 49 | path: /servers 50 | `; 51 | 52 | export const YAMLNonbreakingChanges = `- type: non-breaking 53 | path: /channels 54 | `; 55 | 56 | export const YAMLUnclassifiedChanges = `- type: unclassified 57 | path: /info 58 | `; 59 | 60 | export const MarkdownOutputDiff = `## Breaking 61 | 62 | 63 | - **Path**: \`/servers\` 64 | 65 | 66 | ## Non-breaking 67 | 68 | 69 | - **Path**: \`/channels\` 70 | 71 | 72 | ## Unclassified 73 | 74 | 75 | - **Path**: \`/info\` 76 | 77 | `; 78 | 79 | export const MarkdownBreakingChanges = `## Breaking 80 | 81 | 82 | - **Path**: \`/servers\` 83 | 84 | `; 85 | 86 | export const MarkdownNonbreakingChanges = `## Non-breaking 87 | 88 | 89 | - **Path**: \`/channels\` 90 | 91 | `; 92 | 93 | export const MarkdownUnclassifiedChanges = `## Unclassified 94 | 95 | 96 | - **Path**: \`/info\` 97 | 98 | `; 99 | 100 | export const MarkdownJSONSubtypeChanges = `## Breaking 101 | 102 | 103 | - **Path**: \`/channels/mychannel\` 104 | - **Action**: remove 105 | -
106 | Before 107 | 108 | \`\`\`json 109 | { 110 | "publish": { 111 | "message": { 112 | "headers": { 113 | "properties": { 114 | "some-common-header": { 115 | "type": "string", 116 | "x-parser-schema-id": "" 117 | } 118 | }, 119 | "type": "object", 120 | "x-parser-schema-id": "" 121 | }, 122 | "x-parser-message-name": "channelMessage", 123 | "traits": [ 124 | { 125 | "headers": { 126 | "properties": { 127 | "some-common-header": { 128 | "type": "string", 129 | "x-parser-schema-id": "" 130 | } 131 | }, 132 | "type": "object", 133 | "x-parser-schema-id": "" 134 | }, 135 | "x-some-extension": "some extension" 136 | } 137 | ], 138 | "x-some-extension": "some extension" 139 | } 140 | } 141 | } 142 | \`\`\` 143 |
144 | 145 | 146 | - **Path**: \`/info/version\` 147 | - **Action**: edit 148 | - **After**: 1.1.0 149 | - **Before**: 1.0.0 150 | 151 | 152 | ## Non-breaking 153 | 154 | 155 | - **Path**: \`/channels/anotherChannel\` 156 | - **Action**: add 157 | -
158 | After 159 | 160 | \`\`\`json 161 | { 162 | "publish": { 163 | "message": { 164 | "headers": { 165 | "properties": { 166 | "some-common-header": { 167 | "type": "string", 168 | "x-parser-schema-id": "" 169 | } 170 | }, 171 | "type": "object", 172 | "x-parser-schema-id": "" 173 | }, 174 | "x-parser-message-name": "channelMessage", 175 | "traits": [ 176 | { 177 | "headers": { 178 | "properties": { 179 | "some-common-header": { 180 | "type": "string", 181 | "x-parser-schema-id": "" 182 | } 183 | }, 184 | "type": "object", 185 | "x-parser-schema-id": "" 186 | }, 187 | "x-some-extension": "some extension" 188 | } 189 | ], 190 | "x-some-extension": "some extension" 191 | } 192 | } 193 | } 194 | \`\`\` 195 |
196 | 197 | 198 | `; 199 | 200 | export const MarkdownYAMLSubtypeChanges = `## Breaking 201 | 202 | 203 | - **Path**: \`/channels/mychannel\` 204 | - **Action**: remove 205 | -
206 | Before 207 | 208 | \`\`\`yaml 209 | publish: 210 | message: 211 | headers: 212 | properties: 213 | some-common-header: 214 | type: string 215 | x-parser-schema-id: 216 | type: object 217 | x-parser-schema-id: 218 | x-parser-message-name: channelMessage 219 | traits: 220 | - headers: 221 | properties: 222 | some-common-header: 223 | type: string 224 | x-parser-schema-id: 225 | type: object 226 | x-parser-schema-id: 227 | x-some-extension: some extension 228 | x-some-extension: some extension 229 | 230 | \`\`\` 231 |
232 | 233 | 234 | - **Path**: \`/info/version\` 235 | - **Action**: edit 236 | - **After**: 1.1.0 237 | - **Before**: 1.0.0 238 | 239 | 240 | ## Non-breaking 241 | 242 | 243 | - **Path**: \`/channels/anotherChannel\` 244 | - **Action**: add 245 | -
246 | After 247 | 248 | \`\`\`yaml 249 | publish: 250 | message: 251 | headers: 252 | properties: 253 | some-common-header: 254 | type: string 255 | x-parser-schema-id: 256 | type: object 257 | x-parser-schema-id: 258 | x-parser-message-name: channelMessage 259 | traits: 260 | - headers: 261 | properties: 262 | some-common-header: 263 | type: string 264 | x-parser-schema-id: 265 | type: object 266 | x-parser-schema-id: 267 | x-some-extension: some extension 268 | x-some-extension: some extension 269 | 270 | \`\`\` 271 |
272 | 273 | 274 | `; 275 | -------------------------------------------------------------------------------- /test/fixtures/categorizeChanges.fixtures.ts: -------------------------------------------------------------------------------- 1 | export const standard = { 2 | '/servers': { 3 | add: 'non-breaking', 4 | remove: 'breaking', 5 | edit: 'breaking', 6 | }, 7 | }; 8 | 9 | export const inputDiffOutput = [ 10 | { 11 | action: 'remove', 12 | path: '/servers', 13 | }, 14 | ]; 15 | 16 | export const finalDiffOutput = { 17 | changes: [ 18 | { 19 | action: 'remove', 20 | path: '/servers', 21 | type: 'breaking', 22 | }, 23 | ], 24 | }; 25 | 26 | export const finalDiffOutputAsUnclassified = { 27 | changes: [ 28 | { 29 | action: 'remove', 30 | path: '/servers', 31 | type: 'unclassified', 32 | }, 33 | ], 34 | }; 35 | -------------------------------------------------------------------------------- /test/fixtures/classifier.fixtures.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable sonarjs/no-duplicate-string */ 2 | export const demoStandard = { 3 | '/servers': { 4 | add: 'non-breaking', 5 | remove: 'breaking', 6 | edit: 'breaking', 7 | }, 8 | '/servers/*': { 9 | add: 'non-breaking', 10 | remove: 'breaking', 11 | edit: 'breaking', 12 | }, 13 | '/servers/*/protocol': { 14 | add: 'non-breaking', 15 | remove: 'breaking', 16 | edit: 'breaking', 17 | }, 18 | }; 19 | 20 | export const correctClassification = { 21 | add: 'non-breaking', 22 | remove: 'breaking', 23 | edit: 'breaking', 24 | }; 25 | 26 | export const unclassifiedChange = { 27 | add: 'unclassified', 28 | remove: 'unclassified', 29 | edit: 'unclassified', 30 | }; 31 | -------------------------------------------------------------------------------- /test/fixtures/diff.fixtures.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable sonarjs/no-duplicate-string */ 2 | 3 | export const firstDocument = { 4 | servers: { 5 | production: { 6 | name: 'production', 7 | enum: [1, 2, 3], 8 | }, 9 | }, 10 | }; 11 | 12 | export const secondDocument = { 13 | servers: { 14 | production: { 15 | name: 'production-dev', 16 | enum: [1, 2], 17 | }, 18 | }, 19 | }; 20 | 21 | export const diffLocalOutput = [ 22 | { 23 | action: 'remove', 24 | path: '/servers/production/enum/2', 25 | isArrayIndex: true, 26 | before: 3, 27 | }, 28 | { 29 | action: 'edit', 30 | path: '/servers/production/name', 31 | before: 'production', 32 | after: 'production-dev', 33 | }, 34 | ]; 35 | 36 | export const diffOutput = [ 37 | { 38 | action: 'remove', 39 | path: '/channels/mychannel', 40 | before: { 41 | publish: { 42 | message: { 43 | headers: { 44 | properties: { 45 | 'some-common-header': { 46 | type: 'string', 47 | 'x-parser-schema-id': '', 48 | }, 49 | }, 50 | type: 'object', 51 | 'x-parser-schema-id': '', 52 | }, 53 | traits: [ 54 | { 55 | headers: { 56 | properties: { 57 | 'some-common-header': { 58 | type: 'string', 59 | 'x-parser-schema-id': '', 60 | }, 61 | }, 62 | type: 'object', 63 | 'x-parser-schema-id': '', 64 | }, 65 | 'x-some-extension': 'some extension', 66 | }, 67 | ], 68 | 'x-parser-message-name': 'channelMessage', 69 | 'x-some-extension': 'some extension', 70 | }, 71 | }, 72 | }, 73 | }, 74 | { 75 | action: 'add', 76 | path: '/channels/anotherChannel', 77 | after: { 78 | publish: { 79 | message: { 80 | headers: { 81 | properties: { 82 | 'some-common-header': { 83 | type: 'string', 84 | 'x-parser-schema-id': '', 85 | }, 86 | }, 87 | type: 'object', 88 | 'x-parser-schema-id': '', 89 | }, 90 | traits: [ 91 | { 92 | headers: { 93 | properties: { 94 | 'some-common-header': { 95 | type: 'string', 96 | 'x-parser-schema-id': '', 97 | }, 98 | }, 99 | type: 'object', 100 | 'x-parser-schema-id': '', 101 | }, 102 | 'x-some-extension': 'some extension', 103 | }, 104 | ], 105 | 'x-parser-message-name': 'channelMessage', 106 | 'x-some-extension': 'some extension', 107 | }, 108 | }, 109 | }, 110 | }, 111 | { 112 | action: 'edit', 113 | path: '/info/version', 114 | after: '1.1.0', 115 | before: '1.0.0', 116 | }, 117 | ]; 118 | -------------------------------------------------------------------------------- /test/fixtures/parser.fixtures.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable sonarjs/no-duplicate-string */ 2 | export const outputJSONMessagesChannels = 3 | '{"asyncapi":"2.0.0","info":{"title":"My API","version":"1.0.0"},"channels":{"mychannel":{"publish":{"message":{"x-some-extension":"some extension","headers":{"type":"object","properties":{"some-common-header":{"type":"string","x-parser-schema-id":""}},"x-parser-schema-id":""},"x-parser-original-traits":[{"x-some-extension":"some extension","headers":{"type":"object","properties":{"some-common-header":{"type":"string"}}}}],"schemaFormat":"application/vnd.aai.asyncapi;version=2.0.0","x-parser-message-parsed":true,"x-parser-message-name":"channelMessage"}}}},"components":{"messages":{"channelMessage":{"x-some-extension":"some extension","headers":{"type":"object","properties":{"some-common-header":{"type":"string","x-parser-schema-id":""}},"x-parser-schema-id":""},"x-parser-original-traits":[{"x-some-extension":"some extension","headers":{"type":"object","properties":{"some-common-header":{"type":"string"}}}}],"schemaFormat":"application/vnd.aai.asyncapi;version=2.0.0","x-parser-message-parsed":true,"x-parser-message-name":"channelMessage"},"testMessage":{"payload":{"type":"object","properties":{"name":{"type":"string","x-parser-schema-id":""}},"x-parser-schema-id":"testSchema"},"x-some-extension":"some extension","headers":{"type":"object","properties":{"some-common-header":{"type":"string","x-parser-schema-id":""}},"x-parser-schema-id":""},"x-parser-original-traits":[{"x-some-extension":"some extension","headers":{"type":"object","properties":{"some-common-header":{"type":"string"}}}}],"x-parser-original-schema-format":"application/vnd.aai.asyncapi;version=2.0.0","x-parser-original-payload":{"type":"object","properties":{"name":{"type":"string"}}},"schemaFormat":"application/vnd.aai.asyncapi;version=2.0.0","x-parser-message-parsed":true,"x-parser-message-name":"testMessage"}},"schemas":{"testSchema":{"type":"object","properties":{"name":{"type":"string","x-parser-schema-id":""}},"x-parser-schema-id":"testSchema"}},"messageTraits":{"extension":{"x-some-extension":"some extension","headers":{"type":"object","properties":{"some-common-header":{"type":"string"}}}}}},"x-parser-spec-parsed":true}'; 4 | 5 | export const AsyncAPIDoc = `asyncapi: 2.0.0 6 | info: 7 | title: My API 8 | version: '1.0.0' 9 | 10 | channels: 11 | mychannel: 12 | publish: 13 | message: 14 | $ref: '#/components/messages/channelMessage' 15 | 16 | components: 17 | messages: 18 | channelMessage: 19 | traits: 20 | - $ref: '#/components/messageTraits/extension' 21 | testMessage: 22 | traits: 23 | - $ref: '#/components/messageTraits/extension' 24 | payload: 25 | $ref: '#/components/schemas/testSchema' 26 | schemas: 27 | testSchema: 28 | type: object 29 | properties: 30 | name: 31 | type: string 32 | messageTraits: 33 | extension: 34 | x-some-extension: 'some extension' 35 | headers: 36 | type: object 37 | properties: 38 | some-common-header: 39 | type: string 40 | `; 41 | -------------------------------------------------------------------------------- /test/generateDiff.spec.ts: -------------------------------------------------------------------------------- 1 | import { Parser } from '@asyncapi/parser'; 2 | import { readFileSync } from 'fs'; 3 | import { resolve } from 'path'; 4 | 5 | import generateDiff from '../src/generateDiff'; 6 | 7 | import { 8 | firstDocument, 9 | secondDocument, 10 | diffLocalOutput, 11 | diffOutput, 12 | } from './fixtures/diff.fixtures'; 13 | 14 | const parser = new Parser(); 15 | 16 | describe('Diff', () => { 17 | test('Check if diff is an empty array for same inputs', () => { 18 | expect(generateDiff(firstDocument, firstDocument)).toStrictEqual([]); 19 | }); 20 | 21 | test('Check diff output with local inputs', () => { 22 | expect(generateDiff(firstDocument, secondDocument)).toStrictEqual( 23 | diffLocalOutput 24 | ); 25 | }); 26 | 27 | test('Check diff output through parser with no difference', async () => { 28 | const specDocument = readFileSync( 29 | resolve('./test/spec/asyncapi.yml'), 30 | 'utf-8' 31 | ); 32 | const firstDocument = await parser.parse(specDocument); 33 | expect( 34 | generateDiff( 35 | firstDocument.document?.json(), 36 | firstDocument.document?.json() 37 | ) 38 | ).toStrictEqual([]); 39 | }); 40 | 41 | test('Check diff output through parser with difference input', async () => { 42 | const firstSpecDocument = readFileSync( 43 | resolve('./test/spec/asyncapi.yml'), 44 | 'utf-8' 45 | ); 46 | const secondSpecDocument = readFileSync( 47 | resolve('./test/spec/diffSpec.yml'), 48 | 'utf-8' 49 | ); 50 | const firstDocument = await parser.parse(firstSpecDocument); 51 | const secondDocument = await parser.parse(secondSpecDocument); 52 | expect( 53 | generateDiff( 54 | firstDocument.document?.json(), 55 | secondDocument.document?.json() 56 | ) 57 | ).toStrictEqual(diffOutput); 58 | }); 59 | }); 60 | -------------------------------------------------------------------------------- /test/helpers/DiffHelpers.spec.ts: -------------------------------------------------------------------------------- 1 | import { Operation } from 'fast-json-patch'; 2 | 3 | import { 4 | formatAction, 5 | getBeforeValue, 6 | setIndex, 7 | formatDiffOutput, 8 | getDocumentMajorVersion, 9 | incompatibleDocuments, 10 | } from '../../src/helpers/DiffHelpers'; 11 | import { DiffOutput } from '../../src/types'; 12 | import { 13 | firstDocument, 14 | diffAdd, 15 | diffAddOutput, 16 | diffRemove, 17 | diffRemoveOutput, 18 | diffEdit, 19 | diffEditOutput, 20 | modifyDiffInput, 21 | } from '../fixtures/DiffHelpers.fixtures'; 22 | 23 | describe('Diff Helpers', () => { 24 | test('formatAction function', () => { 25 | expect(formatAction('add')).toBe('add'); 26 | expect(formatAction('remove')).toBe('remove'); 27 | expect(formatAction('replace')).toBe('edit'); 28 | }); 29 | 30 | test('getBeforeValue function', () => { 31 | expect(getBeforeValue(firstDocument, '/servers/production/name')).toBe( 32 | 'production' 33 | ); 34 | }); 35 | 36 | test('setIndex function without array change', () => { 37 | const changeObject = {} as DiffOutput; 38 | setIndex(changeObject, firstDocument, '/servers'); 39 | expect(changeObject).toStrictEqual({}); 40 | }); 41 | 42 | test('handlePath function with array change', () => { 43 | const changeObject = {} as DiffOutput; 44 | setIndex(changeObject, firstDocument, '/servers/production/enum/1'); 45 | expect(changeObject).toStrictEqual({ 46 | isArrayIndex: true, 47 | }); 48 | }); 49 | }); 50 | 51 | describe('formatDiffOutput function', () => { 52 | test('should return an empty array after passing empty diff', () => { 53 | expect(formatDiffOutput([], {})).toEqual([]); 54 | }); 55 | 56 | test('using add operation', () => { 57 | expect(formatDiffOutput(diffAdd as Operation[], {})).toStrictEqual( 58 | diffAddOutput 59 | ); 60 | }); 61 | 62 | test('using remove operation', () => { 63 | expect( 64 | formatDiffOutput(diffRemove as Operation[], modifyDiffInput) 65 | ).toStrictEqual(diffRemoveOutput); 66 | }); 67 | 68 | test('should throw error when firstDocuments is empty', () => { 69 | expect(() => formatDiffOutput(diffRemove as Operation[], {})).toThrowError( 70 | // eslint-disable-next-line quotes 71 | new TypeError("Cannot read properties of undefined (reading 'production')") 72 | ); 73 | }); 74 | 75 | test('using edit operation', () => { 76 | expect( 77 | formatDiffOutput(diffEdit as Operation[], modifyDiffInput) 78 | ).toStrictEqual(diffEditOutput); 79 | }); 80 | }); 81 | 82 | describe('between different asyncapi version', () => { 83 | test('should return correct asyncapi major version', () => { 84 | expect(getDocumentMajorVersion({asyncapi: '3.0.0'})).toEqual('3'); 85 | }); 86 | 87 | test('documents are incompatible', () => { 88 | expect(incompatibleDocuments({asyncapi: '3.0.0'}, {asyncapi: '2.1.0'})).toBeTruthy(); 89 | }); 90 | 91 | test('documents are compatible', () => { 92 | expect(incompatibleDocuments({asyncapi: '3.0.0'}, {asyncapi: '3.0.0'})).toBeFalsy(); 93 | }); 94 | }); 95 | -------------------------------------------------------------------------------- /test/helpers/output/convertToYAML.spec.ts: -------------------------------------------------------------------------------- 1 | import convertToYAML from '../../../src/helpers/output/convertToYAML'; 2 | 3 | describe('YAML output', () => { 4 | test('should return YAML with mock object', () => { 5 | expect(convertToYAML({ hello: 'world' })).toEqual('hello: world\n'); 6 | }); 7 | 8 | test('should return YAML with mock array', () => { 9 | expect(convertToYAML(['hello', 'world'])).toEqual('- hello\n- world\n'); 10 | }); 11 | 12 | test('should return YAML with mock array', () => { 13 | expect(convertToYAML(['hello', { hello: 'world' }])).toEqual( 14 | '- hello\n- hello: world\n' 15 | ); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /test/main.spec.ts: -------------------------------------------------------------------------------- 1 | import { Parser } from '@asyncapi/parser'; 2 | import { readFileSync } from 'fs'; 3 | import { resolve } from 'path'; 4 | 5 | import AsyncAPIDiff from '../src/asyncapidiff'; 6 | import { diff } from '../src'; 7 | import { OverrideObject } from '../src'; 8 | 9 | import { 10 | diffOutput, 11 | breakingChanges, 12 | nonBreakingChanges, 13 | overrides, 14 | changesWithOverrides, 15 | specDocument1, 16 | specDocument2, 17 | arrayChanges, 18 | YAMLArrayChanges, 19 | MarkdownArrayChanges, 20 | diffOutputV3, 21 | } from './fixtures/main.fixtures'; 22 | 23 | const parser = new Parser(); 24 | 25 | describe('main function', () => { 26 | test('runs the diff function for spec v2', async () => { 27 | const firstSpecDocument = readFileSync( 28 | resolve('./test/spec/asyncapi.yml'), 29 | 'utf-8' 30 | ); 31 | const secondSpecDocument = readFileSync( 32 | resolve('./test/spec/diffSpec.yml'), 33 | 'utf-8' 34 | ); 35 | const firstDocument = await parser.parse(firstSpecDocument); 36 | const secondDocument = await parser.parse(secondSpecDocument); 37 | const output = diff( 38 | firstDocument.document?.json(), 39 | secondDocument.document?.json() 40 | ); 41 | expect(output).toBeInstanceOf(AsyncAPIDiff); 42 | expect(output.getOutput()).toEqual(diffOutput); 43 | expect(output.breaking()).toEqual(breakingChanges); 44 | expect(output.nonBreaking()).toEqual(nonBreakingChanges); 45 | }); 46 | 47 | test('throws on incompatible documents', async () => { 48 | const firstSpecDocument = readFileSync( 49 | resolve('./test/spec/asyncapi.yml'), 50 | 'utf-8' 51 | ); 52 | const secondSpecDocument = readFileSync( 53 | resolve('./test/spec/asyncapi-v3.yml'), 54 | 'utf-8' 55 | ); 56 | const firstDocument = await parser.parse(firstSpecDocument); 57 | const secondDocument = await parser.parse(secondSpecDocument); 58 | 59 | expect(() => diff( 60 | firstDocument.document?.json(), 61 | secondDocument.document?.json() 62 | )).toThrowError( 63 | new TypeError('diff between different AsyncAPI version is not allowed') 64 | ); 65 | }); 66 | 67 | test('runs the diff function for spec v3', async () => { 68 | const firstSpecDocument = readFileSync( 69 | resolve('./test/spec/asyncapi-v3.yml'), 70 | 'utf-8' 71 | ); 72 | const secondSpecDocument = readFileSync( 73 | resolve('./test/spec/asyncapi-v3-diff.yml'), 74 | 'utf-8' 75 | ); 76 | const firstDocument = await parser.parse(firstSpecDocument); 77 | const secondDocument = await parser.parse(secondSpecDocument); 78 | const output = diff( 79 | firstDocument.document?.json(), 80 | secondDocument.document?.json() 81 | ); 82 | expect(output).toBeInstanceOf(AsyncAPIDiff); 83 | expect(output.getOutput()).toEqual(diffOutputV3); 84 | }); 85 | 86 | test('runs the diff function with empty spec', () => { 87 | const firstSpec = {asyncapi: '2.1.0'}; 88 | const secondSpec = {asyncapi: '2.1.0'}; 89 | expect(diff(firstSpec, secondSpec).getOutput()).toEqual({ 90 | changes: [], 91 | }); 92 | }); 93 | 94 | test('runs the diff function with overrided changes', async () => { 95 | const firstSpecDocument = readFileSync( 96 | resolve('./test/spec/asyncapi.yml'), 97 | 'utf-8' 98 | ); 99 | const secondSpecDocument = readFileSync( 100 | resolve('./test/spec/diffSpec.yml'), 101 | 'utf-8' 102 | ); 103 | const firstDocument = await parser.parse(firstSpecDocument); 104 | const secondDocument = await parser.parse(secondSpecDocument); 105 | const output = diff( 106 | firstDocument.document?.json(), 107 | secondDocument.document?.json(), 108 | { 109 | override: overrides as OverrideObject, 110 | } 111 | ); 112 | expect(output.getOutput()).toEqual(changesWithOverrides); 113 | }); 114 | 115 | test('checks output with array changes', () => { 116 | const output = diff(specDocument1, specDocument2); 117 | expect(output.getOutput()).toEqual(arrayChanges); 118 | }); 119 | 120 | test('YAML: checks output with array changes', () => { 121 | const output = diff(specDocument1, specDocument2, { outputType: 'yaml' }); 122 | expect(output.getOutput()).toEqual(YAMLArrayChanges); 123 | }); 124 | 125 | test('Markdown: checks output with array changes', () => { 126 | const output = diff(specDocument1, specDocument2, { 127 | outputType: 'markdown', 128 | }); 129 | expect(output.getOutput()).toEqual(MarkdownArrayChanges); 130 | }); 131 | }); 132 | -------------------------------------------------------------------------------- /test/mergeStandard.spec.ts: -------------------------------------------------------------------------------- 1 | import { mergeStandard } from '../src/mergeStandard'; 2 | import { OverrideObject } from '../src/types'; 3 | import { getStandardFromVersion } from '../src/standard'; 4 | 5 | import { 6 | newKey, 7 | exisitngKey, 8 | standardAsString, 9 | mergedStandardAsString, 10 | exisitingKeyStandard, 11 | } from './fixtures/mergeStandard.fixture'; 12 | 13 | describe('mergeStandard()', () => { 14 | test('with empty override object', () => { 15 | const standard = getStandardFromVersion({asyncapi: '2.1.0'}); 16 | mergeStandard(standard, {}); 17 | expect(JSON.stringify(standard)).toBe(standardAsString); 18 | }); 19 | 20 | test('with new override key', () => { 21 | const standard = getStandardFromVersion({asyncapi: '2.1.0'}); 22 | mergeStandard(standard, newKey as OverrideObject); 23 | expect(JSON.stringify(standard)).toBe(mergedStandardAsString); 24 | }); 25 | 26 | test('with exisiting override key', () => { 27 | const standard = getStandardFromVersion({asyncapi: '2.1.0'}); 28 | mergeStandard(standard, exisitngKey as OverrideObject); 29 | expect(JSON.stringify(standard)).toBe(exisitingKeyStandard); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /test/spec/asyncapi-v3-diff.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 3.0.0 2 | info: 3 | title: My Event-Driven API 4 | version: 1.0.0 5 | description: This API provides real-time event streaming capabilities. 6 | termsOfService: https://example.com/terms-of-service 7 | contact: 8 | name: World 9 | email: helloworld@asyncapi.com 10 | license: 11 | name: Apache 2.0 12 | url: https://www.apache.org/licenses/LICENSE-2.0.html 13 | tags: 14 | - name: Events 15 | description: APIs related to event streaming 16 | - name: Authentication 17 | description: APIs for authentication and authorization 18 | externalDocs: 19 | description: Additional documentation 20 | url: https://example.com/docs 21 | servers: 22 | production: 23 | host: rabbitmq.in.mycompany.com:5673 24 | pathname: /v1 25 | protocol: amqp 26 | protocolVersion: "1.1" 27 | description: Production RabbitMQ broker (uses the 'production' vhost). 28 | title: Production Server 29 | summary: Production environment server 30 | security: 31 | - type: http 32 | scheme: bearer 33 | tags: 34 | - name: production 35 | description: Production environment 36 | externalDocs: 37 | description: Additional documentation for the production server 38 | url: https://example.com/docs/production 39 | bindings: 40 | amqp: 41 | exchange: my-exchange 42 | queue: my-queue 43 | staging: 44 | host: rabbitmq.in.mycompany.com:5672 45 | pathname: /v1 46 | protocol: amqp 47 | protocolVersion: "1.0" 48 | description: Staging RabbitMQ broker (uses the 'staging' vhost). 49 | title: Staging Server 50 | summary: Staging environment server 51 | security: 52 | - type: apiKey 53 | in: user 54 | description: Provide your API key as the user and leave the password empty. 55 | tags: 56 | - name: staging 57 | description: Staging environment 58 | externalDocs: 59 | description: Additional documentation for the staging server 60 | url: https://example.com/docs/staging 61 | bindings: 62 | amqp: 63 | exchange: my-exchange 64 | queue: my-queue 65 | channels: 66 | user: 67 | address: 'users.{userid}' 68 | title: Users channel 69 | description: This channel is used to exchange messages about user events. 70 | messages: 71 | userSignedUp: 72 | $ref: '#/components/messages/userSignedUp' 73 | userCompletedOrder: 74 | $ref: '#/components/messages/userCompletedOrder' 75 | parameters: 76 | userId: 77 | $ref: '#/components/parameters/userId' 78 | servers: 79 | - $ref: '#/servers/production' 80 | bindings: 81 | amqp: 82 | is: queue 83 | queue: 84 | exclusive: true 85 | tags: 86 | - name: user 87 | description: User-related messages 88 | externalDocs: 89 | description: 'Find more info here' 90 | url: 'https://example.com' 91 | userSignupReply: 92 | address: 'users.signup.reply' 93 | description: Channel for user signup replies 94 | messages: 95 | userSignedUpReply: 96 | summary: User signup reply message 97 | payload: 98 | type: object 99 | properties: 100 | status: 101 | type: string 102 | description: Status of the signup process 103 | message: 104 | type: string 105 | description: Additional information 106 | 107 | 108 | operations: 109 | sendUserSignUp: 110 | action: send 111 | title: User sign up 112 | summary: Action to sign a user up. 113 | description: A short description 114 | channel: 115 | $ref: '#/channels/user' 116 | security: 117 | - type: oauth2 118 | description: The oauth security descriptions 119 | flows: 120 | clientCredentials: 121 | tokenUrl: 'https://example.com/api/oauth/dialog' 122 | availableScopes: 123 | 'subscribe:auth_revocations': Scope required for authorization revocation topic 124 | scopes: 125 | - 'subscribe:auth_revocations' 126 | tags: 127 | - name: user 128 | - name: signup 129 | - name: register 130 | bindings: 131 | amqp: 132 | ack: false 133 | messages: 134 | - $ref: '#/channels/user/messages/userSignedUp' 135 | reply: 136 | address: 137 | location: '$message.header#/replyTo' 138 | channel: 139 | $ref: '#/channels/userSignupReply' 140 | messages: 141 | - $ref: '#/channels/userSignupReply/messages/userSignedUpReply' 142 | 143 | components: 144 | schemas: 145 | Category: 146 | type: object 147 | properties: 148 | id: 149 | type: integer 150 | format: int64 151 | AvroExample: 152 | schemaFormat: application/vnd.apache.avro+json;version=1.9.0 153 | 154 | servers: 155 | development: 156 | host: '{stage}.in.mycompany.com' 157 | protocol: amqp 158 | description: RabbitMQ broker 159 | bindings: 160 | $ref: '#/components/serverBindings/devAmqp' 161 | variables: 162 | stage: 163 | $ref: '#/components/serverVariables/stage' 164 | security: 165 | - $ref: '#/components/securitySchemes/oauth' 166 | 167 | serverVariables: 168 | stage: 169 | default: demo 170 | description: This value is assigned by the service provider in this example of 'mycompany.com' 171 | 172 | channels: 173 | user: 174 | address: 'users.{userId}' 175 | title: Users channel 176 | description: This channel is used to exchange messages about user events. 177 | messages: 178 | userSignedUp: 179 | $ref: '#/components/messages/userSignUp' 180 | parameters: 181 | userId: 182 | $ref: '#/components/parameters/userId' 183 | servers: 184 | - $ref: '#/components/servers/development' 185 | bindings: 186 | $ref: '#/components/channelBindings/user' 187 | tags: 188 | - $ref: '#/components/tags/user' 189 | externalDocs: 190 | $ref: '#/components/externalDocs/infoDocs' 191 | 192 | messages: 193 | userSignUp: 194 | summary: Action to sign a user up. 195 | traits: 196 | - $ref: '#/components/messageTraits/commonHeaders' 197 | payload: 198 | $ref: '#/components/schemas/Category' 199 | correlationId: 200 | $ref: '#/components/correlationIds/default' 201 | bindings: 202 | $ref: '#/components/messageBindings/user' 203 | userSignedUp: 204 | summary: User signed up event 205 | contentType: application/json 206 | payload: 207 | type: object 208 | properties: 209 | userId: 210 | type: string 211 | description: The ID of the user 212 | email: 213 | type: string 214 | description: The email of the user 215 | userCompletedOrder: 216 | summary: User completed order event 217 | contentType: application/json 218 | payload: 219 | type: object 220 | properties: 221 | orderId: 222 | type: string 223 | description: The ID of the order 224 | userId: 225 | type: string 226 | description: The ID of the user 227 | amount: 228 | type: number 229 | description: The total amount of the order 230 | 231 | 232 | parameters: 233 | userId: 234 | description: Id of the user. 235 | 236 | correlationIds: 237 | default: 238 | description: Default Correlation ID 239 | location: $message.header#/correlationId 240 | 241 | operations: 242 | sendUserSignUp: 243 | action: send 244 | title: User sign up 245 | channel: 246 | $ref: '#/channels/user' 247 | bindings: 248 | $ref: '#/components/operationBindings/sendUser' 249 | traits: 250 | - $ref: '#/components/operationTraits/binding' 251 | reply: 252 | $ref: '#/components/replies/signupReply' 253 | 254 | replies: 255 | signupReply: 256 | address: 257 | $ref: '#/components/replyAddresses/signupReply' 258 | channel: 259 | $ref: '#/channels/userSignupReply' 260 | 261 | replyAddresses: 262 | signupReply: 263 | location: '$message.header#/replyTo' 264 | 265 | 266 | securitySchemes: 267 | oauth: 268 | type: oauth2 269 | description: The oauth security descriptions 270 | flows: 271 | clientCredentials: 272 | tokenUrl: 'https://example.com/api/oauth/dialog' 273 | availableScopes: 274 | 'subscribe:auth_revocations': Scope required for authorization revocation topic 275 | scopes: 276 | - 'subscribe:auth_revocations' 277 | 278 | operationTraits: 279 | binding: 280 | bindings: 281 | amqp: 282 | ack: false 283 | 284 | messageTraits: 285 | commonHeaders: 286 | headers: 287 | type: object 288 | properties: 289 | my-app-header: 290 | type: integer 291 | minimum: 0 292 | maximum: 100 293 | 294 | tags: 295 | user: 296 | name: user 297 | description: User-related messages 298 | 299 | externalDocs: 300 | infoDocs: 301 | url: https://example.com/docs 302 | description: 'Find more info here' 303 | 304 | serverBindings: 305 | devAmqp: 306 | amqp: 307 | exchange: my-exchange 308 | queue: my-queue 309 | 310 | channelBindings: 311 | user: 312 | amqp: 313 | is: queue 314 | queue: 315 | exclusive: true 316 | 317 | operationBindings: 318 | sendUser: 319 | amqp: 320 | ack: false 321 | 322 | messageBindings: 323 | user: 324 | amqp: 325 | contentEncoding: gzip 326 | messageType: 'user.signup' 327 | bindingVersion: '0.3.0' 328 | -------------------------------------------------------------------------------- /test/spec/asyncapi-v3.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 3.0.0 2 | info: 3 | title: My Event-Driven API 4 | version: 1.0.0 5 | description: This API provides real-time event streaming capabilities. 6 | termsOfService: https://example.com/terms-of-service 7 | contact: 8 | name: Hello 9 | email: helloworld@asyncapi.com 10 | license: 11 | name: Apache 2.0 12 | url: https://www.apache.org/licenses/LICENSE-2.0.html 13 | tags: 14 | - name: Events 15 | description: APIs related to event streaming 16 | - name: Authentication 17 | description: APIs for authentication and authorization 18 | externalDocs: 19 | description: Additional documentation 20 | url: https://example.com/docs 21 | servers: 22 | production: 23 | host: rabbitmq.in.mycompany.com:5672 24 | pathname: /v1 25 | protocol: amqp 26 | protocolVersion: "1.0" 27 | description: Production RabbitMQ broker (uses the 'production' vhost). 28 | title: Production Server 29 | summary: Production environment server 30 | security: 31 | - type: http 32 | scheme: bearer 33 | tags: 34 | - name: production 35 | description: Production environment 36 | externalDocs: 37 | description: Additional documentation for the production server 38 | url: https://example.com/docs/production 39 | bindings: 40 | amqp: 41 | exchange: my-exchange 42 | queue: my-queue 43 | staging: 44 | host: rabbitmq.in.mycompany.com:5672 45 | pathname: /v1 46 | protocol: amqp 47 | protocolVersion: "1.0" 48 | description: Staging RabbitMQ broker (uses the 'staging' vhost). 49 | title: Staging Server 50 | summary: Staging environment server 51 | security: 52 | - type: apiKey 53 | in: user 54 | description: Provide your API key as the user and leave the password empty. 55 | tags: 56 | - name: staging 57 | description: Staging environment 58 | externalDocs: 59 | description: Additional documentation for the staging server 60 | url: https://example.com/docs/staging 61 | bindings: 62 | amqp: 63 | exchange: my-exchange 64 | queue: my-queue 65 | channels: 66 | user: 67 | address: 'users.{userId}' 68 | title: Users channel 69 | description: This channel is used to exchange messages about user events. 70 | messages: 71 | userSignedUp: 72 | $ref: '#/components/messages/userSignedUp' 73 | userCompletedOrder: 74 | $ref: '#/components/messages/userCompletedOrder' 75 | parameters: 76 | userId: 77 | $ref: '#/components/parameters/userId' 78 | servers: 79 | - $ref: '#/servers/production' 80 | bindings: 81 | amqp: 82 | is: queue 83 | queue: 84 | exclusive: true 85 | tags: 86 | - name: user 87 | description: User-related messages 88 | externalDocs: 89 | description: 'Find more info here' 90 | url: 'https://example.com' 91 | userSignupReply: 92 | address: 'users.signup.reply' 93 | description: Channel for user signup replies 94 | messages: 95 | userSignedUpReply: 96 | summary: User signup reply message 97 | payload: 98 | type: object 99 | properties: 100 | status: 101 | type: string 102 | description: Status of the signup process 103 | message: 104 | type: string 105 | description: Additional information 106 | 107 | 108 | operations: 109 | sendUserSignUp: 110 | action: send 111 | title: User sign up 112 | summary: Action to sign a user up. 113 | description: A longer description 114 | channel: 115 | $ref: '#/channels/user' 116 | security: 117 | - type: oauth2 118 | description: The oauth security descriptions 119 | flows: 120 | clientCredentials: 121 | tokenUrl: 'https://example.com/api/oauth/dialog' 122 | availableScopes: 123 | 'subscribe:auth_revocations': Scope required for authorization revocation topic 124 | scopes: 125 | - 'subscribe:auth_revocations' 126 | tags: 127 | - name: user 128 | - name: signup 129 | - name: register 130 | bindings: 131 | amqp: 132 | ack: false 133 | messages: 134 | - $ref: '#/channels/user/messages/userSignedUp' 135 | reply: 136 | address: 137 | location: '$message.header#/replyTo' 138 | channel: 139 | $ref: '#/channels/userSignupReply' 140 | messages: 141 | - $ref: '#/channels/userSignupReply/messages/userSignedUpReply' 142 | 143 | components: 144 | schemas: 145 | Category: 146 | type: object 147 | properties: 148 | id: 149 | type: integer 150 | format: int64 151 | AvroExample: 152 | schemaFormat: application/vnd.apache.avro+json;version=1.9.0 153 | 154 | servers: 155 | development: 156 | host: '{stage}.in.mycompany.com' 157 | protocol: amqp 158 | description: RabbitMQ broker 159 | bindings: 160 | $ref: '#/components/serverBindings/devAmqp' 161 | variables: 162 | stage: 163 | $ref: '#/components/serverVariables/stage' 164 | security: 165 | - $ref: '#/components/securitySchemes/oauth' 166 | 167 | serverVariables: 168 | stage: 169 | default: demo 170 | description: This value is assigned by the service provider in this example of 'mycompany.com' 171 | 172 | channels: 173 | user: 174 | address: 'users.{userId}' 175 | title: Users channel 176 | description: This channel is used to exchange messages about user events. 177 | messages: 178 | userSignedUp: 179 | $ref: '#/components/messages/userSignUp' 180 | parameters: 181 | userId: 182 | $ref: '#/components/parameters/userId' 183 | servers: 184 | - $ref: '#/components/servers/development' 185 | bindings: 186 | $ref: '#/components/channelBindings/user' 187 | tags: 188 | - $ref: '#/components/tags/user' 189 | externalDocs: 190 | $ref: '#/components/externalDocs/infoDocs' 191 | 192 | messages: 193 | userSignUp: 194 | summary: Action to sign a user up. 195 | traits: 196 | - $ref: '#/components/messageTraits/commonHeaders' 197 | payload: 198 | $ref: '#/components/schemas/Category' 199 | correlationId: 200 | $ref: '#/components/correlationIds/default' 201 | bindings: 202 | $ref: '#/components/messageBindings/user' 203 | userSignedUp: 204 | summary: User signed up event 205 | contentType: application/json 206 | payload: 207 | type: object 208 | properties: 209 | userId: 210 | type: string 211 | description: The ID of the user 212 | email: 213 | type: string 214 | description: The email of the user 215 | userCompletedOrder: 216 | summary: User completed order event 217 | contentType: application/json 218 | payload: 219 | type: object 220 | properties: 221 | orderId: 222 | type: string 223 | description: The ID of the order 224 | userId: 225 | type: string 226 | description: The ID of the user 227 | amount: 228 | type: number 229 | description: The total amount of the order 230 | 231 | 232 | parameters: 233 | userId: 234 | description: Id of the user. 235 | 236 | correlationIds: 237 | default: 238 | description: Default Correlation ID 239 | location: $message.header#/correlationId 240 | 241 | operations: 242 | sendUserSignUp: 243 | action: send 244 | title: User sign up 245 | channel: 246 | $ref: '#/channels/user' 247 | bindings: 248 | $ref: '#/components/operationBindings/sendUser' 249 | traits: 250 | - $ref: '#/components/operationTraits/binding' 251 | reply: 252 | $ref: '#/components/replies/signupReply' 253 | 254 | replies: 255 | signupReply: 256 | address: 257 | $ref: '#/components/replyAddresses/signupReply' 258 | channel: 259 | $ref: '#/channels/userSignupReply' 260 | 261 | replyAddresses: 262 | signupReply: 263 | location: '$message.header#/replyTo' 264 | 265 | 266 | securitySchemes: 267 | oauth: 268 | type: oauth2 269 | description: The oauth security descriptions 270 | flows: 271 | clientCredentials: 272 | tokenUrl: 'https://example.com/api/oauth/dialog' 273 | availableScopes: 274 | 'subscribe:auth_revocations': Scope required for authorization revocation topic 275 | scopes: 276 | - 'subscribe:auth_revocations' 277 | 278 | operationTraits: 279 | binding: 280 | bindings: 281 | amqp: 282 | ack: false 283 | 284 | messageTraits: 285 | commonHeaders: 286 | headers: 287 | type: object 288 | properties: 289 | my-app-header: 290 | type: integer 291 | minimum: 0 292 | maximum: 100 293 | 294 | tags: 295 | user: 296 | name: user 297 | description: User-related messages 298 | 299 | externalDocs: 300 | infoDocs: 301 | url: https://example.com/docs 302 | description: 'Find more info here' 303 | 304 | serverBindings: 305 | devAmqp: 306 | amqp: 307 | exchange: my-exchange 308 | queue: my-queue 309 | 310 | channelBindings: 311 | user: 312 | amqp: 313 | is: queue 314 | queue: 315 | exclusive: true 316 | 317 | operationBindings: 318 | sendUser: 319 | amqp: 320 | ack: false 321 | 322 | messageBindings: 323 | user: 324 | amqp: 325 | contentEncoding: gzip 326 | messageType: 'user.signup' 327 | bindingVersion: '0.3.0' 328 | -------------------------------------------------------------------------------- /test/spec/asyncapi.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.0.0 2 | info: 3 | title: My API 4 | version: '1.0.0' 5 | 6 | channels: 7 | mychannel: 8 | publish: 9 | message: 10 | $ref: '#/components/messages/channelMessage' 11 | 12 | components: 13 | messages: 14 | channelMessage: 15 | traits: 16 | - $ref: '#/components/messageTraits/extension' 17 | testMessage: 18 | traits: 19 | - $ref: '#/components/messageTraits/extension' 20 | payload: 21 | $ref: '#/components/schemas/testSchema' 22 | schemas: 23 | testSchema: 24 | type: object 25 | properties: 26 | name: 27 | type: string 28 | messageTraits: 29 | extension: 30 | x-some-extension: 'some extension' 31 | headers: 32 | type: object 33 | properties: 34 | some-common-header: 35 | type: string 36 | -------------------------------------------------------------------------------- /test/spec/diffSpec.yml: -------------------------------------------------------------------------------- 1 | asyncapi: 2.0.0 2 | info: 3 | title: My API 4 | version: '1.1.0' 5 | 6 | channels: 7 | anotherChannel: 8 | publish: 9 | message: 10 | $ref: '#/components/messages/channelMessage' 11 | 12 | components: 13 | messages: 14 | channelMessage: 15 | traits: 16 | - $ref: '#/components/messageTraits/extension' 17 | testMessage: 18 | traits: 19 | - $ref: '#/components/messageTraits/extension' 20 | payload: 21 | $ref: '#/components/schemas/testSchema' 22 | schemas: 23 | testSchema: 24 | type: object 25 | properties: 26 | name: 27 | type: string 28 | messageTraits: 29 | extension: 30 | x-some-extension: 'some extension' 31 | headers: 32 | type: object 33 | properties: 34 | some-common-header: 35 | type: string 36 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./lib", 4 | "baseUrl": "./src", 5 | "declaration": true, 6 | "target": "es6", 7 | "lib": [ 8 | "esnext" 9 | ], 10 | "sourceMap": true, 11 | "allowJs": true, 12 | "skipLibCheck": true, 13 | "esModuleInterop": true, 14 | "allowSyntheticDefaultImports": true, 15 | "strict": true, 16 | "forceConsistentCasingInFileNames": true, 17 | "noFallthroughCasesInSwitch": true, 18 | "module": "commonjs", 19 | "moduleResolution": "node", 20 | "resolveJsonModule": true, 21 | "isolatedModules": true 22 | }, 23 | "include": [ 24 | "src/**/*.ts", 25 | ], 26 | "exclude": [ 27 | "node_modules", 28 | "lib" 29 | ] 30 | } -------------------------------------------------------------------------------- /typedoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "entryPoints": ["src/index.ts", "src/asyncapidiff.ts"], 3 | "out": "docs", 4 | "plugin": [ 5 | "typedoc-plugin-markdown", 6 | "typedoc-plugin-rename-defaults" 7 | ], 8 | "readme": "none" 9 | } --------------------------------------------------------------------------------