diff --git a/gatsby-node.js b/gatsby-node.js index 3bfbe213d..9ff5ad5bc 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -1,4 +1,3 @@ -const yaml = require('js-yaml'); const path = require('path'); const { transformBreadcrumbs } = require('./src/utils/setup/transform-breadcrumbs.js'); const { baseUrl } = require('./src/utils/base-url'); @@ -76,14 +75,13 @@ const createRemoteMetadataNode = async ({ createNode, createNodeId, createConten } }; -const atlasAdminChangelogS3Prefix = 'https://mms-openapi-poc.s3.eu-west-1.amazonaws.com/openapi'; +const atlasAdminChangelogS3Prefix = 'https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/changelog'; const fetchChangelogData = async (runId, versions) => { try { /* Using metadata runId, fetch OpenAPI Changelog full change list */ - const changelogResp = await fetch(`${atlasAdminChangelogS3Prefix}/${runId}/changelog.yaml`); - const changelogText = await changelogResp.text(); - const changelog = yaml.safeLoad(changelogText, 'utf8'); + const changelogResp = await fetch(`${atlasAdminChangelogS3Prefix}/${runId}/changelog.json`); + const changelog = await changelogResp.json(); /* Aggregate all Resources in changelog for frontend filter */ const resourcesListSet = new Set(); @@ -95,9 +93,8 @@ const fetchChangelogData = async (runId, versions) => { /* Fetch most recent Resource Versions' diff */ const mostRecentResourceVersions = versions.slice(-2); const mostRecentDiffLabel = mostRecentResourceVersions.join('_'); - const mostRecentDiffResp = await fetch(`${atlasAdminChangelogS3Prefix}/${runId}/${mostRecentDiffLabel}.yaml`); - const mostRecentDiffText = await mostRecentDiffResp.text(); - const mostRecentDiffData = yaml.safeLoad(mostRecentDiffText, 'utf8'); + const mostRecentDiffResp = await fetch(`${atlasAdminChangelogS3Prefix}/${runId}/${mostRecentDiffLabel}.json`); + const mostRecentDiffData = await mostRecentDiffResp.json(); return { changelog, @@ -117,14 +114,13 @@ const fetchChangelogData = async (runId, versions) => { const createOpenAPIChangelogNode = async ({ createNode, createNodeId, createContentDigest }) => { try { /* Fetch OpenAPI Changelog metadata */ - const indexResp = await fetch(`${atlasAdminChangelogS3Prefix}/index.yaml`); - const indexText = await indexResp.text(); - const index = yaml.safeLoad(indexText, 'utf8'); + const indexResp = await fetch(`${atlasAdminChangelogS3Prefix}/prod.json`); + const index = await indexResp.json(); const { runId, versions } = index; if (!runId || typeof runId !== 'string') - throw new Error('OpenAPI Changelog Error: `runId` not available in S3 index.yaml!'); + throw new Error('OpenAPI Changelog Error: `runId` not available in S3 index.json!'); let changelogData = { index, diff --git a/src/components/OpenAPIChangelog/OpenAPIChangelog.js b/src/components/OpenAPIChangelog/OpenAPIChangelog.js index 6ffcb0310..183914cb7 100644 --- a/src/components/OpenAPIChangelog/OpenAPIChangelog.js +++ b/src/components/OpenAPIChangelog/OpenAPIChangelog.js @@ -136,7 +136,7 @@ const OpenAPIChangelog = () => { (2.0{!!index.specRevisionShort && `~${index.specRevisionShort}`}) - Download API Changelog + Download Full API Changelog version.changes.map((change) => change)).flat(); + const allResourceChanges = + changes || versions.map((version) => (version.changes ? version.changes.map((change) => change) : null)).flat(); + /* Filter out all null changes or non-public-facing changes */ const publicResourceChanges = allResourceChanges.filter( - (c) => c.changeCode !== 'operation-id-changed' || c.changeCode !== 'operation-tag-changed' + (c) => c && (c.changeCode !== 'operation-id-changed' || c.changeCode !== 'operation-tag-changed') ); const changeTypeBadge = versions?.[0]?.changeType ? changeTypeBadges[versions[0].changeType] : null; diff --git a/src/components/OpenAPIChangelog/utils/constants.js b/src/components/OpenAPIChangelog/utils/constants.js index 262e4092a..edce4ba89 100644 --- a/src/components/OpenAPIChangelog/utils/constants.js +++ b/src/components/OpenAPIChangelog/utils/constants.js @@ -4,7 +4,7 @@ export const ALL_VERSIONS = 'ALL_VERSIONS'; export const COMPARE_VERSIONS = 'COMPARE_VERSIONS'; export const getDownloadChangelogUrl = (runId) => - `https://mms-openapi-poc.s3.eu-west-1.amazonaws.com/openapi/${runId}/changelog.yaml`; + `https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/changelog/${runId}/changelog.json`; export const changeTypeBadges = { release: { diff --git a/tests/unit/__snapshots__/OpenAPIChangelog.test.js.snap b/tests/unit/__snapshots__/OpenAPIChangelog.test.js.snap index b9a594fb1..7bd1fcb08 100644 --- a/tests/unit/__snapshots__/OpenAPIChangelog.test.js.snap +++ b/tests/unit/__snapshots__/OpenAPIChangelog.test.js.snap @@ -855,7 +855,7 @@ exports[`OpenAPIChangelog tests OpenAPIChangelog renders correctly 1`] = ` aria-disabled="false" class="emotion-8 emotion-9 emotion-10" data-leafygreen-ui="button" - href="https://mms-openapi-poc.s3.eu-west-1.amazonaws.com/openapi/20230403105948111/changelog.yaml" + href="https://mongodb-mms-prod-build-server.s3.amazonaws.com/openapi/changelog/20230403105948111/changelog.json" >
- Download API Changelog + Download Full API Changelog