mc8yp 2.5.0 → 2.5.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.
- package/dist/cli.mjs +1 -26
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1545,7 +1545,7 @@ const consola = createConsola();
|
|
|
1545
1545
|
//#endregion
|
|
1546
1546
|
//#region package.json
|
|
1547
1547
|
var name = "mc8yp";
|
|
1548
|
-
var version = "2.5.
|
|
1548
|
+
var version = "2.5.1";
|
|
1549
1549
|
var description$1 = "Cumulocity IoT MCP Server - Model Context Protocol integration for IoT device management";
|
|
1550
1550
|
//#endregion
|
|
1551
1551
|
//#region \0virtual:core-openapi
|
|
@@ -57857,14 +57857,6 @@ async () => {
|
|
|
57857
57857
|
}
|
|
57858
57858
|
\`\`\`
|
|
57859
57859
|
|
|
57860
|
-
## Efficient Querying
|
|
57861
|
-
|
|
57862
|
-
Parameters with \`schema.format === 'c8y:query'\` accept Cumulocity Query Language. Use \`queryBuilder()\` — injected into every execute sandbox — to construct the query string. Always prefer server-side filtering over fetching all pages: max \`pageSize\` is 2000 and tenants can have millions of objects.
|
|
57863
|
-
|
|
57864
|
-
Key operators: \`eq\`, \`gt\`, \`ge\`, \`lt\`, \`le\`, \`and\`, \`or\`, \`not\`, \`has()\`, \`hasany()\`, \`bygroupid()\`, \`isinhierarchyof()\`. **There is no \`like\` or \`in\`** — use \`eq\` with \`*\` wildcards for substring matches (\`name eq '*pattern*'\`, case-insensitive), and \`or\` chains for multi-value ID matching. When the ID list is large, fetch all and join in memory instead.
|
|
57865
|
-
|
|
57866
|
-
For the full syntax reference, run the query tool: \`() => coreSpec.tags.find(t => t.name === 'Query language')?.description\`
|
|
57867
|
-
|
|
57868
57860
|
${getRuntimeSection()}
|
|
57869
57861
|
|
|
57870
57862
|
${getOpenApiSection()}
|
|
@@ -131836,22 +131828,6 @@ function createCumulocitySafeFetch(tenantUrl, authHeaders, restrictions = [], al
|
|
|
131836
131828
|
allowCompressedResponses: false
|
|
131837
131829
|
});
|
|
131838
131830
|
}
|
|
131839
|
-
const QUERY_BUILDER_SOURCE = `\
|
|
131840
|
-
/**
|
|
131841
|
-
* Builds a Cumulocity query string for parameters of name "query" or with schema.format "c8y:query".
|
|
131842
|
-
* Use to filter server-side. This is always the preferred method if query parameters are present (max pageSize 2000).
|
|
131843
|
-
* No like/in operators — use eq with * wildcards (name eq '*pat*') or or-chains for multi-value.
|
|
131844
|
-
* To get query syntax documentation run query tool → () => coreSpec.tags.find(t => t.name === 'Query language')?.description
|
|
131845
|
-
* Use the path exactly as it appears in serviceSpecs — never prepend /service/<key>.
|
|
131846
|
-
* @example /inventory/managedObjects?\${queryBuilder({ filter: "type eq 'c8y_Firmware'" })}
|
|
131847
|
-
* @example <path>?\${queryBuilder({ filter: "name eq '*Ctrl*'", orderby: "name asc" })}
|
|
131848
|
-
*/
|
|
131849
|
-
function queryBuilder({ filter, orderby, pageSize = 2000 } = {}) {
|
|
131850
|
-
const parts = []
|
|
131851
|
-
if (filter) parts.push('$filter=' + filter)
|
|
131852
|
-
if (orderby) parts.push('$orderby=' + orderby)
|
|
131853
|
-
return (parts.length ? 'query=' + parts.join(' ') + '&' : '') + 'pageSize=' + pageSize
|
|
131854
|
-
}`;
|
|
131855
131831
|
function normalizeCode(functionCode) {
|
|
131856
131832
|
return functionCode.trim().replace(/^```(?:js|javascript|ts|typescript)?\s*/i, "").replace(/\s*```$/, "").trim();
|
|
131857
131833
|
}
|
|
@@ -131943,7 +131919,6 @@ async function execute(functionCode) {
|
|
|
131943
131919
|
const restrictions = c8yMcpServer.ctx.custom?.restrictions ?? [];
|
|
131944
131920
|
const allowRules = c8yMcpServer.ctx.custom?.allowRules ?? [];
|
|
131945
131921
|
const code = [
|
|
131946
|
-
QUERY_BUILDER_SOURCE,
|
|
131947
131922
|
`const __mc8ypExecute = (${normalizeCode(functionCode)});`,
|
|
131948
131923
|
"if (typeof __mc8ypExecute !== \"function\") { throw new TypeError(\"Execute code must evaluate to a function.\") }",
|
|
131949
131924
|
"export default await __mc8ypExecute();"
|