-
Notifications
You must be signed in to change notification settings - Fork 16
Feat/query support #2001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Feat/query support #2001
Conversation
There was a problem hiding this 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 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
--query
flag to the export command with support for both inline JSON and file path inputs - Implemented query filtering infrastructure through a new
applyQueryFilters
method 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}`);
Add Query Filtering Support to Export Command
🎯 Overview
Adds support for a new
--query
flag in thecm:stacks:export
command to enable filtered exports of modules using JSON query parameters.✨ What's New
--query
flag: Accepts inline JSON or file path for filtering module exports--query '{"modules": {...}}'
and--query ./query.json
🔧 Changes Made
1. Export Command Updates
--query
flag tosrc/commands/cm/stacks/export.ts
- for now this will be hidden2. Configuration Handling
ExportConfig
interface to include optionalquery
fieldexport-config-handler.ts
with robust JSON parsing logic3. Base Architecture
applyQueryFilters()
method tobase-class.ts
4. Module Integration
applyQueryFilters
)applyQueryFilters
)applyQueryFilters
)applyQueryFilters
)📖 Usage Examples
Inline JSON Query
File-based Query
# Using external JSON file cm:stacks:export --query ./filters.json
Example
filters.json
:🎨 Query Structure
✅ Supported Modules
applyQueryFilters()
🛡️ Error Handling