@contentstack/cli-variants 1.3.2 → 2.0.0-beta

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.
Files changed (55) hide show
  1. package/lib/export/attributes.d.ts +2 -2
  2. package/lib/export/attributes.js +51 -23
  3. package/lib/export/audiences.d.ts +2 -2
  4. package/lib/export/audiences.js +50 -24
  5. package/lib/export/events.d.ts +2 -2
  6. package/lib/export/events.js +52 -24
  7. package/lib/export/experiences.js +87 -54
  8. package/lib/export/projects.d.ts +3 -2
  9. package/lib/export/projects.js +55 -63
  10. package/lib/export/variant-entries.d.ts +19 -0
  11. package/lib/export/variant-entries.js +76 -1
  12. package/lib/import/attribute.d.ts +2 -0
  13. package/lib/import/attribute.js +83 -37
  14. package/lib/import/audiences.d.ts +2 -0
  15. package/lib/import/audiences.js +85 -41
  16. package/lib/import/events.d.ts +3 -1
  17. package/lib/import/events.js +86 -30
  18. package/lib/import/experiences.d.ts +2 -0
  19. package/lib/import/experiences.js +93 -39
  20. package/lib/import/project.d.ts +2 -0
  21. package/lib/import/project.js +81 -22
  22. package/lib/import/variant-entries.d.ts +10 -0
  23. package/lib/import/variant-entries.js +139 -53
  24. package/lib/index.d.ts +1 -0
  25. package/lib/index.js +1 -0
  26. package/lib/types/export-config.d.ts +0 -2
  27. package/lib/types/import-config.d.ts +0 -1
  28. package/lib/types/utils.d.ts +1 -1
  29. package/lib/utils/constants.d.ts +91 -0
  30. package/lib/utils/constants.js +93 -0
  31. package/lib/utils/personalization-api-adapter.d.ts +34 -1
  32. package/lib/utils/personalization-api-adapter.js +180 -53
  33. package/lib/utils/variant-api-adapter.d.ts +28 -1
  34. package/lib/utils/variant-api-adapter.js +89 -32
  35. package/package.json +2 -2
  36. package/src/export/attributes.ts +84 -34
  37. package/src/export/audiences.ts +87 -41
  38. package/src/export/events.ts +84 -41
  39. package/src/export/experiences.ts +155 -83
  40. package/src/export/projects.ts +71 -39
  41. package/src/export/variant-entries.ts +136 -12
  42. package/src/import/attribute.ts +105 -49
  43. package/src/import/audiences.ts +110 -54
  44. package/src/import/events.ts +104 -41
  45. package/src/import/experiences.ts +140 -62
  46. package/src/import/project.ts +108 -38
  47. package/src/import/variant-entries.ts +188 -75
  48. package/src/index.ts +2 -1
  49. package/src/types/export-config.ts +0 -2
  50. package/src/types/import-config.ts +0 -1
  51. package/src/types/utils.ts +1 -1
  52. package/src/utils/constants.ts +98 -0
  53. package/src/utils/personalization-api-adapter.ts +212 -76
  54. package/src/utils/variant-api-adapter.ts +137 -50
  55. package/tsconfig.json +1 -1
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IMPORT_PROCESS_STATUS = exports.EXPORT_PROCESS_STATUS = exports.MODULE_CONTEXTS = exports.MODULE_DISPLAY_MAPPER = exports.PROCESS_NAMES = void 0;
4
+ exports.PROCESS_NAMES = {
5
+ PROJECTS: 'Projects',
6
+ ATTRIBUTES: 'Attributes',
7
+ AUDIENCES: 'Audiences',
8
+ EVENTS: 'Events',
9
+ EXPERIENCES: 'Experiences',
10
+ VARIANT_ENTRIES: 'Variant Entries',
11
+ };
12
+ exports.MODULE_DISPLAY_MAPPER = {
13
+ events: exports.PROCESS_NAMES.EVENTS,
14
+ attributes: exports.PROCESS_NAMES.ATTRIBUTES,
15
+ audiences: exports.PROCESS_NAMES.AUDIENCES,
16
+ experiences: exports.PROCESS_NAMES.EXPERIENCES,
17
+ projects: exports.PROCESS_NAMES.PROJECTS,
18
+ 'variant-entries': exports.PROCESS_NAMES.VARIANT_ENTRIES,
19
+ };
20
+ exports.MODULE_CONTEXTS = {
21
+ PROJECTS: 'projects',
22
+ ATTRIBUTES: 'attributes',
23
+ AUDIENCES: 'audiences',
24
+ EVENTS: 'events',
25
+ EXPERIENCES: 'experiences',
26
+ VARIANT_ENTRIES: 'variant-entries',
27
+ };
28
+ // Export process status messages
29
+ exports.EXPORT_PROCESS_STATUS = {
30
+ [exports.PROCESS_NAMES.PROJECTS]: {
31
+ FETCHING: 'Fetching projects...',
32
+ EXPORTING: 'Exporting projects...',
33
+ FAILED: 'Failed to export projects.',
34
+ },
35
+ [exports.PROCESS_NAMES.ATTRIBUTES]: {
36
+ FETCHING: 'Fetching attributes...',
37
+ EXPORTING: 'Exporting attributes...',
38
+ FAILED: 'Failed to export attributes.',
39
+ },
40
+ [exports.PROCESS_NAMES.AUDIENCES]: {
41
+ FETCHING: 'Fetching audiences...',
42
+ EXPORTING: 'Exporting audiences...',
43
+ FAILED: 'Failed to export audiences.',
44
+ },
45
+ [exports.PROCESS_NAMES.EVENTS]: {
46
+ FETCHING: 'Fetching events...',
47
+ EXPORTING: 'Exporting events...',
48
+ FAILED: 'Failed to export events.',
49
+ },
50
+ [exports.PROCESS_NAMES.EXPERIENCES]: {
51
+ FETCHING: 'Fetching experiences...',
52
+ EXPORTING: 'Exporting experiences...',
53
+ FAILED: 'Failed to export experiences.',
54
+ },
55
+ [exports.PROCESS_NAMES.VARIANT_ENTRIES]: {
56
+ PROCESSING: 'Processing variant entries...',
57
+ EXPORTING: 'Exporting variant entries...',
58
+ FAILED: 'Failed to export variant entries.',
59
+ },
60
+ };
61
+ // Import process status messages
62
+ exports.IMPORT_PROCESS_STATUS = {
63
+ [exports.PROCESS_NAMES.PROJECTS]: {
64
+ CREATING: 'Creating projects...',
65
+ IMPORTING: 'Importing projects...',
66
+ FAILED: 'Failed to import projects.',
67
+ },
68
+ [exports.PROCESS_NAMES.ATTRIBUTES]: {
69
+ CREATING: 'Creating attributes...',
70
+ IMPORTING: 'Importing attributes...',
71
+ FAILED: 'Failed to import attributes.',
72
+ },
73
+ [exports.PROCESS_NAMES.AUDIENCES]: {
74
+ CREATING: 'Creating audiences...',
75
+ IMPORTING: 'Importing audiences...',
76
+ FAILED: 'Failed to import audiences.',
77
+ },
78
+ [exports.PROCESS_NAMES.EVENTS]: {
79
+ CREATING: 'Creating events...',
80
+ IMPORTING: 'Importing events...',
81
+ FAILED: 'Failed to import events.',
82
+ },
83
+ [exports.PROCESS_NAMES.EXPERIENCES]: {
84
+ CREATING: 'Creating experiences...',
85
+ IMPORTING: 'Importing experiences...',
86
+ FAILED: 'Failed to import experiences.',
87
+ },
88
+ [exports.PROCESS_NAMES.VARIANT_ENTRIES]: {
89
+ PROCESSING: 'Processing variant entries...',
90
+ IMPORTING: 'Importing variant entries...',
91
+ FAILED: 'Failed to import variant entries.',
92
+ },
93
+ };
@@ -1,9 +1,42 @@
1
1
  import { AdapterHelper } from './adapter-helper';
