codeapp-js 0.1.1 → 0.2.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 (121) hide show
  1. package/codeApp/dist/codeapp.js +552 -78
  2. package/codeApp/dist/power-apps-data.js +2531 -2531
  3. package/dev files/outlook.js +218 -9
  4. package/examples/combined demo/dist/codeapp.js +1098 -0
  5. package/examples/combined demo/dist/index.js +69 -114
  6. package/examples/combined demo/dist/power-apps-data.js +646 -170
  7. package/examples/combined demo/power.config.json +42 -42
  8. package/examples/dataverse Demo/dist/codeapp.js +1085 -0
  9. package/examples/dataverse Demo/dist/index.html +54 -54
  10. package/examples/dataverse Demo/dist/index.js +82 -70
  11. package/examples/dataverse Demo/dist/power-apps-data.js +551 -170
  12. package/examples/dataverse Demo/power.config.json +34 -34
  13. package/examples/dataverse Demo/readme.md +79 -79
  14. package/examples/groups Demo/dist/codeapp.js +1085 -0
  15. package/examples/groups Demo/dist/index.js +27 -27
  16. package/examples/groups Demo/dist/power-apps-data.js +551 -170
  17. package/examples/kanban/dist/dataverse.js +94 -94
  18. package/examples/kanban/dist/environmentVar.js +55 -55
  19. package/examples/kanban/dist/office365groups.js +97 -97
  20. package/examples/kanban/dist/office365users.js +169 -169
  21. package/examples/kanban/dist/outlook.js +162 -162
  22. package/examples/kanban/dist/power-apps-data.js +560 -138
  23. package/examples/kanban/dist/sharepoint.js +339 -339
  24. package/examples/myProfile/dist/index.html +184 -184
  25. package/examples/myProfile/dist/index.js +141 -141
  26. package/examples/myProfile/dist/office365users.js +169 -169
  27. package/examples/myProfile/dist/power-apps-data.js +560 -138
  28. package/examples/myProfile/power.config.json +22 -22
  29. package/examples/myProfile/readme.md +79 -79
  30. package/examples/outlook Demo/dist/codeapp.js +1085 -0
  31. package/examples/outlook Demo/dist/index.html +35 -35
  32. package/examples/outlook Demo/dist/index.js +170 -166
  33. package/examples/outlook Demo/dist/outlook.js +121 -121
  34. package/examples/outlook Demo/dist/power-apps-data.js +551 -170
  35. package/examples/outlook Demo/dist/styles.css +84 -84
  36. package/examples/outlook Demo/readme.md +82 -82
  37. package/examples/outlook Demo2/OutlookDemo_1_0_0_1.zip +0 -0
  38. package/examples/outlook Demo2/agent/decision-log.md +7 -0
  39. package/examples/outlook Demo2/dist/codeapp.js +1334 -0
  40. package/examples/outlook Demo2/dist/icon-512.png +0 -0
  41. package/examples/outlook Demo2/dist/index.html +98 -0
  42. package/examples/outlook Demo2/dist/index.js +346 -0
  43. package/examples/outlook Demo2/dist/power-apps-data.js +3007 -0
  44. package/examples/outlook Demo2/dist/styles.css +639 -0
  45. package/examples/outlook Demo2/power.config.json +23 -0
  46. package/examples/outlook Demo2/src/generated/index.ts +14 -0
  47. package/examples/outlook Demo2/src/generated/models/Office365GroupsModel.ts +363 -0
  48. package/examples/outlook Demo2/src/generated/models/Office365OutlookModel.ts +2046 -0
  49. package/examples/outlook Demo2/src/generated/models/Office365UsersModel.ts +254 -0
  50. package/examples/outlook Demo2/src/generated/services/Office365GroupsService.ts +326 -0
  51. package/examples/outlook Demo2/src/generated/services/Office365OutlookService.ts +2476 -0
  52. package/examples/outlook Demo2/src/generated/services/Office365UsersService.ts +358 -0
  53. package/examples/planning Poker/.vscode/settings.json +4 -4
  54. package/examples/planning Poker/additional files/customizations (tables).xml +6428 -6428
  55. package/examples/planning Poker/additional files/dataverse-tables.json +165 -165
  56. package/examples/planning Poker/additional files/readme.md +122 -122
  57. package/examples/planning Poker/dist/dataverse.js +78 -78
  58. package/examples/planning Poker/dist/index.html +198 -198
  59. package/examples/planning Poker/dist/index.js +954 -954
  60. package/examples/planning Poker/dist/power-apps-data.js +560 -138
  61. package/examples/planning Poker/dist/styles.css +815 -815
  62. package/examples/sharePoint Demo/agent/decision-log.md +5 -5
  63. package/examples/sharePoint Demo/dist/codeapp.js +1085 -0
  64. package/examples/sharePoint Demo/dist/index.js +44 -51
  65. package/examples/sharePoint Demo/dist/power-apps-data.js +551 -170
  66. package/examples/sharePoint Demo/power.config.json +22 -22
  67. package/examples/solution explorer/agent/decision-log.md +27 -0
  68. package/examples/solution explorer/agent/mockup-01-swiss-grid.html +452 -0
  69. package/examples/solution explorer/agent/mockup-02-dark-glass.html +496 -0
  70. package/examples/solution explorer/agent/mockup-03-paper-console.html +510 -0
  71. package/examples/solution explorer/agent/mockup-04-neon-noir.html +546 -0
  72. package/examples/solution explorer/agent/mockup-05-zen-garden.html +534 -0
  73. package/examples/solution explorer/dist/codeapp.js +1098 -0
  74. package/examples/solution explorer/dist/icon-512.png +0 -0
  75. package/examples/solution explorer/dist/index.html +80 -0
  76. package/examples/solution explorer/dist/index.js +735 -0
  77. package/examples/solution explorer/dist/power-apps-data.js +3007 -0
  78. package/examples/solution explorer/dist/styles.css +571 -0
  79. package/examples/solution explorer/power.config.json +151 -0
  80. package/examples/todo/dist/dataverse.js +64 -64
  81. package/examples/todo/dist/index.html +75 -75
  82. package/examples/todo/dist/index.js +8 -8
  83. package/examples/todo/dist/power-apps-data.js +560 -138
  84. package/examples/todo/dist/renderer.js +375 -375
  85. package/examples/todo/dist/styles.css +691 -691
  86. package/examples/todo/power.config.json +34 -34
  87. package/package.json +1 -8
  88. package/docs-mockups/atelier/index.html +0 -120
  89. package/docs-mockups/atelier/script.js +0 -23
  90. package/docs-mockups/atelier/styles.css +0 -361
  91. package/docs-mockups/field-guide/index.html +0 -112
  92. package/docs-mockups/field-guide/script.js +0 -20
  93. package/docs-mockups/field-guide/styles.css +0 -272
  94. package/docs-mockups/index.html +0 -80
  95. package/docs-mockups/maker-hub/index.html +0 -178
  96. package/docs-mockups/maker-hub/script.js +0 -20
  97. package/docs-mockups/maker-hub/styles.css +0 -404
  98. package/docs-mockups/script.js +0 -26
  99. package/docs-mockups/signal/index.html +0 -146
  100. package/docs-mockups/signal/script.js +0 -20
  101. package/docs-mockups/signal/styles.css +0 -314
  102. package/docs-mockups/styles.css +0 -287
  103. package/examples/combined demo/dist/dataverse.js +0 -86
  104. package/examples/combined demo/dist/environmentVar.js +0 -55
  105. package/examples/combined demo/dist/office365groups.js +0 -97
  106. package/examples/combined demo/dist/office365users.js +0 -169
  107. package/examples/combined demo/dist/outlook.js +0 -162
  108. package/examples/combined demo/dist/sharepoint.js +0 -339
  109. package/examples/dataverse Demo/dist/dataverse.js +0 -86
  110. package/examples/groups Demo/dist/dataverse.js +0 -86
  111. package/examples/groups Demo/dist/environmentVar.js +0 -55
  112. package/examples/groups Demo/dist/office365groups.js +0 -97
  113. package/examples/groups Demo/dist/office365users.js +0 -169
  114. package/examples/groups Demo/dist/outlook.js +0 -162
  115. package/examples/groups Demo/dist/sharepoint.js +0 -339
  116. package/examples/sharePoint Demo/dist/dataverse.js +0 -94
  117. package/examples/sharePoint Demo/dist/environmentVar.js +0 -55
  118. package/examples/sharePoint Demo/dist/office365groups.js +0 -97
  119. package/examples/sharePoint Demo/dist/office365users.js +0 -169
  120. package/examples/sharePoint Demo/dist/outlook.js +0 -162
  121. package/examples/sharePoint Demo/dist/sharepoint.js +0 -339
