Skip to content

feat: add support for AM in import module#41

Open
naman-contentstack wants to merge 4 commits intofeat/AM2.0from
feat/DX-4976
Open

feat: add support for AM in import module#41
naman-contentstack wants to merge 4 commits intofeat/AM2.0from
feat/DX-4976

Conversation

@naman-contentstack
Copy link
Contributor

Import: Asset Management (AM 2.0) integration

Adds support for AM 2.0–style exports alongside the legacy asset flow in @contentstack/cli-cm-import.

  • Detection: Enables the AM path when the export includes spaces/ and stack metadata indicates am_v2 (see import-config-handler).
  • Orchestration: contentstack-import delegates space creation, folder/asset upload, org-level fields/asset types, and mapper output to @contentstack/cli-asset-management.
  • Mappers: Writes mapper/assets/uid-mapping.json, url-mapping.json, and space-uid-mapping.json for entries resolution (pending requests + throughput charts use GCP metrics; URLs map old AM direct URLs → new).
  • Stack linking: Links imported spaces to the target stack via branch settings (stack.branch(uid).updateSettings / am_v2.linked_workspaces) after mappers are written.
  • UX: Quantification queue UI: dual-axis charts, shared graph height, refresh button loading state, English copy.

Requires: @contentstack/management with branch updateSettings; region assetManagementUrl for AM API calls.

@naman-contentstack naman-contentstack self-assigned this Mar 20, 2026
@naman-contentstack naman-contentstack requested a review from a team as a code owner March 20, 2026 14:23
@github-actions
Copy link

🔒 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

🔒 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

🔒 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

Copy link
Contributor

@shafeeqd959 shafeeqd959 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not added comments for entire code changes, what I would suggest here that we should follow the export and import designs and code structures and utilities that we used in export and import of other modules here as well, please go through the assets. module export and import similar structure can be followed here, along with assets please check other modules as well, you could easily find the pattern that we followed, I expect the same here as well.

export const BATCH_SIZE = 50;
export const CHUNK_FILE_SIZE_MB = 1;

/** Default parallel AM API calls when import caller does not set apiConcurrency. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all these should be part of the import/export config passed from the export or import command, we can have defaults here

import { PROCESS_NAMES, PROCESS_STATUS } from '../constants/index';
import { runInBatches } from '../utils/concurrent-batch';

const STRIP_KEYS = ['created_at', 'created_by', 'updated_at', 'updated_by', 'is_system', 'category', 'preview_image_url', 'category_detail'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have this defined in the config

await this.init();

const dir = this.getAssetTypesDir();
const items = await this.readAllChunkedJson<Record<string, unknown>>(dir, 'asset-types.json');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use our fs utility

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