From 6adfef7c525b2e3a6793555ecda2ed67f941f613 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Fri, 24 May 2024 17:41:33 +0530 Subject: [PATCH 1/4] added variant success file --- packages/contentstack-export/src/config/index.ts | 2 +- packages/contentstack-import/src/config/index.ts | 2 +- .../src/import/variant-entries.ts | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/contentstack-export/src/config/index.ts b/packages/contentstack-export/src/config/index.ts index d6e23f4c7d..f880a3da26 100644 --- a/packages/contentstack-export/src/config/index.ts +++ b/packages/contentstack-export/src/config/index.ts @@ -146,7 +146,7 @@ const config: DefaultConfig = { }, personalization: { baseURL: { - NA: 'https://personalization-api.contentstack.com', + dev11: 'https://dev-personalization-api.csnonprod.com', }, dirName: 'personalization', exportOrder: ['attributes', 'audiences', 'events', 'experiences'], diff --git a/packages/contentstack-import/src/config/index.ts b/packages/contentstack-import/src/config/index.ts index 37ab06b5ca..e6dab761b3 100644 --- a/packages/contentstack-import/src/config/index.ts +++ b/packages/contentstack-import/src/config/index.ts @@ -153,7 +153,7 @@ const config: DefaultConfig = { }, personalization: { baseURL: { - NA: 'https://personalization-api.contentstack.com', + dev11: 'https://dev-personalization-api.csnonprod.com', }, importData: true, dirName: 'personalization', diff --git a/packages/contentstack-variants/src/import/variant-entries.ts b/packages/contentstack-variants/src/import/variant-entries.ts index 6f446017f1..09d50af3dd 100644 --- a/packages/contentstack-variants/src/import/variant-entries.ts +++ b/packages/contentstack-variants/src/import/variant-entries.ts @@ -36,7 +36,8 @@ export default class VariantEntries extends VariantAdapter; public entriesUidMapper!: Record; private installedExtensions!: Record[]; - private variantUidMapperPath!: string; + private variantSuccessPath!: string; + private createdVariantEntries: Record = {}; private environments!: Record; constructor(readonly config: ImportConfig & { helpers?: ImportHelperMethodsConfig }) { @@ -57,6 +58,7 @@ export default class VariantEntries extends VariantAdapter { log(this.config, `Created variant entry: '${variantUid}' of entry uid ${entryUid}`, 'info'); + this.createdVariantEntries[entryUid] = variantUid; }; const onReject = ({ error, apiData: { entryUid, variantUid }, log }: any) => { @@ -236,6 +239,8 @@ export default class VariantEntries extends VariantAdapter Date: Fri, 24 May 2024 17:44:18 +0530 Subject: [PATCH 2/4] revert dev url --- packages/contentstack-export/src/config/index.ts | 2 +- packages/contentstack-import/src/config/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/contentstack-export/src/config/index.ts b/packages/contentstack-export/src/config/index.ts index f880a3da26..d6e23f4c7d 100644 --- a/packages/contentstack-export/src/config/index.ts +++ b/packages/contentstack-export/src/config/index.ts @@ -146,7 +146,7 @@ const config: DefaultConfig = { }, personalization: { baseURL: { - dev11: 'https://dev-personalization-api.csnonprod.com', + NA: 'https://personalization-api.contentstack.com', }, dirName: 'personalization', exportOrder: ['attributes', 'audiences', 'events', 'experiences'], diff --git a/packages/contentstack-import/src/config/index.ts b/packages/contentstack-import/src/config/index.ts index e6dab761b3..37ab06b5ca 100644 --- a/packages/contentstack-import/src/config/index.ts +++ b/packages/contentstack-import/src/config/index.ts @@ -153,7 +153,7 @@ const config: DefaultConfig = { }, personalization: { baseURL: { - dev11: 'https://dev-personalization-api.csnonprod.com', + NA: 'https://personalization-api.contentstack.com', }, importData: true, dirName: 'personalization', From 2da78b53540cb2a2db853d36d31ceb3ecdc31068 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Mon, 27 May 2024 19:17:03 +0530 Subject: [PATCH 3/4] handle failed entry variant case --- .../src/import/variant-entries.ts | 54 ++++++++++--------- .../src/messages/index.ts | 1 + .../src/utils/variant-api-adapter.ts | 2 +- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/packages/contentstack-variants/src/import/variant-entries.ts b/packages/contentstack-variants/src/import/variant-entries.ts index 09d50af3dd..16cce99b41 100644 --- a/packages/contentstack-variants/src/import/variant-entries.ts +++ b/packages/contentstack-variants/src/import/variant-entries.ts @@ -36,8 +36,8 @@ export default class VariantEntries extends VariantAdapter; public entriesUidMapper!: Record; private installedExtensions!: Record[]; - private variantSuccessPath!: string; - private createdVariantEntries: Record = {}; + private failedVariantPath!: string; + private failedVariantEntries!: Record; private environments!: Record; constructor(readonly config: ImportConfig & { helpers?: ImportHelperMethodsConfig }) { @@ -58,7 +58,8 @@ export default class VariantEntries extends VariantAdapter { - log(this.config, `Created variant entry: '${variantUid}' of entry uid ${entryUid}`, 'info'); - this.createdVariantEntries[entryUid] = variantUid; + log(this.config, `Created entry variant: '${variantUid}' of entry uid ${entryUid}`, 'info'); }; - const onReject = ({ error, apiData: { entryUid, variantUid }, log }: any) => { - log(this.config, `Failed to create variant entry: '${variantUid}' of entry uid ${entryUid}`, 'error'); + const onReject = ({ error, apiData, log }: any) => { + const { entryUid, variantUid } = apiData; + this.failedVariantEntries.set(variantUid, apiData); + log(this.config, `Failed to create entry variant: '${variantUid}' of entry uid ${entryUid}`, 'error'); log(this.config, error, 'error'); }; // NOTE Find new variant Id by old Id @@ -220,7 +222,7 @@ export default class VariantEntries extends VariantAdapter { - log(this.config, `Variant entry: '${variantUid}' of entry uid ${entryUid} published successfully!`, 'info'); + log(this.config, `Entry variant: '${variantUid}' of entry uid ${entryUid} published successfully!`, 'info'); }; const onReject = ({ error, apiData: { entryUid, variantUid }, log }: any) => { - log(this.config, `Failed to publish variant entry: '${variantUid}' of entry uid ${entryUid}`, 'error'); + log(this.config, `Failed to publish entry variant: '${variantUid}' of entry uid ${entryUid}`, 'error'); log(this.config, error, 'error'); }; @@ -396,7 +402,7 @@ export default class VariantEntries extends VariantAdapter extends AdapterHelper implement const errorMsg = data?.errors ? formatErrors(data.errors) - : data?.error_message || data?.message || 'Something went wrong while processing variant entries request!'; + : data?.error_message || data?.message || 'Something went wrong while processing entry variant request!'; throw errorMsg; } From 2de74647f8c9e8e3d8296bd0cfcb4827e104b4fd Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Mon, 27 May 2024 20:01:23 +0530 Subject: [PATCH 4/4] added variant uid in publish logger msg --- .../contentstack-variants/src/import/variant-entries.ts | 1 + .../contentstack-variants/src/utils/variant-api-adapter.ts | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/contentstack-variants/src/import/variant-entries.ts b/packages/contentstack-variants/src/import/variant-entries.ts index 16cce99b41..97d8feb695 100644 --- a/packages/contentstack-variants/src/import/variant-entries.ts +++ b/packages/contentstack-variants/src/import/variant-entries.ts @@ -392,6 +392,7 @@ export default class VariantEntries extends VariantAdapter extends AdapterHelper implement options: PublishVariantEntryOptions, apiParams: Record, ) { - const { reject, resolve, log } = apiParams; + const { reject, resolve, log, variantUid } = apiParams; 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: input.entry.variants[0].uid }, log }); + resolve({ response, apiData: { entryUid: entry_uid, variantUid }, log }); const onReject = (error: any) => reject({ error, - apiData: { entryUid: entry_uid, variantUid: input.entry.variants[0].uid }, + apiData: { entryUid: entry_uid, variantUid }, log, });