@contentstack/cli-variants 0.0.1-alpha → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/export/attributes.d.ts +2 -2
- package/lib/export/attributes.js +3 -3
- package/lib/export/audiences.d.ts +2 -2
- package/lib/export/audiences.js +3 -3
- package/lib/export/events.d.ts +2 -2
- package/lib/export/events.js +3 -3
- package/lib/export/experiences.d.ts +2 -2
- package/lib/export/experiences.js +17 -3
- package/lib/export/projects.d.ts +2 -2
- package/lib/export/projects.js +7 -5
- package/lib/import/attribute.d.ts +1 -1
- package/lib/import/attribute.js +20 -10
- package/lib/import/audiences.d.ts +2 -2
- package/lib/import/audiences.js +20 -14
- package/lib/import/events.d.ts +1 -1
- package/lib/import/events.js +14 -8
- package/lib/import/experiences.d.ts +12 -5
- package/lib/import/experiences.js +84 -20
- package/lib/import/project.js +10 -10
- package/lib/import/variant-entries.d.ts +1 -1
- package/lib/import/variant-entries.js +13 -13
- package/lib/messages/index.d.ts +1 -1
- package/lib/messages/index.js +3 -2
- package/lib/types/export-config.d.ts +3 -3
- package/lib/types/import-config.d.ts +1 -1
- package/lib/types/personalization-api-adapter.d.ts +13 -0
- package/lib/types/variant-entry.d.ts +2 -2
- package/lib/utils/audiences-helper.js +14 -3
- package/lib/utils/error-helper.js +1 -1
- package/lib/utils/personalization-api-adapter.d.ts +4 -1
- package/lib/utils/personalization-api-adapter.js +40 -1
- package/lib/utils/variant-api-adapter.js +1 -0
- package/package.json +1 -1
- package/src/export/attributes.ts +5 -5
- package/src/export/audiences.ts +5 -5
- package/src/export/events.ts +5 -5
- package/src/export/experiences.ts +21 -5
- package/src/export/projects.ts +9 -7
- package/src/import/attribute.ts +30 -12
- package/src/import/audiences.ts +36 -18
- package/src/import/events.ts +24 -10
- package/src/import/experiences.ts +118 -28
- package/src/import/project.ts +10 -10
- package/src/import/variant-entries.ts +48 -25
- package/src/messages/index.ts +3 -2
- package/src/types/export-config.ts +3 -3
- package/src/types/import-config.ts +1 -1
- package/src/types/personalization-api-adapter.ts +13 -0
- package/src/types/variant-entry.ts +2 -2
- package/src/utils/audiences-helper.ts +12 -2
- package/src/utils/error-helper.ts +1 -1
- package/src/utils/personalization-api-adapter.ts +32 -2
- package/src/utils/variant-api-adapter.ts +2 -2
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PersonalizationAdapter } from '../utils';
|
|
2
|
-
import {
|
|
2
|
+
import { PersonalizeConfig, ExportConfig } from '../types';
|
|
3
3
|
export default class ExportAttributes extends PersonalizationAdapter<ExportConfig> {
|
|
4
4
|
readonly exportConfig: ExportConfig;
|
|
5
5
|
private attributesConfig;
|
|
6
6
|
private attributesFolderPath;
|
|
7
7
|
private attributes;
|
|
8
|
-
|
|
8
|
+
personalizeConfig: PersonalizeConfig;
|
|
9
9
|
constructor(exportConfig: ExportConfig);
|
|
10
10
|
start(): Promise<void>;
|
|
11
11
|
/**
|
package/lib/export/attributes.js
CHANGED
|
@@ -20,13 +20,13 @@ class ExportAttributes extends utils_1.PersonalizationAdapter {
|
|
|
20
20
|
constructor(exportConfig) {
|
|
21
21
|
super({
|
|
22
22
|
config: exportConfig,
|
|
23
|
-
baseURL: exportConfig.modules.
|
|
23
|
+
baseURL: exportConfig.modules.personalize.baseURL[exportConfig.region.name],
|
|
24
24
|
headers: { authtoken: exportConfig.auth_token, 'X-Project-Uid': exportConfig.project_id },
|
|
25
25
|
});
|
|
26
26
|
this.exportConfig = exportConfig;
|
|
27
|
-
this.
|
|
27
|
+
this.personalizeConfig = exportConfig.modules.personalize;
|
|
28
28
|
this.attributesConfig = exportConfig.modules.attributes;
|
|
29
|
-
this.attributesFolderPath = (0, node_path_1.resolve)((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.
|
|
29
|
+
this.attributesFolderPath = (0, node_path_1.resolve)((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(this.attributesConfig.dirName));
|
|
30
30
|
this.attributes = [];
|
|
31
31
|
}
|
|
32
32
|
start() {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PersonalizationAdapter } from '../utils';
|
|
2
|
-
import {
|
|
2
|
+
import { PersonalizeConfig, ExportConfig } from '../types';
|
|
3
3
|
export default class ExportAudiences extends PersonalizationAdapter<ExportConfig> {
|
|
4
4
|
readonly exportConfig: ExportConfig;
|
|
5
5
|
private audiencesConfig;
|
|
6
6
|
private audiencesFolderPath;
|
|
7
7
|
private audiences;
|
|
8
|
-
|
|
8
|
+
personalizeConfig: PersonalizeConfig;
|
|
9
9
|
constructor(exportConfig: ExportConfig);
|
|
10
10
|
start(): Promise<void>;
|
|
11
11
|
/**
|
package/lib/export/audiences.js
CHANGED
|
@@ -19,13 +19,13 @@ class ExportAudiences extends utils_1.PersonalizationAdapter {
|
|
|
19
19
|
constructor(exportConfig) {
|
|
20
20
|
super({
|
|
21
21
|
config: exportConfig,
|
|
22
|
-
baseURL: exportConfig.modules.
|
|
22
|
+
baseURL: exportConfig.modules.personalize.baseURL[exportConfig.region.name],
|
|
23
23
|
headers: { authtoken: exportConfig.auth_token, 'X-Project-Uid': exportConfig.project_id },
|
|
24
24
|
});
|
|
25
25
|
this.exportConfig = exportConfig;
|
|
26
|
-
this.
|
|
26
|
+
this.personalizeConfig = exportConfig.modules.personalize;
|
|
27
27
|
this.audiencesConfig = exportConfig.modules.audiences;
|
|
28
|
-
this.audiencesFolderPath = (0, node_path_1.resolve)(exportConfig.data, exportConfig.branchName || '', this.
|
|
28
|
+
this.audiencesFolderPath = (0, node_path_1.resolve)(exportConfig.data, exportConfig.branchName || '', this.personalizeConfig.dirName, this.audiencesConfig.dirName);
|
|
29
29
|
this.audiences = [];
|
|
30
30
|
}
|
|
31
31
|
start() {
|
package/lib/export/events.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PersonalizationAdapter } from '../utils';
|
|
2
|
-
import {
|
|
2
|
+
import { PersonalizeConfig, ExportConfig } from '../types';
|
|
3
3
|
export default class ExportEvents extends PersonalizationAdapter<ExportConfig> {
|
|
4
4
|
readonly exportConfig: ExportConfig;
|
|
5
5
|
private eventsConfig;
|
|
6
6
|
private eventsFolderPath;
|
|
7
7
|
private events;
|
|
8
|
-
|
|
8
|
+
personalizeConfig: PersonalizeConfig;
|
|
9
9
|
constructor(exportConfig: ExportConfig);
|
|
10
10
|
start(): Promise<void>;
|
|
11
11
|
/**
|
package/lib/export/events.js
CHANGED
|
@@ -19,13 +19,13 @@ class ExportEvents extends utils_1.PersonalizationAdapter {
|
|
|
19
19
|
constructor(exportConfig) {
|
|
20
20
|
super({
|
|
21
21
|
config: exportConfig,
|
|
22
|
-
baseURL: exportConfig.modules.
|
|
22
|
+
baseURL: exportConfig.modules.personalize.baseURL[exportConfig.region.name],
|
|
23
23
|
headers: { authtoken: exportConfig.auth_token, 'X-Project-Uid': exportConfig.project_id },
|
|
24
24
|
});
|
|
25
25
|
this.exportConfig = exportConfig;
|
|
26
|
-
this.
|
|
26
|
+
this.personalizeConfig = exportConfig.modules.personalize;
|
|
27
27
|
this.eventsConfig = exportConfig.modules.events;
|
|
28
|
-
this.eventsFolderPath = (0, node_path_1.resolve)(exportConfig.data, exportConfig.branchName || '', this.
|
|
28
|
+
this.eventsFolderPath = (0, node_path_1.resolve)(exportConfig.data, exportConfig.branchName || '', this.personalizeConfig.dirName, this.eventsConfig.dirName);
|
|
29
29
|
this.events = [];
|
|
30
30
|
}
|
|
31
31
|
start() {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PersonalizeConfig, ExportConfig } from '../types';
|
|
2
2
|
import { PersonalizationAdapter } from '../utils';
|
|
3
3
|
export default class ExportExperiences extends PersonalizationAdapter<ExportConfig> {
|
|
4
4
|
private experiencesFolderPath;
|
|
5
5
|
exportConfig: ExportConfig;
|
|
6
|
-
|
|
6
|
+
personalizeConfig: PersonalizeConfig;
|
|
7
7
|
constructor(exportConfig: ExportConfig);
|
|
8
8
|
start(): Promise<void>;
|
|
9
9
|
}
|
|
@@ -39,7 +39,7 @@ class ExportExperiences extends utils_1.PersonalizationAdapter {
|
|
|
39
39
|
constructor(exportConfig) {
|
|
40
40
|
super({
|
|
41
41
|
config: exportConfig,
|
|
42
|
-
baseURL: exportConfig.modules.
|
|
42
|
+
baseURL: exportConfig.modules.personalize.baseURL[exportConfig.region.name],
|
|
43
43
|
headers: { authtoken: exportConfig.auth_token, 'X-Project-Uid': exportConfig.project_id },
|
|
44
44
|
cmaConfig: {
|
|
45
45
|
baseURL: exportConfig.region.cma + `/v3`,
|
|
@@ -47,8 +47,8 @@ class ExportExperiences extends utils_1.PersonalizationAdapter {
|
|
|
47
47
|
},
|
|
48
48
|
});
|
|
49
49
|
this.exportConfig = exportConfig;
|
|
50
|
-
this.
|
|
51
|
-
this.experiencesFolderPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.
|
|
50
|
+
this.personalizeConfig = exportConfig.modules.personalize;
|
|
51
|
+
this.experiencesFolderPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), 'experiences');
|
|
52
52
|
}
|
|
53
53
|
start() {
|
|
54
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -59,6 +59,7 @@ class ExportExperiences extends utils_1.PersonalizationAdapter {
|
|
|
59
59
|
// write experiences in to a file
|
|
60
60
|
(0, utils_1.log)(this.exportConfig, 'Starting experiences export', 'info');
|
|
61
61
|
yield utils_1.fsUtil.makeDirectory(this.experiencesFolderPath);
|
|
62
|
+
yield utils_1.fsUtil.makeDirectory(path.resolve((0, cli_utilities_1.sanitizePath)(this.experiencesFolderPath), 'versions'));
|
|
62
63
|
const experiences = (yield this.getExperiences()) || [];
|
|
63
64
|
if (!experiences || (experiences === null || experiences === void 0 ? void 0 : experiences.length) < 1) {
|
|
64
65
|
(0, utils_1.log)(this.exportConfig, 'No Experiences found with the give project', 'info');
|
|
@@ -74,6 +75,19 @@ class ExportExperiences extends utils_1.PersonalizationAdapter {
|
|
|
74
75
|
const experienceToVariantsStr = `${experience.uid}-${variantShortId}-${variants[variantShortId]}`;
|
|
75
76
|
experienceToVariantsStrList.push(experienceToVariantsStr);
|
|
76
77
|
});
|
|
78
|
+
try {
|
|
79
|
+
// fetch versions of experience
|
|
80
|
+
const experienceVersions = (yield this.getExperienceVersions(experience.uid)) || [];
|
|
81
|
+
if (experienceVersions.length > 0) {
|
|
82
|
+
utils_1.fsUtil.writeFile(path.resolve((0, cli_utilities_1.sanitizePath)(this.experiencesFolderPath), 'versions', `${experience.uid}.json`), experienceVersions);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
(0, utils_1.log)(this.exportConfig, `No versions found for experience ${experience.name}`, 'info');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
(0, utils_1.log)(this.exportConfig, `Failed to fetch versions of experience ${experience.name}`, 'error');
|
|
90
|
+
}
|
|
77
91
|
try {
|
|
78
92
|
// fetch content of experience
|
|
79
93
|
const { variant_groups: [variantGroup] = [] } = (yield this.getVariantGroup({ experienceUid: experience.uid })) || {};
|
package/lib/export/projects.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ExportConfig,
|
|
1
|
+
import { ExportConfig, PersonalizeConfig } from '../types';
|
|
2
2
|
import { PersonalizationAdapter } from '../utils';
|
|
3
3
|
export default class ExportProjects extends PersonalizationAdapter<ExportConfig> {
|
|
4
4
|
private projectFolderPath;
|
|
5
5
|
exportConfig: ExportConfig;
|
|
6
|
-
|
|
6
|
+
personalizeConfig: PersonalizeConfig;
|
|
7
7
|
constructor(exportConfig: ExportConfig);
|
|
8
8
|
start(): Promise<void>;
|
|
9
9
|
}
|
package/lib/export/projects.js
CHANGED
|
@@ -39,12 +39,12 @@ class ExportProjects extends utils_1.PersonalizationAdapter {
|
|
|
39
39
|
constructor(exportConfig) {
|
|
40
40
|
super({
|
|
41
41
|
config: exportConfig,
|
|
42
|
-
baseURL: exportConfig.modules.
|
|
42
|
+
baseURL: exportConfig.modules.personalize.baseURL[exportConfig.region.name],
|
|
43
43
|
headers: { authtoken: exportConfig.auth_token, organization_uid: exportConfig.org_uid },
|
|
44
44
|
});
|
|
45
45
|
this.exportConfig = exportConfig;
|
|
46
|
-
this.
|
|
47
|
-
this.projectFolderPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.
|
|
46
|
+
this.personalizeConfig = exportConfig.modules.personalize;
|
|
47
|
+
this.projectFolderPath = path.resolve((0, cli_utilities_1.sanitizePath)(exportConfig.data), (0, cli_utilities_1.sanitizePath)(exportConfig.branchName || ''), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), 'projects');
|
|
48
48
|
}
|
|
49
49
|
start() {
|
|
50
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -54,7 +54,7 @@ class ExportProjects extends utils_1.PersonalizationAdapter {
|
|
|
54
54
|
yield utils_1.fsUtil.makeDirectory(this.projectFolderPath);
|
|
55
55
|
const project = yield this.projects({ connectedStackApiKey: this.exportConfig.apiKey });
|
|
56
56
|
if (!project || (project === null || project === void 0 ? void 0 : project.length) < 1) {
|
|
57
|
-
(0, utils_1.log)(this.exportConfig, 'No
|
|
57
|
+
(0, utils_1.log)(this.exportConfig, 'No Personalize Project connected with the given stack', 'info');
|
|
58
58
|
this.exportConfig.personalizationEnabled = false;
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
@@ -64,7 +64,9 @@ class ExportProjects extends utils_1.PersonalizationAdapter {
|
|
|
64
64
|
(0, utils_1.log)(this.exportConfig, 'Project exported successfully!', 'success');
|
|
65
65
|
}
|
|
66
66
|
catch (error) {
|
|
67
|
-
|
|
67
|
+
if (error !== 'Forbidden') {
|
|
68
|
+
(0, utils_1.log)(this.exportConfig, `Failed to export projects!`, 'error');
|
|
69
|
+
}
|
|
68
70
|
throw error;
|
|
69
71
|
}
|
|
70
72
|
});
|
|
@@ -7,7 +7,7 @@ export default class Attribute extends PersonalizationAdapter<ImportConfig> {
|
|
|
7
7
|
private attrMapperDirPath;
|
|
8
8
|
private attributesUidMapperPath;
|
|
9
9
|
private attributesUidMapper;
|
|
10
|
-
private
|
|
10
|
+
private personalizeConfig;
|
|
11
11
|
private attributeConfig;
|
|
12
12
|
constructor(config: ImportConfig, log?: LogType);
|
|
13
13
|
/**
|
package/lib/import/attribute.js
CHANGED
|
@@ -17,15 +17,15 @@ class Attribute extends utils_1.PersonalizationAdapter {
|
|
|
17
17
|
constructor(config, log = console.log) {
|
|
18
18
|
const conf = {
|
|
19
19
|
config,
|
|
20
|
-
baseURL: config.modules.
|
|
21
|
-
headers: { 'X-Project-Uid': config.modules.
|
|
20
|
+
baseURL: config.modules.personalize.baseURL[config.region.name],
|
|
21
|
+
headers: { 'X-Project-Uid': config.modules.personalize.project_id, authtoken: config.auth_token },
|
|
22
22
|
};
|
|
23
23
|
super(Object.assign(config, conf));
|
|
24
24
|
this.config = config;
|
|
25
25
|
this.log = log;
|
|
26
|
-
this.
|
|
27
|
-
this.attributeConfig = this.
|
|
28
|
-
this.mapperDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.backupDir), 'mapper', (0, cli_utilities_1.sanitizePath)(this.
|
|
26
|
+
this.personalizeConfig = this.config.modules.personalize;
|
|
27
|
+
this.attributeConfig = this.personalizeConfig.attributes;
|
|
28
|
+
this.mapperDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.backupDir), 'mapper', (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName));
|
|
29
29
|
this.attrMapperDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.mapperDirPath), (0, cli_utilities_1.sanitizePath)(this.attributeConfig.dirName));
|
|
30
30
|
this.attributesUidMapperPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.attrMapperDirPath), 'uid-mapping.json');
|
|
31
31
|
this.attributesUidMapper = {};
|
|
@@ -39,16 +39,26 @@ class Attribute extends utils_1.PersonalizationAdapter {
|
|
|
39
39
|
this.log(this.config, this.$t(this.messages.IMPORT_MSG, { module: 'Attributes' }), 'info');
|
|
40
40
|
yield utils_1.fsUtil.makeDirectory(this.attrMapperDirPath);
|
|
41
41
|
const { dirName, fileName } = this.attributeConfig;
|
|
42
|
-
const attributesPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.data), (0, cli_utilities_1.sanitizePath)(this.
|
|
42
|
+
const attributesPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.data), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(dirName), (0, cli_utilities_1.sanitizePath)(fileName));
|
|
43
43
|
if ((0, fs_1.existsSync)(attributesPath)) {
|
|
44
44
|
try {
|
|
45
45
|
const attributes = utils_1.fsUtil.readFile(attributesPath, true);
|
|
46
46
|
for (const attribute of attributes) {
|
|
47
47
|
const { key, name, description, uid } = attribute;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
// skip creating preset attributes, as they are already present in the system
|
|
49
|
+
if (attribute.__type === 'PRESET') {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const attributeRes = yield this.createAttribute({ key, name, description });
|
|
54
|
+
//map old attribute uid to new attribute uid
|
|
55
|
+
//mapper file is used to check whether attribute created or not before creating audience
|
|
56
|
+
this.attributesUidMapper[uid] = (_a = attributeRes === null || attributeRes === void 0 ? void 0 : attributeRes.uid) !== null && _a !== void 0 ? _a : '';
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
this.log(this.config, `Failed to create attribute ${name}!`, 'error');
|
|
60
|
+
this.log(this.config, error, 'error');
|
|
61
|
+
}
|
|
52
62
|
}
|
|
53
63
|
utils_1.fsUtil.writeFile(this.attributesUidMapperPath, this.attributesUidMapper);
|
|
54
64
|
this.log(this.config, this.$t(this.messages.CREATE_SUCCESS, { module: 'Attributes' }), 'info');
|
|
@@ -8,9 +8,9 @@ export default class Audiences extends PersonalizationAdapter<ImportConfig> {
|
|
|
8
8
|
private attributesMapperPath;
|
|
9
9
|
private audiencesUidMapperPath;
|
|
10
10
|
private audiencesUidMapper;
|
|
11
|
-
private
|
|
11
|
+
private personalizeConfig;
|
|
12
12
|
private audienceConfig;
|
|
13
|
-
attributeConfig: ImportConfig['modules']['
|
|
13
|
+
attributeConfig: ImportConfig['modules']['personalize']['attributes'];
|
|
14
14
|
constructor(config: ImportConfig, log?: LogType);
|
|
15
15
|
/**
|
|
16
16
|
* The function asynchronously imports audiences from a JSON file and creates them in the system.
|
package/lib/import/audiences.js
CHANGED
|
@@ -17,16 +17,16 @@ class Audiences extends utils_1.PersonalizationAdapter {
|
|
|
17
17
|
constructor(config, log = console.log) {
|
|
18
18
|
const conf = {
|
|
19
19
|
config,
|
|
20
|
-
baseURL: config.modules.
|
|
21
|
-
headers: { 'X-Project-Uid': config.modules.
|
|
20
|
+
baseURL: config.modules.personalize.baseURL[config.region.name],
|
|
21
|
+
headers: { 'X-Project-Uid': config.modules.personalize.project_id, authtoken: config.auth_token },
|
|
22
22
|
};
|
|
23
23
|
super(Object.assign(config, conf));
|
|
24
24
|
this.config = config;
|
|
25
25
|
this.log = log;
|
|
26
|
-
this.
|
|
27
|
-
this.audienceConfig = this.
|
|
28
|
-
this.attributeConfig = this.
|
|
29
|
-
this.mapperDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.backupDir), 'mapper', (0, cli_utilities_1.sanitizePath)(this.
|
|
26
|
+
this.personalizeConfig = this.config.modules.personalize;
|
|
27
|
+
this.audienceConfig = this.personalizeConfig.audiences;
|
|
28
|
+
this.attributeConfig = this.personalizeConfig.attributes;
|
|
29
|
+
this.mapperDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.backupDir), 'mapper', (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName));
|
|
30
30
|
this.audienceMapperDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.mapperDirPath), (0, cli_utilities_1.sanitizePath)(this.audienceConfig.dirName));
|
|
31
31
|
this.audiencesUidMapperPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.audienceMapperDirPath), 'uid-mapping.json');
|
|
32
32
|
this.attributesMapperPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.mapperDirPath), (0, cli_utilities_1.sanitizePath)(this.attributeConfig.dirName), 'uid-mapping.json');
|
|
@@ -41,21 +41,27 @@ class Audiences extends utils_1.PersonalizationAdapter {
|
|
|
41
41
|
this.log(this.config, this.$t(this.messages.IMPORT_MSG, { module: 'Audiences' }), 'info');
|
|
42
42
|
yield utils_1.fsUtil.makeDirectory(this.audienceMapperDirPath);
|
|
43
43
|
const { dirName, fileName } = this.audienceConfig;
|
|
44
|
-
const audiencesPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.data), (0, cli_utilities_1.sanitizePath)(this.
|
|
44
|
+
const audiencesPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.data), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(dirName), (0, cli_utilities_1.sanitizePath)(fileName));
|
|
45
45
|
if ((0, fs_1.existsSync)(audiencesPath)) {
|
|
46
46
|
try {
|
|
47
47
|
const audiences = utils_1.fsUtil.readFile(audiencesPath, true);
|
|
48
48
|
const attributesUid = utils_1.fsUtil.readFile(this.attributesMapperPath, true) || {};
|
|
49
49
|
for (const audience of audiences) {
|
|
50
50
|
let { name, definition, description, uid } = audience;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
definition.rules
|
|
51
|
+
try {
|
|
52
|
+
//check whether reference attributes exists or not
|
|
53
|
+
if ((_a = definition.rules) === null || _a === void 0 ? void 0 : _a.length) {
|
|
54
|
+
definition.rules = (0, utils_1.lookUpAttributes)(definition.rules, attributesUid);
|
|
55
|
+
}
|
|
56
|
+
const audienceRes = yield this.createAudience({ definition, name, description });
|
|
57
|
+
//map old audience uid to new audience uid
|
|
58
|
+
//mapper file is used to check whether audience created or not before creating experience
|
|
59
|
+
this.audiencesUidMapper[uid] = (_b = audienceRes === null || audienceRes === void 0 ? void 0 : audienceRes.uid) !== null && _b !== void 0 ? _b : '';
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
this.log(this.config, `Failed to create audience uid: ${uid}, name: ${name}`, 'error');
|
|
63
|
+
this.log(this.config, error, 'error');
|
|
54
64
|
}
|
|
55
|
-
const audienceRes = yield this.createAudience({ definition, name, description });
|
|
56
|
-
//map old audience uid to new audience uid
|
|
57
|
-
//mapper file is used to check whether audience created or not before creating experience
|
|
58
|
-
this.audiencesUidMapper[uid] = (_b = audienceRes === null || audienceRes === void 0 ? void 0 : audienceRes.uid) !== null && _b !== void 0 ? _b : '';
|
|
59
65
|
}
|
|
60
66
|
utils_1.fsUtil.writeFile(this.audiencesUidMapperPath, this.audiencesUidMapper);
|
|
61
67
|
this.log(this.config, this.$t(this.messages.CREATE_SUCCESS, { module: 'Audiences' }), 'info');
|
package/lib/import/events.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export default class Events extends PersonalizationAdapter<ImportConfig> {
|
|
|
7
7
|
private eventMapperDirPath;
|
|
8
8
|
private eventsUidMapperPath;
|
|
9
9
|
private eventsUidMapper;
|
|
10
|
-
private
|
|
10
|
+
private personalizeConfig;
|
|
11
11
|
private eventsConfig;
|
|
12
12
|
constructor(config: ImportConfig, log?: LogType);
|
|
13
13
|
/**
|
package/lib/import/events.js
CHANGED
|
@@ -17,15 +17,15 @@ class Events extends utils_1.PersonalizationAdapter {
|
|
|
17
17
|
constructor(config, log = console.log) {
|
|
18
18
|
const conf = {
|
|
19
19
|
config,
|
|
20
|
-
baseURL: config.modules.
|
|
21
|
-
headers: { 'X-Project-Uid': config.modules.
|
|
20
|
+
baseURL: config.modules.personalize.baseURL[config.region.name],
|
|
21
|
+
headers: { 'X-Project-Uid': config.modules.personalize.project_id, authtoken: config.auth_token },
|
|
22
22
|
};
|
|
23
23
|
super(Object.assign(config, conf));
|
|
24
24
|
this.config = config;
|
|
25
25
|
this.log = log;
|
|
26
|
-
this.
|
|
27
|
-
this.eventsConfig = this.
|
|
28
|
-
this.mapperDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.backupDir), 'mapper', (0, cli_utilities_1.sanitizePath)(this.
|
|
26
|
+
this.personalizeConfig = this.config.modules.personalize;
|
|
27
|
+
this.eventsConfig = this.personalizeConfig.events;
|
|
28
|
+
this.mapperDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.backupDir), 'mapper', (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName));
|
|
29
29
|
this.eventMapperDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.mapperDirPath), (0, cli_utilities_1.sanitizePath)(this.eventsConfig.dirName));
|
|
30
30
|
this.eventsUidMapperPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.eventMapperDirPath), 'uid-mapping.json');
|
|
31
31
|
this.eventsUidMapper = {};
|
|
@@ -39,14 +39,20 @@ class Events extends utils_1.PersonalizationAdapter {
|
|
|
39
39
|
this.log(this.config, this.$t(this.messages.IMPORT_MSG, { module: 'Events' }), 'info');
|
|
40
40
|
yield utils_1.fsUtil.makeDirectory(this.eventMapperDirPath);
|
|
41
41
|
const { dirName, fileName } = this.eventsConfig;
|
|
42
|
-
const eventsPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.data), (0, cli_utilities_1.sanitizePath)(this.
|
|
42
|
+
const eventsPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.data), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(dirName), (0, cli_utilities_1.sanitizePath)(fileName));
|
|
43
43
|
if ((0, fs_1.existsSync)(eventsPath)) {
|
|
44
44
|
try {
|
|
45
45
|
const events = utils_1.fsUtil.readFile(eventsPath, true);
|
|
46
46
|
for (const event of events) {
|
|
47
47
|
const { key, description, uid } = event;
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
try {
|
|
49
|
+
const eventsResponse = yield this.createEvents({ key, description });
|
|
50
|
+
this.eventsUidMapper[uid] = (_a = eventsResponse === null || eventsResponse === void 0 ? void 0 : eventsResponse.uid) !== null && _a !== void 0 ? _a : '';
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
this.log(this.config, `failed to create event uid: ${uid}`, 'error');
|
|
54
|
+
this.log(this.config, error, 'error');
|
|
55
|
+
}
|
|
50
56
|
}
|
|
51
57
|
utils_1.fsUtil.writeFile(this.eventsUidMapperPath, this.eventsUidMapper);
|
|
52
58
|
this.log(this.config, this.$t(this.messages.CREATE_SUCCESS, { module: 'Events' }), 'info');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PersonalizationAdapter } from '../utils';
|
|
2
|
-
import { ImportConfig, LogType } from '../types';
|
|
2
|
+
import { ImportConfig, ExperienceStruct, LogType } from '../types';
|
|
3
3
|
export default class Experiences extends PersonalizationAdapter<ImportConfig> {
|
|
4
4
|
readonly config: ImportConfig;
|
|
5
5
|
private readonly log;
|
|
@@ -25,7 +25,9 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
|
|
|
25
25
|
private cmsVariantGroups;
|
|
26
26
|
private experiencesUidMapper;
|
|
27
27
|
private pendingVariantAndVariantGrpForExperience;
|
|
28
|
-
private
|
|
28
|
+
private audiencesUid;
|
|
29
|
+
private eventsUid;
|
|
30
|
+
private personalizeConfig;
|
|
29
31
|
private audienceConfig;
|
|
30
32
|
private experienceConfig;
|
|
31
33
|
constructor(config: ImportConfig, log?: LogType);
|
|
@@ -34,9 +36,14 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
|
|
|
34
36
|
*/
|
|
35
37
|
import(): Promise<void>;
|
|
36
38
|
/**
|
|
37
|
-
* function
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
* function import experience versions from a JSON file and creates them in the project.
|
|
40
|
+
*/
|
|
41
|
+
importExperienceVersions(experience: ExperienceStruct, oldExperienceUid: string): Promise<void>;
|
|
42
|
+
private handleVersionUpdateOrCreate;
|
|
43
|
+
/**
|
|
44
|
+
* function to validate if all variant groups and variants have been created using personalize background job
|
|
45
|
+
* store the variant groups data in mapper/personalize/experiences/cms-variant-groups.json and the variants data
|
|
46
|
+
* in mapper/personalize/experiences/cms-variants.json. If not, invoke validateVariantGroupAndVariantsCreated after some delay.
|
|
40
47
|
* @param retryCount Counter to track the number of times the function has been called
|
|
41
48
|
* @returns
|
|
42
49
|
*/
|
|
@@ -34,8 +34,8 @@ class Experiences extends utils_1.PersonalizationAdapter {
|
|
|
34
34
|
var _a, _b, _c, _d;
|
|
35
35
|
const conf = {
|
|
36
36
|
config,
|
|
37
|
-
baseURL: config.modules.
|
|
38
|
-
headers: { 'X-Project-Uid': config.modules.
|
|
37
|
+
baseURL: config.modules.personalize.baseURL[config.region.name],
|
|
38
|
+
headers: { 'X-Project-Uid': config.modules.personalize.project_id, authtoken: config.auth_token },
|
|
39
39
|
cmaConfig: {
|
|
40
40
|
baseURL: config.region.cma + `/v3`,
|
|
41
41
|
headers: { authtoken: config.auth_token, api_key: config.apiKey },
|
|
@@ -44,12 +44,12 @@ class Experiences extends utils_1.PersonalizationAdapter {
|
|
|
44
44
|
super(Object.assign(config, conf));
|
|
45
45
|
this.config = config;
|
|
46
46
|
this.log = log;
|
|
47
|
-
this.
|
|
48
|
-
this.experiencesDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.data), (0, cli_utilities_1.sanitizePath)(this.
|
|
49
|
-
this.experiencesPath = (0, path_1.join)((0, cli_utilities_1.sanitizePath)(this.experiencesDirPath), (0, cli_utilities_1.sanitizePath)(this.
|
|
50
|
-
this.experienceConfig = this.
|
|
51
|
-
this.audienceConfig = this.
|
|
52
|
-
this.mapperDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.backupDir), 'mapper', (0, cli_utilities_1.sanitizePath)(this.
|
|
47
|
+
this.personalizeConfig = this.config.modules.personalize;
|
|
48
|
+
this.experiencesDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.data), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.experiences.dirName));
|
|
49
|
+
this.experiencesPath = (0, path_1.join)((0, cli_utilities_1.sanitizePath)(this.experiencesDirPath), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.experiences.fileName));
|
|
50
|
+
this.experienceConfig = this.personalizeConfig.experiences;
|
|
51
|
+
this.audienceConfig = this.personalizeConfig.audiences;
|
|
52
|
+
this.mapperDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.backupDir), 'mapper', (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName));
|
|
53
53
|
this.expMapperDirPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.mapperDirPath), (0, cli_utilities_1.sanitizePath)(this.experienceConfig.dirName));
|
|
54
54
|
this.experiencesUidMapperPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.expMapperDirPath), 'uid-mapping.json');
|
|
55
55
|
this.cmsVariantGroupPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.expMapperDirPath), 'cms-variant-groups.json');
|
|
@@ -59,7 +59,7 @@ class Experiences extends utils_1.PersonalizationAdapter {
|
|
|
59
59
|
this.failedCmsExpPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.expMapperDirPath), 'failed-cms-experience.json');
|
|
60
60
|
this.failedCmsExpPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.expMapperDirPath), 'failed-cms-experience.json');
|
|
61
61
|
this.experienceCTsPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.experiencesDirPath), 'experiences-content-types.json');
|
|
62
|
-
this.experienceVariantsIdsPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.data), (0, cli_utilities_1.sanitizePath)(this.
|
|
62
|
+
this.experienceVariantsIdsPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.data), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(this.experienceConfig.dirName), 'experiences-variants-ids.json');
|
|
63
63
|
this.variantUidMapperFilePath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.expMapperDirPath), 'variants-uid-mapping.json');
|
|
64
64
|
this.experiencesUidMapper = {};
|
|
65
65
|
this.cmsVariantGroups = {};
|
|
@@ -70,6 +70,8 @@ class Experiences extends utils_1.PersonalizationAdapter {
|
|
|
70
70
|
this.pendingVariantAndVariantGrpForExperience = [];
|
|
71
71
|
this.cTsSuccessPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.backupDir), 'mapper', 'content_types', 'success.json');
|
|
72
72
|
this.createdCTs = [];
|
|
73
|
+
this.audiencesUid = utils_1.fsUtil.readFile(this.audiencesMapperPath, true) || {};
|
|
74
|
+
this.eventsUid = utils_1.fsUtil.readFile(this.eventsMapperPath, true) || {};
|
|
73
75
|
}
|
|
74
76
|
/**
|
|
75
77
|
* The function asynchronously imports experiences from a JSON file and creates them in the system.
|
|
@@ -82,17 +84,23 @@ class Experiences extends utils_1.PersonalizationAdapter {
|
|
|
82
84
|
if ((0, fs_1.existsSync)(this.experiencesPath)) {
|
|
83
85
|
try {
|
|
84
86
|
const experiences = utils_1.fsUtil.readFile(this.experiencesPath, true);
|
|
85
|
-
const audiencesUid = utils_1.fsUtil.readFile(this.audiencesMapperPath, true) || {};
|
|
86
|
-
const eventsUid = utils_1.fsUtil.readFile(this.eventsMapperPath, true) || {};
|
|
87
87
|
for (const experience of experiences) {
|
|
88
88
|
const { uid } = experience, restExperienceData = __rest(experience, ["uid"]);
|
|
89
89
|
//check whether reference audience exists or not that referenced in variations having __type equal to AudienceBasedVariation & targeting
|
|
90
|
-
let experienceReqObj = (0, utils_1.lookUpAudiences)(restExperienceData, audiencesUid);
|
|
90
|
+
let experienceReqObj = (0, utils_1.lookUpAudiences)(restExperienceData, this.audiencesUid);
|
|
91
91
|
//check whether events exists or not that referenced in metrics
|
|
92
|
-
experienceReqObj = (0, utils_1.lookUpEvents)(experienceReqObj, eventsUid);
|
|
93
|
-
const expRes = yield this.createExperience(experienceReqObj);
|
|
92
|
+
experienceReqObj = (0, utils_1.lookUpEvents)(experienceReqObj, this.eventsUid);
|
|
93
|
+
const expRes = (yield this.createExperience(experienceReqObj));
|
|
94
94
|
//map old experience uid to new experience uid
|
|
95
95
|
this.experiencesUidMapper[uid] = (_a = expRes === null || expRes === void 0 ? void 0 : expRes.uid) !== null && _a !== void 0 ? _a : '';
|
|
96
|
+
try {
|
|
97
|
+
// import versions of experience
|
|
98
|
+
yield this.importExperienceVersions(expRes, uid);
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
this.log(this.config, `Error while importing experience versions of ${expRes.uid}`, 'error');
|
|
102
|
+
this.log(this.config, error, 'error');
|
|
103
|
+
}
|
|
96
104
|
}
|
|
97
105
|
utils_1.fsUtil.writeFile(this.experiencesUidMapperPath, this.experiencesUidMapper);
|
|
98
106
|
this.log(this.config, this.$t(this.messages.CREATE_SUCCESS, { module: 'Experiences' }), 'info');
|
|
@@ -103,9 +111,10 @@ class Experiences extends utils_1.PersonalizationAdapter {
|
|
|
103
111
|
utils_1.fsUtil.writeFile(this.cmsVariantGroupPath, this.cmsVariantGroups);
|
|
104
112
|
if (jobRes)
|
|
105
113
|
this.log(this.config, this.$t(this.messages.CREATE_SUCCESS, { module: 'Variant & Variant groups' }), 'info');
|
|
106
|
-
if (this.
|
|
114
|
+
if (this.personalizeConfig.importData) {
|
|
107
115
|
this.log(this.config, this.messages.UPDATING_CT_IN_EXP, 'info');
|
|
108
116
|
yield this.attachCTsInExperience();
|
|
117
|
+
this.log(this.config, this.messages.UPDATED_CT_IN_EXP, 'info');
|
|
109
118
|
}
|
|
110
119
|
yield this.createVariantIdMapper();
|
|
111
120
|
}
|
|
@@ -117,9 +126,64 @@ class Experiences extends utils_1.PersonalizationAdapter {
|
|
|
117
126
|
});
|
|
118
127
|
}
|
|
119
128
|
/**
|
|
120
|
-
* function
|
|
121
|
-
|
|
122
|
-
|
|
129
|
+
* function import experience versions from a JSON file and creates them in the project.
|
|
130
|
+
*/
|
|
131
|
+
importExperienceVersions(experience, oldExperienceUid) {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
const versionsPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.experiencesDirPath), 'versions', `${(0, cli_utilities_1.sanitizePath)(oldExperienceUid)}.json`);
|
|
134
|
+
if (!(0, fs_1.existsSync)(versionsPath)) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const versions = utils_1.fsUtil.readFile(versionsPath, true);
|
|
138
|
+
const versionMap = {
|
|
139
|
+
ACTIVE: undefined,
|
|
140
|
+
DRAFT: undefined,
|
|
141
|
+
PAUSE: undefined,
|
|
142
|
+
};
|
|
143
|
+
// Process each version and map them by status
|
|
144
|
+
versions.forEach((version) => {
|
|
145
|
+
let versionReqObj = (0, utils_1.lookUpAudiences)(version, this.audiencesUid);
|
|
146
|
+
versionReqObj = (0, utils_1.lookUpEvents)(version, this.eventsUid);
|
|
147
|
+
if (versionReqObj && versionReqObj.status) {
|
|
148
|
+
versionMap[versionReqObj.status] = versionReqObj;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
// Prioritize updating or creating versions based on the order: ACTIVE -> DRAFT -> PAUSE
|
|
152
|
+
return yield this.handleVersionUpdateOrCreate(experience, versionMap);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
// Helper method to handle version update or creation logic
|
|
156
|
+
handleVersionUpdateOrCreate(experience, versionMap) {
|
|
157
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
158
|
+
const { ACTIVE, DRAFT, PAUSE } = versionMap;
|
|
159
|
+
let latestVersionUsed = false;
|
|
160
|
+
if (ACTIVE) {
|
|
161
|
+
yield this.updateExperienceVersion(experience.uid, experience.latestVersion, ACTIVE);
|
|
162
|
+
latestVersionUsed = true;
|
|
163
|
+
}
|
|
164
|
+
if (DRAFT) {
|
|
165
|
+
if (latestVersionUsed) {
|
|
166
|
+
yield this.createExperienceVersion(experience.uid, DRAFT);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
yield this.updateExperienceVersion(experience.uid, experience.latestVersion, DRAFT);
|
|
170
|
+
latestVersionUsed = true;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (PAUSE) {
|
|
174
|
+
if (latestVersionUsed) {
|
|
175
|
+
yield this.createExperienceVersion(experience.uid, PAUSE);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
yield this.updateExperienceVersion(experience.uid, experience.latestVersion, PAUSE);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* function to validate if all variant groups and variants have been created using personalize background job
|
|
185
|
+
* store the variant groups data in mapper/personalize/experiences/cms-variant-groups.json and the variants data
|
|
186
|
+
* in mapper/personalize/experiences/cms-variants.json. If not, invoke validateVariantGroupAndVariantsCreated after some delay.
|
|
123
187
|
* @param retryCount Counter to track the number of times the function has been called
|
|
124
188
|
* @returns
|
|
125
189
|
*/
|
|
@@ -146,7 +210,7 @@ class Experiences extends utils_1.PersonalizationAdapter {
|
|
|
146
210
|
return this.validateVariantGroupAndVariantsCreated(retryCount);
|
|
147
211
|
}
|
|
148
212
|
else {
|
|
149
|
-
this.log(this.config, this.messages.
|
|
213
|
+
this.log(this.config, this.messages.PERSONALIZE_JOB_FAILURE, 'error');
|
|
150
214
|
utils_1.fsUtil.writeFile(this.failedCmsExpPath, this.pendingVariantAndVariantGrpForExperience);
|
|
151
215
|
return false;
|
|
152
216
|
}
|
|
@@ -174,7 +238,7 @@ class Experiences extends utils_1.PersonalizationAdapter {
|
|
|
174
238
|
var _b;
|
|
175
239
|
if ((_b = experienceCTsMap[oldExpUid]) === null || _b === void 0 ? void 0 : _b.length) {
|
|
176
240
|
// Filter content types that were created
|
|
177
|
-
const updatedContentTypes = experienceCTsMap[oldExpUid].filter((ct) => this.createdCTs.includes(ct === null || ct === void 0 ? void 0 : ct.uid));
|
|
241
|
+
const updatedContentTypes = experienceCTsMap[oldExpUid].filter((ct) => this.createdCTs.includes(ct === null || ct === void 0 ? void 0 : ct.uid) && ct.status === 'linked');
|
|
178
242
|
if (updatedContentTypes === null || updatedContentTypes === void 0 ? void 0 : updatedContentTypes.length) {
|
|
179
243
|
const { variant_groups: [variantGroup] = [] } = (yield this.getVariantGroup({ experienceUid: newExpUid })) || {};
|
|
180
244
|
variantGroup.content_types = updatedContentTypes;
|