@@ -2,6 +2,325 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
 
5
+ // node_modules/@microsoft/power-apps/lib/internal/plugins/DefaultPowerAppsBridge.js
6
+ var DefaultPowerAppsBridge = class {
7
+ constructor() {
8
+ __publicField(this, "_antiCSRFToken");
9
+ __publicField(this, "_callbacks", {});
10
+ __publicField(this, "_currentCallbackId", 0);
11
+ __publicField(this, "_instanceId", Date.now().toString());
12
+ __publicField(this, "_messageChannel", new window.MessageChannel());
13
+ __publicField(this, "_postMessageQueue", []);
14
+ __publicField(this, "_postMessageSource");
15
+ __publicField(this, "_handleMessageEvent", (messageEvent) => {
16
+ const message = messageEvent.data;
17
+ if (message && typeof message.isPluginCall === "boolean") {
18
+ if (message.isPluginCall) {
19
+ const callbackId = message.callbackId;
20
+ const status = message.status;
21
+ const args = message.args;
22
+ const keepCallback = message.keepCallback;
23
+ try {
24
+ const callback = this._callbacks[callbackId];
25
+ if (keepCallback) {
26
+ if (callback && callback.onUpdate) {
27
+ callback.onUpdate(message.args?.[0]);
28
+ }
29
+ } else {
30
+ if (callback) {
31
+ if (status === 1) {
32
+ callback.resolve(args[0]);
33
+ } else if (status !== 0) {
34
+ callback.reject(args);
35
+ }
36
+ }
37
+ if (!keepCallback) {
38
+ delete this._callbacks[callbackId];
39
+ }
40
+ }
41
+ } catch (error) {
42
+ console.error(error);
43
+ }
44
+ }
45
+ } else if (message && message.messageType === "initCommunication") {
46
+ this._antiCSRFToken = message.antiCSRFToken;
47
+ this._postMessageSource = this._messageChannel.port1;
48
+ if (this._postMessageSource) {
49
+ for (let i = 0; i < this._postMessageQueue.length; i++) {
50
+ this._postMessageQueue[i].antiCSRFToken = this._antiCSRFToken;
51
+ this._postMessageSource.postMessage(this._postMessageQueue[i]);
52
+ }
53
+ }
54
+ }
55
+ });
56
+ }
57
+ async initialize() {
58
+ this._messageChannel.port1.onmessage = this._handleMessageEvent;
59
+ window.parent.postMessage({
60
+ messageType: "initCommunicationWithPort",
61
+ instanceId: this._instanceId
62
+ }, "*", [this._messageChannel.port2]);
63
+ }
64
+ async executePluginAsync(pluginName, pluginAction, params = [], onUpdate) {
65
+ return new Promise((resolve, reject) => {
66
+ const callbackId = this._getCallbackId(pluginName);
67
+ this._callbacks[callbackId] = { resolve, reject, onUpdate };
68
+ this._sendMessage({
69
+ isPluginCall: true,
70
+ callbackId,
71
+ service: pluginName,
72
+ action: pluginAction,
73
+ actionArgs: params,
74
+ antiCSRFToken: this._antiCSRFToken
75
+ });
76
+ });
77
+ }
78
+ _sendMessage(message) {
79
+ if (!this._postMessageSource) {
80
+ this._postMessageQueue.push(message);
81
+ } else {
82
+ this._postMessageSource.postMessage(message);
83
+ }
84
+ }
85
+ _getCallbackId(pluginName) {
86
+ return "instanceId=" + this._instanceId + "_" + pluginName + this._currentCallbackId++;
87
+ }
88
+ };
89
+
90
+ // node_modules/@microsoft/power-apps/lib/internal/plugins/PluginBridge.js
91
+ var bridgePromise;
92
+ async function executePluginAsync(pluginName, pluginAction, params = [], update) {
93
+ const powerAppsBridge = await getBridge();
94
+ return powerAppsBridge.executePluginAsync(pluginName, pluginAction, params, update);
95
+ }
96
+ async function getBridge() {
97
+ if (!bridgePromise) {
98
+ bridgePromise = new Promise(async (resolve, reject) => {
99
+ try {
100
+ const bridge = window && window.powerAppsBridge ? window.powerAppsBridge : new DefaultPowerAppsBridge();
101
+ await bridge.initialize();
102
+ resolve(bridge);
103
+ } catch (error) {
104
+ reject(error);
105
+ }
106
+ });
107
+ }
108
+ return bridgePromise;
109
+ }
110
+
111
+ // node_modules/@microsoft/power-apps/lib/app/ContextProvider.js
112
+ var context;
113
+ async function getContext() {
114
+ if (context) {
115
+ return context;
116
+ }
117
+ context = await executePluginAsync("AppLifecycle", "getContext");
118
+ return context;
119
+ }
120
+
121
+ // node_modules/@microsoft/power-apps/lib/internal/plugins/SendMessage/IncompatibleMessageReceiver.js
122
+ var IncompatibleMessageReceiver = class {
123
+ constructor(versionInfo, incompatibilityDescription) {
124
+ __publicField(this, "versionInfo");
125
+ __publicField(this, "incompatibilityDescription");
126
+ __publicField(this, "isCompatible", false);
127
+ this.versionInfo = versionInfo;
128
+ this.incompatibilityDescription = incompatibilityDescription;
129
+ }
130
+ };
131
+
132
+ // node_modules/@microsoft/power-apps/lib/internal/plugins/SendMessage/SendMessageOperation.js
133
+ var SendMessageOperation = class {
134
+ constructor(resultPromise, sendUpdate) {
135
+ __publicField(this, "resultPromise");
136
+ __publicField(this, "sendUpdate");
137
+ /**
138
+ * When completed is false onMessageReceived and sendUpdate will be visible.
139
+ * When completed is true then these are hidden.
140
+ */
141
+ __publicField(this, "completed", false);
142
+ __publicField(this, "onMessageReceived");
143
+ this.resultPromise = resultPromise;
144
+ this.sendUpdate = sendUpdate;
145
+ }
146
+ };
147
+
148
+ // node_modules/@microsoft/power-apps/lib/internal/plugins/SendMessage/CompatibleMessageReceiver.js
149
+ var CompatibleMessageReceiver = class {
150
+ constructor(_receiverName, versionInfo) {
151
+ __publicField(this, "_receiverName");
152
+ __publicField(this, "versionInfo");
153
+ __publicField(this, "isCompatible", true);
154
+ this._receiverName = _receiverName;
155
+ this.versionInfo = versionInfo;
156
+ }
157
+ async sendMessage(message, onMessageReceived) {
158
+ let resolveOperationPromise;
159
+ let rejectOperationPromise;
160
+ const operationPromise = new Promise((resolve, reject) => {
161
+ resolveOperationPromise = resolve;
162
+ rejectOperationPromise = reject;
163
+ });
164
+ const correlationId = crypto.randomUUID();
165
+ const handleMessage = (compatibleReceiverMessage) => {
166
+ try {
167
+ if (sendMessageOperation.completed) {
168
+ return;
169
+ }
170
+ if (compatibleReceiverMessage) {
171
+ if (compatibleReceiverMessage.isUpdate) {
172
+ if (sendMessageOperation.onMessageReceived) {
173
+ try {
174
+ sendMessageOperation.onMessageReceived(compatibleReceiverMessage.message);
175
+ } catch (error) {
176
+ sendMessageOperation.completed = true;
177
+ rejectOperationPromise(error);
178
+ }
179
+ } else {
180
+ sendMessageOperation.completed = true;
181
+ rejectOperationPromise(new Error(`Native receiver expected a message handler, but no handler was supplied. Message: ${compatibleReceiverMessage.message}`));
182
+ }
183
+ } else {
184
+ sendMessageOperation.completed = true;
185
+ resolveOperationPromise(compatibleReceiverMessage.message);
186
+ }
187
+ return;
188
+ }
189
+ } catch {
190
+ }
191
+ sendMessageOperation.completed = true;
192
+ resolveOperationPromise(compatibleReceiverMessage.message);
193
+ };
194
+ const handleError = (error) => {
195
+ sendMessageOperation.completed = true;
196
+ rejectOperationPromise(error);
197
+ };
198
+ const sendUpdate = (updateMessage) => {
199
+ if (sendMessageOperation.completed) {
200
+ throw new Error("Tried to send update for completed operation.");
201
+ }
202
+ executePluginAsync("SendMessagePlugin", "sendMessage", [
203
+ this._receiverName,
204
+ updateMessage,
205
+ correlationId
206
+ ]);
207
+ };
208
+ const sendMessageOperation = new SendMessageOperation(operationPromise, sendUpdate);
209
+ sendMessageOperation.onMessageReceived = onMessageReceived;
210
+ try {
211
+ await executePluginAsync("SendMessagePlugin", "sendMessage", [this._receiverName, message, correlationId], (response) => {
212
+ handleMessage(response);
213
+ });
214
+ } catch (error) {
215
+ handleError(error);
216
+ }
217
+ return sendMessageOperation;
218
+ }
219
+ };
220
+
221
+ // node_modules/@microsoft/power-apps/lib/internal/plugins/SendMessage/SendMessage.js
222
+ var SendMessage = class _SendMessage {
223
+ static createInstanceAsync() {
224
+ return Promise.resolve(new _SendMessage());
225
+ }
226
+ async getMessageReceiverAsync(receiverName, isCompatibleChecker) {
227
+ const versionInfo = await this._getVersionInfo(receiverName);
228
+ if (versionInfo) {
229
+ const compatibilityCheckerResult = isCompatibleChecker(versionInfo);
230
+ if (compatibilityCheckerResult.isCompatible === false) {
231
+ return new IncompatibleMessageReceiver(versionInfo, compatibilityCheckerResult.incompatibilityDescription || "");
232
+ } else {
233
+ return new CompatibleMessageReceiver(receiverName, versionInfo);
234
+ }
235
+ } else {
236
+ return new IncompatibleMessageReceiver(void 0, `No receiver ${receiverName} registered.`);
237
+ }
238
+ }
239
+ async _getVersionInfo(receiverName) {
240
+ const result = await executePluginAsync("SendMessagePlugin", "getVersionInfo", [receiverName]);
241
+ return result;
242
+ }
243
+ };
244
+
245
+ // node_modules/@microsoft/power-apps/lib/telemetry/LoggerManager.js
246
+ var loggerInstance;
247
+ async function initializeLogger(logger) {
248
+ loggerInstance = logger;
249
+ const sendMessagePlugin = await SendMessage.createInstanceAsync();
250
+ const receiver = await sendMessagePlugin.getMessageReceiverAsync("PowerApps.AppMonitorReceiver", (versionInfo) => {
251
+ let isCompatible = false;
252
+ if (versionInfo === "1.0.0") {
253
+ isCompatible = true;
254
+ }
255
+ return { isCompatible };
256
+ });
257
+ if (receiver.isCompatible) {
258
+ await receiver.sendMessage("initialize", (message) => {
259
+ const parsedMessage = JSON.parse(message);
260
+ if (parsedMessage.metrics) {
261
+ for (const metric of parsedMessage.metrics) {
262
+ loggerInstance.logMetric?.(metric);
263
+ }
264
+ }
265
+ });
266
+ }
267
+ }
268
+
269
+ // node_modules/@microsoft/power-apps/lib/telemetry/Performance.js
270
+ function getAppLoadedPerformanceData() {
271
+ const performanceApi = new PerformanceApi();
272
+ const perfData = {
273
+ appTimeOrigin: performanceApi.timeOrigin
274
+ };
275
+ const navigationTimingEntries = performanceApi.getEntriesByType("navigation");
276
+ const navigationTiming = navigationTimingEntries[0];
277
+ if (navigationTiming) {
278
+ perfData.appNavigateType = navigationTiming.type;
279
+ perfData.appNavigationStart = navigationTiming.startTime;
280
+ perfData.appNavigationDuration = navigationTiming.duration;
281
+ perfData.appEncodedBodySize = navigationTiming.encodedBodySize;
282
+ perfData.appNextHopProtocol = navigationTiming.nextHopProtocol;
283
+ perfData.appDomainLookupStart = navigationTiming.domainLookupStart;
284
+ perfData.appDomainLookupEnd = navigationTiming.domainLookupEnd;
285
+ perfData.appConnectStart = navigationTiming.connectStart;
286
+ perfData.appConnectEnd = navigationTiming.connectEnd;
287
+ perfData.appSecureConnectionStart = navigationTiming.secureConnectionStart;
288
+ perfData.appFetchStart = navigationTiming.fetchStart;
289
+ perfData.appRequestStart = navigationTiming.requestStart;
290
+ perfData.appResponseStart = navigationTiming.responseStart;
291
+ perfData.appResponseEnd = navigationTiming.responseEnd;
292
+ perfData.appLoadEventEnd = navigationTiming.loadEventEnd;
293
+ perfData.appDomInteractive = navigationTiming.domInteractive;
294
+ perfData.appDomContentLoadedEventStart = navigationTiming.domContentLoadedEventStart;
295
+ }
296
+ return perfData;
297
+ }
298
+ var PerformanceApi = class {
299
+ constructor(targetWindow = window) {
300
+ __publicField(this, "_performance");
301
+ this._performance = targetWindow.performance;
302
+ }
303
+ get timeOrigin() {
304
+ return this._performance?.timeOrigin;
305
+ }
306
+ getEntriesByType(type) {
307
+ if (!this._performance?.getEntriesByType) {
308
+ return [];
309
+ }
310
+ return this._performance.getEntriesByType(type);
311
+ }
312
+ };
313
+
314
+ // node_modules/@microsoft/power-apps/lib/telemetry/index.js
315
+ executePluginAsync("AppLifecycle", "notifyAppSdkLoaded", [getAppLoadedPerformanceData()]);
316
+
317
+ // node_modules/@microsoft/power-apps/lib/app/Config.js
318
+ function setConfig(config) {
319
+ if (config.logger) {
320
+ initializeLogger(config.logger);
321
+ }
322
+ }
323
+
5
324
  // node_modules/@microsoft/power-apps/lib/internal/data/core/common/types.js
