codeapp-js 0.1.0 → 0.2.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.
Files changed (69) hide show
  1. package/codeApp/dist/codeapp.js +326 -72
  2. package/codeApp/dist/icon-512.png +0 -0
  3. package/codeApp/dist/index.html +1 -0
  4. package/codeApp/dist/index.js +1 -1
  5. package/codeApp/dist/power-apps-data.js +2952 -2531
  6. package/codeApp/power.config.json +1 -1
  7. package/dev files/customConnector.js +98 -0
  8. package/dev files/dataverse.js +33 -7
  9. package/dev files/environmentVar.js +1 -1
  10. package/dev files/office365groups.js +1 -1
  11. package/dev files/office365users.js +1 -1
  12. package/dev files/outlook.js +1 -1
  13. package/dev files/power-apps-data.js +2952 -0
  14. package/dev files/sharepoint.js +1 -1
  15. package/examples/combined demo/dist/codeapp.js +1098 -0
  16. package/examples/combined demo/dist/index.js +470 -515
  17. package/examples/combined demo/dist/power-apps-data.js +3007 -2531
  18. package/examples/dataverse Demo/dist/codeapp.js +1085 -0
  19. package/examples/dataverse Demo/dist/index.js +38 -26
  20. package/examples/dataverse Demo/dist/power-apps-data.js +2912 -2531
  21. package/examples/groups Demo/dist/codeapp.js +1085 -0
  22. package/examples/groups Demo/dist/index.js +113 -113
  23. package/examples/groups Demo/dist/power-apps-data.js +2912 -2531
  24. package/examples/groups Demo/power.config.json +3 -2
  25. package/examples/kanban/dist/power-apps-data.js +2953 -2531
  26. package/examples/myProfile/dist/power-apps-data.js +2953 -2531
  27. package/examples/outlook Demo/dist/codeapp.js +1085 -0
  28. package/examples/outlook Demo/dist/index.js +39 -35
  29. package/examples/outlook Demo/dist/power-apps-data.js +2912 -2531
  30. package/examples/planning Poker/dist/power-apps-data.js +2953 -2531
  31. package/examples/sharePoint Demo/dist/codeapp.js +1085 -0
  32. package/examples/sharePoint Demo/dist/index.js +262 -269
  33. package/examples/sharePoint Demo/dist/power-apps-data.js +2912 -2531
  34. package/examples/solution explorer/agent/decision-log.md +27 -0
  35. package/examples/solution explorer/agent/mockup-01-swiss-grid.html +452 -0
  36. package/examples/solution explorer/agent/mockup-02-dark-glass.html +496 -0
  37. package/examples/solution explorer/agent/mockup-03-paper-console.html +510 -0
  38. package/examples/solution explorer/agent/mockup-04-neon-noir.html +546 -0
  39. package/examples/solution explorer/agent/mockup-05-zen-garden.html +534 -0
  40. package/examples/solution explorer/dist/codeapp.js +1098 -0
  41. package/examples/solution explorer/dist/icon-512.png +0 -0
  42. package/examples/solution explorer/dist/index.html +80 -0
  43. package/examples/solution explorer/dist/index.js +735 -0
  44. package/examples/solution explorer/dist/power-apps-data.js +3007 -0
  45. package/examples/solution explorer/dist/styles.css +571 -0
  46. package/examples/solution explorer/power.config.json +151 -0
  47. package/examples/todo/dist/power-apps-data.js +2953 -2531
  48. package/package.json +1 -8
  49. package/.github/instructions/wyattdave.instructions.md +0 -39
  50. package/examples/combined demo/dist/dataverse.js +0 -86
  51. package/examples/combined demo/dist/environmentVar.js +0 -55
  52. package/examples/combined demo/dist/office365groups.js +0 -97
  53. package/examples/combined demo/dist/office365users.js +0 -169
  54. package/examples/combined demo/dist/outlook.js +0 -162
  55. package/examples/combined demo/dist/sharepoint.js +0 -339
  56. package/examples/dataverse Demo/dist/dataverse.js +0 -86
  57. package/examples/groups Demo/dist/dataverse.js +0 -86
  58. package/examples/groups Demo/dist/environmentVar.js +0 -55
  59. package/examples/groups Demo/dist/office365groups.js +0 -97
  60. package/examples/groups Demo/dist/office365users.js +0 -169
  61. package/examples/groups Demo/dist/outlook.js +0 -162
  62. package/examples/groups Demo/dist/sharepoint.js +0 -339
  63. package/examples/sharePoint Demo/dist/dataverse.js +0 -94
  64. package/examples/sharePoint Demo/dist/environmentVar.js +0 -55
  65. package/examples/sharePoint Demo/dist/office365groups.js +0 -97
  66. package/examples/sharePoint Demo/dist/office365users.js +0 -169
  67. package/examples/sharePoint Demo/dist/outlook.js +0 -162
  68. package/examples/sharePoint Demo/dist/sharepoint.js +0 -339
  69. package/scripts/build-power-sdk.mjs +0 -69
