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
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
|
|
2
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
3
|
+
// ─────────────────────────────── SharePoint ─────────────────────────────────
|
|
4
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
5
|
+
import { getClient} from "./power-apps-data.js";
|
|
6
|
+
import {_dbgWrap } from "./codeapp.js";
|
|
7
|
+
// ── Data source name (must match connectionReferences in power.config.json) ──
|
|
8
|
+
const DATA_SOURCE_SP = "sharepointonline";
|
|
9
|
+
|
|
10
|
+
// ── Initialize SDK client for the SharePoint connector ─────────
|
|
11
|
+
function initSpClient() {
|
|
12
|
+
const dataSourcesInfo = {
|
|
13
|
+
[DATA_SOURCE_SP]: {
|
|
14
|
+
tableId: "",
|
|
15
|
+
version: "",
|
|
16
|
+
primaryKey: "",
|
|
17
|
+
dataSourceType: "Connector",
|
|
18
|
+
apis: {
|
|
19
|
+
GetItems: {
|
|
20
|
+
path: "/{connectionId}/datasets/{siteUrl}/tables/{table}/items",
|
|
21
|
+
method: "GET",
|
|
22
|
+
parameters: [
|
|
23
|
+
{ name: "connectionId", in: "path", required: true },
|
|
24
|
+
{ name: "siteUrl", in: "path", required: true },
|
|
25
|
+
{ name: "table", in: "path", required: true },
|
|
26
|
+
{ name: "$filter", in: "query", required: false },
|
|
27
|
+
{ name: "$orderby", in: "query", required: false },
|
|
28
|
+
{ name: "$top", in: "query", required: false },
|
|
29
|
+
{ name: "$skip", in: "query", required: false },
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
GetItem: {
|
|
33
|
+
path: "/{connectionId}/datasets/{siteUrl}/tables/{table}/items/{id}",
|
|
34
|
+
method: "GET",
|
|
35
|
+
parameters: [
|
|
36
|
+
{ name: "connectionId", in: "path", required: true },
|
|
37
|
+
{ name: "siteUrl", in: "path", required: true },
|
|
38
|
+
{ name: "table", in: "path", required: true },
|
|
39
|
+
{ name: "id", in: "path", required: true },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
PostItem: {
|
|
43
|
+
path: "/{connectionId}/datasets/{siteUrl}/tables/{table}/items",
|
|
44
|
+
method: "POST",
|
|
45
|
+
parameters: [
|
|
46
|
+
{ name: "connectionId", in: "path", required: true },
|
|
47
|
+
{ name: "siteUrl", in: "path", required: true },
|
|
48
|
+
{ name: "table", in: "path", required: true },
|
|
49
|
+
{ name: "item", in: "body", required: true },
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
PatchItem: {
|
|
53
|
+
path: "/{connectionId}/datasets/{siteUrl}/tables/{table}/items/{id}",
|
|
54
|
+
method: "PATCH",
|
|
55
|
+
parameters: [
|
|
56
|
+
{ name: "connectionId", in: "path", required: true },
|
|
57
|
+
{ name: "siteUrl", in: "path", required: true },
|
|
58
|
+
{ name: "table", in: "path", required: true },
|
|
59
|
+
{ name: "id", in: "path", required: true },
|
|
60
|
+
{ name: "item", in: "body", required: true },
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
DeleteItem: {
|
|
64
|
+
path: "/{connectionId}/datasets/{siteUrl}/tables/{table}/items/{id}",
|
|
65
|
+
method: "DELETE",
|
|
66
|
+
parameters: [
|
|
67
|
+
{ name: "connectionId", in: "path", required: true },
|
|
68
|
+
{ name: "siteUrl", in: "path", required: true },
|
|
69
|
+
{ name: "table", in: "path", required: true },
|
|
70
|
+
{ name: "id", in: "path", required: true },
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
GetTables: {
|
|
74
|
+
path: "/{connectionId}/datasets/{siteUrl}/tables",
|
|
75
|
+
method: "GET",
|
|
76
|
+
parameters: [
|
|
77
|
+
{ name: "connectionId", in: "path", required: true },
|
|
78
|
+
{ name: "siteUrl", in: "path", required: true },
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
GetDataSetsMetadata: {
|
|
82
|
+
path: "/{connectionId}/datasets/{siteUrl}",
|
|
83
|
+
method: "GET",
|
|
84
|
+
parameters: [
|
|
85
|
+
{ name: "connectionId", in: "path", required: true },
|
|
86
|
+
{ name: "siteUrl", in: "path", required: true },
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
CreateFile: {
|
|
90
|
+
path: "/{connectionId}/datasets/{siteUrl}/files",
|
|
91
|
+
method: "POST",
|
|
92
|
+
parameters: [
|
|
93
|
+
{ name: "connectionId", in: "path", required: true },
|
|
94
|
+
{ name: "siteUrl", in: "path", required: true },
|
|
95
|
+
{ name: "folderPath", in: "query", required: true },
|
|
96
|
+
{ name: "name", in: "query", required: true },
|
|
97
|
+
{ name: "body", in: "body", required: true },
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
UpdateFile: {
|
|
101
|
+
path: "/{connectionId}/datasets/{siteUrl}/files/{id}",
|
|
102
|
+
method: "PUT",
|
|
103
|
+
parameters: [
|
|
104
|
+
{ name: "connectionId", in: "path", required: true },
|
|
105
|
+
{ name: "siteUrl", in: "path", required: true },
|
|
106
|
+
{ name: "id", in: "path", required: true },
|
|
107
|
+
{ name: "body", in: "body", required: true },
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
DeleteFile: {
|
|
111
|
+
path: "/{connectionId}/datasets/{siteUrl}/files/{id}",
|
|
112
|
+
method: "DELETE",
|
|
113
|
+
parameters: [
|
|
114
|
+
{ name: "connectionId", in: "path", required: true },
|
|
115
|
+
{ name: "siteUrl", in: "path", required: true },
|
|
116
|
+
{ name: "id", in: "path", required: true },
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
MoveFile: {
|
|
120
|
+
path: "/{connectionId}/datasets/{siteUrl}/files/{id}/moveto",
|
|
121
|
+
method: "POST",
|
|
122
|
+
parameters: [
|
|
123
|
+
{ name: "connectionId", in: "path", required: true },
|
|
124
|
+
{ name: "siteUrl", in: "path", required: true },
|
|
125
|
+
{ name: "id", in: "path", required: true },
|
|
126
|
+
{ name: "destinationFolderPath", in: "query", required: true },
|
|
127
|
+
{ name: "newFileName", in: "query", required: false },
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
GetFileMetadata: {
|
|
131
|
+
path: "/{connectionId}/datasets/{siteUrl}/files/{id}",
|
|
132
|
+
method: "GET",
|
|
133
|
+
parameters: [
|
|
134
|
+
{ name: "connectionId", in: "path", required: true },
|
|
135
|
+
{ name: "siteUrl", in: "path", required: true },
|
|
136
|
+
{ name: "id", in: "path", required: true },
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
HttpRequest: {
|
|
140
|
+
path: "/{connectionId}/httprequest",
|
|
141
|
+
method: "POST",
|
|
142
|
+
parameters: [
|
|
143
|
+
{ name: "connectionId", in: "path", required: true },
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
return getClient(dataSourcesInfo);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ── Internal: execute a connector operation ────────────────────
|
|
153
|
+
async function execSpOp(operationName, parameters) {
|
|
154
|
+
try {
|
|
155
|
+
const client = await initSpClient();
|
|
156
|
+
const result = await client.executeAsync({
|
|
157
|
+
connectorOperation: {
|
|
158
|
+
tableName: DATA_SOURCE_SP,
|
|
159
|
+
operationName,
|
|
160
|
+
parameters: parameters || {},
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
if (!result) {
|
|
165
|
+
throw new Error("No result returned");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (result.success === false) {
|
|
169
|
+
throw new Error(getSpErrorMessage(result.error));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return Object.prototype.hasOwnProperty.call(result, "data") ? result.data : result;
|
|
173
|
+
} catch (oError) {
|
|
174
|
+
throw new Error("SharePoint " + operationName + " failed: " + getSpErrorMessage(oError));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function getSpErrorMessage(oError) {
|
|
179
|
+
if (!oError) {
|
|
180
|
+
return "Unknown error";
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (typeof oError === "string") {
|
|
184
|
+
return oError;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (oError instanceof Error && oError.message) {
|
|
188
|
+
return oError.message;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const aCandidates = [
|
|
192
|
+
oError.message,
|
|
193
|
+
oError.error && oError.error.message,
|
|
194
|
+
oError.body && oError.body.message,
|
|
195
|
+
oError.body && oError.body.error && oError.body.error.message,
|
|
196
|
+
oError.data && oError.data.message,
|
|
197
|
+
oError.detail,
|
|
198
|
+
];
|
|
199
|
+
|
|
200
|
+
const sCandidate = aCandidates.find(function(sValue) {
|
|
201
|
+
return typeof sValue === "string" && sValue.trim() !== "";
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
if (sCandidate) {
|
|
205
|
+
return sCandidate;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
try {
|
|
209
|
+
return JSON.stringify(oError);
|
|
210
|
+
} catch (oStringifyError) {
|
|
211
|
+
return String(oError);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function requireNonEmptyString(sValue, sLabel) {
|
|
216
|
+
if (typeof sValue !== "string" || sValue.trim() === "") {
|
|
217
|
+
throw new Error("SharePoint " + sLabel + " is required.");
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return sValue.trim();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function requireRecord(oValue, sLabel) {
|
|
224
|
+
if (!oValue || typeof oValue !== "object" || Array.isArray(oValue)) {
|
|
225
|
+
throw new Error("SharePoint " + sLabel + " must be an object.");
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return oValue;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function normalizeHeaders(oHeaders) {
|
|
232
|
+
if (oHeaders == null) {
|
|
233
|
+
return {};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (typeof oHeaders !== "object" || Array.isArray(oHeaders)) {
|
|
237
|
+
throw new Error("SharePoint request headers must be an object.");
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return oHeaders;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function normalizeNumericQueryValue(value, sLabel) {
|
|
244
|
+
if (value == null || value === "") {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const iValue = Number(value);
|
|
249
|
+
if (!Number.isFinite(iValue)) {
|
|
250
|
+
throw new Error("SharePoint " + sLabel + " must be numeric.");
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return iValue;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function requireItemId(iItemId) {
|
|
257
|
+
if ((typeof iItemId !== "string" && typeof iItemId !== "number") || String(iItemId).trim() === "") {
|
|
258
|
+
throw new Error("SharePoint item ID is required.");
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return iItemId;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function buildListContext(sSiteUrl, sListId) {
|
|
265
|
+
return {
|
|
266
|
+
siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
|
|
267
|
+
table: requireNonEmptyString(sListId, "list ID"),
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function buildItemQueryParameters(sSiteUrl, sListId, { filter, orderBy, top, skip } = {}) {
|
|
272
|
+
const oParams = buildListContext(sSiteUrl, sListId);
|
|
273
|
+
if (filter) {
|
|
274
|
+
oParams.$filter = String(filter);
|
|
275
|
+
}
|
|
276
|
+
if (orderBy) {
|
|
277
|
+
oParams.$orderby = String(orderBy);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const iTop = normalizeNumericQueryValue(top, "top");
|
|
281
|
+
const iSkip = normalizeNumericQueryValue(skip, "skip");
|
|
282
|
+
if (iTop != null) {
|
|
283
|
+
oParams.$top = iTop;
|
|
284
|
+
}
|
|
285
|
+
if (iSkip != null) {
|
|
286
|
+
oParams.$skip = iSkip;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return oParams;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function normalizeCollection(oPayload) {
|
|
293
|
+
if (Array.isArray(oPayload)) {
|
|
294
|
+
return oPayload;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const aCandidates = [
|
|
298
|
+
oPayload,
|
|
299
|
+
oPayload && oPayload.value,
|
|
300
|
+
oPayload && oPayload.items,
|
|
301
|
+
oPayload && oPayload.results,
|
|
302
|
+
oPayload && oPayload.body,
|
|
303
|
+
oPayload && oPayload.data,
|
|
304
|
+
oPayload && oPayload.result,
|
|
305
|
+
oPayload && oPayload.response,
|
|
306
|
+
oPayload && oPayload.d && oPayload.d.results,
|
|
307
|
+
];
|
|
308
|
+
|
|
309
|
+
const aMatch = aCandidates.find(function(oCandidate) {
|
|
310
|
+
return Array.isArray(oCandidate);
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
return aMatch || [];
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// ═══════════════════════════════════════════════════════════════
|
|
317
|
+
// GENERIC
|
|
318
|
+
// ═══════════════════════════════════════════════════════════════
|
|
319
|
+
|
|
320
|
+
// ── Call any SharePoint connector operation by name ─────────────
|
|
321
|
+
export async function callSharePointOperation(operationName, parameters = {}) {
|
|
322
|
+
return _dbgWrap('callSharePointOperation', [operationName, parameters], async function() {
|
|
323
|
+
return execSpOp(operationName, parameters);
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// ── Send HTTP Request (raw escape hatch) ───────────────────────
|
|
328
|
+
export async function sendHttpRequest({ method = "GET", uri, headers, body } = {}) {
|
|
329
|
+
return _dbgWrap('sendHttpRequest', [{ method, uri, headers, body }], async function() {
|
|
330
|
+
return execSpOp("HttpRequest", {
|
|
331
|
+
method: String(method || "GET").toUpperCase(),
|
|
332
|
+
uri: requireNonEmptyString(uri, "request URI"),
|
|
333
|
+
headers: normalizeHeaders(headers),
|
|
334
|
+
body: body == null ? "" : body,
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// ═══════════════════════════════════════════════════════════════
|
|
340
|
+
// ITEMS (standard API — uses list ID)
|
|
341
|
+
// ═══════════════════════════════════════════════════════════════
|
|
342
|
+
|
|
343
|
+
// ── Get Items ──────────────────────────────────────────────────
|
|
344
|
+
export async function getItems(sSiteUrl, sListId, { filter, orderBy, top, skip } = {}) {
|
|
345
|
+
return _dbgWrap('getItems', [sSiteUrl, sListId, { filter, orderBy, top, skip }], async function() {
|
|
346
|
+
return execSpOp("GetItems", buildItemQueryParameters(sSiteUrl, sListId, { filter, orderBy, top, skip }));
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// ── Get Item ───────────────────────────────────────────────────
|
|
351
|
+
export async function getSpItem(sSiteUrl, sListId, iItemId) {
|
|
352
|
+
return _dbgWrap('getSpItem', [sSiteUrl, sListId, iItemId], async function() {
|
|
353
|
+
return execSpOp("GetItem", Object.assign(buildListContext(sSiteUrl, sListId), {
|
|
354
|
+
id: requireItemId(iItemId),
|
|
355
|
+
}));
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// ── Create Item ────────────────────────────────────────────────
|
|
360
|
+
export async function createSpItem(sSiteUrl, sListId, oFields) {
|
|
361
|
+
return _dbgWrap('createSpItem', [sSiteUrl, sListId, oFields], async function() {
|
|
362
|
+
return execSpOp("PostItem", Object.assign(buildListContext(sSiteUrl, sListId), {
|
|
363
|
+
item: requireRecord(oFields, "item payload"),
|
|
364
|
+
}));
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// ── Update Item ────────────────────────────────────────────────
|
|
369
|
+
export async function updateSpItem(sSiteUrl, sListId, iItemId, oChangedFields) {
|
|
370
|
+
return _dbgWrap('updateSpItem', [sSiteUrl, sListId, iItemId, oChangedFields], async function() {
|
|
371
|
+
return execSpOp("PatchItem", Object.assign(buildListContext(sSiteUrl, sListId), {
|
|
372
|
+
id: requireItemId(iItemId),
|
|
373
|
+
item: requireRecord(oChangedFields, "item payload"),
|
|
374
|
+
}));
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// ── Delete Item ────────────────────────────────────────────────
|
|
379
|
+
export async function deleteSpItem(sSiteUrl, sListId, iItemId) {
|
|
380
|
+
return _dbgWrap('deleteSpItem', [sSiteUrl, sListId, iItemId], async function() {
|
|
381
|
+
return execSpOp("DeleteItem", Object.assign(buildListContext(sSiteUrl, sListId), {
|
|
382
|
+
id: requireItemId(iItemId),
|
|
383
|
+
}));
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// ═══════════════════════════════════════════════════════════════
|
|
388
|
+
// TABLES / LISTS
|
|
389
|
+
// ═══════════════════════════════════════════════════════════════
|
|
390
|
+
|
|
391
|
+
// ── List Tables (Lists) ────────────────────────────────────────
|
|
392
|
+
export async function listTables(sSiteUrl) {
|
|
393
|
+
return _dbgWrap('listTables', [sSiteUrl], async function() {
|
|
394
|
+
return normalizeCollection(await execSpOp("GetTables", {
|
|
395
|
+
siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
|
|
396
|
+
}));
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// ── List Library (Document Libraries) ──────────────────────────
|
|
401
|
+
export async function listLibrary(sSiteUrl) {
|
|
402
|
+
return _dbgWrap('listLibrary', [sSiteUrl], async function() {
|
|
403
|
+
return execSpOp("GetDataSetsMetadata", {
|
|
404
|
+
siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// ═══════════════════════════════════════════════════════════════
|
|
410
|
+
// FILES
|
|
411
|
+
// ═══════════════════════════════════════════════════════════════
|
|
412
|
+
|
|
413
|
+
// ── Create File ────────────────────────────────────────────────
|
|
414
|
+
export async function createFile(sSiteUrl, sLibraryName, sFileName, fileContent) {
|
|
415
|
+
return _dbgWrap('createFile', [sSiteUrl, sLibraryName, sFileName, fileContent], async function() {
|
|
416
|
+
return execSpOp("CreateFile", {
|
|
417
|
+
siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
|
|
418
|
+
folderPath: requireNonEmptyString(sLibraryName, "folder path"),
|
|
419
|
+
name: requireNonEmptyString(sFileName, "file name"),
|
|
420
|
+
body: fileContent,
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// ── Update File ────────────────────────────────────────────────
|
|
426
|
+
export async function updateFile(sSiteUrl, sFileId, fileContent) {
|
|
427
|
+
return _dbgWrap('updateFile', [sSiteUrl, sFileId, fileContent], async function() {
|
|
428
|
+
return execSpOp("UpdateFile", {
|
|
429
|
+
siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
|
|
430
|
+
id: requireNonEmptyString(String(sFileId || ""), "file ID"),
|
|
431
|
+
body: fileContent,
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// ── Delete File ────────────────────────────────────────────────
|
|
437
|
+
export async function deleteFile(sSiteUrl, sFileId) {
|
|
438
|
+
return _dbgWrap('deleteFile', [sSiteUrl, sFileId], async function() {
|
|
439
|
+
return execSpOp("DeleteFile", {
|
|
440
|
+
siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
|
|
441
|
+
id: requireNonEmptyString(String(sFileId || ""), "file ID"),
|
|
442
|
+
});
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// ── Move File ──────────────────────────────────────────────────
|
|
447
|
+
export async function moveFile(sSiteUrl, sSourceFileId, sDestinationFolderPath, sNewFileName) {
|
|
448
|
+
return _dbgWrap('moveFile', [sSiteUrl, sSourceFileId, sDestinationFolderPath, sNewFileName], async function() {
|
|
449
|
+
return execSpOp("MoveFile", {
|
|
450
|
+
siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
|
|
451
|
+
id: requireNonEmptyString(String(sSourceFileId || ""), "source file ID"),
|
|
452
|
+
destinationFolderPath: requireNonEmptyString(sDestinationFolderPath, "destination folder path"),
|
|
453
|
+
newFileName: sNewFileName || "",
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// ── Get File Metadata ──────────────────────────────────────────
|
|
459
|
+
export async function getFileMetadata(sSiteUrl, sFileId) {
|
|
460
|
+
return _dbgWrap('getFileMetadata', [sSiteUrl, sFileId], async function() {
|
|
461
|
+
return execSpOp("GetFileMetadata", {
|
|
462
|
+
siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
|
|
463
|
+
id: requireNonEmptyString(String(sFileId || ""), "file ID"),
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
}
|