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.
Files changed (158) 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/{examples/combined demo/.power/schemas/office365groups/office365groups.Schema.json → codeApp/.power/schemas/office365groups/office365groups.Schema.json} +2203 -2203
  15. package/codeApp/dist/codeapp.js +95 -1792
  16. package/codeApp/dist/connectors/azureKeyvault.js +459 -0
  17. package/codeApp/dist/connectors/jira.js +1247 -0
  18. package/codeApp/dist/connectors/office365groups.js +642 -0
  19. package/codeApp/dist/connectors/office365users.js +513 -0
  20. package/codeApp/dist/connectors/outlook.js +1393 -0
  21. package/codeApp/dist/connectors/sharepoint.js +466 -0
  22. package/codeApp/dist/connectors/sql.js +149 -0
  23. package/codeApp/dist/connectors/teams.js +280 -0
  24. package/codeApp/dist/power-apps-data.js +16 -2
  25. package/examples/{kanban → apps/kanban}/dist/dataverse.js +94 -94
  26. package/examples/{kanban → apps/kanban}/dist/environmentVar.js +55 -55
  27. package/examples/{kanban → apps/kanban}/dist/index.css +605 -605
  28. package/examples/{kanban → apps/kanban}/dist/index.html +21 -21
  29. package/examples/{kanban → apps/kanban}/dist/index.js +860 -860
  30. package/examples/{kanban → apps/kanban}/dist/office365groups.js +97 -97
  31. package/examples/apps/kanban/dist/office365users.js +451 -0
  32. package/examples/{kanban → apps/kanban}/dist/outlook.js +162 -162
  33. package/examples/{planning Poker/dist/power-apps-data.js → apps/kanban/dist/power-apps-data.js} +2953 -2953
  34. package/examples/{kanban → apps/kanban}/dist/sharepoint.js +435 -339
  35. package/examples/{kanban → apps/kanban}/power.config.json +35 -35
  36. package/examples/{planning Poker → apps/planning Poker}/additional files/customizations (tables).xml +6428 -6428
  37. package/examples/{planning Poker → apps/planning Poker}/additional files/dataverse-tables.json +165 -165
  38. package/examples/{planning Poker → apps/planning Poker}/additional files/readme.md +122 -122
  39. package/examples/{planning Poker → apps/planning Poker}/dist/dataverse.js +78 -78
  40. package/examples/{planning Poker → apps/planning Poker}/dist/index.html +198 -198
  41. package/examples/{planning Poker → apps/planning Poker}/dist/index.js +954 -954
  42. package/examples/{todo/dist/power-apps-data.js → apps/planning Poker/dist/power-apps-data.js } +2953 -2953
  43. package/examples/{planning Poker → apps/planning Poker}/dist/styles.css +815 -815
  44. package/examples/{planning Poker → apps/planning Poker}/power.config.json +50 -50
  45. package/examples/{outlook Demo2 → apps/solution explorer}/dist/codeapp.js +9 -245
  46. package/examples/apps/solution explorer/dist/index.html +80 -0
  47. package/examples/apps/solution explorer/dist/index.js +735 -0
  48. package/examples/apps/solution explorer/dist/styles.css +571 -0
  49. package/examples/apps/solution explorer/power.config.json +151 -0
  50. package/examples/{todo → apps/todo}/dist/dataverse.js +64 -64
  51. package/examples/{todo → apps/todo}/dist/index.html +75 -75
  52. package/examples/{todo → apps/todo}/dist/index.js +8 -8
  53. package/examples/{kanban → apps/todo}/dist/power-apps-data.js +2953 -2953
  54. package/examples/{todo → apps/todo}/dist/renderer.js +375 -375
  55. package/examples/{todo → apps/todo}/dist/styles.css +691 -691
  56. package/examples/{todo → apps/todo}/power.config.json +34 -34
  57. package/examples/combined demo/.power/schemas/appschemas/dataSourcesInfo.ts +6275 -7830
  58. package/examples/combined demo/.power/schemas/jira/jira.Schema.json +6903 -0
  59. package/examples/combined demo/.power/schemas/keyvault/keyvault.Schema.json +1600 -0
  60. package/examples/combined demo/.power/schemas/teams/teams.Schema.json +11112 -0
  61. package/examples/combined demo/dist/codeapp.js +394 -1098
  62. package/examples/{outlook Demo2/OutlookDemo_1_0_0_1.zip → combined demo/dist/icon-512.png} +0 -0
  63. package/examples/combined demo/dist/index.html +29 -511
  64. package/examples/combined demo/dist/index.js +490 -470
  65. package/examples/combined demo/dist/office365users.js +513 -0
  66. package/examples/combined demo/dist/outlook.js +1393 -0
  67. package/examples/combined demo/dist/power-apps-data.js +3079 -3006
  68. package/examples/combined demo/dist/styles.css +483 -0
  69. package/examples/combined demo/power.config.json +33 -42
  70. package/examples/combined demo/src/generated/index.ts +12 -14
  71. package/examples/combined demo/src/generated/models/AzureKeyVaultModel.ts +107 -0
  72. package/examples/combined demo/src/generated/models/JiraModel.ts +501 -0
  73. package/examples/combined demo/src/generated/services/AzureKeyVaultService.ts +257 -0
  74. package/examples/combined demo/src/generated/services/JiraService.ts +1124 -0
  75. package/examples/dataverse Demo/dist/codeapp.js +394 -1085
  76. package/examples/dataverse Demo/dist/icon-512.png +0 -0
  77. package/examples/dataverse Demo/dist/index.html +146 -54
  78. package/examples/dataverse Demo/dist/index.js +693 -83
  79. package/examples/dataverse Demo/dist/power-apps-data.js +3079 -2911
  80. package/examples/dataverse Demo/dist/styles.css +528 -0
  81. package/examples/dataverse Demo/power.config.json +41 -35
  82. package/examples/dataverse Demo/readme.md +79 -79
  83. package/examples/groups Demo/dist/codeapp.js +394 -1085
  84. package/examples/groups Demo/dist/icon-512.png +0 -0
  85. package/examples/groups Demo/dist/index.html +21 -25
  86. package/examples/groups Demo/dist/index.js +304 -113
  87. package/examples/groups Demo/dist/office365groups.js +642 -0
  88. package/examples/groups Demo/dist/power-apps-data.js +3079 -2911
  89. package/examples/groups Demo/dist/styles.css +509 -0
  90. package/examples/groups Demo/power.config.json +25 -25
  91. package/examples/myProfile/dist/codeapp.js +398 -0
  92. package/examples/myProfile/dist/index.html +21 -184
  93. package/examples/myProfile/dist/index.js +324 -141
  94. package/examples/myProfile/dist/office365users.js +517 -169
  95. package/examples/myProfile/dist/power-apps-data.js +3080 -2953
  96. package/examples/myProfile/dist/styles.css +458 -0
  97. package/examples/myProfile/power.config.json +24 -23
  98. package/examples/outlook Demo/dist/codeapp.js +394 -1085
  99. package/examples/outlook Demo/dist/index.html +150 -35
  100. package/examples/outlook Demo/dist/index.js +516 -170
  101. package/examples/outlook Demo/dist/outlook.js +1393 -121
  102. package/examples/outlook Demo/dist/power-apps-data.js +3079 -2911
  103. package/examples/outlook Demo/dist/styles.css +408 -84
  104. package/examples/outlook Demo/power.config.json +24 -23
  105. package/examples/outlook Demo/readme.md +92 -82
  106. package/examples/sharePoint Demo/dist/codeapp.js +394 -1085
  107. package/examples/sharePoint Demo/dist/icon-512.png +0 -0
  108. package/examples/sharePoint Demo/dist/index.html +22 -255
  109. package/examples/sharePoint Demo/dist/index.js +899 -262
  110. package/examples/sharePoint Demo/dist/power-apps-data.js +3079 -2911
  111. package/{dev files → examples/sharePoint Demo/dist}/sharepoint.js +239 -112
  112. package/examples/sharePoint Demo/dist/styles.css +587 -0
  113. package/examples/sharePoint Demo/power.config.json +23 -22
  114. package/package.json +1 -1
  115. package/readme.md +465 -76
  116. package/.vscode/settings.json +0 -6
  117. package/dev files/customConnector.js +0 -98
  118. package/dev files/dataverse.js +0 -120
  119. package/dev files/environmentVar.js +0 -55
  120. package/dev files/office365groups.js +0 -65
  121. package/dev files/office365users.js +0 -169
  122. package/dev files/outlook.js +0 -330
  123. package/dev files/power-apps-data.js +0 -2952
  124. package/examples/combined demo/.power/schemas/office365/office365.Schema.json +0 -21098
  125. package/examples/combined demo/.power/schemas/office365users/office365users.Schema.json +0 -2094
  126. package/examples/kanban/agent/decision-log.md +0 -9
  127. package/examples/kanban/agent/mockup-01-editorial-glass.html +0 -159
  128. package/examples/kanban/agent/mockup-02-dark-rail.html +0 -147
  129. package/examples/kanban/agent/mockup-03-paper-grid.html +0 -114
  130. package/examples/kanban/agent/mockup-04-neon-minimal.html +0 -141
  131. package/examples/kanban/agent/mockup-05-mono-architect.html +0 -119
  132. package/examples/kanban/dist/office365users.js +0 -169
  133. package/examples/kanban/src/generated/index.ts +0 -14
  134. package/examples/kanban/src/generated/models/Office365GroupsModel.ts +0 -363
  135. package/examples/kanban/src/generated/models/Office365OutlookModel.ts +0 -2046
  136. package/examples/kanban/src/generated/models/Office365UsersModel.ts +0 -254
  137. package/examples/kanban/src/generated/services/Office365GroupsService.ts +0 -326
  138. package/examples/kanban/src/generated/services/Office365OutlookService.ts +0 -2476
  139. package/examples/kanban/src/generated/services/Office365UsersService.ts +0 -358
  140. package/examples/outlook Demo2/agent/decision-log.md +0 -7
  141. package/examples/outlook Demo2/dist/index.html +0 -98
  142. package/examples/outlook Demo2/dist/index.js +0 -272
  143. package/examples/outlook Demo2/dist/styles.css +0 -639
  144. package/examples/outlook Demo2/power.config.json +0 -23
  145. package/examples/planning Poker/.vscode/settings.json +0 -5
  146. package/examples/sharePoint Demo/agent/decision-log.md +0 -17
  147. /package/examples/{outlook Demo2 → apps/kanban}/src/generated/index.ts +0 -0
  148. /package/examples/{outlook Demo2 → apps/kanban}/src/generated/models/Office365GroupsModel.ts +0 -0
  149. /package/examples/{outlook Demo2 → apps/kanban}/src/generated/models/Office365OutlookModel.ts +0 -0
  150. /package/examples/{outlook Demo2 → apps/kanban}/src/generated/models/Office365UsersModel.ts +0 -0
  151. /package/examples/{outlook Demo2 → apps/kanban}/src/generated/services/Office365GroupsService.ts +0 -0
  152. /package/examples/{outlook Demo2 → apps/kanban}/src/generated/services/Office365OutlookService.ts +0 -0
  153. /package/examples/{outlook Demo2 → apps/kanban}/src/generated/services/Office365UsersService.ts +0 -0
  154. /package/examples/{planning Poker → apps/planning Poker}/additional files/AgilePoker_1_0_0_1.zip +0 -0
  155. /package/examples/{planning Poker → apps/planning Poker}/additional files/PokerTables_1_0_0_1.zip +0 -0
  156. /package/examples/{outlook Demo2 → apps/solution explorer}/dist/icon-512.png +0 -0
  157. /package/examples/{outlook Demo2 → apps/solution explorer}/dist/power-apps-data.js +0 -0
  158. /package/examples/{todo → apps/todo}/dist/icon192.png +0 -0
