pptb-standard-sample-tool 1.1.12 → 1.2.0

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/app.js CHANGED
@@ -15,6 +15,7 @@ import { createSecuritySuites } from "./security/suites.js";
15
15
  // Global API references
16
16
  const toolbox = window.toolboxAPI;
17
17
  const dataverse = window.dataverseAPI;
18
+ const powerplatform = window.powerplatformAPI;
18
19
  // Application state
19
20
  let currentConnection = null;
20
21
  let secondaryConnection = null;
@@ -189,7 +190,6 @@ function setupEventHandlers() {
189
190
  document.getElementById("show-info-btn")?.addEventListener("click", () => showNotification("Information", "This is an informational message", "info"));
190
191
  document.getElementById("show-warning-btn")?.addEventListener("click", () => showNotification("Warning", "Please review this warning", "warning"));
191
192
  document.getElementById("show-error-btn")?.addEventListener("click", () => showNotification("Error", "An error has occurred", "error"));
192
- document.getElementById("show-loading-btn")?.addEventListener("click", showLoading);
193
193
  // Utility buttons
194
194
  document.getElementById("copy-clipboard-btn")?.addEventListener("click", copyToClipboard);
195
195
  document.getElementById("get-theme-btn")?.addEventListener("click", showCurrentTheme);
@@ -226,6 +226,11 @@ function setupEventHandlers() {
226
226
  document.getElementById("get-metadata-allentities")?.addEventListener("click", getAllEntities);
227
227
  //Execute buttons
228
228
  document.getElementById("whoami-btn")?.addEventListener("click", executeWhoAmI);
229
+ // Power Platform API buttons
230
+ document.getElementById("list-apps-btn")?.addEventListener("click", listPowerApps);
231
+ document.getElementById("list-flows-btn")?.addEventListener("click", listPowerAutomateFlows);
232
+ document.getElementById("list-environments-btn")?.addEventListener("click", listEnvironments);
233
+ document.getElementById("get-governance-btn")?.addEventListener("click", getGovernanceData);
229
234
  // Clear log button
230
235
  document.getElementById("clear-log-btn")?.addEventListener("click", clearLog);
231
236
  // Advanced utilities demos
@@ -252,17 +257,6 @@ async function showNotification(title, body, type) {
252
257
  log(`Error showing notification: ${error.message}`, "error");
253
258
  }
254
259
  }
255
- async function showLoading() {
256
- try {
257
- await toolbox.utils.showLoading("Loading... for 3 seconds");
258
- log("Loading shown for 3 seconds", "info");
259
- await new Promise((resolve) => setTimeout(resolve, 3000));
260
- await toolbox.utils.hideLoading();
261
- }
262
- catch (error) {
263
- log(`Error showing loading: ${error.message}`, "error");
264
- }
265
- }
266
260
  /**
267
261
  * Copy text to clipboard
268
262
  */
@@ -885,7 +879,6 @@ async function demoLoading() {
885
879
  if (output)
886
880
  output.textContent = "Showing loading screen...\n";
887
881
  try {
888
- await toolbox.utils.showLoading("Processing data...");
889
882
  log("Loading screen displayed", "info");
890
883
  // Simulate async work or perform a lightweight query
891
884
  if (currentConnection) {
@@ -910,13 +903,123 @@ async function demoLoading() {
910
903
  await showNotification("Loading Demo Error", error.message, "error");
911
904
  }
912
905
  finally {
913
- await toolbox.utils.hideLoading();
914
906
  if (output)
915
907
  output.textContent += "\nLoading screen hidden.";
916
908
  log("Loading screen hidden", "info");
917
909
  await showNotification("Loading Complete", "Demo finished", "success");
918
910
  }
919
911
  }
912
+ // -----------------------------
913
+ // Power Platform API Examples
914
+ // -----------------------------
915
+ async function listPowerApps() {
916
+ const output = document.getElementById("powerapps-output");
917
+ const envId = document.getElementById("ppapps-env-id")?.value;
918
+ if (!envId) {
919
+ await showNotification("Missing Environment ID", "Please enter an environment ID", "warning");
920
+ if (output)
921
+ output.textContent = "Enter an environment ID to list apps.";
922
+ return;
923
+ }
924
+ try {
925
+ if (output)
926
+ output.textContent = "Fetching Power Apps...\n";
927
+ const result = await powerplatform.PowerApps.Get(`environments/${envId}/apps?api-version=2024-10-01`);
928
+ if (output) {
929
+ const apps = result.value || [];
930
+ output.textContent += `Found ${apps.length} app(s):\n\n`;
931
+ apps.forEach((app, index) => {
932
+ output.textContent += `${index + 1}. ${app.name}\n`;
933
+ output.textContent += ` ID: ${app.id || app.appId}\n`;
934
+ output.textContent += ` Type: ${app.type || "N/A"}\n\n`;
935
+ });
936
+ log(`Listed ${apps.length} Power Apps`, "success");
937
+ }
938
+ }
939
+ catch (error) {
940
+ if (output)
941
+ output.textContent = `Error: ${error.message}`;
942
+ log(`Error listing Power Apps: ${error.message}`, "error");
943
+ }
944
+ }
945
+ async function listPowerAutomateFlows() {
946
+ const output = document.getElementById("powerautomate-output");
947
+ const envId = document.getElementById("ppautomate-env-id")?.value;
948
+ if (!envId) {
949
+ await showNotification("Missing Environment ID", "Please enter an environment ID", "warning");
950
+ if (output)
951
+ output.textContent = "Enter an environment ID to list flows.";
952
+ return;
953
+ }
954
+ try {
955
+ if (output)
956
+ output.textContent = "Fetching Power Automate flows...\n";
957
+ const result = await powerplatform.PowerAutomate.Get(`environments/${envId}/cloudFlows?api-version=2024-10-01`);
958
+ if (output) {
959
+ const flows = result.value || [];
960
+ output.textContent += `Found ${flows.length} flow(s):\n\n`;
961
+ flows.forEach((flow, index) => {
962
+ output.textContent += `${index + 1}. ${flow.displayName || flow.name}\n`;
963
+ output.textContent += ` ID: ${flow.id || flow.flowId}\n`;
964
+ output.textContent += ` State: ${flow.state || "N/A"}\n\n`;
965
+ });
966
+ log(`Listed ${flows.length} Power Automate flows`, "success");
967
+ }
968
+ }
969
+ catch (error) {
970
+ if (output)
971
+ output.textContent = `Error: ${error.message}`;
972
+ log(`Error listing flows: ${error.message}`, "error");
973
+ }
974
+ }
975
+ async function listEnvironments() {
976
+ const output = document.getElementById("environments-output");
977
+ try {
978
+ if (output)
979
+ output.textContent = "Fetching environments...\n";
980
+ const result = await powerplatform.EnvironmentManagement.Get("environments?api-version=2024-10-01");
981
+ if (output) {
982
+ const envs = result.value || [];
983
+ output.textContent += `Found ${envs.length} environment(s):\n\n`;
984
+ envs.forEach((env, index) => {
985
+ output.textContent += `${index + 1}. ${env.displayName}\n`;
986
+ output.textContent += ` ID: ${env.id || env.environmentId}\n`;
987
+ output.textContent += ` Type: ${env.type || env.environmentType || "N/A"}\n\n`;
988
+ });
989
+ log(`Listed ${envs.length} environments`, "success");
990
+ }
991
+ }
992
+ catch (error) {
993
+ if (output)
994
+ output.textContent = `Error: ${error.message}`;
995
+ log(`Error listing environments: ${error.message}`, "error");
996
+ }
997
+ }
998
+ async function getGovernanceData() {
999
+ const output = document.getElementById("governance-output");
1000
+ const envId = document.getElementById("governance-env-id")?.value;
1001
+ if (!envId) {
1002
+ await showNotification("Missing Environment ID", "Please enter an environment ID", "warning");
1003
+ if (output)
1004
+ output.textContent = "Enter an environment ID to get governance data.";
1005
+ return;
1006
+ }
1007
+ try {
1008
+ if (output)
1009
+ output.textContent = "Fetching governance data...\n";
1010
+ const result = await powerplatform.Governance.Get(`ruleBasedPolicies/environments/${envId}/assignments?includeRuleSetCounts=true&api-version=2024-10-01`);
1011
+ if (output) {
1012
+ output.textContent += "Governance Data:\n\n";
1013
+ output.textContent += JSON.stringify(result, null, 2);
1014
+ }
1015
+ log("Governance data retrieved", "success");
1016
+ }
1017
+ catch (error) {
1018
+ if (output)
1019
+ output.textContent = `Error: ${error.message}`;
1020
+ log(`Error getting governance data: ${error.message}`, "error");
1021
+ }
1022
+ }
920
1023
  // Initialize when DOM is ready
921
1024
  if (document.readyState === "loading") {
922
1025
  document.addEventListener("DOMContentLoaded", initialize);
package/dist/index.html CHANGED
@@ -68,10 +68,9 @@
68
68
 
69
69
  <div class="example-group">
70
70
  <h3>Advanced Utilities</h3>
71
- <p style="margin: 4px 0 8px; font-size: 12px; opacity: 0.8">Demonstrates <code>executeParallel</code>, <code>showLoading</code> & <code>hideLoading</code>.</p>
71
+ <p style="margin: 4px 0 8px; font-size: 12px; opacity: 0.8">Demonstrates <code>executeParallel</code>.</p>
72
72
  <div class="button-group">
73
73
  <button id="parallel-demo-btn" class="btn btn-primary">Run Parallel Demo</button>
74
- <button id="loading-demo-btn" class="btn btn-secondary">Run Loading Demo</button>
75
74
  </div>
76
75
  <div id="parallel-output" class="output"></div>
77
76
  </div>
@@ -173,6 +172,56 @@
173
172
  </div>
174
173
  </section>
175
174
 
175
+ <!-- Power Platform API Examples -->
176
+ <section class="card">
177
+ <h2>⚡ Power Platform API Examples</h2>
178
+ <p style="margin: 4px 0 15px; font-size: 12px; opacity: 0.85">Generic HTTP methods for Power Platform Admin APIs (Power Apps, Power Automate, Environment Management, Governance).</p>
179
+
180
+ <div class="example-group">
181
+ <h3>Power Apps API</h3>
182
+ <div class="input-group">
183
+ <label for="ppapps-env-id">Environment ID:</label>
184
+ <input type="text" id="ppapps-env-id" placeholder="Enter environment ID" />
185
+ </div>
186
+ <div class="button-group">
187
+ <button id="list-apps-btn" class="btn">List Admin Apps</button>
188
+ </div>
189
+ <div id="powerapps-output" class="output"></div>
190
+ </div>
191
+
192
+ <div class="example-group">
193
+ <h3>Power Automate API</h3>
194
+ <div class="input-group">
195
+ <label for="ppautomate-env-id">Environment ID:</label>
196
+ <input type="text" id="ppautomate-env-id" placeholder="Enter environment ID" />
197
+ </div>
198
+ <div class="button-group">
199
+ <button id="list-flows-btn" class="btn">List Flows</button>
200
+ </div>
201
+ <div id="powerautomate-output" class="output"></div>
202
+ </div>
203
+
204
+ <div class="example-group">
205
+ <h3>Environment Management API</h3>
206
+ <div class="button-group">
207
+ <button id="list-environments-btn" class="btn btn-primary">List Environments For User</button>
208
+ </div>
209
+ <div id="environments-output" class="output"></div>
210
+ </div>
211
+
212
+ <div class="example-group">
213
+ <h3>Governance API</h3>
214
+ <div class="input-group">
215
+ <label for="governance-env-id">Environment ID:</label>
216
+ <input type="text" id="governance-env-id" placeholder="Enter environment ID" />
217
+ </div>
218
+ <div class="button-group">
219
+ <button id="get-governance-btn" class="btn">List Rule Assignments By Environment Id</button>
220
+ </div>
221
+ <div id="governance-output" class="output"></div>
222
+ </div>
223
+ </section>
224
+
176
225
  <!-- Event Log -->
177
226
  <section class="card">
178
227
  <h2>📋 Event Log</h2>
@@ -9,7 +9,7 @@
9
9
  "version": "1.1.12",
10
10
  "license": "GPL-3.0",
11
11
  "devDependencies": {
12
- "@pptb/types": "^1.0.19",
12
+ "@pptb/types": "^1.2.4-beta.0",
13
13
  "shx": "^0.4.0",
14
14
  "typescript": "^5.0.0"
15
15
  },
@@ -56,11 +56,14 @@
56
56
  }
57
57
  },
58
58
  "node_modules/@pptb/types": {
59
- "version": "1.0.19",
60
- "resolved": "https://registry.npmjs.org/@pptb/types/-/types-1.0.19.tgz",
61
- "integrity": "sha512-1nzI65TZEcP5t672G8T3uzheDI5az7Q58HGOq7F2wh0oxcbLKjSfarD13cNKR01slyBIUTNUF5W3pNHJTLYHYA==",
59
+ "version": "1.2.4-beta.0",
60
+ "resolved": "https://registry.npmjs.org/@pptb/types/-/types-1.2.4-beta.0.tgz",
61
+ "integrity": "sha512-KEY2RjPkxaMkv3XOF48pzGlTiGT2bWdseUgsr2YA9itGkjMj8zegSUiqU6Rb2SA6omdPy1HzD2v5iEB3G4R7ZQ==",
62
62
  "dev": true,
63
- "license": "GPL-3.0"
63
+ "license": "GPL-3.0",
64
+ "bin": {
65
+ "pptb-validate": "bin/pptb-validate.js"
66
+ }
64
67
  },
65
68
  "node_modules/braces": {
66
69
  "version": "3.0.3",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pptb-standard-sample-tool",
3
- "version": "1.1.12",
3
+ "version": "1.2.0",
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",
@@ -28,7 +28,8 @@
28
28
  },
29
29
  "features": {
30
30
  "minAPI": "1.2.2",
31
- "multiConnection": "optional"
31
+ "multiConnection": "optional",
32
+ "enabledForPowerPlatformAPI": true
32
33
  },
33
34
  "repository": {
34
35
  "type": "git",
@@ -47,7 +48,7 @@
47
48
  "watch": "tsc --watch"
48
49
  },
49
50
  "devDependencies": {
50
- "@pptb/types": "^1.0.19",
51
+ "@pptb/types": "^1.2.4-beta.0",
51
52
  "shx": "^0.4.0",
52
53
  "typescript": "^5.0.0"
53
54
  },
@@ -55,4 +56,4 @@
55
56
  "dist",
56
57
  "npm-shrinkwrap.json"
57
58
  ]
58
- }
59
+ }