feat: add support for AM in import module#41
feat: add support for AM in import module#41naman-contentstack wants to merge 7 commits intofeat/AM2.0from
Conversation
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
shafeeqd959
left a comment
There was a problem hiding this comment.
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.
packages/contentstack-asset-management/src/import/asset-types.ts
Outdated
Show resolved
Hide resolved
packages/contentstack-asset-management/src/import/asset-types.ts
Outdated
Show resolved
Hide resolved
🔒 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:
✅ BUILD PASSED - All security checks passed |
🔒 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:
✅ BUILD PASSED - All security checks passed |
| const stripKeys = this.importContext.assetTypesImportInvalidKeys ?? [...FALLBACK_ASSET_TYPES_IMPORT_INVALID_KEYS]; | ||
| const dir = this.getAssetTypesDir(); | ||
| const indexName = this.importContext.assetTypesFileName ?? 'asset-types.json'; | ||
| const items = await readChunkedJsonItems<Record<string, unknown>>(dir, indexName, this.importContext.context); |
There was a problem hiding this comment.
using fs utility, we are already have a way to read to this, no need of this implementation at all "readChunkedJsonItems"
packages/contentstack-asset-management/src/import/asset-types.ts
Outdated
Show resolved
Hide resolved
| toCreate.push({ uid, payload: omit(field, stripKeys) as Record<string, unknown> }); | ||
| } | ||
|
|
||
| await runInBatches(toCreate, this.apiConcurrency, async ({ uid, payload }) => { |
There was a problem hiding this comment.
suggestion: use the concurrency approach and methods in all other modules in import command
| * Read all items from a chunked JSON store (index + chunk files) using FsUtility, | ||
| * matching the pattern used in contentstack-import entry modules. | ||
| */ | ||
| export async function readChunkedJsonItems<T = Record<string, unknown>>( |
🔒 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:
✅ BUILD PASSED - All security checks passed |
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.spaces/and stack metadata indicatesam_v2(seeimport-config-handler).contentstack-importdelegates space creation, folder/asset upload, org-level fields/asset types, and mapper output to@contentstack/cli-asset-management.mapper/assets/uid-mapping.json,url-mapping.json, andspace-uid-mapping.jsonforentriesresolution (pending requests + throughput charts use GCP metrics; URLs map old AM direct URLs → new).stack.branch(uid).updateSettings/am_v2.linked_workspaces) after mappers are written.Requires:
@contentstack/managementwith branchupdateSettings; regionassetManagementUrlfor AM API calls.