codeapp-js 0.3.0 → 1.0.1
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/{examples/combined demo/.power/schemas/office365groups/office365groups.Schema.json → codeApp/.power/schemas/office365groups/office365groups.Schema.json} +2203 -2203
- package/codeApp/dist/codeapp.js +95 -1792
- 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/codeApp/dist/connectors/sharepoint.js +466 -0
- package/codeApp/dist/connectors/sql.js +149 -0
- package/codeApp/dist/connectors/teams.js +280 -0
- package/codeApp/dist/power-apps-data.js +16 -2
- package/examples/{kanban → apps/kanban}/dist/dataverse.js +94 -94
- package/examples/{kanban → apps/kanban}/dist/environmentVar.js +55 -55
- 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/examples/{kanban → apps/kanban}/dist/sharepoint.js +435 -339
- 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/{todo/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/{outlook Demo2 → apps/solution explorer}/dist/codeapp.js +9 -245
- package/examples/apps/solution explorer/dist/index.html +80 -0
- package/examples/apps/solution explorer/dist/index.js +735 -0
- package/examples/apps/solution explorer/dist/styles.css +571 -0
- package/examples/apps/solution explorer/power.config.json +151 -0
- 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/{kanban → 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/{outlook Demo2/OutlookDemo_1_0_0_1.zip → combined demo/dist/icon-512.png} +0 -0
- 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/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/{dev files → examples/sharePoint Demo/dist}/sharepoint.js +239 -112
- 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 +465 -76
- package/.vscode/settings.json +0 -6
- package/dev files/customConnector.js +0 -98
- package/dev files/dataverse.js +0 -120
- package/dev files/environmentVar.js +0 -55
- package/dev files/office365groups.js +0 -65
- package/dev files/office365users.js +0 -169
- package/dev files/outlook.js +0 -330
- package/dev files/power-apps-data.js +0 -2952
- 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/office365users.js +0 -169
- package/examples/kanban/src/generated/index.ts +0 -14
- package/examples/kanban/src/generated/models/Office365GroupsModel.ts +0 -363
- package/examples/kanban/src/generated/models/Office365OutlookModel.ts +0 -2046
- package/examples/kanban/src/generated/models/Office365UsersModel.ts +0 -254
- package/examples/kanban/src/generated/services/Office365GroupsService.ts +0 -326
- package/examples/kanban/src/generated/services/Office365OutlookService.ts +0 -2476
- package/examples/kanban/src/generated/services/Office365UsersService.ts +0 -358
- package/examples/outlook Demo2/agent/decision-log.md +0 -7
- package/examples/outlook Demo2/dist/index.html +0 -98
- package/examples/outlook Demo2/dist/index.js +0 -272
- 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/{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
|
@@ -1,170 +1,516 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
1
|
+
import { enableDebugger } from "./codeapp.js";
|
|
2
|
+
|
|
3
|
+
enableDebugger();
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
getCalendarView,
|
|
7
|
+
getEmail,
|
|
8
|
+
listContactFolders,
|
|
9
|
+
listContacts,
|
|
10
|
+
listEmails,
|
|
11
|
+
listOutlookCategories,
|
|
12
|
+
markEmailAsRead,
|
|
13
|
+
} from './outlook.js';
|
|
14
|
+
|
|
15
|
+
const eStatusLine = document.getElementById('statusLine');
|
|
16
|
+
const eInboxCount = document.getElementById('inboxCount');
|
|
17
|
+
const eEventCount = document.getElementById('eventCount');
|
|
18
|
+
const eContactCount = document.getElementById('contactCount');
|
|
19
|
+
const eCategoryCount = document.getElementById('categoryCount');
|
|
20
|
+
const eSearchInput = document.getElementById('searchInput');
|
|
21
|
+
const eUnreadOnlyInput = document.getElementById('unreadOnlyInput');
|
|
22
|
+
const eMailList = document.getElementById('mailList');
|
|
23
|
+
const eMailDetail = document.getElementById('mailDetail');
|
|
24
|
+
const eCalendarList = document.getElementById('calendarList');
|
|
25
|
+
const eCategoryList = document.getElementById('categoryList');
|
|
26
|
+
const eContactFolderSelect = document.getElementById('contactFolderSelect');
|
|
27
|
+
const eContactList = document.getElementById('contactList');
|
|
28
|
+
const eDiagnosticSelect = document.getElementById('diagnosticSelect');
|
|
29
|
+
const eDiagnosticOutput = document.getElementById('diagnosticOutput');
|
|
30
|
+
const eErrorBanner = document.getElementById('errorBanner');
|
|
31
|
+
const eRefreshAllButton = document.getElementById('refreshAllButton');
|
|
32
|
+
const eRefreshInboxButton = document.getElementById('refreshInboxButton');
|
|
33
|
+
const eRefreshCalendarButton = document.getElementById('refreshCalendarButton');
|
|
34
|
+
const eRefreshContactsButton = document.getElementById('refreshContactsButton');
|
|
35
|
+
const eMarkReadButton = document.getElementById('markReadButton');
|
|
36
|
+
const eInboxForm = document.getElementById('inboxForm');
|
|
37
|
+
|
|
38
|
+
const oState = {
|
|
39
|
+
emails: [],
|
|
40
|
+
selectedEmailId: '',
|
|
41
|
+
selectedEmail: null,
|
|
42
|
+
categories: [],
|
|
43
|
+
events: [],
|
|
44
|
+
contactFolders: [],
|
|
45
|
+
selectedContactFolderId: '',
|
|
46
|
+
contacts: [],
|
|
47
|
+
diagnostics: {
|
|
48
|
+
inbox: null,
|
|
49
|
+
message: null,
|
|
50
|
+
calendar: null,
|
|
51
|
+
contacts: null,
|
|
52
|
+
categories: null,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
function parseJsonIfNeeded(oValue) {
|
|
57
|
+
if (typeof oValue !== 'string') {
|
|
58
|
+
return oValue;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
return JSON.parse(oValue);
|
|
63
|
+
} catch {
|
|
64
|
+
return oValue;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function isPlainObject(oValue) {
|
|
69
|
+
return oValue !== null && typeof oValue === 'object' && Array.isArray(oValue) === false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function findRecords(oValue, fnPredicate, oSeen = new Set(), iDepth = 0) {
|
|
73
|
+
const oParsed = parseJsonIfNeeded(oValue);
|
|
74
|
+
|
|
75
|
+
if (Array.isArray(oParsed)) {
|
|
76
|
+
if (oParsed.length === 0 || fnPredicate(oParsed[0])) {
|
|
77
|
+
return oParsed;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
for (let iIndex = 0; iIndex < oParsed.length; iIndex += 1) {
|
|
81
|
+
const aNested = findRecords(oParsed[iIndex], fnPredicate, oSeen, iDepth + 1);
|
|
82
|
+
if (aNested.length > 0) {
|
|
83
|
+
return aNested;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!isPlainObject(oParsed) || oSeen.has(oParsed) || iDepth > 6) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
oSeen.add(oParsed);
|
|
95
|
+
|
|
96
|
+
return Object.keys(oParsed).reduce(function(aFound, sKey) {
|
|
97
|
+
if (aFound.length > 0) {
|
|
98
|
+
return aFound;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return findRecords(oParsed[sKey], fnPredicate, oSeen, iDepth + 1);
|
|
102
|
+
}, []);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function looksLikeEmail(oRecord) {
|
|
106
|
+
return isPlainObject(oRecord) && Boolean(
|
|
107
|
+
oRecord.Subject || oRecord.subject || oRecord.Id || oRecord.id || oRecord.receivedDateTime || oRecord.DateTimeReceived
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function looksLikeEvent(oRecord) {
|
|
112
|
+
return isPlainObject(oRecord) && Boolean(
|
|
113
|
+
oRecord.Subject || oRecord.subject || oRecord.Start || oRecord.start || oRecord.startWithTimeZone
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function looksLikeCategory(oRecord) {
|
|
118
|
+
return isPlainObject(oRecord) && Boolean(oRecord.displayName || oRecord.DisplayName || oRecord.id || oRecord.Id);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function looksLikeFolder(oRecord) {
|
|
122
|
+
return isPlainObject(oRecord) && Boolean(oRecord.id || oRecord.Id || oRecord.displayName || oRecord.title || oRecord.name);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function looksLikeContact(oRecord) {
|
|
126
|
+
return isPlainObject(oRecord) && Boolean(
|
|
127
|
+
oRecord.displayName || oRecord.DisplayName || oRecord.GivenName || oRecord.givenName || oRecord.EmailAddresses || oRecord.emailAddresses
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function formatDiagnostic(oValue) {
|
|
132
|
+
try {
|
|
133
|
+
return JSON.stringify(oValue, null, 2).slice(0, 4000);
|
|
134
|
+
} catch {
|
|
135
|
+
return String(oValue);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function escapeHtml(sText) {
|
|
140
|
+
if (!sText) {
|
|
141
|
+
return '';
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return String(sText)
|
|
145
|
+
.replace(new RegExp('&', 'g'), '&')
|
|
146
|
+
.replace(new RegExp('<', 'g'), '<')
|
|
147
|
+
.replace(new RegExp('>', 'g'), '>')
|
|
148
|
+
.replace(new RegExp('"', 'g'), '"')
|
|
149
|
+
.replace(new RegExp("'", 'g'), ''');
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function formatDateTime(sValue) {
|
|
153
|
+
if (!sValue) {
|
|
154
|
+
return 'Not available';
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const oDate = new Date(sValue);
|
|
158
|
+
if (Number.isNaN(oDate.getTime())) {
|
|
159
|
+
return sValue;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return oDate.toLocaleDateString() + ' ' + oDate.toLocaleTimeString();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function getSenderText(oEmail) {
|
|
166
|
+
if (!oEmail) {
|
|
167
|
+
return 'Unknown sender';
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (typeof oEmail.From === 'string') {
|
|
171
|
+
return oEmail.From;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (typeof oEmail._from === 'string') {
|
|
175
|
+
return oEmail._from;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (isPlainObject(oEmail.From)) {
|
|
179
|
+
return oEmail.From.Email || oEmail.From.Address || oEmail.From.Name || 'Unknown sender';
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return oEmail.from || oEmail.organizer || 'Unknown sender';
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function getSubjectText(oEmail) {
|
|
186
|
+
return oEmail.Subject || oEmail.subject || '(No Subject)';
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function getReceivedDateText(oEmail) {
|
|
190
|
+
return oEmail.DateTimeReceived || oEmail.receivedDateTime || oEmail.DateTimeCreated || oEmail.createdDateTime || '';
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function isEmailRead(oEmail) {
|
|
194
|
+
return oEmail.IsRead === true || oEmail.isRead === true;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function getEventTitle(oEvent) {
|
|
198
|
+
return oEvent.Subject || oEvent.subject || '(Untitled event)';
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function getEventStart(oEvent) {
|
|
202
|
+
return oEvent.Start || oEvent.startWithTimeZone || oEvent.start || '';
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function getEventEnd(oEvent) {
|
|
206
|
+
return oEvent.End || oEvent.endWithTimeZone || oEvent.end || '';
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function getContactName(oContact) {
|
|
210
|
+
return oContact.DisplayName || oContact.displayName || [oContact.GivenName, oContact.Surname].filter(Boolean).join(' ') || 'Unnamed contact';
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function getContactAddress(oContact) {
|
|
214
|
+
if (typeof oContact.EmailAddresses === 'string') {
|
|
215
|
+
return oContact.EmailAddresses;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const aEmailAddresses = oContact.EmailAddresses || oContact.emailAddresses || [];
|
|
219
|
+
if (Array.isArray(aEmailAddresses) && aEmailAddresses.length > 0) {
|
|
220
|
+
const oPrimary = aEmailAddresses[0];
|
|
221
|
+
return oPrimary.Address || oPrimary.address || oPrimary.Name || oPrimary.name || 'No email';
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return oContact.Email || oContact.email || 'No email';
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function setStatus(sText) {
|
|
228
|
+
eStatusLine.textContent = sText;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function showError(sText) {
|
|
232
|
+
eErrorBanner.textContent = sText;
|
|
233
|
+
eErrorBanner.classList.remove('is-hidden');
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function clearError() {
|
|
237
|
+
eErrorBanner.textContent = '';
|
|
238
|
+
eErrorBanner.classList.add('is-hidden');
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function updateDiagnostics() {
|
|
242
|
+
const sKey = eDiagnosticSelect.value;
|
|
243
|
+
eDiagnosticOutput.textContent = formatDiagnostic(oState.diagnostics[sKey] || 'No payload captured yet.');
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function renderInbox() {
|
|
247
|
+
eInboxCount.textContent = String(oState.emails.length);
|
|
248
|
+
|
|
249
|
+
if (oState.emails.length === 0) {
|
|
250
|
+
eMailList.innerHTML = '<div class="empty-state">No messages matched the current Outlook query.</div>';
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
eMailList.innerHTML = oState.emails.map(function(oEmail) {
|
|
255
|
+
const sId = escapeHtml(oEmail.Id || oEmail.id || '');
|
|
256
|
+
const sActiveClass = oState.selectedEmailId === (oEmail.Id || oEmail.id) ? ' is-active' : '';
|
|
257
|
+
const sReadLabel = isEmailRead(oEmail) ? 'Read' : 'Unread';
|
|
258
|
+
|
|
259
|
+
return '<button class="mail-item' + sActiveClass + '" type="button" data-email-id="' + sId + '">' +
|
|
260
|
+
'<p class="mail-meta">' + escapeHtml(getSenderText(oEmail)) + '</p>' +
|
|
261
|
+
'<p class="mail-item-subject">' + escapeHtml(getSubjectText(oEmail)) + '</p>' +
|
|
262
|
+
'<p class="mail-meta">' + escapeHtml(formatDateTime(getReceivedDateText(oEmail))) + ' · ' + escapeHtml(sReadLabel) + '</p>' +
|
|
263
|
+
'</button>';
|
|
264
|
+
}).join('');
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function renderSelectedEmail() {
|
|
268
|
+
const oEmail = oState.selectedEmail;
|
|
269
|
+
eMarkReadButton.disabled = !oEmail || isEmailRead(oEmail);
|
|
270
|
+
|
|
271
|
+
if (!oEmail) {
|
|
272
|
+
eMailDetail.className = 'mail-detail empty-state';
|
|
273
|
+
eMailDetail.textContent = 'Pick a message to load the full Outlook payload.';
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const sBody = oEmail.Body || oEmail.body || oEmail.BodyPreview || oEmail.bodyPreview || 'No body returned.';
|
|
278
|
+
const aChips = [];
|
|
279
|
+
const aAttachments = oEmail.Attachments || oEmail.attachments || [];
|
|
280
|
+
|
|
281
|
+
if (oEmail.Importance || oEmail.importance) {
|
|
282
|
+
aChips.push('<span class="detail-chip">Importance: ' + escapeHtml(oEmail.Importance || oEmail.importance) + '</span>');
|
|
283
|
+
}
|
|
284
|
+
if (aAttachments.length > 0) {
|
|
285
|
+
aChips.push('<span class="detail-chip">Attachments: ' + escapeHtml(String(aAttachments.length)) + '</span>');
|
|
286
|
+
}
|
|
287
|
+
if (oEmail.Categories || oEmail.categories) {
|
|
288
|
+
const aCategories = oEmail.Categories || oEmail.categories;
|
|
289
|
+
aChips.push('<span class="detail-chip">Categories: ' + escapeHtml((aCategories || []).join(', ')) + '</span>');
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
eMailDetail.className = 'mail-detail';
|
|
293
|
+
eMailDetail.innerHTML = '<div class="mail-detail-grid">' +
|
|
294
|
+
'<p class="mail-meta">' + escapeHtml(getSenderText(oEmail)) + '</p>' +
|
|
295
|
+
'<h3>' + escapeHtml(getSubjectText(oEmail)) + '</h3>' +
|
|
296
|
+
'<p class="mail-meta">Received ' + escapeHtml(formatDateTime(getReceivedDateText(oEmail))) + '</p>' +
|
|
297
|
+
'<div class="detail-chip-row">' + aChips.join('') + '</div>' +
|
|
298
|
+
'<p class="mail-detail-body">' + escapeHtml(sBody) + '</p>' +
|
|
299
|
+
'</div>';
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function renderCalendar() {
|
|
303
|
+
eEventCount.textContent = String(oState.events.length);
|
|
304
|
+
|
|
305
|
+
if (oState.events.length === 0) {
|
|
306
|
+
eCalendarList.innerHTML = '<div class="empty-state">No events were returned for the current calendar window.</div>';
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
eCalendarList.innerHTML = oState.events.map(function(oEvent) {
|
|
311
|
+
return '<article class="event-item">' +
|
|
312
|
+
'<p class="event-title">' + escapeHtml(getEventTitle(oEvent)) + '</p>' +
|
|
313
|
+
'<p class="event-meta">' + escapeHtml(formatDateTime(getEventStart(oEvent))) + '</p>' +
|
|
314
|
+
'<p class="event-meta">Ends ' + escapeHtml(formatDateTime(getEventEnd(oEvent))) + '</p>' +
|
|
315
|
+
'</article>';
|
|
316
|
+
}).join('');
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function renderCategories() {
|
|
320
|
+
eCategoryCount.textContent = String(oState.categories.length);
|
|
321
|
+
|
|
322
|
+
if (oState.categories.length === 0) {
|
|
323
|
+
eCategoryList.innerHTML = '<div class="empty-state">No Outlook categories were returned.</div>';
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
eCategoryList.innerHTML = oState.categories.map(function(oCategory) {
|
|
328
|
+
return '<span class="category-pill">' + escapeHtml(oCategory.displayName || oCategory.DisplayName || oCategory.id || oCategory.Id || 'Category') + '</span>';
|
|
329
|
+
}).join('');
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function renderContactFolders() {
|
|
333
|
+
const aFolders = oState.contactFolders;
|
|
334
|
+
eContactFolderSelect.innerHTML = aFolders.map(function(oFolder) {
|
|
335
|
+
const sId = oFolder.id || oFolder.Id || oFolder.name || oFolder.title || '';
|
|
336
|
+
const sLabel = oFolder.displayName || oFolder.title || oFolder.name || sId || 'Contact folder';
|
|
337
|
+
const sSelected = sId === oState.selectedContactFolderId ? ' selected' : '';
|
|
338
|
+
return '<option value="' + escapeHtml(sId) + '"' + sSelected + '>' + escapeHtml(sLabel) + '</option>';
|
|
339
|
+
}).join('');
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function renderContacts() {
|
|
343
|
+
eContactCount.textContent = String(oState.contacts.length);
|
|
344
|
+
|
|
345
|
+
if (oState.contacts.length === 0) {
|
|
346
|
+
eContactList.innerHTML = '<div class="empty-state">No contacts were returned for the selected folder.</div>';
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
eContactList.innerHTML = oState.contacts.map(function(oContact) {
|
|
351
|
+
return '<article class="contact-item">' +
|
|
352
|
+
'<p class="contact-name">' + escapeHtml(getContactName(oContact)) + '</p>' +
|
|
353
|
+
'<p class="contact-meta">' + escapeHtml(getContactAddress(oContact)) + '</p>' +
|
|
354
|
+
'</article>';
|
|
355
|
+
}).join('');
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
async function loadInbox() {
|
|
359
|
+
setStatus('Loading inbox...');
|
|
360
|
+
const oResult = await listEmails({
|
|
361
|
+
folderId: 'Inbox',
|
|
362
|
+
fetchOnlyUnread: eUnreadOnlyInput.checked,
|
|
363
|
+
searchQuery: eSearchInput.value.trim(),
|
|
364
|
+
top: 12,
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
oState.diagnostics.inbox = oResult;
|
|
368
|
+
oState.emails = findRecords(oResult, looksLikeEmail);
|
|
369
|
+
renderInbox();
|
|
370
|
+
updateDiagnostics();
|
|
371
|
+
|
|
372
|
+
if (oState.emails.length > 0) {
|
|
373
|
+
const sSelectedEmailId = oState.emails.some(function(oEmail) {
|
|
374
|
+
return (oEmail.Id || oEmail.id) === oState.selectedEmailId;
|
|
375
|
+
}) ? oState.selectedEmailId : (oState.emails[0].Id || oState.emails[0].id);
|
|
376
|
+
|
|
377
|
+
await loadEmail(sSelectedEmailId);
|
|
378
|
+
} else {
|
|
379
|
+
oState.selectedEmailId = '';
|
|
380
|
+
oState.selectedEmail = null;
|
|
381
|
+
renderSelectedEmail();
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
async function loadEmail(sEmailId) {
|
|
386
|
+
if (!sEmailId) {
|
|
387
|
+
oState.selectedEmailId = '';
|
|
388
|
+
oState.selectedEmail = null;
|
|
389
|
+
renderSelectedEmail();
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
setStatus('Loading selected message...');
|
|
394
|
+
const oResult = await getEmail(sEmailId, { includeAttachments: true });
|
|
395
|
+
oState.selectedEmailId = sEmailId;
|
|
396
|
+
oState.selectedEmail = parseJsonIfNeeded(oResult);
|
|
397
|
+
oState.diagnostics.message = oResult;
|
|
398
|
+
renderInbox();
|
|
399
|
+
renderSelectedEmail();
|
|
400
|
+
updateDiagnostics();
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
async function loadCalendar() {
|
|
404
|
+
setStatus('Loading calendar view...');
|
|
405
|
+
const oNow = new Date();
|
|
406
|
+
const oEnd = new Date(oNow.getTime() + (3 * 24 * 60 * 60 * 1000));
|
|
407
|
+
const oResult = await getCalendarView({
|
|
408
|
+
calendarId: 'Calendar',
|
|
409
|
+
startDateTimeUtc: oNow.toISOString(),
|
|
410
|
+
endDateTimeUtc: oEnd.toISOString(),
|
|
411
|
+
top: 8,
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
oState.diagnostics.calendar = oResult;
|
|
415
|
+
oState.events = findRecords(oResult, looksLikeEvent);
|
|
416
|
+
renderCalendar();
|
|
417
|
+
updateDiagnostics();
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
async function loadCategories() {
|
|
421
|
+
setStatus('Loading Outlook categories...');
|
|
422
|
+
const oResult = await listOutlookCategories();
|
|
423
|
+
oState.diagnostics.categories = oResult;
|
|
424
|
+
oState.categories = findRecords(oResult, looksLikeCategory);
|
|
425
|
+
renderCategories();
|
|
426
|
+
updateDiagnostics();
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
async function loadContactFoldersAndContacts() {
|
|
430
|
+
setStatus('Loading contact folders...');
|
|
431
|
+
const oFolderResult = await listContactFolders();
|
|
432
|
+
oState.contactFolders = findRecords(oFolderResult, looksLikeFolder);
|
|
433
|
+
if (!oState.selectedContactFolderId && oState.contactFolders.length > 0) {
|
|
434
|
+
oState.selectedContactFolderId = oState.contactFolders[0].id || oState.contactFolders[0].Id || '';
|
|
435
|
+
}
|
|
436
|
+
renderContactFolders();
|
|
437
|
+
|
|
438
|
+
if (!oState.selectedContactFolderId) {
|
|
439
|
+
oState.contacts = [];
|
|
440
|
+
oState.diagnostics.contacts = oFolderResult;
|
|
441
|
+
renderContacts();
|
|
442
|
+
updateDiagnostics();
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
setStatus('Loading contacts...');
|
|
447
|
+
const oContactsResult = await listContacts(oState.selectedContactFolderId, { top: 10 });
|
|
448
|
+
oState.contacts = findRecords(oContactsResult, looksLikeContact);
|
|
449
|
+
oState.diagnostics.contacts = oContactsResult;
|
|
450
|
+
renderContacts();
|
|
451
|
+
updateDiagnostics();
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
async function refreshDesk() {
|
|
455
|
+
clearError();
|
|
456
|
+
try {
|
|
457
|
+
await Promise.all([
|
|
458
|
+
loadInbox(),
|
|
459
|
+
loadCalendar(),
|
|
460
|
+
loadCategories(),
|
|
461
|
+
loadContactFoldersAndContacts(),
|
|
462
|
+
]);
|
|
463
|
+
setStatus('Outlook desk updated at ' + new Date().toLocaleTimeString() + '.');
|
|
464
|
+
} catch (oError) {
|
|
465
|
+
showError('Outlook request failed: ' + (oError.message || oError));
|
|
466
|
+
setStatus('Outlook returned an error.');
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
async function handleMarkRead() {
|
|
471
|
+
if (!oState.selectedEmailId) {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
clearError();
|
|
476
|
+
try {
|
|
477
|
+
setStatus('Marking message as read...');
|
|
478
|
+
await markEmailAsRead(oState.selectedEmailId, { isRead: true });
|
|
479
|
+
await loadInbox();
|
|
480
|
+
setStatus('Message updated at ' + new Date().toLocaleTimeString() + '.');
|
|
481
|
+
} catch (oError) {
|
|
482
|
+
showError('Unable to mark the message as read: ' + (oError.message || oError));
|
|
483
|
+
setStatus('Mark read failed.');
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
eInboxForm.addEventListener('submit', function(oEvent) {
|
|
488
|
+
oEvent.preventDefault();
|
|
489
|
+
refreshDesk();
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
eSearchInput.addEventListener('change', refreshDesk);
|
|
493
|
+
eUnreadOnlyInput.addEventListener('change', refreshDesk);
|
|
494
|
+
eRefreshAllButton.addEventListener('click', refreshDesk);
|
|
495
|
+
eRefreshInboxButton.addEventListener('click', loadInbox);
|
|
496
|
+
eRefreshCalendarButton.addEventListener('click', loadCalendar);
|
|
497
|
+
eRefreshContactsButton.addEventListener('click', loadContactFoldersAndContacts);
|
|
498
|
+
eMarkReadButton.addEventListener('click', handleMarkRead);
|
|
499
|
+
|
|
500
|
+
eMailList.addEventListener('click', function(oEvent) {
|
|
501
|
+
const eButton = oEvent.target.closest('[data-email-id]');
|
|
502
|
+
if (!eButton) {
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
loadEmail(eButton.getAttribute('data-email-id'));
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
eContactFolderSelect.addEventListener('change', function() {
|
|
510
|
+
oState.selectedContactFolderId = eContactFolderSelect.value;
|
|
511
|
+
loadContactFoldersAndContacts();
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
eDiagnosticSelect.addEventListener('change', updateDiagnostics);
|
|
515
|
+
|
|
516
|
+
refreshDesk();
|