Skip to content

Moved the shared filter engine into admin-x-framework - #29203

Merged
9larsons merged 1 commit into
mainfrom
slars/framework-filter-engine
Jul 9, 2026
Merged

Moved the shared filter engine into admin-x-framework#29203
9larsons merged 1 commit into
mainfrom
slars/framework-filter-engine

Conversation

@9larsons

@9larsons 9larsons commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Extracts the posts app's shared filter engine into @tryghost/admin-x-framework, so the domains that depend on it can dissolve into apps/admin independently. This is the last shared-infrastructure prerequisite for the posts co-location — the direct analog of the virtual-list primitive extraction (#29187).

Why

The filter AST/codec system (views/filters) and the value-source engine (hooks/filter-sources) are shared across the posts app's comments and members domains, which move into apps/admin in separate PRs. The forcing case is concrete: usePostResourceValueSource is consumed by both comments/components/comments-filters.tsx and members/components/members-filters.tsx. A workspace package can't import from apps/admin, so once one of those domains moves, the shared code has to already live somewhere both can reach.

It couples to react-query (the value sources wrap the framework api/* hooks) and to the router, so framework is the correct home, not shade — the same rule that placed the virtual-list primitive.

What changed

Extracted to framework, exposed as subpaths mirroring virtual-list:

  • @tryghost/admin-x-framework/filtersviews/filters/* (filter-ast, filter-codecs, filter-types, filter-query-core, resolve-field, filter-normalization, filter-operator-options, filter-relative-date).
  • @tryghost/admin-x-framework/filter-sourceshooks/filter-sources/* (the create-*-value-source engine + the use-*-value-source leaf hooks).
  • @tryghost/admin-x-framework/utils/get-site-timezone — used by comments, members, and post-analytics.

The colocated tests moved with their subjects. The posts consumers are rewired to the new subpaths; the source directories are deleted.

What deliberately stayed in posts

The per-domain field definitions (comment-fields, member-fields, *-filter-query, use-*-filter-fields, comments-filters, members-filters, resource-search-filter) live inside their views and move later with their domain — only their imports of the shared primitives were repointed. label-picker and member-route are out of scope.

Verification

  • pnpm --filter @tryghost/admin-x-framework build | lint | test — exit 0; 525 tests (was 451; the ~74 ported filter tests).
  • pnpm --filter @tryghost/posts build | lint | test — exit 0; 404 tests (was 478; the filter tests moved to framework — 478 − 74 = 404).
  • No @src/views/filters / @src/hooks/filter-sources / get-site-timezone references remain in apps/posts/src; source dirs deleted.

- the filter AST/codec system and the value-source engine were shared across the posts app's comments and members domains, which dissolve into apps/admin in separate PRs; a workspace package can't import from apps/admin, so the shared code had to move to a neutral home both can reach
- it's coupled to react-query (the value sources wrap the framework api hooks) and to the router, so framework is the correct home, not shade
- exposed as @tryghost/admin-x-framework/filters and /filter-sources subpaths, mirroring the virtual-list primitive; get-site-timezone moved too, since comments/members/post-analytics all use it
- the per-domain field definitions stay with their views and move later with their domain — only the shared primitives and value-source engine were extracted
@nx-cloud

nx-cloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 4d3dd73

Command Status Duration Result
nx run @tryghost/admin-x-settings:test:acceptance ✅ Succeeded 11m 4s View ↗
nx run ghost:test:ci:integration ✅ Succeeded 2m 52s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded <1s View ↗
nx run-many -t test:unit -p @tryghost/admin-x-f... ✅ Succeeded 6m 9s View ↗
nx run ghost:test:integration ✅ Succeeded 2m 52s View ↗
nx run @tryghost/admin:build ✅ Succeeded 3m 22s View ↗
nx run ghost:test:legacy ✅ Succeeded 3m 26s View ↗
nx run ghost-admin:test ✅ Succeeded 3m 53s View ↗
Additional runs (9) ✅ Succeeded ... View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-09 15:52:44 UTC

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9710131c-be04-4f34-bd7c-d793845e4d10

📥 Commits

Reviewing files that changed from the base of the PR and between 614e55b and 4d3dd73.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (58)
  • apps/admin-x-framework/package.json
  • apps/admin-x-framework/src/filter-sources/create-combined-value-source.ts
  • apps/admin-x-framework/src/filter-sources/create-ghost-browse-value-source.ts
  • apps/admin-x-framework/src/filter-sources/create-hybrid-value-source.ts
  • apps/admin-x-framework/src/filter-sources/create-local-value-source.ts
  • apps/admin-x-framework/src/filter-sources/create-remote-value-source.ts
  • apps/admin-x-framework/src/filter-sources/index.ts
  • apps/admin-x-framework/src/filter-sources/use-email-post-value-source.ts
  • apps/admin-x-framework/src/filter-sources/use-label-value-source.ts
  • apps/admin-x-framework/src/filter-sources/use-member-value-source.ts
  • apps/admin-x-framework/src/filter-sources/use-post-resource-value-source.ts
  • apps/admin-x-framework/src/filter-sources/use-tier-value-source.ts
  • apps/admin-x-framework/src/filter-sources/utils.ts
  • apps/admin-x-framework/src/filters/filter-ast.ts
  • apps/admin-x-framework/src/filters/filter-codecs.ts
  • apps/admin-x-framework/src/filters/filter-date.ts
  • apps/admin-x-framework/src/filters/filter-normalization.ts
  • apps/admin-x-framework/src/filters/filter-operator-options.ts
  • apps/admin-x-framework/src/filters/filter-query-core.ts
  • apps/admin-x-framework/src/filters/filter-relative-date.tsx
  • apps/admin-x-framework/src/filters/filter-types.ts
  • apps/admin-x-framework/src/filters/index.ts
  • apps/admin-x-framework/src/filters/resolve-field.ts
  • apps/admin-x-framework/src/nql-lang.d.ts
  • apps/admin-x-framework/src/utils/get-site-timezone.ts
  • apps/admin-x-framework/test/setup.ts
  • apps/admin-x-framework/test/unit/filter-sources/create-combined-value-source.test.tsx
  • apps/admin-x-framework/test/unit/filter-sources/create-hybrid-value-source.test.tsx
  • apps/admin-x-framework/test/unit/filter-sources/create-remote-value-source.test.tsx
  • apps/admin-x-framework/test/unit/filter-sources/use-tier-value-source.test.tsx
  • apps/admin-x-framework/test/unit/filters/filter-ast.test.ts
  • apps/admin-x-framework/test/unit/filters/filter-codecs.test.ts
  • apps/admin-x-framework/test/unit/filters/filter-normalization.test.ts
  • apps/admin-x-framework/test/unit/filters/filter-query-core.test.ts
  • apps/admin-x-framework/test/unit/filters/filter-relative-date.test.tsx
  • apps/admin-x-framework/test/unit/filters/filter-types.test.ts
  • apps/admin-x-framework/test/unit/filters/resolve-field.test.ts
  • apps/admin-x-framework/test/unit/utils/get-site-timezone.test.ts
  • apps/posts/src/hooks/use-label-picker.ts
  • apps/posts/src/views/PostAnalytics/components/post-analytics-header.tsx
  • apps/posts/src/views/comments/comment-fields.ts
  • apps/posts/src/views/comments/comment-filter-query.ts
  • apps/posts/src/views/comments/comments.tsx
  • apps/posts/src/views/comments/components/comments-filters.tsx
  • apps/posts/src/views/comments/use-comment-filter-fields.ts
  • apps/posts/src/views/members/components/members-filters.tsx
  • apps/posts/src/views/members/hooks/resource-search-filter.ts
  • apps/posts/src/views/members/member-fields.test.ts
  • apps/posts/src/views/members/member-fields.ts
  • apps/posts/src/views/members/member-filter-query.test.ts
  • apps/posts/src/views/members/member-filter-query.ts
  • apps/posts/src/views/members/member-query-params.test.ts
  • apps/posts/src/views/members/member-query-params.ts
  • apps/posts/src/views/members/members.tsx
  • apps/posts/src/views/members/use-member-filter-fields.ts
  • apps/posts/test/unit/hooks/use-label-picker.test.tsx
  • apps/posts/test/unit/views/comments/comment-fields.test.ts
  • apps/posts/test/unit/views/comments/comment-filter-query.test.ts

Walkthrough

This change introduces new public export entrypoints (./utils/get-site-timezone, ./filters, ./filter-sources) and dependencies (@tryghost/nql-lang, temporal-polyfill, use-debounce) in the admin-x-framework package. Barrel modules were added for filters and filter-sources, a new @tryghost/nql-lang type declaration was created, and internal imports within admin-x-framework were switched from alias/package paths to relative paths. Consumer code and tests in apps/posts were updated to import filters, filter-sources, and timezone utilities from the new admin-x-framework package exports instead of local modules. No functional logic changes were made.

Suggested reviewers: EvanHahn, acburdine

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: extracting the shared filter engine into admin-x-framework.
Description check ✅ Passed The description is directly related to the changeset and accurately explains the extraction and rewiring work.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch slars/framework-filter-engine

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.04%. Comparing base (a8a9d1b) to head (4d3dd73).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #29203      +/-   ##
==========================================
- Coverage   74.07%   74.04%   -0.03%     
==========================================
  Files        1570     1570              
  Lines      136629   136628       -1     
  Branches    16530    16521       -9     
==========================================
- Hits       101204   101163      -41     
- Misses      34419    34460      +41     
+ Partials     1006     1005       -1     
Flag Coverage Δ
admin-tests 55.19% <ø> (+0.02%) ⬆️
e2e-tests 76.15% <ø> (-0.04%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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.

@9larsons
9larsons merged commit 7493e13 into main Jul 9, 2026
52 checks passed
@9larsons
9larsons deleted the slars/framework-filter-engine branch July 9, 2026 16:09
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.

1 participant