pptb-standard-sample-tool 1.3.2 → 1.3.3

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 +6 -16
  2. package/package.json +1 -1
package/dist/headless.js CHANGED
@@ -1,13 +1,5 @@
1
1
  "use strict";
2
2
  /// <reference types="@pptb/types" />
3
- function getDataverseApi() {
4
- const runtime = globalThis;
5
- let api = runtime.window?.dataverseAPI ?? runtime.dataverseAPI;
6
- if (!api) {
7
- api = window?.dataverseAPI ?? null;
8
- }
9
- return api ?? null;
10
- }
11
3
  function sanitizeEntityName(value) {
12
4
  const trimmed = value.trim();
13
5
  if (!/^[A-Za-z0-9_]+$/.test(trimmed)) {
@@ -43,20 +35,18 @@ function buildFetchXml(entityName, idAttribute, nameAttribute) {
43
35
  */
44
36
  async function invokeHeadless(input, context) {
45
37
  const { toolId, toolName, invocationMode, updateProgress, logger } = context;
46
- const dataverseApi = getDataverseApi();
47
- if (!dataverseApi) {
48
- throw new Error("Dataverse API is not available in this runtime context");
49
- }
50
38
  logger.info(`Starting headless run for ${toolName} (${toolId}) in mode ${invocationMode}`);
51
39
  updateProgress(10, "validating input");
40
+ if (typeof dataverseAPI === "undefined" || dataverseAPI === null) {
41
+ throw new Error("dataverseAPI is not available in this runtime context");
42
+ }
52
43
  const entityName = sanitizeEntityName(typeof input.entityName === "string" && input.entityName.trim() !== "" ? input.entityName : "account");
53
- updateProgress(40, "dataverse api available");
54
- updateProgress(55, "resolving entity metadata");
55
- const attributes = await resolveEntityAttributes(dataverseApi, entityName);
44
+ updateProgress(40, "resolving entity metadata");
45
+ const attributes = await resolveEntityAttributes(dataverseAPI, entityName);
56
46
  updateProgress(75, "building FetchXML");
57
47
  const fetchXml = buildFetchXml(entityName, attributes.idAttribute, attributes.nameAttribute);
58
48
  updateProgress(90, "executing FetchXML query");
59
- const result = await dataverseApi.fetchXmlQuery(fetchXml);
49
+ const result = await dataverseAPI.fetchXmlQuery(fetchXml);
60
50
  updateProgress(100, "done");
61
51
  logger.info(`Headless run complete for entity: ${entityName}. Returned ${result.value.length} record(s).`);
62
52
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pptb-standard-sample-tool",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
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",