pptb-standard-sample-tool 1.3.0 → 1.3.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.
Files changed (2) hide show
  1. package/dist/headless.js +11 -16
  2. package/package.json +1 -1
package/dist/headless.js CHANGED
@@ -2,11 +2,11 @@
2
2
  /// <reference types="@pptb/types" />
3
3
  function getDataverseApi() {
4
4
  const runtime = globalThis;
5
- const api = runtime.dataverseAPI ?? runtime.window?.dataverseAPI;
5
+ let api = runtime.window?.dataverseAPI ?? runtime.dataverseAPI;
6
6
  if (!api) {
7
- throw new Error("Dataverse API is not available in this runtime context");
7
+ api = window?.dataverseAPI ?? null;
8
8
  }
9
- return api;
9
+ return api ?? null;
10
10
  }
11
11
  function sanitizeEntityName(value) {
12
12
  const trimmed = value.trim();
@@ -31,10 +31,7 @@ async function resolveEntityAttributes(api, entityName) {
31
31
  }
32
32
  }
33
33
  function buildFetchXml(entityName, idAttribute, nameAttribute) {
34
- const attributeLines = [
35
- ` <attribute name="${idAttribute}" />`,
36
- ...(nameAttribute ? [` <attribute name="${nameAttribute}" />`] : []),
37
- ];
34
+ const attributeLines = [` <attribute name="${idAttribute}" />`, ...(nameAttribute ? [` <attribute name="${nameAttribute}" />`] : [])];
38
35
  const orderLine = nameAttribute ? `\n <order attribute="${nameAttribute}" />` : "";
39
36
  return `<fetch top="10">\n <entity name="${entityName}">\n${attributeLines.join("\n")}${orderLine}\n </entity>\n</fetch>`;
40
37
  }
@@ -45,21 +42,19 @@ function buildFetchXml(entityName, idAttribute, nameAttribute) {
45
42
  * so MCP agents can consume it without opening the tool UI.
46
43
  */
47
44
  async function invokeHeadless(input, context) {
48
- const { toolId, toolName, invocationMode, authToken, updateProgress, logger } = context;
45
+ const { toolId, toolName, invocationMode, updateProgress, logger } = context;
49
46
  const dataverseApi = getDataverseApi();
47
+ if (!dataverseApi) {
48
+ throw new Error("Dataverse API is not available in this runtime context");
49
+ }
50
50
  logger.info(`Starting headless run for ${toolName} (${toolId}) in mode ${invocationMode}`);
51
51
  updateProgress(10, "validating input");
52
52
  const entityName = sanitizeEntityName(typeof input.entityName === "string" && input.entityName.trim() !== "" ? input.entityName : "account");
53
- if (authToken) {
54
- updateProgress(40, "auth token received");
55
- }
56
- else {
57
- updateProgress(40, "running without auth token");
58
- }
53
+ updateProgress(40, "dataverse api available");
59
54
  updateProgress(55, "resolving entity metadata");
60
- const { idAttribute, nameAttribute } = await resolveEntityAttributes(dataverseApi, entityName);
55
+ const attributes = await resolveEntityAttributes(dataverseApi, entityName);
61
56
  updateProgress(75, "building FetchXML");
62
- const fetchXml = buildFetchXml(entityName, idAttribute, nameAttribute);
57
+ const fetchXml = buildFetchXml(entityName, attributes.idAttribute, attributes.nameAttribute);
63
58
  updateProgress(90, "executing FetchXML query");
64
59
  const result = await dataverseApi.fetchXmlQuery(fetchXml);
65
60
  updateProgress(100, "done");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pptb-standard-sample-tool",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "displayName": "HTML Sample Tool",
5
5
  "description": "A sample Power Platform ToolBox tool built with HTML, CSS, and TypeScript",
6
6
  "main": "index.html",