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.
Files changed (176) hide show
  1. package/AI/codeapp.agent.md +105 -0
  2. package/AI/skills/connections/SKILL.md +47 -0
  3. package/AI/skills/dataverse/SKILL.md +99 -0
  4. package/AI/skills/environment-variables/SKILL.md +89 -0
  5. package/AI/skills/frontend-design/SKILL.md +34 -0
  6. package/AI/skills/jira/SKILL.md +81 -0
  7. package/AI/skills/office365-groups/SKILL.md +61 -0
  8. package/AI/skills/office365-outlook/SKILL.md +52 -0
  9. package/AI/skills/office365-users/SKILL.md +78 -0
  10. package/AI/skills/sharepoint/SKILL.md +77 -0
  11. package/AI/skills/sql/SKILL.md +85 -0
  12. package/AI/skills/start/SKILL.md +46 -0
  13. package/AI/skills/teams/SKILL.md +55 -0
  14. package/codeApp/.power/schemas/appschemas/dataSourcesInfo.ts +6275 -0
  15. package/codeApp/.power/schemas/jira/jira.Schema.json +6903 -0
  16. package/codeApp/.power/schemas/keyvault/keyvault.Schema.json +1600 -0
  17. package/{examples/combined demo/.power/schemas/office365groups/office365groups.Schema.json → codeApp/.power/schemas/office365groups/office365groups.Schema.json} +2203 -2203
  18. package/codeApp/.power/schemas/teams/teams.Schema.json +11112 -0
  19. package/codeApp/dist/codeapp.js +103 -1043
  20. package/codeApp/dist/connectors/azureKeyvault.js +459 -0
  21. package/codeApp/dist/connectors/jira.js +1247 -0
  22. package/codeApp/dist/connectors/office365groups.js +642 -0
  23. package/codeApp/dist/connectors/office365users.js +513 -0
  24. package/codeApp/dist/connectors/outlook.js +1393 -0
  25. package/{examples/kanban/dist → codeApp/dist/connectors}/sharepoint.js +466 -339
  26. package/codeApp/dist/connectors/sql.js +149 -0
  27. package/codeApp/dist/connectors/teams.js +280 -0
  28. package/codeApp/dist/index.js +1 -1
  29. package/codeApp/dist/power-apps-data.js +725 -176
  30. package/codeApp/src/generated/index.ts +12 -0
  31. package/codeApp/src/generated/models/AzureKeyVaultModel.ts +107 -0
  32. package/codeApp/src/generated/models/JiraModel.ts +501 -0
  33. package/codeApp/src/generated/services/AzureKeyVaultService.ts +257 -0
  34. package/codeApp/src/generated/services/JiraService.ts +1124 -0
  35. package/examples/{kanban → apps/kanban}/dist/dataverse.js +94 -94
  36. package/examples/{kanban → apps/kanban}/dist/index.css +605 -605
  37. package/examples/{kanban → apps/kanban}/dist/index.html +21 -21
  38. package/examples/{kanban → apps/kanban}/dist/index.js +860 -860
  39. package/examples/{kanban → apps/kanban}/dist/office365groups.js +97 -97
  40. package/examples/apps/kanban/dist/office365users.js +451 -0
  41. package/examples/{kanban → apps/kanban}/dist/outlook.js +162 -162
  42. package/examples/{planning Poker/dist/power-apps-data.js → apps/kanban/dist/power-apps-data.js} +2953 -2953
  43. package/{dev files/sharepoint.js → examples/apps/kanban/dist/sharepoint.js} +195 -99
  44. package/examples/{kanban → apps/kanban}/power.config.json +35 -35
  45. package/examples/{planning Poker → apps/planning Poker}/additional files/customizations (tables).xml +6428 -6428
  46. package/examples/{planning Poker → apps/planning Poker}/additional files/dataverse-tables.json +165 -165
  47. package/examples/{planning Poker → apps/planning Poker}/additional files/readme.md +122 -122
  48. package/examples/{planning Poker → apps/planning Poker}/dist/dataverse.js +78 -78
  49. package/examples/{planning Poker → apps/planning Poker}/dist/index.html +198 -198
  50. package/examples/{planning Poker → apps/planning Poker}/dist/index.js +954 -954
  51. package/examples/{kanban/dist/power-apps-data.js → apps/planning Poker/dist/power-apps-data.js } +2953 -2953
  52. package/examples/{planning Poker → apps/planning Poker}/dist/styles.css +815 -815
  53. package/examples/{planning Poker → apps/planning Poker}/power.config.json +50 -50
  54. package/examples/{solution explorer → apps/solution explorer}/dist/codeapp.js +1098 -1098
  55. package/examples/{solution explorer → apps/solution explorer}/dist/index.html +80 -80
  56. package/examples/{solution explorer → apps/solution explorer}/dist/index.js +735 -735
  57. package/examples/{solution explorer → apps/solution explorer}/dist/styles.css +571 -571
  58. package/examples/{solution explorer → apps/solution explorer}/power.config.json +150 -150
  59. package/examples/{todo → apps/todo}/dist/dataverse.js +64 -64
  60. package/examples/{todo → apps/todo}/dist/index.html +75 -75
  61. package/examples/{todo → apps/todo}/dist/index.js +8 -8
  62. package/examples/{todo → apps/todo}/dist/power-apps-data.js +2953 -2953
  63. package/examples/{todo → apps/todo}/dist/renderer.js +375 -375
  64. package/examples/{todo → apps/todo}/dist/styles.css +691 -691
  65. package/examples/{todo → apps/todo}/power.config.json +34 -34
  66. package/examples/combined demo/.power/schemas/appschemas/dataSourcesInfo.ts +6275 -7830
  67. package/examples/combined demo/.power/schemas/jira/jira.Schema.json +6903 -0
  68. package/examples/combined demo/.power/schemas/keyvault/keyvault.Schema.json +1600 -0
  69. package/examples/combined demo/.power/schemas/teams/teams.Schema.json +11112 -0
  70. package/examples/combined demo/dist/codeapp.js +394 -1098
  71. package/examples/combined demo/dist/index.html +29 -511
  72. package/examples/combined demo/dist/index.js +490 -470
  73. package/examples/combined demo/dist/office365users.js +513 -0
  74. package/examples/combined demo/dist/outlook.js +1393 -0
  75. package/examples/combined demo/dist/power-apps-data.js +3079 -3006
  76. package/examples/combined demo/dist/styles.css +483 -0
  77. package/examples/combined demo/power.config.json +33 -42
  78. package/examples/combined demo/src/generated/index.ts +12 -14
  79. package/examples/combined demo/src/generated/models/AzureKeyVaultModel.ts +107 -0
  80. package/examples/combined demo/src/generated/models/JiraModel.ts +501 -0
  81. package/examples/combined demo/src/generated/services/AzureKeyVaultService.ts +257 -0
  82. package/examples/combined demo/src/generated/services/JiraService.ts +1124 -0
  83. package/examples/dataverse Demo/dist/codeapp.js +394 -1085
  84. package/examples/{outlook Demo2/OutlookDemo_1_0_0_1.zip → dataverse Demo/dist/icon-512.png} +0 -0
  85. package/examples/dataverse Demo/dist/index.html +146 -54
  86. package/examples/dataverse Demo/dist/index.js +693 -83
  87. package/examples/dataverse Demo/dist/power-apps-data.js +3079 -2911
  88. package/examples/dataverse Demo/dist/styles.css +528 -0
  89. package/examples/dataverse Demo/power.config.json +41 -35
  90. package/examples/dataverse Demo/readme.md +79 -79
  91. package/examples/groups Demo/dist/codeapp.js +394 -1085
  92. package/examples/groups Demo/dist/icon-512.png +0 -0
  93. package/examples/groups Demo/dist/index.html +21 -25
  94. package/examples/groups Demo/dist/index.js +304 -113
  95. package/examples/groups Demo/dist/office365groups.js +642 -0
  96. package/examples/groups Demo/dist/power-apps-data.js +3079 -2911
  97. package/examples/groups Demo/dist/styles.css +509 -0
  98. package/examples/groups Demo/power.config.json +25 -25
  99. package/examples/myProfile/dist/codeapp.js +398 -0
  100. package/examples/myProfile/dist/index.html +21 -184
  101. package/examples/myProfile/dist/index.js +324 -141
  102. package/examples/myProfile/dist/office365users.js +517 -169
  103. package/examples/myProfile/dist/power-apps-data.js +3080 -2953
  104. package/examples/myProfile/dist/styles.css +458 -0
  105. package/examples/myProfile/power.config.json +24 -23
  106. package/examples/outlook Demo/dist/codeapp.js +394 -1085
  107. package/examples/outlook Demo/dist/index.html +150 -35
  108. package/examples/outlook Demo/dist/index.js +516 -170
  109. package/examples/outlook Demo/dist/outlook.js +1393 -121
  110. package/examples/outlook Demo/dist/power-apps-data.js +3079 -2911
  111. package/examples/outlook Demo/dist/styles.css +408 -84
  112. package/examples/outlook Demo/power.config.json +24 -23
  113. package/examples/outlook Demo/readme.md +92 -82
  114. package/examples/sharePoint Demo/dist/codeapp.js +394 -1085
  115. package/examples/sharePoint Demo/dist/icon-512.png +0 -0
  116. package/examples/sharePoint Demo/dist/index.html +22 -255
  117. package/examples/sharePoint Demo/dist/index.js +899 -262
  118. package/examples/sharePoint Demo/dist/power-apps-data.js +3079 -2911
  119. package/examples/sharePoint Demo/dist/sharepoint.js +466 -0
  120. package/examples/sharePoint Demo/dist/styles.css +587 -0
  121. package/examples/sharePoint Demo/power.config.json +23 -22
  122. package/package.json +1 -1
  123. package/readme.md +479 -61
  124. package/.github/instructions/wyattdave.instructions.md +0 -39
  125. package/.vscode/settings.json +0 -6
  126. package/dev files/dataverse.js +0 -105
  127. package/dev files/office365groups.js +0 -65
  128. package/dev files/office365users.js +0 -169
  129. package/dev files/outlook.js +0 -330
  130. package/examples/combined demo/.power/schemas/office365/office365.Schema.json +0 -21098
  131. package/examples/combined demo/.power/schemas/office365users/office365users.Schema.json +0 -2094
  132. package/examples/kanban/agent/decision-log.md +0 -9
  133. package/examples/kanban/agent/mockup-01-editorial-glass.html +0 -159
  134. package/examples/kanban/agent/mockup-02-dark-rail.html +0 -147
  135. package/examples/kanban/agent/mockup-03-paper-grid.html +0 -114
  136. package/examples/kanban/agent/mockup-04-neon-minimal.html +0 -141
  137. package/examples/kanban/agent/mockup-05-mono-architect.html +0 -119
  138. package/examples/kanban/dist/environmentVar.js +0 -55
  139. package/examples/kanban/dist/office365users.js +0 -169
  140. package/examples/kanban/src/generated/index.ts +0 -14
  141. package/examples/outlook Demo2/agent/decision-log.md +0 -7
  142. package/examples/outlook Demo2/dist/codeapp.js +0 -1334
  143. package/examples/outlook Demo2/dist/index.html +0 -98
  144. package/examples/outlook Demo2/dist/index.js +0 -346
  145. package/examples/outlook Demo2/dist/styles.css +0 -639
  146. package/examples/outlook Demo2/power.config.json +0 -23
  147. package/examples/planning Poker/.vscode/settings.json +0 -5
  148. package/examples/sharePoint Demo/agent/decision-log.md +0 -17
  149. package/examples/solution explorer/agent/decision-log.md +0 -27
  150. package/examples/solution explorer/agent/mockup-01-swiss-grid.html +0 -452
  151. package/examples/solution explorer/agent/mockup-02-dark-glass.html +0 -496
  152. package/examples/solution explorer/agent/mockup-03-paper-console.html +0 -510
  153. package/examples/solution explorer/agent/mockup-04-neon-noir.html +0 -546
  154. package/examples/solution explorer/agent/mockup-05-zen-garden.html +0 -534
  155. package/examples/solution explorer/dist/power-apps-data.js +0 -3007
  156. package/scripts/build-power-sdk.mjs +0 -69
  157. /package/{examples/kanban → codeApp}/src/generated/models/Office365GroupsModel.ts +0 -0
  158. /package/{examples/kanban → codeApp}/src/generated/models/Office365OutlookModel.ts +0 -0
  159. /package/{examples/kanban → codeApp}/src/generated/models/Office365UsersModel.ts +0 -0
  160. /package/{examples/kanban → codeApp}/src/generated/services/Office365GroupsService.ts +0 -0
  161. /package/{examples/kanban → codeApp}/src/generated/services/Office365OutlookService.ts +0 -0
  162. /package/{examples/kanban → codeApp}/src/generated/services/Office365UsersService.ts +0 -0
  163. /package/{dev files → examples/apps/kanban/dist}/environmentVar.js +0 -0
  164. /package/examples/{outlook Demo2 → apps/kanban}/src/generated/index.ts +0 -0
  165. /package/examples/{outlook Demo2 → apps/kanban}/src/generated/models/Office365GroupsModel.ts +0 -0
  166. /package/examples/{outlook Demo2 → apps/kanban}/src/generated/models/Office365OutlookModel.ts +0 -0
  167. /package/examples/{outlook Demo2 → apps/kanban}/src/generated/models/Office365UsersModel.ts +0 -0
  168. /package/examples/{outlook Demo2 → apps/kanban}/src/generated/services/Office365GroupsService.ts +0 -0
  169. /package/examples/{outlook Demo2 → apps/kanban}/src/generated/services/Office365OutlookService.ts +0 -0
  170. /package/examples/{outlook Demo2 → apps/kanban}/src/generated/services/Office365UsersService.ts +0 -0
  171. /package/examples/{planning Poker → apps/planning Poker}/additional files/AgilePoker_1_0_0_1.zip +0 -0
  172. /package/examples/{planning Poker → apps/planning Poker}/additional files/PokerTables_1_0_0_1.zip +0 -0
  173. /package/examples/{outlook Demo2 → apps/solution explorer}/dist/icon-512.png +0 -0
  174. /package/examples/{outlook Demo2 → apps/solution explorer}/dist/power-apps-data.js +0 -0
  175. /package/examples/{todo → apps/todo}/dist/icon192.png +0 -0
  176. /package/examples/{solution explorer → combined demo}/dist/icon-512.png +0 -0
