Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/contentstack-config/src/utils/region-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const regions = {
name: 'NA',
'developerHubUrl': 'https://developerhub-api.contentstack.com',
'launchHubUrl': 'https://launch-api.contentstack.com',
'personalizeUrl': 'https://personalization-api.contentstack.com',
'personalizeUrl': 'https://personalize-api.contentstack.com',
},
EU: {
cma: 'https://eu-api.contentstack.com',
Expand All @@ -33,7 +33,7 @@ const regions = {
name: 'EU',
'developerHubUrl': 'https://eu-developerhub-api.contentstack.com',
'launchHubUrl': 'https://eu-launch-api.contentstack.com',
'personalizeUrl': 'Not available',
'personalizeUrl': 'https://eu-personalize-api.contentstack.com',
},
'AZURE-NA': {
cma: 'https://azure-na-api.contentstack.com',
Expand All @@ -42,7 +42,7 @@ const regions = {
name: 'AZURE-NA',
'developerHubUrl': 'https://azure-na-developerhub-api.contentstack.com',
'launchHubUrl': 'https://azure-na-launch-api.contentstack.com',
'personalizeUrl': 'Not available',
'personalizeUrl': 'https://azure-na-personalize-api.contentstack.com',
},
'AZURE-EU': {
cma: 'https://azure-eu-api.contentstack.com',
Expand All @@ -51,7 +51,7 @@ const regions = {
name: 'AZURE-EU',
'developerHubUrl': 'https://azure-eu-developerhub-api.contentstack.com',
'launchHubUrl': 'https://azure-eu-launch-api.contentstack.com',
'personalizeUrl': 'Not available',
'personalizeUrl': 'https://azure-eu-personalize-api.contentstack.com',
},
'GCP-NA': {
cma: 'https://gcp-na-api.contentstack.com',
Expand All @@ -60,7 +60,7 @@ const regions = {
name: 'GCP-NA',
'developerHubUrl': 'https://gcp-na-developerhub-api.contentstack.com',
'launchHubUrl': 'Not available',
'personalizeUrl': 'Not available',
'personalizeUrl': 'https://gcp-na-personalize-api.contentstack.com',
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default class ExportCommand extends Command {
exportConfig.host = this.cmaHost;
exportConfig.region = this.region;
exportConfig.developerHubBaseUrl = this.developerHubUrl;
exportConfig.modules.personalize.baseURL[exportConfig.region.name] = this.personalizeUrl;
if (this.personalizeUrl) exportConfig.modules.personalize.baseURL[exportConfig.region.name] = this.personalizeUrl;
exportDir = exportConfig.cliLogsPath || exportConfig.data || exportConfig.exportDir;
const managementAPIClient: ContentstackClient = await managementSDKClient(exportConfig);
const moduleExporter = new ModuleExporter(managementAPIClient, exportConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default class ImportCommand extends Command {
importConfig.host = this.cmaHost;
importConfig.region = this.region;
importConfig.developerHubBaseUrl = this.developerHubUrl;
importConfig.modules.personalize.baseURL[importConfig.region.name] = this.personalizeUrl;
if (this.personalizeUrl) importConfig.modules.personalize.baseURL[importConfig.region.name] = this.personalizeUrl;
backupDir = importConfig.cliLogsPath || importConfig.backupDir;

const managementAPIClient: ContentstackClient = await managementSDKClient(importConfig);
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const config: DefaultConfig = {
},
personalize: {
baseURL: {
NA: 'https://personalization-api.contentstack.com',
NA: 'https://personalize-api.contentstack.com',
},
importData: true,
dirName: 'personalize',
Expand Down
4 changes: 4 additions & 0 deletions packages/contentstack-variants/src/import/attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export default class Attribute extends PersonalizationAdapter<ImportConfig> {

for (const attribute of attributes) {
const { key, name, description, uid } = attribute;
// skip creating preset attributes, as they are already present in the system
if (attribute.__type === 'PRESET') {
continue;
}
try {
const attributeRes = await this.createAttribute({ key, name, description });
//map old attribute uid to new attribute uid
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-variants/src/import/experiences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
Object.entries(this.experiencesUidMapper).map(async ([oldExpUid, newExpUid]) => {
if (experienceCTsMap[oldExpUid]?.length) {
// Filter content types that were created
const updatedContentTypes = experienceCTsMap[oldExpUid].filter((ct: any) =>
this.createdCTs.includes(ct?.uid),
const updatedContentTypes = experienceCTsMap[oldExpUid].filter(
(ct: any) => this.createdCTs.includes(ct?.uid) && ct.status === 'linked',
);
if (updatedContentTypes?.length) {
const { variant_groups: [variantGroup] = [] } =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
reject: onReject.bind(this),
resolve: onSuccess.bind(this),
log: log,
variantEntryUID: newVariantUid,
variantUid: newVariantUid,
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const lookUpAudiences = (
} else if (experience.variants) {
for (let index = experience.variants.length - 1; index >= 0; index--) {
const expVariations = experience.variants[index];
if (expVariations['__type'] === 'AudienceBasedVariation' && expVariations?.audiences?.length) {
if (expVariations['__type'] === 'SegmentedVariant' && expVariations?.audiences?.length) {
updateAudiences(expVariations.audiences, audiencesUid);
if (!expVariations.audiences.length) {
experience.variants.splice(index, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
});

try {
this.apiClient.headers({ api_version: undefined });
const res = await this.apiClient.put<VariantEntryStruct>(endpoint, { entry: input });
const data = this.handleVariantAPIRes(res);

Expand Down Expand Up @@ -214,8 +215,7 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
const { entry_uid, content_type_uid } = options;
let endpoint = `content_types/${content_type_uid}/entries/${entry_uid}/publish`;

const onSuccess = (response: any) =>
resolve({ response, apiData: { entryUid: entry_uid, variantUid }, log });
const onSuccess = (response: any) => resolve({ response, apiData: { entryUid: entry_uid, variantUid }, log });
const onReject = (error: any) =>
reject({
error,
Expand Down