codeapp-js 1.0.2 → 1.1.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.
Files changed (128) hide show
  1. package/AI/skills/autoreview/SKILL.md +69 -0
  2. package/AI/skills/connections/SKILL.md +4 -4
  3. package/AI/skills/dataverse/SKILL.md +4 -2
  4. package/AI/skills/keyvault/SKILL.md +139 -0
  5. package/AI/skills/office365-groups/SKILL.md +46 -25
  6. package/AI/skills/office365-outlook/SKILL.md +56 -25
  7. package/AI/skills/office365-users/SKILL.md +41 -36
  8. package/AI/skills/sharepoint/SKILL.md +174 -31
  9. package/AI/skills/start/SKILL.md +1 -0
  10. package/codeApp/dist/connectors/autoreview.js +1654 -0
  11. package/codeApp/dist/connectors/office365groups.js +2995 -432
  12. package/{examples/outlook Demo/.power/schemas/office365/office365.Schema.json → codeApp/dist/connectors/office365outlook.js} +7439 -16
  13. package/codeApp/dist/connectors/office365users.js +2990 -349
  14. package/codeApp/dist/connectors/sharepoint.js +529 -308
  15. package/examples/combined demo/dist/connectors/office365outlook.js +28521 -0
  16. package/examples/combined demo/dist/connectors/office365users.js +3154 -0
  17. package/examples/combined demo/dist/index.js +2 -6
  18. package/examples/combined demo/power.config.json +1 -1
  19. package/examples/groups Demo/{.power/schemas/office365groups/office365groups.Schema.json → dist/connectors/office365groups.js } +3205 -2204
  20. package/examples/groups Demo/dist/index.js +1 -5
  21. package/examples/groups Demo/power.config.json +1 -1
  22. package/examples/myProfile/dist/connectors/office365users.js +3154 -0
  23. package/examples/myProfile/dist/index.js +1 -5
  24. package/examples/myProfile/power.config.json +1 -1
  25. package/examples/outlook Demo/dist/connectors/office365outlook.js +28521 -0
  26. package/examples/outlook Demo/dist/index.js +2 -5
  27. package/examples/outlook Demo/power.config.json +1 -1
  28. package/examples/sharePoint Demo/dist/connectors/sharepoint.js +687 -0
  29. package/examples/sharePoint Demo/dist/index.js +86 -127
  30. package/examples/sharePoint Demo/power.config.json +1 -1
  31. package/package.json +1 -1
  32. package/codeApp/.power/schemas/appschemas/dataSourcesInfo.ts +0 -6275
  33. package/codeApp/.power/schemas/jira/jira.Schema.json +0 -6903
  34. package/codeApp/.power/schemas/keyvault/keyvault.Schema.json +0 -1600
  35. package/codeApp/.power/schemas/office365groups/office365groups.Schema.json +0 -2204
  36. package/codeApp/.power/schemas/teams/teams.Schema.json +0 -11112
  37. package/codeApp/dist/connectors/outlook.js +0 -1393
  38. package/codeApp/src/generated/models/AzureKeyVaultModel.ts +0 -107
  39. package/codeApp/src/generated/models/JiraModel.ts +0 -501
  40. package/codeApp/src/generated/models/Office365GroupsModel.ts +0 -363
  41. package/codeApp/src/generated/models/Office365OutlookModel.ts +0 -2046
  42. package/codeApp/src/generated/models/Office365UsersModel.ts +0 -254
  43. package/codeApp/src/generated/services/AzureKeyVaultService.ts +0 -257
  44. package/codeApp/src/generated/services/JiraService.ts +0 -1124
  45. package/codeApp/src/generated/services/Office365GroupsService.ts +0 -326
  46. package/codeApp/src/generated/services/Office365OutlookService.ts +0 -2476
  47. package/codeApp/src/generated/services/Office365UsersService.ts +0 -358
  48. package/examples/apps/kanban/dist/dataverse.js +0 -94
  49. package/examples/apps/kanban/dist/environmentVar.js +0 -55
  50. package/examples/apps/kanban/dist/index.css +0 -605
  51. package/examples/apps/kanban/dist/index.html +0 -21
  52. package/examples/apps/kanban/dist/index.js +0 -860
  53. package/examples/apps/kanban/dist/office365groups.js +0 -97
  54. package/examples/apps/kanban/dist/office365users.js +0 -451
  55. package/examples/apps/kanban/dist/outlook.js +0 -162
  56. package/examples/apps/kanban/dist/power-apps-data.js +0 -2953
  57. package/examples/apps/kanban/dist/sharepoint.js +0 -435
  58. package/examples/apps/kanban/power.config.json +0 -35
  59. package/examples/apps/kanban/src/generated/index.ts +0 -14
  60. package/examples/apps/kanban/src/generated/models/Office365GroupsModel.ts +0 -363
  61. package/examples/apps/kanban/src/generated/models/Office365OutlookModel.ts +0 -2046
  62. package/examples/apps/kanban/src/generated/models/Office365UsersModel.ts +0 -254
  63. package/examples/apps/kanban/src/generated/services/Office365GroupsService.ts +0 -326
  64. package/examples/apps/kanban/src/generated/services/Office365OutlookService.ts +0 -2476
  65. package/examples/apps/kanban/src/generated/services/Office365UsersService.ts +0 -358
  66. package/examples/apps/planning Poker/additional files/AgilePoker_1_0_0_1.zip +0 -0
  67. package/examples/apps/planning Poker/additional files/PokerTables_1_0_0_1.zip +0 -0
  68. package/examples/apps/planning Poker/additional files/customizations (tables).xml +0 -6429
  69. package/examples/apps/planning Poker/additional files/dataverse-tables.json +0 -165
  70. package/examples/apps/planning Poker/additional files/readme.md +0 -122
  71. package/examples/apps/planning Poker/dist/dataverse.js +0 -78
  72. package/examples/apps/planning Poker/dist/index.html +0 -198
  73. package/examples/apps/planning Poker/dist/index.js +0 -955
  74. package/examples/apps/planning Poker/dist/power-apps-data.js +0 -2953
  75. package/examples/apps/planning Poker/dist/styles.css +0 -815
  76. package/examples/apps/planning Poker/power.config.json +0 -50
  77. package/examples/apps/solution explorer/dist/codeapp.js +0 -1098
  78. package/examples/apps/solution explorer/dist/icon-512.png +0 -0
  79. package/examples/apps/solution explorer/dist/index.html +0 -80
  80. package/examples/apps/solution explorer/dist/index.js +0 -735
  81. package/examples/apps/solution explorer/dist/power-apps-data.js +0 -3007
  82. package/examples/apps/solution explorer/dist/styles.css +0 -571
  83. package/examples/apps/solution explorer/power.config.json +0 -151
  84. package/examples/apps/todo/dist/dataverse.js +0 -64
  85. package/examples/apps/todo/dist/icon192.png +0 -0
  86. package/examples/apps/todo/dist/index.html +0 -75
  87. package/examples/apps/todo/dist/index.js +0 -9
  88. package/examples/apps/todo/dist/power-apps-data.js +0 -2953
  89. package/examples/apps/todo/dist/renderer.js +0 -375
  90. package/examples/apps/todo/dist/styles.css +0 -691
  91. package/examples/apps/todo/power.config.json +0 -35
  92. package/examples/combined demo/.power/schemas/appschemas/dataSourcesInfo.ts +0 -6275
  93. package/examples/combined demo/.power/schemas/jira/jira.Schema.json +0 -6903
  94. package/examples/combined demo/.power/schemas/keyvault/keyvault.Schema.json +0 -1600
  95. package/examples/combined demo/.power/schemas/teams/teams.Schema.json +0 -11112
  96. package/examples/combined demo/dist/office365users.js +0 -513
  97. package/examples/combined demo/dist/outlook.js +0 -1393
  98. package/examples/combined demo/src/generated/index.ts +0 -12
  99. package/examples/combined demo/src/generated/models/AzureKeyVaultModel.ts +0 -107
  100. package/examples/combined demo/src/generated/models/JiraModel.ts +0 -501
  101. package/examples/combined demo/src/generated/models/Office365GroupsModel.ts +0 -363
  102. package/examples/combined demo/src/generated/models/Office365OutlookModel.ts +0 -2046
  103. package/examples/combined demo/src/generated/models/Office365UsersModel.ts +0 -254
  104. package/examples/combined demo/src/generated/services/AzureKeyVaultService.ts +0 -257
  105. package/examples/combined demo/src/generated/services/JiraService.ts +0 -1124
  106. package/examples/combined demo/src/generated/services/Office365GroupsService.ts +0 -326
  107. package/examples/combined demo/src/generated/services/Office365OutlookService.ts +0 -2476
  108. package/examples/combined demo/src/generated/services/Office365UsersService.ts +0 -358
  109. package/examples/groups Demo/.power/schemas/appschemas/dataSourcesInfo.ts +0 -613
  110. package/examples/groups Demo/dist/office365groups.js +0 -642
  111. package/examples/groups Demo/src/generated/index.ts +0 -10
  112. package/examples/groups Demo/src/generated/models/Office365GroupsModel.ts +0 -363
  113. package/examples/groups Demo/src/generated/services/Office365GroupsService.ts +0 -326
  114. package/examples/myProfile/dist/office365users.js +0 -517
  115. package/examples/outlook Demo/.power/schemas/appschemas/dataSourcesInfo.ts +0 -6512
  116. package/examples/outlook Demo/dist/outlook.js +0 -1393
  117. package/examples/outlook Demo/src/generated/index.ts +0 -10
  118. package/examples/outlook Demo/src/generated/models/Office365OutlookModel.ts +0 -2046
  119. package/examples/outlook Demo/src/generated/services/Office365OutlookService.ts +0 -2476
  120. package/examples/sharePoint Demo/dist/sharepoint.js +0 -466
  121. package/examples/sharePoint Demo/src/generated/index.ts +0 -14
  122. package/examples/sharePoint Demo/src/generated/models/Office365GroupsModel.ts +0 -363
  123. package/examples/sharePoint Demo/src/generated/models/Office365OutlookModel.ts +0 -2046
  124. package/examples/sharePoint Demo/src/generated/models/Office365UsersModel.ts +0 -254
  125. package/examples/sharePoint Demo/src/generated/services/Office365GroupsService.ts +0 -326
  126. package/examples/sharePoint Demo/src/generated/services/Office365OutlookService.ts +0 -2476
  127. package/examples/sharePoint Demo/src/generated/services/Office365UsersService.ts +0 -358
  128. package/readme.md +0 -590
