codeapp-js 0.2.2 → 0.3.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.
Files changed (43) hide show
  1. package/codeApp/.power/schemas/appschemas/dataSourcesInfo.ts +6275 -0
  2. package/codeApp/.power/schemas/jira/jira.Schema.json +6903 -0
  3. package/codeApp/.power/schemas/keyvault/keyvault.Schema.json +1600 -0
  4. package/codeApp/.power/schemas/teams/teams.Schema.json +11112 -0
  5. package/codeApp/dist/codeapp.js +757 -0
  6. package/codeApp/dist/index.js +1 -1
  7. package/codeApp/dist/power-apps-data.js +711 -176
  8. package/codeApp/src/generated/index.ts +12 -0
  9. package/codeApp/src/generated/models/AzureKeyVaultModel.ts +107 -0
  10. package/codeApp/src/generated/models/JiraModel.ts +501 -0
  11. package/codeApp/src/generated/models/Office365GroupsModel.ts +363 -0
  12. package/codeApp/src/generated/models/Office365OutlookModel.ts +2046 -0
  13. package/codeApp/src/generated/models/Office365UsersModel.ts +254 -0
  14. package/codeApp/src/generated/services/AzureKeyVaultService.ts +257 -0
  15. package/codeApp/src/generated/services/JiraService.ts +1124 -0
  16. package/codeApp/src/generated/services/Office365GroupsService.ts +326 -0
  17. package/codeApp/src/generated/services/Office365OutlookService.ts +2476 -0
  18. package/codeApp/src/generated/services/Office365UsersService.ts +358 -0
  19. package/dev files/customConnector.js +98 -0
  20. package/dev files/dataverse.js +22 -7
  21. package/dev files/environmentVar.js +1 -1
  22. package/dev files/office365groups.js +1 -1
  23. package/dev files/office365users.js +1 -1
  24. package/dev files/outlook.js +1 -1
  25. package/{examples/solution explorer/dist → dev files}/power-apps-data.js +2951 -3006
  26. package/dev files/sharepoint.js +1 -1
  27. package/examples/outlook Demo2/dist/index.js +10 -84
  28. package/package.json +1 -1
  29. package/readme.md +33 -4
  30. package/.github/instructions/wyattdave.instructions.md +0 -39
  31. package/examples/solution explorer/agent/decision-log.md +0 -27
  32. package/examples/solution explorer/agent/mockup-01-swiss-grid.html +0 -452
  33. package/examples/solution explorer/agent/mockup-02-dark-glass.html +0 -496
  34. package/examples/solution explorer/agent/mockup-03-paper-console.html +0 -510
  35. package/examples/solution explorer/agent/mockup-04-neon-noir.html +0 -546
  36. package/examples/solution explorer/agent/mockup-05-zen-garden.html +0 -534
  37. package/examples/solution explorer/dist/codeapp.js +0 -1098
  38. package/examples/solution explorer/dist/icon-512.png +0 -0
  39. package/examples/solution explorer/dist/index.html +0 -80
  40. package/examples/solution explorer/dist/index.js +0 -735
  41. package/examples/solution explorer/dist/styles.css +0 -571
  42. package/examples/solution explorer/power.config.json +0 -151
  43. package/scripts/build-power-sdk.mjs +0 -69
@@ -1,8 +1,359 @@
1
+ /* power-apps-data.js - Standalone Power Apps SDK for Code Apps
2
+ Converted from @microsoft/power-apps v1.0.4
3
+ Zero dependencies - all code is self-contained
4
+ Version 2.0.1: add error handling and fix for invalid response formats from plugins
5
+ */
1
6
  var __defProp = Object.defineProperty;
2
7
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
8
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
9
 
