@contentstack/cli-variants 1.2.0 → 1.2.1

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.
@@ -226,6 +226,7 @@ class Experiences extends utils_1.PersonalizationAdapter {
226
226
  }
227
227
  }
228
228
  catch (error) {
229
+ this.log(this.config, `Error while validating variant group and variants creation:`, 'error');
229
230
  throw error;
230
231
  }
231
232
  });
@@ -95,14 +95,22 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
95
95
  }
96
96
  getExperience(experienceUid) {
97
97
  return __awaiter(this, void 0, void 0, function* () {
98
+ var _a, _b, _c, _d;
98
99
  const getExperiencesEndPoint = `/experiences/${experienceUid}`;
100
+ if ((_b = (_a = this.apiClient).requestConfig) === null || _b === void 0 ? void 0 : _b.call(_a).data) {
101
+ (_d = (_c = this.apiClient).requestConfig) === null || _d === void 0 ? true : delete _d.call(_c).data; // explicitly prevent any accidental body
102
+ }
99
103
  const data = yield this.apiClient.get(getExperiencesEndPoint);
100
104
  return (yield this.handleVariantAPIRes(data));
101
105
  });
102
106
  }
103
107
  getExperienceVersions(experienceUid) {
104
108
  return __awaiter(this, void 0, void 0, function* () {
109
+ var _a, _b, _c, _d;
105
110
  const getExperiencesVersionsEndPoint = `/experiences/${experienceUid}/versions`;
111
+ if ((_b = (_a = this.apiClient).requestConfig) === null || _b === void 0 ? void 0 : _b.call(_a).data) {
112
+ (_d = (_c = this.apiClient).requestConfig) === null || _d === void 0 ? true : delete _d.call(_c).data; // explicitly prevent any accidental body
113
+ }
106
114
  const data = yield this.apiClient.get(getExperiencesVersionsEndPoint);
107
115
  return (yield this.handleVariantAPIRes(data));
108
116
  });
@@ -240,10 +248,7 @@ class PersonalizationAdapter extends adapter_helper_1.AdapterHelper {
240
248
  yield cli_utilities_1.authenticationHandler.refreshAccessToken(res);
241
249
  const errorMsg = (data === null || data === void 0 ? void 0 : data.errors)
242
250
  ? (0, error_helper_1.formatErrors)(data.errors)
243
- : (data === null || data === void 0 ? void 0 : data.error) ||
244
- (data === null || data === void 0 ? void 0 : data.error_message) ||
245
- (data === null || data === void 0 ? void 0 : data.message) ||
246
- 'Something went wrong while processing variant entries request!';
251
+ : (data === null || data === void 0 ? void 0 : data.error) || (data === null || data === void 0 ? void 0 : data.error_message) || (data === null || data === void 0 ? void 0 : data.message) || data;
247
252
  throw errorMsg;
248
253
  });
249
254
  }
@@ -226,7 +226,7 @@ class VariantHttpClient extends adapter_helper_1.AdapterHelper {
226
226
  yield cli_utilities_1.authenticationHandler.refreshAccessToken(res);
227
227
  const errorMsg = (data === null || data === void 0 ? void 0 : data.errors)
228
228
  ? (0, error_helper_1.formatErrors)(data.errors)
229
- : (data === null || data === void 0 ? void 0 : data.error_message) || (data === null || data === void 0 ? void 0 : data.message) || 'Something went wrong while processing entry variant request!';
229
+ : (data === null || data === void 0 ? void 0 : data.error_message) || (data === null || data === void 0 ? void 0 : data.message) || data;
230
230
  throw errorMsg;
231
231
  });
232
232
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/cli-variants",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Variants plugin",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -266,6 +266,7 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
266
266
  return true;
267
267
  }
268
268
  } catch (error) {
269
+ this.log(this.config, `Error while validating variant group and variants creation:`, 'error');
269
270
  throw error;
270
271
  }
271
272
  }
@@ -36,12 +36,12 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
36
36
  const token = authenticationHandler.accessToken;
37
37
  if (authenticationHandler.isOauthEnabled) {
38
38
  this.apiClient.headers({ authorization: token });
39
- if(this.adapterConfig.cmaConfig) {
39
+ if (this.adapterConfig.cmaConfig) {
40
40
  this.cmaAPIClient?.headers({ authorization: token });
41
41
  }
42
42
  } else {
43
43
  this.apiClient.headers({ authtoken: token });
44
- if(this.adapterConfig.cmaConfig) {
44
+ if (this.adapterConfig.cmaConfig) {
45
45
  this.cmaAPIClient?.headers({ authtoken: token });
46
46
  }
47
47
  }
@@ -91,12 +91,18 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
91
91
 
92
92
  async getExperience(experienceUid: string): Promise<ExperienceStruct | void> {
93
93
  const getExperiencesEndPoint = `/experiences/${experienceUid}`;
94
+ if (this.apiClient.requestConfig?.().data) {
95
+ delete this.apiClient.requestConfig?.().data; // explicitly prevent any accidental body
96
+ }
94
97
  const data = await this.apiClient.get(getExperiencesEndPoint);
95
98
  return (await this.handleVariantAPIRes(data)) as ExperienceStruct;
96
99
  }
97
100
 
98
101
  async getExperienceVersions(experienceUid: string): Promise<ExperienceStruct | void> {
99
102
  const getExperiencesVersionsEndPoint = `/experiences/${experienceUid}/versions`;
103
+ if (this.apiClient.requestConfig?.().data) {
104
+ delete this.apiClient.requestConfig?.().data; // explicitly prevent any accidental body
105
+ }
100
106
  const data = await this.apiClient.get(getExperiencesVersionsEndPoint);
101
107
  return (await this.handleVariantAPIRes(data)) as ExperienceStruct;
102
108
  }
@@ -231,11 +237,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
231
237
 
232
238
  const errorMsg = data?.errors
233
239
  ? formatErrors(data.errors)
234
- : data?.error ||
235
- data?.error_message ||
236
- data?.message ||
237
- 'Something went wrong while processing variant entries request!';
238
-
240
+ : data?.error || data?.error_message || data?.message || data;
239
241
  throw errorMsg;
240
242
  }
241
243
  }
@@ -270,7 +270,7 @@ export class VariantHttpClient<C> extends AdapterHelper<C, HttpClient> implement
270
270
 
271
271
  const errorMsg = data?.errors
272
272
  ? formatErrors(data.errors)
273
- : data?.error_message || data?.message || 'Something went wrong while processing entry variant request!';
273
+ : data?.error_message || data?.message || data;
274
274
 
275
275
  throw errorMsg;
276
276
  }