@contentstack/mcp 0.5.0 → 0.5.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/dist/index.js +25 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import dotenv from "dotenv";
|
|
|
13
13
|
// package.json
|
|
14
14
|
var package_default = {
|
|
15
15
|
name: "@contentstack/mcp",
|
|
16
|
-
version: "0.5.
|
|
16
|
+
version: "0.5.2",
|
|
17
17
|
main: "./dist/index.js",
|
|
18
18
|
type: "module",
|
|
19
19
|
publishConfig: {
|
|
@@ -262,7 +262,7 @@ var ContentstackOAuthHandler = class _ContentstackOAuthHandler {
|
|
|
262
262
|
while (!exitProgram) {
|
|
263
263
|
const { action } = await inquirer.prompt([
|
|
264
264
|
{
|
|
265
|
-
type: "
|
|
265
|
+
type: "select",
|
|
266
266
|
name: "action",
|
|
267
267
|
message: "Select an action:",
|
|
268
268
|
choices: [
|
|
@@ -289,7 +289,7 @@ var ContentstackOAuthHandler = class _ContentstackOAuthHandler {
|
|
|
289
289
|
async showAuthMenu() {
|
|
290
290
|
const { authAction } = await inquirer.prompt([
|
|
291
291
|
{
|
|
292
|
-
type: "
|
|
292
|
+
type: "select",
|
|
293
293
|
name: "authAction",
|
|
294
294
|
message: "Authorization actions:",
|
|
295
295
|
choices: [
|
|
@@ -455,7 +455,7 @@ var ContentstackOAuthHandler = class _ContentstackOAuthHandler {
|
|
|
455
455
|
}));
|
|
456
456
|
const { selectedRegion } = await inquirer.prompt([
|
|
457
457
|
{
|
|
458
|
-
type: "
|
|
458
|
+
type: "select",
|
|
459
459
|
name: "selectedRegion",
|
|
460
460
|
message: "Select your Contentstack region:",
|
|
461
461
|
choices
|
|
@@ -922,6 +922,16 @@ async function buildContentstackRequest(actionMapper, args, groupName, subgroupN
|
|
|
922
922
|
}
|
|
923
923
|
});
|
|
924
924
|
}
|
|
925
|
+
const customHeaders = {};
|
|
926
|
+
if (actionMapper.headers) {
|
|
927
|
+
Object.entries(actionMapper.headers).forEach(
|
|
928
|
+
([headerName, argName]) => {
|
|
929
|
+
if (args[argName] !== void 0) {
|
|
930
|
+
customHeaders[headerName] = args[argName];
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
);
|
|
934
|
+
}
|
|
925
935
|
let body = void 0;
|
|
926
936
|
if (actionMapper.body) {
|
|
927
937
|
if (actionMapper.type === "complex") {
|
|
@@ -955,7 +965,8 @@ async function buildContentstackRequest(actionMapper, args, groupName, subgroupN
|
|
|
955
965
|
url2,
|
|
956
966
|
body,
|
|
957
967
|
queryParams,
|
|
958
|
-
options
|
|
968
|
+
options,
|
|
969
|
+
customHeaders
|
|
959
970
|
);
|
|
960
971
|
return returnObj;
|
|
961
972
|
}
|
|
@@ -979,7 +990,8 @@ async function buildGraphQLRequest(actionMapper, args, groupName, subgroupName,
|
|
|
979
990
|
actionMapper.apiUrl,
|
|
980
991
|
graphqlBody,
|
|
981
992
|
{},
|
|
982
|
-
options
|
|
993
|
+
options,
|
|
994
|
+
{}
|
|
983
995
|
);
|
|
984
996
|
}
|
|
985
997
|
function buildBodyPayload(schema, data) {
|
|
@@ -1039,7 +1051,7 @@ function buildBodyPayload(schema, data) {
|
|
|
1039
1051
|
}
|
|
1040
1052
|
return walk(schema).value;
|
|
1041
1053
|
}
|
|
1042
|
-
async function buildReturnValue(groupName, subgroupName, method, url2, data, queryParams, options) {
|
|
1054
|
+
async function buildReturnValue(groupName, subgroupName, method, url2, data, queryParams, options, customHeaders = {}) {
|
|
1043
1055
|
if (!url2) {
|
|
1044
1056
|
throw new Error("URL is required");
|
|
1045
1057
|
}
|
|
@@ -1148,6 +1160,12 @@ async function buildReturnValue(groupName, subgroupName, method, url2, data, que
|
|
|
1148
1160
|
...oauthHeaders
|
|
1149
1161
|
};
|
|
1150
1162
|
}
|
|
1163
|
+
if (Object.keys(customHeaders).length > 0) {
|
|
1164
|
+
config.headers = {
|
|
1165
|
+
...config.headers,
|
|
1166
|
+
...customHeaders
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1151
1169
|
return config;
|
|
1152
1170
|
}
|
|
1153
1171
|
|