5
- // node_modules/@microsoft/power-apps/lib/internal/data/core/common/types.js
10
+ const BRIDGE_INIT_TIMEOUT_MS = 8000;
11
+ const PLUGIN_CALL_TIMEOUT_MS = 30000;
12
+
13
+ var DefaultPowerAppsBridge = class {
14
+ constructor() {
15
+ __publicField(this, "_antiCSRFToken");
16
+ __publicField(this, "_callbacks", {});
17
+ __publicField(this, "_currentCallbackId", 0);
18
+ __publicField(this, "_instanceId", Date.now().toString());
19
+ __publicField(this, "_messageChannel", new window.MessageChannel());
20
+ __publicField(this, "_postMessageQueue", []);
21
+ __publicField(this, "_postMessageSource");
22
+ __publicField(this, "_initializePromise");
23
+ __publicField(this, "_handleMessageEvent", (messageEvent) => {
24
+ const message = messageEvent.data;
25
+ if (message && typeof message.isPluginCall === "boolean") {
26
+ if (message.isPluginCall) {
27
+ const callbackId = message.callbackId;
28
+ const status = message.status;
29
+ const args = message.args;
30
+ const keepCallback = message.keepCallback;
31
+ try {
32
+ const callback = this._callbacks[callbackId];
33
+ if (keepCallback) {
34
+ if (callback && callback.onUpdate) {
35
+ callback.onUpdate(message.args?.[0]);
36
+ }
37
+ } else {
38
+ if (callback) {
39
+ if (status === 1) {
40
+ callback.resolve(args[0]);
41
+ } else if (status !== 0) {
42
+ callback.reject(args);
43
+ }
44
+ }
45
+ if (!keepCallback) {
46
+ delete this._callbacks[callbackId];
47
+ }
48
+ }
49
+ } catch (error) {
50
+ console.error(error);
51
+ }
52
+ }
53
+ } else if (message && message.messageType === "initCommunication") {
54
+ this._antiCSRFToken = message.antiCSRFToken;
55
+ this._postMessageSource = this._messageChannel.port1;
56
+ if (this._postMessageSource) {
57
+ for (let i = 0; i < this._postMessageQueue.length; i++) {
58
+ this._postMessageQueue[i].antiCSRFToken = this._antiCSRFToken;
59
+ this._postMessageSource.postMessage(this._postMessageQueue[i]);
60
+ }
61
+ this._postMessageQueue = [];
62
+ }
63
+ }
64
+ });
65
+ }
66
+ async initialize() {
67
+ if (this._initializePromise) {
68
+ return this._initializePromise;
69
+ }
70
+ this._initializePromise = new Promise((resolve, reject) => {
71
+ if (window.parent === window) {
72
+ reject(new Error("Power Apps host was not detected. Open this app from the Power Apps Code Apps host instead of a standalone browser tab."));
73
+ return;
74
+ }
75
+ this._messageChannel.port1.onmessage = (messageEvent) => {
76
+ this._handleMessageEvent(messageEvent);
77
+ if (this._postMessageSource) {
78
+ clearTimeout(timeoutId);
79
+ resolve();
80
+ }
81
+ };
82
+ const timeoutId = window.setTimeout(() => {
83
+ reject(new Error("Timed out waiting for the Power Apps host to initialize the message bridge."));
84
+ }, BRIDGE_INIT_TIMEOUT_MS);
85
+ window.parent.postMessage({
86
+ messageType: "initCommunicationWithPort",
87
+ instanceId: this._instanceId
88
+ }, "*", [this._messageChannel.port2]);
89
+ });
90
+ return this._initializePromise;
91
+ }
92
+ async executePluginAsync(pluginName, pluginAction, params = [], onUpdate) {
93
+ return new Promise((resolve, reject) => {
94
+ const callbackId = this._getCallbackId(pluginName);
95
+ const timeoutId = window.setTimeout(() => {
96
+ delete this._callbacks[callbackId];
97
+ reject(new Error(`Timed out waiting for ${pluginName}.${pluginAction} to return from the Power Apps host.`));
98
+ }, PLUGIN_CALL_TIMEOUT_MS);
99
+ this._callbacks[callbackId] = {
100
+ resolve: (value) => {
101
+ clearTimeout(timeoutId);
102
+ resolve(value);
103
+ },
104
+ reject: (error) => {
105
+ clearTimeout(timeoutId);
106
+ reject(error);
107
+ },
108
+ onUpdate
109
+ };
110
+ this._sendMessage({
111
+ isPluginCall: true,
112
+ callbackId,
113
+ service: pluginName,
114
+ action: pluginAction,
115
+ actionArgs: params,
116
+ antiCSRFToken: this._antiCSRFToken
117
+ });
118
+ });
119
+ }
120
+ _sendMessage(message) {
121
+ if (!this._postMessageSource) {
122
+ this._postMessageQueue.push(message);
123
+ } else {
124
+ this._postMessageSource.postMessage(message);
125
+ }
126
+ }
127
+ _getCallbackId(pluginName) {
128
+ return "instanceId=" + this._instanceId + "_" + pluginName + this._currentCallbackId++;
129
+ }
130
+ };
131
+
132
+ var bridgePromise;
133
+ async function executePluginAsync(pluginName, pluginAction, params = [], update) {
134
+ const powerAppsBridge = await getBridge();
135
+ return powerAppsBridge.executePluginAsync(pluginName, pluginAction, params, update);
136
+ }
137
+ async function getBridge() {
138
+ if (!bridgePromise) {
139
+ bridgePromise = new Promise(async (resolve, reject) => {
140
+ try {
141
+ const bridge = window && window.powerAppsBridge ? window.powerAppsBridge : new DefaultPowerAppsBridge();
142
+ await bridge.initialize();
143
+ resolve(bridge);
144
+ } catch (error) {
145
+ bridgePromise = void 0;
146
+ reject(error);
147
+ }
148
+ });
149
+ }
150
+ return bridgePromise;
151
+ }
152
+
153
+ var context;
154
+ async function getContext() {
155
+ if (context) {
156
+ return context;
157
+ }
158
+ context = await executePluginAsync("AppLifecycle", "getContext");
159
+ return context;
160
+ }
161
+
162
+ var IncompatibleMessageReceiver = class {
163
+ constructor(versionInfo, incompatibilityDescription) {
164
+ __publicField(this, "versionInfo");
165
+ __publicField(this, "incompatibilityDescription");
166
+ __publicField(this, "isCompatible", false);
167
+ this.versionInfo = versionInfo;
168
+ this.incompatibilityDescription = incompatibilityDescription;
169
+ }
170
+ };
171
+
172
+ var SendMessageOperation = class {
173
+ constructor(resultPromise, sendUpdate) {
174
+ __publicField(this, "resultPromise");
175
+ __publicField(this, "sendUpdate");
176
+ /**
177
+ * When completed is false onMessageReceived and sendUpdate will be visible.
178
+ * When completed is true then these are hidden.
179
+ */
180
+ __publicField(this, "completed", false);
181
+ __publicField(this, "onMessageReceived");
182
+ this.resultPromise = resultPromise;
183
+ this.sendUpdate = sendUpdate;
184
+ }
185
+ };
186
+
187
+ var CompatibleMessageReceiver = class {
188
+ constructor(_receiverName, versionInfo) {
189
+ __publicField(this, "_receiverName");
190
+ __publicField(this, "versionInfo");
191
+ __publicField(this, "isCompatible", true);
192
+ this._receiverName = _receiverName;
193
+ this.versionInfo = versionInfo;
194
+ }
195
+ async sendMessage(message, onMessageReceived) {
196
+ let resolveOperationPromise;
197
+ let rejectOperationPromise;
198
+ const operationPromise = new Promise((resolve, reject) => {
199
+ resolveOperationPromise = resolve;
200
+ rejectOperationPromise = reject;
201
+ });
202
+ const correlationId = crypto.randomUUID();
203
+ const handleMessage = (compatibleReceiverMessage) => {
204
+ try {
205
+ if (sendMessageOperation.completed) {
206
+ return;
207
+ }
208
+ if (compatibleReceiverMessage) {
209
+ if (compatibleReceiverMessage.isUpdate) {
210
+ if (sendMessageOperation.onMessageReceived) {
211
+ try {
212
+ sendMessageOperation.onMessageReceived(compatibleReceiverMessage.message);
213
+ } catch (error) {
214
+ sendMessageOperation.completed = true;
215
+ rejectOperationPromise(error);
216
+ }
217
+ } else {
218
+ sendMessageOperation.completed = true;
219
+ rejectOperationPromise(new Error(`Native receiver expected a message handler, but no handler was supplied. Message: ${compatibleReceiverMessage.message}`));
220
+ }
221
+ } else {
222
+ sendMessageOperation.completed = true;
223
+ resolveOperationPromise(compatibleReceiverMessage.message);
224
+ }
225
+ return;
226
+ }
227
+ } catch {
228
+ }
229
+ sendMessageOperation.completed = true;
230
+ resolveOperationPromise(compatibleReceiverMessage.message);
231
+ };
232
+ const handleError = (error) => {
233
+ sendMessageOperation.completed = true;
234
+ rejectOperationPromise(error);
235
+ };
236
+ const sendUpdate = (updateMessage) => {
237
+ if (sendMessageOperation.completed) {
238
+ throw new Error("Tried to send update for completed operation.");
239
+ }
240
+ executePluginAsync("SendMessagePlugin", "sendMessage", [
241
+ this._receiverName,
242
+ updateMessage,
243
+ correlationId
244
+ ]);
245
+ };
246
+ const sendMessageOperation = new SendMessageOperation(operationPromise, sendUpdate);
247
+ sendMessageOperation.onMessageReceived = onMessageReceived;
248
+ try {
249
+ await executePluginAsync("SendMessagePlugin", "sendMessage", [this._receiverName, message, correlationId], (response) => {
250
+ handleMessage(response);
251
+ });
252
+ } catch (error) {
253
+ handleError(error);
254
+ }
255
+ return sendMessageOperation;
256
+ }
257
+ };
258
+
259
+ var SendMessage = class _SendMessage {
260
+ static createInstanceAsync() {
261
+ return Promise.resolve(new _SendMessage());
262
+ }
263
+ async getMessageReceiverAsync(receiverName, isCompatibleChecker) {
264
+ const versionInfo = await this._getVersionInfo(receiverName);
265
+ if (versionInfo) {
266
+ const compatibilityCheckerResult = isCompatibleChecker(versionInfo);
267
+ if (compatibilityCheckerResult.isCompatible === false) {
268
+ return new IncompatibleMessageReceiver(versionInfo, compatibilityCheckerResult.incompatibilityDescription || "");
269
+ } else {
270
+ return new CompatibleMessageReceiver(receiverName, versionInfo);
271
+ }
272
+ } else {
273
+ return new IncompatibleMessageReceiver(void 0, `No receiver ${receiverName} registered.`);
274
+ }
275
+ }
276
+ async _getVersionInfo(receiverName) {
277
+ const result = await executePluginAsync("SendMessagePlugin", "getVersionInfo", [receiverName]);
278
+ return result;
279
+ }
280
+ };
281
+
282
+ var loggerInstance;
283
+ async function initializeLogger(logger) {
284
+ loggerInstance = logger;
285
+ const sendMessagePlugin = await SendMessage.createInstanceAsync();
286
+ const receiver = await sendMessagePlugin.getMessageReceiverAsync("PowerApps.AppMonitorReceiver", (versionInfo) => {
287
+ let isCompatible = false;
288
+ if (versionInfo === "1.0.0") {
289
+ isCompatible = true;
290
+ }
291
+ return { isCompatible };
292
+ });
293
+ if (receiver.isCompatible) {
294
+ await receiver.sendMessage("initialize", (message) => {
295
+ const parsedMessage = JSON.parse(message);
296
+ if (parsedMessage.metrics) {
297
+ for (const metric of parsedMessage.metrics) {
298
+ loggerInstance.logMetric?.(metric);
299
+ }
300
+ }
301
+ });
302
+ }
303
+ }
304
+
305
+ function getAppLoadedPerformanceData() {
306
+ const performanceApi = new PerformanceApi();
307
+ const perfData = {
308
+ appTimeOrigin: performanceApi.timeOrigin
309
+ };
310
+ const navigationTimingEntries = performanceApi.getEntriesByType("navigation");
311
+ const navigationTiming = navigationTimingEntries[0];
312
+ if (navigationTiming) {
313
+ perfData.appNavigateType = navigationTiming.type;
314
+ perfData.appNavigationStart = navigationTiming.startTime;
315
+ perfData.appNavigationDuration = navigationTiming.duration;
316
+ perfData.appEncodedBodySize = navigationTiming.encodedBodySize;
317
+ perfData.appNextHopProtocol = navigationTiming.nextHopProtocol;
318
+ perfData.appDomainLookupStart = navigationTiming.domainLookupStart;
319
+ perfData.appDomainLookupEnd = navigationTiming.domainLookupEnd;
320
+ perfData.appConnectStart = navigationTiming.connectStart;
321
+ perfData.appConnectEnd = navigationTiming.connectEnd;
322
+ perfData.appSecureConnectionStart = navigationTiming.secureConnectionStart;
323
+ perfData.appFetchStart = navigationTiming.fetchStart;
324
+ perfData.appRequestStart = navigationTiming.requestStart;
325
+ perfData.appResponseStart = navigationTiming.responseStart;
326
+ perfData.appResponseEnd = navigationTiming.responseEnd;
327
+ perfData.appLoadEventEnd = navigationTiming.loadEventEnd;
328
+ perfData.appDomInteractive = navigationTiming.domInteractive;
329
+ perfData.appDomContentLoadedEventStart = navigationTiming.domContentLoadedEventStart;
330
+ }
331
+ return perfData;
332
+ }
333
+ var PerformanceApi = class {
334
+ constructor(targetWindow = window) {
335
+ __publicField(this, "_performance");
336
+ this._performance = targetWindow.performance;
337
+ }
338
+ get timeOrigin() {
339
+ return this._performance?.timeOrigin;
340
+ }
341
+ getEntriesByType(type) {
342
+ if (!this._performance?.getEntriesByType) {
343
+ return [];
344
+ }
345
+ return this._performance.getEntriesByType(type);
346
+ }
347
+ };
348
+
349
+ executePluginAsync("AppLifecycle", "notifyAppSdkLoaded", [getAppLoadedPerformanceData()]);
350
+
351
+ function setConfig(config) {
352
+ if (config.logger) {
353
+ initializeLogger(config.logger);
354
+ }
355
+ }
356
+
6
357
  var HttpMethod;