2
- import { HttpClient } from '@contentstack/cli-utilities';
2
+ import { HttpClient, CLIProgressManager } from '@contentstack/cli-utilities';
3
3
  import { ProjectStruct, Personalization, GetProjectsParams, CreateProjectInput, CreateAttributeInput, APIConfig, GetVariantGroupInput, EventStruct, AudienceStruct, AttributeStruct, CreateAudienceInput, CreateEventInput, CreateExperienceInput, ExperienceStruct, UpdateExperienceInput, CMSExperienceStruct, VariantAPIRes, APIResponse, VariantGroupStruct, VariantGroup, CreateExperienceVersionInput, ExportConfig } from '../types';
4
4
  export declare class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> implements Personalization<T> {
5
5
  exportConfig?: ExportConfig;
6
+ protected progressManager: CLIProgressManager | null;
7
+ protected parentProgressManager: CLIProgressManager | null;
8
+ protected currentModuleName: string;
9
+ protected cachedData: any[] | null;
6
10
  constructor(options: APIConfig);
11
+ /**
12
+ * Set parent progress manager for sub-module integration
13
+ */
14
+ setParentProgressManager(parentProgress: CLIProgressManager): void;
15
+ /**
16
+ * Set cached data to avoid redundant API calls
17
+ */
18
+ setCachedData(data: any[]): void;
19
+ /**
20
+ * Create simple progress manager for single process tracking
21
+ */
22
+ protected createSimpleProgress(moduleName: string, total?: number): CLIProgressManager;
23
+ /**
24
+ * Create nested progress manager for multi-process tracking
25
+ */
26
+ protected createNestedProgress(moduleName: string): CLIProgressManager;
27
+ /**
28
+ * Complete progress manager
29
+ */
30
+ protected completeProgress(success?: boolean, error?: string): void;
31
+ /**
32
+ * Execute action with loading spinner for initial setup tasks
33
+ */
34
+ protected withLoadingSpinner<T>(message: string, action: () => Promise<T>): Promise<T>;
35
+ /**
36
+ * Update progress for a specific item
37
+ */
38
+ protected updateProgress(success: boolean, itemName: string, error?: string, processName?: string): void;
39
+ static printFinalSummary(): void;
7
40
  init(): Promise<void>;
8
41
  projects(options: GetProjectsParams): Promise<ProjectStruct[]>;
9
42
  /**
@@ -28,45 +28,149 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
28
28
  constructor(options) {
29
29
  var _a;
30
30
  super(options);
31
+ this.progressManager = null;
32
+ this.parentProgressManager = null; // Add parent progress manager
33
+ this.currentModuleName = '';
34
+ this.cachedData = null; // Add cached data property
31
35
  cli_utilities_1.log.debug('PersonalizationAdapter initialized', (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
32
36
  }
37
+ /**
38
+ * Set parent progress manager for sub-module integration
39
+ */
40
+ setParentProgressManager(parentProgress) {
41
+ this.parentProgressManager = parentProgress;
42
+ }
43
+ /**
44
+ * Set cached data to avoid redundant API calls
45
+ */
46
+ setCachedData(data) {
47
+ var _a;
48
+ this.cachedData = data;
49
+ cli_utilities_1.log.debug(`Cached data set with ${(data === null || data === void 0 ? void 0 : data.length) || 0} items`, (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
50
+ }
51
+ /**
52
+ * Create simple progress manager for single process tracking
53
+ */
54
+ createSimpleProgress(moduleName, total) {
55
+ var _a;
56
+ this.currentModuleName = moduleName;
57
+ // If we have a parent progress manager, use it instead of creating a new one
58
+ if (this.parentProgressManager) {
59
+ this.progressManager = this.parentProgressManager;
60
+ return this.progressManager;
61
+ }
62
+ const logConfig = cli_utilities_1.configHandler.get('log') || {};
63
+ const showConsoleLogs = (_a = logConfig.showConsoleLogs) !== null && _a !== void 0 ? _a : false;
64
+ this.progressManager = cli_utilities_1.CLIProgressManager.createSimple(moduleName, total, showConsoleLogs);
65
+ return this.progressManager;
66
+ }
67
+ /**
68
+ * Create nested progress manager for multi-process tracking
69
+ */
70
+ createNestedProgress(moduleName) {
71
+ var _a;
72
+ this.currentModuleName = moduleName;
73
+ // If we have a parent progress manager, use it instead of creating a new one
74
+ if (this.parentProgressManager) {
75
+ this.progressManager = this.parentProgressManager;
76
+ return this.progressManager;
77
+ }
78
+ const logConfig = cli_utilities_1.configHandler.get('log') || {};
79
+ const showConsoleLogs = (_a = logConfig.showConsoleLogs) !== null && _a !== void 0 ? _a : false;
80
+ this.progressManager = cli_utilities_1.CLIProgressManager.createNested(moduleName, showConsoleLogs);
81
+ return this.progressManager;
82
+ }
83
+ /**
84
+ * Complete progress manager
85
+ */
86
+ completeProgress(success = true, error) {
87
+ var _a;
88
+ // Only complete progress if we own the progress manager (no parent)
89
+ if (!this.parentProgressManager) {
90
+ (_a = this.progressManager) === null || _a === void 0 ? void 0 : _a.complete(success, error);
91
+ }
92
+ this.progressManager = null;
93
+ }
94
+ /**
95
+ * Execute action with loading spinner for initial setup tasks
96
+ */
97
+ withLoadingSpinner(message, action) {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ var _a;
100
+ const logConfig = cli_utilities_1.configHandler.get('log') || {};
101
+ const showConsoleLogs = (_a = logConfig.showConsoleLogs) !== null && _a !== void 0 ? _a : false;
102
+ if (showConsoleLogs) {
103
+ // If console logs are enabled, don't show spinner, just execute the action
104
+ return yield action();
105
+ }
106
+ return yield cli_utilities_1.CLIProgressManager.withLoadingSpinner(message, action);
107
+ });
108
+ }
109
+ /**
110
+ * Update progress for a specific item
111
+ */
112
+ updateProgress(success, itemName, error, processName) {
113
+ if (this.parentProgressManager) {
114
+ this.parentProgressManager.tick(success, itemName, error, processName);
115
+ }
116
+ else if (this.progressManager) {
117
+ this.progressManager.tick(success, itemName, error, processName);
118
+ }
119
+ }
120
+ static printFinalSummary() {
121
+ cli_utilities_1.CLIProgressManager.printGlobalSummary();
122
+ }
33
123
  init() {
34
124
  return __awaiter(this, void 0, void 0, function* () {
35
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
36
- cli_utilities_1.log.debug('Initializing personalization adapter...', (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
37
- yield cli_utilities_1.authenticationHandler.getAuthDetails();
38
- const token = cli_utilities_1.authenticationHandler.accessToken;
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
- 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);
42
- this.apiClient.headers({ authorization: token });
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);
45
- (_e = this.cmaAPIClient) === null || _e === void 0 ? void 0 : _e.headers({ authorization: token });
125
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
126
+ try {
127
+ cli_utilities_1.log.debug('Initializing personalization adapter...', (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
128
+ yield cli_utilities_1.authenticationHandler.getAuthDetails();
129
+ const token = cli_utilities_1.authenticationHandler.accessToken;
130
+ 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);
131
+ if (cli_utilities_1.authenticationHandler.isOauthEnabled) {
132
+ cli_utilities_1.log.debug('Setting OAuth authorization header', (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
133
+ this.apiClient.headers({ authorization: token });
134
+ if (this.adapterConfig.cmaConfig) {
135
+ cli_utilities_1.log.debug('Setting OAuth authorization header for CMA client', (_d = this.exportConfig) === null || _d === void 0 ? void 0 : _d.context);
136
+ (_e = this.cmaAPIClient) === null || _e === void 0 ? void 0 : _e.headers({ authorization: token });
137
+ }
46
138
  }
47
- }
48
- else {
49
- cli_utilities_1.log.debug('Setting authtoken header', (_f = this.exportConfig) === null || _f === void 0 ? void 0 : _f.context);
50
- this.apiClient.headers({ authtoken: token });
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);
53
- (_h = this.cmaAPIClient) === null || _h === void 0 ? void 0 : _h.headers({ authtoken: token });
139
+ else {
140
+ cli_utilities_1.log.debug('Setting authtoken header', (_f = this.exportConfig) === null || _f === void 0 ? void 0 : _f.context);
141
+ this.apiClient.headers({ authtoken: token });
142
+ if (this.adapterConfig.cmaConfig) {
143
+ cli_utilities_1.log.debug('Setting authtoken header for CMA client', (_g = this.exportConfig) === null || _g === void 0 ? void 0 : _g.context);
144
+ (_h = this.cmaAPIClient) === null || _h === void 0 ? void 0 : _h.headers({ authtoken: token });
145
+ }
54
146
  }
147
+ cli_utilities_1.log.debug('Personalization adapter initialization completed', (_j = this.exportConfig) === null || _j === void 0 ? void 0 : _j.context);
148
+ }
149
+ catch (error) {
150
+ cli_utilities_1.log.debug(`Personalization adapter initialization failed: ${error}`, (_k = this.exportConfig) === null || _k === void 0 ? void 0 : _k.context);
55
151
  }
56
- cli_utilities_1.log.debug('Personalization adapter initialization completed', (_j = this.exportConfig) === null || _j === void 0 ? void 0 : _j.context);
57
152
  });
58
153
  }
59
154
  projects(options) {
60
155
  return __awaiter(this, void 0, void 0, function* () {
61
156
  var _a, _b, _c;
62
- cli_utilities_1.log.debug(`Fetching projects for stack API key: ${options.connectedStackApiKey}`, (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
63
157
  yield this.init();
64
158
  const getProjectEndPoint = `/projects?connectedStackApiKey=${options.connectedStackApiKey}`;
65
- cli_utilities_1.log.debug(`Making API call to: ${getProjectEndPoint}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
66
- const data = yield this.apiClient.get(getProjectEndPoint);
67
- const result = (yield this.handleVariantAPIRes(data));
68
- cli_utilities_1.log.debug(`Fetched ${(result === null || result === void 0 ? void 0 : result.length) || 0} projects`, (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
69
- return result;
159
+ cli_utilities_1.log.debug(`Making API call to: ${getProjectEndPoint}`, (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
160
+ try {
161
+ const data = yield this.apiClient.get(getProjectEndPoint);
162
+ const result = (yield this.handleVariantAPIRes(data));
163
+ cli_utilities_1.log.debug(`Fetched ${(result === null || result === void 0 ? void 0 : result.length) || 0} projects`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
164
+ // Update progress for each project fetched
165
+ result === null || result === void 0 ? void 0 : result.forEach((project) => {
166
+ this.updateProgress(true, `project: ${project.name || project.uid}`, undefined, 'Projects');
167
+ });
168
+ return result;
169
+ }
170
+ catch (error) {
171
+ cli_utilities_1.log.debug(`Failed to fetch projects: ${error}`, (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
172
+ throw error;
173
+ }
70
174
  });
71
175
  }
72
176
  /**
@@ -85,7 +189,7 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
85
189
  cli_utilities_1.log.debug(`Creating project: ${project.name}`, (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
86
190
  const data = yield this.apiClient.post('/projects', project);
87
191
  const result = (yield this.handleVariantAPIRes(data));
88
- cli_utilities_1.log.debug(`Project created successfully: ${result.uid}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
192
+ cli_utilities_1.log.info(`Project created successfully: ${result === null || result === void 0 ? void 0 : result.uid}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
89
193
  return result;
90
194
  });
91
195
  }
@@ -104,19 +208,29 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
104
208
  cli_utilities_1.log.debug(`Creating attribute: ${attribute.name}`, (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
105
209
  const data = yield this.apiClient.post('/attributes', attribute);
106
210
  const result = (yield this.handleVariantAPIRes(data));
107
- cli_utilities_1.log.debug(`Attribute created successfully: ${result.uid}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
211
+ cli_utilities_1.log.info(`Attribute created successfully: ${(result === null || result === void 0 ? void 0 : result.name) || (result === null || result === void 0 ? void 0 : result.uid)}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
108
212
  return result;
109
213
  });
110
214
  }
111
215
  getExperiences() {
112
216
  return __awaiter(this, void 0, void 0, function* () {
113
- var _a, _b;
217
+ var _a, _b, _c;
114
218
  cli_utilities_1.log.debug('Fetching experiences from personalization API', (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
115
219
  const getExperiencesEndPoint = `/experiences`;
116
- const data = yield this.apiClient.get(getExperiencesEndPoint);
117
- const result = (yield this.handleVariantAPIRes(data));
118
- cli_utilities_1.log.debug(`Fetched ${(result === null || result === void 0 ? void 0 : result.length) || 0} experiences`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
119
- return result;
220
+ try {
221
+ const data = yield this.apiClient.get(getExperiencesEndPoint);
222
+ const result = (yield this.handleVariantAPIRes(data));
223
+ cli_utilities_1.log.debug(`Fetched ${(result === null || result === void 0 ? void 0 : result.length) || 0} experiences`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
224
+ // Update progress for each experience fetched
225
+ result === null || result === void 0 ? void 0 : result.forEach((experience) => {
226
+ this.updateProgress(true, `experience: ${experience.name || experience.uid}`, undefined, 'Experiences');
227
+ });
228
+ return result;
229
+ }
230
+ catch (error) {
231
+ cli_utilities_1.log.debug(`Failed to fetch experiences: ${error}`, (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
232
+ throw error;
233
+ }
120
234
  });
121
235
  }
122
236
  getExperience(experienceUid) {
@@ -143,7 +257,7 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
143
257
  }
144
258
  const data = yield this.apiClient.get(getExperiencesVersionsEndPoint);
145
259
  const result = (yield this.handleVariantAPIRes(data));
146
- cli_utilities_1.log.debug(`Experience versions fetched successfully for: ${experienceUid}`, (_f = this.exportConfig) === null || _f === void 0 ? void 0 : _f.context);
260
+ cli_utilities_1.log.info(`Experience versions fetched successfully for: ${experienceUid}`, (_f = this.exportConfig) === null || _f === void 0 ? void 0 : _f.context);
147
261
  return result;
148
262
  });
149
263
  }
@@ -187,7 +301,7 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
187
301
  .queryParams({ experience_uid: input.experienceUid })
188
302
  .get(getVariantGroupEndPoint);
189
303
  const result = (yield this.handleVariantAPIRes(data));
190
- cli_utilities_1.log.debug(`Variant group fetched successfully for experience: ${input.experienceUid}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
304
+ cli_utilities_1.log.debug(`Variant group fetched successfully for experience: ${input === null || input === void 0 ? void 0 : input.experienceUid}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
191
305
  return result;
192
306
  }
193
307
  else {
@@ -203,7 +317,7 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
203
317
  const updateVariantGroupEndPoint = `/variant_groups/${input.uid}`;
204
318
  const data = yield this.cmaAPIClient.put(updateVariantGroupEndPoint, input);
205
319
  const result = (yield this.handleVariantAPIRes(data));
206
- cli_utilities_1.log.debug(`Variant group updated successfully: ${input.uid}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
320
+ cli_utilities_1.log.debug(`Variant group updated successfully: ${input === null || input === void 0 ? void 0 : input.uid}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
207
321
  return result;
208
322
  }
209
323
  else {
@@ -213,32 +327,45 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
213
327
  }
214
328
  getEvents() {
215
329
  return __awaiter(this, void 0, void 0, function* () {
216
- var _a, _b;
330
+ var _a, _b, _c;
217
331
  cli_utilities_1.log.debug('Fetching events from personalization API', (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
218
- const data = yield this.apiClient.get('/events');
219
- const result = (yield this.handleVariantAPIRes(data));
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);
221
- return result;
332
+ try {
333
+ const data = yield this.apiClient.get('/events');
334
+ const result = (yield this.handleVariantAPIRes(data));
335
+ 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);
336
+ return result;
337
+ }
338
+ catch (error) {
339
+ cli_utilities_1.log.debug(`Failed to fetch events: ${error}`, (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
340
+ // Return empty array instead of throwing to prevent spinner from hanging
341
+ throw error;
342
+ }
222
343
  });
223
344
  }
224
345
  createEvents(event) {
225
346
  return __awaiter(this, void 0, void 0, function* () {
226
- var _a, _b;
227
- cli_utilities_1.log.debug(`Creating event: ${event.key}`, (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
347
+ var _a;
228
348
  const data = yield this.apiClient.post('/events', event);
229
349
  const result = (yield this.handleVariantAPIRes(data));
230
- cli_utilities_1.log.debug(`Event created successfully: ${result.uid}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
350
+ cli_utilities_1.log.info(`Event created successfully: ${result === null || result === void 0 ? void 0 : result.uid}`, (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
231
351
  return result;
232
352
  });
233
353
  }
234
354
  getAudiences() {
235
355
  return __awaiter(this, void 0, void 0, function* () {
236
- var _a, _b;
356
+ var _a, _b, _c;
237
357
  cli_utilities_1.log.debug('Fetching audiences from personalization API', (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
238
- const data = yield this.apiClient.get('/audiences');
239
- const result = (yield this.handleVariantAPIRes(data));
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);
241
- return result;
358
+ try {
359
+ const data = yield this.apiClient.get('/audiences');
360
+ const result = (yield this.handleVariantAPIRes(data));
361
+ 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);
362
+ return result;
363
+ }
364
+ catch (error) {
365
+ cli_utilities_1.log.debug(`Failed to fetch audiences: ${error}`, (_c = this.exportConfig) === null || _c === void 0 ? void 0 : _c.context);
366
+ // Return empty array instead of throwing to prevent spinner from hanging
367
+ throw error;
368
+ }
242
369
  });
243
370
  }
244
371
  getAttributes() {
@@ -247,7 +374,7 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
247
374
  cli_utilities_1.log.debug('Fetching attributes from personalization API', (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
248
375
  const data = yield this.apiClient.get('/attributes');
249
376
  const result = (yield this.handleVariantAPIRes(data));
250
- cli_utilities_1.log.debug(`Fetched ${(result === null || result === void 0 ? void 0 : result.length) || 0} attributes`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
377
+ 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);
251
378
  return result;
252
379
  });
253
380
  }
@@ -265,7 +392,7 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
265
392
  cli_utilities_1.log.debug(`Creating audience: ${audience.name}`, (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
266
393
  const data = yield this.apiClient.post('/audiences', audience);
267
394
  const result = (yield this.handleVariantAPIRes(data));
268
- cli_utilities_1.log.debug(`Audience created successfully: ${result.uid}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
395
+ cli_utilities_1.log.info(`Audience created successfully: ${(result === null || result === void 0 ? void 0 : result.name) || (result === null || result === void 0 ? void 0 : result.uid)}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
269
396
  return result;
270
397
  });
271
398
  }
@@ -283,7 +410,7 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
283
410
  cli_utilities_1.log.debug(`Creating experience: ${experience.name}`, (_a = this.exportConfig) === null || _a === void 0 ? void 0 : _a.context);
284
411
  const data = yield this.apiClient.post('/experiences', experience);
285
412
  const result = (yield this.handleVariantAPIRes(data));
286
- cli_utilities_1.log.debug(`Experience created successfully: ${result.uid}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
413
+ cli_utilities_1.log.info(`Experience created successfully: ${(result === null || result === void 0 ? void 0 : result.name) || (result === null || result === void 0 ? void 0 : result.uid)}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
287
414
  return result;
288
415
  });
289
416
  }
@@ -299,7 +426,7 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
299
426
  const updateCTInExpEndPoint = `/experiences/${experienceUid}/cms-integration/variant-group`;
300
427
  const data = yield this.apiClient.post(updateCTInExpEndPoint, experience);
301
428
  const result = (yield this.handleVariantAPIRes(data));
302
- cli_utilities_1.log.debug(`Content types updated successfully in experience: ${experienceUid}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
429
+ cli_utilities_1.log.info(`Content types updated successfully in experience: ${experienceUid}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
303
430
  return result;
304
431
  });
305
432
  }
@@ -315,7 +442,7 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
315
442
  const getCTFromExpEndPoint = `/experiences/${experienceUid}/cms-integration/variant-group`;
316
443
  const data = yield this.apiClient.get(getCTFromExpEndPoint);
317
444
  const result = (yield this.handleVariantAPIRes(data));
318
- cli_utilities_1.log.debug(`Content types fetched successfully from experience: ${experienceUid}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
445
+ cli_utilities_1.log.info(`Content types fetched successfully from experience: ${experienceUid}`, (_b = this.exportConfig) === null || _b === void 0 ? void 0 : _b.context);
319
446
  return result;
320
447
  });
321
448
  }
@@ -1,4 +1,4 @@
1
- import { HttpClient, HttpClientOptions, ContentstackClient, ContentstackConfig } from '@contentstack/cli-utilities';
1
+ import { HttpClient, HttpClientOptions, ContentstackClient, ContentstackConfig, CLIProgressManager } from '@contentstack/cli-utilities';
2
2
  import { APIConfig, AdapterType, AnyProperty, ExportConfig, VariantOptions, VariantsOption, VariantInterface, VariantEntryStruct, CreateVariantEntryDto, CreateVariantEntryOptions, APIResponse, PublishVariantEntryDto, PublishVariantEntryOptions } from '../types';
3
3
  import messages from '../messages';
4
4
  import { AdapterHelper } from './adapter-helper';
@@ -77,7 +77,34 @@ export declare class VariantAdapter<T> {
77
77
  protected variantInstance: T;
78
78
  readonly messages: typeof messages;
79
79
  exportConfig?: any;
80
+ protected progressManager: CLIProgressManager | null;
81
+ protected parentProgressManager: CLIProgressManager | null;
82
+ protected currentModuleName: string;
80
83
  constructor(config: ContentstackConfig & AnyProperty & AdapterType<T, ContentstackConfig>);
81
84
  constructor(config: APIConfig & AdapterType<T, APIConfig & AnyProperty>, options?: HttpClientOptions);
85
+ /**
86
+ * Set parent progress manager for sub-module integration
87
+ */
88
+ setParentProgressManager(parentProgress: CLIProgressManager): void;
89
+ /**
90
+ * Create simple progress manager for single process tracking
91
+ */
92
+ protected createSimpleProgress(moduleName: string, total?: number): CLIProgressManager;
93
+ /**
94
+ * Create nested progress manager for multi-process tracking
95
+ */
96
+ protected createNestedProgress(moduleName: string): CLIProgressManager;
97
+ /**
98
+ * Complete progress manager
99
+ */
100
+ protected completeProgress(success?: boolean, error?: string): void;
101
+ /**
102
+ * Execute action with loading spinner for initial setup tasks
103
+ */
104
+ protected withLoadingSpinner<T>(message: string, action: () => Promise<T>): Promise<T>;
105
+ /**
106
+ * Update progress for a specific item
107
+ */
108
+ protected updateProgress(success: boolean, itemName: string, error?: string, processName?: string): void;
82
109
  }
83
110
  export default VariantAdapter;