Skip to content

Add Algolia index of pages#2282

Merged
lkostrowski merged 16 commits intomainfrom
lkostrowski/page-indexing
Mar 25, 2026
Merged

Add Algolia index of pages#2282
lkostrowski merged 16 commits intomainfrom
lkostrowski/page-indexing

Conversation

@lkostrowski
Copy link
Copy Markdown
Member

No description provided.

lkostrowski and others added 2 commits March 17, 2026 09:59
Add support for indexing Saleor Pages to Algolia, following the same
patterns established for categories. Pages are indexed to a dedicated
"pages" index with configurable fields (content, seoDescription,
metadata, attributes) and always-indexed fields (title, slug, pageTypeId,
seoTitle).

- Add PageData GraphQL fragment, subscriptions (created/updated/deleted),
  and bulk import query
- Add pageToAlgolia() and pageToAlgoliaIndexId() utilities
- Extend SearchProvider interface and AlgoliaSearchProvider with page
  CRUD methods, batch import, and index settings
- Add PAGE_CREATED/UPDATED/DELETED webhook definitions and handlers
- Add page fields configuration (schema, router mutation, UI form)
- Add page bulk import support alongside products and categories
- Pass pageEnabledKeys through webhook context, search provider, and
  setup-indices

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use PageFilterInput type from generated GraphQL for the filter variable
- Replace dynamic import with static import for PageTypesDataDocument
- Rename page webhook files from underscores to dashes (page_created -> page-created)
- Update webhookPath in definitions to match renamed files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 17, 2026 10:42
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
saleor-app-payment-stripe Building Building Preview, Comment Mar 25, 2026 7:27am
saleor-app-search Ready Ready Preview, Comment Mar 25, 2026 7:27am
7 Skipped Deployments
Project Deployment Actions Updated (UTC)
saleor-app-avatax Ignored Ignored Preview Mar 25, 2026 7:27am
saleor-app-cms Ignored Ignored Preview Mar 25, 2026 7:27am
saleor-app-klaviyo Ignored Ignored Preview Mar 25, 2026 7:27am
saleor-app-payment-np-atobarai Ignored Ignored Preview Mar 25, 2026 7:27am
saleor-app-products-feed Ignored Ignored Preview Mar 25, 2026 7:27am
saleor-app-segment Ignored Ignored Preview Mar 25, 2026 7:27am
saleor-app-smtp Ignored Ignored Preview Mar 25, 2026 7:27am

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 17, 2026

🦋 Changeset detected

Latest commit: def3de8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
saleor-app-search Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
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 adds Algolia indexing support for Saleor pages in the search app, mirroring the existing patterns for products and categories.

Changes:

  • Adds page CRUD webhook handlers (page-created, page-updated, page-deleted) with page type filtering
  • Adds configuration UI for page fields selection and page type filtering
  • Extends the Algolia search provider and batch import to support pages

Reviewed changes