@@ -1,12 +1,16 @@
1
- import { getClient } from "./power-apps-data.js";
2
1
 
2
+ // ────────────────────────────────────────────────────────────────────────────
3
+ // ─────────────────────────────── SharePoint ─────────────────────────────────
4
+ // ────────────────────────────────────────────────────────────────────────────
5
+ import { getClient} from "./power-apps-data.js";
6
+ import {_dbgWrap } from "./codeapp.js";
3
7
  // ── Data source name (must match connectionReferences in power.config.json) ──
4
- const DATA_SOURCE = "sharepointonline";
8
+ const DATA_SOURCE_SP = "sharepointonline";
5
9
 
6
10
  // ── Initialize SDK client for the SharePoint connector ─────────
7
- function initClient() {
11
+ function initSpClient() {
8
12
  const dataSourcesInfo = {
9
- [DATA_SOURCE]: {
13
+ [DATA_SOURCE_SP]: {
10
14
  tableId: "",
11
15
  version: "",
12
16
  primaryKey: "",
@@ -146,19 +150,167 @@ function initClient() {
146
150
  }
147
151
 
148
152
  // ── Internal: execute a connector operation ────────────────────
149
- async function execOp(operationName, parameters) {
150
- const client = await initClient();
151
- const result = await client.executeAsync({
152
- connectorOperation: {
153
- tableName: DATA_SOURCE,
154
- operationName,
155
- parameters,
156
- },
153
+ async function execSpOp(operationName, parameters) {
154
+ try {
155
+ const client = await initSpClient();
156
+ const result = await client.executeAsync({
157
+ connectorOperation: {
158
+ tableName: DATA_SOURCE_SP,
159
+ operationName,
160
+ parameters: parameters || {},
161
+ },
162
+ });
163
+
164
+ if (!result) {
165
+ throw new Error("No result returned");
166
+ }
167
+
168
+ if (result.success === false) {
169
+ throw new Error(getSpErrorMessage(result.error));
170
+ }
171
+
172
+ return Object.prototype.hasOwnProperty.call(result, "data") ? result.data : result;
173
+ } catch (oError) {
174
+ throw new Error("SharePoint " + operationName + " failed: " + getSpErrorMessage(oError));
175
+ }
176
+ }
177
+
178
+ function getSpErrorMessage(oError) {
179
+ if (!oError) {
180
+ return "Unknown error";
181
+ }
182
+
183
+ if (typeof oError === "string") {
184
+ return oError;
185
+ }
186
+
187
+ if (oError instanceof Error && oError.message) {
188
+ return oError.message;
189
+ }
190
+
191
+ const aCandidates = [
192
+ oError.message,
193
+ oError.error && oError.error.message,
194
+ oError.body && oError.body.message,
195
+ oError.body && oError.body.error && oError.body.error.message,
196
+ oError.data && oError.data.message,
197
+ oError.detail,
198
+ ];
199
+
200
+ const sCandidate = aCandidates.find(function(sValue) {
201
+ return typeof sValue === "string" && sValue.trim() !== "";
157
202
  });
158
- if (!result.success) {
159
- throw new Error(result.error?.message || "Operation failed");
203
+
204
+ if (sCandidate) {
205
+ return sCandidate;
206
+ }
207
+
208
+ try {
209
+ return JSON.stringify(oError);
210
+ } catch (oStringifyError) {
211
+ return String(oError);
212
+ }
213
+ }
214
+
215
+ function requireNonEmptyString(sValue, sLabel) {
216
+ if (typeof sValue !== "string" || sValue.trim() === "") {
217
+ throw new Error("SharePoint " + sLabel + " is required.");
160
218
  }
161
- return result.data;
219
+
220
+ return sValue.trim();
221
+ }
222
+
223
+ function requireRecord(oValue, sLabel) {
224
+ if (!oValue || typeof oValue !== "object" || Array.isArray(oValue)) {
225
+ throw new Error("SharePoint " + sLabel + " must be an object.");
226
+ }
227
+
228
+ return oValue;
229
+ }
230
+
231
+ function normalizeHeaders(oHeaders) {
232
+ if (oHeaders == null) {
233
+ return {};
234
+ }
235
+
236
+ if (typeof oHeaders !== "object" || Array.isArray(oHeaders)) {
237
+ throw new Error("SharePoint request headers must be an object.");
238
+ }
239
+
240
+ return oHeaders;
241
+ }
242
+
243
+ function normalizeNumericQueryValue(value, sLabel) {
244
+ if (value == null || value === "") {
245
+ return null;
246
+ }
247
+
248
+ const iValue = Number(value);
249
+ if (!Number.isFinite(iValue)) {
250
+ throw new Error("SharePoint " + sLabel + " must be numeric.");
251
+ }
252
+
253
+ return iValue;
254
+ }
255
+
256
+ function requireItemId(iItemId) {
257
+ if ((typeof iItemId !== "string" && typeof iItemId !== "number") || String(iItemId).trim() === "") {
258
+ throw new Error("SharePoint item ID is required.");
259
+ }
260
+
261
+ return iItemId;
262
+ }
263
+
264
+ function buildListContext(sSiteUrl, sListId) {
265
+ return {
266
+ siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
267
+ table: requireNonEmptyString(sListId, "list ID"),
268
+ };
269
+ }
270
+
271
+ function buildItemQueryParameters(sSiteUrl, sListId, { filter, orderBy, top, skip } = {}) {
272
+ const oParams = buildListContext(sSiteUrl, sListId);
273
+ if (filter) {
274
+ oParams.$filter = String(filter);
275
+ }
276
+ if (orderBy) {
277
+ oParams.$orderby = String(orderBy);
278
+ }
279
+
280
+ const iTop = normalizeNumericQueryValue(top, "top");
281
+ const iSkip = normalizeNumericQueryValue(skip, "skip");
282
+ if (iTop != null) {
283
+ oParams.$top = iTop;
284
+ }
285
+ if (iSkip != null) {
286
+ oParams.$skip = iSkip;
287
+ }
288
+
289
+ return oParams;
290
+ }
291
+
292
+ function normalizeCollection(oPayload) {
293
+ if (Array.isArray(oPayload)) {
294
+ return oPayload;
295
+ }
296
+
297
+ const aCandidates = [
298
+ oPayload,
299
+ oPayload && oPayload.value,
300
+ oPayload && oPayload.items,
301
+ oPayload && oPayload.results,
302
+ oPayload && oPayload.body,
303
+ oPayload && oPayload.data,
304
+ oPayload && oPayload.result,
305
+ oPayload && oPayload.response,
306
+ oPayload && oPayload.d && oPayload.d.results,
307
+ ];
308
+
309
+ const aMatch = aCandidates.find(function(oCandidate) {
310
+ return Array.isArray(oCandidate);
311
+ });
312
+
313
+ return aMatch || [];
162
314
  }
163
315
 
164
316
  // ═══════════════════════════════════════════════════════════════
@@ -167,16 +319,20 @@ async function execOp(operationName, parameters) {
167
319
 
168
320
  // ── Call any SharePoint connector operation by name ─────────────
169
321
  export async function callSharePointOperation(operationName, parameters = {}) {
170
- return execOp(operationName, parameters);
322
+ return _dbgWrap('callSharePointOperation', [operationName, parameters], async function() {
323
+ return execSpOp(operationName, parameters);
324
+ });
171
325
  }
172
326
 
173
- // ── Send HTTP Request (for list-name-based operations) ─────────
174
- export async function sendHttpRequest({ method = "GET", uri, headers, body }) {
175
- return execOp("HttpRequest", {
176
- method,
177
- uri,
178
- headers: headers || {},
179
- body: body || "",
327
+ // ── Send HTTP Request (raw escape hatch) ───────────────────────
328
+ export async function sendHttpRequest({ method = "GET", uri, headers, body } = {}) {
329
+ return _dbgWrap('sendHttpRequest', [{ method, uri, headers, body }], async function() {
330
+ return execSpOp("HttpRequest", {
331
+ method: String(method || "GET").toUpperCase(),
332
+ uri: requireNonEmptyString(uri, "request URI"),
333
+ headers: normalizeHeaders(headers),
334
+ body: body == null ? "" : body,
335
+ });
180
336
  });
181
337
  }
182
338
 
@@ -186,106 +342,67 @@ export async function sendHttpRequest({ method = "GET", uri, headers, body }) {
186
342
 
187
343
  // ── Get Items ──────────────────────────────────────────────────
188
344
  export async function getItems(sSiteUrl, sListId, { filter, orderBy, top, skip } = {}) {
189
- let params = { siteUrl: encodeURIComponent(sSiteUrl), table: sListId };
190
- if (filter) params.$filter = filter;
191
- if (orderBy) params.$orderby = orderBy;
192
- if (top != null) params.$top = top;
193
- if (skip != null) params.$skip = skip;
194
- return execOp("GetItems", params);
345
+ return _dbgWrap('getItems', [sSiteUrl, sListId, { filter, orderBy, top, skip }], async function() {
346
+ return execSpOp("GetItems", buildItemQueryParameters(sSiteUrl, sListId, { filter, orderBy, top, skip }));
347
+ });
195
348
  }
196
349
 
197
350
  // ── Get Item ───────────────────────────────────────────────────
198
- export async function getItem(sSiteUrl, sListId, iItemId) {
199
- return execOp("GetItem", {
200
- siteUrl: encodeURIComponent(sSiteUrl),
201
- table: sListId,
202
- id: iItemId,
351
+ export async function getSpItem(sSiteUrl, sListId, iItemId) {
352
+ return _dbgWrap('getSpItem', [sSiteUrl, sListId, iItemId], async function() {
353
+ return execSpOp("GetItem", Object.assign(buildListContext(sSiteUrl, sListId), {
354
+ id: requireItemId(iItemId),
355
+ }));
203
356
  });
204
357
  }
205
358
 
206
359
  // ── Create Item ────────────────────────────────────────────────
207
- export async function createItem(sSiteUrl, sListId, oFields) {
208
- return execOp("PostItem", {
209
- siteUrl: encodeURIComponent(sSiteUrl),
210
- table: sListId,
211
- item: oFields,
360
+ export async function createSpItem(sSiteUrl, sListId, oFields) {
361
+ return _dbgWrap('createSpItem', [sSiteUrl, sListId, oFields], async function() {
362
+ return execSpOp("PostItem", Object.assign(buildListContext(sSiteUrl, sListId), {
363
+ item: requireRecord(oFields, "item payload"),
364
+ }));
212
365
  });
213
366
  }
214
367
 
215
368
  // ── Update Item ────────────────────────────────────────────────
216
- export async function updateItem(sSiteUrl, sListId, iItemId, oChangedFields) {
217
- return execOp("PatchItem", {
218
- siteUrl: encodeURIComponent(sSiteUrl),
219
- table: sListId,
220
- id: iItemId,
221
- item: oChangedFields,
369
+ export async function updateSpItem(sSiteUrl, sListId, iItemId, oChangedFields) {
370
+ return _dbgWrap('updateSpItem', [sSiteUrl, sListId, iItemId, oChangedFields], async function() {
371
+ return execSpOp("PatchItem", Object.assign(buildListContext(sSiteUrl, sListId), {
372
+ id: requireItemId(iItemId),
373
+ item: requireRecord(oChangedFields, "item payload"),
374
+ }));
222
375
  });
223
376
  }
224
377
 
225
378
  // ── Delete Item ────────────────────────────────────────────────
226
- export async function deleteItem(sSiteUrl, sListId, iItemId) {
227
- return execOp("DeleteItem", {
228
- siteUrl: encodeURIComponent(sSiteUrl),
229
- table: sListId,
230
- id: iItemId,
379
+ export async function deleteSpItem(sSiteUrl, sListId, iItemId) {
380
+ return _dbgWrap('deleteSpItem', [sSiteUrl, sListId, iItemId], async function() {
381
+ return execSpOp("DeleteItem", Object.assign(buildListContext(sSiteUrl, sListId), {
382
+ id: requireItemId(iItemId),
383
+ }));
231
384
  });
232
385
  }
233
386
 
234
- // ═══════════════════════════════════════════════════════════════
235
- // ITEMS (HTTP API — uses list name)
236
- // ═══════════════════════════════════════════════════════════════
237
-
238
- // ── Get Items by List Name ─────────────────────────────────────
239
- export async function getItemsByName(sSiteUrl, sListName, { filter, orderBy, top, skip } = {}) {
240
- let sUri = sSiteUrl + "/_api/web/lists/getbytitle('" + sListName + "')/items";
241
- let aQuery = [];
242
- if (filter) aQuery.push("$filter=" + filter);
243
- if (orderBy) aQuery.push("$orderby=" + orderBy);
244
- if (top != null) aQuery.push("$top=" + top);
245
- if (skip != null) aQuery.push("$skip=" + skip);
246
- if (aQuery.length > 0) sUri = sUri + "?" + aQuery.join("&");
247
- return sendHttpRequest({ method: "GET", uri: sUri, headers: { Accept: "application/json;odata=nometadata" } });
248
- }
249
-
250
- // ── Get Item by List Name ──────────────────────────────────────
251
- export async function getItemByName(sSiteUrl, sListName, iItemId) {
252
- let sUri = sSiteUrl + "/_api/web/lists/getbytitle('" + sListName + "')/items(" + iItemId + ")";
253
- return sendHttpRequest({ method: "GET", uri: sUri, headers: { Accept: "application/json;odata=nometadata" } });
254
- }
255
-
256
- // ── Create Item by List Name ───────────────────────────────────
257
- export async function createItemByName(sSiteUrl, sListName, oFields) {
258
- let sUri = sSiteUrl + "/_api/web/lists/getbytitle('" + sListName + "')/items";
259
- return sendHttpRequest({ method: "POST", uri: sUri, headers: { Accept: "application/json;odata=nometadata", "Content-Type": "application/json;odata=nometadata" }, body: JSON.stringify(oFields) });
260
- }
261
-
262
- // ── Update Item by List Name ───────────────────────────────────
263
- export async function updateItemByName(sSiteUrl, sListName, iItemId, oChangedFields) {
264
- let sUri = sSiteUrl + "/_api/web/lists/getbytitle('" + sListName + "')/items(" + iItemId + ")";
265
- return sendHttpRequest({ method: "PATCH", uri: sUri, headers: { Accept: "application/json;odata=nometadata", "Content-Type": "application/json;odata=nometadata", "If-Match": "*" }, body: JSON.stringify(oChangedFields) });
266
- }
267
-
268
- // ── Delete Item by List Name ───────────────────────────────────
269
- export async function deleteItemByName(sSiteUrl, sListName, iItemId) {
270
- let sUri = sSiteUrl + "/_api/web/lists/getbytitle('" + sListName + "')/items(" + iItemId + ")";
271
- return sendHttpRequest({ method: "DELETE", uri: sUri, headers: { Accept: "application/json;odata=nometadata", "If-Match": "*" } });
272
- }
273
-
274
387
  // ═══════════════════════════════════════════════════════════════
275
388
  // TABLES / LISTS
276
389
  // ═══════════════════════════════════════════════════════════════
277
390
 
278
391
  // ── List Tables (Lists) ────────────────────────────────────────
279
392
  export async function listTables(sSiteUrl) {
280
- return execOp("GetTables", {
281
- siteUrl: encodeURIComponent(sSiteUrl),
393
+ return _dbgWrap('listTables', [sSiteUrl], async function() {
394
+ return normalizeCollection(await execSpOp("GetTables", {
395
+ siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
396
+ }));
282
397
  });
283
398
  }
284
399
 
285
400
  // ── List Library (Document Libraries) ──────────────────────────
286
401
  export async function listLibrary(sSiteUrl) {
287
- return execOp("GetDataSetsMetadata", {
288
- siteUrl: encodeURIComponent(sSiteUrl),
402
+ return _dbgWrap('listLibrary', [sSiteUrl], async function() {
403
+ return execSpOp("GetDataSetsMetadata", {
404
+ siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
405
+ });
289
406
  });
290
407
  }
291
408
 
@@ -295,45 +412,55 @@ export async function listLibrary(sSiteUrl) {
295
412
 
296
413
  // ── Create File ────────────────────────────────────────────────
297
414
  export async function createFile(sSiteUrl, sLibraryName, sFileName, fileContent) {
298
- return execOp("CreateFile", {
299
- siteUrl: encodeURIComponent(sSiteUrl),
300
- folderPath: sLibraryName,
301
- name: sFileName,
415
+ return _dbgWrap('createFile', [sSiteUrl, sLibraryName, sFileName, fileContent], async function() {
416
+ return execSpOp("CreateFile", {
417
+ siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
418
+ folderPath: requireNonEmptyString(sLibraryName, "folder path"),
419
+ name: requireNonEmptyString(sFileName, "file name"),
302
420
  body: fileContent,
303
421
  });
422
+ });
304
423
  }
305
424
 
306
425
  // ── Update File ────────────────────────────────────────────────
307
426
  export async function updateFile(sSiteUrl, sFileId, fileContent) {
308
- return execOp("UpdateFile", {
309
- siteUrl: encodeURIComponent(sSiteUrl),
310
- id: sFileId,
427
+ return _dbgWrap('updateFile', [sSiteUrl, sFileId, fileContent], async function() {
428
+ return execSpOp("UpdateFile", {
429
+ siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
430
+ id: requireNonEmptyString(String(sFileId || ""), "file ID"),
311
431
  body: fileContent,
312
432
  });
433
+ });
313
434
  }
314
435
 
315
436
  // ── Delete File ────────────────────────────────────────────────
316
437
  export async function deleteFile(sSiteUrl, sFileId) {
317
- return execOp("DeleteFile", {
318
- siteUrl: encodeURIComponent(sSiteUrl),
319
- id: sFileId,
438
+ return _dbgWrap('deleteFile', [sSiteUrl, sFileId], async function() {
439
+ return execSpOp("DeleteFile", {
440
+ siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
441
+ id: requireNonEmptyString(String(sFileId || ""), "file ID"),
442
+ });
320
443
  });
321
444
  }
322
445
 
323
446
  // ── Move File ──────────────────────────────────────────────────
324
447
  export async function moveFile(sSiteUrl, sSourceFileId, sDestinationFolderPath, sNewFileName) {
325
- return execOp("MoveFile", {
326
- siteUrl: encodeURIComponent(sSiteUrl),
327
- id: sSourceFileId,
328
- destinationFolderPath: sDestinationFolderPath,
448
+ return _dbgWrap('moveFile', [sSiteUrl, sSourceFileId, sDestinationFolderPath, sNewFileName], async function() {
449
+ return execSpOp("MoveFile", {
450
+ siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
451
+ id: requireNonEmptyString(String(sSourceFileId || ""), "source file ID"),
452
+ destinationFolderPath: requireNonEmptyString(sDestinationFolderPath, "destination folder path"),
329
453
  newFileName: sNewFileName || "",
330
454
  });
455
+ });
331
456
  }
332
457
 
333
458
  // ── Get File Metadata ──────────────────────────────────────────
334
459
  export async function getFileMetadata(sSiteUrl, sFileId) {
335
- return execOp("GetFileMetadata", {
336
- siteUrl: encodeURIComponent(sSiteUrl),
337
- id: sFileId,
460
+ return _dbgWrap('getFileMetadata', [sSiteUrl, sFileId], async function() {
461
+ return execSpOp("GetFileMetadata", {
462
+ siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
463
+ id: requireNonEmptyString(String(sFileId || ""), "file ID"),
338
464
  });
339
- }
465
+ });
466
+ }