7
358
  (function(HttpMethod2) {
8
359
  HttpMethod2["GET"] = "GET";
@@ -17,7 +368,6 @@ var DataSources;
17
368
  DataSources2["Connector"] = "Connector";
18
369
  })(DataSources || (DataSources = {}));
19
370
 
20
- // node_modules/@microsoft/power-apps/lib/internal/data/core/error/codes.js
21
371
  var ErrorCodes;
22
372
  (function(ErrorCodes2) {
23
373
  ErrorCodes2["InitializationFailed"] = "PDR_INIT_FAILED";
@@ -44,7 +394,6 @@ var ErrorCodes;
44
394
  ErrorCodes2["TokenAcquisitionFailed"] = "TOKEN_ACQUISITION_FAILED";
45
395
  })(ErrorCodes || (ErrorCodes = {}));
46
396
 
47
- // node_modules/@microsoft/power-apps/lib/internal/data/core/error/messages.js
48
397
  var UnknownErrorMessage = "An unknown error occurred";
49
398
  var ErrorMessages = {
50
399
  // PowerDataRuntime specific errors
@@ -93,12 +442,10 @@ var DataOperationErrorMessages;
93
442
  DataOperationErrorMessages2["UpdateFailed"] = "Update operation failure";
94
443
  })(DataOperationErrorMessages || (DataOperationErrorMessages = {}));
95
444
 
96
- // node_modules/@microsoft/power-apps/lib/internal/data/core/types/index.js
97
445
  function isOperationResult(result) {
98
446
  return result?.success !== void 0;
99
447
  }
100
448
 
101
- // node_modules/@microsoft/power-apps/lib/internal/data/core/telemetry/log.js
102
449
  var ServiceName = "PublishedAppTelemetry";
103
450
  var TelemetryActionNames;
