feat(global-fields): switch to per-file export/import format#307
Conversation
Replaces the bulk-array globalfields.json export with individual {uid}.json
files per global field, consistent with how content types are handled.
Export writes each global field to global_fields/{uid}.json instead of
collecting all into a single array file. Import and content-types modules
now use readGlobalFieldSchemas to scan the directory and read all per-file
schemas. The audit base command is updated to use the same function when
loading global field schemas for cross-reference validation.
The globalfields.json fileName config values are retained for type
compatibility but are no longer read or written at runtime.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
Consider reviewing these vulnerabilities when fixes become available. |
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
Consider reviewing these vulnerabilities when fixes become available. |
…json stubs, add per-uid file assertions across export/import/audit Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
Consider reviewing these vulnerabilities when fixes become available. |
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
Consider reviewing these vulnerabilities when fixes become available. |
Summary
{uid}.jsonfiles instead of a singleglobalfields.jsonarrayreadGlobalFieldSchemasBackground
Previously, all global fields were collected into a single
globalfields.jsonarray file during export. This created a monolithic file that grew unbounded and made partial reads, diffs, and targeted lookups impractical. The new per-file format stores each global field asglobal_fields/{uid}.json, making the export directory self-describing and consistent with the content types module.Changes
Export (
contentstack-export)src/export/modules/global-fields.ts{uid}.jsonimmediately insanitizeAttribssrc/config/index.tsfileNameretained for type compatibility; comment clarifies it is not used at runtimeImport (
contentstack-import)src/import/modules/global-fields.tsfsUtil.readFile(fileName)withreadGlobalFieldSchemas(dirPath)src/import/modules/content-types.tsanalyzeImportData; addedglobalfields.jsonto the content-types directory ignore list to prevent stale files being picked up as content typessrc/config/index.tsfileNamecomment updatedImport Setup (
contentstack-import-setup)src/config/index.tsfileNamecomment updatedAudit (
contentstack-audit)src/audit-base-command.tsgetCtAndGfSchemanow callsreadGlobalFieldSchemas(gfDirPath)instead of reading a single JSON file; removed unusedreadFileSyncimportsrc/config/index.tsfileNamecomment updatedBehaviour
global_fields/globalfields.json(array of all fields)global_fields/{uid}.jsonper fieldfsUtil.readFilereadGlobalFieldSchemasfs.readFileSyncreadGlobalFieldSchemas[]array fileDependencies
Requires
readGlobalFieldSchemasexported from@contentstack/cli-utilities— available in the companion PR to the cli repo. Runnpm run setupfrom the workspace root before type-checking.Test plan
global_fields/contains individual{uid}.jsonfilesglobal_fields/directory is created but emptycm:stacks:audit— verify global field cross-references resolve correctlynpx tsc --noEmitpasses in all four packages afternpm run setup🤖 Generated with Claude Code