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.
- package/AI/skills/autoreview/SKILL.md +69 -0
- package/AI/skills/connections/SKILL.md +4 -4
- package/AI/skills/dataverse/SKILL.md +4 -2
- package/AI/skills/keyvault/SKILL.md +139 -0
- package/AI/skills/office365-groups/SKILL.md +46 -25
- package/AI/skills/office365-outlook/SKILL.md +56 -25
- package/AI/skills/office365-users/SKILL.md +41 -36
- package/AI/skills/sharepoint/SKILL.md +174 -31
- package/AI/skills/start/SKILL.md +1 -0
- package/codeApp/dist/connectors/autoreview.js +1654 -0
- package/codeApp/dist/connectors/office365groups.js +2995 -432
- package/{examples/outlook Demo/.power/schemas/office365/office365.Schema.json → codeApp/dist/connectors/office365outlook.js} +7439 -16
- package/codeApp/dist/connectors/office365users.js +2990 -349
- package/codeApp/dist/connectors/sharepoint.js +529 -308
- package/examples/combined demo/dist/connectors/office365outlook.js +28521 -0
- package/examples/combined demo/dist/connectors/office365users.js +3154 -0
- package/examples/combined demo/dist/index.js +2 -6
- package/examples/combined demo/power.config.json +1 -1
- package/examples/groups Demo/{.power/schemas/office365groups/office365groups.Schema.json → dist/connectors/office365groups.js } +3205 -2204
- package/examples/groups Demo/dist/index.js +1 -5
- package/examples/groups Demo/power.config.json +1 -1
- package/examples/myProfile/dist/connectors/office365users.js +3154 -0
- package/examples/myProfile/dist/index.js +1 -5
- package/examples/myProfile/power.config.json +1 -1
- package/examples/outlook Demo/dist/connectors/office365outlook.js +28521 -0
- package/examples/outlook Demo/dist/index.js +2 -5
- package/examples/outlook Demo/power.config.json +1 -1
- package/examples/sharePoint Demo/dist/connectors/sharepoint.js +687 -0
- package/examples/sharePoint Demo/dist/index.js +86 -127
- package/examples/sharePoint Demo/power.config.json +1 -1
- package/package.json +1 -1
- package/codeApp/.power/schemas/appschemas/dataSourcesInfo.ts +0 -6275
- package/codeApp/.power/schemas/jira/jira.Schema.json +0 -6903
- package/codeApp/.power/schemas/keyvault/keyvault.Schema.json +0 -1600
- package/codeApp/.power/schemas/office365groups/office365groups.Schema.json +0 -2204
- package/codeApp/.power/schemas/teams/teams.Schema.json +0 -11112
- package/codeApp/dist/connectors/outlook.js +0 -1393
- package/codeApp/src/generated/models/AzureKeyVaultModel.ts +0 -107
- package/codeApp/src/generated/models/JiraModel.ts +0 -501
- package/codeApp/src/generated/models/Office365GroupsModel.ts +0 -363
- package/codeApp/src/generated/models/Office365OutlookModel.ts +0 -2046
- package/codeApp/src/generated/models/Office365UsersModel.ts +0 -254
- package/codeApp/src/generated/services/AzureKeyVaultService.ts +0 -257
- package/codeApp/src/generated/services/JiraService.ts +0 -1124
- package/codeApp/src/generated/services/Office365GroupsService.ts +0 -326
- package/codeApp/src/generated/services/Office365OutlookService.ts +0 -2476
- package/codeApp/src/generated/services/Office365UsersService.ts +0 -358
- package/examples/apps/kanban/dist/dataverse.js +0 -94
- package/examples/apps/kanban/dist/environmentVar.js +0 -55
- package/examples/apps/kanban/dist/index.css +0 -605
- package/examples/apps/kanban/dist/index.html +0 -21
- package/examples/apps/kanban/dist/index.js +0 -860
- package/examples/apps/kanban/dist/office365groups.js +0 -97
- package/examples/apps/kanban/dist/office365users.js +0 -451
- package/examples/apps/kanban/dist/outlook.js +0 -162
- package/examples/apps/kanban/dist/power-apps-data.js +0 -2953
- package/examples/apps/kanban/dist/sharepoint.js +0 -435
- package/examples/apps/kanban/power.config.json +0 -35
- package/examples/apps/kanban/src/generated/index.ts +0 -14
- package/examples/apps/kanban/src/generated/models/Office365GroupsModel.ts +0 -363
- package/examples/apps/kanban/src/generated/models/Office365OutlookModel.ts +0 -2046
- package/examples/apps/kanban/src/generated/models/Office365UsersModel.ts +0 -254
- package/examples/apps/kanban/src/generated/services/Office365GroupsService.ts +0 -326
- package/examples/apps/kanban/src/generated/services/Office365OutlookService.ts +0 -2476
- package/examples/apps/kanban/src/generated/services/Office365UsersService.ts +0 -358
- package/examples/apps/planning Poker/additional files/AgilePoker_1_0_0_1.zip +0 -0
- package/examples/apps/planning Poker/additional files/PokerTables_1_0_0_1.zip +0 -0
- package/examples/apps/planning Poker/additional files/customizations (tables).xml +0 -6429
- package/examples/apps/planning Poker/additional files/dataverse-tables.json +0 -165
- package/examples/apps/planning Poker/additional files/readme.md +0 -122
- package/examples/apps/planning Poker/dist/dataverse.js +0 -78
- package/examples/apps/planning Poker/dist/index.html +0 -198
- package/examples/apps/planning Poker/dist/index.js +0 -955
- package/examples/apps/planning Poker/dist/power-apps-data.js +0 -2953
- package/examples/apps/planning Poker/dist/styles.css +0 -815
- package/examples/apps/planning Poker/power.config.json +0 -50
- package/examples/apps/solution explorer/dist/codeapp.js +0 -1098
- package/examples/apps/solution explorer/dist/icon-512.png +0 -0
- package/examples/apps/solution explorer/dist/index.html +0 -80
- package/examples/apps/solution explorer/dist/index.js +0 -735
- package/examples/apps/solution explorer/dist/power-apps-data.js +0 -3007
- package/examples/apps/solution explorer/dist/styles.css +0 -571
- package/examples/apps/solution explorer/power.config.json +0 -151
- package/examples/apps/todo/dist/dataverse.js +0 -64
- package/examples/apps/todo/dist/icon192.png +0 -0
- package/examples/apps/todo/dist/index.html +0 -75
- package/examples/apps/todo/dist/index.js +0 -9
- package/examples/apps/todo/dist/power-apps-data.js +0 -2953
- package/examples/apps/todo/dist/renderer.js +0 -375
- package/examples/apps/todo/dist/styles.css +0 -691
- package/examples/apps/todo/power.config.json +0 -35
- package/examples/combined demo/.power/schemas/appschemas/dataSourcesInfo.ts +0 -6275
- package/examples/combined demo/.power/schemas/jira/jira.Schema.json +0 -6903
- package/examples/combined demo/.power/schemas/keyvault/keyvault.Schema.json +0 -1600
- package/examples/combined demo/.power/schemas/teams/teams.Schema.json +0 -11112
- package/examples/combined demo/dist/office365users.js +0 -513
- package/examples/combined demo/dist/outlook.js +0 -1393
- package/examples/combined demo/src/generated/index.ts +0 -12
- package/examples/combined demo/src/generated/models/AzureKeyVaultModel.ts +0 -107
- package/examples/combined demo/src/generated/models/JiraModel.ts +0 -501
- package/examples/combined demo/src/generated/models/Office365GroupsModel.ts +0 -363
- package/examples/combined demo/src/generated/models/Office365OutlookModel.ts +0 -2046
- package/examples/combined demo/src/generated/models/Office365UsersModel.ts +0 -254
- package/examples/combined demo/src/generated/services/AzureKeyVaultService.ts +0 -257
- package/examples/combined demo/src/generated/services/JiraService.ts +0 -1124
- package/examples/combined demo/src/generated/services/Office365GroupsService.ts +0 -326
- package/examples/combined demo/src/generated/services/Office365OutlookService.ts +0 -2476
- package/examples/combined demo/src/generated/services/Office365UsersService.ts +0 -358
- package/examples/groups Demo/.power/schemas/appschemas/dataSourcesInfo.ts +0 -613
- package/examples/groups Demo/dist/office365groups.js +0 -642
- package/examples/groups Demo/src/generated/index.ts +0 -10
- package/examples/groups Demo/src/generated/models/Office365GroupsModel.ts +0 -363
- package/examples/groups Demo/src/generated/services/Office365GroupsService.ts +0 -326
- package/examples/myProfile/dist/office365users.js +0 -517
- package/examples/outlook Demo/.power/schemas/appschemas/dataSourcesInfo.ts +0 -6512
- package/examples/outlook Demo/dist/outlook.js +0 -1393
- package/examples/outlook Demo/src/generated/index.ts +0 -10
- package/examples/outlook Demo/src/generated/models/Office365OutlookModel.ts +0 -2046
- package/examples/outlook Demo/src/generated/services/Office365OutlookService.ts +0 -2476
- package/examples/sharePoint Demo/dist/sharepoint.js +0 -466
- package/examples/sharePoint Demo/src/generated/index.ts +0 -14
- package/examples/sharePoint Demo/src/generated/models/Office365GroupsModel.ts +0 -363
- package/examples/sharePoint Demo/src/generated/models/Office365OutlookModel.ts +0 -2046
- package/examples/sharePoint Demo/src/generated/models/Office365UsersModel.ts +0 -254
- package/examples/sharePoint Demo/src/generated/services/Office365GroupsService.ts +0 -326
- package/examples/sharePoint Demo/src/generated/services/Office365OutlookService.ts +0 -2476
- package/examples/sharePoint Demo/src/generated/services/Office365UsersService.ts +0 -358
- package/readme.md +0 -590
|
@@ -1,186 +1,202 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
path:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
path:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
path:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
153
|
-
async function execSpOp(operationName, parameters) {
|
|
154
|
+
async function executeConnectorOperation(operationName, parameters = {}) {
|
|
154
155
|
try {
|
|
155
|
-
const
|
|
156
|
-
const
|
|
156
|
+
const oClient = await initSharePointClient();
|
|
157
|
+
const oResult = await oClient.executeAsync({
|
|
157
158
|
connectorOperation: {
|
|
158
|
-
tableName:
|
|
159
|
+
tableName: DATA_SOURCE_NAME,
|
|
159
160
|
operationName,
|
|
160
|
-
parameters
|
|
161
|
+
parameters,
|
|
161
162
|
},
|
|
162
163
|
});
|
|
163
164
|
|
|
164
|
-
if (!
|
|
165
|
-
throw new Error(
|
|
165
|
+
if (!oResult) {
|
|
166
|
+
throw new Error('No result returned');
|
|
166
167
|
}
|
|
167
168
|
|
|
168
|
-
if (
|
|
169
|
-
throw new Error(getSpErrorMessage(
|
|
169
|
+
if (oResult.success === false) {
|
|
170
|
+
throw new Error(getSpErrorMessage(oResult.error));
|
|
170
171
|
}
|
|
171
172
|
|
|
172
|
-
return Object.prototype.hasOwnProperty.call(
|
|
173
|
+
return Object.prototype.hasOwnProperty.call(oResult, 'data') ? oResult.data : oResult;
|
|
173
174
|
} catch (oError) {
|
|
174
|
-
throw new Error(
|
|
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
|
|
196
|
+
return 'Unknown error';
|
|
181
197
|
}
|
|
182
198
|
|
|
183
|
-
if (typeof oError ===
|
|
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(
|
|
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 !==
|
|
217
|
-
throw new Error(
|
|
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 !==
|
|
225
|
-
throw new Error(
|
|
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 !==
|
|
237
|
-
throw new Error(
|
|
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(
|
|
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 !==
|
|
258
|
-
throw new Error(
|
|
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
|
|
277
|
+
function buildSiteUrlParam(siteUrl) {
|
|
278
|
+
return encodeURIComponent(requireNonEmptyString(siteUrl, 'site URL'));
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function buildListContext(siteUrl, listId) {
|
|
265
282
|
return {
|
|
266
|
-
siteUrl:
|
|
267
|
-
table: requireNonEmptyString(
|
|
283
|
+
siteUrl: buildSiteUrlParam(siteUrl),
|
|
284
|
+
table: requireNonEmptyString(String(listId || ''), 'list ID'),
|
|
268
285
|
};
|
|
269
286
|
}
|
|
270
287
|
|
|
271
|
-
function buildItemQueryParameters(
|
|
272
|
-
const
|
|
288
|
+
function buildItemQueryParameters(siteUrl, listId, { filter, orderBy, top, skip } = {}) {
|
|
289
|
+
const oParameters = buildListContext(siteUrl, listId);
|
|
273
290
|
if (filter) {
|
|
274
|
-
|
|
291
|
+
oParameters.$filter = String(filter);
|
|
275
292
|
}
|
|
276
293
|
if (orderBy) {
|
|
277
|
-
|
|
294
|
+
oParameters.$orderby = String(orderBy);
|
|
278
295
|
}
|
|
279
296
|
|
|
280
|
-
const iTop = normalizeNumericQueryValue(top,
|
|
281
|
-
const iSkip = normalizeNumericQueryValue(skip,
|
|
297
|
+
const iTop = normalizeNumericQueryValue(top, 'top');
|
|
298
|
+
const iSkip = normalizeNumericQueryValue(skip, 'skip');
|
|
282
299
|
if (iTop != null) {
|
|
283
|
-
|
|
300
|
+
oParameters.$top = iTop;
|
|
284
301
|
}
|
|
285
302
|
if (iSkip != null) {
|
|
286
|
-
|
|
303
|
+
oParameters.$skip = iSkip;
|
|
287
304
|
}
|
|
288
305
|
|
|
289
|
-
return
|
|
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(
|
|
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
|
-
|
|
318
|
-
|
|
330
|
+
function normalizeSharePointLookupValue(value) {
|
|
331
|
+
if (value === undefined || value === null) {
|
|
332
|
+
return '';
|
|
333
|
+
}
|
|
319
334
|
|
|
320
|
-
|
|
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
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
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
|
-
|
|
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
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
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
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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
|
-
|
|
360
|
-
|
|
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
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
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
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
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
|
-
|
|
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
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
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
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
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
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
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
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
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
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
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
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
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;
|