Skip to content

Conversation

@tathagat2241
Copy link
Contributor

@tathagat2241 tathagat2241 commented Oct 29, 2025

Summary

This PR implements comprehensive API endpoints for managing SpaceCat configurations and extends the audit toggle functionality to support organization-level operations.

Changes Made

New API Endpoints

  1. PUT /configurations/latest/queues - Update queue configurations
  2. PATCH /configurations/latest/jobs/:jobType - Update job properties (interval, group)
  3. PATCH /configurations/latest/handlers/:handlerType - Update handler settings
  4. PATCH /configurations/latest - Changed from PUT to support partial updates/merges
  5. POST /configurations/:version/restore - restores the last good version

Enhanced Endpoints

  • GET /configurations/latest - Added response schema validation using checkConfiguration
  • PATCH /configurations/sites/audits - Extended to support organization-level audit toggling via organizationId

Controller Changes (src/controllers/configuration.js)

  • Added updateQueues method with validation
  • Added updateJob method with job type validation
  • Added updateHandler method with handler property validation
  • Updated updateConfiguration method for flexible partial updates
  • Added response validation to getLatest method
  • Added restoreVersion() method
  • Fixed getByVersion() method to parse URL parameters correctly

Controller Changes (src/controllers/sites-audits-toggle.js)

  • Modified validateInput to accept either baseURL or organizationId
  • Enhanced execute to handle both site-level and organization-level operations

Routes (src/routes/index.js)

  • Added route: PUT /configurations/latest/queues
  • Added route: PATCH /configurations/latest/jobs/:jobType
  • Added route: PATCH /configurations/latest/handlers/:handlerType
  • Changed route: PUT /configurations/latestPATCH /configurations/latest

OpenAPI Documentation

  • Updated configuration-api.yaml with all new endpoints and schema changes
  • Updated configurations-sites-audits-api.yaml to document organization-level support

Tests

  • Added comprehensive unit tests for all new controller methods
  • Added tests for organization-level audit toggling
  • Added tests for ConfigurationDto branch coverage
  • Updated route tests to reflect new endpoints
  • All tests passing with 100% coverage for configuration controller

Dependencies

This PR depends on the spacecat-shared PR that exports the checkConfiguration function and adds the configuration model methods.

Testing

  • All tests passing
  • 100% code coverage for configuration controller
  • Lint errors resolved

Please ensure your pull request adheres to the following guidelines:

  • make sure to link the related issues in this description. Or if there's no issue created, make sure you
    describe here the problem you're solving.
  • when merging / squashing, make sure the fixed issue references are visible in the commits, for easy compilation of release notes

If the PR is changing the API specification:

  • make sure you add a "Not implemented yet" note the endpoint description, if the implementation is not ready
    yet. Ideally, return a 501 status code with a message explaining the feature is not implemented yet.
  • make sure you add at least one example of the request and response.

If the PR is changing the API implementation or an entity exposed through the API:

  • make sure you update the API specification and the examples to reflect the changes.

If the PR is introducing a new audit type:

  • make sure you update the API specification with the type, schema of the audit result and an example

Related Issues

https://jira.corp.adobe.com/browse/LLMO-908

Thanks for contributing!

@github-actions
Copy link

This PR will trigger a minor release when merged.

throw new Error('Context required');
}
const { dataAccess } = ctx;
const { dataAccess, log } = ctx;
Copy link
Contributor

Choose a reason for hiding this comment

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

seem log added but not used ?

}

configuration.updateQueues(queues);
await configuration.save();
Copy link
Contributor

Choose a reason for hiding this comment

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

before saving suggested to set updatedBy
see reference in siteController

return badRequest('Configuration data is required and cannot be empty');
}

const hasHandlers = configData.handlers !== undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

use hasText for this everywhere

const site = await Site.findByBaseURL(baseURL);
if (site === null) {
return { status: 404, message: `Site with baseURL: ${baseURL} not found.` };
const isSiteOperation = baseURL !== undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

use hasText

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.

3 participants