@@ -1,269 +1,262 @@
1
-
2
- import { getItemsByName, getItems, listTables } from './sharepoint.js';
3
-
4
- const sSiteUrl = '<SITE_URL>';
5
- const sListName = '<LIST_NAME>';
6
- const iTopRows = 20;
7
-
8
- function getElementById(sId) {
9
- return document.getElementById(sId);
10
- }
11
-
12
- function setStatus(sMessage, bIsError = false) {
13
- const eStatusBar = getElementById('statusBar');
14
-
15
- if (!eStatusBar) {
16
- return;
17
- }
18
-
19
- eStatusBar.hidden = false;
20
- eStatusBar.textContent = sMessage;
21
- eStatusBar.dataset.state = bIsError ? 'error' : 'info';
22
- }
23
-
24
- function hideStatus() {
25
- const eStatusBar = getElementById('statusBar');
26
-
27
- if (!eStatusBar) {
28
- return;
29
- }
30
-
31
- eStatusBar.hidden = true;
32
- }
33
-
34
- function setMetaLabels(iRowCount) {
35
- const eSiteLabel = getElementById('siteLabel');
36
- const eListLabel = getElementById('listLabel');
37
- const eCountLabel = getElementById('countLabel');
38
-
39
- if (eSiteLabel) {
40
- eSiteLabel.textContent = `Site: ${sSiteUrl}`;
41
- }
42
-
43
- if (eListLabel) {
44
- eListLabel.textContent = `List: ${sListName}`;
45
- }
46
-
47
- if (eCountLabel) {
48
- eCountLabel.textContent = `Rows: ${iRowCount}`;
49
- }
50
- }
51
-
52
- function normalizeResultArray(oResult) {
53
- if (Array.isArray(oResult)) {
54
- return oResult;
55
- }
56
-
57
- if (oResult && Array.isArray(oResult.value)) {
58
- return oResult.value;
59
- }
60
-
61
- if (oResult && oResult.body && Array.isArray(oResult.body.value)) {
62
- return oResult.body.value;
63
- }
64
-
65
- if (oResult && Array.isArray(oResult.body)) {
66
- return oResult.body;
67
- }
68
-
69
- return [];
70
- }
71
-
72
- function isRenderableValue(value) {
73
- return value === null || ['string', 'number', 'boolean'].includes(typeof value);
74
- }
75
-
76
- function getVisibleColumns(aRows) {
77
- const aIgnoredColumns = [
78
- '@odata.etag',
79
- 'Attachments',
80
- 'ContentTypeId',
81
- 'GUID',
82
- 'ComplianceAssetId',
83
- 'odata.editLink'
84
- ];
85
-
86
- const aColumns = [];
87
-
88
- aRows.forEach((oRow) => {
89
- Object.keys(oRow || {}).forEach((sKey) => {
90
- const bIgnored =
91
- aIgnoredColumns.includes(sKey) ||
92
- sKey.indexOf('@odata') === 0 ||
93
- sKey.indexOf('_') === 0;
94
-
95
- if (bIgnored || aColumns.includes(sKey)) {
96
- return;
97
- }
98
-
99
- if (isRenderableValue(oRow[sKey])) {
100
- aColumns.push(sKey);
101
- }
102
- });
103
- });
104
-
105
- return aColumns;
106
- }
107
-
108
- function formatCellValue(value) {
109
- if (value === null || value === undefined || value === '') {
110
- return '';
111
- }
112
-
113
- if (typeof value === 'boolean') {
114
- return value ? 'Yes' : 'No';
115
- }
116
-
117
- return String(value);
118
- }
119
-
120
- function renderTable(aRows) {
121
- const eTable = getElementById('listTable');
122
- const eTableHead = getElementById('tableHead');
123
- const eTableBody = getElementById('tableBody');
124
- const eEmptyState = getElementById('emptyState');
125
-
126
- if (!eTable || !eTableHead || !eTableBody || !eEmptyState) {
127
- return;
128
- }
129
-
130
- eTableHead.innerHTML = '';
131
- eTableBody.innerHTML = '';
132
-
133
- if (!aRows.length) {
134
- eTable.hidden = true;
135
- eEmptyState.hidden = false;
136
- return;
137
- }
138
-
139
- const aColumns = getVisibleColumns(aRows);
140
-
141
- if (!aColumns.length) {
142
- eTable.hidden = true;
143
- eEmptyState.hidden = false;
144
- setStatus('Rows loaded, but no simple text columns were available to render.');
145
- return;
146
- }
147
-
148
- const eHeaderRow = document.createElement('tr');
149
-
150
- aColumns.forEach((sColumn) => {
151
- const eHeaderCell = document.createElement('th');
152
- eHeaderCell.textContent = sColumn;
153
- eHeaderRow.appendChild(eHeaderCell);
154
- });
155
-
156
- eTableHead.appendChild(eHeaderRow);
157
-
158
- aRows.forEach((oRow) => {
159
- const eBodyRow = document.createElement('tr');
160
-
161
- aColumns.forEach((sColumn) => {
162
- const eBodyCell = document.createElement('td');
163
- eBodyCell.textContent = formatCellValue(oRow[sColumn]);
164
- eBodyRow.appendChild(eBodyCell);
165
- });
166
-
167
- eTableBody.appendChild(eBodyRow);
168
- });
169
-
170
- eEmptyState.hidden = true;
171
- eTable.hidden = false;
172
- }
173
-
174
- function normalizeText(value) {
175
- return String(value || '').trim().toLowerCase();
176
- }
177
-
178
- function getListIdentifier(oList) {
179
- return (
180
- oList?.Name ||
181
- oList?.name ||
182
- oList?.Id ||
183
- oList?.id ||
184
- oList?.TableName ||
185
- oList?.tableName ||
186
- ''
187
- );
188
- }
189
-
190
- function matchesListName(oList) {
191
- const sTarget = normalizeText(sListName);
192
- const aCandidates = [
193
- oList?.DisplayName,
194
- oList?.displayName,
195
- oList?.Title,
196
- oList?.title,
197
- oList?.Name,
198
- oList?.name
199
- ]
200
- .filter(Boolean)
201
- .map((value) => normalizeText(value));
202
-
203
- return aCandidates.includes(sTarget);
204
- }
205
-
206
- async function loadRowsByListName() {
207
- const oResult = await getItemsByName(sSiteUrl, sListName, { top: iTopRows });
208
- return normalizeResultArray(oResult).slice(0, iTopRows);
209
- }
210
-
211
- async function loadRowsByResolvedListId() {
212
- setStatus('List name lookup failed. Trying connector table lookup...');
213
-
214
- const oTablesResult = await listTables(sSiteUrl);
215
- const aLists = normalizeResultArray(oTablesResult);
216
- const oMatchedList = aLists.find((oList) => matchesListName(oList));
217
- const sResolvedListId = getListIdentifier(oMatchedList);
218
-
219
- if (!sResolvedListId) {
220
- throw new Error(`List '${sListName}' was not found in connector metadata.`);
221
- }
222
-
223
- const oItemsResult = await getItems(sSiteUrl, sResolvedListId, { top: iTopRows });
224
- return normalizeResultArray(oItemsResult).slice(0, iTopRows);
225
- }
226
-
227
- function shouldTryFallback(oError) {
228
- const sMessage = oError && oError.message ? oError.message : String(oError);
229
- return sMessage.indexOf('404') >= 0 || sMessage.indexOf('Resource not found') >= 0;
230
- }
231
-
232
- async function loadSharePointRows() {
233
- setStatus('Loading rows from SharePoint...');
234
-
235
- let aRows = [];
236
-
237
- try {
238
- aRows = await loadRowsByListName();
239
- } catch (oError) {
240
- if (!shouldTryFallback(oError)) {
241
- throw oError;
242
- }
243
-
244
- aRows = await loadRowsByResolvedListId();
245
- }
246
-
247
- setMetaLabels(aRows.length);
248
- renderTable(aRows);
249
-
250
- if (aRows.length) {
251
- hideStatus();
252
- return;
253
- }
254
-
255
- setStatus('The list loaded successfully, but no rows were returned.');
256
- }
257
-
258
- async function boot() {
259
- setMetaLabels(0);
260
-
261
- try {
262
- await loadSharePointRows();
263
- } catch (oErr) {
264
- const sMessage = oErr && oErr.message ? oErr.message : String(oErr);
265
- setStatus('SharePoint: ' + sMessage, true);
266
- }
267
- }
268
-
269
- boot();
1
+
2
+ import { getItemsByName, getItems, listTables } from './codeapp.js';
3
+
4
+ let sSiteUrl = '<SITE_URL>';
5
+ let sListName = '<LIST_NAME>';
6
+ let iTopRows = 20;
7
+
8
+ function getElementById(sId) {
9
+ return document.getElementById(sId);
10
+ }
11
+
12
+ function setStatus(sMessage, bIsError = false) {
13
+ let eStatusBar = getElementById('statusBar');
14
+
15
+ if (!eStatusBar) {
16
+ return;
17
+ }
18
+
19
+ eStatusBar.hidden = false;
20
+ eStatusBar.textContent = sMessage;
21
+ eStatusBar.dataset.state = bIsError ? 'error' : 'info';
22
+ }
23
+
24
+ function hideStatus() {
25
+ let eStatusBar = getElementById('statusBar');
26
+
27
+ if (!eStatusBar) {
28
+ return;
29
+ }
30
+
31
+ eStatusBar.hidden = true;
32
+ }
33
+
34
+ function setMetaLabels(iRowCount) {
35
+ let eSiteLabel = getElementById('siteLabel');
36
+ let eListLabel = getElementById('listLabel');
37
+ let eCountLabel = getElementById('countLabel');
38
+
39
+ if (eSiteLabel) {
40
+ eSiteLabel.textContent = 'Site: ' + sSiteUrl;
41
+ }
42
+
43
+ if (eListLabel) {
44
+ eListLabel.textContent = 'List: ' + sListName;
45
+ }
46
+
47
+ if (eCountLabel) {
48
+ eCountLabel.textContent = 'Rows: ' + iRowCount;
49
+ }
50
+ }
51
+
52
+ function normalizeResultArray(oResult) {
53
+ if (Array.isArray(oResult)) {
54
+ return oResult;
55
+ }
56
+
57
+ if (oResult && Array.isArray(oResult.value)) {
58
+ return oResult.value;
59
+ }
60
+
61
+ if (oResult && oResult.body && Array.isArray(oResult.body.value)) {
62
+ return oResult.body.value;
63
+ }
64
+
65
+ if (oResult && Array.isArray(oResult.body)) {
66
+ return oResult.body;
67
+ }
68
+
69
+ return [];
70
+ }
71
+
72
+ function isRenderableValue(value) {
73
+ return value === null || ['string', 'number', 'boolean'].includes(typeof value);
74
+ }
75
+
76
+ function getVisibleColumns(aRows) {
77
+ let aIgnoredColumns = [
78
+ '@odata.etag',
79
+ 'Attachments',
80
+ 'ContentTypeId',
81
+ 'GUID',
82
+ 'ComplianceAssetId',
83
+ 'odata.editLink'
84
+ ];
85
+
86
+ let aColumns = [];
87
+
88
+ aRows.forEach((oRow) => {
89
+ Object.keys(oRow || {}).forEach((sKey) => {
90
+ let bIgnored =
91
+ aIgnoredColumns.includes(sKey) ||
92
+ sKey.indexOf('@odata') === 0 ||
93
+ sKey.indexOf('_') === 0;
94
+
95
+ if (bIgnored || aColumns.includes(sKey)) {
96
+ return;
97
+ }
98
+
99
+ if (isRenderableValue(oRow[sKey])) {
100
+ aColumns.push(sKey);
101
+ }
102
+ });
103
+ });
104
+
105
+ return aColumns;
106
+ }
107
+
108
+ function formatCellValue(value) {
109
+ if (value === null || value === undefined || value === '') {
110
+ return '\u2014';
111
+ }
112
+
113
+ if (typeof value === 'boolean') {
114
+ return value ? 'Yes' : 'No';
115
+ }
116
+
117
+ return String(value);
118
+ }
119
+
120
+ function renderTable(aRows) {
121
+ let eTable = getElementById('listTable');
122
+ let eTableHead = getElementById('tableHead');
123
+ let eTableBody = getElementById('tableBody');
124
+ let eEmptyState = getElementById('emptyState');
125
+
126
+ if (!eTable || !eTableHead || !eTableBody || !eEmptyState) {
127
+ return;
128
+ }
129
+
130
+ eTableHead.innerHTML = '';
131
+ eTableBody.innerHTML = '';
132
+
133
+ if (!aRows.length) {
134
+ eTable.hidden = true;
135
+ eEmptyState.hidden = false;
136
+ return;
137
+ }
138
+
139
+ let aColumns = getVisibleColumns(aRows);
140
+
141
+ if (!aColumns.length) {
142
+ eTable.hidden = true;
143
+ eEmptyState.hidden = false;
144
+ setStatus('Rows loaded, but no simple text columns were available to render.');
145
+ return;
146
+ }
147
+
148
+ let eHeaderRow = document.createElement('tr');
149
+
150
+ aColumns.forEach((sColumn) => {
151
+ let eHeaderCell = document.createElement('th');
152
+ eHeaderCell.textContent = sColumn;
153
+ eHeaderRow.appendChild(eHeaderCell);
154
+ });
155
+
156
+ eTableHead.appendChild(eHeaderRow);
157
+
158
+ aRows.forEach((oRow) => {
159
+ let eBodyRow = document.createElement('tr');
160
+
161
+ aColumns.forEach((sColumn) => {
162
+ let eBodyCell = document.createElement('td');
163
+ eBodyCell.textContent = formatCellValue(oRow[sColumn]);
164
+ eBodyRow.appendChild(eBodyCell);
165
+ });
166
+
167
+ eTableBody.appendChild(eBodyRow);
168
+ });
169
+
170
+ eEmptyState.hidden = true;
171
+ eTable.hidden = false;
172
+ }
173
+
174
+ function normalizeText(value) {
175
+ return String(value || '').trim().toLowerCase();
176
+ }
177
+
178
+ function getListIdentifier(oList) {
179
+ if (!oList) return '';
180
+ return oList.Name || oList.name || oList.Id || oList.id || oList.TableName || oList.tableName || '';
181
+ }
182
+
183
+ function matchesListName(oList) {
184
+ let sTarget = normalizeText(sListName);
185
+ let aCandidates = [
186
+ oList ? oList.DisplayName : null,
187
+ oList ? oList.displayName : null,
188
+ oList ? oList.Title : null,
189
+ oList ? oList.title : null,
190
+ oList ? oList.Name : null,
191
+ oList ? oList.name : null
192
+ ]
193
+ .filter(Boolean)
194
+ .map((value) => normalizeText(value));
195
+
196
+ return aCandidates.includes(sTarget);
197
+ }
198
+
199
+ async function loadRowsByListName() {
200
+ let oResult = await getItemsByName(sSiteUrl, sListName, { top: iTopRows });
201
+ return normalizeResultArray(oResult).slice(0, iTopRows);
202
+ }
203
+
204
+ async function loadRowsByResolvedListId() {
205
+ setStatus('List name lookup failed. Trying connector table lookup...');
206
+
207
+ let oTablesResult = await listTables(sSiteUrl);
208
+ let aLists = normalizeResultArray(oTablesResult);
209
+ let oMatchedList = aLists.find((oList) => matchesListName(oList));
210
+ let sResolvedListId = getListIdentifier(oMatchedList);
211
+
212
+ if (!sResolvedListId) {
213
+ throw new Error('List \'' + sListName + '\' was not found in connector metadata.');
214
+ }
215
+
216
+ let oItemsResult = await getItems(sSiteUrl, sResolvedListId, { top: iTopRows });
217
+ return normalizeResultArray(oItemsResult).slice(0, iTopRows);
218
+ }
219
+
220
+ function shouldTryFallback(oError) {
221
+ let sMessage = oError && oError.message ? oError.message : String(oError);
222
+ return sMessage.indexOf('404') >= 0 || sMessage.indexOf('Resource not found') >= 0;
223
+ }
224
+
225
+ async function loadSharePointRows() {
226
+ setStatus('Loading rows from SharePoint...');
227
+
228
+ let aRows = [];
229
+
230
+ try {
231
+ aRows = await loadRowsByListName();
232
+ } catch (oError) {
233
+ if (!shouldTryFallback(oError)) {
234
+ throw oError;
235
+ }
236
+
237
+ aRows = await loadRowsByResolvedListId();
238
+ }
239
+
240
+ setMetaLabels(aRows.length);
241
+ renderTable(aRows);
242
+
243
+ if (aRows.length) {
244
+ hideStatus();
245
+ return;
246
+ }
247
+
248
+ setStatus('The list loaded successfully, but no rows were returned.');
249
+ }
250
+
251
+ async function boot() {
252
+ setMetaLabels(0);
253
+
254
+ try {
255
+ await loadSharePointRows();
256
+ } catch (oErr) {
257
+ let sMessage = oErr && oErr.message ? oErr.message : String(oErr);
258
+ setStatus('SharePoint: ' + sMessage, true);
259
+ }
260
+ }
261
+
262
+ boot();