@contentstack/cli-variants 1.2.0 → 1.2.2
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/import/experiences.js +1 -0
- package/lib/utils/personalization-api-adapter.js +9 -4
- package/lib/utils/variant-api-adapter.js +1 -1
- package/package.json +5 -5
- package/src/import/experiences.ts +1 -0
- package/src/utils/personalization-api-adapter.ts +9 -7
- package/src/utils/variant-api-adapter.ts +1 -1
|
@@ -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) ||
|
|
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.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Variants plugin",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@contentstack/cli-dev-dependencies": "^1.3.0",
|
|
21
|
-
"@oclif/test": "^4.1.
|
|
22
|
-
"@types/node": "^20.17.
|
|
21
|
+
"@oclif/test": "^4.1.13",
|
|
22
|
+
"@types/node": "^20.17.50",
|
|
23
23
|
"mocha": "^10.8.2",
|
|
24
24
|
"nyc": "^15.1.0",
|
|
25
25
|
"ts-node": "^10.9.2",
|
|
26
|
-
"typescript": "^5.
|
|
26
|
+
"typescript": "^5.8.3"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@contentstack/cli-utilities": "~1.
|
|
29
|
+
"@contentstack/cli-utilities": "~1.12.0",
|
|
30
30
|
"lodash": "^4.17.21",
|
|
31
31
|
"mkdirp": "^1.0.4",
|
|
32
32
|
"winston": "^3.17.0"
|
|
@@ -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 ||
|
|
273
|
+
: data?.error_message || data?.message || data;
|
|
274
274
|
|
|
275
275
|
throw errorMsg;
|
|
276
276
|
}
|