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
@@ -0,0 +1,642 @@
1
+ // ────────────────────────────────────────────────────────────────────────────
2
+ // ────────────────────────────── O365 Groups──────────────────────────────────
3
+ // ────────────────────────────────────────────────────────────────────────────
4
+ import { getClient } from "./power-apps-data.js";
5
+ import {_dbgWrap,unwrapResult } from "./codeapp.js";
6
+ // ── Data source names (must match connectionReferences in power.config.json) ──
7
+ const DATA_SOURCE_GROUPS_CANDIDATES = ["office365groups", "Office365Groups"];
8
+ const GROUPS_APIS = {
9
+ ListGroupMembers: {
10
+ path: "/{connectionId}/v1.0/groups/{groupId}/members",
11
+ method: "GET",
12
+ parameters: [
13
+ { name: "connectionId", in: "path", required: true, type: "string" },
14
+ { name: "groupId", in: "path", required: true, type: "string" },
15
+ { name: "$top", in: "query", required: false, type: "integer" },
16
+ ],
17
+ responseInfo: { 200: { type: "object" } },
18
+ },
19
+ OnGroupMembershipChange: {
20
+ path: "/{connectionId}/trigger/v1.0/groups/delta",
21
+ method: "GET",
22
+ parameters: [
23
+ { name: "connectionId", in: "path", required: true, type: "string" },
24
+ { name: "groupId", in: "query", required: true, type: "string" },
25
+ { name: "$select", in: "query", required: false, type: "string" },
26
+ ],
27
+ responseInfo: { 200: { type: "array" } },
28
+ },
29
+ AddMemberToGroup: {
30
+ path: "/{connectionId}/v1.0/groups/{groupId}/members/$ref",
31
+ method: "POST",
32
+ parameters: [
33
+ { name: "connectionId", in: "path", required: true, type: "string" },
34
+ { name: "groupId", in: "path", required: true, type: "string" },
35
+ { name: "userUpn", in: "query", required: true, type: "string" },
36
+ ],
37
+ responseInfo: { 204: { type: "void" } },
38
+ },
39
+ ListOwnedGroups: {
40
+ path: "/{connectionId}/v1.0/me/memberOf/$/microsoft.graph.group",
41
+ method: "GET",
42
+ parameters: [
43
+ { name: "connectionId", in: "path", required: true, type: "string" },
44
+ ],
45
+ responseInfo: { 200: { type: "object" } },
46
+ },
47
+ ListOwnedGroups_V2: {
48
+ path: "/{connectionId}/v1.0/me/ownedObjects/$/microsoft.graph.group",
49
+ method: "GET",
50
+ parameters: [
51
+ { name: "connectionId", in: "path", required: true, type: "string" },
52
+ { name: "extractSensitivityLabel", in: "query", required: false, type: "boolean" },
53
+ { name: "fetchSensitivityLabelMetadata", in: "query", required: false, type: "boolean" },
54
+ ],
55
+ responseInfo: { 200: { type: "object" } },
56
+ },
57
+ ListOwnedGroups_V3: {
58
+ path: "/{connectionId}/v2/v1.0/me/memberOf/$/microsoft.graph.group",
59
+ method: "GET",
60
+ parameters: [
61
+ { name: "connectionId", in: "path", required: true, type: "string" },
62
+ { name: "extractSensitivityLabel", in: "query", required: false, type: "boolean" },
63
+ { name: "fetchSensitivityLabelMetadata", in: "query", required: false, type: "boolean" },
64
+ ],
65
+ responseInfo: { 200: { type: "object" } },
66
+ },
67
+ ListGroups: {
68
+ path: "/{connectionId}/v1.0/groups",
69
+ method: "GET",
70
+ parameters: [
71
+ { name: "connectionId", in: "path", required: true, type: "string" },
72
+ { name: "extractSensitivityLabel", in: "query", required: false, type: "boolean" },
73
+ { name: "fetchSensitivityLabelMetadata", in: "query", required: false, type: "boolean" },
74
+ { name: "$filter", in: "query", required: false, type: "string" },
75
+ { name: "$top", in: "query", required: false, type: "integer" },
76
+ { name: "$skiptoken", in: "query", required: false, type: "string" },
77
+ ],
78
+ responseInfo: { 200: { type: "object" } },
79
+ },
80
+ CreateCalendarEvent: {
81
+ path: "/{connectionId}/v1.0/groups/{groupId}/events",
82
+ method: "POST",
83
+ parameters: [
84
+ { name: "connectionId", in: "path", required: true, type: "string" },
85
+ { name: "groupId", in: "path", required: true, type: "string" },
86
+ { name: "body", in: "body", required: true, type: "object" },
87
+ ],
88
+ responseInfo: { 201: { type: "object" } },
89
+ },
90
+ CreateCalendarEventV2: {
91
+ path: "/{connectionId}/v2/v1.0/groups/{groupId}/events",
92
+ method: "POST",
93
+ parameters: [
94
+ { name: "connectionId", in: "path", required: true, type: "string" },
95
+ { name: "groupId", in: "path", required: true, type: "string" },
96
+ { name: "body", in: "body", required: true, type: "object" },
97
+ ],
98
+ responseInfo: { 201: { type: "object" } },
99
+ },
100
+ CalendarDeleteItem_V2: {
101
+ path: "/{connectionId}/v1.0/groups/{groupId}/events/{event}",
102
+ method: "DELETE",
103
+ parameters: [
104
+ { name: "connectionId", in: "path", required: true, type: "string" },
105
+ { name: "groupId", in: "path", required: true, type: "string" },
106
+ { name: "event", in: "path", required: true, type: "string" },
107
+ ],
108
+ responseInfo: { 204: { type: "void" }, default: { type: "void" } },
109
+ },
110
+ UpdateCalendarEvent: {
111
+ path: "/{connectionId}/v1.0/groups/{groupId}/events/{event}",
112
+ method: "PATCH",
113
+ parameters: [
114
+ { name: "connectionId", in: "path", required: true, type: "string" },
115
+ { name: "groupId", in: "path", required: true, type: "string" },
116
+ { name: "event", in: "path", required: true, type: "string" },
117
+ { name: "body", in: "body", required: true, type: "object" },
118
+ ],
119
+ responseInfo: { 200: { type: "object" } },
120
+ },
121
+ RemoveMemberFromGroup: {
122
+ path: "/{connectionId}/v1.0/groups/{groupId}/members/memberId/$ref",
123
+ method: "DELETE",
124
+ parameters: [
125
+ { name: "connectionId", in: "path", required: true, type: "string" },
126
+ { name: "groupId", in: "path", required: true, type: "string" },
127
+ { name: "userUpn", in: "query", required: true, type: "string" },
128
+ ],
129
+ responseInfo: { 204: { type: "void" } },
130
+ },
131
+ OnNewEvent: {
132
+ path: "/{connectionId}/trigger/v1.0/groups/{groupId}/events",
133
+ method: "GET",
134
+ parameters: [
135
+ { name: "connectionId", in: "path", required: true, type: "string" },
136
+ { name: "groupId", in: "path", required: true, type: "string" },
137
+ ],
138
+ responseInfo: { 200: { type: "array" } },
139
+ },
140
+ HttpRequestV2: {
141
+ path: "/{connectionId}/v2/httprequest",
142
+ method: "POST",
143
+ parameters: [
144
+ { name: "connectionId", in: "path", required: true, type: "string" },
145
+ { name: "Uri", in: "header", required: true, type: "string" },
146
+ { name: "Method", in: "header", required: true, type: "string" },
147
+ { name: "Body", in: "body", required: false, type: "object" },
148
+ { name: "ContentType", in: "header", required: false, type: "string" },
149
+ { name: "CustomHeader1", in: "header", required: false, type: "string" },
150
+ { name: "CustomHeader2", in: "header", required: false, type: "string" },
151
+ { name: "CustomHeader3", in: "header", required: false, type: "string" },
152
+ { name: "CustomHeader4", in: "header", required: false, type: "string" },
153
+ { name: "CustomHeader5", in: "header", required: false, type: "string" },
154
+ ],
155
+ responseInfo: { 200: { type: "object" }, default: { type: "void" } },
156
+ },
157
+ HttpRequest: {
158
+ path: "/{connectionId}/httprequest",
159
+ method: "POST",
160
+ parameters: [
161
+ { name: "connectionId", in: "path", required: true, type: "string" },
162
+ { name: "Uri", in: "header", required: true, type: "string" },
163
+ { name: "Method", in: "header", required: true, type: "string" },
164
+ { name: "Body", in: "body", required: false, type: "object" },
165
+ { name: "ContentType", in: "header", required: false, type: "string" },
166
+ { name: "CustomHeader1", in: "header", required: false, type: "string" },
167
+ { name: "CustomHeader2", in: "header", required: false, type: "string" },
168
+ { name: "CustomHeader3", in: "header", required: false, type: "string" },
169
+ { name: "CustomHeader4", in: "header", required: false, type: "string" },
170
+ { name: "CustomHeader5", in: "header", required: false, type: "string" },
171
+ ],
172
+ responseInfo: { 200: { type: "object" }, default: { type: "void" } },
173
+ },
174
+ ListDeletedGroups: {
175
+ path: "/{connectionId}/v1.0/directory/deletedItems/microsoft.graph.group",
176
+ method: "GET",
177
+ parameters: [
178
+ { name: "connectionId", in: "path", required: true, type: "string" },
179
+ ],
180
+ responseInfo: { 200: { type: "object" } },
181
+ },
182
+ RestoreDeletedGroup: {
183
+ path: "/{connectionId}/v1.0/directory/deletedItems/{groupId}/restore",
184
+ method: "POST",
185
+ parameters: [
186
+ { name: "connectionId", in: "path", required: true, type: "string" },
187
+ { name: "groupId", in: "path", required: true, type: "string" },
188
+ ],
189
+ responseInfo: { 200: { type: "void" } },
190
+ },
191
+ ListDeletedGroupsByOwner: {
192
+ path: "/{connectionId}/v1.0/directory/deletedItems/getUserOwnedObjects",
193
+ method: "POST",
194
+ parameters: [
195
+ { name: "connectionId", in: "path", required: true, type: "string" },
196
+ { name: "userId", in: "header", required: true, type: "string" },
197
+ ],
198
+ responseInfo: { 200: { type: "object" } },
199
+ },
200
+ };
201
+
202
+ function initGroupsClient() {
203
+ const dataSourcesInfo = {};
204
+
205
+ DATA_SOURCE_GROUPS_CANDIDATES.forEach(function(sDataSourceName) {
206
+ dataSourcesInfo[sDataSourceName] = {
207
+ tableId: "",
208
+ version: "",
209
+ primaryKey: "",
210
+ dataSourceType: "Connector",
211
+ apis: GROUPS_APIS,
212
+ };
213
+ });
214
+
215
+ return getClient(dataSourcesInfo);
216
+ }
217
+
218
+ function isGroupsObject(oValue) {
219
+ return !!oValue && typeof oValue === "object" && !Array.isArray(oValue);
220
+ }
221
+
222
+ function pickGroupsValue() {
223
+ for (let iIndex = 0; iIndex < arguments.length; iIndex += 1) {
224
+ const oValue = arguments[iIndex];
225
+ if (oValue !== undefined && oValue !== null) return oValue;
226
+ }
227
+ return undefined;
228
+ }
229
+
230
+ function setGroupsIfDefined(oTarget, sKey, oValue) {
231
+ if (oValue !== undefined && oValue !== null) {
232
+ oTarget[sKey] = oValue;
233
+ }
234
+ }
235
+
236
+ function stringifyGroupsError(oError) {
237
+ if (!oError) return "Unknown error";
238
+ if (typeof oError === "string") return oError;
239
+ if (typeof oError.message === "string" && oError.message) return oError.message;
240
+
241
+ try {
242
+ return JSON.stringify(oError);
243
+ } catch (oErr) {
244
+ return String(oError);
245
+ }
246
+ }
247
+
248
+ function normalizeGroupsSelect(oValue) {
249
+ if (Array.isArray(oValue)) return oValue.join(",");
250
+ return oValue;
251
+ }
252
+
253
+ function extractGroupsSkipToken(sNextLink) {
254
+ if (!sNextLink || typeof sNextLink !== "string") return undefined;
255
+
256
+ try {
257
+ const oUrl = new URL(sNextLink);
258
+ return pickGroupsValue(
259
+ oUrl.searchParams.get("$skiptoken"),
260
+ oUrl.searchParams.get("$skipToken"),
261
+ oUrl.searchParams.get("skiptoken"),
262
+ oUrl.searchParams.get("skipToken")
263
+ );
264
+ } catch (oError) {
265
+ return undefined;
266
+ }
267
+ }
268
+
269
+ function getGroupsHeaderValue(oHeaders, sName) {
270
+ if (!isGroupsObject(oHeaders)) return undefined;
271
+
272
+ const sMatch = String(sName).toLowerCase();
273
+ const aEntries = Object.entries(oHeaders);
274
+ for (let iIndex = 0; iIndex < aEntries.length; iIndex += 1) {
275
+ const [sHeaderName, oValue] = aEntries[iIndex];
276
+ if (String(sHeaderName).toLowerCase() === sMatch) {
277
+ return oValue;
278
+ }
279
+ }
280
+
281
+ return undefined;
282
+ }
283
+
284
+ function normalizeGroupsCustomHeaders(oHeaders, aCustomHeaders) {
285
+ const aResolved = Array.isArray(aCustomHeaders) ? aCustomHeaders.filter((oValue) => oValue != null) : [];
286
+
287
+ if (!isGroupsObject(oHeaders)) return aResolved.slice(0, 5);
288
+
289
+ const aEntries = Object.entries(oHeaders);
290
+ for (let iIndex = 0; iIndex < aEntries.length; iIndex += 1) {
291
+ const [sHeaderName, oValue] = aEntries[iIndex];
292
+ if (oValue === undefined || oValue === null) continue;
293
+ if (String(sHeaderName).toLowerCase() === "content-type") continue;
294
+ aResolved.push(String(sHeaderName) + ": " + String(oValue));
295
+ if (aResolved.length >= 5) break;
296
+ }
297
+
298
+ return aResolved.slice(0, 5);
299
+ }
300
+
301
+ function normalizeGroupsStartEnd(oSource, sKey) {
302
+ const oValue = pickGroupsValue(oSource[sKey], oSource[sKey.charAt(0).toUpperCase() + sKey.slice(1)]);
303
+
304
+ if (isGroupsObject(oValue)) {
305
+ return {
306
+ dateTime: pickGroupsValue(oValue.dateTime, oValue.DateTime),
307
+ timeZone: pickGroupsValue(oValue.timeZone, oValue.TimeZone, oSource.timeZone, oSource.TimeZone, oSource.timezone),
308
+ };
309
+ }
310
+
311
+ const sDateTime = pickGroupsValue(
312
+ oSource[sKey + "DateTime"],
313
+ oSource[sKey + "At"],
314
+ oSource[sKey],
315
+ oSource[sKey.charAt(0).toUpperCase() + sKey.slice(1) + "DateTime"],
316
+ oSource[sKey.charAt(0).toUpperCase() + sKey.slice(1) + "At"]
317
+ );
318
+
319
+ if (sDateTime === undefined || sDateTime === null) return undefined;
320
+
321
+ return {
322
+ dateTime: sDateTime,
323
+ timeZone: pickGroupsValue(oSource.timeZone, oSource.TimeZone, oSource.timezone),
324
+ };
325
+ }
326
+
327
+ function normalizeGroupsEventBody(oSource) {
328
+ const oBodySource = isGroupsObject(oSource.body) ? oSource.body : (isGroupsObject(oSource.Body) ? oSource.Body : null);
329
+
330
+ if (oBodySource) {
331
+ const oBody = {};
332
+ setGroupsIfDefined(oBody, "content", pickGroupsValue(oBodySource.content, oBodySource.Content, oBodySource.body, oBodySource.Body));
333
+ setGroupsIfDefined(oBody, "contentType", pickGroupsValue(oBodySource.contentType, oBodySource.ContentType, oSource.contentType, oSource.ContentType, oSource.isHtml === false ? "Text" : undefined));
334
+ return Object.keys(oBody).length > 0 ? oBody : undefined;
335
+ }
336
+
337
+ const sContent = pickGroupsValue(oSource.bodyContent, oSource.description, oSource.content);
338
+ if (sContent === undefined || sContent === null) return undefined;
339
+
340
+ return {
341
+ content: sContent,
342
+ contentType: pickGroupsValue(oSource.contentType, oSource.ContentType, oSource.isHtml === false ? "Text" : "Html"),
343
+ };
344
+ }
345
+
346
+ function normalizeGroupsEventLocation(oSource) {
347
+ const oLocation = pickGroupsValue(oSource.location, oSource.Location);
348
+ if (typeof oLocation === "string") {
349
+ return { displayName: oLocation };
350
+ }
351
+
352
+ if (isGroupsObject(oLocation)) {
353
+ return { displayName: pickGroupsValue(oLocation.displayName, oLocation.DisplayName) };
354
+ }
355
+
356
+ return undefined;
357
+ }
358
+
359
+ function normalizeGroupsEventPayload(oOptions) {
360
+ const oSource = isGroupsObject(oOptions && oOptions.body) && pickGroupsValue(oOptions.body.subject, oOptions.body.Subject, oOptions.body.start, oOptions.body.Start)
361
+ ? oOptions.body
362
+ : (isGroupsObject(oOptions) ? oOptions : {});
363
+
364
+ const oPayload = {};
365
+ setGroupsIfDefined(oPayload, "subject", pickGroupsValue(oSource.subject, oSource.Subject, oSource.title));
366
+ setGroupsIfDefined(oPayload, "start", normalizeGroupsStartEnd(oSource, "start"));
367
+ setGroupsIfDefined(oPayload, "end", normalizeGroupsStartEnd(oSource, "end"));
368
+ setGroupsIfDefined(oPayload, "body", normalizeGroupsEventBody(oSource));
369
+ setGroupsIfDefined(oPayload, "location", normalizeGroupsEventLocation(oSource));
370
+ setGroupsIfDefined(oPayload, "importance", pickGroupsValue(oSource.importance, oSource.Importance));
371
+ setGroupsIfDefined(oPayload, "isAllDay", pickGroupsValue(oSource.isAllDay, oSource.IsAllDay));
372
+ setGroupsIfDefined(oPayload, "isReminderOn", pickGroupsValue(oSource.isReminderOn, oSource.IsReminderOn));
373
+ setGroupsIfDefined(oPayload, "reminderMinutesBeforeStart", pickGroupsValue(oSource.reminderMinutesBeforeStart, oSource.ReminderMinutesBeforeStart, oSource.reminderMinutes, oSource.reminder));
374
+ setGroupsIfDefined(oPayload, "showAs", pickGroupsValue(oSource.showAs, oSource.ShowAs));
375
+ setGroupsIfDefined(oPayload, "responseRequested", pickGroupsValue(oSource.responseRequested, oSource.ResponseRequested));
376
+ return oPayload;
377
+ }
378
+
379
+ // ── Internal: execute a connector operation ────────────────────
380
+ async function execGroupsOp(operationName, parameters) {
381
+ if (!Object.prototype.hasOwnProperty.call(GROUPS_APIS, operationName)) {
382
+ throw new Error("Office 365 Groups operation metadata is not registered for: " + operationName);
383
+ }
384
+
385
+ const client = await initGroupsClient();
386
+ const aErrors = [];
387
+
388
+ for (let iIndex = 0; iIndex < DATA_SOURCE_GROUPS_CANDIDATES.length; iIndex += 1) {
389
+ const sDataSourceName = DATA_SOURCE_GROUPS_CANDIDATES[iIndex];
390
+
391
+ try {
392
+ const result = await client.executeAsync({
393
+ connectorOperation: {
394
+ tableName: sDataSourceName,
395
+ operationName,
396
+ parameters,
397
+ },
398
+ });
399
+
400
+ return unwrapResult(result);
401
+ } catch (oErr) {
402
+ const sMessage = stringifyGroupsError(oErr);
403
+ aErrors.push(sDataSourceName + ": " + sMessage);
404
+
405
+ if (sMessage.indexOf("Connection reference not found") === -1) {
406
+ throw oErr;
407
+ }
408
+ }
409
+ }
410
+
411
+ throw new Error("No Office 365 Groups connection reference matched. Tried: " + aErrors.join(" || "));
412
+ }
413
+
414
+ // ═══════════════════════════════════════════════════════════════
415
+ // GENERIC
416
+ // ═══════════════════════════════════════════════════════════════
417
+
418
+ // ── Call any Office 365 Groups operation by name ───────────────
419
+ export async function callGroupsOperation(operationName, parameters = {}) {
420
+ return _dbgWrap('callGroupsOperation', [operationName, parameters], async function() {
421
+ return execGroupsOp(operationName, parameters);
422
+ });
423
+ }
424
+
425
+ // ── Open HTTP Request ──────────────────────────────────────────
426
+ export async function openGroupsHttpRequest({ method = "GET", uri, headers, body, contentType, customHeaders, version, useV2, operationName } = {}) {
427
+ return _dbgWrap('openGroupsHttpRequest', [{ method, uri, headers, body, contentType, customHeaders, version, useV2, operationName }], async function() {
428
+ const aHeaders = normalizeGroupsCustomHeaders(headers, customHeaders);
429
+ const sOperationName = operationName || (pickGroupsValue(version, useV2 ? 2 : undefined) === 2 ? "HttpRequestV2" : "HttpRequest");
430
+ return execGroupsOp(sOperationName, {
431
+ Uri: uri,
432
+ Method: method,
433
+ Body: body,
434
+ ContentType: pickGroupsValue(contentType, getGroupsHeaderValue(headers, "Content-Type")),
435
+ CustomHeader1: aHeaders[0],
436
+ CustomHeader2: aHeaders[1],
437
+ CustomHeader3: aHeaders[2],
438
+ CustomHeader4: aHeaders[3],
439
+ CustomHeader5: aHeaders[4],
440
+ });
441
+ });
442
+ }
443
+
444
+ // ═══════════════════════════════════════════════════════════════
445
+ // GROUPS
446
+ // ═══════════════════════════════════════════════════════════════
447
+
448
+ // ── List My Groups ─────────────────────────────────────────────
449
+ export async function listMyGroups(oOptions = {}) {
450
+ return _dbgWrap('listMyGroups', [oOptions], async function() {
451
+ if (!isGroupsObject(oOptions)) {
452
+ oOptions = {};
453
+ }
454
+
455
+ const iVersion = pickGroupsValue(oOptions.version, oOptions.v, 1);
456
+ const sOperationName = iVersion === 3 ? "ListOwnedGroups_V3" : (iVersion === 2 ? "ListOwnedGroups_V2" : "ListOwnedGroups");
457
+ const params = {};
458
+ setGroupsIfDefined(params, "extractSensitivityLabel", oOptions.extractSensitivityLabel);
459
+ setGroupsIfDefined(params, "fetchSensitivityLabelMetadata", oOptions.fetchSensitivityLabelMetadata);
460
+ return execGroupsOp(sOperationName, params);
461
+ });
462
+ }
463
+
464
+ // ── List Members of a Group ────────────────────────────────────
465
+ export async function listGroupMembers(groupId, oOptions) {
466
+ return _dbgWrap('listGroupMembers', [groupId, oOptions], async function() {
467
+ if (isGroupsObject(groupId)) {
468
+ oOptions = groupId;
469
+ groupId = pickGroupsValue(oOptions.groupId, oOptions.id);
470
+ }
471
+
472
+ oOptions = isGroupsObject(oOptions) ? oOptions : {};
473
+ const params = { groupId };
474
+ setGroupsIfDefined(params, "$top", pickGroupsValue(oOptions.top, oOptions.$top));
475
+ return execGroupsOp("ListGroupMembers", params);
476
+ });
477
+ }
478
+
479
+ export async function listOwnedGroups(oOptions = {}) {
480
+ return _dbgWrap('listOwnedGroups', [oOptions], async function() {
481
+ return listMyGroups(oOptions);
482
+ });
483
+ }
484
+
485
+ export async function listGroups(oOptions = {}) {
486
+ return _dbgWrap('listGroups', [oOptions], async function() {
487
+ oOptions = isGroupsObject(oOptions) ? oOptions : {};
488
+ const params = {};
489
+ setGroupsIfDefined(params, "extractSensitivityLabel", oOptions.extractSensitivityLabel);
490
+ setGroupsIfDefined(params, "fetchSensitivityLabelMetadata", oOptions.fetchSensitivityLabelMetadata);
491
+ setGroupsIfDefined(params, "$filter", pickGroupsValue(oOptions.filter, oOptions.$filter));
492
+ setGroupsIfDefined(params, "$top", pickGroupsValue(oOptions.top, oOptions.$top));
493
+
494
+ const oSkipToken = pickGroupsValue(
495
+ oOptions.skipToken,
496
+ oOptions.$skipToken,
497
+ oOptions.$skiptoken,
498
+ extractGroupsSkipToken(oOptions.nextLink),
499
+ oOptions.skip
500
+ );
501
+
502
+ if (oSkipToken !== undefined && oSkipToken !== null) {
503
+ params.$skiptoken = String(oSkipToken);
504
+ }
505
+
506
+ return execGroupsOp("ListGroups", params);
507
+ });
508
+ }
509
+
510
+ export async function onGroupMembershipChange(groupId, oOptions = {}) {
511
+ return _dbgWrap('onGroupMembershipChange', [groupId, oOptions], async function() {
512
+ if (isGroupsObject(groupId)) {
513
+ oOptions = groupId;
514
+ groupId = pickGroupsValue(oOptions.groupId, oOptions.id);
515
+ }
516
+
517
+ oOptions = isGroupsObject(oOptions) ? oOptions : {};
518
+ return execGroupsOp("OnGroupMembershipChange", {
519
+ groupId,
520
+ $select: normalizeGroupsSelect(pickGroupsValue(oOptions.select, oOptions.$select)),
521
+ });
522
+ });
523
+ }
524
+
525
+ export async function addMemberToGroup(userUpn, groupId) {
526
+ return _dbgWrap('addMemberToGroup', [userUpn, groupId], async function() {
527
+ if (isGroupsObject(userUpn)) {
528
+ groupId = pickGroupsValue(userUpn.groupId, userUpn.id);
529
+ userUpn = pickGroupsValue(userUpn.userUpn, userUpn.upn, userUpn.userPrincipalName, userUpn.email, userUpn.mail);
530
+ }
531
+
532
+ return execGroupsOp("AddMemberToGroup", {
533
+ userUpn,
534
+ groupId,
535
+ });
536
+ });
537
+ }
538
+
539
+ export async function removeMemberFromGroup(userUpn, groupId) {
540
+ return _dbgWrap('removeMemberFromGroup', [userUpn, groupId], async function() {
541
+ if (isGroupsObject(userUpn)) {
542
+ groupId = pickGroupsValue(userUpn.groupId, userUpn.id);
543
+ userUpn = pickGroupsValue(userUpn.userUpn, userUpn.upn, userUpn.userPrincipalName, userUpn.email, userUpn.mail);
544
+ }
545
+
546
+ return execGroupsOp("RemoveMemberFromGroup", {
547
+ userUpn,
548
+ groupId,
549
+ });
550
+ });
551
+ }
552
+
553
+ export async function createGroupEvent(groupId, oBodyOrOptions) {
554
+ return _dbgWrap('createGroupEvent', [groupId, oBodyOrOptions], async function() {
555
+ let oOptions = isGroupsObject(oBodyOrOptions) ? oBodyOrOptions : {};
556
+
557
+ if (isGroupsObject(groupId)) {
558
+ oOptions = groupId;
559
+ groupId = pickGroupsValue(oOptions.groupId, oOptions.id);
560
+ }
561
+
562
+ const iVersion = pickGroupsValue(oOptions.version, oOptions.v, 2);
563
+ return execGroupsOp(iVersion === 1 ? "CreateCalendarEvent" : "CreateCalendarEventV2", {
564
+ groupId,
565
+ body: normalizeGroupsEventPayload(oOptions),
566
+ });
567
+ });
568
+ }
569
+
570
+ export async function updateGroupEvent(sEventId, oBodyOrOptions, sGroupId) {
571
+ return _dbgWrap('updateGroupEvent', [sEventId, oBodyOrOptions, sGroupId], async function() {
572
+ let oOptions = isGroupsObject(oBodyOrOptions) ? oBodyOrOptions : {};
573
+
574
+ if (isGroupsObject(sEventId)) {
575
+ oOptions = sEventId;
576
+ sEventId = pickGroupsValue(oOptions.eventId, oOptions.id, oOptions.event);
577
+ sGroupId = pickGroupsValue(oOptions.groupId, oOptions.group, oOptions.ownerGroupId);
578
+ }
579
+
580
+ return execGroupsOp("UpdateCalendarEvent", {
581
+ event: sEventId,
582
+ groupId: pickGroupsValue(oOptions.groupId, sGroupId),
583
+ body: normalizeGroupsEventPayload(oOptions),
584
+ });
585
+ });
586
+ }
587
+
588
+ export async function deleteGroupEvent(sEventId, sGroupId) {
589
+ return _dbgWrap('deleteGroupEvent', [sEventId, sGroupId], async function() {
590
+ if (isGroupsObject(sEventId)) {
591
+ sGroupId = pickGroupsValue(sEventId.groupId, sEventId.group, sEventId.ownerGroupId);
592
+ sEventId = pickGroupsValue(sEventId.eventId, sEventId.id, sEventId.event);
593
+ }
594
+
595
+ return execGroupsOp("CalendarDeleteItem_V2", {
596
+ event: sEventId,
597
+ groupId: sGroupId,
598
+ });
599
+ });
600
+ }
601
+
602
+ export async function onNewGroupEvent(groupId) {
603
+ return _dbgWrap('onNewGroupEvent', [groupId], async function() {
604
+ if (isGroupsObject(groupId)) {
605
+ groupId = pickGroupsValue(groupId.groupId, groupId.id);
606
+ }
607
+
608
+ return execGroupsOp("OnNewEvent", {
609
+ groupId,
610
+ });
611
+ });
612
+ }
613
+
614
+ export async function listDeletedGroups() {
615
+ return _dbgWrap('listDeletedGroups', [], async function() {
616
+ return execGroupsOp("ListDeletedGroups", {});
617
+ });
618
+ }
619
+
620
+ export async function restoreDeletedGroup(groupId) {
621
+ return _dbgWrap('restoreDeletedGroup', [groupId], async function() {
622
+ if (isGroupsObject(groupId)) {
623
+ groupId = pickGroupsValue(groupId.groupId, groupId.id);
624
+ }
625
+
626
+ return execGroupsOp("RestoreDeletedGroup", {
627
+ groupId,
628
+ });
629
+ });
630
+ }
631
+
632
+ export async function listDeletedGroupsByOwner(userId) {
633
+ return _dbgWrap('listDeletedGroupsByOwner', [userId], async function() {
634
+ if (isGroupsObject(userId)) {
635
+ userId = pickGroupsValue(userId.userId, userId.id, userId.ownerId);
636
+ }
637
+
638
+ return execGroupsOp("ListDeletedGroupsByOwner", {
639
+ userId,
640
+ });
641
+ });
642
+ }