Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds query filtering support to the export command, allowing users to filter module exports using JSON query parameters via a new --query flag. The implementation includes both inline JSON and file-based query input methods, with robust error handling and backward compatibility.
- Added
--queryflag to the export command with support for both inline JSON and file path inputs - Implemented query filtering infrastructure through a new
applyQueryFiltersmethod in the base class - Integrated query filtering across all supported modules (content-types, global-fields, extensions, taxonomies, assets)
Reviewed Changes
Copilot reviewed 26 out of 28 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/contentstack-export/src/commands/cm/stacks/export.ts | Added the new hidden --query flag to the export command |
| packages/contentstack-export/src/utils/export-config-handler.ts | Added query parsing logic for both inline JSON and file-based inputs |
| packages/contentstack-export/src/types/export-config.ts | Extended ExportConfig interface to include query field and additional boolean flags |
| packages/contentstack-export/src/export/modules/base-class.ts | Added applyQueryFilters method for reusable query application |
| packages/contentstack-export/src/export/modules/*.ts | Integrated query filtering into individual module exporters |
| packages/contentstack-export/src/export/module-exporter.ts | Added logic to conditionally skip stack settings and dependencies |
| packages/contentstack/package.json | Version bump for the export package dependency |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
packages/contentstack-export/src/utils/export-config-handler.ts:106
- [nitpick] The error message could be more specific about what constitutes a valid query format. Consider providing examples of valid formats in the error message.
throw new Error(`Invalid query format: ${error.message}`);
aman19K
requested changes
Jul 18, 2025
harshithad0703
previously approved these changes
Jul 21, 2025
aman19K
approved these changes
Jul 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Query Filtering Support to Export Command
🎯 Overview
Adds support for a new
--queryflag in thecm:stacks:exportcommand to enable filtered exports of modules using JSON query parameters.✨ What's New
--queryflag: Accepts inline JSON or file path for filtering module exports--query '{"modules": {...}}'and--query ./query.json🔧 Changes Made
1. Export Command Updates
--queryflag tosrc/commands/cm/stacks/export.ts- for now this will be hidden2. Configuration Handling
ExportConfiginterface to include optionalqueryfieldexport-config-handler.tswith robust JSON parsing logic3. Base Architecture
applyQueryFilters()method tobase-class.ts4. Module Integration
applyQueryFilters)applyQueryFilters)applyQueryFilters)applyQueryFilters)📖 Usage Examples
Inline JSON Query
File-based Query
# Using external JSON file cm:stacks:export --query ./filters.jsonExample
filters.json:{ "modules": { "content-types": { "title": {"$in": ["Blog", "Author"]}, "updated_at": {"$gte": "2024-01-01"} }, "extensions": { "type": "field" } } }🎨 Query Structure
{ "modules": { "module-name": { // Standard Contentstack API query parameters "field": {"$operator": "value"}, "limit": 10, "skip": 0 } } }✅ Supported Modules
applyQueryFilters()🛡️ Error Handling