Copilot reviewed 29 out of 30 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
apps/search/webhooks.ts Registers new page webhook definitions
apps/search/src/webhooks/definitions/page-*.ts New webhook definitions for page events
apps/search/src/pages/api/webhooks/saleor/page-*.ts Webhook handlers for page CRUD events
apps/search/src/lib/algolia/algoliaSearchProvider.ts Adds page CRUD and batch methods to Algolia provider
apps/search/src/lib/algolia/pageAlgoliaUtils.ts Page-to-Algolia object transformation
apps/search/src/lib/algolia-fields.ts Page field definitions and labels
apps/search/src/lib/searchProvider.ts Extends SearchProvider interface with page methods
apps/search/src/lib/webhook-event-types.ts Page webhook event type definitions
apps/search/src/modules/configuration/configuration.ts Schema and AppConfig extensions for page settings
apps/search/src/modules/configuration/configuration.router.ts tRPC routes for page config and page types
apps/search/src/components/AlgoliaPageFieldsSelectionForm.tsx UI for page fields selection
apps/search/src/components/PageTypesFilterForm.tsx UI for page type filtering
apps/search/src/components/ImportProductsToAlgolia/* Extended batch import to include pages
apps/search/src/views/configuration/configuration.view.tsx Adds page config sections to UI
apps/search/src/webhooks/webhook-context.ts Passes page enabled keys to search provider
apps/search/src/pages/api/setup-indices.ts Passes page enabled keys during index setup
apps/search/graphql/** GraphQL fragments, queries, and subscriptions for pages
apps/search/generated/graphql.ts Auto-generated GraphQL types
apps/search/src/lib/algolia/algoliaUtils.ts Exports mapSelectedAttributesToRecord for reuse

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 24.07592% with 760 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.03%. Comparing base (cbb49af) to head (def3de8).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ts/ImportProductsToAlgolia/ImportToAlgoliaCard.tsx 0.00% 75 Missing and 1 partial ⚠️
.../src/components/AlgoliaPageFieldsSelectionForm.tsx 0.00% 72 Missing and 1 partial ⚠️
...arch/src/pages/api/webhooks/saleor/page_created.ts 1.36% 72 Missing ⚠️
...arch/src/pages/api/webhooks/saleor/page_updated.ts 1.36% 72 Missing ⚠️
apps/search/src/components/PageTypesFilterForm.tsx 0.00% 69 Missing and 1 partial ⚠️
...arch/src/pages/api/webhooks/saleor/page_deleted.ts 1.58% 62 Missing ⚠️
...rch/src/views/configuration/configuration.view.tsx 0.00% 50 Missing ⚠️
.../src/modules/configuration/configuration.router.ts 0.00% 49 Missing ⚠️
...ps/search/src/lib/algolia/algoliaSearchProvider.ts 2.12% 46 Missing ⚠️
apps/search/src/lib/algolia/pageAlgoliaUtils.ts 11.36% 39 Missing ⚠️
... and 15 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2282      +/-   ##
==========================================
- Coverage   37.31%   37.03%   -0.29%     
==========================================
  Files         996     1015      +19     
  Lines       65115    65870     +755     
  Branches     3359     3384      +25     
==========================================
+ Hits        24299    24395      +96     
- Misses      40447    41096     +649     
- Partials      369      379      +10     
Flag Coverage Δ
avatax 56.62% <ø> (ø)
cms 18.67% <ø> (ø)
domain 100.00% <ø> (ø)
dynamo-config-repository 79.29% <ø> (ø)
errors 91.66% <ø> (ø)
logger 28.81% <ø> (ø)
np-atobarai 72.54% <ø> (ø)
products-feed 5.91% <ø> (ø)
search 30.74% <24.07%> (-3.85%) ⬇️
segment 32.38% <ø> (ø)
shared 37.35% <ø> (ø)
smtp 34.87% <ø> (ø)
stripe 71.09% <ø> (ø)
webhook-utils 11.02% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

lkostrowski and others added 7 commits March 17, 2026 14:06
Show a placeholder in ImportPagesToAlgolia when no page types are
selected, and ensure the component re-renders when the filter is
updated — without requiring a page refresh.

Lift the getConfig query to ConfigurationView so both
PageTypesFilterForm and ImportPagesToAlgolia share state through
props rather than relying on cross-component tRPC cache invalidation
which doesn't work reliably with the dual QueryClient setup.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pages are only stored as plain text, so the JSON content field
is unnecessary. Removes "content" from AlgoliaPageFields and
the corresponding indexing logic in pageToAlgolia.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract the monolithic useBatchUpload.ts into focused single-responsibility files:
- useUploadState.ts: upload state management hook and UploadState type
- useGraphQLClient.ts: paginated GraphQL fetching (products, categories, pages)
- runBatchedUpload.ts: batched async upload utility
- useProductsBatchUpload.ts, useCategoriesBatchUpload.ts, usePagesBatchUpload.ts: individual batch upload hooks

useBatchUpload.ts remains as a re-export barrel for backward compatibility.
Consumers updated to import directly from the specific modules.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 23, 2026 15:41
@lkostrowski lkostrowski marked this pull request as ready for review March 23, 2026 15:42
@lkostrowski lkostrowski requested a review from a team as a code owner March 23, 2026 15:42
Copy link
Copy Markdown
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

Adds Saleor Pages indexing support to the Search app’s Algolia integration, including new page webhooks, page index mapping/settings, and configuration UI for page-specific field selection and page-type filtering.

Changes:

  • Add PAGE_CREATED / PAGE_UPDATED / PAGE_DELETED webhooks and handlers that sync Pages to a dedicated Algolia “pages” index.
  • Extend Algolia provider + config to support page field mapping (pageEnabledKeys) and page-type filtering.
  • Expand the configuration UI with page-type selection, page field selection, and separate “initial import” actions for products, categories, and pages.

Reviewed changes

Copilot reviewed 40 out of 41 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
apps/search/webhooks.ts Registers new page webhook definitions in the app’s webhook list.
apps/search/src/webhooks/webhook-context.ts Passes page field mapping (pageEnabledKeys) into Algolia provider during webhook handling.
apps/search/src/webhooks/definitions/page-created.ts Defines PAGE_CREATED webhook (currently uses kebab-case route path).
apps/search/src/webhooks/definitions/page-updated.ts Defines PAGE_UPDATED webhook (currently uses kebab-case route path).
apps/search/src/webhooks/definitions/page-deleted.ts Defines PAGE_DELETED webhook (currently uses kebab-case route path).
apps/search/src/pages/api/webhooks/saleor/page-created.ts New API handler to index created pages into Algolia with error handling.
apps/search/src/pages/api/webhooks/saleor/page-updated.ts New API handler to update pages in Algolia with error handling.
apps/search/src/pages/api/webhooks/saleor/page-deleted.ts New API handler to remove pages from Algolia with error handling.
apps/search/src/pages/api/setup-indices.ts Extends index setup to include page field mapping defaults.
apps/search/src/modules/configuration/configuration.ts Adds page fields mapping + page type filter storage to metadata-backed config.
apps/search/src/modules/configuration/configuration.router.ts Adds tRPC endpoints for page fields mapping, page types fetching, and page-type filter persistence.
apps/search/src/views/configuration/configuration.view.tsx Adds UI sections for page types filter, page field filtering, and page import; expands import UI.
apps/search/src/lib/webhook-event-types.ts Adds typed payload aliases for page subscription events.
apps/search/src/lib/searchProvider.ts Extends provider contract with create/update/delete Page operations.
apps/search/src/lib/algolia/pageAlgoliaUtils.ts Adds page-to-Algolia record mapping and “pages” index naming helper.
apps/search/src/lib/algolia/algoliaUtils.ts Exports mapSelectedAttributesToRecord for reuse in page mapping.
apps/search/src/lib/algolia/algoliaSearchProvider.ts Adds pages index name, page CRUD operations, batch page upload, and page index settings.
apps/search/src/lib/algolia-fields.ts Introduces page field keys + labels for UI-driven field selection.
apps/search/src/components/PageTypesFilterForm.tsx New UI form for selecting allowed page types (used for indexing filter).
apps/search/src/components/AlgoliaPageFieldsSelectionForm.tsx New UI form for selecting which page fields are sent to Algolia.
apps/search/src/components/ImportProductsToAlgolia/index.tsx Converts barrel to export separate import cards (products/categories/pages).
apps/search/src/components/ImportProductsToAlgolia/ImportToAlgoliaCard.tsx Shared card UI for client-side “initial import” flows.
apps/search/src/components/ImportProductsToAlgolia/ImportProductsToAlgolia.tsx Refactors product import into shared card + new batch upload hook.
apps/search/src/components/ImportProductsToAlgolia/ImportCategoriesToAlgolia.tsx Adds “initial import categories” UI using shared card + new batch upload hook.
apps/search/src/components/ImportProductsToAlgolia/ImportPagesToAlgolia.tsx Adds “initial import pages” UI with guard when no page types are selected.
apps/search/src/components/ImportProductsToAlgolia/useUploadState.ts Extracts upload state management for reuse across import flows.
apps/search/src/components/ImportProductsToAlgolia/runBatchedUpload.ts Adds reusable batching helper for async-generator-based imports.
apps/search/src/components/ImportProductsToAlgolia/useGraphQLClient.ts Adds client-side GraphQL fetching for channels/products/categories/pages (for initial import).
apps/search/src/components/ImportProductsToAlgolia/useProductsBatchUpload.ts New hook implementing product batch import using shared batching helper.
apps/search/src/components/ImportProductsToAlgolia/useCategoriesBatchUpload.ts New hook implementing category batch import using shared batching helper.
apps/search/src/components/ImportProductsToAlgolia/usePagesBatchUpload.ts New hook implementing page batch import using shared batching helper.
apps/search/src/components/ImportProductsToAlgolia/useBatchUpload.ts Replaces old combined hook with re-exports of new per-entity hooks/types.
apps/search/src/components/ImportProductsToAlgolia/useBatchUpload.test.ts Updates tests to cover useProductsBatchUpload instead of the removed combined hook.
apps/search/src/components/ImportProductsToAlgolia/useSearchProvider.ts Ensures Algolia provider gets pageEnabledKeys from config defaults.
apps/search/graphql/fragments/PageData.graphql Adds Page fragment used by webhooks/import queries.
apps/search/graphql/subscriptions/pageCreated.graphql Adds page-created subscription document.
apps/search/graphql/subscriptions/pageUpdated.graphql Adds page-updated subscription document.
apps/search/graphql/subscriptions/pageDeleted.graphql Adds page-deleted subscription document.
apps/search/graphql/queries/PagesData.graphql Adds query used for client-side page import (filtered by page types).
apps/search/graphql/queries/PageTypesData.graphql Adds query used to populate page types selection UI.
apps/search/generated/graphql.ts Updates generated types/documents to include pages + page types queries and subscriptions.

Comment on lines +7 to +10
export const webhookPageUpdated = new SaleorAsyncWebhook<PageUpdated>({
webhookPath: "api/webhooks/saleor/page-updated",
event: "PAGE_UPDATED",
apl: saleorApp.apl,
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

All existing Saleor webhook routes in this app use snake_case (e.g. product_updated, category_created). These new page webhooks introduce kebab-case paths (page-updated, etc.), which is inconsistent and will be harder to reason about. Consider switching webhookPath (and the corresponding API route filename) to snake_case to match the rest of the app.

Copilot uses AI. Check for mistakes.
Comment on lines +84 to +88
Choose which page types should be indexed in Algolia.
</Text>
<Text as="p" marginBottom={1.5}>
If no page types are selected, all pages will be indexed.
</Text>
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The UI copy here says that when no page types are selected, all pages will be indexed, but the implementation (ImportPagesToAlgolia + webhooks + import query) treats an empty selection as "no pages indexed". Please align the description with actual behavior (or change the indexing logic to match the copy).

Copilot uses AI. Check for mistakes.
witoszekdev
witoszekdev previously approved these changes Mar 23, 2026
@lkostrowski lkostrowski merged commit 233f044 into main Mar 25, 2026
48 of 51 checks passed
@lkostrowski lkostrowski deleted the lkostrowski/page-indexing branch March 25, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants