Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/giant-pets-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gitbook-docs": minor
---

Update generate metadata script to add synced response in S3 for solutions and release note
10 changes: 6 additions & 4 deletions packages/gitbook-docs/src/scripts/generateGuidesMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import {
} from '../helpers/fetchFromStrapi';
import { StrapiGuide, MetadataInfo } from '../helpers/guidesMetadataHelper';
import { sitePathFromS3Path } from '../helpers/sitePathFromS3Path';
import {
getSyncedGuideListPagesResponseJsonPath,
getSyncedGuidesResponseJsonPath,
} from '../syncedResponses';

// Load environment variables from .env file
dotenv.config();
Expand All @@ -27,11 +31,9 @@ const S3_PATH_TO_GITBOOK_DOCS =
process.env.S3_PATH_TO_GITBOOK_DOCS || 'devportal-docs/docs';
const S3_GUIDE_METADATA_JSON_PATH =
process.env.S3_GUIDE_METADATA_JSON_PATH || 'guides-metadata.json';
const SYNCED_GUIDES_RESPONSE_JSON_PATH =
process.env.SYNCED_GUIDES_RESPONSE_JSON_PATH || 'synced-guides-response.json';
const SYNCED_GUIDES_RESPONSE_JSON_PATH = getSyncedGuidesResponseJsonPath();
const SYNCED_GUIDE_LIST_PAGES_RESPONSE_JSON_PATH =
process.env.SYNCED_GUIDE_LIST_PAGES_RESPONSE_JSON_PATH ||
'synced-guide-list-pages-response.json';
getSyncedGuideListPagesResponseJsonPath();

const s3Client = makeS3Client();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { extractTitleFromMarkdown } from '../helpers/extractTitle.helper';
import { fetchFromStrapi } from '../helpers/fetchFromStrapi';
import { sitePathFromS3Path } from '../helpers/sitePathFromS3Path';
import { StrapiReleaseNote } from '../helpers/guidesMetadataHelper';
import { getSyncedReleaseNotesResponseJsonPath } from '../syncedResponses';

// Load environment variables from .env file
dotenv.config();
Expand All @@ -25,6 +26,8 @@ const S3_PATH_TO_GITBOOK_DOCS =
const S3_RELEASE_NOTES_METADATA_JSON_PATH =
process.env.S3_RELEASE_NOTES_METADATA_JSON_PATH ||
'release-notes-metadata.json';
const SYNCED_RELEASE_NOTES_RESPONSE_JSON_PATH =
getSyncedReleaseNotesResponseJsonPath();

const s3Client = makeS3Client();