@@ -0,0 +1,398 @@
1
+ import { getClient, getContext, callActionAsync } from "./power-apps-data.js";
2
+
3
+ // ── Initialize SDK & Client ────────────────────────────────────
4
+ let oSharedClient = null;
5
+ let oInitialDataSources = {};
6
+
7
+ // ── Set initial data sources (call before any API calls) ───────
8
+ export function initDataSources(oSources) {
9
+ return _dbgWrap('initDataSources', [oSources], function() {
10
+ oInitialDataSources = oSources || {};
11
+ oSharedClient = null;
12
+ });
13
+ }
14
+
15
+ function getSharedClient() {
16
+ if (!oSharedClient) {
17
+ oSharedClient = getClient(Object.assign({}, oInitialDataSources, oDataSources));
18
+ }
19
+ return oSharedClient;
20
+ }
21
+
22
+ // ── Unwrap SDK response ────────────────────────────────────────
23
+ export function unwrapResult(result) {
24
+ if (result && result.success === false) {
25
+ let sMsg = result.error ? (result.error.message || JSON.stringify(result.error)) : 'Operation failed';
26
+ throw new Error(sMsg);
27
+ }
28
+ return result && 'data' in result ? result.data : result;
29
+ }
30
+
31
+ function stringifyConnectorError(oError) {
32
+ if (!oError) return 'Unknown error';
33
+ if (typeof oError === 'string') return oError;
34
+ if (typeof oError.message === 'string' && oError.message) return oError.message;
35
+
36
+ try {
37
+ return JSON.stringify(oError);
38
+ } catch (oErr) {
39
+ return String(oError);
40
+ }
41
+ }
42
+
43
+ // ── Debugger ───────────────────────────────────────────────────
44
+ let _bDebugActive = false;
45
+ let _aDebugEntries = [];
46
+ let _eDebugPanel = null;
47
+ let _eDebugIcon = null;
48
+ let _eDebugList = null;
49
+ let _iDebugCounter = 0;
50
+
51
+ export function _dbgWrap(sName, aArgs, fnBody) {
52
+ if (!_bDebugActive) return fnBody();
53
+ let oEntry = { iId: ++_iDebugCounter, sName: sName, aArgs: _dbgClone(aArgs), iTime: Date.now() };
54
+ _aDebugEntries.unshift(oEntry);
55
+ _dbgRenderEntry(oEntry, true);
56
+ let oResult;
57
+ try {
58
+ oResult = fnBody();
59
+ } catch (oErr) {
60
+ oEntry.oError = oErr && oErr.message ? oErr.message : String(oErr);
61
+ oEntry.iDuration = Date.now() - oEntry.iTime;
62
+ _dbgRenderEntry(oEntry, false);
63
+ throw oErr;
64
+ }
65
+ if (oResult && typeof oResult.then === 'function') {
66
+ return oResult.then(function(oVal) {
67
+ oEntry.oResult = _dbgClone(oVal);
68
+ oEntry.iDuration = Date.now() - oEntry.iTime;
69
+ _dbgRenderEntry(oEntry, false);
70
+ return oVal;
71
+ }, function(oErr) {
72
+ oEntry.oError = oErr && oErr.message ? oErr.message : String(oErr);
73
+ oEntry.iDuration = Date.now() - oEntry.iTime;
74
+ _dbgRenderEntry(oEntry, false);
75
+ throw oErr;
76
+ });
77
+ }
78
+ oEntry.oResult = _dbgClone(oResult);
79
+ oEntry.iDuration = Date.now() - oEntry.iTime;
80
+ _dbgRenderEntry(oEntry, false);
81
+ return oResult;
82
+ }
83
+
84
+ function _dbgClone(oVal) {
85
+ try { return JSON.parse(JSON.stringify(oVal)); }
86
+ catch (oErr) { return String(oVal); }
87
+ }
88
+
89
+ function _dbgFormatTime(iTimestamp) {
90
+ let oDate = new Date(iTimestamp);
91
+ let sH = String(oDate.getHours()).padStart(2, '0');
92
+ let sM = String(oDate.getMinutes()).padStart(2, '0');
93
+ let sS = String(oDate.getSeconds()).padStart(2, '0');
94
+ let sMs = String(oDate.getMilliseconds()).padStart(3, '0');
95
+ return sH + ':' + sM + ':' + sS + '.' + sMs;
96
+ }
97
+
98
+ function _dbgEscapeHtml(sStr) {
99
+ if (typeof sStr !== 'string') sStr = String(sStr);
100
+ return sStr.replace(new RegExp('&', 'g'), '&amp;').replace(new RegExp('<', 'g'), '&lt;').replace(new RegExp('>', 'g'), '&gt;');
101
+ }
102
+
103
+ function _dbgRenderEntry(oEntry, bPending) {
104
+ if (!_eDebugList) return;
105
+ let sId = 'dbg-' + oEntry.iId;
106
+ let eRow = _eDebugList.querySelector('[data-dbg-id="' + sId + '"]');
107
+ if (!eRow) {
108
+ eRow = document.createElement('div');
109
+ eRow.setAttribute('data-dbg-id', sId);
110
+ eRow.style.cssText = 'border-bottom:1px solid #333;padding:6px 8px;font-size:12px;cursor:pointer;';
111
+ _eDebugList.prepend(eRow);
112
+ }
113
+ let sStatus = bPending ? '\u23F3' : (oEntry.oError ? '\u274C' : '\u2705');
114
+ let sDuration = bPending ? '\u2026' : oEntry.iDuration + 'ms';
115
+ eRow.innerHTML = '<div style="display:flex;justify-content:space-between;align-items:center;gap:6px;">'
116
+ + '<span style="flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;"><strong>' + sStatus + ' ' + _dbgEscapeHtml(oEntry.sName) + '</strong></span>'
117
+ + '<span style="color:#888;font-size:11px;white-space:nowrap;">' + _dbgFormatTime(oEntry.iTime) + ' | ' + sDuration + '</span>'
118
+ + '<button class="dbg-copy" style="background:#333;color:#e0e0e0;border:1px solid #555;border-radius:3px;padding:1px 6px;cursor:pointer;font-size:11px;white-space:nowrap;" title="Copy to clipboard">⎘</button>'
119
+ + '</div>';
120
+ eRow.querySelector('.dbg-copy').onclick = function(e) {
121
+ e.stopPropagation();
122
+ let oData = { name: oEntry.sName, args: oEntry.aArgs, time: _dbgFormatTime(oEntry.iTime) };
123
+ if (oEntry.oError) { oData.error = oEntry.oError; }
124
+ else if (oEntry.oResult !== undefined) { oData.result = oEntry.oResult; }
125
+ if (oEntry.iDuration !== undefined) { oData.duration = oEntry.iDuration + 'ms'; }
126
+ navigator.clipboard.writeText(JSON.stringify(oData, null, 2)).then(function() {
127
+ let eBtn = eRow.querySelector('.dbg-copy');
128
+ eBtn.textContent = '\u2713';
129
+ setTimeout(function() { eBtn.textContent = '\u2398'; }, 1000);
130
+ });
131
+ };
132
+ eRow.onclick = function() {
133
+ let eDetail = eRow.querySelector('.dbg-detail');
134
+ if (eDetail) { eDetail.remove(); return; }
135
+ eDetail = document.createElement('div');
136
+ eDetail.className = 'dbg-detail';
137
+ eDetail.style.cssText = 'margin-top:4px;padding:4px;background:#1a1a2e;border-radius:4px;font-size:11px;overflow:auto;max-height:300px;';
138
+ let sArgsHtml = '<div style="color:#61dafb;margin-bottom:4px;"><b>Args:</b> <pre style="margin:2px 0;white-space:pre-wrap;word-break:break-all;">' + _dbgEscapeHtml(JSON.stringify(oEntry.aArgs, null, 2)) + '</pre></div>';
139
+ let sResultHtml = '';
140
+ if (oEntry.oError) {
141
+ sResultHtml = '<div style="color:#ff6b6b;"><b>Error:</b> <pre style="margin:2px 0;white-space:pre-wrap;word-break:break-all;">' + _dbgEscapeHtml(oEntry.oError) + '</pre></div>';
142
+ } else if (!bPending) {
143
+ sResultHtml = '<div style="color:#a8e6cf;"><b>Result:</b> <pre style="margin:2px 0;white-space:pre-wrap;word-break:break-all;">' + _dbgEscapeHtml(JSON.stringify(oEntry.oResult, null, 2)) + '</pre></div>';
144
+ }
145
+ eDetail.innerHTML = sArgsHtml + sResultHtml;
146
+ eRow.appendChild(eDetail);
147
+ };
148
+ if (_eDebugIcon) {
149
+ let eBadge = _eDebugIcon.querySelector('.dbg-badge');
150
+ if (eBadge) eBadge.textContent = String(_aDebugEntries.length);
151
+ }
152
+ }
153
+
154
+ function _dbgInjectUI() {
155
+ _eDebugIcon = document.createElement('div');
156
+ _eDebugIcon.id = 'codeapp-debug-icon';
157
+ _eDebugIcon.innerHTML = '<span style="font-size:18px;">\uD83D\uDC1B</span>'
158
+ + '<span class="dbg-badge" style="position:absolute;top:-4px;right:-4px;background:#ff6b6b;color:#fff;font-size:10px;border-radius:50%;width:18px;height:18px;display:flex;align-items:center;justify-content:center;">0</span>';
159
+ _eDebugIcon.style.cssText = 'position:fixed;top:10px;right:70px;z-index:999999;width:36px;height:36px;background:#1e1e2e;border:1px solid #444;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 2px 8px rgba(0,0,0,0.4);user-select:none;';
160
+ _eDebugIcon.onclick = function() {
161
+ _eDebugPanel.style.display = _eDebugPanel.style.display === 'none' ? 'flex' : 'none';
162
+ };
163
+ document.body.appendChild(_eDebugIcon);
164
+
165
+ _eDebugPanel = document.createElement('div');
166
+ _eDebugPanel.id = 'codeapp-debug-panel';
167
+ _eDebugPanel.style.cssText = 'position:fixed;top:0;right:0;z-index:999998;width:420px;height:100vh;background:#16161e;color:#e0e0e0;font-family:monospace;display:none;flex-direction:column;box-shadow:-4px 0 16px rgba(0,0,0,0.5);';
168
+
169
+ let eHeader = document.createElement('div');
170
+ eHeader.style.cssText = 'padding:10px 12px;background:#1e1e2e;border-bottom:1px solid #333;display:flex;justify-content:space-between;align-items:center;flex-shrink:0;';
171
+ eHeader.innerHTML = '<span style="font-weight:bold;font-size:14px;">\uD83D\uDC1B codeapp.js Debugger</span>';
172
+ let eClear = document.createElement('button');
173
+ eClear.textContent = 'Clear';
174
+ eClear.style.cssText = 'background:#333;color:#e0e0e0;border:1px solid #555;border-radius:4px;padding:3px 10px;cursor:pointer;font-size:12px;';
175
+ eClear.onclick = function() {
176
+ _aDebugEntries = [];
177
+ _eDebugList.innerHTML = '';
178
+ let eBadge = _eDebugIcon.querySelector('.dbg-badge');
179
+ if (eBadge) eBadge.textContent = '0';
180
+ };
181
+ eHeader.appendChild(eClear);
182
+ _eDebugPanel.appendChild(eHeader);
183
+
184
+ _eDebugList = document.createElement('div');
185
+ _eDebugList.style.cssText = 'flex:1;overflow-y:auto;';
186
+ _eDebugPanel.appendChild(_eDebugList);
187
+ document.body.appendChild(_eDebugPanel);
188
+
189
+ // Render entries logged before UI was ready
190
+ _aDebugEntries.slice().reverse().forEach(function(oEntry) {
191
+ _dbgRenderEntry(oEntry, false);
192
+ });
193
+ }
194
+
195
+ export function enableDebugger() {
196
+ console.warn('Debug mode enabled: all API calls will be logged in the debug panel. Call enableDebugger() only in development environments.');
197
+ if (_bDebugActive) return;
198
+ _bDebugActive = true;
199
+ if (document.body) {
200
+ _dbgInjectUI();
201
+ } else {
202
+ document.addEventListener('DOMContentLoaded', _dbgInjectUI);
203
+ }
204
+ }
205
+
206
+ // ── Get Environment Variable (single query with expand) ────────
207
+ export async function getEnvironmentVariable(sSchemaName) {
208
+ return _dbgWrap('getEnvironmentVariable', [sSchemaName], async function() {
209
+ let client = getSharedClient();
210
+
211
+ // Try single query: filter values by expanded definition schema name
212
+ let valResult = await client.retrieveMultipleRecordsAsync('environmentvariablevalues', {
213
+ filter: "EnvironmentVariableDefinitionId/schemaname eq '" + sSchemaName + "'",
214
+ select: ['value'],
215
+ expand: [{ name: 'EnvironmentVariableDefinitionId', select: ['defaultvalue', 'schemaname'] }],
216
+ });
217
+ let aVals = unwrapResult(valResult);
218
+
219
+ // If value record exists, return it
220
+ if (Array.isArray(aVals) && aVals.length > 0 && aVals[0].value) {
221
+ return aVals[0].value;
222
+ }
223
+
224
+ // No value record — fall back to definition default value
225
+ let defResult = await client.retrieveMultipleRecordsAsync('environmentvariabledefinitions', {
226
+ filter: "schemaname eq '" + sSchemaName + "'",
227
+ select: ['defaultvalue'],
228
+ });
229
+ let aDefs = unwrapResult(defResult);
230
+ if (!Array.isArray(aDefs) || aDefs.length === 0) {
231
+ throw new Error('Environment variable not found: ' + sSchemaName);
232
+ }
233
+ return aDefs[0].defaultvalue || '';
234
+ });
235
+ }
236
+
237
+ // ────────────────────────────────────────────────────────────────────────────
238
+ // ─────────────────────────────── Dataverse ──────────────────────────────────
239
+ // ────────────────────────────────────────────────────────────────────────────
240
+
241
+ // ── Table Registry (populated at runtime via registerTable) ────
242
+ let oDataSources = {};
243
+
244
+ // ── Register a Dataverse table for use by the library ──────────
245
+ export function registerTable(sTableName, sPrimaryKey) {
246
+ return _dbgWrap('registerTable', [sTableName, sPrimaryKey], function() {
247
+ oDataSources[sTableName] = {
248
+ tableId: '',
249
+ version: '',
250
+ primaryKey: sPrimaryKey,
251
+ dataSourceType: 'Dataverse',
252
+ apis: {},
253
+ };
254
+ // reset client so it picks up the new table on next call
255
+ oSharedClient = null;
256
+ });
257
+ }
258
+
259
+ // ── Ensure value is an array (accepts array or comma-separated string)
260
+ function ensureArray(value) {
261
+ if (!value) return value;
262
+ if (Array.isArray(value)) return value;
263
+ if (typeof value === 'string') return value.split(',').map(function(s) { return s.trim(); });
264
+ return value;
265
+ }
266
+
267
+ // ── Create ─────────────────────────────────────────────────────
268
+ export async function createItem(tableName, primaryKey, record) {
269
+ return _dbgWrap('createItem', [tableName, primaryKey, record], async function() {
270
+ const client = getSharedClient();
271
+ const result = await client.createRecordAsync(tableName, record);
272
+ return unwrapResult(result);
273
+ });
274
+ }
275
+
276
+ // ── Read (single) ──────────────────────────────────────────────
277
+ export async function getItem(tableName, primaryKey, id, select) {
278
+ return _dbgWrap('getItem', [tableName, primaryKey, id, select], async function() {
279
+ const client = getSharedClient();
280
+ select = ensureArray(select);
281
+ const options = select ? { select } : undefined;
282
+ const result = await client.retrieveRecordAsync(tableName, id, options);
283
+ return unwrapResult(result);
284
+ });
285
+ }
286
+
287
+ // ── List (multiple) ────────────────────────────────────────────
288
+ export async function listItems(tableName, primaryKey, { filter, select, orderBy, top, skip } = {}) {
289
+ return _dbgWrap('listItems', [tableName, primaryKey, { filter, select, orderBy, top, skip }], async function() {
290
+ const client = getSharedClient();
291
+ select = ensureArray(select);
292
+ orderBy = ensureArray(orderBy);
293
+ const result = await client.retrieveMultipleRecordsAsync(tableName, {
294
+ filter,
295
+ select,
296
+ orderBy,
297
+ top,
298
+ skip,
299
+ });
300
+ let oUnwrapped = unwrapResult(result);
301
+ return { entities: Array.isArray(oUnwrapped) ? oUnwrapped : [] };
302
+ });
303
+ }
304
+
305
+ // ── Update ─────────────────────────────────────────────────────
306
+ export async function updateItem(tableName, primaryKey, id, changedFields) {
307
+ return _dbgWrap('updateItem', [tableName, primaryKey, id, changedFields], async function() {
308
+ const client = getSharedClient();
309
+ const result = await client.updateRecordAsync(tableName, id, changedFields);
310
+ return unwrapResult(result);
311
+ });
312
+ }
313
+
314
+ // ── Delete ─────────────────────────────────────────────────────
315
+ export async function deleteItem(tableName, primaryKey, id) {
316
+ return _dbgWrap('deleteItem', [tableName, primaryKey, id], async function() {
317
+ const client = getSharedClient();
318
+ const result = await client.deleteRecordAsync(tableName, id);
319
+ return unwrapResult(result);
320
+ });
321
+ }
322
+
323
+ // ── Unbound Action ─────────────────────────────────────────────
324
+ // Calls an unbound Dataverse action by POSTing to the action endpoint.
325
+ // Do NOT add action names to power.config.json dataSources — they are
326
+ // not entities and will cause deploy errors.
327
+ export async function callUnboundAction(tableName, primaryKey, actionName, params) {
328
+ return _dbgWrap('callUnboundAction', [tableName, primaryKey, actionName, params], async function() {
329
+ let oAllSources = Object.assign({}, oInitialDataSources, oDataSources);
330
+ let result = await callActionAsync(oAllSources, actionName, params || {});
331
+ return unwrapResult(result);
332
+ });
333
+ }
334
+
335
+ // ── WhoAmI ─────────────────────────────────────────────────────
336
+ export async function whoAmI() {
337
+ return _dbgWrap('whoAmI', [], async function() {
338
+ let oCtx = await getContext();
339
+ let sId = oCtx.UserId || oCtx.userId || oCtx.systemuserid;
340
+ if (sId) return sId;
341
+ if (oCtx.userSettings && oCtx.userSettings.userId) return oCtx.userSettings.userId;
342
+ return oCtx;
343
+ });
344
+ }
345
+
346
+ // ────────────────────────────────────────────────────────────────────────────
347
+ // ───────────────────────── Connector Helpers ────────────────────────────────
348
+ // ────────────────────────────────────────────────────────────────────────────
349
+
350
+ function initConnectorClientWithCandidates(aDataSourceCandidates, oApis) {
351
+ const dataSourcesInfo = {};
352
+
353
+ aDataSourceCandidates.forEach(function(sDataSourceName) {
354
+ dataSourcesInfo[sDataSourceName] = {
355
+ tableId: '',
356
+ version: '',
357
+ primaryKey: '',
358
+ dataSourceType: 'Connector',
359
+ apis: oApis,
360
+ };
361
+ });
362
+
363
+ return getClient(dataSourcesInfo);
364
+ }
365
+
366
+ async function execConnectorOpWithCandidates(aDataSourceCandidates, oApis, sConnectorName, operationName, parameters) {
367
+ if (!Object.prototype.hasOwnProperty.call(oApis, operationName)) {
368
+ throw new Error(sConnectorName + ' operation metadata is not registered for: ' + operationName);
369
+ }
370
+
371
+ const client = await initConnectorClientWithCandidates(aDataSourceCandidates, oApis);
372
+ const aErrors = [];
373
+
374
+ for (let iIndex = 0; iIndex < aDataSourceCandidates.length; iIndex += 1) {
375
+ const sDataSourceName = aDataSourceCandidates[iIndex];
376
+
377
+ try {
378
+ const result = await client.executeAsync({
379
+ connectorOperation: {
380
+ tableName: sDataSourceName,
381
+ operationName,
382
+ parameters,
383
+ },
384
+ });
385
+
386
+ return unwrapResult(result);
387
+ } catch (oErr) {
388
+ const sMessage = stringifyConnectorError(oErr);
389
+ aErrors.push(sDataSourceName + ': ' + sMessage);
390
+
391
+ if (sMessage.indexOf('Connection reference not found') === -1) {
392
+ throw oErr;
393
+ }
394
+ }
395
+ }
396
+
397
+ throw new Error('No ' + sConnectorName + ' connection reference matched. Tried: ' + aErrors.join(' || '));
398
+ }
@@ -1,184 +1,21 @@
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>My Profile</title>
7
- <script type="importmap">
8
- {
9
- "imports": {
10
- "@microsoft/power-apps/data": "./power-apps-data.js"
11
- }
12
- }
13
- </script>
14
- <style>
15
- :root {
16
- --bg: #f4f5f7;
17
- --surface: #ffffff;
18
- --accent: #4f46e5;
19
- --accent-light: #e0e7ff;
20
- --text: #1e1e2e;
21
- --text-muted: #6b7280;
22
- --border: #e5e7eb;
23
- --radius: 16px;
24
- --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
25
- --shadow-lg: 0 10px 30px rgba(0,0,0,.08);
26
- }
27
-
28
- * { margin: 0; padding: 0; box-sizing: border-box; }
29
-
30
- body {
31
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
32
- background: var(--bg);
33
- color: var(--text);
34
- min-height: 100vh;
35
- }
36
-
37
- /* ── Loading state ── */
38
- .loader {
39
- display: flex;
40
- align-items: center;
41
- justify-content: center;
42
- height: 100vh;
43
- gap: 6px;
44
- }
45
- .loader span {
46
- width: 8px; height: 8px;
47
- border-radius: 50%;
48
- background: var(--accent);
49
- animation: pulse .8s ease-in-out infinite alternate;
50
- }
51
- .loader span:nth-child(2) { animation-delay: .15s; }
52
- .loader span:nth-child(3) { animation-delay: .3s; }
53
- @keyframes pulse { to { opacity: .2; transform: scale(.7); } }
54
-
55
- /* ── Layout ── */
56
- .app { max-width: 960px; margin: 0 auto; padding: 32px 20px 48px; }
57
-
58
- /* ── Hero card ── */
59
- .hero {
60
- position: relative;
61
- background: var(--surface);
62
- border-radius: var(--radius);
63
- box-shadow: var(--shadow-lg);
64
- overflow: hidden;
65
- margin-bottom: 28px;
66
- }
67
- .hero-banner {
68
- height: 120px;
69
- background: linear-gradient(135deg, var(--accent), #7c3aed, #a855f7);
70
- }
71
- .hero-body {
72
- display: flex;
73
- align-items: flex-end;
74
- gap: 20px;
75
- padding: 0 28px 24px;
76
- margin-top: -52px;
77
- position: relative;
78
- }
79
- .avatar-ring {
80
- flex-shrink: 0;
81
- width: 104px; height: 104px;
82
- border-radius: 50%;
83
- border: 4px solid var(--surface);
84
- box-shadow: var(--shadow);
85
- overflow: hidden;
86
- background: var(--accent-light);
87
- display: flex;
88
- align-items: center;
89
- justify-content: center;
90
- }
91
- .avatar-ring img {
92
- width: 100%; height: 100%;
93
- object-fit: cover;
94
- }
95
- .avatar-ring .initials {
96
- font-size: 28px;
97
- font-weight: 700;
98
- color: var(--accent);
99
- }
100
- .hero-info { padding-bottom: 4px; }
101
- .hero-info h1 { font-size: 22px; font-weight: 700; line-height: 1.2; }
102
- .hero-info p { color: var(--text-muted); font-size: 14px; margin-top: 2px; }
103
-
104
- /* ── Detail chips ── */
105
- .details {
106
- display: flex;
107
- flex-wrap: wrap;
108
- gap: 10px;
109
- padding: 0 28px 24px;
110
- }
111
- .chip {
112
- display: inline-flex;
113
- align-items: center;
114
- gap: 6px;
115
- background: var(--bg);
116
- border: 1px solid var(--border);
117
- border-radius: 999px;
118
- padding: 6px 14px;
119
- font-size: 13px;
120
- color: var(--text);
121
- }
122
- .chip svg { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; }
123
-
124
- /* ── Section titles ── */
125
- .section-title {
126
- font-size: 13px;
127
- font-weight: 600;
128
- text-transform: uppercase;
129
- letter-spacing: .06em;
130
- color: var(--text-muted);
131
- margin-bottom: 12px;
132
- }
133
-
134
- /* ── Columns ── */
135
- .columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
136
- @media (max-width: 640px) { .columns { grid-template-columns: 1fr; } }
137
-
138
- /* ── Person card ── */
139
- .card {
140
- background: var(--surface);
141
- border-radius: var(--radius);
142
- box-shadow: var(--shadow);
143
- padding: 20px;
144
- }
145
- .person-row {
146
- display: flex;
147
- align-items: center;
148
- gap: 14px;
149
- padding: 10px 0;
150
- }
151
- .person-row + .person-row { border-top: 1px solid var(--border); }
152
- .person-avatar {
153
- width: 40px; height: 40px;
154
- border-radius: 50%;
155
- background: var(--accent-light);
156
- display: flex;
157
- align-items: center;
158
- justify-content: center;
159
- flex-shrink: 0;
160
- overflow: hidden;
161
- font-size: 14px;
162
- font-weight: 600;
163
- color: var(--accent);
164
- }
165
- .person-avatar img { width: 100%; height: 100%; object-fit: cover; }
166
- .person-meta { min-width: 0; }
167
- .person-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
168
- .person-title { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
169
-
170
- .empty-state {
171
- text-align: center;
172
- padding: 24px 0;
173
- color: var(--text-muted);
174
- font-size: 13px;
175
- }
176
- </style>
177
- </head>
178
- <body>
179
- <div id="root">
180
- <div class="loader"><span></span><span></span><span></span></div>
181
- </div>
182
- <script type="module" src="index.js"></script>
183
- </body>
184
- </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
+ <link rel="icon" type="image/png" href="./office-240.png" />
7
+ <title>My Profile</title>
8
+ <link rel="stylesheet" href="./styles.css" />
9
+ <script type="importmap">
10
+ {
11
+ "imports": {
12
+ "@microsoft/power-apps/data": "./power-apps-data.js"
13
+ }
14
+ }
15
+ </script>
16
+ </head>
17
+ <body>
18
+ <div id="root"></div>
19
+ <script type="module" src="index.js"></script>
20
+ </body>
21
+ </html>