pptb-standard-sample-tool 1.5.2 → 1.6.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
@@ -284,6 +284,9 @@ function setupEventHandlers() {
284
284
  document.getElementById("get-metadata-allentities")?.addEventListener("click", getAllEntities);
285
285
  //Execute buttons
286
286
  document.getElementById("whoami-btn")?.addEventListener("click", executeWhoAmI);
287
+ document.getElementById("query-with-headers-btn")?.addEventListener("click", queryAccountsWithHeaders);
288
+ document.getElementById("execute-batch-btn")?.addEventListener("click", executeReadBatch);
289
+ document.getElementById("execute-transaction-btn")?.addEventListener("click", executeAtomicTransaction);
287
290
  // Power Platform API buttons
288
291
  document.getElementById("list-apps-btn")?.addEventListener("click", listPowerApps);
289
292
  document.getElementById("list-flows-btn")?.addEventListener("click", listPowerAutomateFlows);
@@ -854,6 +857,98 @@ async function executeWhoAmI() {
854
857
  log(`Error executing WhoAmI: ${error.message}`, "error");
855
858
  }
856
859
  }
860
+ function getAdditionalHeaders() {
861
+ const input = document.getElementById("dataverse-headers");
862
+ const parsed = JSON.parse(input?.value || "{}");
863
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
864
+ throw new Error("Additional headers must be a JSON object");
865
+ }
866
+ const headers = {};
867
+ for (const [name, value] of Object.entries(parsed)) {
868
+ if (typeof value !== "string") {
869
+ throw new Error(`Header value for '${name}' must be a string`);
870
+ }
871
+ headers[name] = value;
872
+ }
873
+ return headers;
874
+ }
875
+ async function queryAccountsWithHeaders() {
876
+ if (!currentConnection) {
877
+ await showNotification("No Connection", "Please connect to a Dataverse environment", "warning");
878
+ return;
879
+ }
880
+ const output = document.getElementById("headers-output");
881
+ try {
882
+ const headers = getAdditionalHeaders();
883
+ if (output)
884
+ output.textContent = "Querying accounts with additional headers...\n";
885
+ const result = await dataverse.queryData("accounts?$select=name,accountid&$top=5", "primary", headers);
886
+ if (output) {
887
+ output.textContent = `Found ${result.value.length} account(s):\n\n`;
888
+ output.textContent += JSON.stringify(result.value, null, 2);
889
+ }
890
+ log(`Queried ${result.value.length} accounts with additional headers`, "success");
891
+ }
892
+ catch (error) {
893
+ if (output)
894
+ output.textContent = `Error: ${error.message}`;
895
+ log(`Error querying accounts with headers: ${error.message}`, "error");
896
+ }
897
+ }
898
+ async function executeReadBatch() {
899
+ if (!currentConnection) {
900
+ await showNotification("No Connection", "Please connect to a Dataverse environment", "warning");
901
+ return;
902
+ }
903
+ const output = document.getElementById("batch-output");
904
+ try {
905
+ const headers = getAdditionalHeaders();
906
+ if (output)
907
+ output.textContent = "Executing read batch...\n";
908
+ const results = await dataverse.executeBatch([
909
+ { method: "GET", url: "accounts?$select=name,accountid&$top=3" },
910
+ { method: "GET", url: "contacts?$select=fullname,contactid&$top=3" },
911
+ ], "primary", headers);
912
+ if (output)
913
+ output.textContent = `Batch returned ${results.length} result(s):\n\n${JSON.stringify(results, null, 2)}`;
914
+ log(`Read batch completed with ${results.length} result(s)`, "success");
915
+ }
916
+ catch (error) {
917
+ if (output)
918
+ output.textContent = `Error: ${error.message}`;
919
+ log(`Error executing read batch: ${error.message}`, "error");
920
+ }
921
+ }
922
+ async function executeAtomicTransaction() {
923
+ if (!currentConnection) {
924
+ await showNotification("No Connection", "Please connect to a Dataverse environment", "warning");
925
+ return;
926
+ }
927
+ const output = document.getElementById("batch-output");
928
+ try {
929
+ const headers = getAdditionalHeaders();
930
+ const suffix = new Date().toISOString();
931
+ if (output)
932
+ output.textContent = `Executing atomic transaction (creating an account and contact - ${`HTML Sample ${suffix}`} )...\n`;
933
+ const results = await dataverse.executeTransaction([
934
+ { method: "POST", url: "accounts", contentId: "account", body: { name: `HTML Sample ${suffix}` } },
935
+ {
936
+ method: "POST",
937
+ url: "contacts",
938
+ contentId: "contact",
939
+ body: { firstname: "HTML", lastname: `Sample ${suffix}` },
940
+ },
941
+ ], "primary", headers);
942
+ if (output)
943
+ output.textContent = `Transaction returned ${results.length} result(s):\n\n${JSON.stringify(results, null, 2)}`;
944
+ log(`Atomic transaction completed with ${results.length} result(s)`, "success");
945
+ }
946
+ catch (error) {
947
+ if (output)
948
+ output.textContent = `Error: ${error.message}`;
949
+ log(`Error executing atomic transaction: ${error.message}`, "error");
950
+ }
951
+ }
857
952
  /**
858
953
  * Apply current theme
859
954
  */
