Skip to content

dev: Refactor Algolia client wrapper#82

Merged
justlevine merged 9 commits intodevelopfrom
dev/algolia-client
Dec 14, 2025
Merged

dev: Refactor Algolia client wrapper#82
justlevine merged 9 commits intodevelopfrom
dev/algolia-client

Conversation

@justlevine
Copy link
Collaborator

@justlevine justlevine commented Dec 11, 2025

Description

This PR refactors and relocates the Algolia client wrapper into Modules/Search. Other algolia-related files remain the same.

Technical Details

  1. The related algolia-credentials endpoint was moved into Rest/Search_Controller (We're intentionally not getting it from v2/settings because we want only our endpoint to be allowed to decode it.)
  2. The related Governing_Data call to that endpoint was moved into the new Algolia class as a private method.
  3. Credential caching on the client side was removed. It's a clunkly implementation without cron jobs and those are beyond the scope. If there's a noticable perf hit when demoing we can consider restoring it.
  4. Removed the unecessary admin_key from all areas of the backend (Yes I know I'll have to dedupe the conflicts once we merge chore: convert settings into TS & fix encryption issue #81

The other classes were intentionally left out of this PR. I'm trying to keep the diffs small for fast code review before the weekend 🤞

Checklist

Screenshots

To-do

Fixes/Covers issue

Fixes #

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Algolia client wrapper by relocating it from Inc\Algolia to Modules\Search, consolidating credential management into a new REST controller, and removing the admin_key field throughout the codebase.

Key changes:

  • Creates a new Algolia class in Modules\Search with improved encapsulation and index caching
  • Introduces Search_Controller for handling Algolia credential GET/POST operations
  • Removes client-side credential caching and the now-unused admin_key field
  • Updates all references across the codebase to use the new namespace

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
inc/Modules/Search/Algolia.php New Algolia wrapper with private methods, index caching, and credential fetching for both governing and consumer sites
inc/Modules/Rest/Search_Controller.php New REST controller for algolia-credentials endpoint with simplified validation
inc/Modules/Search/Settings.php Removes admin_key references from credential storage and retrieval
inc/Modules/Rest/Governing_Data.php Removes credential fetching and caching logic (moved to Algolia class)
inc/classes/rest/class-basic-options.php Removes old credential endpoints and validation logic
inc/classes/algolia/class-algolia.php Deleted (moved to new location)
inc/classes/algolia/class-algolia-search.php Updates import to use new Algolia namespace
inc/classes/algolia/class-algolia-index.php Updates import to use new Algolia namespace
inc/classes/algolia/class-algolia-index-by-post.php Updates import to use new Algolia namespace
uninstall.php Updates namespace reference for Algolia class
inc/Main.php Registers new Search_Controller

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@justlevine justlevine requested a review from up1512001 December 11, 2025 20:53
Copy link
Member

Choose a reason for hiding this comment

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

I was also working on this file cleanup 😄 will rebase to your current branch.

Copy link
Member

@up1512001 up1512001 left a comment

Choose a reason for hiding this comment

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

@justlevine Added few nits overall looks good as its just stripping basic options & admin_key removal.

@justlevine
Copy link
Collaborator Author

Merged in #81 , then updated the new TSX endpoints to use /algolia-credentials and /shared-sites. Per call our general design guidelines are:

  • wp/v2/settings when convenient
  • /one*/v1/{endpoint} when
    • Dealing with encrypted data (we don't want anybody's call to settings to expose decrypted keys)
    • Dealing with cross-site access to plugin-specific data.

(As refactoring progresses, it may make sense to clobber different plugin-specific endpoints to a single transport for all governing side data in a single request ).

More important than any of the above, is short-term shipability and long-term reshare/maintenance

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@justlevine justlevine requested a review from up1512001 December 12, 2025 13:46
Copy link
Member

@up1512001 up1512001 left a comment

Choose a reason for hiding this comment

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

Approving just we need to fix initial site adding logic.


setSites( data.shared_sites );

if ( data.shared_sites.length === 0 ) {
Copy link
Member

Choose a reason for hiding this comment

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

this will not cause reload when I add first site which it should happen.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the logic used by OneDesign and OneLogs, so I'm considering this nonblocking.

https://github.com/rtCamp/OneDesign/blob/0bcbac04e84013f78ddd02da5bec7fbc487d8364/assets/src/admin/settings/index.js#L86-L88

@justlevine justlevine merged commit 3264728 into develop Dec 14, 2025
5 of 7 checks passed
@justlevine justlevine deleted the dev/algolia-client branch December 14, 2025 13:04
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.

2 participants