@trops/dash-core 0.1.53 → 0.1.54
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.esm.js +69 -33
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +69 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -9527,18 +9527,29 @@ function headerTemplateToRows(headerTemplate, nextRowId) {
|
|
|
9527
9527
|
}
|
|
9528
9528
|
|
|
9529
9529
|
/**
|
|
9530
|
-
* Serialize the current form state into a
|
|
9530
|
+
* Serialize the current form state into a bare MCP JSON config string.
|
|
9531
9531
|
*
|
|
9532
|
-
* Output format:
|
|
9532
|
+
* Output format (stdio):
|
|
9533
9533
|
* {
|
|
9534
|
-
* "
|
|
9535
|
-
*
|
|
9536
|
-
*
|
|
9534
|
+
* "type": "stdio",
|
|
9535
|
+
* "command": "npx",
|
|
9536
|
+
* "args": ["-y", "package-name"],
|
|
9537
|
+
* "env": { "API_KEY": "${API_KEY}" }
|
|
9537
9538
|
* }
|
|
9538
9539
|
*
|
|
9539
|
-
*
|
|
9540
|
+
* Output format (HTTP):
|
|
9541
|
+
* {
|
|
9542
|
+
* "type": "streamable_http",
|
|
9543
|
+
* "url": "https://example.com/mcp",
|
|
9544
|
+
* "headerTemplate": { "Authorization": "Bearer {{apiKey}}" }
|
|
9545
|
+
* }
|
|
9546
|
+
*
|
|
9547
|
+
* Credential values are NOT embedded — env values use ${FIELD_NAME} syntax
|
|
9548
|
+
* to reference credential fields entered separately in the form.
|
|
9549
|
+
*
|
|
9550
|
+
* @param {string} name - The provider name (unused in output, kept for API compat)
|
|
9540
9551
|
* @param {string} transport - "stdio" or "streamable_http"
|
|
9541
|
-
* @param {object} fields - { command, args, envMappingRows, url, headerRows
|
|
9552
|
+
* @param {object} fields - { command, args, envMappingRows, url, headerRows }
|
|
9542
9553
|
* @returns {string} Formatted JSON string
|
|
9543
9554
|
*/
|
|
9544
9555
|
function formStateToMcpJson(name, transport, fields) {
|
|
@@ -9551,9 +9562,7 @@ function formStateToMcpJson(name, transport, fields) {
|
|
|
9551
9562
|
_fields$url = fields.url,
|
|
9552
9563
|
url = _fields$url === void 0 ? "" : _fields$url,
|
|
9553
9564
|
_fields$headerRows = fields.headerRows,
|
|
9554
|
-
headerRows = _fields$headerRows === void 0 ? [] : _fields$headerRows
|
|
9555
|
-
_fields$credentialDat = fields.credentialData,
|
|
9556
|
-
credentialData = _fields$credentialDat === void 0 ? {} : _fields$credentialDat;
|
|
9565
|
+
headerRows = _fields$headerRows === void 0 ? [] : _fields$headerRows;
|
|
9557
9566
|
var serverConfig;
|
|
9558
9567
|
if (transport === "stdio") {
|
|
9559
9568
|
var argsArray = args.trim().split(/\s+/).filter(Boolean);
|
|
@@ -9561,11 +9570,12 @@ function formStateToMcpJson(name, transport, fields) {
|
|
|
9561
9570
|
envMappingRows.forEach(function (row) {
|
|
9562
9571
|
var envVar = row.envVar.trim();
|
|
9563
9572
|
var credField = row.credField.trim();
|
|
9564
|
-
if (envVar) {
|
|
9565
|
-
env[envVar] =
|
|
9573
|
+
if (envVar && credField) {
|
|
9574
|
+
env[envVar] = "${".concat(credField, "}");
|
|
9566
9575
|
}
|
|
9567
9576
|
});
|
|
9568
9577
|
serverConfig = {
|
|
9578
|
+
type: "stdio",
|
|
9569
9579
|
command: command.trim()
|
|
9570
9580
|
};
|
|
9571
9581
|
if (argsArray.length > 0) serverConfig.args = argsArray;
|
|
@@ -9573,29 +9583,36 @@ function formStateToMcpJson(name, transport, fields) {
|
|
|
9573
9583
|
} else {
|
|
9574
9584
|
// streamable_http
|
|
9575
9585
|
serverConfig = {
|
|
9586
|
+
type: "streamable_http",
|
|
9576
9587
|
url: url.trim()
|
|
9577
9588
|
};
|
|
9578
|
-
var
|
|
9589
|
+
var headerTemplate = {};
|
|
9579
9590
|
headerRows.forEach(function (row) {
|
|
9580
9591
|
var hName = row.headerName.trim();
|
|
9581
9592
|
var hValue = row.headerValue.trim();
|
|
9582
9593
|
if (hName && hValue) {
|
|
9583
|
-
|
|
9594
|
+
headerTemplate[hName] = hValue;
|
|
9584
9595
|
}
|
|
9585
9596
|
});
|
|
9586
|
-
if (Object.keys(
|
|
9597
|
+
if (Object.keys(headerTemplate).length > 0) serverConfig.headerTemplate = headerTemplate;
|
|
9587
9598
|
}
|
|
9588
|
-
return JSON.stringify(
|
|
9589
|
-
mcpServers: _defineProperty({}, name || "server-name", serverConfig)
|
|
9590
|
-
}, null, 2);
|
|
9599
|
+
return JSON.stringify(serverConfig, null, 2);
|
|
9591
9600
|
}
|
|
9592
9601
|
|
|
9593
9602
|
/**
|
|
9594
|
-
* Parse
|
|
9603
|
+
* Parse an MCP JSON config string back into form state.
|
|
9604
|
+
*
|
|
9605
|
+
* Accepts multiple input formats:
|
|
9606
|
+
* - Bare config: { "command": ..., "args": [...], "env": { "KEY": "${FIELD}" } }
|
|
9607
|
+
* - Wrapped: { "mcpServers": { "name": { ... } } } — unwraps and uses key as providerName
|
|
9595
9608
|
*
|
|
9596
|
-
*
|
|
9597
|
-
* -
|
|
9598
|
-
* -
|
|
9609
|
+
* Transport detection:
|
|
9610
|
+
* - Explicit `type` or `transport` field
|
|
9611
|
+
* - Inferred: `url` present → streamable_http, `command` present → stdio
|
|
9612
|
+
*
|
|
9613
|
+
* stdio env value parsing:
|
|
9614
|
+
* - "${FIELD_NAME}" → envVar = key, credField = FIELD_NAME (reference syntax)
|
|
9615
|
+
* - "literal-value" → envVar = key, credField = key, credentialData[key] = value
|
|
9599
9616
|
*
|
|
9600
9617
|
* @param {string} jsonString - The JSON to parse
|
|
9601
9618
|
* @param {Function} nextRowId - Function that returns a unique row ID
|
|
@@ -9622,15 +9639,22 @@ function mcpJsonToFormState(jsonString, nextRowId) {
|
|
|
9622
9639
|
var _entries$ = _slicedToArray(entries[0], 2);
|
|
9623
9640
|
providerName = _entries$[0];
|
|
9624
9641
|
serverConfig = _entries$[1];
|
|
9625
|
-
} else if (parsed.command || parsed.url) {
|
|
9642
|
+
} else if (parsed.command || parsed.url || parsed.type || parsed.transport) {
|
|
9626
9643
|
serverConfig = parsed;
|
|
9627
9644
|
} else {
|
|
9628
9645
|
return {
|
|
9629
|
-
error: "Unrecognized format: expected
|
|
9646
|
+
error: "Unrecognized format: expected a server config with command, url, or type"
|
|
9630
9647
|
};
|
|
9631
9648
|
}
|
|
9632
|
-
|
|
9633
|
-
|
|
9649
|
+
|
|
9650
|
+
// Determine transport from type/transport field or infer from contents
|
|
9651
|
+
var explicitType = serverConfig.type || serverConfig.transport;
|
|
9652
|
+
var transport;
|
|
9653
|
+
if (explicitType) {
|
|
9654
|
+
transport = explicitType === "stdio" ? "stdio" : "streamable_http";
|
|
9655
|
+
} else {
|
|
9656
|
+
transport = serverConfig.url ? "streamable_http" : "stdio";
|
|
9657
|
+
}
|
|
9634
9658
|
var result = {
|
|
9635
9659
|
providerName: providerName,
|
|
9636
9660
|
transport: transport,
|
|
@@ -9650,12 +9674,24 @@ function mcpJsonToFormState(jsonString, nextRowId) {
|
|
|
9650
9674
|
var _ref6 = _slicedToArray(_ref5, 2),
|
|
9651
9675
|
envVar = _ref6[0],
|
|
9652
9676
|
value = _ref6[1];
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
credField
|
|
9657
|
-
|
|
9658
|
-
|
|
9677
|
+
// Check for ${FIELD_NAME} reference syntax
|
|
9678
|
+
var refMatch = typeof value === "string" && value.match(/^\$\{(.+)\}$/);
|
|
9679
|
+
if (refMatch) {
|
|
9680
|
+
// Reference syntax — credField is the extracted name, no credential value
|
|
9681
|
+
result.envMappingRows.push({
|
|
9682
|
+
id: nextRowId(),
|
|
9683
|
+
envVar: envVar,
|
|
9684
|
+
credField: refMatch[1]
|
|
9685
|
+
});
|
|
9686
|
+
} else {
|
|
9687
|
+
// Literal value — use envVar as credField and store the value
|
|
9688
|
+
result.envMappingRows.push({
|
|
9689
|
+
id: nextRowId(),
|
|
9690
|
+
envVar: envVar,
|
|
9691
|
+
credField: envVar
|
|
9692
|
+
});
|
|
9693
|
+
result.credentialData[envVar] = value || "";
|
|
9694
|
+
}
|
|
9659
9695
|
});
|
|
9660
9696
|
}
|
|
9661
9697
|
} else {
|
|
@@ -26756,7 +26792,7 @@ var CustomMcpServerForm = function CustomMcpServerForm(_ref2) {
|
|
|
26756
26792
|
setJsonError(null);
|
|
26757
26793
|
},
|
|
26758
26794
|
language: "json",
|
|
26759
|
-
placeholder: '{\n "
|
|
26795
|
+
placeholder: '{\n "type": "stdio",\n "command": "npx",\n "args": ["-y", "package-name"],\n "env": {\n "API_KEY": "${API_KEY}"\n }\n}'
|
|
26760
26796
|
})]
|
|
26761
26797
|
}), viewMode === "form" && /*#__PURE__*/jsxs(Fragment, {
|
|
26762
26798
|
children: [/*#__PURE__*/jsxs("div", {
|