6
325
  var HttpMethod;
7
326
  (function(HttpMethod2) {
@@ -496,18 +815,18 @@ var RuntimeMetadataOperations = class {
496
815
  __publicField(this, "_clientProvider");
497
816
  this._clientProvider = _clientProvider;
498
817
  }
499
- async getConnections(context) {
818
+ async getConnections(context2) {
500
819
  const client = await this._clientProvider.getMetadataClientAsync();
501
- const response = await client.getAppConnectionConfigsAsync(context);
820
+ const response = await client.getAppConnectionConfigsAsync(context2);
502
821
  return {
503
822
  success: response.success,
504
823
  data: response.data ? [response.data] : [],
505
824
  error: response.error
506
825
  };
507
826
  }
508
- async getConnectionApis(_connectionId, context) {
827
+ async getConnectionApis(_connectionId, context2) {
509
828
  const client = await this._clientProvider.getMetadataClientAsync();
510
- const response = await client.getAppDataSourceConfigsAsync(context);
829
+ const response = await client.getAppDataSourceConfigsAsync(context2);
511
830
  return {
512
831
  success: response.success,
513
832
  data: response.data ? [response.data] : [],
@@ -566,7 +885,7 @@ var _RuntimeDataClient = class _RuntimeDataClient {
566
885
  * @throws Error if the request fails or the response is invalid
567
886
  * @throws Error if the request body is invalid
568
887
  */
569
- async createDataAsync(url, apiId, tableName, body, context) {
888
+ async createDataAsync(url, apiId, tableName, body, context2) {
570
889
  try {
571
890
  if (!body) {
572
891
  throw new Error(`${DataOperationErrorMessages.InvalidRequest}: ${DataOperationErrorMessages.MissingRequestBody}`);
@@ -578,8 +897,8 @@ var _RuntimeDataClient = class _RuntimeDataClient {
578
897
  tableName,
579
898
  body: JSON.stringify(body)
580
899
  };
581
- context = this._ensureContext(context, "runtimeDataClient.createDataAsync");
582
- return await this._executeRequest(config, context);
900
+ context2 = this._ensureContext(context2, "runtimeDataClient.createDataAsync");
901
+ return await this._executeRequest(config, context2);
583
902
  } catch (error) {
584
903
  if (isOperationResult(error)) {
585
904
  return error;
@@ -599,7 +918,7 @@ var _RuntimeDataClient = class _RuntimeDataClient {
599
918
  * @throws Error if the request fails or the response is invalid
600
919
  * @throws Error if the request body is invalid
601
920
  */
602
- async updateDataAsync(url, apiId, tableName, body, context) {
921
+ async updateDataAsync(url, apiId, tableName, body, context2) {
603
922
  try {
604
923
  if (!body) {
605
924
  throw new Error(`${DataOperationErrorMessages.InvalidRequest}: ${DataOperationErrorMessages.MissingRequestBody}`);
@@ -611,8 +930,8 @@ var _RuntimeDataClient = class _RuntimeDataClient {
611
930
  tableName,
612
931
  body: JSON.stringify(body)
613
932
  };
614
- context = this._ensureContext(context, "runtimeDataClient.updateDataAsync");
615
- return await this._executeRequest(config, context);
933
+ context2 = this._ensureContext(context2, "runtimeDataClient.updateDataAsync");
934
+ return await this._executeRequest(config, context2);
616
935
  } catch (error) {
617
936
  if (isOperationResult(error)) {
618
937
  return error;
@@ -630,7 +949,7 @@ var _RuntimeDataClient = class _RuntimeDataClient {
630
949
  * @return Promise resolving to the response data
631
950
  * @throws Error if the request fails or the response is invalid
632
951
  */
633
- async deleteDataAsync(url, connectionApi, serviceNamespace, context) {
952
+ async deleteDataAsync(url, connectionApi, serviceNamespace, context2) {
634
953
  try {
635
954
  const config = {
636
955
  url,
@@ -638,8 +957,8 @@ var _RuntimeDataClient = class _RuntimeDataClient {
638
957
  apiId: connectionApi,
639
958
  tableName: serviceNamespace
640
959
  };
641
- context = this._ensureContext(context, "runtimeDataClient.deleteDataAsync");
642
- return await this._executeRequest(config, context);
960
+ context2 = this._ensureContext(context2, "runtimeDataClient.deleteDataAsync");
961
+ return await this._executeRequest(config, context2);
643
962
  } catch (error) {
644
963
  if (isOperationResult(error)) {
645
964
  return error;
@@ -660,7 +979,7 @@ var _RuntimeDataClient = class _RuntimeDataClient {
660
979
  * @return Promise resolving to the response data
661
980
  * @throws Error if the request fails or the response is invalid
662
981
  */
663
- async retrieveDataAsync(url, apiId, tableName, method, headers, body, context) {
982
+ async retrieveDataAsync(url, apiId, tableName, method, headers, body, context2) {
664
983
  try {
665
984
  const config = {
666
985
  url,
@@ -670,8 +989,8 @@ var _RuntimeDataClient = class _RuntimeDataClient {
670
989
  headers,
671
990
  body: body ? typeof body === "string" ? body : JSON.stringify(body) : void 0
672
991
  };
673
- context = this._ensureContext(context, "runtimeDataClient.retrieveDataAsync");
674
- return await this._executeRequest(config, context);
992
+ context2 = this._ensureContext(context2, "runtimeDataClient.retrieveDataAsync");
993
+ return await this._executeRequest(config, context2);
675
994
  } catch (error) {
676
995
  if (isOperationResult(error)) {
677
996
  return error;
@@ -728,7 +1047,7 @@ var _RuntimeDataClient = class _RuntimeDataClient {
728
1047
  * @return The headers for the request
729
1048
  * @throws Error if header creation fails
730
1049
  */
731
- _createHeaders(token, config, context) {
1050
+ _createHeaders(token, config, context2) {
732
1051
  const baseHeaders = {
733
1052
  Accept: "application/json",
734
1053
  "x-ms-protocol-semantics": "cdp",
@@ -736,14 +1055,14 @@ var _RuntimeDataClient = class _RuntimeDataClient {
736
1055
  Authorization: `paauth ${token}`,
737
1056
  "x-ms-pa-client-custom-headers-options": '{"addCustomHeaders":true}',
738
1057
  "x-ms-enable-selects": "true",
739
- "x-ms-pa-client-telemetry-options": `paclient-telemetry {"operationName":"${context?.operationName ?? "runtimeDataClient.executeRequest"}"}`,
1058
+ "x-ms-pa-client-telemetry-options": `paclient-telemetry {"operationName":"${context2?.operationName ?? "runtimeDataClient.executeRequest"}"}`,
740
1059
  "x-ms-pa-client-telemetry-additional-data": `{"apiId":"${config.apiId}"}`
741
1060
  };
742
1061
  if (config.apiId === DataSources.Dataverse) {
743
1062
  baseHeaders["x-ms-protocol-semantics"] = DataSources.Dataverse;
744
1063
  baseHeaders.Authorization = `dynamicauth ${token}`;
745
1064
  const { baseUrl, encodedPath } = extractDataverseUrlParts(config.url);
746
- const batchId = context?.batchId || "";
1065
+ const batchId = context2?.batchId || "";
747
1066
  const preferHeader = this._mergePreferHeaders(config.headers, config.method);
748
1067
  baseHeaders.BatchInfo = JSON.stringify({
749
1068
  baseUrl,
@@ -769,9 +1088,9 @@ var _RuntimeDataClient = class _RuntimeDataClient {
769
1088
  * @throws Error if the request fails or the response is invalid
770
1089
  * @throws Error if the response content type is invalid
771
1090
  */
772
- async _executeRequest(config, context) {
773
- const token = await this._getAccessToken(config.apiId, context?.datasetName);
774
- const headers = this._createHeaders(token, config, context);
1091
+ async _executeRequest(config, context2) {
1092
+ const token = await this._getAccessToken(config.apiId, context2?.datasetName);
1093
+ const headers = this._createHeaders(token, config, context2);
775
1094
  const requestBody = config.body ? new Blob([config.body], { type: "application/json" }) : "";
776
1095
  let result;
777
1096
  try {
@@ -809,12 +1128,12 @@ var _RuntimeDataClient = class _RuntimeDataClient {
809
1128
  text = "{}";
810
1129
  }
811
1130
  const parsedResult = JSON.parse(text);
812
- if (context?.isDataVerseOperation || this._isDataverseCall(config.url)) {
1131
+ if (context2?.isDataVerseOperation || this._isDataverseCall(config.url)) {
813
1132
  return {
814
1133
  success: true,
815
1134
  data: parsedResult
816
1135
  };
817
- } else if (!context?.isExecuteAsync && "value" in parsedResult && Array.isArray(parsedResult.value)) {
1136
+ } else if (!context2?.isExecuteAsync && "value" in parsedResult && Array.isArray(parsedResult.value)) {
818
1137
  return {
819
1138
  success: true,
820
1139
  data: parsedResult.value,
@@ -844,7 +1163,7 @@ var _RuntimeDataClient = class _RuntimeDataClient {
844
1163
  if (buffer instanceof ArrayBuffer) {
845
1164
  const value = convertArrayBufferToString(buffer);
846
1165
  const status = responseData[0].status;
847
- const responseType = context?.responseInfo?.[status];
1166
+ const responseType = context2?.responseInfo?.[status];
848
1167
  if (responseType) {
849
1168
  let parsedValue;
850
1169
  try {
@@ -888,14 +1207,14 @@ var _RuntimeDataClient = class _RuntimeDataClient {
888
1207
  };
889
1208
  }
890
1209
  }
891
- _ensureContext(context, defaultOperationName) {
892
- if (!context) {
893
- context = {};
1210
+ _ensureContext(context2, defaultOperationName) {
1211
+ if (!context2) {
1212
+ context2 = {};
894
1213
  }
895
- if (!context.operationName) {
896
- context.operationName = defaultOperationName;
1214
+ if (!context2.operationName) {
1215
+ context2.operationName = defaultOperationName;
897
1216
  }
898
- return context;
1217
+ return context2;
899
1218
  }
900
1219
  /**
901
1220
  * Checks if the given URL is a Dataverse API call
@@ -2305,112 +2624,6 @@ __publicField(_PowerDataSourcesInfoProvider, "instance", null);
2305
2624
  var PowerDataSourcesInfoProvider = _PowerDataSourcesInfoProvider;
2306
2625
  var powerDataSourcesInfoProvider_default = PowerDataSourcesInfoProvider;
2307
2626
 
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
2627
  // node_modules/@microsoft/power-apps/lib/internal/data/ConnectionUtils.js
2415
2628
  var connectionsLoaded = false;
2416
2629
  async function loadConnections() {
@@ -2504,6 +2717,9 @@ var _dataOperationExecutor;
2504
2717
  function getDataOperationExecutor() {
2505
2718
  return _dataOperationExecutor;
2506
2719
  }
2720
+ function setDataOperationExecutor(dataOperationExecutorOverride) {
2721
+ _dataOperationExecutor = dataOperationExecutorOverride;
2722
+ }
2507
2723
  function getClient(dataSourcesInfo) {
2508
2724
  return {
2509
2725
  createRecordAsync: (tableName, record) => {
@@ -2526,6 +2742,212 @@ function getClient(dataSourcesInfo) {
2526
2742
  }
2527
2743
  };
2528
2744
  }
2745
+
2746
+ // node_modules/@microsoft/power-apps/lib/internal/data/core/data/executors/mockDataOperationExecutor.js
2747
+ var MockDataOperationExecutor = class {
2748
+ constructor(data) {
2749
+ __publicField(this, "_dataStore");
2750
+ this._dataStore = data;
2751
+ }
2752
+ async createRecordAsync(tableName, data) {
2753
+ return {
2754
+ success: false,
2755
+ error: { message: "createRecordAsync is not supported by MockDataOperationExecutor" },
2756
+ data: null
2757
+ };
2758
+ }
2759
+ async updateRecordAsync(tableName, id, data) {
2760
+ return {
2761
+ success: false,
2762
+ error: { message: "updateRecordAsync is not supported by MockDataOperationExecutor" },
2763
+ data: null
2764
+ };
2765
+ }
2766
+ async deleteRecordAsync(tableName, id) {
2767
+ return {
2768
+ success: false,
2769
+ error: { message: "deleteRecordAsync is not supported by MockDataOperationExecutor" },
2770
+ data: void 0
2771
+ };
2772
+ }
2773
+ async retrieveRecordAsync(tableName, id, options) {
2774
+ if (!this._dataStore[tableName]) {
2775
+ return {
2776
+ success: false,
2777
+ error: { message: `table <${tableName}> not found` },
2778
+ data: null
2779
+ };
2780
+ }
2781
+ const record = this._dataStore[tableName][id];
2782
+ if (!record) {
2783
+ return {
2784
+ success: false,
2785
+ error: { message: `record with id "${id}" not found in table <${tableName}>` },
2786
+ data: null
2787
+ };
2788
+ }
2789
+ return {
2790
+ success: true,
2791
+ data: record
2792
+ };
2793
+ }
2794
+ async retrieveMultipleRecordsAsync(tableName, options) {
2795
+ if (!this._dataStore[tableName]) {
2796
+ return {
2797
+ success: false,
2798
+ error: { message: `table <${tableName}> not found` },
2799
+ data: []
2800
+ };
2801
+ }
2802
+ return {
2803
+ success: true,
2804
+ data: Object.values(this._dataStore[tableName])
2805
+ };
2806
+ }
2807
+ async executeAsync(operation) {
2808
+ return {
2809
+ success: false,
2810
+ error: { message: "executeAsync is not supported by MockDataOperationExecutor" },
2811
+ data: null
2812
+ };
2813
+ }
2814
+ };
2815
+ function createMockDataExecutor(data) {
2816
+ return new MockDataOperationExecutor(data);
2817
+ }
2818
+
2819
+ // node_modules/@microsoft/power-apps/lib/internal/data/core/types/dataverseMetadata.js
2820
+ var entityClusterModeEnum = {
2821
+ 0: "Partitioned",
2822
+ 1: "Replicated",
2823
+ 2: "Local"
2824
+ };
2825
+ function getEntityClusterModeName(value) {
2826
+ return entityClusterModeEnum[value];
2827
+ }
2828
+ var ownershipTypeEnum = {
2829
+ 0: "None",
2830
+ 1: "UserOwned",
2831
+ 2: "TeamOwned",
2832
+ 4: "BusinessOwned",
2833
+ 8: "OrganizationOwned",
2834
+ 16: "BusinessParented",
2835
+ 32: "Filtered"
2836
+ };
2837
+ function getOwnershipTypeName(value) {
2838
+ return ownershipTypeEnum[value];
2839
+ }
2840
+ var privilegeTypeEnum = {
2841
+ 0: "None",
2842
+ 1: "Create",
2843
+ 2: "Read",
2844
+ 3: "Write",
2845
+ 4: "Delete",
2846
+ 5: "Assign",
2847
+ 6: "Share",
2848
+ 7: "Append",
2849
+ 8: "AppendTo"
2850
+ };
2851
+ function getPrivilegeTypeName(value) {
2852
+ return privilegeTypeEnum[value];
2853
+ }
2854
+ var attributeTypeCodeEnum = {
2855
+ 0: "Boolean",
2856
+ 1: "Customer",
2857
+ 2: "DateTime",
2858
+ 3: "Decimal",
2859
+ 4: "Double",
2860
+ 5: "Integer",
2861
+ 6: "Lookup",
2862
+ 7: "Memo",
2863
+ 8: "Money",
2864
+ 9: "Owner",
2865
+ 10: "PartyList",
2866
+ 11: "Picklist",
2867
+ 12: "State",
2868
+ 13: "Status",
2869
+ 14: "String",
2870
+ 15: "Uniqueidentifier",
2871
+ 16: "CalendarRules",
2872
+ 17: "Virtual",
2873
+ 18: "BigInt",
2874
+ 19: "ManagedProperty",
2875
+ 20: "EntityName"
2876
+ };
2877
+ function getAttributeTypeCodeName(value) {
2878
+ return attributeTypeCodeEnum[value];
2879
+ }
2880
+ var attributeRequiredLevelEnum = {
2881
+ 0: "None",
2882
+ 1: "SystemRequired",
2883
+ 2: "ApplicationRequired",
2884
+ 3: "Recommended"
2885
+ };
2886
+ function getAttributeRequiredLevelName(value) {
2887
+ return attributeRequiredLevelEnum[value];
2888
+ }
2889
+ var relationshipTypeEnum = {
2890
+ 0: "OneToManyRelationship",
2891
+ 1: "ManyToManyRelationship"
2892
+ };
2893
+ function getRelationshipTypeName(value) {
2894
+ return relationshipTypeEnum[value];
2895
+ }
2896
+ var securityTypesEnum = {
2897
+ 0: "None",
2898
+ 1: "Append",
2899
+ 2: "ParentChild",
2900
+ 8: "Pointer",
2901
+ 16: "Inheritance"
2902
+ // The referencing entity record inherits security from the referenced security record.
2903
+ };
2904
+ function getSecurityTypesName(value) {
2905
+ return securityTypesEnum[value];
2906
+ }
2907
+ var associatedMenuBehaviorEnum = {
2908
+ 0: "UseCollectionName",
2909
+ 1: "UseLabel",
2910
+ 2: "DoNotDisplay"
2911
+ };
2912
+ function getAssociatedMenuBehaviorName(value) {
2913
+ return associatedMenuBehaviorEnum[value];
2914
+ }
2915
+ var associatedMenuGroupEnum = {
2916
+ 0: "Details",
2917
+ 1: "Sales",
2918
+ 2: "Service",
2919
+ 3: "Marketing"
2920
+ };
2921
+ function getAssociatedMenuGroupName(value) {
2922
+ return associatedMenuGroupEnum[value];
2923
+ }
2924
+ var cascadeTypeEnum = {
2925
+ 0: "NoCascade",
2926
+ 1: "Cascade",
2927
+ 2: "Active",
2928
+ 3: "UserOwned",
2929
+ 4: "RemoveLink",
2930
+ 5: "Restrict"
2931
+ // Prevent the Referenced entity record from being deleted when referencing entities exist.
2932
+ };
2933
+ function getCascadeTypeName(value) {
2934
+ return cascadeTypeEnum[value];
2935
+ }
2529
2936
  export {
2530
- getClient
2937
+ createMockDataExecutor,
2938
+ getAssociatedMenuBehaviorName,
2939
+ getAssociatedMenuGroupName,
2940
+ getAttributeRequiredLevelName,
2941
+ getAttributeTypeCodeName,
2942
+ getCascadeTypeName,
2943
+ getClient,
2944
+ getContext,
2945
+ getEntityClusterModeName,
2946
+ getOwnershipTypeName,
2947
+ getPrivilegeTypeName,
2948
+ getRelationshipTypeName,
2949
+ getSecurityTypesName,
2950
+ initializeLogger,
2951
+ setConfig,
2952
+ setDataOperationExecutor
2531
2953
  };