@@ -1,186 +1,202 @@
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
- },
1
+ import { getClient } from '../power-apps-data.js';
2
+ import { _dbgWrap } from '../codeapp.js';
3
+
4
+ const DATA_SOURCE_NAME = 'sharepointonline';
5
+
6
+ const dataSourcesInfo = {
7
+ [DATA_SOURCE_NAME]: {
8
+ tableId: '',
9
+ version: '',
10
+ primaryKey: '',
11
+ dataSourceType: 'Connector',
12
+ apis: {
13
+ GetItems: {
14
+ path: '/{connectionId}/datasets/{siteUrl}/tables/{table}/items',
15
+ method: 'GET',
16
+ parameters: [
17
+ { name: 'connectionId', in: 'path', required: true, type: 'string' },
18
+ { name: 'siteUrl', in: 'path', required: true, type: 'string' },
19
+ { name: 'table', in: 'path', required: true, type: 'string' },
20
+ { name: '$filter', in: 'query', required: false, type: 'string' },
21
+ { name: '$orderby', in: 'query', required: false, type: 'string' },
22
+ { name: '$top', in: 'query', required: false, type: 'integer' },
23
+ { name: '$skip', in: 'query', required: false, type: 'integer' },
24
+ ],
25
+ },
26
+ GetItem: {
27
+ path: '/{connectionId}/datasets/{siteUrl}/tables/{table}/items/{id}',
28
+ method: 'GET',
29
+ parameters: [
30
+ { name: 'connectionId', in: 'path', required: true, type: 'string' },
31
+ { name: 'siteUrl', in: 'path', required: true, type: 'string' },
32
+ { name: 'table', in: 'path', required: true, type: 'string' },
33
+ { name: 'id', in: 'path', required: true, type: 'string' },
34
+ ],
35
+ },
36
+ PostItem: {
37
+ path: '/{connectionId}/datasets/{siteUrl}/tables/{table}/items',
38
+ method: 'POST',
39
+ parameters: [
40
+ { name: 'connectionId', in: 'path', required: true, type: 'string' },
41
+ { name: 'siteUrl', in: 'path', required: true, type: 'string' },
42
+ { name: 'table', in: 'path', required: true, type: 'string' },
43
+ { name: 'item', in: 'body', required: true, type: 'object' },
44
+ ],
45
+ },
46
+ PatchItem: {
47
+ path: '/{connectionId}/datasets/{siteUrl}/tables/{table}/items/{id}',
48
+ method: 'PATCH',
49
+ parameters: [
50
+ { name: 'connectionId', in: 'path', required: true, type: 'string' },
51
+ { name: 'siteUrl', in: 'path', required: true, type: 'string' },
52
+ { name: 'table', in: 'path', required: true, type: 'string' },
53
+ { name: 'id', in: 'path', required: true, type: 'string' },
54
+ { name: 'item', in: 'body', required: true, type: 'object' },
55
+ ],
56
+ },
57
+ DeleteItem: {
58
+ path: '/{connectionId}/datasets/{siteUrl}/tables/{table}/items/{id}',
59
+ method: 'DELETE',
60
+ parameters: [
61
+ { name: 'connectionId', in: 'path', required: true, type: 'string' },
62
+ { name: 'siteUrl', in: 'path', required: true, type: 'string' },
63
+ { name: 'table', in: 'path', required: true, type: 'string' },
64
+ { name: 'id', in: 'path', required: true, type: 'string' },
65
+ ],
66
+ },
67
+ GetTables: {
68
+ path: '/{connectionId}/datasets/{siteUrl}/tables',
69
+ method: 'GET',
70
+ parameters: [
71
+ { name: 'connectionId', in: 'path', required: true, type: 'string' },
72
+ { name: 'siteUrl', in: 'path', required: true, type: 'string' },
73
+ ],
74
+ },
75
+ GetDataSetsMetadata: {
76
+ path: '/{connectionId}/datasets/{siteUrl}',
77
+ method: 'GET',
78
+ parameters: [
79
+ { name: 'connectionId', in: 'path', required: true, type: 'string' },
80
+ { name: 'siteUrl', in: 'path', required: true, type: 'string' },
81
+ ],
82
+ },
83
+ CreateFile: {
84
+ path: '/{connectionId}/datasets/{siteUrl}/files',
85
+ method: 'POST',
86
+ parameters: [
87
+ { name: 'connectionId', in: 'path', required: true, type: 'string' },
88
+ { name: 'siteUrl', in: 'path', required: true, type: 'string' },
89
+ { name: 'folderPath', in: 'query', required: true, type: 'string' },
90
+ { name: 'name', in: 'query', required: true, type: 'string' },
91
+ { name: 'body', in: 'body', required: true, type: 'object' },
92
+ ],
93
+ },
94
+ UpdateFile: {
95
+ path: '/{connectionId}/datasets/{siteUrl}/files/{id}',
96
+ method: 'PUT',
97
+ parameters: [
98
+ { name: 'connectionId', in: 'path', required: true, type: 'string' },
99
+ { name: 'siteUrl', in: 'path', required: true, type: 'string' },
100
+ { name: 'id', in: 'path', required: true, type: 'string' },
101
+ { name: 'body', in: 'body', required: true, type: 'object' },
102
+ ],
103
+ },
104
+ DeleteFile: {
105
+ path: '/{connectionId}/datasets/{siteUrl}/files/{id}',
106
+ method: 'DELETE',
107
+ parameters: [
108
+ { name: 'connectionId', in: 'path', required: true, type: 'string' },
109
+ { name: 'siteUrl', in: 'path', required: true, type: 'string' },
110
+ { name: 'id', in: 'path', required: true, type: 'string' },
111
+ ],
112
+ },
113
+ MoveFile: {
114
+ path: '/{connectionId}/datasets/{siteUrl}/files/{id}/moveto',
115
+ method: 'POST',
116
+ parameters: [
117
+ { name: 'connectionId', in: 'path', required: true, type: 'string' },
118
+ { name: 'siteUrl', in: 'path', required: true, type: 'string' },
119
+ { name: 'id', in: 'path', required: true, type: 'string' },
120
+ { name: 'destinationFolderPath', in: 'query', required: true, type: 'string' },
121
+ { name: 'newFileName', in: 'query', required: false, type: 'string' },
122
+ ],
123
+ },
124
+ GetFileMetadata: {
125
+ path: '/{connectionId}/datasets/{siteUrl}/files/{id}',
126
+ method: 'GET',
127
+ parameters: [
128
+ { name: 'connectionId', in: 'path', required: true, type: 'string' },
129
+ { name: 'siteUrl', in: 'path', required: true, type: 'string' },
130
+ { name: 'id', in: 'path', required: true, type: 'string' },
131
+ ],
132
+ },
133
+ HttpRequest: {
134
+ path: '/{connectionId}/httprequest',
135
+ method: 'POST',
136
+ parameters: [
137
+ { name: 'connectionId', in: 'path', required: true, type: 'string' },
138
+ { name: 'method', in: 'body', required: true, type: 'string' },
139
+ { name: 'uri', in: 'body', required: true, type: 'string' },
140
+ { name: 'headers', in: 'body', required: false, type: 'object' },
141
+ { name: 'body', in: 'body', required: false, type: 'string' },
142
+ ],
146
143
  },
147
144
  },
148
- };
145
+ },
146
+ };
147
+
148
+ const sharePointListCache = new Map();
149
+
150
+ function initSharePointClient() {
149
151
  return getClient(dataSourcesInfo);
150
152
  }
