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.
- 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/codeApp/dist/connectors/sharepoint.js +466 -0
- 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/{dev files → examples/sharePoint Demo/dist}/sharepoint.js +239 -112
- 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,12 +1,16 @@
|
|
|
1
|
-
import { getClient } from "./power-apps-data.js";
|
|
2
1
|
|
|
2
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
3
|
+
// ─────────────────────────────── SharePoint ─────────────────────────────────
|
|
4
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
5
|
+
import { getClient} from "./power-apps-data.js";
|
|
6
|
+
import {_dbgWrap } from "./codeapp.js";
|
|
3
7
|
// ── Data source name (must match connectionReferences in power.config.json) ──
|
|
4
|
-
const
|
|
8
|
+
const DATA_SOURCE_SP = "sharepointonline";
|
|
5
9
|
|
|
6
10
|
// ── Initialize SDK client for the SharePoint connector ─────────
|
|
7
|
-
function
|
|
11
|
+
function initSpClient() {
|
|
8
12
|
const dataSourcesInfo = {
|
|
9
|
-
[
|
|
13
|
+
[DATA_SOURCE_SP]: {
|
|
10
14
|
tableId: "",
|
|
11
15
|
version: "",
|
|
12
16
|
primaryKey: "",
|
|
@@ -146,19 +150,167 @@ function initClient() {
|
|
|
146
150
|
}
|
|
147
151
|
|
|
148
152
|
// ── Internal: execute a connector operation ────────────────────
|
|
149
|
-
async function
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
async function execSpOp(operationName, parameters) {
|
|
154
|
+
try {
|
|
155
|
+
const client = await initSpClient();
|
|
156
|
+
const result = await client.executeAsync({
|
|
157
|
+
connectorOperation: {
|
|
158
|
+
tableName: DATA_SOURCE_SP,
|
|
159
|
+
operationName,
|
|
160
|
+
parameters: parameters || {},
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
if (!result) {
|
|
165
|
+
throw new Error("No result returned");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (result.success === false) {
|
|
169
|
+
throw new Error(getSpErrorMessage(result.error));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return Object.prototype.hasOwnProperty.call(result, "data") ? result.data : result;
|
|
173
|
+
} catch (oError) {
|
|
174
|
+
throw new Error("SharePoint " + operationName + " failed: " + getSpErrorMessage(oError));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function getSpErrorMessage(oError) {
|
|
179
|
+
if (!oError) {
|
|
180
|
+
return "Unknown error";
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (typeof oError === "string") {
|
|
184
|
+
return oError;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (oError instanceof Error && oError.message) {
|
|
188
|
+
return oError.message;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const aCandidates = [
|
|
192
|
+
oError.message,
|
|
193
|
+
oError.error && oError.error.message,
|
|
194
|
+
oError.body && oError.body.message,
|
|
195
|
+
oError.body && oError.body.error && oError.body.error.message,
|
|
196
|
+
oError.data && oError.data.message,
|
|
197
|
+
oError.detail,
|
|
198
|
+
];
|
|
199
|
+
|
|
200
|
+
const sCandidate = aCandidates.find(function(sValue) {
|
|
201
|
+
return typeof sValue === "string" && sValue.trim() !== "";
|
|
157
202
|
});
|
|
158
|
-
|
|
159
|
-
|
|
203
|
+
|
|
204
|
+
if (sCandidate) {
|
|
205
|
+
return sCandidate;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
try {
|
|
209
|
+
return JSON.stringify(oError);
|
|
210
|
+
} catch (oStringifyError) {
|
|
211
|
+
return String(oError);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function requireNonEmptyString(sValue, sLabel) {
|
|
216
|
+
if (typeof sValue !== "string" || sValue.trim() === "") {
|
|
217
|
+
throw new Error("SharePoint " + sLabel + " is required.");
|
|
160
218
|
}
|
|
161
|
-
|
|
219
|
+
|
|
220
|
+
return sValue.trim();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function requireRecord(oValue, sLabel) {
|
|
224
|
+
if (!oValue || typeof oValue !== "object" || Array.isArray(oValue)) {
|
|
225
|
+
throw new Error("SharePoint " + sLabel + " must be an object.");
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return oValue;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function normalizeHeaders(oHeaders) {
|
|
232
|
+
if (oHeaders == null) {
|
|
233
|
+
return {};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (typeof oHeaders !== "object" || Array.isArray(oHeaders)) {
|
|
237
|
+
throw new Error("SharePoint request headers must be an object.");
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return oHeaders;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function normalizeNumericQueryValue(value, sLabel) {
|
|
244
|
+
if (value == null || value === "") {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const iValue = Number(value);
|
|
249
|
+
if (!Number.isFinite(iValue)) {
|
|
250
|
+
throw new Error("SharePoint " + sLabel + " must be numeric.");
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return iValue;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function requireItemId(iItemId) {
|
|
257
|
+
if ((typeof iItemId !== "string" && typeof iItemId !== "number") || String(iItemId).trim() === "") {
|
|
258
|
+
throw new Error("SharePoint item ID is required.");
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return iItemId;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function buildListContext(sSiteUrl, sListId) {
|
|
265
|
+
return {
|
|
266
|
+
siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
|
|
267
|
+
table: requireNonEmptyString(sListId, "list ID"),
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function buildItemQueryParameters(sSiteUrl, sListId, { filter, orderBy, top, skip } = {}) {
|
|
272
|
+
const oParams = buildListContext(sSiteUrl, sListId);
|
|
273
|
+
if (filter) {
|
|
274
|
+
oParams.$filter = String(filter);
|
|
275
|
+
}
|
|
276
|
+
if (orderBy) {
|
|
277
|
+
oParams.$orderby = String(orderBy);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const iTop = normalizeNumericQueryValue(top, "top");
|
|
281
|
+
const iSkip = normalizeNumericQueryValue(skip, "skip");
|
|
282
|
+
if (iTop != null) {
|
|
283
|
+
oParams.$top = iTop;
|
|
284
|
+
}
|
|
285
|
+
if (iSkip != null) {
|
|
286
|
+
oParams.$skip = iSkip;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return oParams;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function normalizeCollection(oPayload) {
|
|
293
|
+
if (Array.isArray(oPayload)) {
|
|
294
|
+
return oPayload;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const aCandidates = [
|
|
298
|
+
oPayload,
|
|
299
|
+
oPayload && oPayload.value,
|
|
300
|
+
oPayload && oPayload.items,
|
|
301
|
+
oPayload && oPayload.results,
|
|
302
|
+
oPayload && oPayload.body,
|
|
303
|
+
oPayload && oPayload.data,
|
|
304
|
+
oPayload && oPayload.result,
|
|
305
|
+
oPayload && oPayload.response,
|
|
306
|
+
oPayload && oPayload.d && oPayload.d.results,
|
|
307
|
+
];
|
|
308
|
+
|
|
309
|
+
const aMatch = aCandidates.find(function(oCandidate) {
|
|
310
|
+
return Array.isArray(oCandidate);
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
return aMatch || [];
|
|
162
314
|
}
|
|
163
315
|
|
|
164
316
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -167,16 +319,20 @@ async function execOp(operationName, parameters) {
|
|
|
167
319
|
|
|
168
320
|
// ── Call any SharePoint connector operation by name ─────────────
|
|
169
321
|
export async function callSharePointOperation(operationName, parameters = {}) {
|
|
170
|
-
return
|
|
322
|
+
return _dbgWrap('callSharePointOperation', [operationName, parameters], async function() {
|
|
323
|
+
return execSpOp(operationName, parameters);
|
|
324
|
+
});
|
|
171
325
|
}
|
|
172
326
|
|
|
173
|
-
// ── Send HTTP Request (
|
|
174
|
-
export async function sendHttpRequest({ method = "GET", uri, headers, body }) {
|
|
175
|
-
return
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
327
|
+
// ── Send HTTP Request (raw escape hatch) ───────────────────────
|
|
328
|
+
export async function sendHttpRequest({ method = "GET", uri, headers, body } = {}) {
|
|
329
|
+
return _dbgWrap('sendHttpRequest', [{ method, uri, headers, body }], async function() {
|
|
330
|
+
return execSpOp("HttpRequest", {
|
|
331
|
+
method: String(method || "GET").toUpperCase(),
|
|
332
|
+
uri: requireNonEmptyString(uri, "request URI"),
|
|
333
|
+
headers: normalizeHeaders(headers),
|
|
334
|
+
body: body == null ? "" : body,
|
|
335
|
+
});
|
|
180
336
|
});
|
|
181
337
|
}
|
|
182
338
|
|
|
@@ -186,106 +342,67 @@ export async function sendHttpRequest({ method = "GET", uri, headers, body }) {
|
|
|
186
342
|
|
|
187
343
|
// ── Get Items ──────────────────────────────────────────────────
|
|
188
344
|
export async function getItems(sSiteUrl, sListId, { filter, orderBy, top, skip } = {}) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (top != null) params.$top = top;
|
|
193
|
-
if (skip != null) params.$skip = skip;
|
|
194
|
-
return execOp("GetItems", params);
|
|
345
|
+
return _dbgWrap('getItems', [sSiteUrl, sListId, { filter, orderBy, top, skip }], async function() {
|
|
346
|
+
return execSpOp("GetItems", buildItemQueryParameters(sSiteUrl, sListId, { filter, orderBy, top, skip }));
|
|
347
|
+
});
|
|
195
348
|
}
|
|
196
349
|
|
|
197
350
|
// ── Get Item ───────────────────────────────────────────────────
|
|
198
|
-
export async function
|
|
199
|
-
return
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
351
|
+
export async function getSpItem(sSiteUrl, sListId, iItemId) {
|
|
352
|
+
return _dbgWrap('getSpItem', [sSiteUrl, sListId, iItemId], async function() {
|
|
353
|
+
return execSpOp("GetItem", Object.assign(buildListContext(sSiteUrl, sListId), {
|
|
354
|
+
id: requireItemId(iItemId),
|
|
355
|
+
}));
|
|
203
356
|
});
|
|
204
357
|
}
|
|
205
358
|
|
|
206
359
|
// ── Create Item ────────────────────────────────────────────────
|
|
207
|
-
export async function
|
|
208
|
-
return
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
360
|
+
export async function createSpItem(sSiteUrl, sListId, oFields) {
|
|
361
|
+
return _dbgWrap('createSpItem', [sSiteUrl, sListId, oFields], async function() {
|
|
362
|
+
return execSpOp("PostItem", Object.assign(buildListContext(sSiteUrl, sListId), {
|
|
363
|
+
item: requireRecord(oFields, "item payload"),
|
|
364
|
+
}));
|
|
212
365
|
});
|
|
213
366
|
}
|
|
214
367
|
|
|
215
368
|
// ── Update Item ────────────────────────────────────────────────
|
|
216
|
-
export async function
|
|
217
|
-
return
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
369
|
+
export async function updateSpItem(sSiteUrl, sListId, iItemId, oChangedFields) {
|
|
370
|
+
return _dbgWrap('updateSpItem', [sSiteUrl, sListId, iItemId, oChangedFields], async function() {
|
|
371
|
+
return execSpOp("PatchItem", Object.assign(buildListContext(sSiteUrl, sListId), {
|
|
372
|
+
id: requireItemId(iItemId),
|
|
373
|
+
item: requireRecord(oChangedFields, "item payload"),
|
|
374
|
+
}));
|
|
222
375
|
});
|
|
223
376
|
}
|
|
224
377
|
|
|
225
378
|
// ── Delete Item ────────────────────────────────────────────────
|
|
226
|
-
export async function
|
|
227
|
-
return
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
379
|
+
export async function deleteSpItem(sSiteUrl, sListId, iItemId) {
|
|
380
|
+
return _dbgWrap('deleteSpItem', [sSiteUrl, sListId, iItemId], async function() {
|
|
381
|
+
return execSpOp("DeleteItem", Object.assign(buildListContext(sSiteUrl, sListId), {
|
|
382
|
+
id: requireItemId(iItemId),
|
|
383
|
+
}));
|
|
231
384
|
});
|
|
232
385
|
}
|
|
233
386
|
|
|
234
|
-
// ═══════════════════════════════════════════════════════════════
|
|
235
|
-
// ITEMS (HTTP API — uses list name)
|
|
236
|
-
// ═══════════════════════════════════════════════════════════════
|
|
237
|
-
|
|
238
|
-
// ── Get Items by List Name ─────────────────────────────────────
|
|
239
|
-
export async function getItemsByName(sSiteUrl, sListName, { filter, orderBy, top, skip } = {}) {
|
|
240
|
-
let sUri = sSiteUrl + "/_api/web/lists/getbytitle('" + sListName + "')/items";
|
|
241
|
-
let aQuery = [];
|
|
242
|
-
if (filter) aQuery.push("$filter=" + filter);
|
|
243
|
-
if (orderBy) aQuery.push("$orderby=" + orderBy);
|
|
244
|
-
if (top != null) aQuery.push("$top=" + top);
|
|
245
|
-
if (skip != null) aQuery.push("$skip=" + skip);
|
|
246
|
-
if (aQuery.length > 0) sUri = sUri + "?" + aQuery.join("&");
|
|
247
|
-
return sendHttpRequest({ method: "GET", uri: sUri, headers: { Accept: "application/json;odata=nometadata" } });
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// ── Get Item by List Name ──────────────────────────────────────
|
|
251
|
-
export async function getItemByName(sSiteUrl, sListName, iItemId) {
|
|
252
|
-
let sUri = sSiteUrl + "/_api/web/lists/getbytitle('" + sListName + "')/items(" + iItemId + ")";
|
|
253
|
-
return sendHttpRequest({ method: "GET", uri: sUri, headers: { Accept: "application/json;odata=nometadata" } });
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// ── Create Item by List Name ───────────────────────────────────
|
|
257
|
-
export async function createItemByName(sSiteUrl, sListName, oFields) {
|
|
258
|
-
let sUri = sSiteUrl + "/_api/web/lists/getbytitle('" + sListName + "')/items";
|
|
259
|
-
return sendHttpRequest({ method: "POST", uri: sUri, headers: { Accept: "application/json;odata=nometadata", "Content-Type": "application/json;odata=nometadata" }, body: JSON.stringify(oFields) });
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// ── Update Item by List Name ───────────────────────────────────
|
|
263
|
-
export async function updateItemByName(sSiteUrl, sListName, iItemId, oChangedFields) {
|
|
264
|
-
let sUri = sSiteUrl + "/_api/web/lists/getbytitle('" + sListName + "')/items(" + iItemId + ")";
|
|
265
|
-
return sendHttpRequest({ method: "PATCH", uri: sUri, headers: { Accept: "application/json;odata=nometadata", "Content-Type": "application/json;odata=nometadata", "If-Match": "*" }, body: JSON.stringify(oChangedFields) });
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// ── Delete Item by List Name ───────────────────────────────────
|
|
269
|
-
export async function deleteItemByName(sSiteUrl, sListName, iItemId) {
|
|
270
|
-
let sUri = sSiteUrl + "/_api/web/lists/getbytitle('" + sListName + "')/items(" + iItemId + ")";
|
|
271
|
-
return sendHttpRequest({ method: "DELETE", uri: sUri, headers: { Accept: "application/json;odata=nometadata", "If-Match": "*" } });
|
|
272
|
-
}
|
|
273
|
-
|
|
274
387
|
// ═══════════════════════════════════════════════════════════════
|
|
275
388
|
// TABLES / LISTS
|
|
276
389
|
// ═══════════════════════════════════════════════════════════════
|
|
277
390
|
|
|
278
391
|
// ── List Tables (Lists) ────────────────────────────────────────
|
|
279
392
|
export async function listTables(sSiteUrl) {
|
|
280
|
-
return
|
|
281
|
-
|
|
393
|
+
return _dbgWrap('listTables', [sSiteUrl], async function() {
|
|
394
|
+
return normalizeCollection(await execSpOp("GetTables", {
|
|
395
|
+
siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
|
|
396
|
+
}));
|
|
282
397
|
});
|
|
283
398
|
}
|
|
284
399
|
|
|
285
400
|
// ── List Library (Document Libraries) ──────────────────────────
|
|
286
401
|
export async function listLibrary(sSiteUrl) {
|
|
287
|
-
return
|
|
288
|
-
|
|
402
|
+
return _dbgWrap('listLibrary', [sSiteUrl], async function() {
|
|
403
|
+
return execSpOp("GetDataSetsMetadata", {
|
|
404
|
+
siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
|
|
405
|
+
});
|
|
289
406
|
});
|
|
290
407
|
}
|
|
291
408
|
|
|
@@ -295,45 +412,55 @@ export async function listLibrary(sSiteUrl) {
|
|
|
295
412
|
|
|
296
413
|
// ── Create File ────────────────────────────────────────────────
|
|
297
414
|
export async function createFile(sSiteUrl, sLibraryName, sFileName, fileContent) {
|
|
298
|
-
return
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
415
|
+
return _dbgWrap('createFile', [sSiteUrl, sLibraryName, sFileName, fileContent], async function() {
|
|
416
|
+
return execSpOp("CreateFile", {
|
|
417
|
+
siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
|
|
418
|
+
folderPath: requireNonEmptyString(sLibraryName, "folder path"),
|
|
419
|
+
name: requireNonEmptyString(sFileName, "file name"),
|
|
302
420
|
body: fileContent,
|
|
303
421
|
});
|
|
422
|
+
});
|
|
304
423
|
}
|
|
305
424
|
|
|
306
425
|
// ── Update File ────────────────────────────────────────────────
|
|
307
426
|
export async function updateFile(sSiteUrl, sFileId, fileContent) {
|
|
308
|
-
return
|
|
309
|
-
|
|
310
|
-
|
|
427
|
+
return _dbgWrap('updateFile', [sSiteUrl, sFileId, fileContent], async function() {
|
|
428
|
+
return execSpOp("UpdateFile", {
|
|
429
|
+
siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
|
|
430
|
+
id: requireNonEmptyString(String(sFileId || ""), "file ID"),
|
|
311
431
|
body: fileContent,
|
|
312
432
|
});
|
|
433
|
+
});
|
|
313
434
|
}
|
|
314
435
|
|
|
315
436
|
// ── Delete File ────────────────────────────────────────────────
|
|
316
437
|
export async function deleteFile(sSiteUrl, sFileId) {
|
|
317
|
-
return
|
|
318
|
-
|
|
319
|
-
|
|
438
|
+
return _dbgWrap('deleteFile', [sSiteUrl, sFileId], async function() {
|
|
439
|
+
return execSpOp("DeleteFile", {
|
|
440
|
+
siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
|
|
441
|
+
id: requireNonEmptyString(String(sFileId || ""), "file ID"),
|
|
442
|
+
});
|
|
320
443
|
});
|
|
321
444
|
}
|
|
322
445
|
|
|
323
446
|
// ── Move File ──────────────────────────────────────────────────
|
|
324
447
|
export async function moveFile(sSiteUrl, sSourceFileId, sDestinationFolderPath, sNewFileName) {
|
|
325
|
-
return
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
448
|
+
return _dbgWrap('moveFile', [sSiteUrl, sSourceFileId, sDestinationFolderPath, sNewFileName], async function() {
|
|
449
|
+
return execSpOp("MoveFile", {
|
|
450
|
+
siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
|
|
451
|
+
id: requireNonEmptyString(String(sSourceFileId || ""), "source file ID"),
|
|
452
|
+
destinationFolderPath: requireNonEmptyString(sDestinationFolderPath, "destination folder path"),
|
|
329
453
|
newFileName: sNewFileName || "",
|
|
330
454
|
});
|
|
455
|
+
});
|
|
331
456
|
}
|
|
332
457
|
|
|
333
458
|
// ── Get File Metadata ──────────────────────────────────────────
|
|
334
459
|
export async function getFileMetadata(sSiteUrl, sFileId) {
|
|
335
|
-
return
|
|
336
|
-
|
|
337
|
-
|
|
460
|
+
return _dbgWrap('getFileMetadata', [sSiteUrl, sFileId], async function() {
|
|
461
|
+
return execSpOp("GetFileMetadata", {
|
|
462
|
+
siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
|
|
463
|
+
id: requireNonEmptyString(String(sFileId || ""), "file ID"),
|
|
338
464
|
});
|
|
339
|
-
}
|
|
465
|
+
});
|
|
466
|
+
}
|