codeapp-js 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/codeApp/dist/codeapp.js +326 -72
  2. package/codeApp/dist/icon-512.png +0 -0
  3. package/codeApp/dist/index.html +1 -0
  4. package/codeApp/dist/index.js +1 -1
  5. package/codeApp/dist/power-apps-data.js +2952 -2531
  6. package/codeApp/power.config.json +1 -1
  7. package/dev files/customConnector.js +98 -0
  8. package/dev files/dataverse.js +33 -7
  9. package/dev files/environmentVar.js +1 -1
  10. package/dev files/office365groups.js +1 -1
  11. package/dev files/office365users.js +1 -1
  12. package/dev files/outlook.js +1 -1
  13. package/dev files/power-apps-data.js +2952 -0
  14. package/dev files/sharepoint.js +1 -1
  15. package/examples/combined demo/dist/codeapp.js +1098 -0
  16. package/examples/combined demo/dist/index.js +470 -515
  17. package/examples/combined demo/dist/power-apps-data.js +3007 -2531
  18. package/examples/dataverse Demo/dist/codeapp.js +1085 -0
  19. package/examples/dataverse Demo/dist/index.js +38 -26
  20. package/examples/dataverse Demo/dist/power-apps-data.js +2912 -2531
  21. package/examples/groups Demo/dist/codeapp.js +1085 -0
  22. package/examples/groups Demo/dist/index.js +113 -113
  23. package/examples/groups Demo/dist/power-apps-data.js +2912 -2531
  24. package/examples/groups Demo/power.config.json +3 -2
  25. package/examples/kanban/dist/power-apps-data.js +2953 -2531
  26. package/examples/myProfile/dist/power-apps-data.js +2953 -2531
  27. package/examples/outlook Demo/dist/codeapp.js +1085 -0
  28. package/examples/outlook Demo/dist/index.js +39 -35
  29. package/examples/outlook Demo/dist/power-apps-data.js +2912 -2531
  30. package/examples/planning Poker/dist/power-apps-data.js +2953 -2531
  31. package/examples/sharePoint Demo/dist/codeapp.js +1085 -0
  32. package/examples/sharePoint Demo/dist/index.js +262 -269
  33. package/examples/sharePoint Demo/dist/power-apps-data.js +2912 -2531
  34. package/examples/solution explorer/agent/decision-log.md +27 -0
  35. package/examples/solution explorer/agent/mockup-01-swiss-grid.html +452 -0
  36. package/examples/solution explorer/agent/mockup-02-dark-glass.html +496 -0
  37. package/examples/solution explorer/agent/mockup-03-paper-console.html +510 -0
  38. package/examples/solution explorer/agent/mockup-04-neon-noir.html +546 -0
  39. package/examples/solution explorer/agent/mockup-05-zen-garden.html +534 -0
  40. package/examples/solution explorer/dist/codeapp.js +1098 -0
  41. package/examples/solution explorer/dist/icon-512.png +0 -0
  42. package/examples/solution explorer/dist/index.html +80 -0
  43. package/examples/solution explorer/dist/index.js +735 -0
  44. package/examples/solution explorer/dist/power-apps-data.js +3007 -0
  45. package/examples/solution explorer/dist/styles.css +571 -0
  46. package/examples/solution explorer/power.config.json +151 -0
  47. package/examples/todo/dist/power-apps-data.js +2953 -2531
  48. package/package.json +1 -8
  49. package/.github/instructions/wyattdave.instructions.md +0 -39
  50. package/examples/combined demo/dist/dataverse.js +0 -86
  51. package/examples/combined demo/dist/environmentVar.js +0 -55
  52. package/examples/combined demo/dist/office365groups.js +0 -97
  53. package/examples/combined demo/dist/office365users.js +0 -169
  54. package/examples/combined demo/dist/outlook.js +0 -162
  55. package/examples/combined demo/dist/sharepoint.js +0 -339
  56. package/examples/dataverse Demo/dist/dataverse.js +0 -86
  57. package/examples/groups Demo/dist/dataverse.js +0 -86
  58. package/examples/groups Demo/dist/environmentVar.js +0 -55
  59. package/examples/groups Demo/dist/office365groups.js +0 -97
  60. package/examples/groups Demo/dist/office365users.js +0 -169
  61. package/examples/groups Demo/dist/outlook.js +0 -162
  62. package/examples/groups Demo/dist/sharepoint.js +0 -339
  63. package/examples/sharePoint Demo/dist/dataverse.js +0 -94
  64. package/examples/sharePoint Demo/dist/environmentVar.js +0 -55
  65. package/examples/sharePoint Demo/dist/office365groups.js +0 -97
  66. package/examples/sharePoint Demo/dist/office365users.js +0 -169
  67. package/examples/sharePoint Demo/dist/outlook.js +0 -162
  68. package/examples/sharePoint Demo/dist/sharepoint.js +0 -339
  69. package/scripts/build-power-sdk.mjs +0 -69