151
153
 
152
- // ── Internal: execute a connector operation ────────────────────
153
- async function execSpOp(operationName, parameters) {
154
+ async function executeConnectorOperation(operationName, parameters = {}) {
154
155
  try {
155
- const client = await initSpClient();
156
- const result = await client.executeAsync({
156
+ const oClient = await initSharePointClient();
157
+ const oResult = await oClient.executeAsync({
157
158
  connectorOperation: {
158
- tableName: DATA_SOURCE_SP,
159
+ tableName: DATA_SOURCE_NAME,
159
160
  operationName,
160
- parameters: parameters || {},
161
+ parameters,
161
162
  },
162
163
  });
163
164
 
164
- if (!result) {
165
- throw new Error("No result returned");
165
+ if (!oResult) {
166
+ throw new Error('No result returned');
166
167
  }
167
168
 
168
- if (result.success === false) {
169
- throw new Error(getSpErrorMessage(result.error));
169
+ if (oResult.success === false) {
170
+ throw new Error(getSpErrorMessage(oResult.error));
170
171
  }
171
172
 
172
- return Object.prototype.hasOwnProperty.call(result, "data") ? result.data : result;
173
+ return Object.prototype.hasOwnProperty.call(oResult, 'data') ? oResult.data : oResult;
173
174
  } catch (oError) {
174
- throw new Error("SharePoint " + operationName + " failed: " + getSpErrorMessage(oError));
175
+ throw new Error('SharePoint ' + operationName + ' failed: ' + getSpErrorMessage(oError));
175
176
  }
176
177
  }
177
178
 
179
+ function pickSharePointValue() {
180
+ for (let iIndex = 0; iIndex < arguments.length; iIndex += 1) {
181
+ const oValue = arguments[iIndex];
182
+ if (oValue !== undefined && oValue !== null) {
183
+ return oValue;
184
+ }
185
+ }
186
+
187
+ return undefined;
188
+ }
189
+
190
+ function isSharePointRecord(oValue) {
191
+ return !!oValue && typeof oValue === 'object' && !Array.isArray(oValue);
192
+ }
193
+
178
194
  function getSpErrorMessage(oError) {
179
195
  if (!oError) {
180
- return "Unknown error";
196
+ return 'Unknown error';
181
197
  }
182
198
 
183
- if (typeof oError === "string") {
199
+ if (typeof oError === 'string') {
184
200
  return oError;
185
201
  }
186
202
 
@@ -197,10 +213,7 @@ function getSpErrorMessage(oError) {
197
213
  oError.detail,
198
214
  ];
199
215
 
200
- const sCandidate = aCandidates.find(function(sValue) {
201
- return typeof sValue === "string" && sValue.trim() !== "";
202
- });
203
-
216
+ const sCandidate = aCandidates.find((sValue) => typeof sValue === 'string' && sValue.trim() !== '');
204
217
  if (sCandidate) {
205
218
  return sCandidate;
206
219
  }
@@ -213,16 +226,16 @@ function getSpErrorMessage(oError) {
213
226
  }
214
227
 
215
228
  function requireNonEmptyString(sValue, sLabel) {
216
- if (typeof sValue !== "string" || sValue.trim() === "") {
217
- throw new Error("SharePoint " + sLabel + " is required.");
229
+ if (typeof sValue !== 'string' || sValue.trim() === '') {
230
+ throw new Error('SharePoint ' + sLabel + ' is required.');
218
231
  }
219
232
 
220
233
  return sValue.trim();
221
234
  }
222
235
 
223
236
  function requireRecord(oValue, sLabel) {
224
- if (!oValue || typeof oValue !== "object" || Array.isArray(oValue)) {
225
- throw new Error("SharePoint " + sLabel + " must be an object.");
237
+ if (!oValue || typeof oValue !== 'object' || Array.isArray(oValue)) {
238
+ throw new Error('SharePoint ' + sLabel + ' must be an object.');
226
239
  }
227
240
 
228
241
  return oValue;
@@ -233,60 +246,64 @@ function normalizeHeaders(oHeaders) {
233
246
  return {};
234
247
  }
235
248
 
236
- if (typeof oHeaders !== "object" || Array.isArray(oHeaders)) {
237
- throw new Error("SharePoint request headers must be an object.");
249
+ if (typeof oHeaders !== 'object' || Array.isArray(oHeaders)) {
250
+ throw new Error('SharePoint request headers must be an object.');
238
251
  }
239
252
 
240
253
  return oHeaders;
241
254
  }
242
255
 
243
256
  function normalizeNumericQueryValue(value, sLabel) {
244
- if (value == null || value === "") {
257
+ if (value == null || value === '') {
245
258
  return null;
246
259
  }
247
260
 
248
261
  const iValue = Number(value);
249
262
  if (!Number.isFinite(iValue)) {
250
- throw new Error("SharePoint " + sLabel + " must be numeric.");
263
+ throw new Error('SharePoint ' + sLabel + ' must be numeric.');
251
264
  }
252
265
 
253
266
  return iValue;
254
267
  }
255
268
 
256
269
  function requireItemId(iItemId) {
257
- if ((typeof iItemId !== "string" && typeof iItemId !== "number") || String(iItemId).trim() === "") {
258
- throw new Error("SharePoint item ID is required.");
270
+ if ((typeof iItemId !== 'string' && typeof iItemId !== 'number') || String(iItemId).trim() === '') {
271
+ throw new Error('SharePoint item ID is required.');
259
272
  }
260
273
 
261
274
  return iItemId;
262
275
  }
263
276
 
264
- function buildListContext(sSiteUrl, sListId) {
277
+ function buildSiteUrlParam(siteUrl) {
278
+ return encodeURIComponent(requireNonEmptyString(siteUrl, 'site URL'));
279
+ }
280
+
281
+ function buildListContext(siteUrl, listId) {
265
282
  return {
266
- siteUrl: encodeURIComponent(requireNonEmptyString(sSiteUrl, "site URL")),
267
- table: requireNonEmptyString(sListId, "list ID"),
283
+ siteUrl: buildSiteUrlParam(siteUrl),
284
+ table: requireNonEmptyString(String(listId || ''), 'list ID'),
268
285
  };
269
286
  }
270
287
 
271
- function buildItemQueryParameters(sSiteUrl, sListId, { filter, orderBy, top, skip } = {}) {
272
- const oParams = buildListContext(sSiteUrl, sListId);
288
+ function buildItemQueryParameters(siteUrl, listId, { filter, orderBy, top, skip } = {}) {
289
+ const oParameters = buildListContext(siteUrl, listId);
273
290
  if (filter) {
274
- oParams.$filter = String(filter);
291
+ oParameters.$filter = String(filter);
275
292
  }
276
293
  if (orderBy) {
277
- oParams.$orderby = String(orderBy);
294
+ oParameters.$orderby = String(orderBy);
278
295
  }
279
296
 
280
- const iTop = normalizeNumericQueryValue(top, "top");
281
- const iSkip = normalizeNumericQueryValue(skip, "skip");
297
+ const iTop = normalizeNumericQueryValue(top, 'top');
298
+ const iSkip = normalizeNumericQueryValue(skip, 'skip');
282
299
  if (iTop != null) {
283
- oParams.$top = iTop;
300
+ oParameters.$top = iTop;
284
301
  }
285
302
  if (iSkip != null) {
286
- oParams.$skip = iSkip;
303
+ oParameters.$skip = iSkip;
287
304
  }
288
305
 
289
- return oParams;
306
+ return oParameters;
290
307
  }
291
308
 
292
309
  function normalizeCollection(oPayload) {
@@ -306,161 +323,365 @@ function normalizeCollection(oPayload) {
306
323
  oPayload && oPayload.d && oPayload.d.results,
307
324
  ];
308
325
 
309
- const aMatch = aCandidates.find(function(oCandidate) {
310
- return Array.isArray(oCandidate);
311
- });
312
-
326
+ const aMatch = aCandidates.find((oCandidate) => Array.isArray(oCandidate));
313
327
  return aMatch || [];
314
328
  }
315
329
 
316
- // ═══════════════════════════════════════════════════════════════
317
- // GENERIC
318
- // ═══════════════════════════════════════════════════════════════
330
+ function normalizeSharePointLookupValue(value) {
331
+ if (value === undefined || value === null) {
332
+ return '';
333
+ }
319
334
 
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
- });
335
+ return String(value).trim().toLowerCase();
325
336
  }
326
337
 
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
- });
338
+ function normalizeSharePointListReference(listReference) {
339
+ if (typeof listReference === 'string' || typeof listReference === 'number') {
340
+ const sValue = String(listReference).trim();
341
+ if (!sValue) {
342
+ throw new Error('SharePoint list reference is required.');
343
+ }
344
+
345
+ return { listName: sValue };
346
+ }
347
+
348
+ if (!isSharePointRecord(listReference)) {
349
+ throw new Error('SharePoint list reference must be a string or object.');
350
+ }
351
+
352
+ return listReference;
337
353
  }
338
354
 
339
- // ═══════════════════════════════════════════════════════════════
340
- // ITEMS (standard API — uses list ID)
341
- // ═══════════════════════════════════════════════════════════════
355
+ function getSharePointTableToken(oTable) {
356
+ const sCandidate = pickSharePointValue(
357
+ oTable && oTable.Name,
358
+ oTable && oTable.name,
359
+ oTable && oTable.table,
360
+ oTable && oTable.TableName,
361
+ oTable && oTable.tableName,
362
+ oTable && oTable.LogicalName,
363
+ oTable && oTable.logicalName
364
+ );
365
+
366
+ return typeof sCandidate === 'string' ? sCandidate.trim() : '';
367
+ }
342
368
 
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
- });
369
+ function getSharePointExternalListId(oTable) {
370
+ const sCandidate = pickSharePointValue(
371
+ oTable && oTable.Id,
372
+ oTable && oTable.id,
373
+ oTable && oTable.TableId,
374
+ oTable && oTable.tableId,
375
+ oTable && oTable.ListId,
376
+ oTable && oTable.listId,
377
+ oTable && oTable.UniqueId,
378
+ oTable && oTable.uniqueId,
379
+ getSharePointTableToken(oTable)
380
+ );
381
+
382
+ return typeof sCandidate === 'string' ? sCandidate.trim() : '';
348
383
  }
349
384
 
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
- });
385
+ function getSharePointTableNames(oTable) {
386
+ const aCandidates = [
387
+ oTable && oTable.DisplayName,
388
+ oTable && oTable.displayName,
389
+ oTable && oTable.Title,
390
+ oTable && oTable.title,
391
+ oTable && oTable.ListName,
392
+ oTable && oTable.listName,
393
+ oTable && oTable.Name,
394
+ oTable && oTable.name,
395
+ ];
396
+
397
+ return aCandidates
398
+ .filter((sValue, iIndex, aValues) => typeof sValue === 'string' && sValue.trim() !== '' && aValues.indexOf(sValue) === iIndex)
399
+ .map((sValue) => sValue.trim());
357
400
  }
358
401
 
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
- });
402
+ function getSharePointPreferredListName(oTable, sFallback) {
403
+ return pickSharePointValue(...getSharePointTableNames(oTable), sFallback, '');
366
404
  }
367
405
 
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
- });
406
+ function getSharePointListCacheKey(siteUrl, { listId, listName } = {}) {
407
+ return [
408
+ buildSiteUrlParam(siteUrl),
409
+ normalizeSharePointLookupValue(listId),
410
+ normalizeSharePointLookupValue(listName),
411
+ ].join('::');
376
412
  }
377
413
 
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
- });
414
+ function createResolvedSharePointList(siteUrl, oTable, { listId, listName, accessLabel, matchedBy } = {}) {
415
+ const sSiteUrl = requireNonEmptyString(siteUrl, 'site URL');
416
+ const sTableToken = requireNonEmptyString(getSharePointTableToken(oTable) || getSharePointExternalListId(oTable), 'table token');
417
+ const sResolvedListId = requireNonEmptyString(getSharePointExternalListId(oTable) || listId || sTableToken, 'list ID');
418
+ const sResolvedListName = getSharePointPreferredListName(oTable, listName || sResolvedListId);
419
+ const sAccessLabel = pickSharePointValue(accessLabel, 'Connector table API');
420
+ const sMatchedBy = pickSharePointValue(matchedBy, 'connector table lookup');
421
+
422
+ return {
423
+ siteUrl: sSiteUrl,
424
+ listId: sResolvedListId,
425
+ listName: sResolvedListName,
426
+ table: sTableToken,
427
+ accessLabel: sAccessLabel,
428
+ matchedBy: sMatchedBy,
429
+ rawTable: oTable || null,
430
+ sSiteUrl: sSiteUrl,
431
+ sListId: sResolvedListId,
432
+ sListName: sResolvedListName,
433
+ sAccessLabel: sAccessLabel,
434
+ sMatchedBy: sMatchedBy,
435
+ oTable: oTable || null,
436
+ };
385
437
  }
