@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.js
CHANGED
|
@@ -9546,18 +9546,29 @@ function headerTemplateToRows(headerTemplate, nextRowId) {
|
|
|
9546
9546
|
}
|
|
9547
9547
|
|
|
9548
9548
|
/**
|
|
9549
|
-
* Serialize the current form state into a
|
|
9549
|
+
* Serialize the current form state into a bare MCP JSON config string.
|
|
9550
9550
|
*
|
|
9551
|
-
* Output format:
|
|
9551
|
+
* Output format (stdio):
|
|
9552
9552
|
* {
|
|
9553
|
-
* "
|
|
9554
|
-
*
|
|
9555
|
-
*
|
|
9553
|
+
* "type": "stdio",
|
|
9554
|
+
* "command": "npx",
|
|
9555
|
+
* "args": ["-y", "package-name"],
|
|
9556
|
+
* "env": { "API_KEY": "${API_KEY}" }
|
|
9556
9557
|
* }
|
|
9557
9558
|
*
|
|
9558
|
-
*
|
|
9559
|
+
* Output format (HTTP):
|
|
9560
|
+
* {
|
|
9561
|
+
* "type": "streamable_http",
|
|
9562
|
+
* "url": "https://example.com/mcp",
|
|
9563
|
+
* "headerTemplate": { "Authorization": "Bearer {{apiKey}}" }
|
|
9564
|
+
* }
|
|
9565
|
+
*
|
|
9566
|
+
* Credential values are NOT embedded — env values use ${FIELD_NAME} syntax
|
|
9567
|
+
* to reference credential fields entered separately in the form.
|
|
9568
|
+
*
|
|
9569
|
+
* @param {string} name - The provider name (unused in output, kept for API compat)
|
|
9559
9570
|
* @param {string} transport - "stdio" or "streamable_http"
|
|
9560
|
-
* @param {object} fields - { command, args, envMappingRows, url, headerRows
|
|
9571
|
+
* @param {object} fields - { command, args, envMappingRows, url, headerRows }
|
|
9561
9572
|
* @returns {string} Formatted JSON string
|
|
9562
9573
|
*/
|
|
9563
9574
|
function formStateToMcpJson(name, transport, fields) {
|
|
@@ -9570,9 +9581,7 @@ function formStateToMcpJson(name, transport, fields) {
|
|
|
9570
9581
|
_fields$url = fields.url,
|
|
9571
9582
|
url = _fields$url === void 0 ? "" : _fields$url,
|
|
9572
9583
|
_fields$headerRows = fields.headerRows,
|
|
9573
|
-
headerRows = _fields$headerRows === void 0 ? [] : _fields$headerRows
|
|
9574
|
-
_fields$credentialDat = fields.credentialData,
|
|
9575
|
-
credentialData = _fields$credentialDat === void 0 ? {} : _fields$credentialDat;
|
|
9584
|
+
headerRows = _fields$headerRows === void 0 ? [] : _fields$headerRows;
|
|
9576
9585
|
var serverConfig;
|
|
9577
9586
|
if (transport === "stdio") {
|
|
9578
9587
|
var argsArray = args.trim().split(/\s+/).filter(Boolean);
|
|
@@ -9580,11 +9589,12 @@ function formStateToMcpJson(name, transport, fields) {
|
|
|
9580
9589
|
envMappingRows.forEach(function (row) {
|
|
9581
9590
|
var envVar = row.envVar.trim();
|
|
9582
9591
|
var credField = row.credField.trim();
|
|
9583
|
-
if (envVar) {
|
|
9584
|
-
env[envVar] =
|
|
9592
|
+
if (envVar && credField) {
|
|
9593
|
+
env[envVar] = "${".concat(credField, "}");
|
|
9585
9594
|
}
|
|
9586
9595
|
});
|
|
9587
9596
|
serverConfig = {
|
|
9597
|
+
type: "stdio",
|
|
9588
9598
|
command: command.trim()
|
|
9589
9599
|
};
|
|
9590
9600
|
if (argsArray.length > 0) serverConfig.args = argsArray;
|
|
@@ -9592,29 +9602,36 @@ function formStateToMcpJson(name, transport, fields) {
|
|
|
9592
9602
|
} else {
|
|
9593
9603
|
// streamable_http
|
|
9594
9604
|
serverConfig = {
|
|
9605
|
+
type: "streamable_http",
|
|
9595
9606
|
url: url.trim()
|
|
9596
9607
|
};
|
|
9597
|
-
var
|
|
9608
|
+
var headerTemplate = {};
|
|
9598
9609
|
headerRows.forEach(function (row) {
|
|
9599
9610
|
var hName = row.headerName.trim();
|
|
9600
9611
|
var hValue = row.headerValue.trim();
|
|
9601
9612
|
if (hName && hValue) {
|
|
9602
|
-
|
|
9613
|
+
headerTemplate[hName] = hValue;
|
|
9603
9614
|
}
|
|
9604
9615
|
});
|
|
9605
|
-
if (Object.keys(
|
|
9616
|
+
if (Object.keys(headerTemplate).length > 0) serverConfig.headerTemplate = headerTemplate;
|
|
9606
9617
|
}
|
|
9607
|
-
return JSON.stringify(
|
|
9608
|
-
mcpServers: _defineProperty({}, name || "server-name", serverConfig)
|
|
9609
|
-
}, null, 2);
|
|
9618
|
+
return JSON.stringify(serverConfig, null, 2);
|
|
9610
9619
|
}
|
|
9611
9620
|
|
|
9612
9621
|
/**
|
|
9613
|
-
* Parse
|
|
9622
|
+
* Parse an MCP JSON config string back into form state.
|
|
9623
|
+
*
|
|
9624
|
+
* Accepts multiple input formats:
|
|
9625
|
+
* - Bare config: { "command": ..., "args": [...], "env": { "KEY": "${FIELD}" } }
|
|
9626
|
+
* - Wrapped: { "mcpServers": { "name": { ... } } } — unwraps and uses key as providerName
|
|
9614
9627
|
*
|
|
9615
|
-
*
|
|
9616
|
-
* -
|
|
9617
|
-
* -
|
|
9628
|
+
* Transport detection:
|
|
9629
|
+
* - Explicit `type` or `transport` field
|
|
9630
|
+
* - Inferred: `url` present → streamable_http, `command` present → stdio
|
|
9631
|
+
*
|
|
9632
|
+
* stdio env value parsing:
|
|
9633
|
+
* - "${FIELD_NAME}" → envVar = key, credField = FIELD_NAME (reference syntax)
|
|
9634
|
+
* - "literal-value" → envVar = key, credField = key, credentialData[key] = value
|
|
9618
9635
|
*
|
|
9619
9636
|
* @param {string} jsonString - The JSON to parse
|
|
9620
9637
|
* @param {Function} nextRowId - Function that returns a unique row ID
|
|
@@ -9641,15 +9658,22 @@ function mcpJsonToFormState(jsonString, nextRowId) {
|
|
|
9641
9658
|
var _entries$ = _slicedToArray(entries[0], 2);
|
|
9642
9659
|
providerName = _entries$[0];
|
|
9643
9660
|
serverConfig = _entries$[1];
|
|
9644
|
-
} else if (parsed.command || parsed.url) {
|
|
9661
|
+
} else if (parsed.command || parsed.url || parsed.type || parsed.transport) {
|
|
9645
9662
|
serverConfig = parsed;
|
|
9646
9663
|
} else {
|
|
9647
9664
|
return {
|
|
9648
|
-
error: "Unrecognized format: expected
|
|
9665
|
+
error: "Unrecognized format: expected a server config with command, url, or type"
|
|
9649
9666
|
};
|
|
9650
9667
|
}
|
|
9651
|
-
|
|
9652
|
-
|
|
9668
|
+
|
|
9669
|
+
// Determine transport from type/transport field or infer from contents
|
|
9670
|
+
var explicitType = serverConfig.type || serverConfig.transport;
|
|
9671
|
+
var transport;
|
|
9672
|
+
if (explicitType) {
|
|
9673
|
+
transport = explicitType === "stdio" ? "stdio" : "streamable_http";
|
|
9674
|
+
} else {
|
|
9675
|
+
transport = serverConfig.url ? "streamable_http" : "stdio";
|
|
9676
|
+
}
|
|
9653
9677
|
var result = {
|
|
9654
9678
|
providerName: providerName,
|
|
9655
9679
|
transport: transport,
|
|
@@ -9669,12 +9693,24 @@ function mcpJsonToFormState(jsonString, nextRowId) {
|
|
|
9669
9693
|
var _ref6 = _slicedToArray(_ref5, 2),
|
|
9670
9694
|
envVar = _ref6[0],
|
|
9671
9695
|
value = _ref6[1];
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
credField
|
|
9676
|
-
|
|
9677
|
-
|
|
9696
|
+
// Check for ${FIELD_NAME} reference syntax
|
|
9697
|
+
var refMatch = typeof value === "string" && value.match(/^\$\{(.+)\}$/);
|
|
9698
|
+
if (refMatch) {
|
|
9699
|
+
// Reference syntax — credField is the extracted name, no credential value
|
|
9700
|
+
result.envMappingRows.push({
|
|
9701
|
+
id: nextRowId(),
|
|
9702
|
+
envVar: envVar,
|
|
9703
|
+
credField: refMatch[1]
|
|
9704
|
+
});
|
|
9705
|
+
} else {
|
|
9706
|
+
// Literal value — use envVar as credField and store the value
|
|
9707
|
+
result.envMappingRows.push({
|
|
9708
|
+
id: nextRowId(),
|
|
9709
|
+
envVar: envVar,
|
|
9710
|
+
credField: envVar
|
|
9711
|
+
});
|
|
9712
|
+
result.credentialData[envVar] = value || "";
|
|
9713
|
+
}
|
|
9678
9714
|
});
|
|
9679
9715
|
}
|
|
9680
9716
|
} else {
|
|
@@ -26775,7 +26811,7 @@ var CustomMcpServerForm = function CustomMcpServerForm(_ref2) {
|
|
|
26775
26811
|
setJsonError(null);
|
|
26776
26812
|
},
|
|
26777
26813
|
language: "json",
|
|
26778
|
-
placeholder: '{\n "
|
|
26814
|
+
placeholder: '{\n "type": "stdio",\n "command": "npx",\n "args": ["-y", "package-name"],\n "env": {\n "API_KEY": "${API_KEY}"\n }\n}'
|
|
26779
26815
|
})]
|
|
26780
26816
|
}), viewMode === "form" && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
26781
26817
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|