diff --git a/package-lock.json b/package-lock.json index c1cd355f6f..50c74faf07 100644 --- a/package-lock.json +++ b/package-lock.json @@ -885,9 +885,9 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.10.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", - "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.1.tgz", + "integrity": "sha512-Zm2NGpWELsQAD1xsJzGQpYfvICSsFkEpU0jxBjfdC6uNEWXcHnfs9hScFWtXVDVl+rBQJGrl4g1vcKIejpH9dA==", "dev": true, "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" @@ -2025,9 +2025,9 @@ } }, "node_modules/@oclif/core": { - "version": "3.26.6", - "resolved": "https://registry.npmjs.org/@oclif/core/-/core-3.26.6.tgz", - "integrity": "sha512-+FiTw1IPuJTF9tSAlTsY8bGK4sgthehjz7c2SvYdgQncTkxI2xvUch/8QpjNYGLEmUneNygvYMRBax2KJcLccA==", + "version": "3.26.9", + "resolved": "https://registry.npmjs.org/@oclif/core/-/core-3.26.9.tgz", + "integrity": "sha512-yB5Yxd62DsHqqCK/60L8IiGpTRIU4J+fzCqfbPRiIYE5+agfN63kppaM+TbqyMBdsnt/PQOnYD8Bhs1quUr6fg==", "dependencies": { "@types/cli-progress": "^3.11.5", "ansi-escapes": "^4.3.2", @@ -2037,7 +2037,7 @@ "clean-stack": "^3.0.1", "cli-progress": "^3.12.0", "color": "^4.2.3", - "debug": "^4.3.4", + "debug": "^4.3.5", "ejs": "^3.1.10", "get-package-type": "^0.1.0", "globby": "^11.1.0", @@ -3041,9 +3041,9 @@ } }, "node_modules/@slack/logger/node_modules/@types/node": { - "version": "20.14.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.0.tgz", - "integrity": "sha512-5cHBxFGJx6L4s56Bubp4fglrEpmyJypsqI6RgzMfBHWUJQGWAAi8cWcgetEbZXHYXo9C2Fa4EEds/uSyS4cxmA==", + "version": "20.14.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.1.tgz", + "integrity": "sha512-T2MzSGEu+ysB/FkWfqmhV3PLyQlowdptmmgD20C6QxsS8Fmv5SjpZ1ayXaEC0S21/h5UJ9iA6W/5vSNU5l00OA==", "dependencies": { "undici-types": "~5.26.4" } @@ -4137,14 +4137,14 @@ } }, "node_modules/ajv": { - "version": "8.14.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.14.0.tgz", - "integrity": "sha512-oYs1UUtO97ZO2lJ4bwnWeQW8/zvOIQLGKcvPTsWmvc2SYgBb+upuNS5NxoLaMU4h8Ju3Nbj6Cq8mD2LQoqVKFA==", + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.15.0.tgz", + "integrity": "sha512-15BTtQUOsSrmHCy+B4VnAiJAJxJ8IFgu6fcjFQF3jQYZ78nLSQthlFg4ehp+NLIyfvFgOlxNsjKIEhydtFPVHQ==", "dependencies": { "fast-deep-equal": "^3.1.3", + "fast-uri": "^2.3.0", "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.4.1" + "require-from-string": "^2.0.2" }, "funding": { "type": "github", @@ -4602,9 +4602,9 @@ } }, "node_modules/aws-sdk": { - "version": "2.1632.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1632.0.tgz", - "integrity": "sha512-doNHUxto00r7r9qWb5RcIsQHUTHdGiPPyJoXxmsmQW6aOr69BqYeuFl8SicNS1YzP6s5sFFnDNKq9KB7jA2fyA==", + "version": "2.1633.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1633.0.tgz", + "integrity": "sha512-9OUTdosQgZO6P6hPyEOUDvm4cymbMB0Qn1etucPql95DHjNyIex3FJOBbeRikU+5Wt9Djgdcr+BqAee2Lv/7iw==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -6948,9 +6948,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.788", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.788.tgz", - "integrity": "sha512-ubp5+Ev/VV8KuRoWnfP2QF2Bg+O2ZFdb49DiiNbz2VmgkIqrnyYaqIOqj8A6K/3p1xV0QcU5hBQ1+BmB6ot1OA==", + "version": "1.4.789", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.789.tgz", + "integrity": "sha512-0VbyiaXoT++Fi2vHGo2ThOeS6X3vgRCWrjPeO2FeIAWL6ItiSJ9BqlH8LfCXe3X1IdcG+S0iLoNaxQWhfZoGzQ==", "dev": true }, "node_modules/elegant-spinner": { @@ -8102,13 +8102,13 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/scope-manager": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.11.0.tgz", - "integrity": "sha512-27tGdVEiutD4POirLZX4YzT180vevUURJl4wJGmm6TrQoiYwuxTIY98PBp6L2oN+JQxzE0URvYlzJaBHIekXAw==", + "version": "7.12.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.12.0.tgz", + "integrity": "sha512-itF1pTnN6F3unPak+kutH9raIkL3lhH1YRPGgt7QQOh43DQKVJXmWkpb+vpc/TiDHs6RSd9CTbDsc/Y+Ygq7kg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.11.0", - "@typescript-eslint/visitor-keys": "7.11.0" + "@typescript-eslint/types": "7.12.0", + "@typescript-eslint/visitor-keys": "7.12.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -8119,9 +8119,9 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/types": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.11.0.tgz", - "integrity": "sha512-MPEsDRZTyCiXkD4vd3zywDCifi7tatc4K37KqTprCvaXptP7Xlpdw0NR2hRJTetG5TxbWDB79Ys4kLmHliEo/w==", + "version": "7.12.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.12.0.tgz", + "integrity": "sha512-o+0Te6eWp2ppKY3mLCU+YA9pVJxhUJE15FV7kxuD9jgwIAa+w/ycGJBMrYDTpVGUM/tgpa9SeMOugSabWFq7bg==", "dev": true, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -8132,13 +8132,13 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/typescript-estree": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.11.0.tgz", - "integrity": "sha512-cxkhZ2C/iyi3/6U9EPc5y+a6csqHItndvN/CzbNXTNrsC3/ASoYQZEt9uMaEp+xFNjasqQyszp5TumAVKKvJeQ==", + "version": "7.12.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.12.0.tgz", + "integrity": "sha512-5bwqLsWBULv1h6pn7cMW5dXX/Y2amRqLaKqsASVwbBHMZSnHqE/HN4vT4fE0aFsiwxYvr98kqOWh1a8ZKXalCQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.11.0", - "@typescript-eslint/visitor-keys": "7.11.0", + "@typescript-eslint/types": "7.12.0", + "@typescript-eslint/visitor-keys": "7.12.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -8160,15 +8160,15 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/utils": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.11.0.tgz", - "integrity": "sha512-xlAWwPleNRHwF37AhrZurOxA1wyXowW4PqVXZVUNCLjB48CqdPJoJWkrpH2nij9Q3Lb7rtWindtoXwxjxlKKCA==", + "version": "7.12.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.12.0.tgz", + "integrity": "sha512-Y6hhwxwDx41HNpjuYswYp6gDbkiZ8Hin9Bf5aJQn1bpTs3afYY4GX+MPYxma8jtoIV2GRwTM/UJm/2uGCVv+DQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "7.11.0", - "@typescript-eslint/types": "7.11.0", - "@typescript-eslint/typescript-estree": "7.11.0" + "@typescript-eslint/scope-manager": "7.12.0", + "@typescript-eslint/types": "7.12.0", + "@typescript-eslint/typescript-estree": "7.12.0" }, "engines": { "node": "^18.18.0 || >=20.0.0" @@ -8182,12 +8182,12 @@ } }, "node_modules/eslint-plugin-perfectionist/node_modules/@typescript-eslint/visitor-keys": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.11.0.tgz", - "integrity": "sha512-7syYk4MzjxTEk0g/w3iqtgxnFQspDJfn6QKD36xMuuhTzjcxY7F8EmBLnALjVyaOF1/bVocu3bS/2/F7rXrveQ==", + "version": "7.12.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.12.0.tgz", + "integrity": "sha512-uZk7DevrQLL3vSnfFl5bj4sL75qC9D6EdjemIdbtkuUmIheWpuiiylSY01JxJE7+zGrOWDZrp1WxOuDntvKrHQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.11.0", + "@typescript-eslint/types": "7.12.0", "eslint-visitor-keys": "^3.4.3" }, "engines": { @@ -8797,6 +8797,11 @@ "fastest-levenshtein": "^1.0.7" } }, + "node_modules/fast-uri": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-2.3.0.tgz", + "integrity": "sha512-eel5UKGn369gGEWOqBShmFJWfq/xSJvsgDzgLYC845GneayWvXBf0lJCBn5qTABfewy1ZDPoaR5OZCP+kssfuw==" + }, "node_modules/fastest-levenshtein": { "version": "1.0.16", "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", @@ -11761,9 +11766,9 @@ } }, "node_modules/jackspeak": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.1.2.tgz", - "integrity": "sha512-kWmLKn2tRtfYMF/BakihVVRzBKOxz4gJMiL2Rj91WnAB5TPZumSH99R/Yf1qE1u4uRimvCSJfm6hnxohXeEXjQ==", + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.2.3.tgz", + "integrity": "sha512-htOzIMPbpLid/Gq9/zaz9SfExABxqRe1sSCdxntlO/aMD6u0issZQiY25n2GKQUtJ02j7z5sfptlAOMpWWOmvw==", "dependencies": { "@isaacs/cliui": "^8.0.2" }, @@ -23035,6 +23040,7 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, "dependencies": { "punycode": "^2.1.0" } @@ -24887,7 +24893,7 @@ "@contentstack/cli-cm-clone": "~1.10.5", "@contentstack/cli-cm-export": "~1.11.4", "@contentstack/cli-cm-export-to-csv": "~1.7.1", - "@contentstack/cli-cm-import": "~1.15.6", + "@contentstack/cli-cm-import": "~1.15.7", "@contentstack/cli-cm-migrate-rte": "~1.4.17", "@contentstack/cli-cm-seed": "~1.7.5", "@contentstack/cli-command": "~1.2.18", @@ -25003,9 +25009,9 @@ "dev": true }, "packages/contentstack-audit/node_modules/@types/node": { - "version": "20.14.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.0.tgz", - "integrity": "sha512-5cHBxFGJx6L4s56Bubp4fglrEpmyJypsqI6RgzMfBHWUJQGWAAi8cWcgetEbZXHYXo9C2Fa4EEds/uSyS4cxmA==", + "version": "20.14.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.1.tgz", + "integrity": "sha512-T2MzSGEu+ysB/FkWfqmhV3PLyQlowdptmmgD20C6QxsS8Fmv5SjpZ1ayXaEC0S21/h5UJ9iA6W/5vSNU5l00OA==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -25429,7 +25435,7 @@ "dependencies": { "@colors/colors": "^1.5.0", "@contentstack/cli-cm-export": "~1.11.4", - "@contentstack/cli-cm-import": "~1.15.6", + "@contentstack/cli-cm-import": "~1.15.7", "@contentstack/cli-command": "~1.2.18", "@contentstack/cli-utilities": "~1.6.2", "async": "^3.2.4", @@ -26514,7 +26520,7 @@ }, "packages/contentstack-import": { "name": "@contentstack/cli-cm-import", - "version": "1.15.6", + "version": "1.15.7", "license": "MIT", "dependencies": { "@contentstack/cli-audit": "~1.6.2", @@ -26727,9 +26733,9 @@ "dev": true }, "packages/contentstack-launch/node_modules/@types/node": { - "version": "16.18.97", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.97.tgz", - "integrity": "sha512-4muilE1Lbfn57unR+/nT9AFjWk0MtWi5muwCEJqnOvfRQDbSfLCUdN7vCIg8TYuaANfhLOV85ve+FNpiUsbSRg==", + "version": "16.18.98", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.18.98.tgz", + "integrity": "sha512-fpiC20NvLpTLAzo3oVBKIqBGR6Fx/8oAK/SSf7G+fydnXMY1x4x9RZ6sBXhqKlCU21g2QapUsbLlhv3+a7wS+Q==", "dev": true }, "packages/contentstack-launch/node_modules/acorn": { @@ -26999,7 +27005,7 @@ "version": "1.7.5", "license": "MIT", "dependencies": { - "@contentstack/cli-cm-import": "~1.15.6", + "@contentstack/cli-cm-import": "~1.15.7", "@contentstack/cli-command": "~1.2.18", "@contentstack/cli-utilities": "~1.6.2", "inquirer": "8.2.4", diff --git a/packages/contentstack-clone/package.json b/packages/contentstack-clone/package.json index ed02269c3f..1805af5db7 100644 --- a/packages/contentstack-clone/package.json +++ b/packages/contentstack-clone/package.json @@ -7,7 +7,7 @@ "dependencies": { "@colors/colors": "^1.5.0", "@contentstack/cli-cm-export": "~1.11.4", - "@contentstack/cli-cm-import": "~1.15.6", + "@contentstack/cli-cm-import": "~1.15.7", "@contentstack/cli-command": "~1.2.18", "@contentstack/cli-utilities": "~1.6.2", "async": "^3.2.4", @@ -72,4 +72,4 @@ "cm:stack-clone": "O-CLN" } } -} \ No newline at end of file +} diff --git a/packages/contentstack-import/package.json b/packages/contentstack-import/package.json index b7204be466..15ca62e95c 100644 --- a/packages/contentstack-import/package.json +++ b/packages/contentstack-import/package.json @@ -1,7 +1,7 @@ { "name": "@contentstack/cli-cm-import", "description": "Contentstack CLI plugin to import content into stack", - "version": "1.15.6", + "version": "1.15.7", "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { @@ -99,4 +99,4 @@ } }, "repository": "https://github.com/contentstack/cli" -} \ No newline at end of file +} diff --git a/packages/contentstack-import/src/utils/asset-helper.ts b/packages/contentstack-import/src/utils/asset-helper.ts index 924028243e..d13bb8dd57 100644 --- a/packages/contentstack-import/src/utils/asset-helper.ts +++ b/packages/contentstack-import/src/utils/asset-helper.ts @@ -83,11 +83,11 @@ export const lookupAssets = function ( if ( schema[i].data_type === 'text' && schema[i].field_metadata && - (schema[i].field_metadata.markdown || schema[i].field_metadata.rich_text_type) + (schema[i]?.field_metadata?.markdown || schema[i]?.field_metadata?.rich_text_type) ) { parent.push(schema[i].uid); findFileUrls(schema[i], entryToFind, assetUrls); - if (schema[i].field_metadata.rich_text_type) { + if (schema[i]?.field_metadata?.rich_text_type) { findAssetIdsFromHtmlRte(entryToFind, schema[i]); } parent.pop(); @@ -110,7 +110,7 @@ export const lookupAssets = function ( } // added rich_text_type field check because some marketplace extensions also // have data_type has json - if (schema[i].data_type === 'json' && schema[i].field_metadata.rich_text_type) { + if (schema[i].data_type === 'json' && schema[i]?.field_metadata?.rich_text_type) { parent.push(schema[i].uid); // findFileUrls(schema[i], entry, assetUrls) findAssetIdsFromJsonRte(data.entry, data.content_type.schema); @@ -188,7 +188,7 @@ export const lookupAssets = function ( break; } case 'json': { - if (entryObj[element.uid] && element.field_metadata.rich_text_type) { + if (entryObj[element.uid] && element?.field_metadata?.rich_text_type) { if (element.multiple) { entryObj[element.uid].forEach((jsonRteData: any) => { gatherJsonRteAssetIds(jsonRteData); @@ -267,7 +267,7 @@ export const lookupAssets = function ( if (typeof uid !== 'undefined') { const escapedAssetUid = assetUid.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); const regex = new RegExp(`\\b${escapedAssetUid}\\b`, 'img'); - let { status } = validateRegex(new RegExp(regex, 'img')) + let { status } = validateRegex(new RegExp(regex, 'img')); if (status === 'safe') { entry = entry.replace(regex, uid); matchedUids.push(assetUid); diff --git a/packages/contentstack-import/src/utils/content-type-helper.ts b/packages/contentstack-import/src/utils/content-type-helper.ts index 3e3b30ef35..fa485221c5 100644 --- a/packages/contentstack-import/src/utils/content-type-helper.ts +++ b/packages/contentstack-import/src/utils/content-type-helper.ts @@ -60,10 +60,10 @@ export const suppressSchemaReference = function (schema: any, flag: any) { } } else if (schema[i].data_type === 'reference') { flag.references = true; - } else if (schema[i].data_type === 'json' && schema[i].field_metadata.rich_text_type) { + } else if (schema[i].data_type === 'json' && schema[i]?.field_metadata?.rich_text_type) { flag.jsonRte = true; if (schema[i].field_metadata.embed_entry === true) flag.jsonRteEmbeddedEntries = true; - } else if (schema[i].data_type === 'text' && schema[i].field_metadata.rich_text_type) { + } else if (schema[i].data_type === 'text' && schema[i]?.field_metadata?.rich_text_type) { flag.rte = true; if (schema[i].field_metadata.embed_entry === true) flag.rteEmbeddedEntries = true; } @@ -143,18 +143,18 @@ export const removeReferenceFields = async function ( } else if ( // handling entry references in json rte schema[i].data_type === 'json' && - schema[i].field_metadata.rich_text_type && - schema[i].field_metadata.embed_entry && - schema[i].reference_to.length > 1 + schema[i]?.field_metadata?.rich_text_type && + schema[i]?.field_metadata?.embed_entry && + schema[i]?.reference_to?.length > 1 ) { flag.supressed = true; schema[i].reference_to = ['sys_assets']; } else if ( // handling entry references in rte schema[i].data_type === 'text' && - schema[i].field_metadata.rich_text_type && - schema[i].field_metadata.embed_entry && - schema[i].reference_to.length >= 1 + schema[i]?.field_metadata?.rich_text_type && + schema[i]?.field_metadata?.embed_entry && + schema[i]?.reference_to?.length >= 1 ) { flag.supressed = true; schema[i].reference_to = ['sys_assets']; @@ -185,4 +185,4 @@ export const updateFieldRules = function (contentType: any) { } } return fieldRules; -} +}; diff --git a/packages/contentstack-import/src/utils/entries-helper.ts b/packages/contentstack-import/src/utils/entries-helper.ts index 206afa4c5f..2a6019225c 100644 --- a/packages/contentstack-import/src/utils/entries-helper.ts +++ b/packages/contentstack-import/src/utils/entries-helper.ts @@ -62,8 +62,8 @@ export const lookupEntries = function ( if (_entry && _parent[j]) { if (j === len - 1 && _entry[_parent[j]]) { if (form_id !== '_assets') { - if (_entry[_parent[j]]?.length) { - _entry[_parent[j]].forEach((item: any, idx: any) => { + if (_entry[_parent[j]]?.length && Object.keys(_entry).includes(_parent[j])) { + _entry[_parent[j]]?.forEach((item: any, idx: any) => { if (typeof item.uid === 'string' && item._content_type_uid) { uids.push(item.uid); } else if (typeof item === 'string' && preserveStackVersion === true) { @@ -110,7 +110,7 @@ export const lookupEntries = function ( case 'reference': if (Array.isArray(schema[i].reference_to)) { isNewRefFields = true; - schema[i].reference_to.forEach((reference: any) => { + schema[i]?.reference_to?.forEach((reference: any) => { parent.push(schema[i].uid); update(parent, reference, _entry); parent.pop(); @@ -137,7 +137,7 @@ export const lookupEntries = function ( } break; case 'json': - if (schema[i].field_metadata.rich_text_type) { + if (schema[i]?.field_metadata?.rich_text_type) { findEntryIdsFromJsonRte(data.entry, data.content_type.schema); } break; @@ -174,7 +174,7 @@ export const lookupEntries = function ( break; } case 'json': { - if (entry[element.uid] && element.field_metadata.rich_text_type) { + if (entry[element.uid] && element?.field_metadata?.rich_text_type) { if (element.multiple) { entry[element.uid]?.forEach((jsonRteData: any) => { gatherJsonRteEntryIds(jsonRteData); @@ -201,7 +201,7 @@ export const lookupEntries = function ( uids = _.uniq(uids); let entry = JSON.stringify(data.entry); - uids.forEach(function (uid: any) { + uids?.forEach(function (uid: any) { if (mappedUids.hasOwnProperty(uid)) { const sanitizedUid = escapeRegExp(uid); const escapedMappedUid = escapeRegExp(mappedUids[uid]); @@ -252,7 +252,7 @@ function findUidsInNewRefFields(entry: any, uids: string[]) { if (entry.uid && entry._content_type_uid) { uids.push(entry.uid); } else if (Array.isArray(entry) && entry.length) { - entry.forEach(function (elem) { + entry?.forEach(function (elem) { findUidsInNewRefFields(elem, uids); }); } else if (Object.keys(entry).length) { @@ -299,7 +299,7 @@ export const removeUidsFromJsonRteFields = ( break; } case 'json': { - if (entry[element.uid] && element.field_metadata.rich_text_type) { + if (entry[element.uid] && element?.field_metadata?.rich_text_type) { if (element.multiple) { entry[element.uid] = entry[element.uid].map((jsonRteData: any) => { delete jsonRteData.uid; // remove uid @@ -394,7 +394,7 @@ export const removeEntryRefsFromJSONRTE = (entry: Record, ctSchema: } case 'json': { const structuredPTag = '{"type":"p","attrs":{},"children":[{"text":""}]}'; - if (entry[element.uid] && element.field_metadata.rich_text_type) { + if (entry[element.uid] && element?.field_metadata?.rich_text_type) { if (element.multiple) { entry[element.uid] = entry[element.uid].map(removeReferenceInJsonRTE); @@ -427,7 +427,7 @@ export const removeEntryRefsFromJSONRTE = (entry: Record, ctSchema: break; } case 'text': { - if (entry[element.uid] && element.field_metadata.rich_text_type) { + if (entry[element.uid] && element?.field_metadata?.rich_text_type) { if (element.multiple) { let rteContent = []; for (let i = 0; i < entry[element.uid].length; i++) { @@ -532,7 +532,7 @@ export const restoreJsonRteEntryRefs = ( break; } case 'json': { - if (entry[element.uid] && element.field_metadata.rich_text_type) { + if (entry[element.uid] && element?.field_metadata?.rich_text_type) { if (element.multiple && Array.isArray(entry[element.uid])) { entry[element.uid] = sourceStackEntry[element.uid].map((jsonRTE: any) => { jsonRTE = restoreReferenceInJsonRTE(jsonRTE, uidMapper); @@ -556,7 +556,7 @@ export const restoreJsonRteEntryRefs = ( break; } case 'text': { - if (entry[element.uid] && element.field_metadata.rich_text_type) { + if (entry[element.uid] && element?.field_metadata?.rich_text_type) { entry[element.uid] = sourceStackEntry[element.uid]; const matches = Object.keys(uidMapper).filter((uid) => { if (sourceStackEntry[element.uid].indexOf(uid) !== -1) return uid; @@ -582,8 +582,7 @@ function updateUids(str: string, match: string, uidMapper: Record uidMapper[matchedString]); + if (status === 'safe') return str.replace(regex, (matchedString) => uidMapper[matchedString]); } function setDirtyTrue(jsonRteChild: any) { diff --git a/packages/contentstack-seed/package.json b/packages/contentstack-seed/package.json index b7fc7bec8d..cebae6f8a6 100644 --- a/packages/contentstack-seed/package.json +++ b/packages/contentstack-seed/package.json @@ -5,7 +5,7 @@ "author": "Contentstack", "bugs": "https://github.com/contentstack/cli/issues", "dependencies": { - "@contentstack/cli-cm-import": "~1.15.6", + "@contentstack/cli-cm-import": "~1.15.7", "@contentstack/cli-command": "~1.2.18", "@contentstack/cli-utilities": "~1.6.2", "inquirer": "8.2.4", @@ -73,4 +73,4 @@ "version": "oclif readme && git add README.md", "clean": "rm -rf ./node_modules tsconfig.build.tsbuildinfo" } -} \ No newline at end of file +} diff --git a/packages/contentstack/package.json b/packages/contentstack/package.json index 75db192359..0167d6398e 100755 --- a/packages/contentstack/package.json +++ b/packages/contentstack/package.json @@ -30,7 +30,7 @@ "@contentstack/cli-cm-export": "~1.11.4", "@contentstack/cli-cm-clone": "~1.10.5", "@contentstack/cli-cm-export-to-csv": "~1.7.1", - "@contentstack/cli-cm-import": "~1.15.6", + "@contentstack/cli-cm-import": "~1.15.7", "@contentstack/cli-cm-migrate-rte": "~1.4.17", "@contentstack/cli-cm-seed": "~1.7.5", "@contentstack/cli-command": "~1.2.18", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f7d93d8382..00f3616b22 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,7 +18,7 @@ importers: '@contentstack/cli-cm-clone': ~1.10.5 '@contentstack/cli-cm-export': ~1.11.4 '@contentstack/cli-cm-export-to-csv': ~1.7.1 - '@contentstack/cli-cm-import': ~1.15.6 + '@contentstack/cli-cm-import': ~1.15.7 '@contentstack/cli-cm-migrate-rte': ~1.4.17 '@contentstack/cli-cm-seed': ~1.7.5 '@contentstack/cli-command': ~1.2.18 @@ -424,7 +424,7 @@ importers: specifiers: '@colors/colors': ^1.5.0 '@contentstack/cli-cm-export': ~1.11.4 - '@contentstack/cli-cm-import': ~1.15.6 + '@contentstack/cli-cm-import': ~1.15.7 '@contentstack/cli-command': ~1.2.18 '@contentstack/cli-utilities': ~1.6.2 '@oclif/test': ^2.5.6 @@ -990,7 +990,7 @@ importers: packages/contentstack-seed: specifiers: - '@contentstack/cli-cm-import': ~1.15.6 + '@contentstack/cli-cm-import': ~1.15.7 '@contentstack/cli-command': ~1.2.18 '@contentstack/cli-utilities': ~1.6.2 '@oclif/plugin-help': ^5.1.19