386
438
 
387
- // ═══════════════════════════════════════════════════════════════
388
- // TABLES / LISTS
389
- // ═══════════════════════════════════════════════════════════════
439
+ function createConfiguredSharePointList(siteUrl, { listId, listName, accessLabel, matchedBy } = {}) {
440
+ const sSiteUrl = requireNonEmptyString(siteUrl, 'site URL');
441
+ const sResolvedListId = requireNonEmptyString(String(listId || ''), 'list ID');
442
+ const sResolvedListName = requireNonEmptyString(String(listName || sResolvedListId), 'list name');
443
+ const sAccessLabel = pickSharePointValue(accessLabel, 'Configured list ID');
444
+ const sMatchedBy = pickSharePointValue(matchedBy, 'configured list ID');
390
445
 
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
- });
446
+ return {
447
+ siteUrl: sSiteUrl,
448
+ listId: sResolvedListId,
449
+ listName: sResolvedListName,
450
+ table: sResolvedListId,
451
+ accessLabel: sAccessLabel,
452
+ matchedBy: sMatchedBy,
453
+ rawTable: null,
454
+ sSiteUrl: sSiteUrl,
455
+ sListId: sResolvedListId,
456
+ sListName: sResolvedListName,
457
+ sAccessLabel: sAccessLabel,
458
+ sMatchedBy: sMatchedBy,
459
+ oTable: null,
460
+ };
398
461
  }
