Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[XM Cloud][Next.js] Editing Configuration Endpoint #1724

Merged
merged 20 commits into from
Feb 7, 2024
Merged

Conversation

yavorsk
Copy link
Contributor

@yavorsk yavorsk commented Feb 2, 2024

Description / Motivation

This PR introduces a protected endpoint in the xmcloud addon - /api/editing/config?secret=[jss-editing-secret]. The endpoint provides configuration information (the sitecore packages used by the app and all registered components) to be used to determine feature compatibility on pages side.
Includes:

  • the actual endpoint in the xmcloud addon;
  • generate-metadata - added to bootstrap, gathers information about referenced sitecore packages at build time and writes a file in the temp folder;
  • the editing configuration middleware plus unit tests;

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Copy link
Contributor

@addy-pathania addy-pathania left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
Please add an appropriate title to the PR.
See some comments.

import { getJssEditingSecret } from '../utils/utils';
import { debug } from '@sitecore-jss/sitecore-jss';

interface Metadata {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This interface should be exported / shared with the metadata generation

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@ambrauer ambrauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, just one minor adjustment suggested.

CHANGELOG.md Show resolved Hide resolved
Comment on lines 14 to 16
const metadata: Metadata = { packages: {} };
metadata.packages = getPackagesMetadata();
writeMetadata(metadata);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would switch our SDK function to be a getMetadata() function which returns Metadata (shouldn't have any knowledge of "packages" here in the app layer). This way, if we add anything to metadata in the future, there is nothing in the app layer to update.

Suggested change
const metadata: Metadata = { packages: {} };
metadata.packages = getPackagesMetadata();
writeMetadata(metadata);
const metadata = getMetadata();
writeMetadata(metadata);

@yavorsk yavorsk changed the title Feature/jss 1397 [XM Cloud][Next.js] Editing Configuration Endpoint Feb 6, 2024
Copy link
Contributor

@addy-pathania addy-pathania left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. 👍🏼

@yavorsk yavorsk dismissed art-alexeyenko’s stale review February 7, 2024 08:20

The commented functionality has been tested and works ok :)

@yavorsk yavorsk merged commit 4a03707 into dev Feb 7, 2024
1 check passed
@yavorsk yavorsk deleted the feature/JSS-1397 branch February 7, 2024 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants