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.
- package/codeApp/dist/codeapp.js +552 -78
- package/codeApp/dist/power-apps-data.js +2531 -2531
- package/dev files/outlook.js +218 -9
- package/examples/combined demo/dist/codeapp.js +1098 -0
- package/examples/combined demo/dist/index.js +69 -114
- package/examples/combined demo/dist/power-apps-data.js +646 -170
- package/examples/combined demo/power.config.json +42 -42
- package/examples/dataverse Demo/dist/codeapp.js +1085 -0
- package/examples/dataverse Demo/dist/index.html +54 -54
- package/examples/dataverse Demo/dist/index.js +82 -70
- package/examples/dataverse Demo/dist/power-apps-data.js +551 -170
- package/examples/dataverse Demo/power.config.json +34 -34
- package/examples/dataverse Demo/readme.md +79 -79
- package/examples/groups Demo/dist/codeapp.js +1085 -0
- package/examples/groups Demo/dist/index.js +27 -27
- package/examples/groups Demo/dist/power-apps-data.js +551 -170
- package/examples/kanban/dist/dataverse.js +94 -94
- package/examples/kanban/dist/environmentVar.js +55 -55
- package/examples/kanban/dist/office365groups.js +97 -97
- package/examples/kanban/dist/office365users.js +169 -169
- package/examples/kanban/dist/outlook.js +162 -162
- package/examples/kanban/dist/power-apps-data.js +560 -138
- package/examples/kanban/dist/sharepoint.js +339 -339
- package/examples/myProfile/dist/index.html +184 -184
- package/examples/myProfile/dist/index.js +141 -141
- package/examples/myProfile/dist/office365users.js +169 -169
- package/examples/myProfile/dist/power-apps-data.js +560 -138
- package/examples/myProfile/power.config.json +22 -22
- package/examples/myProfile/readme.md +79 -79
- package/examples/outlook Demo/dist/codeapp.js +1085 -0
- package/examples/outlook Demo/dist/index.html +35 -35
- package/examples/outlook Demo/dist/index.js +170 -166
- package/examples/outlook Demo/dist/outlook.js +121 -121
- package/examples/outlook Demo/dist/power-apps-data.js +551 -170
- package/examples/outlook Demo/dist/styles.css +84 -84
- package/examples/outlook Demo/readme.md +82 -82
- package/examples/outlook Demo2/OutlookDemo_1_0_0_1.zip +0 -0
- package/examples/outlook Demo2/agent/decision-log.md +7 -0
- package/examples/outlook Demo2/dist/codeapp.js +1334 -0
- package/examples/outlook Demo2/dist/icon-512.png +0 -0
- package/examples/outlook Demo2/dist/index.html +98 -0
- package/examples/outlook Demo2/dist/index.js +346 -0
- package/examples/outlook Demo2/dist/power-apps-data.js +3007 -0
- package/examples/outlook Demo2/dist/styles.css +639 -0
- package/examples/outlook Demo2/power.config.json +23 -0
- package/examples/outlook Demo2/src/generated/index.ts +14 -0
- package/examples/outlook Demo2/src/generated/models/Office365GroupsModel.ts +363 -0
- package/examples/outlook Demo2/src/generated/models/Office365OutlookModel.ts +2046 -0
- package/examples/outlook Demo2/src/generated/models/Office365UsersModel.ts +254 -0
- package/examples/outlook Demo2/src/generated/services/Office365GroupsService.ts +326 -0
- package/examples/outlook Demo2/src/generated/services/Office365OutlookService.ts +2476 -0
- package/examples/outlook Demo2/src/generated/services/Office365UsersService.ts +358 -0
- package/examples/planning Poker/.vscode/settings.json +4 -4
- package/examples/planning Poker/additional files/customizations (tables).xml +6428 -6428
- package/examples/planning Poker/additional files/dataverse-tables.json +165 -165
- package/examples/planning Poker/additional files/readme.md +122 -122
- package/examples/planning Poker/dist/dataverse.js +78 -78
- package/examples/planning Poker/dist/index.html +198 -198
- package/examples/planning Poker/dist/index.js +954 -954
- package/examples/planning Poker/dist/power-apps-data.js +560 -138
- package/examples/planning Poker/dist/styles.css +815 -815
- package/examples/sharePoint Demo/agent/decision-log.md +5 -5
- package/examples/sharePoint Demo/dist/codeapp.js +1085 -0
- package/examples/sharePoint Demo/dist/index.js +44 -51
- package/examples/sharePoint Demo/dist/power-apps-data.js +551 -170
- package/examples/sharePoint Demo/power.config.json +22 -22
- package/examples/solution explorer/agent/decision-log.md +27 -0
- package/examples/solution explorer/agent/mockup-01-swiss-grid.html +452 -0
- package/examples/solution explorer/agent/mockup-02-dark-glass.html +496 -0
- package/examples/solution explorer/agent/mockup-03-paper-console.html +510 -0
- package/examples/solution explorer/agent/mockup-04-neon-noir.html +546 -0
- package/examples/solution explorer/agent/mockup-05-zen-garden.html +534 -0
- package/examples/solution explorer/dist/codeapp.js +1098 -0
- package/examples/solution explorer/dist/icon-512.png +0 -0
- package/examples/solution explorer/dist/index.html +80 -0
- package/examples/solution explorer/dist/index.js +735 -0
- package/examples/solution explorer/dist/power-apps-data.js +3007 -0
- package/examples/solution explorer/dist/styles.css +571 -0
- package/examples/solution explorer/power.config.json +151 -0
- package/examples/todo/dist/dataverse.js +64 -64
- package/examples/todo/dist/index.html +75 -75
- package/examples/todo/dist/index.js +8 -8
- package/examples/todo/dist/power-apps-data.js +560 -138
- package/examples/todo/dist/renderer.js +375 -375
- package/examples/todo/dist/styles.css +691 -691
- package/examples/todo/power.config.json +34 -34
- package/package.json +1 -8
- package/docs-mockups/atelier/index.html +0 -120
- package/docs-mockups/atelier/script.js +0 -23
- package/docs-mockups/atelier/styles.css +0 -361
- package/docs-mockups/field-guide/index.html +0 -112
- package/docs-mockups/field-guide/script.js +0 -20
- package/docs-mockups/field-guide/styles.css +0 -272
- package/docs-mockups/index.html +0 -80
- package/docs-mockups/maker-hub/index.html +0 -178
- package/docs-mockups/maker-hub/script.js +0 -20
- package/docs-mockups/maker-hub/styles.css +0 -404
- package/docs-mockups/script.js +0 -26
- package/docs-mockups/signal/index.html +0 -146
- package/docs-mockups/signal/script.js +0 -20
- package/docs-mockups/signal/styles.css +0 -314
- package/docs-mockups/styles.css +0 -287
- package/examples/combined demo/dist/dataverse.js +0 -86
- package/examples/combined demo/dist/environmentVar.js +0 -55
- package/examples/combined demo/dist/office365groups.js +0 -97
- package/examples/combined demo/dist/office365users.js +0 -169
- package/examples/combined demo/dist/outlook.js +0 -162
- package/examples/combined demo/dist/sharepoint.js +0 -339
- package/examples/dataverse Demo/dist/dataverse.js +0 -86
- package/examples/groups Demo/dist/dataverse.js +0 -86
- package/examples/groups Demo/dist/environmentVar.js +0 -55
- package/examples/groups Demo/dist/office365groups.js +0 -97
- package/examples/groups Demo/dist/office365users.js +0 -169
- package/examples/groups Demo/dist/outlook.js +0 -162
- package/examples/groups Demo/dist/sharepoint.js +0 -339
- package/examples/sharePoint Demo/dist/dataverse.js +0 -94
- package/examples/sharePoint Demo/dist/environmentVar.js +0 -55
- package/examples/sharePoint Demo/dist/office365groups.js +0 -97
- package/examples/sharePoint Demo/dist/office365users.js +0 -169
- package/examples/sharePoint Demo/dist/outlook.js +0 -162
- package/examples/sharePoint Demo/dist/sharepoint.js +0 -339
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Outlook Inbox</title>
|
|
7
|
-
<script type="importmap">
|
|
8
|
-
{
|
|
9
|
-
"imports": {
|
|
10
|
-
"@microsoft/power-apps/data": "./power-apps-data.js"
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
</script>
|
|
14
|
-
<link rel="stylesheet" href="styles.css" />
|
|
15
|
-
</head>
|
|
16
|
-
<body>
|
|
17
|
-
<div id="root">
|
|
18
|
-
<h1>My Inbox</h1>
|
|
19
|
-
<div id="loading">Loading emails...</div>
|
|
20
|
-
<table id="emailTable" style="display:none">
|
|
21
|
-
<thead>
|
|
22
|
-
<tr>
|
|
23
|
-
<th>From</th>
|
|
24
|
-
<th>Subject</th>
|
|
25
|
-
<th>Received</th>
|
|
26
|
-
<th>Read</th>
|
|
27
|
-
</tr>
|
|
28
|
-
</thead>
|
|
29
|
-
<tbody id="emailBody"></tbody>
|
|
30
|
-
</table>
|
|
31
|
-
<div id="error" style="display:none"></div>
|
|
32
|
-
</div>
|
|
33
|
-
<script type="module" src="index.js"></script>
|
|
34
|
-
</body>
|
|
35
|
-
</html>
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Outlook Inbox</title>
|
|
7
|
+
<script type="importmap">
|
|
8
|
+
{
|
|
9
|
+
"imports": {
|
|
10
|
+
"@microsoft/power-apps/data": "./power-apps-data.js"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
|
+
<link rel="stylesheet" href="styles.css" />
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<div id="root">
|
|
18
|
+
<h1>My Inbox</h1>
|
|
19
|
+
<div id="loading">Loading emails...</div>
|
|
20
|
+
<table id="emailTable" style="display:none">
|
|
21
|
+
<thead>
|
|
22
|
+
<tr>
|
|
23
|
+
<th>From</th>
|
|
24
|
+
<th>Subject</th>
|
|
25
|
+
<th>Received</th>
|
|
26
|
+
<th>Read</th>
|
|
27
|
+
</tr>
|
|
28
|
+
</thead>
|
|
29
|
+
<tbody id="emailBody"></tbody>
|
|
30
|
+
</table>
|
|
31
|
+
<div id="error" style="display:none"></div>
|
|
32
|
+
</div>
|
|
33
|
+
<script type="module" src="index.js"></script>
|
|
34
|
+
</body>
|
|
35
|
+
</html>
|
|
@@ -1,166 +1,170 @@
|
|
|
1
|
-
import { listEmails } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function parseJsonIfNeeded(oValue) {
|
|
9
|
-
if (typeof oValue !==
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
return JSON.parse(oValue);
|
|
13
|
-
} catch {
|
|
14
|
-
return oValue;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function isPlainObject(oValue) {
|
|
19
|
-
return oValue != null && typeof oValue ===
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function looksLikeEmailRecord(oValue) {
|
|
23
|
-
if (!isPlainObject(oValue)) return false;
|
|
24
|
-
|
|
25
|
-
return Boolean(
|
|
26
|
-
oValue.Subject ||
|
|
27
|
-
oValue.subject ||
|
|
28
|
-
oValue.From ||
|
|
29
|
-
oValue.from ||
|
|
30
|
-
oValue.DateTimeReceived ||
|
|
31
|
-
oValue.receivedDateTime ||
|
|
32
|
-
oValue.Id ||
|
|
33
|
-
oValue.id
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function findEmailArray(oValue, oSeen = new Set(), iDepth = 0) {
|
|
38
|
-
var oParsed = parseJsonIfNeeded(oValue);
|
|
39
|
-
|
|
40
|
-
if (Array.isArray(oParsed)) {
|
|
41
|
-
if (oParsed.length === 0 || looksLikeEmailRecord(oParsed[0])) return oParsed;
|
|
42
|
-
|
|
43
|
-
for (var iArrayIndex = 0; iArrayIndex < oParsed.length; iArrayIndex += 1) {
|
|
44
|
-
var aNested = findEmailArray(oParsed[iArrayIndex], oSeen, iDepth + 1);
|
|
45
|
-
if (aNested.length > 0) return aNested;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!isPlainObject(oParsed) || oSeen.has(oParsed) || iDepth > 6) return [];
|
|
52
|
-
|
|
53
|
-
oSeen.add(oParsed);
|
|
54
|
-
|
|
55
|
-
var aKeys = Object.keys(oParsed);
|
|
56
|
-
for (var iKeyIndex = 0; iKeyIndex < aKeys.length; iKeyIndex += 1) {
|
|
57
|
-
var sKey = aKeys[iKeyIndex];
|
|
58
|
-
var aNested = findEmailArray(oParsed[sKey], oSeen, iDepth + 1);
|
|
59
|
-
if (aNested.length > 0) return aNested;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return [];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function extractEmails(oResult) {
|
|
66
|
-
return findEmailArray(oResult);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function getSenderText(oEmail) {
|
|
70
|
-
if (!oEmail) return
|
|
71
|
-
if (typeof oEmail.From ===
|
|
72
|
-
if (oEmail.From && typeof oEmail.From ===
|
|
73
|
-
return oEmail.From.Email || oEmail.From.Address || oEmail.From.Name ||
|
|
74
|
-
}
|
|
75
|
-
return oEmail.from ||
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function getSubjectText(oEmail) {
|
|
79
|
-
return oEmail.Subject || oEmail.subject ||
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function getReceivedDate(oEmail) {
|
|
83
|
-
return oEmail.DateTimeReceived || oEmail.ReceivedTime || oEmail.receivedDateTime ||
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function isEmailRead(oEmail) {
|
|
87
|
-
return oEmail.IsRead === true || oEmail.isRead === true;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function formatDiagnostic(oResult) {
|
|
91
|
-
try {
|
|
92
|
-
return JSON.stringify(oResult, null, 2).slice(0, 2000);
|
|
93
|
-
} catch {
|
|
94
|
-
return String(oResult);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function formatDate(sDate) {
|
|
99
|
-
if (!sDate) return
|
|
100
|
-
var oDate = new Date(sDate);
|
|
101
|
-
return oDate.toLocaleDateString() +
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function escapeHtml(sText) {
|
|
105
|
-
if (!sText) return
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
aEmails.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
var
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
1
|
+
import { listEmails } from './codeapp.js';
|
|
2
|
+
|
|
3
|
+
let eLoading = document.getElementById('loading');
|
|
4
|
+
let eTable = document.getElementById('emailTable');
|
|
5
|
+
let eBody = document.getElementById('emailBody');
|
|
6
|
+
let eError = document.getElementById('error');
|
|
7
|
+
|
|
8
|
+
function parseJsonIfNeeded(oValue) {
|
|
9
|
+
if (typeof oValue !== 'string') return oValue;
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
return JSON.parse(oValue);
|
|
13
|
+
} catch {
|
|
14
|
+
return oValue;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function isPlainObject(oValue) {
|
|
19
|
+
return oValue != null && typeof oValue === 'object' && Array.isArray(oValue) === false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function looksLikeEmailRecord(oValue) {
|
|
23
|
+
if (!isPlainObject(oValue)) return false;
|
|
24
|
+
|
|
25
|
+
return Boolean(
|
|
26
|
+
oValue.Subject ||
|
|
27
|
+
oValue.subject ||
|
|
28
|
+
oValue.From ||
|
|
29
|
+
oValue.from ||
|
|
30
|
+
oValue.DateTimeReceived ||
|
|
31
|
+
oValue.receivedDateTime ||
|
|
32
|
+
oValue.Id ||
|
|
33
|
+
oValue.id
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function findEmailArray(oValue, oSeen = new Set(), iDepth = 0) {
|
|
38
|
+
var oParsed = parseJsonIfNeeded(oValue);
|
|
39
|
+
|
|
40
|
+
if (Array.isArray(oParsed)) {
|
|
41
|
+
if (oParsed.length === 0 || looksLikeEmailRecord(oParsed[0])) return oParsed;
|
|
42
|
+
|
|
43
|
+
for (var iArrayIndex = 0; iArrayIndex < oParsed.length; iArrayIndex += 1) {
|
|
44
|
+
var aNested = findEmailArray(oParsed[iArrayIndex], oSeen, iDepth + 1);
|
|
45
|
+
if (aNested.length > 0) return aNested;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!isPlainObject(oParsed) || oSeen.has(oParsed) || iDepth > 6) return [];
|
|
52
|
+
|
|
53
|
+
oSeen.add(oParsed);
|
|
54
|
+
|
|
55
|
+
var aKeys = Object.keys(oParsed);
|
|
56
|
+
for (var iKeyIndex = 0; iKeyIndex < aKeys.length; iKeyIndex += 1) {
|
|
57
|
+
var sKey = aKeys[iKeyIndex];
|
|
58
|
+
var aNested = findEmailArray(oParsed[sKey], oSeen, iDepth + 1);
|
|
59
|
+
if (aNested.length > 0) return aNested;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function extractEmails(oResult) {
|
|
66
|
+
return findEmailArray(oResult);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getSenderText(oEmail) {
|
|
70
|
+
if (!oEmail) return '';
|
|
71
|
+
if (typeof oEmail.From === 'string') return oEmail.From;
|
|
72
|
+
if (oEmail.From && typeof oEmail.From === 'object') {
|
|
73
|
+
return oEmail.From.Email || oEmail.From.Address || oEmail.From.Name || '';
|
|
74
|
+
}
|
|
75
|
+
return oEmail.from || '';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function getSubjectText(oEmail) {
|
|
79
|
+
return oEmail.Subject || oEmail.subject || '(No Subject)';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function getReceivedDate(oEmail) {
|
|
83
|
+
return oEmail.DateTimeReceived || oEmail.ReceivedTime || oEmail.receivedDateTime || '';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function isEmailRead(oEmail) {
|
|
87
|
+
return oEmail.IsRead === true || oEmail.isRead === true;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function formatDiagnostic(oResult) {
|
|
91
|
+
try {
|
|
92
|
+
return JSON.stringify(oResult, null, 2).slice(0, 2000);
|
|
93
|
+
} catch {
|
|
94
|
+
return String(oResult);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function formatDate(sDate) {
|
|
99
|
+
if (!sDate) return '';
|
|
100
|
+
var oDate = new Date(sDate);
|
|
101
|
+
return oDate.toLocaleDateString() + ' ' + oDate.toLocaleTimeString();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function escapeHtml(sText) {
|
|
105
|
+
if (!sText) return '';
|
|
106
|
+
let sStr = String(sText);
|
|
107
|
+
return sStr
|
|
108
|
+
.replace(new RegExp('&', 'g'), '&')
|
|
109
|
+
.replace(new RegExp('<', 'g'), '<')
|
|
110
|
+
.replace(new RegExp('>', 'g'), '>')
|
|
111
|
+
.replace(new RegExp('"', 'g'), '"')
|
|
112
|
+
.replace(new RegExp("'", 'g'), ''');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function renderEmails(aEmails) {
|
|
116
|
+
eBody.innerHTML = '';
|
|
117
|
+
|
|
118
|
+
if (aEmails.length === 0) {
|
|
119
|
+
eBody.innerHTML = '<tr><td colspan="4">No emails found.</td></tr>';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
aEmails.forEach((oEmail) => {
|
|
123
|
+
var sFrom = escapeHtml(getSenderText(oEmail));
|
|
124
|
+
var sSubject = escapeHtml(getSubjectText(oEmail));
|
|
125
|
+
var sReceived = formatDate(getReceivedDate(oEmail));
|
|
126
|
+
var bRead = isEmailRead(oEmail);
|
|
127
|
+
var sRow = '<tr>' +
|
|
128
|
+
'<td>' + sFrom + '</td>' +
|
|
129
|
+
'<td>' + sSubject + '</td>' +
|
|
130
|
+
'<td>' + sReceived + '</td>' +
|
|
131
|
+
'<td>' + (bRead ? 'Yes' : 'No') + '</td>' +
|
|
132
|
+
'</tr>';
|
|
133
|
+
eBody.innerHTML += sRow;
|
|
134
|
+
});
|
|
135
|
+
eLoading.style.display = 'none';
|
|
136
|
+
eTable.style.display = 'table';
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function showError(sMessage) {
|
|
140
|
+
eLoading.style.display = 'none';
|
|
141
|
+
eError.style.display = 'block';
|
|
142
|
+
eError.textContent = 'Error: ' + sMessage;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function boot() {
|
|
146
|
+
try {
|
|
147
|
+
var oResult = await listEmails({ folderId: 'Inbox', top: 10 });
|
|
148
|
+
var aEmails = extractEmails(oResult);
|
|
149
|
+
|
|
150
|
+
if (aEmails.length === 0) {
|
|
151
|
+
var oFallbackResult = await listEmails({ top: 10 });
|
|
152
|
+
var aFallbackEmails = extractEmails(oFallbackResult);
|
|
153
|
+
|
|
154
|
+
if (aFallbackEmails.length > 0) {
|
|
155
|
+
renderEmails(aFallbackEmails);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
showError('No emails extracted from Outlook response. Raw response: ' + formatDiagnostic(oResult));
|
|
160
|
+
renderEmails([]);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
renderEmails(aEmails);
|
|
165
|
+
} catch (oErr) {
|
|
166
|
+
showError('Outlook: ' + (oErr.message || oErr));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
boot();
|
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
import { getClient } from "@microsoft/power-apps/data";
|
|
2
|
-
|
|
3
|
-
// ── Data source name (must match connectionReferences in power.config.json) ──
|
|
4
|
-
const DATA_SOURCE_CANDIDATES = ["office365outlook", "Office365Outlook", "office365"];
|
|
5
|
-
const OUTLOOK_APIS = {
|
|
6
|
-
GetEmailsV3: {
|
|
7
|
-
path: "/{connectionId}/v3/Mail",
|
|
8
|
-
method: "GET",
|
|
9
|
-
parameters: [
|
|
10
|
-
{ name: "connectionId", in: "path", required: true },
|
|
11
|
-
{ name: "folderPath", in: "query", required: false },
|
|
12
|
-
{ name: "to", in: "query", required: false },
|
|
13
|
-
{ name: "cc", in: "query", required: false },
|
|
14
|
-
{ name: "toOrCc", in: "query", required: false },
|
|
15
|
-
{ name: "from", in: "query", required: false },
|
|
16
|
-
{ name: "importance", in: "query", required: false },
|
|
17
|
-
{ name: "fetchOnlyWithAttachment", in: "query", required: false },
|
|
18
|
-
{ name: "subjectFilter", in: "query", required: false },
|
|
19
|
-
{ name: "fetchOnlyUnread", in: "query", required: false },
|
|
20
|
-
{ name: "fetchOnlyFlagged", in: "query", required: false },
|
|
21
|
-
{ name: "mailboxAddress", in: "query", required: false },
|
|
22
|
-
{ name: "includeAttachments", in: "query", required: false },
|
|
23
|
-
{ name: "searchQuery", in: "query", required: false },
|
|
24
|
-
{ name: "top", in: "query", required: false },
|
|
25
|
-
],
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
// ── Initialize SDK client for the Office 365 Outlook connector ──
|
|
30
|
-
function initClient() {
|
|
31
|
-
const dataSourcesInfo = {};
|
|
32
|
-
|
|
33
|
-
DATA_SOURCE_CANDIDATES.forEach((sDataSourceName) => {
|
|
34
|
-
dataSourcesInfo[sDataSourceName] = {
|
|
35
|
-
tableId: "",
|
|
36
|
-
version: "",
|
|
37
|
-
primaryKey: "",
|
|
38
|
-
dataSourceType: "Connector",
|
|
39
|
-
apis: OUTLOOK_APIS,
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
return getClient(dataSourcesInfo);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function stringifyErrorDetails(oError) {
|
|
47
|
-
if (!oError) return "Operation failed";
|
|
48
|
-
if (typeof oError === "string") return oError;
|
|
49
|
-
if (oError instanceof Error) return oError.message || "Operation failed";
|
|
50
|
-
|
|
51
|
-
var aPropertyNames = Object.getOwnPropertyNames(oError);
|
|
52
|
-
var oSerializable = {};
|
|
53
|
-
aPropertyNames.forEach((sName) => {
|
|
54
|
-
oSerializable[sName] = oError[sName];
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
return JSON.stringify(oSerializable);
|
|
59
|
-
} catch {
|
|
60
|
-
return String(oError);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function unwrapResult(oResult) {
|
|
65
|
-
if (oResult && oResult.success === false) {
|
|
66
|
-
var sMessage = stringifyErrorDetails(oResult.error);
|
|
67
|
-
if (oResult.data !== undefined) {
|
|
68
|
-
sMessage += " | data: " + stringifyErrorDetails(oResult.data);
|
|
69
|
-
}
|
|
70
|
-
throw new Error(sMessage);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (oResult && Object.prototype.hasOwnProperty.call(oResult, "data")) {
|
|
74
|
-
return oResult.data;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return oResult;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// ── Internal: execute a connector operation ────────────────────
|
|
81
|
-
async function execOp(operationName, parameters) {
|
|
82
|
-
const client = await initClient();
|
|
83
|
-
const aErrors = [];
|
|
84
|
-
|
|
85
|
-
for (let iIndex = 0; iIndex < DATA_SOURCE_CANDIDATES.length; iIndex += 1) {
|
|
86
|
-
const sDataSourceName = DATA_SOURCE_CANDIDATES[iIndex];
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
const result = await client.executeAsync({
|
|
90
|
-
connectorOperation: {
|
|
91
|
-
tableName: sDataSourceName,
|
|
92
|
-
operationName,
|
|
93
|
-
parameters,
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
return unwrapResult(result);
|
|
98
|
-
} catch (oErr) {
|
|
99
|
-
const sMessage = stringifyErrorDetails(oErr);
|
|
100
|
-
aErrors.push(sDataSourceName + ": " + sMessage);
|
|
101
|
-
|
|
102
|
-
if (sMessage.indexOf("Connection reference not found") === -1) {
|
|
103
|
-
throw oErr;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
throw new Error("No Outlook connection reference matched. Tried: " + aErrors.join(" || "));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// ── List Emails ────────────────────────────────────────────────
|
|
112
|
-
export async function listEmails({ folderId = "Inbox", fetchOnlyUnread, searchQuery, top, skip } = {}) {
|
|
113
|
-
void skip;
|
|
114
|
-
|
|
115
|
-
return execOp("GetEmailsV3", {
|
|
116
|
-
folderPath: folderId,
|
|
117
|
-
fetchOnlyUnread,
|
|
118
|
-
searchQuery,
|
|
119
|
-
top: top != null ? top : 10,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
1
|
+
import { getClient } from "@microsoft/power-apps/data";
|
|
2
|
+
|
|
3
|
+
// ── Data source name (must match connectionReferences in power.config.json) ──
|
|
4
|
+
const DATA_SOURCE_CANDIDATES = ["office365outlook", "Office365Outlook", "office365"];
|
|
5
|
+
const OUTLOOK_APIS = {
|
|
6
|
+
GetEmailsV3: {
|
|
7
|
+
path: "/{connectionId}/v3/Mail",
|
|
8
|
+
method: "GET",
|
|
9
|
+
parameters: [
|
|
10
|
+
{ name: "connectionId", in: "path", required: true },
|
|
11
|
+
{ name: "folderPath", in: "query", required: false },
|
|
12
|
+
{ name: "to", in: "query", required: false },
|
|
13
|
+
{ name: "cc", in: "query", required: false },
|
|
14
|
+
{ name: "toOrCc", in: "query", required: false },
|
|
15
|
+
{ name: "from", in: "query", required: false },
|
|
16
|
+
{ name: "importance", in: "query", required: false },
|
|
17
|
+
{ name: "fetchOnlyWithAttachment", in: "query", required: false },
|
|
18
|
+
{ name: "subjectFilter", in: "query", required: false },
|
|
19
|
+
{ name: "fetchOnlyUnread", in: "query", required: false },
|
|
20
|
+
{ name: "fetchOnlyFlagged", in: "query", required: false },
|
|
21
|
+
{ name: "mailboxAddress", in: "query", required: false },
|
|
22
|
+
{ name: "includeAttachments", in: "query", required: false },
|
|
23
|
+
{ name: "searchQuery", in: "query", required: false },
|
|
24
|
+
{ name: "top", in: "query", required: false },
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// ── Initialize SDK client for the Office 365 Outlook connector ──
|
|
30
|
+
function initClient() {
|
|
31
|
+
const dataSourcesInfo = {};
|
|
32
|
+
|
|
33
|
+
DATA_SOURCE_CANDIDATES.forEach((sDataSourceName) => {
|
|
34
|
+
dataSourcesInfo[sDataSourceName] = {
|
|
35
|
+
tableId: "",
|
|
36
|
+
version: "",
|
|
37
|
+
primaryKey: "",
|
|
38
|
+
dataSourceType: "Connector",
|
|
39
|
+
apis: OUTLOOK_APIS,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return getClient(dataSourcesInfo);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function stringifyErrorDetails(oError) {
|
|
47
|
+
if (!oError) return "Operation failed";
|
|
48
|
+
if (typeof oError === "string") return oError;
|
|
49
|
+
if (oError instanceof Error) return oError.message || "Operation failed";
|
|
50
|
+
|
|
51
|
+
var aPropertyNames = Object.getOwnPropertyNames(oError);
|
|
52
|
+
var oSerializable = {};
|
|
53
|
+
aPropertyNames.forEach((sName) => {
|
|
54
|
+
oSerializable[sName] = oError[sName];
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
return JSON.stringify(oSerializable);
|
|
59
|
+
} catch {
|
|
60
|
+
return String(oError);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function unwrapResult(oResult) {
|
|
65
|
+
if (oResult && oResult.success === false) {
|
|
66
|
+
var sMessage = stringifyErrorDetails(oResult.error);
|
|
67
|
+
if (oResult.data !== undefined) {
|
|
68
|
+
sMessage += " | data: " + stringifyErrorDetails(oResult.data);
|
|
69
|
+
}
|
|
70
|
+
throw new Error(sMessage);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (oResult && Object.prototype.hasOwnProperty.call(oResult, "data")) {
|
|
74
|
+
return oResult.data;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return oResult;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ── Internal: execute a connector operation ────────────────────
|
|
81
|
+
async function execOp(operationName, parameters) {
|
|
82
|
+
const client = await initClient();
|
|
83
|
+
const aErrors = [];
|
|
84
|
+
|
|
85
|
+
for (let iIndex = 0; iIndex < DATA_SOURCE_CANDIDATES.length; iIndex += 1) {
|
|
86
|
+
const sDataSourceName = DATA_SOURCE_CANDIDATES[iIndex];
|
|
87
|
+
|
|
88
|
+
try {
|
|
89
|
+
const result = await client.executeAsync({
|
|
90
|
+
connectorOperation: {
|
|
91
|
+
tableName: sDataSourceName,
|
|
92
|
+
operationName,
|
|
93
|
+
parameters,
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return unwrapResult(result);
|
|
98
|
+
} catch (oErr) {
|
|
99
|
+
const sMessage = stringifyErrorDetails(oErr);
|
|
100
|
+
aErrors.push(sDataSourceName + ": " + sMessage);
|
|
101
|
+
|
|
102
|
+
if (sMessage.indexOf("Connection reference not found") === -1) {
|
|
103
|
+
throw oErr;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
throw new Error("No Outlook connection reference matched. Tried: " + aErrors.join(" || "));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ── List Emails ────────────────────────────────────────────────
|
|
112
|
+
export async function listEmails({ folderId = "Inbox", fetchOnlyUnread, searchQuery, top, skip } = {}) {
|
|
113
|
+
void skip;
|
|
114
|
+
|
|
115
|
+
return execOp("GetEmailsV3", {
|
|
116
|
+
folderPath: folderId,
|
|
117
|
+
fetchOnlyUnread,
|
|
118
|
+
searchQuery,
|
|
119
|
+
top: top != null ? top : 10,
|
|
120
|
+
});
|
|
121
|
+
}
|