399
462
 
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
- });
463
+ function findSharePointTable(aTables, { listId, listName } = {}) {
464
+ const sNormalizedListId = normalizeSharePointLookupValue(listId);
465
+ const sNormalizedListName = normalizeSharePointLookupValue(listName);
466
+
467
+ return normalizeCollection(aTables).find((oTable) => {
468
+ const aIdCandidates = [
469
+ getSharePointTableToken(oTable),
470
+ getSharePointExternalListId(oTable),
471
+ ].map((sValue) => normalizeSharePointLookupValue(sValue)).filter(Boolean);
472
+
473
+ if (sNormalizedListId && aIdCandidates.indexOf(sNormalizedListId) !== -1) {
474
+ return true;
475
+ }
476
+
477
+ if (!sNormalizedListName) {
478
+ return false;
479
+ }
480
+
481
+ return getSharePointTableNames(oTable).some((sCandidate) => normalizeSharePointLookupValue(sCandidate) === sNormalizedListName);
482
+ }) || null;
407
483
  }
408
484
 
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,
485
+ export const callSharePointOperation = async (operationName, parameters = {}) => _dbgWrap('callSharePointOperation', [operationName, parameters], async function() {
486
+ return executeConnectorOperation(operationName, parameters);
487
+ });
488
+
489
+ export const sendHttpRequest = async ({ method = 'GET', uri, headers, body } = {}) => _dbgWrap('sendHttpRequest', [{ method, uri, headers, body }], async function() {
490
+ return executeConnectorOperation('HttpRequest', {
491
+ method: String(method || 'GET').toUpperCase(),
492
+ uri: requireNonEmptyString(uri, 'request URI'),
493
+ headers: normalizeHeaders(headers),
494
+ body: body == null ? '' : body,
421
495
  });
496
+ });
497
+
498
+ export const getItems = async (siteUrl, listId, { filter, orderBy, top, skip } = {}) => _dbgWrap('getItems', [siteUrl, listId, { filter, orderBy, top, skip }], async function() {
499
+ return executeConnectorOperation('GetItems', buildItemQueryParameters(siteUrl, listId, { filter, orderBy, top, skip }));
500
+ });
501
+
502
+ export const getSpItem = async (siteUrl, listId, itemId) => _dbgWrap('getSpItem', [siteUrl, listId, itemId], async function() {
503
+ return executeConnectorOperation('GetItem', Object.assign(buildListContext(siteUrl, listId), {
504
+ id: requireItemId(itemId),
505
+ }));
506
+ });
507
+
508
+ export const createSpItem = async (siteUrl, listId, fields) => _dbgWrap('createSpItem', [siteUrl, listId, fields], async function() {
509
+ return executeConnectorOperation('PostItem', Object.assign(buildListContext(siteUrl, listId), {
510
+ item: requireRecord(fields, 'item payload'),
511
+ }));
512
+ });
513
+
514
+ export const updateSpItem = async (siteUrl, listId, itemId, changedFields) => _dbgWrap('updateSpItem', [siteUrl, listId, itemId, changedFields], async function() {
515
+ return executeConnectorOperation('PatchItem', Object.assign(buildListContext(siteUrl, listId), {
516
+ id: requireItemId(itemId),
517
+ item: requireRecord(changedFields, 'item payload'),
518
+ }));
519
+ });
520
+
521
+ export const deleteSpItem = async (siteUrl, listId, itemId) => _dbgWrap('deleteSpItem', [siteUrl, listId, itemId], async function() {
522
+ return executeConnectorOperation('DeleteItem', Object.assign(buildListContext(siteUrl, listId), {
523
+ id: requireItemId(itemId),
524
+ }));
525
+ });
526
+
527
+ export const listTables = async (siteUrl) => _dbgWrap('listTables', [siteUrl], async function() {
528
+ return normalizeCollection(await executeConnectorOperation('GetTables', {
529
+ siteUrl: buildSiteUrlParam(siteUrl),
530
+ }));
531
+ });
532
+
533
+ export const listLibrary = async (siteUrl) => _dbgWrap('listLibrary', [siteUrl], async function() {
534
+ return executeConnectorOperation('GetDataSetsMetadata', {
535
+ siteUrl: buildSiteUrlParam(siteUrl),
422
536
  });
423
- }
537
+ });
538
+
539
+ export const resolveSharePointList = async (siteUrl, listReference = {}) => _dbgWrap('resolveSharePointList', [siteUrl, listReference], async function() {
540
+ const sSiteUrl = requireNonEmptyString(siteUrl, 'site URL');
541
+ const oReference = normalizeSharePointListReference(listReference);
542
+ const sListId = typeof pickSharePointValue(oReference.listId, oReference.sListId, oReference.table) === 'string' ? pickSharePointValue(oReference.listId, oReference.sListId, oReference.table).trim() : '';
543
+ const sListName = typeof pickSharePointValue(oReference.listName, oReference.sListName, oReference.name, oReference.title) === 'string' ? pickSharePointValue(oReference.listName, oReference.sListName, oReference.name, oReference.title).trim() : '';
544
+ const bRefresh = oReference.refresh === true;
545
+ const bSkipTableLookup = oReference.skipTableLookup === true;
546
+
547
+ if (!sListId && !sListName) {
548
+ throw new Error('Provide a SharePoint listId or listName.');
549
+ }
550
+
551
+ const sCacheKey = getSharePointListCacheKey(sSiteUrl, { listId: sListId, listName: sListName });
552
+ if (!bRefresh && sharePointListCache.has(sCacheKey)) {
553
+ return sharePointListCache.get(sCacheKey);
554
+ }
555
+
556
+ let oResolvedList = null;
557
+ let oLookupError = null;
558
+
559
+ if (!bSkipTableLookup) {
560
+ try {
561
+ const aTables = await listTables(sSiteUrl);
562
+ const oMatchedTable = findSharePointTable(aTables, {
563
+ listId: sListId,
564
+ listName: sListName,
565
+ });
566
+
567
+ if (oMatchedTable) {
568
+ oResolvedList = createResolvedSharePointList(sSiteUrl, oMatchedTable, {
569
+ listId: sListId,
570
+ listName: sListName,
571
+ matchedBy: sListId ? 'connector table ID' : 'connector table name',
572
+ });
573
+ }
574
+ } catch (oError) {
575
+ oLookupError = oError;
576
+ }
577
+ }
578
+
579
+ if (!oResolvedList && sListId) {
580
+ oResolvedList = createConfiguredSharePointList(sSiteUrl, {
581
+ listId: sListId,
582
+ listName: sListName,
583
+ });
584
+ }
585
+
586
+ if (!oResolvedList && oLookupError) {
587
+ throw oLookupError;
588
+ }
424
589
 
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"),
590
+ if (!oResolvedList) {
591
+ throw new Error('SharePoint list "' + sListName + '" was not found for site ' + sSiteUrl + '.');
592
+ }
593
+
594
+ sharePointListCache.set(sCacheKey, oResolvedList);
595
+ return oResolvedList;
596
+ });
597
+
598
+ export const getItemsByList = async (siteUrl, listReference, queryOptions = {}) => _dbgWrap('getItemsByList', [siteUrl, listReference, queryOptions], async function() {
599
+ const oResolvedList = await resolveSharePointList(siteUrl, listReference);
600
+ return getItems(oResolvedList.siteUrl, pickSharePointValue(oResolvedList.table, oResolvedList.listId), queryOptions);
601
+ });
602
+
603
+ export const getSpItemByList = async (siteUrl, listReference, itemId) => _dbgWrap('getSpItemByList', [siteUrl, listReference, itemId], async function() {
604
+ const oResolvedList = await resolveSharePointList(siteUrl, listReference);
605
+ return getSpItem(oResolvedList.siteUrl, pickSharePointValue(oResolvedList.table, oResolvedList.listId), itemId);
606
+ });
607
+
608
+ export const createSpItemByList = async (siteUrl, listReference, fields) => _dbgWrap('createSpItemByList', [siteUrl, listReference, fields], async function() {
609
+ const oResolvedList = await resolveSharePointList(siteUrl, listReference);
610
+ return createSpItem(oResolvedList.siteUrl, pickSharePointValue(oResolvedList.table, oResolvedList.listId), fields);
611
+ });
612
+
613
+ export const updateSpItemByList = async (siteUrl, listReference, itemId, changedFields) => _dbgWrap('updateSpItemByList', [siteUrl, listReference, itemId, changedFields], async function() {
614
+ const oResolvedList = await resolveSharePointList(siteUrl, listReference);
615
+ return updateSpItem(oResolvedList.siteUrl, pickSharePointValue(oResolvedList.table, oResolvedList.listId), itemId, changedFields);
616
+ });
617
+
618
+ export const deleteSpItemByList = async (siteUrl, listReference, itemId) => _dbgWrap('deleteSpItemByList', [siteUrl, listReference, itemId], async function() {
619
+ const oResolvedList = await resolveSharePointList(siteUrl, listReference);
620
+ return deleteSpItem(oResolvedList.siteUrl, pickSharePointValue(oResolvedList.table, oResolvedList.listId), itemId);
621
+ });
622
+
623
+ export const createFile = async (siteUrl, folderPath, fileName, fileContent) => _dbgWrap('createFile', [siteUrl, folderPath, fileName, fileContent], async function() {
624
+ return executeConnectorOperation('CreateFile', {
625
+ siteUrl: buildSiteUrlParam(siteUrl),
626
+ folderPath: requireNonEmptyString(folderPath, 'folder path'),
627
+ name: requireNonEmptyString(fileName, 'file name'),
431
628
  body: fileContent,
432
629
  });
433
- });
434
- }
630
+ });
435
631
 
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
- });
632
+ export const updateFile = async (siteUrl, fileId, fileContent) => _dbgWrap('updateFile', [siteUrl, fileId, fileContent], async function() {
633
+ return executeConnectorOperation('UpdateFile', {
634
+ siteUrl: buildSiteUrlParam(siteUrl),
635
+ id: requireNonEmptyString(String(fileId || ''), 'file ID'),
636
+ body: fileContent,
443
637
  });
444
- }
638
+ });
445
639
 
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 || "",
640
+ export const deleteFile = async (siteUrl, fileId) => _dbgWrap('deleteFile', [siteUrl, fileId], async function() {
641
+ return executeConnectorOperation('DeleteFile', {
642
+ siteUrl: buildSiteUrlParam(siteUrl),
643
+ id: requireNonEmptyString(String(fileId || ''), 'file ID'),
454
644
  });
645
+ });
646
+
647
+ export const moveFile = async (siteUrl, sourceFileId, destinationFolderPath, newFileName) => _dbgWrap('moveFile', [siteUrl, sourceFileId, destinationFolderPath, newFileName], async function() {
648
+ return executeConnectorOperation('MoveFile', {
649
+ siteUrl: buildSiteUrlParam(siteUrl),
650
+ id: requireNonEmptyString(String(sourceFileId || ''), 'source file ID'),
651
+ destinationFolderPath: requireNonEmptyString(destinationFolderPath, 'destination folder path'),
652
+ newFileName: newFileName || '',
455
653
  });
456
- }
654
+ });
457
655
 
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
- });
656
+ export const getFileMetadata = async (siteUrl, fileId) => _dbgWrap('getFileMetadata', [siteUrl, fileId], async function() {
657
+ return executeConnectorOperation('GetFileMetadata', {
658
+ siteUrl: buildSiteUrlParam(siteUrl),
659
+ id: requireNonEmptyString(String(fileId || ''), 'file ID'),
465
660
  });
466
- }
661
+ });
662
+
663
+ const SharePointService = {
664
+ callSharePointOperation,
665
+ sendHttpRequest,
666
+ resolveSharePointList,
667
+ getItems,
668
+ getSpItem,
669
+ createSpItem,
670
+ updateSpItem,
671
+ deleteSpItem,
672
+ getItemsByList,
673
+ getSpItemByList,
674
+ createSpItemByList,
675
+ updateSpItemByList,
676
+ deleteSpItemByList,
677
+ listTables,
678
+ listLibrary,
679
+ createFile,
680
+ updateFile,
681
+ deleteFile,
682
+ moveFile,
683
+ getFileMetadata,
684
+ };
685
+
686
+ export { SharePointService };
687
+ export default SharePointService;