@contentstack/cli-variants 1.3.4 → 1.3.6
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.js +1 -1
- package/lib/export/audiences.js +1 -1
- package/lib/export/events.js +2 -2
- package/lib/export/experiences.js +1 -1
- package/lib/export/projects.js +3 -3
- package/lib/import/audiences.js +1 -1
- package/lib/import/events.js +1 -1
- package/lib/import/experiences.js +5 -5
- package/lib/import/project.js +1 -1
- package/lib/import/variant-entries.js +3 -3
- package/lib/types/export-config.d.ts +6 -1
- package/lib/types/utils.d.ts +0 -8
- package/lib/utils/personalization-api-adapter.js +13 -13
- package/lib/utils/variant-api-adapter.js +10 -10
- package/package.json +2 -2
- package/src/export/attributes.ts +1 -1
- package/src/export/audiences.ts +1 -1
- package/src/export/events.ts +2 -2
- package/src/export/experiences.ts +1 -1
- package/src/export/projects.ts +3 -3
- package/src/import/audiences.ts +1 -1
- package/src/import/events.ts +1 -1
- package/src/import/experiences.ts +5 -5
- package/src/import/project.ts +1 -1
- package/src/import/variant-entries.ts +3 -3
- package/src/types/export-config.ts +7 -1
- package/src/types/utils.ts +0 -8
- package/src/utils/personalization-api-adapter.ts +13 -13
- package/src/utils/variant-api-adapter.ts +10 -10
package/lib/export/attributes.js
CHANGED
|
@@ -47,7 +47,7 @@ class ExportAttributes extends utils_1.PersonalizationAdapter {
|
|
|
47
47
|
cli_utilities_1.log.debug(`Fetched ${((_a = this.attributes) === null || _a === void 0 ? void 0 : _a.length) || 0} attributes`, this.exportConfig.context);
|
|
48
48
|
if (!((_b = this.attributes) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
49
49
|
cli_utilities_1.log.debug('No attributes found, completing export', this.exportConfig.context);
|
|
50
|
-
cli_utilities_1.log.info('No
|
|
50
|
+
cli_utilities_1.log.info('No attributes found for the given project.', this.exportConfig.context);
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
53
53
|
cli_utilities_1.log.debug(`Processing ${this.attributes.length} attributes`, this.exportConfig.context);
|
package/lib/export/audiences.js
CHANGED
|
@@ -47,7 +47,7 @@ class ExportAudiences extends utils_1.PersonalizationAdapter {
|
|
|
47
47
|
cli_utilities_1.log.debug(`Fetched ${((_a = this.audiences) === null || _a === void 0 ? void 0 : _a.length) || 0} audiences`, this.exportConfig.context);
|
|
48
48
|
if (!((_b = this.audiences) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
49
49
|
cli_utilities_1.log.debug('No audiences found, completing export', this.exportConfig.context);
|
|
50
|
-
cli_utilities_1.log.info('No
|
|
50
|
+
cli_utilities_1.log.info('No audiences found for the given project.', this.exportConfig.context);
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
else {
|
package/lib/export/events.js
CHANGED
|
@@ -42,12 +42,12 @@ class ExportEvents extends utils_1.PersonalizationAdapter {
|
|
|
42
42
|
cli_utilities_1.log.debug(`Creating events directory at: ${this.eventsFolderPath}`, this.exportConfig.context);
|
|
43
43
|
yield utils_1.fsUtil.makeDirectory(this.eventsFolderPath);
|
|
44
44
|
cli_utilities_1.log.debug('Events directory created successfully', this.exportConfig.context);
|
|
45
|
-
cli_utilities_1.log.debug('Fetching events from
|
|
45
|
+
cli_utilities_1.log.debug('Fetching events from Personalize API...', this.exportConfig.context);
|
|
46
46
|
this.events = (yield this.getEvents());
|
|
47
47
|
cli_utilities_1.log.debug(`Fetched ${((_a = this.events) === null || _a === void 0 ? void 0 : _a.length) || 0} events`, this.exportConfig.context);
|
|
48
48
|
if (!((_b = this.events) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
49
49
|
cli_utilities_1.log.debug('No events found, completing export', this.exportConfig.context);
|
|
50
|
-
cli_utilities_1.log.info('No
|
|
50
|
+
cli_utilities_1.log.info('No events found for the given project.', this.exportConfig.context);
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
@@ -85,7 +85,7 @@ class ExportExperiences extends utils_1.PersonalizationAdapter {
|
|
|
85
85
|
cli_utilities_1.log.debug(`Fetched ${(experiences === null || experiences === void 0 ? void 0 : experiences.length) || 0} experiences`, this.exportConfig.context);
|
|
86
86
|
if (!experiences || (experiences === null || experiences === void 0 ? void 0 : experiences.length) < 1) {
|
|
87
87
|
cli_utilities_1.log.debug('No experiences found, completing export', this.exportConfig.context);
|
|
88
|
-
cli_utilities_1.log.info('No
|
|
88
|
+
cli_utilities_1.log.info('No experiences found for the given project.', this.exportConfig.context);
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
91
|
const experiencesFilePath = path.resolve((0, cli_utilities_1.sanitizePath)(this.experiencesFolderPath), 'experiences.json');
|
package/lib/export/projects.js
CHANGED
|
@@ -74,11 +74,11 @@ class ExportProjects extends utils_1.PersonalizationAdapter {
|
|
|
74
74
|
cli_utilities_1.log.debug(`Fetched ${(project === null || project === void 0 ? void 0 : project.length) || 0} projects`, this.exportConfig.context);
|
|
75
75
|
if (!project || (project === null || project === void 0 ? void 0 : project.length) < 1) {
|
|
76
76
|
cli_utilities_1.log.debug('No projects found, disabling personalization', this.exportConfig.context);
|
|
77
|
-
cli_utilities_1.log.info(`No Personalize
|
|
77
|
+
cli_utilities_1.log.info(`No Personalize project connected with the given stack.`, this.exportConfig.context);
|
|
78
78
|
this.exportConfig.personalizationEnabled = false;
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
|
-
cli_utilities_1.log.debug(`Found ${project.length} projects
|
|
81
|
+
cli_utilities_1.log.debug(`Found ${project.length} projects`, this.exportConfig.context);
|
|
82
82
|
this.exportConfig.personalizationEnabled = true;
|
|
83
83
|
this.exportConfig.project_id = (_a = project[0]) === null || _a === void 0 ? void 0 : _a.uid;
|
|
84
84
|
cli_utilities_1.log.debug(`Set project ID: ${(_b = project[0]) === null || _b === void 0 ? void 0 : _b.uid}`, this.exportConfig.context);
|
|
@@ -91,7 +91,7 @@ class ExportProjects extends utils_1.PersonalizationAdapter {
|
|
|
91
91
|
catch (error) {
|
|
92
92
|
if (error !== 'Forbidden') {
|
|
93
93
|
cli_utilities_1.log.debug(`Error occurred during projects export: ${error}`, this.exportConfig.context);
|
|
94
|
-
cli_utilities_1.log.error('Failed to export projects
|
|
94
|
+
cli_utilities_1.log.error('Failed to export projects.', this.exportConfig.context);
|
|
95
95
|
}
|
|
96
96
|
else {
|
|
97
97
|
cli_utilities_1.log.debug('Projects export forbidden, likely due to permissions', this.exportConfig.context);
|
package/lib/import/audiences.js
CHANGED
|
@@ -49,7 +49,7 @@ class Audiences extends utils_1.PersonalizationAdapter {
|
|
|
49
49
|
const audiences = utils_1.fsUtil.readFile(audiencesPath, true);
|
|
50
50
|
cli_utilities_1.log.info(`Found ${audiences.length} audiences to import`, this.config.context);
|
|
51
51
|
const attributesUid = utils_1.fsUtil.readFile(this.attributesMapperPath, true) || {};
|
|
52
|
-
cli_utilities_1.log.debug(`Loaded ${Object.keys(attributesUid).length} attribute mappings
|
|
52
|
+
cli_utilities_1.log.debug(`Loaded ${Object.keys(attributesUid).length} attribute mappings`, this.config.context);
|
|
53
53
|
for (const audience of audiences) {
|
|
54
54
|
let { name, definition, description, uid } = audience;
|
|
55
55
|
cli_utilities_1.log.debug(`Processing audience: ${name} (${uid})`, this.config.context);
|
package/lib/import/events.js
CHANGED
|
@@ -48,7 +48,7 @@ class Events extends utils_1.PersonalizationAdapter {
|
|
|
48
48
|
cli_utilities_1.log.info(`Found ${events.length} events to import`, this.config.context);
|
|
49
49
|
for (const event of events) {
|
|
50
50
|
const { key, description, uid } = event;
|
|
51
|
-
cli_utilities_1.log.debug(`Processing event: ${key} (${uid})
|
|
51
|
+
cli_utilities_1.log.debug(`Processing event: ${key} (${uid})...`, this.config.context);
|
|
52
52
|
try {
|
|
53
53
|
cli_utilities_1.log.debug(`Creating event: ${key}`, this.config.context);
|
|
54
54
|
const eventsResponse = yield this.createEvents({ key, description });
|
|
@@ -191,11 +191,11 @@ class Experiences extends utils_1.PersonalizationAdapter {
|
|
|
191
191
|
}
|
|
192
192
|
if (PAUSE) {
|
|
193
193
|
if (latestVersionUsed) {
|
|
194
|
-
cli_utilities_1.log.debug(`Creating new
|
|
194
|
+
cli_utilities_1.log.debug(`Creating new PAUSED version for: ${experience.uid}`, this.config.context);
|
|
195
195
|
yield this.createExperienceVersion(experience.uid, PAUSE);
|
|
196
196
|
}
|
|
197
197
|
else {
|
|
198
|
-
cli_utilities_1.log.debug(`Updating experience version to
|
|
198
|
+
cli_utilities_1.log.debug(`Updating experience version to PAUSED for: ${experience.uid}`, this.config.context);
|
|
199
199
|
yield this.updateExperienceVersion(experience.uid, experience.latestVersion, PAUSE);
|
|
200
200
|
}
|
|
201
201
|
}
|
|
@@ -225,7 +225,7 @@ class Experiences extends utils_1.PersonalizationAdapter {
|
|
|
225
225
|
return expUid; // Return the expUid for filtering later
|
|
226
226
|
}
|
|
227
227
|
else {
|
|
228
|
-
cli_utilities_1.log.debug(`Variants
|
|
228
|
+
cli_utilities_1.log.debug(`Variants or variant group not ready for experience: ${expUid}`, this.config.context);
|
|
229
229
|
}
|
|
230
230
|
}));
|
|
231
231
|
yield Promise.all(promises);
|
|
@@ -239,7 +239,7 @@ class Experiences extends utils_1.PersonalizationAdapter {
|
|
|
239
239
|
return this.validateVariantGroupAndVariantsCreated(retryCount);
|
|
240
240
|
}
|
|
241
241
|
else {
|
|
242
|
-
cli_utilities_1.log.error('Personalize job failed to create variants and variant groups', this.config.context);
|
|
242
|
+
cli_utilities_1.log.error('Personalize job failed to create variants and variant groups.', this.config.context);
|
|
243
243
|
cli_utilities_1.log.error(`Failed experiences: ${this.pendingVariantAndVariantGrpForExperience.join(', ')}`, this.config.context);
|
|
244
244
|
utils_1.fsUtil.writeFile(this.failedCmsExpPath, this.pendingVariantAndVariantGrpForExperience);
|
|
245
245
|
return false;
|
|
@@ -263,7 +263,7 @@ class Experiences extends utils_1.PersonalizationAdapter {
|
|
|
263
263
|
// Read the created content types from the file
|
|
264
264
|
this.createdCTs = utils_1.fsUtil.readFile(this.cTsSuccessPath, true);
|
|
265
265
|
if (!this.createdCTs) {
|
|
266
|
-
cli_utilities_1.log.
|
|
266
|
+
cli_utilities_1.log.warn('No content types created.', this.config.context);
|
|
267
267
|
return;
|
|
268
268
|
}
|
|
269
269
|
cli_utilities_1.log.debug(`Found ${this.createdCTs.length} created content types`, this.config.context);
|
package/lib/import/project.js
CHANGED
|
@@ -55,7 +55,7 @@ class Project extends utils_1.PersonalizationAdapter {
|
|
|
55
55
|
}).catch((error) => __awaiter(this, void 0, void 0, function* () {
|
|
56
56
|
if (error.includes('personalization.PROJECTS.DUPLICATE_NAME') ||
|
|
57
57
|
error.includes('personalize.PROJECTS.DUPLICATE_NAME')) {
|
|
58
|
-
cli_utilities_1.log.warn(`Project name already exists, generating new name
|
|
58
|
+
cli_utilities_1.log.warn(`Project name already exists, generating new name.`, this.config.context);
|
|
59
59
|
const projectName = yield (0, utils_1.askProjectName)('Copy Of ' + (newName || project.name));
|
|
60
60
|
return yield createProject(projectName);
|
|
61
61
|
}
|
|
@@ -96,7 +96,7 @@ class VariantEntries extends variant_api_adapter_1.default {
|
|
|
96
96
|
const variantIdPath = (0, path_1.resolve)((0, cli_utilities_1.sanitizePath)(this.config.backupDir), 'mapper', (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.dirName), (0, cli_utilities_1.sanitizePath)(this.personalizeConfig.experiences.dirName), 'variants-uid-mapping.json');
|
|
97
97
|
cli_utilities_1.log.debug(`Checking for variant entry data file: ${filePath}`, this.config.context);
|
|
98
98
|
if (!(0, fs_1.existsSync)(filePath)) {
|
|
99
|
-
cli_utilities_1.log.warn(`Variant entry data file not found at path: ${filePath}
|
|
99
|
+
cli_utilities_1.log.warn(`Variant entry data file not found at path: ${filePath}`, this.config.context);
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
102
|
cli_utilities_1.log.debug(`Checking for variant ID mapping file: ${variantIdPath}`, this.config.context);
|
|
@@ -387,7 +387,7 @@ class VariantEntries extends variant_api_adapter_1.default {
|
|
|
387
387
|
continue;
|
|
388
388
|
}
|
|
389
389
|
if ((_a = this.environments) === null || _a === void 0 ? void 0 : _a.length) {
|
|
390
|
-
cli_utilities_1.log.info('No
|
|
390
|
+
cli_utilities_1.log.info('No environments found. Skipping entry variant publishing...', this.config.context);
|
|
391
391
|
return;
|
|
392
392
|
}
|
|
393
393
|
const onSuccess = ({ response, apiData: { entryUid, variantUid } }) => {
|
|
@@ -441,7 +441,7 @@ class VariantEntries extends variant_api_adapter_1.default {
|
|
|
441
441
|
cli_utilities_1.log.debug(`Processing ${variantEntry.publish_details.length} publish details`, this.config.context);
|
|
442
442
|
}
|
|
443
443
|
else {
|
|
444
|
-
cli_utilities_1.log.debug('No publish details found for variant entry', this.config.context);
|
|
444
|
+
cli_utilities_1.log.debug('No publish details found for variant entry.', this.config.context);
|
|
445
445
|
}
|
|
446
446
|
if (variantEntry.publish_details && ((_b = variantEntry.publish_details) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
447
447
|
(0, forEach_1.default)(variantEntry.publish_details, (pubObject) => {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Therefore, we are duplicating the following types from the export.
|
|
5
5
|
*/
|
|
6
6
|
import { AnyProperty, Context } from './utils';
|
|
7
|
-
export type Modules = 'stack' | 'assets' | 'locales' | 'environments' | 'extensions' | 'webhooks' | 'global-fields' | 'entries' | 'content-types' | 'custom-roles' | 'workflows' | 'labels' | 'marketplace-apps' | 'taxonomies' | 'personalize';
|
|
7
|
+
export type Modules = 'stack' | 'assets' | 'locales' | 'environments' | 'extensions' | 'webhooks' | 'global-fields' | 'entries' | 'content-types' | 'custom-roles' | 'workflows' | 'labels' | 'marketplace-apps' | 'taxonomies' | 'personalize' | 'composable-studio';
|
|
8
8
|
export type branch = {
|
|
9
9
|
uid: string;
|
|
10
10
|
source: string;
|
|
@@ -159,6 +159,11 @@ export interface DefaultConfig {
|
|
|
159
159
|
fileName: string;
|
|
160
160
|
dependencies?: Modules[];
|
|
161
161
|
};
|
|
162
|
+
'composable-studio': {
|
|
163
|
+
dirName: string;
|
|
164
|
+
fileName: string;
|
|
165
|
+
apiBaseUrl: string;
|
|
166
|
+
};
|
|
162
167
|
masterLocale: {
|
|
163
168
|
dirName: string;
|
|
164
169
|
fileName: string;
|
package/lib/types/utils.d.ts
CHANGED
|
@@ -6,13 +6,5 @@ export interface LogType {
|
|
|
6
6
|
(config: any, message: any, type: 'info' | 'error' | 'success'): void;
|
|
7
7
|
}
|
|
8
8
|
export interface Context {
|
|
9
|
-
command: string;
|
|
10
9
|
module: string;
|
|
11
|
-
userId: string | undefined;
|
|
12
|
-
email: string | undefined;
|
|
13
|
-
sessionId: string | undefined;
|
|
14
|
-
clientId?: string | undefined;
|
|
15
|
-
apiKey: string;
|
|
16
|
-
orgId: string;
|
|
17
|
-
authMethod?: string;
|
|
18
10
|
}
|
|
@@ -28,7 +28,7 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
|
|
|
28
28
|
constructor(options) {
|
|
29
29
|
var _a;
|
|
30
30
|
super(options);
|
|
31
|
-
cli_utilities_1.log.debug('
|
|
31
|
+
cli_utilities_1.log.debug('Personalization adapter initialized.', (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
|
|
32
32
|
}
|
|
33
33
|
init() {
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -38,22 +38,22 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
|
|
|
38
38
|
const token = cli_utilities_1.authenticationHandler.accessToken;
|
|
39
39
|
cli_utilities_1.log.debug(`Authentication type: ${cli_utilities_1.authenticationHandler.isOauthEnabled ? 'OAuth' : 'Token'}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
|
|
40
40
|
if (cli_utilities_1.authenticationHandler.isOauthEnabled) {
|
|
41
|
-
cli_utilities_1.log.debug('Setting OAuth authorization header', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
|
|
41
|
+
cli_utilities_1.log.debug('Setting OAuth authorization header...', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
|
|
42
42
|
this.apiClient.headers({ authorization: token });
|
|
43
43
|
if (this.adapterConfig.cmaConfig) {
|
|
44
|
-
cli_utilities_1.log.debug('Setting OAuth authorization header for CMA client', (_d = this.exportConfig) === null || _d === void 0 ? void 0 : _d.context);
|
|
44
|
+
cli_utilities_1.log.debug('Setting OAuth authorization header for CMA client...', (_d = this.exportConfig) === null || _d === void 0 ? void 0 : _d.context);
|
|
45
45
|
(_e = this.cmaAPIClient) === null || _e === void 0 ? void 0 : _e.headers({ authorization: token });
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
|
-
cli_utilities_1.log.debug('Setting authtoken header', (_f = this.exportConfig) === null || _f === void 0 ? void 0 : _f.context);
|
|
49
|
+
cli_utilities_1.log.debug('Setting authtoken header...', (_f = this.exportConfig) === null || _f === void 0 ? void 0 : _f.context);
|
|
50
50
|
this.apiClient.headers({ authtoken: token });
|
|
51
51
|
if (this.adapterConfig.cmaConfig) {
|
|
52
|
-
cli_utilities_1.log.debug('Setting authtoken header for CMA client', (_g = this.exportConfig) === null || _g === void 0 ? void 0 : _g.context);
|
|
52
|
+
cli_utilities_1.log.debug('Setting authtoken header for CMA client...', (_g = this.exportConfig) === null || _g === void 0 ? void 0 : _g.context);
|
|
53
53
|
(_h = this.cmaAPIClient) === null || _h === void 0 ? void 0 : _h.headers({ authtoken: token });
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
cli_utilities_1.log.debug('Personalization adapter initialization completed', (_j = this.exportConfig) === null || _j === void 0 ? void 0 : _j.context);
|
|
56
|
+
cli_utilities_1.log.debug('Personalization adapter initialization completed.', (_j = this.exportConfig) === null || _j === void 0 ? void 0 : _j.context);
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
projects(options) {
|
|
@@ -111,7 +111,7 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
|
|
|
111
111
|
getExperiences() {
|
|
112
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
113
|
var _a, _b;
|
|
114
|
-
cli_utilities_1.log.debug('Fetching experiences from
|
|
114
|
+
cli_utilities_1.log.debug('Fetching experiences from Personalize API...', (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
|
|
115
115
|
const getExperiencesEndPoint = `/experiences`;
|
|
116
116
|
const data = yield this.apiClient.get(getExperiencesEndPoint);
|
|
117
117
|
const result = (yield this.handleVariantAPIRes(data));
|
|
@@ -191,7 +191,7 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
|
|
|
191
191
|
return result;
|
|
192
192
|
}
|
|
193
193
|
else {
|
|
194
|
-
cli_utilities_1.log.debug('CMA API client not available for variant group fetch', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
|
|
194
|
+
cli_utilities_1.log.debug('CMA API client not available for variant group fetch.', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
|
|
195
195
|
}
|
|
196
196
|
});
|
|
197
197
|
}
|
|
@@ -207,14 +207,14 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
|
|
|
207
207
|
return result;
|
|
208
208
|
}
|
|
209
209
|
else {
|
|
210
|
-
cli_utilities_1.log.debug('CMA API client not available for variant group update', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
|
|
210
|
+
cli_utilities_1.log.debug('CMA API client not available for variant group update.', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
|
|
211
211
|
}
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
214
|
getEvents() {
|
|
215
215
|
return __awaiter(this, void 0, void 0, function* () {
|
|
216
216
|
var _a, _b;
|
|
217
|
-
cli_utilities_1.log.debug('Fetching events from
|
|
217
|
+
cli_utilities_1.log.debug('Fetching events from Personalize API...', (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
|
|
218
218
|
const data = yield this.apiClient.get('/events');
|
|
219
219
|
const result = (yield this.handleVariantAPIRes(data));
|
|
220
220
|
cli_utilities_1.log.debug(`Fetched ${(result === null || result === void 0 ? void 0 : result.length) || 0} events`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
|
|
@@ -234,7 +234,7 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
|
|
|
234
234
|
getAudiences() {
|
|
235
235
|
return __awaiter(this, void 0, void 0, function* () {
|
|
236
236
|
var _a, _b;
|
|
237
|
-
cli_utilities_1.log.debug('Fetching audiences from
|
|
237
|
+
cli_utilities_1.log.debug('Fetching audiences from Personalize API...', (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
|
|
238
238
|
const data = yield this.apiClient.get('/audiences');
|
|
239
239
|
const result = (yield this.handleVariantAPIRes(data));
|
|
240
240
|
cli_utilities_1.log.debug(`Fetched ${(result === null || result === void 0 ? void 0 : result.length) || 0} audiences`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
|
|
@@ -244,7 +244,7 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
|
|
|
244
244
|
getAttributes() {
|
|
245
245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
246
246
|
var _a, _b;
|
|
247
|
-
cli_utilities_1.log.debug('Fetching attributes from
|
|
247
|
+
cli_utilities_1.log.debug('Fetching attributes from Personalize API...', (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
|
|
248
248
|
const data = yield this.apiClient.get('/attributes');
|
|
249
249
|
const result = (yield this.handleVariantAPIRes(data));
|
|
250
250
|
cli_utilities_1.log.info(`Fetched ${(result === null || result === void 0 ? void 0 : result.length) || 0} attributes`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
|
|
@@ -331,7 +331,7 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
|
|
|
331
331
|
const { status, data } = res;
|
|
332
332
|
cli_utilities_1.log.debug(`API response status: ${status}`, (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
|
|
333
333
|
if (status >= 200 && status < 300) {
|
|
334
|
-
cli_utilities_1.log.debug('API request successful', (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
|
|
334
|
+
cli_utilities_1.log.debug('API request successful.', (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
|
|
335
335
|
return data;
|
|
336
336
|
}
|
|
337
337
|
cli_utilities_1.log.debug(`API request failed with status: ${status}`, (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
|
|
@@ -46,11 +46,11 @@ class VariantHttpClient extends adapter_helper_1.AdapterHelper {
|
|
|
46
46
|
const token = cli_utilities_1.authenticationHandler.accessToken;
|
|
47
47
|
cli_utilities_1.log.debug(`Authentication type: ${cli_utilities_1.authenticationHandler.isOauthEnabled ? 'OAuth' : 'Token'}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
|
|
48
48
|
if (cli_utilities_1.authenticationHandler.isOauthEnabled) {
|
|
49
|
-
cli_utilities_1.log.debug('Setting OAuth authorization header', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
|
|
49
|
+
cli_utilities_1.log.debug('Setting OAuth authorization header...', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
|
|
50
50
|
this.apiClient.headers({ authorization: token });
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
53
|
-
cli_utilities_1.log.debug('Setting authtoken header', (_d = this.exportConfig) === null || _d === void 0 ? void 0 : _d.context);
|
|
53
|
+
cli_utilities_1.log.debug('Setting authtoken header...', (_d = this.exportConfig) === null || _d === void 0 ? void 0 : _d.context);
|
|
54
54
|
this.apiClient.headers({ authtoken: token });
|
|
55
55
|
}
|
|
56
56
|
});
|
|
@@ -83,7 +83,7 @@ class VariantHttpClient extends adapter_helper_1.AdapterHelper {
|
|
|
83
83
|
cli_utilities_1.log.debug(`Fetching variant entries for content type: ${content_type_uid}, entry: ${entry_uid}, locale: ${locale}`, (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
|
|
84
84
|
cli_utilities_1.log.debug(`Query parameters - skip: ${skip}, limit: ${limit}, include_variant: ${include_variant}, include_count: ${include_count}, include_publish_details: ${include_publish_details}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
|
|
85
85
|
if (variantConfig.serveMockData && callback) {
|
|
86
|
-
cli_utilities_1.log.debug('Using mock data for variant entries', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
|
|
86
|
+
cli_utilities_1.log.debug('Using mock data for variant entries...', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
|
|
87
87
|
let data = [];
|
|
88
88
|
if ((0, fs_1.existsSync)(variantConfig.mockDataPath)) {
|
|
89
89
|
cli_utilities_1.log.debug(`Loading mock data from: ${variantConfig.mockDataPath}`, (_d = this.exportConfig) === null || _d === void 0 ? void 0 : _d.context);
|
|
@@ -131,11 +131,11 @@ class VariantHttpClient extends adapter_helper_1.AdapterHelper {
|
|
|
131
131
|
cli_utilities_1.log.debug(`Received ${(_h = response.entries) === null || _h === void 0 ? void 0 : _h.length} variant entries out of total ${response.count}`, (_j = this.exportConfig) === null || _j === void 0 ? void 0 : _j.context);
|
|
132
132
|
}
|
|
133
133
|
if (callback) {
|
|
134
|
-
cli_utilities_1.log.debug('Executing callback with variant entries', (_k = this.exportConfig) === null || _k === void 0 ? void 0 : _k.context);
|
|
134
|
+
cli_utilities_1.log.debug('Executing callback with variant entries...', (_k = this.exportConfig) === null || _k === void 0 ? void 0 : _k.context);
|
|
135
135
|
callback(response.entries);
|
|
136
136
|
}
|
|
137
137
|
else {
|
|
138
|
-
cli_utilities_1.log.debug('Adding variant entries to collection', (_l = this.exportConfig) === null || _l === void 0 ? void 0 : _l.context);
|
|
138
|
+
cli_utilities_1.log.debug('Adding variant entries to collection...', (_l = this.exportConfig) === null || _l === void 0 ? void 0 : _l.context);
|
|
139
139
|
entries = entries.concat(response.entries);
|
|
140
140
|
}
|
|
141
141
|
if (getAllData && skip + limit < response.count) {
|
|
@@ -154,7 +154,7 @@ class VariantHttpClient extends adapter_helper_1.AdapterHelper {
|
|
|
154
154
|
return yield this.variantEntries(options, entries);
|
|
155
155
|
}
|
|
156
156
|
if (returnResult) {
|
|
157
|
-
cli_utilities_1.log.debug('Returning variant entries result', (_p = this.exportConfig) === null || _p === void 0 ? void 0 : _p.context);
|
|
157
|
+
cli_utilities_1.log.debug('Returning variant entries result...', (_p = this.exportConfig) === null || _p === void 0 ? void 0 : _p.context);
|
|
158
158
|
return { entries };
|
|
159
159
|
}
|
|
160
160
|
});
|
|
@@ -264,7 +264,7 @@ class VariantHttpClient extends adapter_helper_1.AdapterHelper {
|
|
|
264
264
|
const { status, data } = res;
|
|
265
265
|
cli_utilities_1.log.debug(`API response status: ${status}`, (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
|
|
266
266
|
if (status >= 200 && status < 300) {
|
|
267
|
-
cli_utilities_1.log.debug('API request successful', (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
|
|
267
|
+
cli_utilities_1.log.debug('API request successful.', (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
|
|
268
268
|
return data;
|
|
269
269
|
}
|
|
270
270
|
cli_utilities_1.log.debug(`API request failed with status: ${status}`, (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
|
|
@@ -321,17 +321,17 @@ class VariantAdapter {
|
|
|
321
321
|
var _a, _b, _c, _d;
|
|
322
322
|
cli_utilities_1.log.debug('Initializing VariantAdapter...', (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
|
|
323
323
|
if (config.httpClient) {
|
|
324
|
-
cli_utilities_1.log.debug('Using HTTP client variant instance', (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
|
|
324
|
+
cli_utilities_1.log.debug('Using HTTP client variant instance.', (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
|
|
325
325
|
const { httpClient, Adapter } = config, restConfig = __rest(config, ["httpClient", "Adapter"]);
|
|
326
326
|
this.variantInstance = new Adapter(restConfig, options);
|
|
327
327
|
}
|
|
328
328
|
else {
|
|
329
|
-
cli_utilities_1.log.debug('Using SDK variant instance', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
|
|
329
|
+
cli_utilities_1.log.debug('Using SDK variant instance.', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
|
|
330
330
|
const { Adapter } = config, restConfig = __rest(config, ["Adapter"]);
|
|
331
331
|
this.variantInstance = new Adapter(restConfig);
|
|
332
332
|
}
|
|
333
333
|
this.messages = messages_1.default;
|
|
334
|
-
cli_utilities_1.log.debug('VariantAdapter initialized successfully', (_d = this.exportConfig) === null || _d === void 0 ? void 0 : _d.context);
|
|
334
|
+
cli_utilities_1.log.debug('VariantAdapter initialized successfully.', (_d = this.exportConfig) === null || _d === void 0 ? void 0 : _d.context);
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
exports.VariantAdapter = VariantAdapter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-variants",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"description": "Variants plugin",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"typescript": "^5.8.3"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@contentstack/cli-utilities": "~1.
|
|
30
|
+
"@contentstack/cli-utilities": "~1.16.0",
|
|
31
31
|
"@oclif/core": "^4.3.0",
|
|
32
32
|
"@oclif/plugin-help": "^6.2.28",
|
|
33
33
|
"lodash": "^4.17.21",
|
package/src/export/attributes.ts
CHANGED
|
@@ -47,7 +47,7 @@ export default class ExportAttributes extends PersonalizationAdapter<ExportConfi
|
|
|
47
47
|
|
|
48
48
|
if (!this.attributes?.length) {
|
|
49
49
|
log.debug('No attributes found, completing export', this.exportConfig.context);
|
|
50
|
-
log.info('No
|
|
50
|
+
log.info('No attributes found for the given project.', this.exportConfig.context);
|
|
51
51
|
} else {
|
|
52
52
|
log.debug(`Processing ${this.attributes.length} attributes`, this.exportConfig.context);
|
|
53
53
|
this.sanitizeAttribs();
|
package/src/export/audiences.ts
CHANGED
|
@@ -48,7 +48,7 @@ export default class ExportAudiences extends PersonalizationAdapter<ExportConfig
|
|
|
48
48
|
|
|
49
49
|
if (!this.audiences?.length) {
|
|
50
50
|
log.debug('No audiences found, completing export', this.exportConfig.context);
|
|
51
|
-
log.info('No
|
|
51
|
+
log.info('No audiences found for the given project.', this.exportConfig.context);
|
|
52
52
|
return;
|
|
53
53
|
} else {
|
|
54
54
|
log.debug(`Processing ${this.audiences.length} audiences`, this.exportConfig.context);
|
package/src/export/events.ts
CHANGED
|
@@ -42,13 +42,13 @@ export default class ExportEvents extends PersonalizationAdapter<ExportConfig> {
|
|
|
42
42
|
await fsUtil.makeDirectory(this.eventsFolderPath);
|
|
43
43
|
log.debug('Events directory created successfully', this.exportConfig.context);
|
|
44
44
|
|
|
45
|
-
log.debug('Fetching events from
|
|
45
|
+
log.debug('Fetching events from Personalize API...', this.exportConfig.context);
|
|
46
46
|
this.events = (await this.getEvents()) as EventStruct[];
|
|
47
47
|
log.debug(`Fetched ${this.events?.length || 0} events`, this.exportConfig.context);
|
|
48
48
|
|
|
49
49
|
if (!this.events?.length) {
|
|
50
50
|
log.debug('No events found, completing export', this.exportConfig.context);
|
|
51
|
-
log.info('No
|
|
51
|
+
log.info('No events found for the given project.', this.exportConfig.context);
|
|
52
52
|
return;
|
|
53
53
|
} else {
|
|
54
54
|
log.debug(`Processing ${this.events.length} events`, this.exportConfig.context);
|
|
@@ -55,7 +55,7 @@ export default class ExportExperiences extends PersonalizationAdapter<ExportConf
|
|
|
55
55
|
|
|
56
56
|
if (!experiences || experiences?.length < 1) {
|
|
57
57
|
log.debug('No experiences found, completing export', this.exportConfig.context);
|
|
58
|
-
log.info('No
|
|
58
|
+
log.info('No experiences found for the given project.', this.exportConfig.context);
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
|
package/src/export/projects.ts
CHANGED
|
@@ -43,12 +43,12 @@ export default class ExportProjects extends PersonalizationAdapter<ExportConfig>
|
|
|
43
43
|
|
|
44
44
|
if (!project || project?.length < 1) {
|
|
45
45
|
log.debug('No projects found, disabling personalization', this.exportConfig.context);
|
|
46
|
-
log.info(`No Personalize
|
|
46
|
+
log.info(`No Personalize project connected with the given stack.`, this.exportConfig.context);
|
|
47
47
|
this.exportConfig.personalizationEnabled = false;
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
log.debug(`Found ${project.length} projects
|
|
51
|
+
log.debug(`Found ${project.length} projects`, this.exportConfig.context);
|
|
52
52
|
this.exportConfig.personalizationEnabled = true;
|
|
53
53
|
this.exportConfig.project_id = project[0]?.uid;
|
|
54
54
|
log.debug(`Set project ID: ${project[0]?.uid}`, this.exportConfig.context);
|
|
@@ -62,7 +62,7 @@ export default class ExportProjects extends PersonalizationAdapter<ExportConfig>
|
|
|
62
62
|
} catch (error) {
|
|
63
63
|
if (error !== 'Forbidden') {
|
|
64
64
|
log.debug(`Error occurred during projects export: ${error}`, this.exportConfig.context);
|
|
65
|
-
log.error('Failed to export projects
|
|
65
|
+
log.error('Failed to export projects.', this.exportConfig.context);
|
|
66
66
|
} else {
|
|
67
67
|
log.debug('Projects export forbidden, likely due to permissions', this.exportConfig.context);
|
|
68
68
|
}
|
package/src/import/audiences.ts
CHANGED
|
@@ -65,7 +65,7 @@ export default class Audiences extends PersonalizationAdapter<ImportConfig> {
|
|
|
65
65
|
log.info(`Found ${audiences.length} audiences to import`, this.config.context);
|
|
66
66
|
|
|
67
67
|
const attributesUid = (fsUtil.readFile(this.attributesMapperPath, true) as Record<string, string>) || {};
|
|
68
|
-
log.debug(`Loaded ${Object.keys(attributesUid).length} attribute mappings
|
|
68
|
+
log.debug(`Loaded ${Object.keys(attributesUid).length} attribute mappings`, this.config.context);
|
|
69
69
|
|
|
70
70
|
for (const audience of audiences) {
|
|
71
71
|
let { name, definition, description, uid } = audience;
|
package/src/import/events.ts
CHANGED
|
@@ -58,7 +58,7 @@ export default class Events extends PersonalizationAdapter<ImportConfig> {
|
|
|
58
58
|
|
|
59
59
|
for (const event of events) {
|
|
60
60
|
const { key, description, uid } = event;
|
|
61
|
-
log.debug(`Processing event: ${key} (${uid})
|
|
61
|
+
log.debug(`Processing event: ${key} (${uid})...`, this.config.context);
|
|
62
62
|
|
|
63
63
|
try {
|
|
64
64
|
log.debug(`Creating event: ${key}`, this.config.context);
|
|
@@ -241,10 +241,10 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
|
|
|
241
241
|
|
|
242
242
|
if (PAUSE) {
|
|
243
243
|
if (latestVersionUsed) {
|
|
244
|
-
log.debug(`Creating new
|
|
244
|
+
log.debug(`Creating new PAUSED version for: ${experience.uid}`, this.config.context);
|
|
245
245
|
await this.createExperienceVersion(experience.uid, PAUSE);
|
|
246
246
|
} else {
|
|
247
|
-
log.debug(`Updating experience version to
|
|
247
|
+
log.debug(`Updating experience version to PAUSED for: ${experience.uid}`, this.config.context);
|
|
248
248
|
await this.updateExperienceVersion(experience.uid, experience.latestVersion, PAUSE);
|
|
249
249
|
}
|
|
250
250
|
}
|
|
@@ -271,7 +271,7 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
|
|
|
271
271
|
this.cmsVariantGroups[expUid] = expRes._cms?.variantGroup ?? {};
|
|
272
272
|
return expUid; // Return the expUid for filtering later
|
|
273
273
|
} else {
|
|
274
|
-
log.debug(`Variants
|
|
274
|
+
log.debug(`Variants or variant group not ready for experience: ${expUid}`, this.config.context);
|
|
275
275
|
}
|
|
276
276
|
});
|
|
277
277
|
|
|
@@ -288,7 +288,7 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
|
|
|
288
288
|
);
|
|
289
289
|
return this.validateVariantGroupAndVariantsCreated(retryCount);
|
|
290
290
|
} else {
|
|
291
|
-
log.error('Personalize job failed to create variants and variant groups', this.config.context);
|
|
291
|
+
log.error('Personalize job failed to create variants and variant groups.', this.config.context);
|
|
292
292
|
log.error(`Failed experiences: ${this.pendingVariantAndVariantGrpForExperience.join(', ')}`, this.config.context);
|
|
293
293
|
fsUtil.writeFile(this.failedCmsExpPath, this.pendingVariantAndVariantGrpForExperience);
|
|
294
294
|
return false;
|
|
@@ -310,7 +310,7 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
|
|
|
310
310
|
// Read the created content types from the file
|
|
311
311
|
this.createdCTs = fsUtil.readFile(this.cTsSuccessPath, true) as any;
|
|
312
312
|
if (!this.createdCTs) {
|
|
313
|
-
log.
|
|
313
|
+
log.warn('No content types created.', this.config.context);
|
|
314
314
|
return;
|
|
315
315
|
}
|
|
316
316
|
|
package/src/import/project.ts
CHANGED
|
@@ -67,7 +67,7 @@ export default class Project extends PersonalizationAdapter<ImportConfig> {
|
|
|
67
67
|
error.includes('personalization.PROJECTS.DUPLICATE_NAME') ||
|
|
68
68
|
error.includes('personalize.PROJECTS.DUPLICATE_NAME')
|
|
69
69
|
) {
|
|
70
|
-
log.warn(`Project name already exists, generating new name
|
|
70
|
+
log.warn(`Project name already exists, generating new name.`, this.config.context);
|
|
71
71
|
const projectName = await askProjectName('Copy Of ' + (newName || project.name));
|
|
72
72
|
return await createProject(projectName);
|
|
73
73
|
}
|
|
@@ -85,7 +85,7 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
|
|
|
85
85
|
|
|
86
86
|
log.debug(`Checking for variant entry data file: ${filePath}`, this.config.context);
|
|
87
87
|
if (!existsSync(filePath)) {
|
|
88
|
-
log.warn(`Variant entry data file not found at path: ${filePath}
|
|
88
|
+
log.warn(`Variant entry data file not found at path: ${filePath}`, this.config.context);
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -489,7 +489,7 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
|
|
|
489
489
|
}
|
|
490
490
|
|
|
491
491
|
if (this.environments?.length) {
|
|
492
|
-
log.info('No
|
|
492
|
+
log.info('No environments found. Skipping entry variant publishing...', this.config.context);
|
|
493
493
|
return;
|
|
494
494
|
}
|
|
495
495
|
|
|
@@ -572,7 +572,7 @@ export default class VariantEntries extends VariantAdapter<VariantHttpClient<Imp
|
|
|
572
572
|
if (variantEntry.publish_details && variantEntry.publish_details?.length > 0) {
|
|
573
573
|
log.debug(`Processing ${variantEntry.publish_details.length} publish details`, this.config.context);
|
|
574
574
|
} else {
|
|
575
|
-
log.debug('No publish details found for variant entry', this.config.context);
|
|
575
|
+
log.debug('No publish details found for variant entry.', this.config.context);
|
|
576
576
|
}
|
|
577
577
|
|
|
578
578
|
if (variantEntry.publish_details && variantEntry.publish_details?.length > 0) {
|
|
@@ -20,7 +20,8 @@ export type Modules =
|
|
|
20
20
|
| 'labels'
|
|
21
21
|
| 'marketplace-apps'
|
|
22
22
|
| 'taxonomies'
|
|
23
|
-
| 'personalize'
|
|
23
|
+
| 'personalize'
|
|
24
|
+
| 'composable-studio';
|
|
24
25
|
|
|
25
26
|
export type branch = {
|
|
26
27
|
uid: string;
|
|
@@ -183,6 +184,11 @@ export interface DefaultConfig {
|
|
|
183
184
|
fileName: string;
|
|
184
185
|
dependencies?: Modules[];
|
|
185
186
|
};
|
|
187
|
+
'composable-studio': {
|
|
188
|
+
dirName: string;
|
|
189
|
+
fileName: string;
|
|
190
|
+
apiBaseUrl: string;
|
|
191
|
+
};
|
|
186
192
|
masterLocale: {
|
|
187
193
|
dirName: string;
|
|
188
194
|
fileName: string;
|
package/src/types/utils.ts
CHANGED
|
@@ -8,13 +8,5 @@ export interface LogType {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export interface Context {
|
|
11
|
-
command: string;
|
|
12
11
|
module: string;
|
|
13
|
-
userId: string | undefined;
|
|
14
|
-
email: string | undefined;
|
|
15
|
-
sessionId: string | undefined;
|
|
16
|
-
clientId?: string | undefined;
|
|
17
|
-
apiKey: string;
|
|
18
|
-
orgId: string;
|
|
19
|
-
authMethod?: string;
|
|
20
12
|
}
|
|
@@ -32,7 +32,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
|
|
|
32
32
|
|
|
33
33
|
constructor(options: APIConfig) {
|
|
34
34
|
super(options);
|
|
35
|
-
log.debug('
|
|
35
|
+
log.debug('Personalization adapter initialized.', this.exportConfig?.context);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
async init(): Promise<void> {
|
|
@@ -42,21 +42,21 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
|
|
|
42
42
|
log.debug(`Authentication type: ${authenticationHandler.isOauthEnabled ? 'OAuth' : 'Token'}`, this.exportConfig?.context );
|
|
43
43
|
|
|
44
44
|
if (authenticationHandler.isOauthEnabled) {
|
|
45
|
-
log.debug('Setting OAuth authorization header', this.exportConfig?.context );
|
|
45
|
+
log.debug('Setting OAuth authorization header...', this.exportConfig?.context );
|
|
46
46
|
this.apiClient.headers({ authorization: token });
|
|
47
47
|
if (this.adapterConfig.cmaConfig) {
|
|
48
|
-
log.debug('Setting OAuth authorization header for CMA client', this.exportConfig?.context );
|
|
48
|
+
log.debug('Setting OAuth authorization header for CMA client...', this.exportConfig?.context );
|
|
49
49
|
this.cmaAPIClient?.headers({ authorization: token });
|
|
50
50
|
}
|
|
51
51
|
} else {
|
|
52
|
-
log.debug('Setting authtoken header', this.exportConfig?.context );
|
|
52
|
+
log.debug('Setting authtoken header...', this.exportConfig?.context );
|
|
53
53
|
this.apiClient.headers({ authtoken: token });
|
|
54
54
|
if (this.adapterConfig.cmaConfig) {
|
|
55
|
-
log.debug('Setting authtoken header for CMA client', this.exportConfig?.context );
|
|
55
|
+
log.debug('Setting authtoken header for CMA client...', this.exportConfig?.context );
|
|
56
56
|
this.cmaAPIClient?.headers({ authtoken: token });
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
log.debug('Personalization adapter initialization completed', this.exportConfig?.context );
|
|
59
|
+
log.debug('Personalization adapter initialization completed.', this.exportConfig?.context );
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
async projects(options: GetProjectsParams): Promise<ProjectStruct[]> {
|
|
@@ -106,7 +106,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
async getExperiences(): Promise<ExperienceStruct[]> {
|
|
109
|
-
log.debug('Fetching experiences from
|
|
109
|
+
log.debug('Fetching experiences from Personalize API...', this.exportConfig?.context );
|
|
110
110
|
const getExperiencesEndPoint = `/experiences`;
|
|
111
111
|
const data = await this.apiClient.get(getExperiencesEndPoint);
|
|
112
112
|
const result = (await this.handleVariantAPIRes(data)) as ExperienceStruct[];
|
|
@@ -179,7 +179,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
|
|
|
179
179
|
log.debug(`Variant group fetched successfully for experience: ${input?.experienceUid}`, this.exportConfig?.context );
|
|
180
180
|
return result;
|
|
181
181
|
} else {
|
|
182
|
-
log.debug('CMA API client not available for variant group fetch', this.exportConfig?.context );
|
|
182
|
+
log.debug('CMA API client not available for variant group fetch.', this.exportConfig?.context );
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
@@ -192,12 +192,12 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
|
|
|
192
192
|
log.debug(`Variant group updated successfully: ${input?.uid}`, this.exportConfig?.context );
|
|
193
193
|
return result;
|
|
194
194
|
} else {
|
|
195
|
-
log.debug('CMA API client not available for variant group update', this.exportConfig?.context );
|
|
195
|
+
log.debug('CMA API client not available for variant group update.', this.exportConfig?.context );
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
async getEvents(): Promise<EventStruct[] | void> {
|
|
200
|
-
log.debug('Fetching events from
|
|
200
|
+
log.debug('Fetching events from Personalize API...', this.exportConfig?.context );
|
|
201
201
|
const data = await this.apiClient.get<EventStruct>('/events');
|
|
202
202
|
const result = (await this.handleVariantAPIRes(data)) as EventStruct[];
|
|
203
203
|
log.debug(`Fetched ${result?.length || 0} events`, this.exportConfig?.context );
|
|
@@ -213,7 +213,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
async getAudiences(): Promise<AudienceStruct[] | void> {
|
|
216
|
-
log.debug('Fetching audiences from
|
|
216
|
+
log.debug('Fetching audiences from Personalize API...', this.exportConfig?.context );
|
|
217
217
|
const data = await this.apiClient.get<AudienceStruct>('/audiences');
|
|
218
218
|
const result = (await this.handleVariantAPIRes(data)) as AudienceStruct[];
|
|
219
219
|
log.debug(`Fetched ${result?.length || 0} audiences`, this.exportConfig?.context );
|
|
@@ -221,7 +221,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
async getAttributes(): Promise<AttributeStruct[] | void> {
|
|
224
|
-
log.debug('Fetching attributes from
|
|
224
|
+
log.debug('Fetching attributes from Personalize API...', this.exportConfig?.context );
|
|
225
225
|
const data = await this.apiClient.get<AttributeStruct>('/attributes');
|
|
226
226
|
const result = (await this.handleVariantAPIRes(data)) as AttributeStruct[];
|
|
227
227
|
log.info(`Fetched ${result?.length || 0} attributes`, this.exportConfig?.context );
|
|
@@ -302,7 +302,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
|
|
|
302
302
|
log.debug(`API response status: ${status}`, this.exportConfig?.context );
|
|
303
303
|
|
|
304
304
|
if (status >= 200 && status < 300) {
|
|
305
|
-
log.debug('API request successful', this.exportConfig?.context );
|
|
305
|
+
log.debug('API request successful.', this.exportConfig?.context );
|
|
306
306
|
return data;
|
|
307
307
|
}
|
|
308
308
|
|
|
@@ -51,10 +51,10 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
|
|
|
51
51
|
this.exportConfig?.context,
|
|
52
52
|
);
|
|
53
53
|
if (authenticationHandler.isOauthEnabled) {
|
|
54
|
-
log.debug('Setting OAuth authorization header', this.exportConfig?.context);
|
|
54
|
+
log.debug('Setting OAuth authorization header...', this.exportConfig?.context);
|
|
55
55
|
this.apiClient.headers({ authorization: token });
|
|
56
56
|
} else {
|
|
57
|
-
log.debug('Setting authtoken header', this.exportConfig?.context);
|
|
57
|
+
log.debug('Setting authtoken header...', this.exportConfig?.context);
|
|
58
58
|
this.apiClient.headers({ authtoken: token });
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -107,7 +107,7 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
|
|
|
107
107
|
);
|
|
108
108
|
|
|
109
109
|
if (variantConfig.serveMockData && callback) {
|
|
110
|
-
log.debug('Using mock data for variant entries', this.exportConfig?.context);
|
|
110
|
+
log.debug('Using mock data for variant entries...', this.exportConfig?.context);
|
|
111
111
|
let data = [] as Record<string, any>[];
|
|
112
112
|
|
|
113
113
|
if (existsSync(variantConfig.mockDataPath)) {
|
|
@@ -172,10 +172,10 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
if (callback) {
|
|
175
|
-
log.debug('Executing callback with variant entries', this.exportConfig?.context);
|
|
175
|
+
log.debug('Executing callback with variant entries...', this.exportConfig?.context);
|
|
176
176
|
callback(response.entries);
|
|
177
177
|
} else {
|
|
178
|
-
log.debug('Adding variant entries to collection', this.exportConfig?.context);
|
|
178
|
+
log.debug('Adding variant entries to collection...', this.exportConfig?.context);
|
|
179
179
|
entries = entries.concat(response.entries);
|
|
180
180
|
}
|
|
181
181
|
|
|
@@ -198,7 +198,7 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
if (returnResult) {
|
|
201
|
-
log.debug('Returning variant entries result', this.exportConfig?.context );
|
|
201
|
+
log.debug('Returning variant entries result...', this.exportConfig?.context );
|
|
202
202
|
return { entries };
|
|
203
203
|
}
|
|
204
204
|
}
|
|
@@ -327,7 +327,7 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
|
|
|
327
327
|
log.debug(`API response status: ${status}`, this.exportConfig?.context);
|
|
328
328
|
|
|
329
329
|
if (status >= 200 && status < 300) {
|
|
330
|
-
log.debug('API request successful', this.exportConfig?.context);
|
|
330
|
+
log.debug('API request successful.', this.exportConfig?.context);
|
|
331
331
|
return data;
|
|
332
332
|
}
|
|
333
333
|
|
|
@@ -401,17 +401,17 @@ export class VariantAdapter<T> {
|
|
|
401
401
|
log.debug('Initializing VariantAdapter...', this.exportConfig?.context);
|
|
402
402
|
|
|
403
403
|
if (config.httpClient) {
|
|
404
|
-
log.debug('Using HTTP client variant instance', this.exportConfig?.context);
|
|
404
|
+
log.debug('Using HTTP client variant instance.', this.exportConfig?.context);
|
|
405
405
|
const { httpClient, Adapter, ...restConfig } = config;
|
|
406
406
|
this.variantInstance = new Adapter(restConfig, options);
|
|
407
407
|
} else {
|
|
408
|
-
log.debug('Using SDK variant instance', this.exportConfig?.context);
|
|
408
|
+
log.debug('Using SDK variant instance.', this.exportConfig?.context);
|
|
409
409
|
const { Adapter, ...restConfig } = config;
|
|
410
410
|
this.variantInstance = new Adapter(restConfig);
|
|
411
411
|
}
|
|
412
412
|
|
|
413
413
|
this.messages = messages;
|
|
414
|
-
log.debug('VariantAdapter initialized successfully', this.exportConfig?.context);
|
|
414
|
+
log.debug('VariantAdapter initialized successfully.', this.exportConfig?.context);
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
417
|
|