Skip to content

export query v1 support#122

Draft
shafeeqd959 wants to merge 2 commits intodevelopmentfrom
query-export-v1
Draft

export query v1 support#122
shafeeqd959 wants to merge 2 commits intodevelopmentfrom
query-export-v1

Conversation

@shafeeqd959
Copy link
Copy Markdown
Contributor

@shafeeqd959 shafeeqd959 commented Apr 30, 2026

Summary
Aligns @contentstack/cli-cm-export-query with CLI v1 export layout and utilities, and fixes missing entries when multiple content-types export runs overwrite content_types/schema.json.

Motivation
v1 on-disk contract — Content types are aggregated in content_types/schema.json; global fields stay on the existing global_fields layout (globalfields.json / per-file), not a single CT-style schema.json for GFs.
Utilities — Current @contentstack/cli-utilities does not expose loadChalk / readContentTypeSchemas in the same way; the plugin should not depend on them.
Entries gap — cli-cm-export writes schema.json with only the content types from the latest content-types run. Query export invokes that module several times (query + closure), so schema.json could drop earlier types (e.g. queried test) while {uid}.json files remained. The entries module only reads schema.json, so entries for those types were skipped.
Changes
CLI v1 / query plan (query-v1.md)
export-query.ts — Removed loadChalk import and await loadChalk() from run().
read-content-type-schemas.ts (new) —
readContentTypesFromExportDir — reads …/content_types/schema.json into any[].
readGlobalFieldSchemasFromDir — globalfields.json first, then legacy per-directory / loose JSON under global_fields/.
query-executor.ts — expandSchemaClosure uses the above for CT vs GF reads instead of utilities’ readContentTypeSchemas.
dependency-resolver.ts — Disk fallback loads CTs via readContentTypesFromExportDir only; removed unused utilities imports.
config/index.ts — contentVersion set to 1 for this branch.
Fix: full CT list for entries / closure
rebuildContentTypesSchemaJson — Rebuilds content_types/schema.json from every per-UID *.json in that folder (excluding schema.json), deduped by uid.
module-exporter.ts — After each successful content-types export, calls rebuildContentTypesSchemaJson for {exportDir}/{branch}/content_types so the aggregate matches all on-disk CT files before entries (and matches what closure reads from disk).
Tests
query-executor.test.ts — Stubs readContentTypesFromExportDir / readGlobalFieldSchemasFromDir instead of non-existent content-type-utils.
dependency-resolver.test.ts — contentVersion: 1, temp-dir coverage for disk fallback from schema.json, and related imports.
read-content-type-schemas.test.ts — Merge, dedupe-by-uid, and invalid-file behavior for rebuildContentTypesSchemaJson.
How to verify
Run a query export that pulls a CT and then pulls referenced CTs (e.g. title filter on a type that references others).
Confirm content_types/schema.json lists all UIDs that have content_types/.json.
Confirm entries// exists for each of those types (including the originally queried one).
Risk / notes
Order of files on disk — Rebuild uses readdir; duplicate uid from multiple files resolves to one winner (last write wins in the current Map iteration order). Normal export layout is one file per uid.
Upstream — Longer term, merging in @contentstack/cli-cm-export would avoid needing this rebuild in the plugin; until then this keeps v1 query export consistent.

@github-actions
Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 0 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

✅ BUILD PASSED - All security checks passed

@github-actions
Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 0 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

✅ BUILD PASSED - All security checks passed

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