Expand Down Expand Up @@ -98,11 +101,14 @@ async function main() {

// eslint-disable-next-line functional/no-let
let strapiReleaseNotes;
// eslint-disable-next-line functional/no-let
let responseJson;
try {
const { data } = await fetchFromStrapi<StrapiReleaseNote>(
const result = await fetchFromStrapi<StrapiReleaseNote>(
'api/release-notes?populate[0]=product&pagination[pageSize]=1000&pagination[page]=1'
);
strapiReleaseNotes = data;
strapiReleaseNotes = result.data;
responseJson = result.responseJson;
} catch (error) {
console.error('Error fetching release notes from Strapi:', error);
process.exit(1);
Expand All @@ -123,6 +129,14 @@ async function main() {
`${S3_BUCKET_NAME}`,
s3Client
);

// TODO: remove when Strapi will manage Metadata
await writeSitemapJson(
responseJson,
SYNCED_RELEASE_NOTES_RESPONSE_JSON_PATH,
`${S3_BUCKET_NAME}`,
s3Client
);
}

// Execute the function
Expand Down
48 changes: 45 additions & 3 deletions packages/gitbook-docs/src/scripts/generateSolutionsMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ import {
writeSitemapJson,
} from '../helpers/s3Bucket.helper';
import { extractTitleFromMarkdown } from '../helpers/extractTitle.helper';
import { fetchFromStrapi } from '../helpers/fetchFromStrapi';
import {
fetchFromStrapi,
getResponseFromStrapi,
} from '../helpers/fetchFromStrapi';
import { sitePathFromS3Path } from '../helpers/sitePathFromS3Path';
import { StrapiSolution } from '../helpers/guidesMetadataHelper';
import {
getSyncedSolutionListPagesResponseJsonPath,
getSyncedSolutionsResponseJsonPath,
} from '../syncedResponses';

// Load environment variables from .env file
dotenv.config();
Expand All @@ -24,6 +31,10 @@ const S3_PATH_TO_GITBOOK_DOCS =
process.env.S3_PATH_TO_GITBOOK_DOCS || 'devportal-docs/docs';
const S3_SOLUTIONS_METADATA_JSON_PATH =
process.env.S3_SOLUTIONS_METADATA_JSON_PATH || 'solutions-metadata.json';
const SYNCED_SOLUTIONS_RESPONSE_JSON_PATH =
getSyncedSolutionsResponseJsonPath();
const SYNCED_SOLUTION_LIST_PAGES_RESPONSE_JSON_PATH =
getSyncedSolutionListPagesResponseJsonPath();

const s3Client = makeS3Client();
function generateUrlPath(
Expand Down Expand Up @@ -92,13 +103,28 @@ async function convertSolutionToSitemapItems(
async function main() {
console.log('Starting to process Markdown files...');

// TODO: remove when Strapi will manage Metadata
// eslint-disable-next-line functional/no-let
let solutionListPagesResponse;
try {
solutionListPagesResponse = await getResponseFromStrapi(
'api/solution-list-page/?populate%5Bsolutions%5D%5Bpopulate%5D%5B0%5D=bannerLinks&populate%5Bsolutions%5D%5Bpopulate%5D%5B1%5D=bannerLinks.icon&populate%5Bsolutions%5D%5Bpopulate%5D%5B2%5D=products.logo&populate%5Bsolutions%5D%5Bpopulate%5D%5B3%5D=icon&populate%5Bsolutions%5D%5Bpopulate%5D%5B4%5D=icon.name&populate%5Bsolutions%5D%5Bpopulate%5D%5B5%5D=stats&populate%5Bsolutions%5D%5Bpopulate%5D%5B6%5D=steps&populate%5Bsolutions%5D%5Bpopulate%5D%5B7%5D=steps.products&populate%5Bsolutions%5D%5Bpopulate%5D%5B8%5D=webinars&populate%5Bsolutions%5D%5Bpopulate%5D%5B9%5D=webinars.coverImage&populate%5Bsolutions%5D%5Bpopulate%5D%5B10%5D=caseHistories&populate%5Bsolutions%5D%5Bpopulate%5D%5B11%5D=caseHistories.case_histories&populate%5Bsolutions%5D%5Bpopulate%5D%5B12%5D=caseHistories.case_histories.image&populate%5BcaseHistories%5D%5Bpopulate%5D%5B0%5D=case_histories&populate%5BcaseHistories%5D%5Bpopulate%5D%5B1%5D=case_histories.image&populate%5Bfeatures%5D%5Bpopulate%5D%5B0%5D=items.icon&populate%5Bseo%5D%5Bpopulate%5D=%2A%2CmetaImage%2CmetaSocial.image'
);
} catch (error) {
console.error('Error fetching solution list pages from Strapi:', error);
process.exit(1);
}

// eslint-disable-next-line functional/no-let
let strapiSolutions;
// eslint-disable-next-line functional/no-let
let responseJson;
try {
const { data } = await fetchFromStrapi<StrapiSolution>(
const result = await fetchFromStrapi<StrapiSolution>(
'api/solutions?pagination[pageSize]=1000&pagination[page]=1'
);
strapiSolutions = data;
strapiSolutions = result.data;
responseJson = result.responseJson;
} catch (error) {
console.error('Error fetching solutions from Strapi:', error);
process.exit(1);
Expand All @@ -115,6 +141,22 @@ async function main() {
`${S3_BUCKET_NAME}`,
s3Client
);

// TODO: remove when Strapi will manage Metadata
await writeSitemapJson(
responseJson,
SYNCED_SOLUTIONS_RESPONSE_JSON_PATH,
`${S3_BUCKET_NAME}`,
s3Client
);

// TODO: remove when Strapi will manage Metadata
await writeSitemapJson(
solutionListPagesResponse,
SYNCED_SOLUTION_LIST_PAGES_RESPONSE_JSON_PATH,
`${S3_BUCKET_NAME}`,
s3Client
);
}

// Execute the function
Expand Down
13 changes: 13 additions & 0 deletions packages/gitbook-docs/src/syncedResponses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export const getSyncedGuidesResponseJsonPath = () =>
process.env.SYNCED_GUIDES_RESPONSE_JSON_PATH || 'synced-guides-response.json';
export const getSyncedGuideListPagesResponseJsonPath = () =>
process.env.SYNCED_GUIDE_LIST_PAGES_RESPONSE_JSON_PATH ||
'synced-guide-list-pages-response.json';

export const getSyncedSolutionsResponseJsonPath = () =>
'synced-solutions-response.json';
export const getSyncedSolutionListPagesResponseJsonPath = () =>
'synced-solution-list-pages-response.json';

export const getSyncedReleaseNotesResponseJsonPath = () =>
'synced-release-notes-response.json';