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