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