104
451
  (function(TelemetryActionNames2) {
@@ -207,7 +554,6 @@ var _Log = class _Log {
207
554
  __publicField(_Log, "_instance", null);
208
555
  var Log = _Log;
209
556
 
210
- // node_modules/@microsoft/power-apps/lib/internal/data/core/error/types.js
211
557
  var PowerDataRuntimeError = class extends Error {
212
558
  /**
213
559
  * Creates an instance of PowerDataRuntimeError.
@@ -228,7 +574,6 @@ var PowerDataRuntimeError = class extends Error {
228
574
  }
229
575
  };
230
576
 
231
- // node_modules/@microsoft/power-apps/lib/internal/data/core/error/constants.js
232
577
  var HeaderNames;
233
578
  (function(HeaderNames2) {
234
579
  HeaderNames2["RequestId"] = "x-ms-client-request-id";
@@ -250,7 +595,6 @@ var ConnectorOperationName;
250
595
  ConnectorOperationName2["RetrieveMultipleRecords"] = "connectorDataOperation.retrieveMultipleRecordsAsync";
251
596
  })(ConnectorOperationName || (ConnectorOperationName = {}));
252
597
 
253
- // node_modules/@microsoft/power-apps/lib/internal/data/core/error/util.js
254
598
  function getErrorMessage(error) {
255
599
  if (typeof error === "string") {
256
600
  return error;
@@ -300,7 +644,6 @@ function parseHttpPluginError(error) {
300
644
  };
301
645
  }
302
646
 
303
- // node_modules/@microsoft/power-apps/lib/internal/data/core/data/defaultOperationOrchestrator.js
304
647
  var DefaultDataOperationOrchestrator = class {
305
648
  // Static identifiers for services and actions
306
649
  // Used to identify specific services and actions within the PowerApps environment
@@ -488,7 +831,6 @@ var DefaultDataOperationOrchestrator = class {
488
831
  }
489
832
  };
490
833
 
491
- // node_modules/@microsoft/power-apps/lib/internal/data/core/metadata/runtimeMetadataOperations.js
492
834
  var RuntimeMetadataOperations = class {
493
835
  // Static identifiers for services and actions
494
836
  // Used to identify specific services and actions within the PowerApps environment
@@ -496,18 +838,18 @@ var RuntimeMetadataOperations = class {
496
838
  __publicField(this, "_clientProvider");
497
839
  this._clientProvider = _clientProvider;
498
840
  }
499
- async getConnections(context) {
841
+ async getConnections(context2) {
500
842
  const client = await this._clientProvider.getMetadataClientAsync();
501
- const response = await client.getAppConnectionConfigsAsync(context);
843
+ const response = await client.getAppConnectionConfigsAsync(context2);
502
844
  return {
503
845
  success: response.success,
504
846
  data: response.data ? [response.data] : [],
505
847
  error: response.error
506
848
  };
507
849
  }
508
- async getConnectionApis(_connectionId, context) {
850
+ async getConnectionApis(_connectionId, context2) {
509
851
  const client = await this._clientProvider.getMetadataClientAsync();
510
- const response = await client.getAppDataSourceConfigsAsync(context);
852
+ const response = await client.getAppDataSourceConfigsAsync(context2);
511
853
  return {
512
854
  success: response.success,
513
855
  data: response.data ? [response.data] : [],
@@ -516,7 +858,6 @@ var RuntimeMetadataOperations = class {
516
858
  }
517
859
  };
518
860
 
519
- // node_modules/@microsoft/power-apps/lib/internal/data/core/common/utils.js
520
861
  function arrayBufferToBase64(buffer) {
521
862
  return window.btoa(convertArrayBufferToString(buffer));
522
863
  }
@@ -541,7 +882,6 @@ function extractDataverseUrlParts(url) {
541
882
  return { baseUrl, encodedPath };
542
883
  }
543
884
 
544
- // node_modules/@microsoft/power-apps/lib/internal/data/core/runtimeClient/runtimeDataClient.js
545
885
  var _RuntimeDataClient = class _RuntimeDataClient {
546
886
  // Constructor for RuntimeDataClient
547
887
  // Accepts an IPowerOperationExecutor instance for executing operations
@@ -566,7 +906,7 @@ var _RuntimeDataClient = class _RuntimeDataClient {
566
906
  * @throws Error if the request fails or the response is invalid
567
907
  * @throws Error if the request body is invalid
568
908
  */
569
- async createDataAsync(url, apiId, tableName, body, context) {
909
+ async createDataAsync(url, apiId, tableName, body, context2) {
570
910
  try {
571
911
  if (!body) {
572
912
  throw new Error(`${DataOperationErrorMessages.InvalidRequest}: ${DataOperationErrorMessages.MissingRequestBody}`);
@@ -578,8 +918,8 @@ var _RuntimeDataClient = class _RuntimeDataClient {
578
918
  tableName,
579
919
  body: JSON.stringify(body)
580
920
  };
581
- context = this._ensureContext(context, "runtimeDataClient.createDataAsync");
582
- return await this._executeRequest(config, context);
921
+ context2 = this._ensureContext(context2, "runtimeDataClient.createDataAsync");
922
+ return await this._executeRequest(config, context2);
583
923
  } catch (error) {
584
924
  if (isOperationResult(error)) {
585
925
  return error;
@@ -599,7 +939,7 @@ var _RuntimeDataClient = class _RuntimeDataClient {
599
939
  * @throws Error if the request fails or the response is invalid
600
940
  * @throws Error if the request body is invalid
601
941
  */
602
- async updateDataAsync(url, apiId, tableName, body, context) {
942
+ async updateDataAsync(url, apiId, tableName, body, context2) {
603
943
  try {
604
944
  if (!body) {
605
945
  throw new Error(`${DataOperationErrorMessages.InvalidRequest}: ${DataOperationErrorMessages.MissingRequestBody}`);
@@ -611,8 +951,8 @@ var _RuntimeDataClient = class _RuntimeDataClient {
611
951
  tableName,
612
952
  body: JSON.stringify(body)
613
953
  };
614
- context = this._ensureContext(context, "runtimeDataClient.updateDataAsync");
615
- return await this._executeRequest(config, context);
954
+ context2 = this._ensureContext(context2, "runtimeDataClient.updateDataAsync");
955
+ return await this._executeRequest(config, context2);
616
956
  } catch (error) {
617
957
  if (isOperationResult(error)) {
618
958
  return error;
@@ -630,7 +970,7 @@ var _RuntimeDataClient = class _RuntimeDataClient {
630
970
  * @return Promise resolving to the response data
631
971
  * @throws Error if the request fails or the response is invalid
632
972
  */
633
- async deleteDataAsync(url, connectionApi, serviceNamespace, context) {
973
+ async deleteDataAsync(url, connectionApi, serviceNamespace, context2) {
634
974
  try {
635
975
  const config = {
636
976
  url,
@@ -638,8 +978,8 @@ var _RuntimeDataClient = class _RuntimeDataClient {
638
978
  apiId: connectionApi,
639
979
  tableName: serviceNamespace
640
980
  };
641
- context = this._ensureContext(context, "runtimeDataClient.deleteDataAsync");
642
- return await this._executeRequest(config, context);
981
+ context2 = this._ensureContext(context2, "runtimeDataClient.deleteDataAsync");
982
+ return await this._executeRequest(config, context2);
643
983
  } catch (error) {
644
984
  if (isOperationResult(error)) {
645
985
  return error;
@@ -660,7 +1000,7 @@ var _RuntimeDataClient = class _RuntimeDataClient {
660
1000
  * @return Promise resolving to the response data
661
1001
  * @throws Error if the request fails or the response is invalid
662
1002
  */
663
- async retrieveDataAsync(url, apiId, tableName, method, headers, body, context) {
1003
+ async retrieveDataAsync(url, apiId, tableName, method, headers, body, context2) {
664
1004
  try {
665
1005
  const config = {
666
1006
  url,
@@ -670,8 +1010,8 @@ var _RuntimeDataClient = class _RuntimeDataClient {
670
1010
  headers,
671
1011
  body: body ? typeof body === "string" ? body : JSON.stringify(body) : void 0
672
1012
  };
673
- context = this._ensureContext(context, "runtimeDataClient.retrieveDataAsync");
674
- return await this._executeRequest(config, context);
1013
+ context2 = this._ensureContext(context2, "runtimeDataClient.retrieveDataAsync");
1014
+ return await this._executeRequest(config, context2);
675
1015
  } catch (error) {
676
1016
  if (isOperationResult(error)) {
677
1017
  return error;
@@ -728,7 +1068,7 @@ var _RuntimeDataClient = class _RuntimeDataClient {
728
1068
  * @return The headers for the request
729
1069
  * @throws Error if header creation fails
730
1070
  */
731
- _createHeaders(token, config, context) {
1071
+ _createHeaders(token, config, context2) {
732
1072
  const baseHeaders = {
733
1073
  Accept: "application/json",
734
1074
  "x-ms-protocol-semantics": "cdp",
@@ -736,14 +1076,14 @@ var _RuntimeDataClient = class _RuntimeDataClient {
736
1076
  Authorization: `paauth ${token}`,
737
1077
  "x-ms-pa-client-custom-headers-options": '{"addCustomHeaders":true}',
738
1078
  "x-ms-enable-selects": "true",
739
- "x-ms-pa-client-telemetry-options": `paclient-telemetry {"operationName":"${context?.operationName ?? "runtimeDataClient.executeRequest"}"}`,
1079
+ "x-ms-pa-client-telemetry-options": `paclient-telemetry {"operationName":"${context2?.operationName ?? "runtimeDataClient.executeRequest"}"}`,
740
1080
  "x-ms-pa-client-telemetry-additional-data": `{"apiId":"${config.apiId}"}`
741
1081
  };
742
1082
  if (config.apiId === DataSources.Dataverse) {
743
1083
  baseHeaders["x-ms-protocol-semantics"] = DataSources.Dataverse;
744
1084
  baseHeaders.Authorization = `dynamicauth ${token}`;
745
1085
  const { baseUrl, encodedPath } = extractDataverseUrlParts(config.url);
746
- const batchId = context?.batchId || "";
1086
+ const batchId = context2?.batchId || "";
747
1087
  const preferHeader = this._mergePreferHeaders(config.headers, config.method);
748
1088
  baseHeaders.BatchInfo = JSON.stringify({
749
1089
  baseUrl,
@@ -769,9 +1109,9 @@ var _RuntimeDataClient = class _RuntimeDataClient {
769
1109
  * @throws Error if the request fails or the response is invalid
770
1110
  * @throws Error if the response content type is invalid
771
1111
  */
772
- async _executeRequest(config, context) {
773
- const token = await this._getAccessToken(config.apiId, context?.datasetName);
774
- const headers = this._createHeaders(token, config, context);
1112
+ async _executeRequest(config, context2) {
1113
+ const token = await this._getAccessToken(config.apiId, context2?.datasetName);
1114
+ const headers = this._createHeaders(token, config, context2);
775
1115
  const requestBody = config.body ? new Blob([config.body], { type: "application/json" }) : "";
776
1116
  let result;
777
1117
  try {
@@ -809,12 +1149,12 @@ var _RuntimeDataClient = class _RuntimeDataClient {
809
1149
  text = "{}";
810
1150
  }
811
1151
  const parsedResult = JSON.parse(text);
812
- if (context?.isDataVerseOperation || this._isDataverseCall(config.url)) {
1152
+ if (context2?.isDataVerseOperation || this._isDataverseCall(config.url)) {
813
1153
  return {
814
1154
  success: true,
815
1155
  data: parsedResult
816
1156
  };
817
- } else if (!context?.isExecuteAsync && "value" in parsedResult && Array.isArray(parsedResult.value)) {
1157
+ } else if (!context2?.isExecuteAsync && "value" in parsedResult && Array.isArray(parsedResult.value)) {
818
1158
  return {
819
1159
  success: true,
820
1160
  data: parsedResult.value,
@@ -844,7 +1184,7 @@ var _RuntimeDataClient = class _RuntimeDataClient {
844
1184
  if (buffer instanceof ArrayBuffer) {
845
1185
  const value = convertArrayBufferToString(buffer);
846
1186
  const status = responseData[0].status;
847
- const responseType = context?.responseInfo?.[status];
1187
+ const responseType = context2?.responseInfo?.[status];
848
1188
  if (responseType) {
849
1189
  let parsedValue;
850
1190
  try {
@@ -888,14 +1228,14 @@ var _RuntimeDataClient = class _RuntimeDataClient {
888
1228
  };
889
1229
  }
890
1230
  }
891
- _ensureContext(context, defaultOperationName) {
892
- if (!context) {
893
- context = {};
1231
+ _ensureContext(context2, defaultOperationName) {
1232
+ if (!context2) {
1233
+ context2 = {};
894
1234
  }
895
- if (!context.operationName) {
896
- context.operationName = defaultOperationName;
1235
+ if (!context2.operationName) {
1236
+ context2.operationName = defaultOperationName;
897
1237
  }
898
- return context;
1238
+ return context2;
899
1239
  }
900
1240
  /**
901
1241
  * Checks if the given URL is a Dataverse API call
@@ -951,7 +1291,6 @@ __publicField(_RuntimeDataClient, "ACTIONS", {
951
1291
  __publicField(_RuntimeDataClient, "REQUEST_SOURCE", "PublishedApp");
952
1292
  var RuntimeDataClient = _RuntimeDataClient;
953
1293
 
954
- // node_modules/@microsoft/power-apps/lib/internal/data/core/runtimeClient/runtimeMetadataClient.js
955
1294
  var _RuntimeMetadataClient = class _RuntimeMetadataClient {
956
1295
  // Private member for the PowerOperationExecutor
957
1296
  // The PowerOperationExecutor is used to execute operations on the clients
@@ -1012,13 +1351,23 @@ var _RuntimeMetadataClient = class _RuntimeMetadataClient {
1012
1351
  async _executeOperation(config) {
1013
1352
  try {
1014
1353
  const result = await this._powerOperationExecutor.execute(config.service, config.action, config.params || []);
1015
- const lowerCaseResult = Object.keys(result.data).reduce((acc, key) => {
1016
- acc[key.toLowerCase()] = (result.data ?? {})[key];
1354
+ const rawResult = result && typeof result === "object" && "data" in result ? result.data : result;
1355
+ const normalizedResult = Array.isArray(rawResult) && rawResult.length === 1 && rawResult[0] && typeof rawResult[0] === "object"
1356
+ ? rawResult[0]
1357
+ : rawResult;
1358
+ if (!normalizedResult || typeof normalizedResult !== "object" || Array.isArray(normalizedResult)) {
1359
+ throw new PowerDataRuntimeError(ErrorCodes.InvalidMetadataResponse, JSON.stringify(rawResult));
1360
+ }
1361
+ const lowerCaseResult = Object.keys(normalizedResult).reduce((acc, key) => {
1362
+ acc[key.toLowerCase()] = normalizedResult[key];
1017
1363
  return acc;
1018
1364
  }, {});
1019
1365
  return lowerCaseResult;
1020
- } catch {
1021
- throw new PowerDataRuntimeError(ErrorCodes.InvalidMetadataResponse);
1366
+ } catch (error) {
1367
+ if (error instanceof PowerDataRuntimeError) {
1368
+ throw error;
1369
+ }
1370
+ throw new PowerDataRuntimeError(ErrorCodes.InvalidMetadataResponse, getErrorMessage(error));
1022
1371
  }
1023
1372
  }
1024
1373
  };
@@ -1036,7 +1385,6 @@ __publicField(_RuntimeMetadataClient, "ACTIONS", {
1036
1385
  });
1037
1386
  var RuntimeMetadataClient = _RuntimeMetadataClient;
1038
1387
 
1039
- // node_modules/@microsoft/power-apps/lib/internal/data/core/runtimeClient/runtimeClientProvider.js
1040
1388
  var RuntimeClientProvider = class {
1041
1389
  // Constructor for RuntimeClientProvider
1042
1390
  // Accepts an optional IPowerOperationExecutor instance for executing operations
@@ -1112,7 +1460,6 @@ var RuntimeClientProvider = class {
1112
1460
  }
1113
1461
  };
1114
1462
 
1115
- // node_modules/@microsoft/power-apps/lib/internal/data/core/data/executors/shared/stringQueryOptions.js
1116
1463
  function convertOptionsToQueryString(options) {
1117
1464
  if (!options) {
1118
1465
  return "";
@@ -1143,7 +1490,6 @@ function convertOptionsToQueryString(options) {
1143
1490
  return parts.length ? `?${parts.join("&")}` : "";
1144
1491
  }
1145
1492
 
1146
- // node_modules/@microsoft/power-apps/lib/internal/data/core/data/executors/dataverseDataOperationExecutor.js
1147
1493
  var ODATA_NEXT_LINK = "@odata.nextLink";
1148
1494
  var DataverseDataOperationExecutor = class {
1149
1495
  constructor(clientProvider) {
@@ -1575,7 +1921,6 @@ function extractSkipToken(nextLink) {
1575
1921
  return match ? decodeURIComponent(match[1]) : void 0;
1576
1922
  }
1577
1923
 
1578
- // node_modules/@microsoft/power-apps/lib/internal/data/core/data/executors/connectorDataOperationExecutor.js
1579
1924
  var ConnectorDataOperationExecutor = class {
1580
1925
  // =====================================
1581
1926
  // Constructor
@@ -2076,7 +2421,6 @@ var ConnectorDataOperationExecutor = class {
2076
2421
  }
2077
2422
  };
2078
2423
 
2079
- // node_modules/@microsoft/power-apps/lib/internal/data/core/metadata/runtimeDataSourceService.js
2080
2424
  var DataSourceServiceError;
2081
2425
  /* @__PURE__ */ (function(DataSourceServiceError2) {
2082
2426
  })(DataSourceServiceError || (DataSourceServiceError = {}));
@@ -2167,7 +2511,6 @@ var RuntimeDataSourceService = class {
2167
2511
  }
2168
2512
  };
2169
2513
 
2170
- // node_modules/@microsoft/power-apps/lib/internal/data/core/runtime/powerDataRuntime.js
2171
2514
  var PowerDataRuntime = class {
2172
2515
  /**
2173
2516
  * Creates a new instance of PowerDataRuntime
@@ -2253,7 +2596,6 @@ var PowerDataRuntime = class {
2253
2596
  }
2254
2597
  };
2255
2598
 
2256
- // node_modules/@microsoft/power-apps/lib/internal/data/core/runtime/powerDataRuntimeInstance.js
2257
2599
  var powerDataRuntimeInstance;
2258
2600
  function getPowerDataRuntime(powerDataSourcesInfoProvider, powerOperationExecutor) {
2259
2601
  if (!powerDataRuntimeInstance) {
@@ -2265,7 +2607,6 @@ function getPowerDataRuntime(powerDataSourcesInfoProvider, powerOperationExecuto
2265
2607
  return powerDataRuntimeInstance;
2266
2608
  }
2267
2609
 
2268
- // node_modules/@microsoft/power-apps/lib/internal/data/core/runtime/powerDataSourcesInfoProvider.js
2269
2610
  var _PowerDataSourcesInfoProvider = class _PowerDataSourcesInfoProvider {
2270
2611
  /**
2271
2612
  * Private constructor to enforce the singleton pattern.
@@ -2305,121 +2646,22 @@ __publicField(_PowerDataSourcesInfoProvider, "instance", null);
2305
2646
  var PowerDataSourcesInfoProvider = _PowerDataSourcesInfoProvider;
2306
2647
  var powerDataSourcesInfoProvider_default = PowerDataSourcesInfoProvider;
2307
2648
 
2308
- // node_modules/@microsoft/power-apps/lib/internal/plugins/DefaultPowerAppsBridge.js
2309
- var DefaultPowerAppsBridge = class {
2310
- constructor() {
2311
- __publicField(this, "_antiCSRFToken");
2312
- __publicField(this, "_callbacks", {});
2313
- __publicField(this, "_currentCallbackId", 0);
2314
- __publicField(this, "_instanceId", Date.now().toString());
2315
- __publicField(this, "_messageChannel", new window.MessageChannel());
2316
- __publicField(this, "_postMessageQueue", []);
2317
- __publicField(this, "_postMessageSource");
2318
- __publicField(this, "_handleMessageEvent", (messageEvent) => {
2319
- const message = messageEvent.data;
2320
- if (message && typeof message.isPluginCall === "boolean") {
2321
- if (message.isPluginCall) {
2322
- const callbackId = message.callbackId;
2323
- const status = message.status;
2324
- const args = message.args;
2325
- const keepCallback = message.keepCallback;
2326
- try {
2327
- const callback = this._callbacks[callbackId];
2328
- if (keepCallback) {
2329
- if (callback && callback.onUpdate) {
2330
- callback.onUpdate(message.args?.[0]);
2331
- }
2332
- } else {
2333
- if (callback) {
2334
- if (status === 1) {
2335
- callback.resolve(args[0]);
2336
- } else if (status !== 0) {
2337
- callback.reject(args);
2338
- }
2339
- }
2340
- if (!keepCallback) {
2341
- delete this._callbacks[callbackId];
2342
- }
2343
- }
2344
- } catch (error) {
2345
- console.error(error);
2346
- }
2347
- }
2348
- } else if (message && message.messageType === "initCommunication") {
2349
- this._antiCSRFToken = message.antiCSRFToken;
2350
- this._postMessageSource = this._messageChannel.port1;
2351
- if (this._postMessageSource) {
2352
- for (let i = 0; i < this._postMessageQueue.length; i++) {
2353
- this._postMessageQueue[i].antiCSRFToken = this._antiCSRFToken;
2354
- this._postMessageSource.postMessage(this._postMessageQueue[i]);
2355
- }
2356
- }
2357
- }
2358
- });
2359
- }
2360
- async initialize() {
2361
- this._messageChannel.port1.onmessage = this._handleMessageEvent;
2362
- window.parent.postMessage({
2363
- messageType: "initCommunicationWithPort",
2364
- instanceId: this._instanceId
2365
- }, "*", [this._messageChannel.port2]);
2366
- }
2367
- async executePluginAsync(pluginName, pluginAction, params = [], onUpdate) {
2368
- return new Promise((resolve, reject) => {
2369
- const callbackId = this._getCallbackId(pluginName);
2370
- this._callbacks[callbackId] = { resolve, reject, onUpdate };
2371
- this._sendMessage({
2372
- isPluginCall: true,
2373
- callbackId,
2374
- service: pluginName,
2375
- action: pluginAction,
2376
- actionArgs: params,
2377
- antiCSRFToken: this._antiCSRFToken
2378
- });
2379
- });
2380
- }
2381
- _sendMessage(message) {
2382
- if (!this._postMessageSource) {
2383
- this._postMessageQueue.push(message);
2384
- } else {
2385
- this._postMessageSource.postMessage(message);
2386
- }
2387
- }
2388
- _getCallbackId(pluginName) {
2389
- return "instanceId=" + this._instanceId + "_" + pluginName + this._currentCallbackId++;
2390
- }
2391
- };
2392
-
2393
- // node_modules/@microsoft/power-apps/lib/internal/plugins/PluginBridge.js
2394
- var bridgePromise;
2395
- async function executePluginAsync(pluginName, pluginAction, params = [], update) {
2396
- const powerAppsBridge = await getBridge();
2397
- return powerAppsBridge.executePluginAsync(pluginName, pluginAction, params, update);
2398
- }
2399
- async function getBridge() {
2400
- if (!bridgePromise) {
2401
- bridgePromise = new Promise(async (resolve, reject) => {
2402
- try {
2403
- const bridge = window && window.powerAppsBridge ? window.powerAppsBridge : new DefaultPowerAppsBridge();
2404
- await bridge.initialize();
2405
- resolve(bridge);
2406
- } catch (error) {
2407
- reject(error);
2408
- }
2409
- });
2410
- }
2411
- return bridgePromise;
2412
- }
2413
-
2414
- // node_modules/@microsoft/power-apps/lib/internal/data/ConnectionUtils.js
2415
2649
  var connectionsLoaded = false;
2416
2650
  async function loadConnections() {
2417
2651
  if (connectionsLoaded) {
2418
2652
  return;
2419
2653
  }
2420
2654
  connectionsLoaded = true;
2421
- await loadNonCompositeConnectionsAsync();
2422
- await resolveCompositeConnectionsAsync();
2655
+ try {
2656
+ await loadNonCompositeConnectionsAsync();
2657
+ } catch (error) {
2658
+ console.warn("Power Apps connection preload failed; continuing with runtime metadata fetch.", error);
2659
+ }
2660
+ try {
2661
+ await resolveCompositeConnectionsAsync();
2662
+ } catch (error) {
2663
+ console.warn("Power Apps composite connection resolution failed; continuing with runtime metadata fetch.", error);
2664
+ }
2423
2665
  }
2424
2666
  async function loadNonCompositeConnectionsAsync() {
2425
2667
  return executePluginAsync("AppPowerAppsClientPlugin", "loadNonCompositeConnectionsAsync", []);
@@ -2428,7 +2670,6 @@ async function resolveCompositeConnectionsAsync() {
2428
2670
  return executePluginAsync("AppPowerAppsClientPlugin", "resolveCompositeConnectionsAsync", []);
2429
2671
  }
2430
2672
 
2431
- // node_modules/@microsoft/power-apps/lib/internal/data/OperationExecutor.js
2432
2673
  var loadConnectionsPromise;
2433
2674
  var OperationExecutor = class {
2434
2675
  /**
@@ -2455,7 +2696,6 @@ var OperationExecutor = class {
2455
2696
  }
2456
2697
  };
2457
2698
 
2458
- // node_modules/@microsoft/power-apps/lib/internal/data/core/runtime/getRuntimeContext.js
2459
2699
  var _executor;
2460
2700
  function getExecutor() {
2461
2701
  if (!_executor) {
@@ -2469,41 +2709,131 @@ async function getPowerSdkInstance(dataSourcesInfo) {
2469
2709
  return getPowerDataRuntime(provider, executor);
2470
2710
  }
2471
2711
 
2472
- // node_modules/@microsoft/power-apps/lib/internal/data/core/api/createRecord.js
2473
2712
  async function createRecordAsync(dataSourcesInfo, tableName, record) {
2474
2713
  return await (await getPowerSdkInstance(dataSourcesInfo)).Data.createRecordAsync(tableName, record);
2475
2714
  }
2476
2715
 
2477
- // node_modules/@microsoft/power-apps/lib/internal/data/core/api/updateRecord.js
2478
2716
  async function updateRecordAsync(dataSourcesInfo, tableName, recordId, changes) {
2479
2717
  return await (await getPowerSdkInstance(dataSourcesInfo)).Data.updateRecordAsync(tableName, recordId, changes);
2480
2718
  }
2481
2719
 
2482
- // node_modules/@microsoft/power-apps/lib/internal/data/core/api/deleteRecord.js
2483
2720
  async function deleteRecordAsync(dataSourcesInfo, tableName, recordId) {
2484
2721
  return await (await getPowerSdkInstance(dataSourcesInfo)).Data.deleteRecordAsync(tableName, recordId);
2485
2722
  }
2486
2723
 
2487
- // node_modules/@microsoft/power-apps/lib/internal/data/core/api/retrieveRecord.js
2488
2724
  async function retrieveRecordAsync(dataSourcesInfo, tableName, recordId, options) {
2489
2725
  return await (await getPowerSdkInstance(dataSourcesInfo)).Data.retrieveRecordAsync(tableName, recordId, options);
2490
2726
  }
2491
2727
 
2492
- // node_modules/@microsoft/power-apps/lib/internal/data/core/api/retrieveMultipleRecords.js
2493
2728
  async function retrieveMultipleRecordsAsync(dataSourcesInfo, tableName, options) {
2494
2729
  return await (await getPowerSdkInstance(dataSourcesInfo)).Data.retrieveMultipleRecordsAsync(tableName, options);
2495
2730
  }
2496
2731
 
2497
- // node_modules/@microsoft/power-apps/lib/internal/data/core/api/execute.js
2498
2732
  async function executeAsync(dataSourcesInfo, operation) {
2499
2733
  return await (await getPowerSdkInstance(dataSourcesInfo)).Data.executeAsync(operation);
2500
2734
  }
2501
2735
 
2502
- // node_modules/@microsoft/power-apps/lib/data/powerAppsData.js
2736
+ async function callActionAsync(dataSourcesInfo, actionName, params) {
2737
+ var sdkInstance = await getPowerSdkInstance(dataSourcesInfo);
2738
+ var dvExecutor = sdkInstance.Data._dataverseOperation;
2739
+ var dataClient = await dvExecutor._getDataClient();
2740
+ var dbRefs = await dvExecutor.getDatabaseReferences();
2741
+ var sInstanceUrl = null;
2742
+ var sDatasetName = null;
2743
+ for (var sDbKey of Object.keys(dbRefs)) {
2744
+ var oDb = dbRefs[sDbKey];
2745
+ if (oDb.databaseDetails && oDb.databaseDetails.linkedEnvironmentMetadata) {
2746
+ sInstanceUrl = oDb.databaseDetails.linkedEnvironmentMetadata.instanceUrl;
2747
+ sDatasetName = oDb.databaseDetails.environmentName;
2748
+ break;
2749
+ }
2750
+ }
2751
+ if (!sInstanceUrl) {
2752
+ throw new Error("Cannot call unbound action: no Dataverse instance URL found. Ensure at least one Dataverse table is registered.");
2753
+ }
2754
+ var sBaseUrl = sInstanceUrl.endsWith("/") ? sInstanceUrl : sInstanceUrl + "/";
2755
+ var sRequestUrl = sBaseUrl + "api/data/v9.0/" + actionName;
2756
+ var oContext = {
2757
+ operationName: DataverseOperationName.CreateRecord,
2758
+ datasetName: sDatasetName,
2759
+ isDataVerseOperation: true
2760
+ };
2761
+ var sToken = await dataClient._getAccessToken(DataSources.Dataverse, sDatasetName);
2762
+ var oHeaders = dataClient._createHeaders(sToken, {
2763
+ url: sRequestUrl,
2764
+ method: HttpMethod.POST,
2765
+ apiId: DataSources.Dataverse,
2766
+ tableName: actionName,
2767
+ body: JSON.stringify(params || {})
2768
+ }, oContext);
2769
+ var oRequestBody = new Blob([JSON.stringify(params || {})], { type: "application/json" });
2770
+ var oRawResult;
2771
+ try {
2772
+ oRawResult = await dataClient._powerOperationExecutor.execute(
2773
+ "AppHttpClientPlugin", "sendHttpAsync",
2774
+ [
2775
+ {
2776
+ url: sRequestUrl,
2777
+ method: HttpMethod.POST,
2778
+ requestSource: "PublishedApp",
2779
+ allowSessionStorage: true,
2780
+ returnDirectResponse: true,
2781
+ headers: oHeaders
2782
+ },
2783
+ oRequestBody,
2784
+ "arraybuffer"
2785
+ ]
2786
+ );
2787
+ } catch (oErr) {
2788
+ return { success: false, data: null, error: oErr };
2789
+ }
2790
+ var aResponseData = oRawResult.data;
2791
+ var oRespHeaders = aResponseData[0] ? aResponseData[0].headers || {} : {};
2792
+ var iStatus = aResponseData[0] ? aResponseData[0].status : 0;
2793
+ var sContentType = oRespHeaders["Content-Type"] || "";
2794
+ // HTTP 2xx with no body or no parseable content = success (void actions like GrantAccess)
2795
+ if (iStatus >= 200 && iStatus < 300 && (!sContentType || !aResponseData[1])) {
2796
+ return { success: true, data: null, error: null };
2797
+ }
2798
+ // Try to parse JSON response
2799
+ if (sContentType.indexOf("application/json") !== -1 && aResponseData[1]) {
2800
+ try {
2801
+ var sText = "";
2802
+ if (aResponseData[1] instanceof ArrayBuffer) {
2803
+ sText = new TextDecoder().decode(aResponseData[1]);
2804
+ } else if (typeof aResponseData[1] === "string") {
2805
+ sText = aResponseData[1];
2806
+ }
2807
+ if (!sText) sText = "{}";
2808
+ var oParsed = JSON.parse(sText);
2809
+ if (iStatus >= 200 && iStatus < 300) {
2810
+ return { success: true, data: oParsed, error: null };
2811
+ }
2812
+ // Error response from server
2813
+ var sErrMsg = oParsed.error ? (oParsed.error.message || JSON.stringify(oParsed.error)) : JSON.stringify(oParsed);
2814
+ return { success: false, data: null, error: { message: sErrMsg } };
2815
+ } catch (oParseErr) {
2816
+ if (iStatus >= 200 && iStatus < 300) {
2817
+ return { success: true, data: null, error: null };
2818
+ }
2819
+ return { success: false, data: null, error: { message: "Failed to parse action response" } };
2820
+ }
2821
+ }
2822
+ // Any other 2xx = success
2823
+ if (iStatus >= 200 && iStatus < 300) {
2824
+ return { success: true, data: null, error: null };
2825
+ }
2826
+ // Non-2xx with non-JSON body
2827
+ return { success: false, data: null, error: { message: "Action failed with status " + iStatus } };
2828
+ }
2829
+
2503
2830
  var _dataOperationExecutor;
2504
2831
  function getDataOperationExecutor() {
2505
2832
  return _dataOperationExecutor;
2506
2833
  }
2834
+ function setDataOperationExecutor(dataOperationExecutorOverride) {
2835
+ _dataOperationExecutor = dataOperationExecutorOverride;
2836
+ }
2507
2837
  function getClient(dataSourcesInfo) {
2508
2838
  return {
2509
2839
  createRecordAsync: (tableName, record) => {
@@ -2526,6 +2856,211 @@ function getClient(dataSourcesInfo) {
2526
2856
  }
2527
2857
  };
2528
2858
  }
2529
- export {
2530
- getClient
2859
+
2860
+ var MockDataOperationExecutor = class {
2861
+ constructor(data) {
2862
+ __publicField(this, "_dataStore");
2863
+ this._dataStore = data;
2864
+ }
2865
+ async createRecordAsync(tableName, data) {
2866
+ return {
2867
+ success: false,
2868
+ error: { message: "createRecordAsync is not supported by MockDataOperationExecutor" },
2869
+ data: null
2870
+ };
2871
+ }
2872
+ async updateRecordAsync(tableName, id, data) {
2873
+ return {
2874
+ success: false,
2875
+ error: { message: "updateRecordAsync is not supported by MockDataOperationExecutor" },
2876
+ data: null
2877
+ };
2878
+ }
2879
+ async deleteRecordAsync(tableName, id) {
2880
+ return {
2881
+ success: false,
2882
+ error: { message: "deleteRecordAsync is not supported by MockDataOperationExecutor" },
2883
+ data: void 0
2884
+ };
2885
+ }
2886
+ async retrieveRecordAsync(tableName, id, options) {
2887
+ if (!this._dataStore[tableName]) {
2888
+ return {
2889
+ success: false,
2890
+ error: { message: `table <${tableName}> not found` },
2891
+ data: null
2892
+ };
2893
+ }
2894
+ const record = this._dataStore[tableName][id];
2895
+ if (!record) {
2896
+ return {
2897
+ success: false,
2898
+ error: { message: `record with id "${id}" not found in table <${tableName}>` },
2899
+ data: null
2900
+ };
2901
+ }
2902
+ return {
2903
+ success: true,
2904
+ data: record
2905
+ };
2906
+ }
2907
+ async retrieveMultipleRecordsAsync(tableName, options) {
2908
+ if (!this._dataStore[tableName]) {
2909
+ return {
2910
+ success: false,
2911
+ error: { message: `table <${tableName}> not found` },
2912
+ data: []
2913
+ };
2914
+ }
2915
+ return {
2916
+ success: true,
2917
+ data: Object.values(this._dataStore[tableName])
2918
+ };
2919
+ }
2920
+ async executeAsync(operation) {
2921
+ return {
2922
+ success: false,
2923
+ error: { message: "executeAsync is not supported by MockDataOperationExecutor" },
2924
+ data: null
2925
+ };
2926
+ }
2927
+ };
2928
+ function createMockDataExecutor(data) {
2929
+ return new MockDataOperationExecutor(data);
2930
+ }
2931
+
2932
+ var entityClusterModeEnum = {
2933
+ 0: "Partitioned",
2934
+ 1: "Replicated",
2935
+ 2: "Local"
2936
+ };
2937
+ function getEntityClusterModeName(value) {
2938
+ return entityClusterModeEnum[value];
2939
+ }
2940
+ var ownershipTypeEnum = {
2941
+ 0: "None",
2942
+ 1: "UserOwned",
2943
+ 2: "TeamOwned",
2944
+ 4: "BusinessOwned",
2945
+ 8: "OrganizationOwned",
2946
+ 16: "BusinessParented",
2947
+ 32: "Filtered"
2948
+ };
2949
+ function getOwnershipTypeName(value) {
2950
+ return ownershipTypeEnum[value];
2951
+ }
2952
+ var privilegeTypeEnum = {
2953
+ 0: "None",
2954
+ 1: "Create",
2955
+ 2: "Read",
2956
+ 3: "Write",
2957
+ 4: "Delete",
2958
+ 5: "Assign",
2959
+ 6: "Share",
2960
+ 7: "Append",
2961
+ 8: "AppendTo"
2962
+ };
2963
+ function getPrivilegeTypeName(value) {
2964
+ return privilegeTypeEnum[value];
2965
+ }
2966
+ var attributeTypeCodeEnum = {
2967
+ 0: "Boolean",
2968
+ 1: "Customer",
2969
+ 2: "DateTime",
2970
+ 3: "Decimal",
2971
+ 4: "Double",
2972
+ 5: "Integer",
2973
+ 6: "Lookup",
2974
+ 7: "Memo",
2975
+ 8: "Money",
2976
+ 9: "Owner",
2977
+ 10: "PartyList",
2978
+ 11: "Picklist",
2979
+ 12: "State",
2980
+ 13: "Status",
2981
+ 14: "String",
2982
+ 15: "Uniqueidentifier",
2983
+ 16: "CalendarRules",
2984
+ 17: "Virtual",
2985
+ 18: "BigInt",
2986
+ 19: "ManagedProperty",
2987
+ 20: "EntityName"
2988
+ };
2989
+ function getAttributeTypeCodeName(value) {
2990
+ return attributeTypeCodeEnum[value];
2991
+ }
2992
+ var attributeRequiredLevelEnum = {
2993
+ 0: "None",
2994
+ 1: "SystemRequired",
2995
+ 2: "ApplicationRequired",
2996
+ 3: "Recommended"
2997
+ };
2998
+ function getAttributeRequiredLevelName(value) {
2999
+ return attributeRequiredLevelEnum[value];
3000
+ }
3001
+ var relationshipTypeEnum = {
3002
+ 0: "OneToManyRelationship",
3003
+ 1: "ManyToManyRelationship"
3004
+ };
3005
+ function getRelationshipTypeName(value) {
3006
+ return relationshipTypeEnum[value];
3007
+ }
3008
+ var securityTypesEnum = {
3009
+ 0: "None",
3010
+ 1: "Append",
3011
+ 2: "ParentChild",
3012
+ 8: "Pointer",
3013
+ 16: "Inheritance"
3014
+ // The referencing entity record inherits security from the referenced security record.
2531
3015
  };
3016
+ function getSecurityTypesName(value) {
3017
+ return securityTypesEnum[value];
3018
+ }
3019
+ var associatedMenuBehaviorEnum = {
3020
+ 0: "UseCollectionName",
3021
+ 1: "UseLabel",
3022
+ 2: "DoNotDisplay"
3023
+ };
3024
+ function getAssociatedMenuBehaviorName(value) {
3025
+ return associatedMenuBehaviorEnum[value];
3026
+ }
3027
+ var associatedMenuGroupEnum = {
3028
+ 0: "Details",
3029
+ 1: "Sales",
3030
+ 2: "Service",
3031
+ 3: "Marketing"
3032
+ };
3033
+ function getAssociatedMenuGroupName(value) {
3034
+ return associatedMenuGroupEnum[value];
3035
+ }
3036
+ var cascadeTypeEnum = {
3037
+ 0: "NoCascade",
3038
+ 1: "Cascade",
3039
+ 2: "Active",
3040
+ 3: "UserOwned",
3041
+ 4: "RemoveLink",
3042
+ 5: "Restrict"
3043
+ // Prevent the Referenced entity record from being deleted when referencing entities exist.
3044
+ };
3045
+ function getCascadeTypeName(value) {
3046
+ return cascadeTypeEnum[value];
3047
+ }
3048
+ export {
3049
+ callActionAsync,
3050
+ createMockDataExecutor,
3051
+ getAssociatedMenuBehaviorName,
3052
+ getAssociatedMenuGroupName,
3053
+ getAttributeRequiredLevelName,
3054
+ getAttributeTypeCodeName,
3055
+ getCascadeTypeName,
3056
+ getClient,
3057
+ getContext,
3058
+ getEntityClusterModeName,
3059
+ getOwnershipTypeName,
3060
+ getPrivilegeTypeName,
3061
+ getRelationshipTypeName,
3062
+ getSecurityTypesName,
3063
+ initializeLogger,
3064
+ setConfig,
3065
+ setDataOperationExecutor
3066
+ };