package/dist/index.html CHANGED
@@ -183,6 +183,38 @@
183
183
  <button id="whoami-btn" class="btn">Execute WhoAmI</button>
184
184
  <div id="execute-output" class="output"></div>
185
185
  </div>
186
+
187
+ <div class="example-group">
188
+ <h3>Additional Headers</h3>
189
+ <p style="margin: 4px 0 10px; font-size: 12px; opacity: 0.85">
190
+ Headers are shown for consent before the request is sent. Use valid Dataverse header names and string values.
191
+ </p>
192
+ <div class="input-group">
193
+ <label for="dataverse-headers">Additional Headers (JSON):</label>
194
+ <textarea
195
+ id="dataverse-headers"
196
+ style="width: 100%; min-height: 90px; padding: 10px; border: 2px solid #e0e0e0; border-radius: 6px; font-family: monospace; font-size: 12px; line-height: 1.4"
197
+ >{
198
+ "Prefer": "odata.include-annotations=\"*\""
199
+ }</textarea>
200
+ </div>
201
+ <div class="button-group">
202
+ <button id="query-with-headers-btn" class="btn btn-primary">Query Accounts with Headers</button>
203
+ </div>
204
+ <div id="headers-output" class="output"></div>
205
+ </div>
206
+
207
+ <div class="example-group">
208
+ <h3>Batch Operations</h3>
209
+ <p style="margin: 4px 0 10px; font-size: 12px; opacity: 0.85">
210
+ Runs independent reads in one <code>$batch</code> request or creates an account and contact in one atomic transaction.
211
+ </p>
212
+ <div class="button-group">
213
+ <button id="execute-batch-btn" class="btn btn-primary">Execute Read Batch</button>
214
+ <button id="execute-transaction-btn" class="btn btn-warning">Execute Atomic Transaction</button>
215
+ </div>
216
+ <div id="batch-output" class="output"></div>
217
+ </div>
186
218
  </section>
187
219
 
188
220
  <!-- Power Platform API Examples -->
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "pptb-standard-sample-tool",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pptb-standard-sample-tool",
9
- "version": "1.5.1",
9
+ "version": "1.5.2",
10
10
  "license": "GPL-3.0",
11
11
  "devDependencies": {
12
- "@pptb/types": "^1.2.6-beta.2",
12
+ "@pptb/types": "^1.2.7-beta.0",
13
13
  "shx": "^0.4.0",
14
14
  "typescript": "^5.0.0"
15
15
  },
@@ -69,9 +69,9 @@
69
69
  }
70
70
  },
71
71
  "node_modules/@pptb/types": {
72
- "version": "1.2.6-beta.2",
73
- "resolved": "https://registry.npmjs.org/@pptb/types/-/types-1.2.6-beta.2.tgz",
74
- "integrity": "sha512-k6Ov2Jfl3c2Et4h86fiKPZK2E0i/hIMGDNnXsXZgREAwU4tMtBmcqrQNr6YfFJOIRzM2fSbQDqW9bGecup5i2Q==",
72
+ "version": "1.2.7-beta.0",
73
+ "resolved": "https://registry.npmjs.org/@pptb/types/-/types-1.2.7-beta.0.tgz",
74
+ "integrity": "sha512-6nVHBinyLC+kAkHwyswN56rv4chDg1RkDjdBASDaxxzJI3PDcW3cVitwKl4mDxeQqNZi7KlIZo+zIZkZt5yC4A==",
75
75
  "dev": true,
76
76
  "license": "GPL-3.0",
77
77
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pptb-standard-sample-tool",
3
- "version": "1.5.2",
3
+ "version": "1.6.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",
@@ -79,7 +79,7 @@
79
79
  "validate": "pptb-validate"
80
80
  },
81
81
  "devDependencies": {
82
- "@pptb/types": "^1.2.6-beta.2",
82
+ "@pptb/types": "^1.2.7-beta.0",
83
83
  "shx": "^0.4.0",
84
84
  "typescript": "^5.0.0"
85
85
  },