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,97 +1,97 @@
1
- import { getClient } from "@microsoft/power-apps/data";
2
-
3
- // ── Data source name (must match the generated connector data source name) ──
4
- const DATA_SOURCE = "office365groups";
5
-
6
- const GROUPS_APIS = {
7
- ListOwnedGroups: {
8
- path: "/{connectionId}/v1.0/me/memberOf/$/microsoft.graph.group",
9
- method: "GET",
10
- parameters: [
11
- { name: "connectionId", in: "path", required: true },
12
- ],
13
- },
14
- ListGroupMembers: {
15
- path: "/{connectionId}/v1.0/groups/{groupId}/members",
16
- method: "GET",
17
- parameters: [
18
- { name: "connectionId", in: "path", required: true },
19
- { name: "groupId", in: "path", required: true },
20
- { name: "$top", in: "query", required: false },
21
- ],
22
- },
23
- HttpRequest: {
24
- path: "/{connectionId}/httprequest",
25
- method: "POST",
26
- parameters: [
27
- { name: "connectionId", in: "path", required: true },
28
- ],
29
- },
30
- };
31
-
32
- // ── Initialize SDK client for the Office 365 Groups connector ──
33
- function initClient() {
34
- const dataSourcesInfo = {
35
- [DATA_SOURCE]: {
36
- tableId: "",
37
- version: "",
38
- primaryKey: "",
39
- dataSourceType: "Connector",
40
- apis: GROUPS_APIS,
41
- },
42
- };
43
- return getClient(dataSourcesInfo);
44
- }
45
-
46
- // ── Internal: execute a connector operation ────────────────────
47
- async function execOp(operationName, parameters) {
48
- const client = await initClient();
49
- const result = await client.executeAsync({
50
- connectorOperation: {
51
- tableName: DATA_SOURCE,
52
- operationName,
53
- parameters,
54
- },
55
- });
56
-
57
- if (!result.success) {
58
- throw new Error(result.error?.message || "Operation failed");
59
- }
60
-
61
- return Object.prototype.hasOwnProperty.call(result, "data") ? result.data : result;
62
- }
63
-
64
- // ═══════════════════════════════════════════════════════════════
65
- // GENERIC
66
- // ═══════════════════════════════════════════════════════════════
67
-
68
- // ── Call any Office 365 Groups operation by name ───────────────
69
- export async function callGroupsOperation(operationName, parameters = {}) {
70
- return execOp(operationName, parameters);
71
- }
72
-
73
- // ── Open HTTP Request ──────────────────────────────────────────
74
- export async function openHttpRequest({ method = "GET", uri, headers, body }) {
75
- return execOp("HttpRequest", {
76
- method,
77
- uri,
78
- headers: headers || {},
79
- body: body || "",
80
- });
81
- }
82
-
83
- // ═══════════════════════════════════════════════════════════════
84
- // GROUPS
85
- // ═══════════════════════════════════════════════════════════════
86
-
87
- // ── List My Groups ─────────────────────────────────────────────
88
- export async function listMyGroups() {
89
- return execOp("ListOwnedGroups", {});
90
- }
91
-
92
- // ── List Members of a Group ────────────────────────────────────
93
- export async function listGroupMembers(groupId) {
94
- return execOp("ListGroupMembers", {
95
- groupId,
96
- });
97
- }
1
+ import { getClient } from "@microsoft/power-apps/data";
2
+
3
+ // ── Data source name (must match the generated connector data source name) ──
4
+ const DATA_SOURCE = "office365groups";
5
+
6
+ const GROUPS_APIS = {
7
+ ListOwnedGroups: {
8
+ path: "/{connectionId}/v1.0/me/memberOf/$/microsoft.graph.group",
9
+ method: "GET",
10
+ parameters: [
11
+ { name: "connectionId", in: "path", required: true },
12
+ ],
13
+ },
14
+ ListGroupMembers: {
15
+ path: "/{connectionId}/v1.0/groups/{groupId}/members",
16
+ method: "GET",
17
+ parameters: [
18
+ { name: "connectionId", in: "path", required: true },
19
+ { name: "groupId", in: "path", required: true },
20
+ { name: "$top", in: "query", required: false },
21
+ ],
22
+ },
23
+ HttpRequest: {
24
+ path: "/{connectionId}/httprequest",
25
+ method: "POST",
26
+ parameters: [
27
+ { name: "connectionId", in: "path", required: true },
28
+ ],
29
+ },
30
+ };
31
+
32
+ // ── Initialize SDK client for the Office 365 Groups connector ──
33
+ function initClient() {
34
+ const dataSourcesInfo = {
35
+ [DATA_SOURCE]: {
36
+ tableId: "",
37
+ version: "",
38
+ primaryKey: "",
39
+ dataSourceType: "Connector",
40
+ apis: GROUPS_APIS,
41
+ },
42
+ };
43
+ return getClient(dataSourcesInfo);
44
+ }
45
+
46
+ // ── Internal: execute a connector operation ────────────────────
47
+ async function execOp(operationName, parameters) {
48
+ const client = await initClient();
49
+ const result = await client.executeAsync({
50
+ connectorOperation: {
51
+ tableName: DATA_SOURCE,
52
+ operationName,
53
+ parameters,
54
+ },
55
+ });
56
+
57
+ if (!result.success) {
58
+ throw new Error(result.error?.message || "Operation failed");
59
+ }
60
+
61
+ return Object.prototype.hasOwnProperty.call(result, "data") ? result.data : result;
62
+ }
63
+
64
+ // ═══════════════════════════════════════════════════════════════
65
+ // GENERIC
66
+ // ═══════════════════════════════════════════════════════════════
67
+
68
+ // ── Call any Office 365 Groups operation by name ───────────────
69
+ export async function callGroupsOperation(operationName, parameters = {}) {
70
+ return execOp(operationName, parameters);
71
+ }
72
+
73
+ // ── Open HTTP Request ──────────────────────────────────────────
74
+ export async function openHttpRequest({ method = "GET", uri, headers, body }) {
75
+ return execOp("HttpRequest", {
76
+ method,
77
+ uri,
78
+ headers: headers || {},
79
+ body: body || "",
80
+ });
81
+ }
82
+
83
+ // ═══════════════════════════════════════════════════════════════
84
+ // GROUPS
85
+ // ═══════════════════════════════════════════════════════════════
86
+
87
+ // ── List My Groups ─────────────────────────────────────────────
88
+ export async function listMyGroups() {
89
+ return execOp("ListOwnedGroups", {});
90
+ }
91
+
92
+ // ── List Members of a Group ────────────────────────────────────
93
+ export async function listGroupMembers(groupId) {
94
+ return execOp("ListGroupMembers", {
95
+ groupId,
96
+ });
97
+ }
@@ -0,0 +1,451 @@
1
+ import { getClient } from "@microsoft/power-apps/data";
2
+
3
+ // ── Data source name (must match connectionReferences in power.config.json) ──
4
+ const DATA_SOURCE = "office365users";
5
+
6
+ const USERS_APIS = {
7
+ UpdateMyProfile: {
8
+ path: "/{connectionId}/codeless/v1.0/me",
9
+ method: "PATCH",
10
+ parameters: [
11
+ { name: "connectionId", in: "path", required: true },
12
+ { name: "body", in: "body", required: false },
13
+ ],
14
+ },
15
+ MyProfile_V2: {
16
+ path: "/{connectionId}/codeless/v1.0/me",
17
+ method: "GET",
18
+ parameters: [
19
+ { name: "connectionId", in: "path", required: true },
20
+ { name: "$select", in: "query", required: false },
21
+ ],
22
+ },
23
+ UpdateMyPhoto: {
24
+ path: "/{connectionId}/codeless/v1.0/me/photo/$value",
25
+ method: "PUT",
26
+ parameters: [
27
+ { name: "connectionId", in: "path", required: true },
28
+ { name: "body", in: "body", required: true },
29
+ { name: "Content_Type", in: "header", required: true },
30
+ ],
31
+ },
32
+ MyTrendingDocuments: {
33
+ path: "/{connectionId}/codeless/v1.0/me/insights/trending",
34
+ method: "GET",
35
+ parameters: [
36
+ { name: "connectionId", in: "path", required: true },
37
+ { name: "$filter", in: "query", required: false },
38
+ { name: "extractSensitivityLabel", in: "query", required: false },
39
+ { name: "fetchSensitivityLabelMetadata", in: "query", required: false },
40
+ ],
41
+ },
42
+ RelevantPeople: {
43
+ path: "/{connectionId}/codeless/v1.0/users/{userId}/people",
44
+ method: "GET",
45
+ parameters: [
46
+ { name: "connectionId", in: "path", required: true },
47
+ { name: "userId", in: "path", required: true },
48
+ ],
49
+ },
50
+ UserProfile_V2: {
51
+ path: "/{connectionId}/codeless/v1.0/users/{id}",
52
+ method: "GET",
53
+ parameters: [
54
+ { name: "connectionId", in: "path", required: true },
55
+ { name: "id", in: "path", required: true },
56
+ { name: "$select", in: "query", required: false },
57
+ ],
58
+ },
59
+ UserPhotoMetadata: {
60
+ path: "/{connectionId}/codeless/v1.0/users/{userId}/photo",
61
+ method: "GET",
62
+ parameters: [
63
+ { name: "connectionId", in: "path", required: true },
64
+ { name: "userId", in: "path", required: true },
65
+ ],
66
+ },
67
+ Manager_V2: {
68
+ path: "/{connectionId}/codeless/v1.0/users/{id}/manager",
69
+ method: "GET",
70
+ parameters: [
71
+ { name: "connectionId", in: "path", required: true },
72
+ { name: "id", in: "path", required: true },
73
+ { name: "$select", in: "query", required: false },
74
+ ],
75
+ },
76
+ DirectReports_V2: {
77
+ path: "/{connectionId}/codeless/v1.0/users/{id}/directReports",
78
+ method: "GET",
79
+ parameters: [
80
+ { name: "connectionId", in: "path", required: true },
81
+ { name: "id", in: "path", required: true },
82
+ { name: "$select", in: "query", required: false },
83
+ { name: "$top", in: "query", required: false },
84
+ ],
85
+ },
86
+ UserPhoto_V2: {
87
+ path: "/{connectionId}/codeless/v1.0/users/{id}/photo/$value",
88
+ method: "GET",
89
+ parameters: [
90
+ { name: "connectionId", in: "path", required: true },
91
+ { name: "id", in: "path", required: true },
92
+ ],
93
+ responseInfo: { "200": "image/jpeg" },
94
+ },
95
+ TrendingDocuments: {
96
+ path: "/{connectionId}/codeless/v1.0/users/{id}/insights/trending",
97
+ method: "GET",
98
+ parameters: [
99
+ { name: "connectionId", in: "path", required: true },
100
+ { name: "id", in: "path", required: true },
101
+ { name: "$filter", in: "query", required: false },
102
+ { name: "extractSensitivityLabel", in: "query", required: false },
103
+ { name: "fetchSensitivityLabelMetadata", in: "query", required: false },
104
+ ],
105
+ },
106
+ SearchUserV2: {
107
+ path: "/{connectionId}/codeless/v1.0/users",
108
+ method: "GET",
109
+ parameters: [
110
+ { name: "connectionId", in: "path", required: true },
111
+ { name: "searchTerm", in: "query", required: false },
112
+ { name: "top", in: "query", required: false },
113
+ { name: "isSearchTermRequired", in: "query", required: false },
114
+ { name: "skipToken", in: "query", required: false },
115
+ ],
116
+ },
117
+ SearchUser_V2: {
118
+ path: "/{connectionId}/codeless/v1.0/users",
119
+ method: "GET",
120
+ parameters: [
121
+ { name: "connectionId", in: "path", required: true },
122
+ { name: "searchTerm", in: "query", required: false },
123
+ { name: "top", in: "query", required: false },
124
+ { name: "isSearchTermRequired", in: "query", required: false },
125
+ { name: "skipToken", in: "query", required: false },
126
+ ],
127
+ },
128
+ HttpRequest: {
129
+ path: "/{connectionId}/codeless/v1.0/httprequest",
130
+ method: "POST",
131
+ parameters: [
132
+ { name: "connectionId", in: "path", required: true },
133
+ { name: "Uri", in: "header", required: true },
134
+ { name: "Method", in: "header", required: true },
135
+ { name: "Body", in: "body", required: false },
136
+ { name: "ContentType", in: "header", required: false },
137
+ { name: "CustomHeader1", in: "header", required: false },
138
+ { name: "CustomHeader2", in: "header", required: false },
139
+ { name: "CustomHeader3", in: "header", required: false },
140
+ { name: "CustomHeader4", in: "header", required: false },
141
+ { name: "CustomHeader5", in: "header", required: false },
142
+ ],
143
+ },
144
+ };
145
+
146
+ // ── Initialize SDK client for the Office 365 Users connector ───
147
+ function initClient() {
148
+ const dataSourcesInfo = {
149
+ [DATA_SOURCE]: {
150
+ tableId: "",
151
+ version: "",
152
+ primaryKey: "",
153
+ dataSourceType: "Connector",
154
+ apis: USERS_APIS,
155
+ },
156
+ };
157
+ return getClient(dataSourcesInfo);
158
+ }
159
+
160
+ function unwrapResult(result) {
161
+ if (result && result.success === false) {
162
+ throw new Error(result.error?.message || "Operation failed");
163
+ }
164
+
165
+ return result && Object.prototype.hasOwnProperty.call(result, "data") ? result.data : result;
166
+ }
167
+
168
+ function isUsersObject(value) {
169
+ return !!value && typeof value === "object" && !Array.isArray(value);
170
+ }
171
+
172
+ function pickUsersValue() {
173
+ for (let iIndex = 0; iIndex < arguments.length; iIndex += 1) {
174
+ const value = arguments[iIndex];
175
+ if (value !== undefined && value !== null) return value;
176
+ }
177
+
178
+ return undefined;
179
+ }
180
+
181
+ function setUsersIfDefined(target, key, value) {
182
+ if (value !== undefined && value !== null) {
183
+ target[key] = value;
184
+ }
185
+ }
186
+
187
+ function normalizeUsersSelect(value) {
188
+ if (Array.isArray(value)) return value.join(",");
189
+ return value;
190
+ }
191
+
192
+ function normalizeUsersSelectOptions(options) {
193
+ if (isUsersObject(options)) return options;
194
+ if (options === undefined || options === null) return {};
195
+ return { select: options };
196
+ }
197
+
198
+ function normalizeUsersDirectReportsOptions(options) {
199
+ if (isUsersObject(options)) return options;
200
+ if (typeof options === "number") return { top: options };
201
+ if (options === undefined || options === null) return {};
202
+ return { select: options };
203
+ }
204
+
205
+ function normalizeUsersSearchOptions(options) {
206
+ if (typeof options === "string") return { searchTerm: options };
207
+ return isUsersObject(options) ? options : {};
208
+ }
209
+
210
+ function normalizeUsersTrendingOptions(options) {
211
+ if (typeof options === "string") return { filter: options };
212
+ return isUsersObject(options) ? options : {};
213
+ }
214
+
215
+ function extractUsersSkipToken(nextLink) {
216
+ if (!nextLink || typeof nextLink !== "string") return undefined;
217
+
218
+ try {
219
+ const url = new URL(nextLink);
220
+ return pickUsersValue(
221
+ url.searchParams.get("skipToken"),
222
+ url.searchParams.get("$skiptoken"),
223
+ url.searchParams.get("$skipToken"),
224
+ url.searchParams.get("skiptoken")
225
+ );
226
+ } catch {
227
+ return undefined;
228
+ }
229
+ }
230
+
231
+ function getUsersHeaderValue(headers, name) {
232
+ if (!isUsersObject(headers)) return undefined;
233
+
234
+ const headerName = String(name).toLowerCase();
235
+ const entries = Object.entries(headers);
236
+ for (let iIndex = 0; iIndex < entries.length; iIndex += 1) {
237
+ const [currentName, value] = entries[iIndex];
238
+ if (String(currentName).toLowerCase() === headerName) {
239
+ return value;
240
+ }
241
+ }
242
+
243
+ return undefined;
244
+ }
245
+
246
+ function normalizeUsersCustomHeaders(headers, customHeaders) {
247
+ const resolved = Array.isArray(customHeaders) ? customHeaders.filter((value) => value != null) : [];
248
+
249
+ if (!isUsersObject(headers)) return resolved.slice(0, 5);
250
+
251
+ const entries = Object.entries(headers);
252
+ for (let iIndex = 0; iIndex < entries.length; iIndex += 1) {
253
+ const [headerName, value] = entries[iIndex];
254
+ if (value === undefined || value === null) continue;
255
+ if (String(headerName).toLowerCase() === "content-type") continue;
256
+ resolved.push(String(headerName) + ": " + String(value));
257
+ if (resolved.length >= 5) break;
258
+ }
259
+
260
+ return resolved.slice(0, 5);
261
+ }
262
+
263
+ // ── Internal: execute a connector operation ────────────────────
264
+ async function execOp(operationName, parameters) {
265
+ const client = await initClient();
266
+ const result = await client.executeAsync({
267
+ connectorOperation: {
268
+ tableName: DATA_SOURCE,
269
+ operationName,
270
+ parameters,
271
+ },
272
+ });
273
+ return unwrapResult(result);
274
+ }
275
+
276
+ // ═══════════════════════════════════════════════════════════════
277
+ // GENERIC
278
+ // ═══════════════════════════════════════════════════════════════
279
+
280
+ // ── Call any Office 365 Users operation by name ────────────────
281
+ export async function callUsersOperation(operationName, parameters = {}) {
282
+ return execOp(operationName, parameters);
283
+ }
284
+
285
+ // ── Open HTTP Request ──────────────────────────────────────────
286
+ export async function openHttpRequest({ method = "GET", uri, headers, body, contentType, customHeaders } = {}) {
287
+ const resolvedHeaders = normalizeUsersCustomHeaders(headers, customHeaders);
288
+ return execOp("HttpRequest", {
289
+ Uri: uri,
290
+ Method: method,
291
+ Body: body,
292
+ ContentType: pickUsersValue(contentType, getUsersHeaderValue(headers, "Content-Type")),
293
+ CustomHeader1: resolvedHeaders[0],
294
+ CustomHeader2: resolvedHeaders[1],
295
+ CustomHeader3: resolvedHeaders[2],
296
+ CustomHeader4: resolvedHeaders[3],
297
+ CustomHeader5: resolvedHeaders[4],
298
+ });
299
+ }
300
+
301
+ export async function updateMyProfile(profile = {}) {
302
+ const body = isUsersObject(profile) && "body" in profile ? profile.body : profile;
303
+ return execOp("UpdateMyProfile", { body });
304
+ }
305
+
306
+ // ═══════════════════════════════════════════════════════════════
307
+ // PROFILE
308
+ // ═══════════════════════════════════════════════════════════════
309
+
310
+ // ── Get My Profile ─────────────────────────────────────────────
311
+ export async function getMyProfile(options) {
312
+ const resolvedOptions = normalizeUsersSelectOptions(options);
313
+ const params = {};
314
+ setUsersIfDefined(params, "$select", normalizeUsersSelect(pickUsersValue(resolvedOptions.select, resolvedOptions.$select)));
315
+ return execOp("MyProfile_V2", params);
316
+ }
317
+
318
+ // ── Get User Profile ───────────────────────────────────────────
319
+ export async function getUserProfile(userId, options) {
320
+ if (isUsersObject(userId)) {
321
+ options = userId;
322
+ userId = pickUsersValue(options.userId, options.id);
323
+ }
324
+
325
+ const resolvedOptions = normalizeUsersSelectOptions(options);
326
+ const params = { id: userId };
327
+ setUsersIfDefined(params, "$select", normalizeUsersSelect(pickUsersValue(resolvedOptions.select, resolvedOptions.$select)));
328
+ return execOp("UserProfile_V2", params);
329
+ }
330
+
331
+ // ═══════════════════════════════════════════════════════════════
332
+ // MANAGER & REPORTS
333
+ // ═══════════════════════════════════════════════════════════════
334
+
335
+ // ── Get Manager ────────────────────────────────────────────────
336
+ export async function getManager(userId, options) {
337
+ if (isUsersObject(userId)) {
338
+ options = userId;
339
+ userId = pickUsersValue(options.userId, options.id);
340
+ }
341
+
342
+ const resolvedOptions = normalizeUsersSelectOptions(options);
343
+ const params = { id: userId };
344
+ setUsersIfDefined(params, "$select", normalizeUsersSelect(pickUsersValue(resolvedOptions.select, resolvedOptions.$select)));
345
+ return execOp("Manager_V2", params);
346
+ }
347
+
348
+ // ── Get Direct Reports ─────────────────────────────────────────
349
+ export async function getDirectReports(userId, options) {
350
+ if (isUsersObject(userId)) {
351
+ options = userId;
352
+ userId = pickUsersValue(options.userId, options.id);
353
+ }
354
+
355
+ const resolvedOptions = normalizeUsersDirectReportsOptions(options);
356
+ const params = { id: userId };
357
+ setUsersIfDefined(params, "$select", normalizeUsersSelect(pickUsersValue(resolvedOptions.select, resolvedOptions.$select)));
358
+ setUsersIfDefined(params, "$top", pickUsersValue(resolvedOptions.top, resolvedOptions.$top));
359
+ return execOp("DirectReports_V2", params);
360
+ }
361
+
362
+ export async function getMyTrendingDocuments(options = {}) {
363
+ const resolvedOptions = normalizeUsersTrendingOptions(options);
364
+ const params = {};
365
+ setUsersIfDefined(params, "$filter", pickUsersValue(resolvedOptions.filter, resolvedOptions.$filter));
366
+ setUsersIfDefined(params, "extractSensitivityLabel", resolvedOptions.extractSensitivityLabel);
367
+ setUsersIfDefined(params, "fetchSensitivityLabelMetadata", resolvedOptions.fetchSensitivityLabelMetadata);
368
+ return execOp("MyTrendingDocuments", params);
369
+ }
370
+
371
+ export async function getRelevantPeople(userId) {
372
+ if (isUsersObject(userId)) {
373
+ userId = pickUsersValue(userId.userId, userId.id);
374
+ }
375
+
376
+ return execOp("RelevantPeople", { userId });
377
+ }
378
+
379
+ // ═══════════════════════════════════════════════════════════════
380
+ // PHOTO
381
+ // ═══════════════════════════════════════════════════════════════
382
+
383
+ // ── Get User Photo ─────────────────────────────────────────────
384
+ export async function updateMyPhoto(bodyOrOptions, contentType) {
385
+ if (isUsersObject(bodyOrOptions)) {
386
+ contentType = pickUsersValue(bodyOrOptions.contentType, bodyOrOptions.Content_Type, bodyOrOptions.mimeType);
387
+ bodyOrOptions = pickUsersValue(bodyOrOptions.body, bodyOrOptions.content, bodyOrOptions.photo, bodyOrOptions.fileContent);
388
+ }
389
+
390
+ return execOp("UpdateMyPhoto", {
391
+ body: bodyOrOptions,
392
+ Content_Type: contentType,
393
+ });
394
+ }
395
+
396
+ export async function getUserPhotoMetadata(userId) {
397
+ if (isUsersObject(userId)) {
398
+ userId = pickUsersValue(userId.userId, userId.id);
399
+ }
400
+
401
+ return execOp("UserPhotoMetadata", { userId });
402
+ }
403
+
404
+ export async function getUserPhoto(userId) {
405
+ if (isUsersObject(userId)) {
406
+ userId = pickUsersValue(userId.userId, userId.id);
407
+ }
408
+
409
+ return execOp("UserPhoto_V2", { id: userId });
410
+ }
411
+
412
+ export async function getTrendingDocuments(userId, options = {}) {
413
+ if (isUsersObject(userId)) {
414
+ options = userId;
415
+ userId = pickUsersValue(options.userId, options.id);
416
+ }
417
+
418
+ const resolvedOptions = normalizeUsersTrendingOptions(options);
419
+ const params = { id: userId };
420
+ setUsersIfDefined(params, "$filter", pickUsersValue(resolvedOptions.filter, resolvedOptions.$filter));
421
+ setUsersIfDefined(params, "extractSensitivityLabel", resolvedOptions.extractSensitivityLabel);
422
+ setUsersIfDefined(params, "fetchSensitivityLabelMetadata", resolvedOptions.fetchSensitivityLabelMetadata);
423
+ return execOp("TrendingDocuments", params);
424
+ }
425
+
426
+ // ═══════════════════════════════════════════════════════════════
427
+ // SEARCH
428
+ // ═══════════════════════════════════════════════════════════════
429
+
430
+ // ── Search for Users ───────────────────────────────────────────
431
+ export async function searchForUsers(options = {}) {
432
+ const resolvedOptions = normalizeUsersSearchOptions(options);
433
+ const params = {};
434
+ setUsersIfDefined(params, "searchTerm", resolvedOptions.searchTerm);
435
+ setUsersIfDefined(params, "top", pickUsersValue(resolvedOptions.top, resolvedOptions.$top));
436
+ setUsersIfDefined(params, "isSearchTermRequired", resolvedOptions.isSearchTermRequired);
437
+
438
+ const skipToken = pickUsersValue(
439
+ resolvedOptions.skipToken,
440
+ resolvedOptions.$skipToken,
441
+ resolvedOptions.$skiptoken,
442
+ extractUsersSkipToken(resolvedOptions.nextLink),
443
+ resolvedOptions.skip
444
+ );
445
+
446
+ if (skipToken !== undefined && skipToken !== null) {
447
+ params.skipToken = String(skipToken);
448
+ }
449
+
450
+ return execOp("SearchUserV2", params);
451
+ }