@@ -1,169 +0,0 @@
1
- import { getClient } from "@microsoft/power-apps/data";
2
-
3
- // ── Data source name (must match connectionReferences in power.config.json) ──
4
- const DATA_SOURCE = "office365users";
5
-
6
- // ── Initialize SDK client for the Office 365 Users connector ───
7
- function initClient() {
8
- const dataSourcesInfo = {
9
- [DATA_SOURCE]: {
10
- tableId: "",
11
- version: "",
12
- primaryKey: "",
13
- dataSourceType: "Connector",
14
- apis: {
15
- MyProfile_V2: {
16
- path: "/{connectionId}/codeless/v1.0/me",
17
- method: "GET",
18
- parameters: [
19
- { name: "connectionId", in: "path", required: true },
20
- ],
21
- },
22
- UserProfile_V2: {
23
- path: "/{connectionId}/codeless/v1.0/users/{id}",
24
- method: "GET",
25
- parameters: [
26
- { name: "connectionId", in: "path", required: true },
27
- { name: "id", in: "path", required: true },
28
- ],
29
- },
30
- Manager_V2: {
31
- path: "/{connectionId}/codeless/v1.0/users/{id}/manager",
32
- method: "GET",
33
- parameters: [
34
- { name: "connectionId", in: "path", required: true },
35
- { name: "id", in: "path", required: true },
36
- ],
37
- },
38
- DirectReports_V2: {
39
- path: "/{connectionId}/codeless/v1.0/users/{id}/directReports",
40
- method: "GET",
41
- parameters: [
42
- { name: "connectionId", in: "path", required: true },
43
- { name: "id", in: "path", required: true },
44
- ],
45
- },
46
- UserPhoto_V2: {
47
- path: "/{connectionId}/codeless/v1.0/users/{id}/photo/$value",
48
- method: "GET",
49
- parameters: [
50
- { name: "connectionId", in: "path", required: true },
51
- { name: "id", in: "path", required: true },
52
- ],
53
- responseInfo: { "200": "image/jpeg" },
54
- },
55
- SearchUser_V2: {
56
- path: "/{connectionId}/codeless/v1.0/users",
57
- method: "GET",
58
- parameters: [
59
- { name: "connectionId", in: "path", required: true },
60
- { name: "searchTerm", in: "query", required: false },
61
- { name: "$top", in: "query", required: false },
62
- { name: "$skip", in: "query", required: false },
63
- ],
64
- },
65
- HttpRequest: {
66
- path: "/{connectionId}/codeless/v1.0/httprequest",
67
- method: "POST",
68
- parameters: [
69
- { name: "connectionId", in: "path", required: true },
70
- ],
71
- },
72
- },
73
- },
74
- };
75
- return getClient(dataSourcesInfo);
76
- }
77
-
78
- // ── Internal: execute a connector operation ────────────────────
79
- async function execOp(operationName, parameters) {
80
- const client = await initClient();
81
- const result = await client.executeAsync({
82
- connectorOperation: {
83
- tableName: DATA_SOURCE,
84
- operationName,
85
- parameters,
86
- },
87
- });
88
- if (!result.success) {
89
- throw new Error(result.error?.message || "Operation failed");
90
- }
91
- return result.data;
92
- }
93
-
94
- // ═══════════════════════════════════════════════════════════════
95
- // GENERIC
96
- // ═══════════════════════════════════════════════════════════════
97
-
98
- // ── Call any Office 365 Users operation by name ────────────────
99
- export async function callUsersOperation(operationName, parameters = {}) {
100
- return execOp(operationName, parameters);
101
- }
102
-
103
- // ── Open HTTP Request ──────────────────────────────────────────
104
- export async function openHttpRequest({ method = "GET", uri, headers, body }) {
105
- return execOp("HttpRequest", {
106
- method,
107
- uri,
108
- headers: headers || {},
109
- body: body || "",
110
- });
111
- }
112
-
113
- // ═══════════════════════════════════════════════════════════════
114
- // PROFILE
115
- // ═══════════════════════════════════════════════════════════════
116
-
117
- // ── Get My Profile ─────────────────────────────────────────────
118
- export async function getMyProfile() {
119
- return execOp("MyProfile_V2", {});
120
- }
121
-
122
- // ── Get User Profile ───────────────────────────────────────────
123
- export async function getUserProfile(userId) {
124
- return execOp("UserProfile_V2", {
125
- id: userId,
126
- });
127
- }
128
-
129
- // ═══════════════════════════════════════════════════════════════
130
- // MANAGER & REPORTS
131
- // ═══════════════════════════════════════════════════════════════
132
-
133
- // ── Get Manager ────────────────────────────────────────────────
134
- export async function getManager(userId) {
135
- return execOp("Manager_V2", {
136
- id: userId,
137
- });
138
- }
139
-
140
- // ── Get Direct Reports ─────────────────────────────────────────
141
- export async function getDirectReports(userId) {
142
- return execOp("DirectReports_V2", {
143
- id: userId,
144
- });
145
- }
146
-
147
- // ═══════════════════════════════════════════════════════════════
148
- // PHOTO
149
- // ═══════════════════════════════════════════════════════════════
150
-
151
- // ── Get User Photo ─────────────────────────────────────────────
152
- export async function getUserPhoto(userId) {
153
- return execOp("UserPhoto_V2", {
154
- id: userId,
155
- });
156
- }
157
-
158
- // ═══════════════════════════════════════════════════════════════
159
- // SEARCH
160
- // ═══════════════════════════════════════════════════════════════
161
-
162
- // ── Search for Users ───────────────────────────────────────────
163
- export async function searchForUsers({ searchTerm, top, skip } = {}) {
164
- const params = {};
165
- if (searchTerm) params.searchTerm = searchTerm;
166
- if (top != null) params.$top = top;
167
- if (skip != null) params.$skip = skip;
168
- return execOp("SearchUser_V2", params);
169
- }
@@ -1,162 +0,0 @@
1
- import { getClient } from "@microsoft/power-apps/data";
2
-
3
- // ── Data source name (must match connectionReferences in power.config.json) ──
4
- const DATA_SOURCE = "Office365Outlook";
5
-
6
- // ── Initialize SDK client for the Office 365 Outlook connector ──
7
- function initClient() {
8
- const dataSourcesInfo = {
9
- [DATA_SOURCE]: {
10
- tableId: "",
11
- version: "",
12
- primaryKey: "",
13
- dataSourceType: "Connector",
14
- apis: {},
15
- },
16
- };
17
- return getClient(dataSourcesInfo);
18
- }
19
-
20
- // ── Internal: execute a connector operation ────────────────────
21
- async function execOp(operationName, parameters) {
22
- const client = await initClient();
23
- return client.executeAsync({
24
- connectorOperation: {
25
- tableName: DATA_SOURCE,
26
- operationName,
27
- parameters,
28
- },
29
- });
30
- }
31
-
32
- // ═══════════════════════════════════════════════════════════════
33
- // GENERIC
34
- // ═══════════════════════════════════════════════════════════════
35
-
36
- // ── Call any Outlook connector operation by name ───────────────
37
- export async function callOutlookOperation(operationName, parameters = {}) {
38
- return execOp(operationName, parameters);
39
- }
40
-
41
- // ═══════════════════════════════════════════════════════════════
42
- // MAIL
43
- // ═══════════════════════════════════════════════════════════════
44
-
45
- // ── Send Email ─────────────────────────────────────────────────
46
- export async function sendEmail({ to, cc, bcc, subject, body, isHtml = true, importance = "Normal", attachments }) {
47
- return execOp("SendEmailV2", {
48
- "emailMessage/To": to,
49
- "emailMessage/Subject": subject,
50
- "emailMessage/Body": body,
51
- "emailMessage/Cc": cc || "",
52
- "emailMessage/Bcc": bcc || "",
53
- "emailMessage/Importance": importance,
54
- "emailMessage/IsHtml": isHtml,
55
- "emailMessage/Attachments": attachments || [],
56
- });
57
- }
58
-
59
- // ── Forward Email ──────────────────────────────────────────────
60
- export async function forwardEmail(messageId, { to, comment = "" }) {
61
- return execOp("ForwardEmailV2", {
62
- message_id: messageId,
63
- "emailMessage/To": to,
64
- "emailMessage/Comment": comment,
65
- });
66
- }
67
-
68
- // ── Reply to Email ─────────────────────────────────────────────
69
- export async function replyToEmail(messageId, { comment, replyAll = false }) {
70
- return execOp(replyAll ? "ReplyAllToV3" : "ReplyToV3", {
71
- message_id: messageId,
72
- comment,
73
- });
74
- }
75
-
76
- // ── List Emails ────────────────────────────────────────────────
77
- export async function listEmails({ folderId = "Inbox", fetchOnlyUnread, searchQuery, top, skip } = {}) {
78
- const params = { folderPath: folderId };
79
- if (fetchOnlyUnread != null) params.fetchOnlyUnread = fetchOnlyUnread;
80
- if (searchQuery) params.searchQuery = searchQuery;
81
- if (top != null) params.top = top;
82
- if (skip != null) params.skip = skip;
83
- return execOp("GetEmailsV3", params);
84
- }
85
-
86
- // ── Send from Shared Mailbox ───────────────────────────────────
87
- export async function sendFromSharedMailbox(sharedMailbox, { to, cc, bcc, subject, body, isHtml = true, importance = "Normal", attachments }) {
88
- return execOp("SharedMailboxSendEmailV2", {
89
- "emailMessage/To": to,
90
- "emailMessage/Subject": subject,
91
- "emailMessage/Body": body,
92
- "emailMessage/Cc": cc || "",
93
- "emailMessage/Bcc": bcc || "",
94
- "emailMessage/Importance": importance,
95
- "emailMessage/IsHtml": isHtml,
96
- "emailMessage/Attachments": attachments || [],
97
- mailboxAddress: sharedMailbox,
98
- });
99
- }
100
-
101
- // ── Move Email ─────────────────────────────────────────────────
102
- export async function moveEmail(messageId, destinationFolderId) {
103
- return execOp("MoveEmailV2", {
104
- message_id: messageId,
105
- folderPath: destinationFolderId,
106
- });
107
- }
108
-
109
- // ── Delete Email ───────────────────────────────────────────────
110
- export async function deleteEmail(messageId) {
111
- return execOp("DeleteEmailV2", {
112
- message_id: messageId,
113
- });
114
- }
115
-
116
- // ═══════════════════════════════════════════════════════════════
117
- // CALENDAR
118
- // ═══════════════════════════════════════════════════════════════
119
-
120
- // ── Create Event ───────────────────────────────────────────────
121
- export async function createEvent({ calendarId = "Calendar", subject, body, start, end, location, attendees, isAllDay = false, importance = "Normal", isHtml = true, timeZone = "UTC" }) {
122
- return execOp("V4CalendarPostItem", {
123
- table: calendarId,
124
- "item/subject": subject,
125
- "item/body": body || "",
126
- "item/start": start,
127
- "item/end": end,
128
- "item/timeZone": timeZone,
129
- "item/location": location || "",
130
- "item/requiredAttendees": Array.isArray(attendees) ? attendees.join(";") : (attendees || ""),
131
- "item/isAllDay": isAllDay,
132
- "item/importance": importance,
133
- "item/isHtml": isHtml,
134
- });
135
- }
136
-
137
- // ── List Events ────────────────────────────────────────────────
138
- export async function listEvents({ calendarId = "Calendar", filter, orderBy, top, skip } = {}) {
139
- const params = { table: calendarId };
140
- if (filter) params.$filter = filter;
141
- if (orderBy) params.$orderby = orderBy;
142
- if (top != null) params.$top = top;
143
- if (skip != null) params.$skip = skip;
144
- return execOp("V2CalendarGetItems", params);
145
- }
146
-
147
- // ── Edit Event ─────────────────────────────────────────────────
148
- export async function editEvent(eventId, changedFields, calendarId = "Calendar") {
149
- return execOp("V4CalendarPatchItem", {
150
- table: calendarId,
151
- id: eventId,
152
- ...changedFields,
153
- });
154
- }
155
-
156
- // ── Delete Event ───────────────────────────────────────────────
157
- export async function deleteEvent(eventId, calendarId = "Calendar") {
158
- return execOp("V2CalendarDeleteItem", {
159
- table: calendarId,
160
- id: eventId,
161
- });
162
- }
@@ -1,339 +0,0 @@
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
- const client = await initClient();
151
- const result = await client.executeAsync({
152
- connectorOperation: {
153
- tableName: DATA_SOURCE,
154
- operationName,
155
- parameters,
156
- },
157
- });
158
- if (!result.success) {
159
- throw new Error(result.error?.message || "Operation failed");
160
- }
161
- return result.data;
162
- }
163
-
164
- // ═══════════════════════════════════════════════════════════════
165
- // GENERIC
166
- // ═══════════════════════════════════════════════════════════════
167
-
168
- // ── Call any SharePoint connector operation by name ─────────────
169
- export async function callSharePointOperation(operationName, parameters = {}) {
170
- return execOp(operationName, parameters);
171
- }
172
-
173
- // ── Send HTTP Request (for list-name-based operations) ─────────
174
- export async function sendHttpRequest({ method = "GET", uri, headers, body }) {
175
- return execOp("HttpRequest", {
176
- method,
177
- uri,
178
- headers: headers || {},
179
- body: body || "",
180
- });
181
- }
182
-
183
- // ═══════════════════════════════════════════════════════════════
184
- // ITEMS (standard API — uses list ID)
185
- // ═══════════════════════════════════════════════════════════════
186
-
187
- // ── Get Items ──────────────────────────────────────────────────
188
- export async function getItems(sSiteUrl, sListId, { filter, orderBy, top, skip } = {}) {
189
- let params = { siteUrl: encodeURIComponent(sSiteUrl), table: sListId };
190
- if (filter) params.$filter = filter;
191
- if (orderBy) params.$orderby = orderBy;
192
- if (top != null) params.$top = top;
193
- if (skip != null) params.$skip = skip;
194
- return execOp("GetItems", params);
195
- }
196
-
197
- // ── Get Item ───────────────────────────────────────────────────
198
- export async function getItem(sSiteUrl, sListId, iItemId) {
199
- return execOp("GetItem", {
200
- siteUrl: encodeURIComponent(sSiteUrl),
201
- table: sListId,
202
- id: iItemId,
203
- });
204
- }
205
-
206
- // ── Create Item ────────────────────────────────────────────────
207
- export async function createItem(sSiteUrl, sListId, oFields) {
208
- return execOp("PostItem", {
209
- siteUrl: encodeURIComponent(sSiteUrl),
210
- table: sListId,
211
- item: oFields,
212
- });
213
- }
214
-
215
- // ── Update Item ────────────────────────────────────────────────
216
- export async function updateItem(sSiteUrl, sListId, iItemId, oChangedFields) {
217
- return execOp("PatchItem", {
218
- siteUrl: encodeURIComponent(sSiteUrl),
219
- table: sListId,
220
- id: iItemId,
221
- item: oChangedFields,
222
- });
223
- }
224
-
225
- // ── Delete Item ────────────────────────────────────────────────
226
- export async function deleteItem(sSiteUrl, sListId, iItemId) {
227
- return execOp("DeleteItem", {
228
- siteUrl: encodeURIComponent(sSiteUrl),
229
- table: sListId,
230
- id: iItemId,
231
- });
232
- }
233
-
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
- // ═══════════════════════════════════════════════════════════════
275
- // TABLES / LISTS
276
- // ═══════════════════════════════════════════════════════════════
277
-
278
- // ── List Tables (Lists) ────────────────────────────────────────
279
- export async function listTables(sSiteUrl) {
280
- return execOp("GetTables", {
281
- siteUrl: encodeURIComponent(sSiteUrl),
282
- });
283
- }
284
-
285
- // ── List Library (Document Libraries) ──────────────────────────
286
- export async function listLibrary(sSiteUrl) {
287
- return execOp("GetDataSetsMetadata", {
288
- siteUrl: encodeURIComponent(sSiteUrl),
289
- });
290
- }
291
-
292
- // ═══════════════════════════════════════════════════════════════
293
- // FILES
294
- // ═══════════════════════════════════════════════════════════════
295
-
296
- // ── Create File ────────────────────────────────────────────────
297
- export async function createFile(sSiteUrl, sLibraryName, sFileName, fileContent) {
298
- return execOp("CreateFile", {
299
- siteUrl: encodeURIComponent(sSiteUrl),
300
- folderPath: sLibraryName,
301
- name: sFileName,
302
- body: fileContent,
303
- });
304
- }
305
-
306
- // ── Update File ────────────────────────────────────────────────
307
- export async function updateFile(sSiteUrl, sFileId, fileContent) {
308
- return execOp("UpdateFile", {
309
- siteUrl: encodeURIComponent(sSiteUrl),
310
- id: sFileId,
311
- body: fileContent,
312
- });
313
- }
314
-
315
- // ── Delete File ────────────────────────────────────────────────
316
- export async function deleteFile(sSiteUrl, sFileId) {
317
- return execOp("DeleteFile", {
318
- siteUrl: encodeURIComponent(sSiteUrl),
319
- id: sFileId,
320
- });
321
- }
322
-
323
- // ── Move File ──────────────────────────────────────────────────
324
- export async function moveFile(sSiteUrl, sSourceFileId, sDestinationFolderPath, sNewFileName) {
325
- return execOp("MoveFile", {
326
- siteUrl: encodeURIComponent(sSiteUrl),
327
- id: sSourceFileId,
328
- destinationFolderPath: sDestinationFolderPath,
329
- newFileName: sNewFileName || "",
330
- });
331
- }
332
-
333
- // ── Get File Metadata ──────────────────────────────────────────
334
- export async function getFileMetadata(sSiteUrl, sFileId) {
335
- return execOp("GetFileMetadata", {
336
- siteUrl: encodeURIComponent(sSiteUrl),
337
- id: sFileId,
338
- });
339
- }