@prismatic-io/components-ms-sharepoint 0.0.0-stage → 0.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.
@@ -0,0 +1,3238 @@
1
+ let _prismatic_io_spectral = require("@prismatic-io/spectral");
2
+ let _prismatic_io_spectral_http = require("@prismatic-io/spectral/http");
3
+ let _azure_msal_node = require("@azure/msal-node");
4
+ let node_stream = require("node:stream");
5
+ let node_url = require("node:url");
6
+ //#region ../../packages/ms-utils/dist/connections/OAuth2AuthorizationCodeConnection.js
7
+ const _getMicrosoftOAuth2AuthorizationCodeConnection = ({ key, defaultScopes, comments, additionalInputs }) => (0, _prismatic_io_spectral.oauth2Connection)({
8
+ key,
9
+ display: {
10
+ label: "OAuth 2.0 Authorization Code",
11
+ description: "Authenticates actions in all Microsoft's Graph API services."
12
+ },
13
+ oauth2Type: _prismatic_io_spectral.OAuth2Type.AuthorizationCode,
14
+ inputs: (0, _prismatic_io_spectral.templateConnectionInputs)(Object.assign({
15
+ baseUrl: {
16
+ label: "Base URL",
17
+ placeholder: "https://graph.microsoft.com",
18
+ example: "https://graph.microsoft.com",
19
+ default: "https://graph.microsoft.com",
20
+ type: "string",
21
+ required: true,
22
+ shown: true,
23
+ comments: (comments === null || comments === void 0 ? void 0 : comments.baseUrl) || "The base URL for the Microsoft Graph API. Depending on your cloud environment, you can choose the correct one [here](https://learn.microsoft.com/en-us/graph/deployments#microsoft-graph-and-graph-explorer-service-root-endpoints)."
24
+ },
25
+ tenantUrl: {
26
+ label: "Tenant URL",
27
+ type: "string",
28
+ required: true,
29
+ shown: true,
30
+ comments: (comments === null || comments === void 0 ? void 0 : comments.tenantUrl) || "The tenant URL for the Microsoft Graph API. This is the URL of the tenant that you are connecting to. You can find this in the Azure portal or [here](https://learn.microsoft.com/en-us/entra/identity-platform/authentication-national-cloud#microsoft-entra-authentication-endpoints).",
31
+ example: "login.microsoftonline.com/common",
32
+ default: "login.microsoftonline.com/common",
33
+ placeholder: "login.microsoftonline.com/common"
34
+ },
35
+ scopes: {
36
+ label: "Scopes",
37
+ placeholder: "Scopes",
38
+ type: "string",
39
+ required: false,
40
+ shown: true,
41
+ comments: (comments === null || comments === void 0 ? void 0 : comments.scopes) || "Microsoft Graph API permission scopes are set on the OAuth application.",
42
+ default: defaultScopes || "offline_access"
43
+ },
44
+ clientId: {
45
+ label: "Client ID",
46
+ placeholder: "Client ID",
47
+ type: "string",
48
+ required: true,
49
+ shown: true,
50
+ comments: (comments === null || comments === void 0 ? void 0 : comments.clientId) || "Client Id of your Azure application.",
51
+ example: "11111111-2222-3333-4444-555555555555"
52
+ },
53
+ clientSecret: {
54
+ label: "Client secret value",
55
+ placeholder: "Client secret value",
56
+ type: "password",
57
+ required: true,
58
+ shown: true,
59
+ comments: (comments === null || comments === void 0 ? void 0 : comments.clientSecret) || "Client Secret generated under 'Certificates & Secrets' in your Azure application.",
60
+ example: "11111111-2222-3333-4444-555555555555"
61
+ },
62
+ extraParameters: {
63
+ label: "Additional Authorization Parameters",
64
+ type: "string",
65
+ required: false,
66
+ shown: true,
67
+ example: "prompt=consent",
68
+ placeholder: "Enter additional parameters for the authorization URL.",
69
+ comments: (comments === null || comments === void 0 ? void 0 : comments.extraParameters) || "Query string parameters to append to the OAuth authorization URL. Common parameters include `prompt=consent` to force the consent screen or `login_hint=user@example.com` to pre-fill the login email."
70
+ }
71
+ }, additionalInputs || {}), {
72
+ authorizeUrl: {
73
+ label: "Authorize URL",
74
+ placeholder: "Authorize URL",
75
+ type: "template",
76
+ required: true,
77
+ shown: false,
78
+ comments: (comments === null || comments === void 0 ? void 0 : comments.authorizeUrl) || "The OAuth 2.0 Authorization URL for Microsoft's Graph API.",
79
+ example: "login.microsoftonline.com/common",
80
+ templateValue: "https://{{#tenantUrl}}/oauth2/v2.0/authorize?{{#extraParameters}}"
81
+ },
82
+ tokenUrl: {
83
+ label: "Token URL",
84
+ placeholder: "Token URL",
85
+ type: "template",
86
+ required: true,
87
+ shown: false,
88
+ comments: (comments === null || comments === void 0 ? void 0 : comments.tokenUrl) || "The OAuth 2.0 Token URL for Microsoft's Graph API.",
89
+ example: "login.microsoftonline.com/common",
90
+ templateValue: "https://{{#tenantUrl}}/oauth2/v2.0/token"
91
+ }
92
+ }, _prismatic_io_spectral.OAuth2Type.AuthorizationCode)
93
+ });
94
+ const getMicrosoftOAuth2AuthorizationCodeConnection = _getMicrosoftOAuth2AuthorizationCodeConnection;
95
+ //#endregion
96
+ //#region ../../packages/ms-utils/dist/connections/OAuth2CertificateCredentialsConnection.js
97
+ const _getMicrosoftCertificateCredentialsConnection = ({ key, defaultScopes, comments, additionalInputs }) => (0, _prismatic_io_spectral.connection)({
98
+ key,
99
+ display: {
100
+ label: "Certificate Credentials",
101
+ description: "Authenticates actions in all Microsoft's Graph API services."
102
+ },
103
+ inputs: (0, _prismatic_io_spectral.templateConnectionInputs)(Object.assign({
104
+ baseUrl: {
105
+ label: "Base URL",
106
+ placeholder: "https://graph.microsoft.com",
107
+ example: "https://graph.microsoft.com",
108
+ default: "https://graph.microsoft.com",
109
+ type: "string",
110
+ required: true,
111
+ shown: true,
112
+ comments: "The base URL for the Microsoft Graph API. Depending on your cloud environment, you can choose the correct one [here](https://learn.microsoft.com/en-us/graph/deployments#microsoft-graph-and-graph-explorer-service-root-endpoints)."
113
+ },
114
+ entraIdEndpoint: {
115
+ label: "Microsoft Entra ID Endpoint",
116
+ type: "string",
117
+ required: true,
118
+ shown: true,
119
+ comments: "The Microsoft Entra ID endpoint for the Microsoft Graph API. You can find this in the Azure portal or [here](https://learn.microsoft.com/en-us/graph/deployments#app-registration-and-token-service-root-endpoints).",
120
+ example: "https://login.microsoftonline.com",
121
+ default: "https://login.microsoftonline.com",
122
+ placeholder: "https://login.microsoftonline.com"
123
+ },
124
+ tenant: {
125
+ label: "Tenant",
126
+ type: "string",
127
+ required: true,
128
+ shown: true,
129
+ comments: (comments === null || comments === void 0 ? void 0 : comments.tenantId) || "The tenant ID or name for the Microsoft Graph API. This is the ID or name of the tenant that you are connecting to.",
130
+ example: "11111111-2222-3333-4444-555555555555",
131
+ placeholder: "Enter your tenant ID or name"
132
+ },
133
+ clientId: {
134
+ label: "Client ID",
135
+ placeholder: "Client ID",
136
+ type: "string",
137
+ required: true,
138
+ shown: true,
139
+ comments: (comments === null || comments === void 0 ? void 0 : comments.clientId) || "Client Id of your Azure application.",
140
+ example: "11111111-2222-3333-4444-555555555555"
141
+ },
142
+ certificate: {
143
+ label: "Private Certificate",
144
+ type: "text",
145
+ required: true,
146
+ shown: true,
147
+ comments: "Your X.509 private certificate."
148
+ },
149
+ certificateThumbprint: {
150
+ label: "Certificate Thumbprint",
151
+ type: "string",
152
+ required: true,
153
+ shown: true,
154
+ comments: "Thumbprint of the certificate."
155
+ },
156
+ scopes: {
157
+ label: "Scopes",
158
+ placeholder: "https://graph.microsoft.com/.default",
159
+ type: "string",
160
+ required: false,
161
+ shown: true,
162
+ comments: (comments === null || comments === void 0 ? void 0 : comments.scopes) || "Microsoft Graph API Scopes.",
163
+ default: defaultScopes || "https://graph.microsoft.com/.default"
164
+ }
165
+ }, additionalInputs || {}), {})
166
+ });
167
+ const getMicrosoftCertificateCredentialsConnection = _getMicrosoftCertificateCredentialsConnection;
168
+ //#endregion
169
+ //#region ../../packages/ms-utils/dist/connections/OAuth2ClientCredentialsConnection.js
170
+ const _getMicrosoftOAuth2ClientCredentialsConnection = ({ key, defaultScopes, comments, additionalInputs }) => (0, _prismatic_io_spectral.oauth2Connection)({
171
+ key,
172
+ oauth2Type: _prismatic_io_spectral.OAuth2Type.ClientCredentials,
173
+ display: {
174
+ label: "OAuth 2.0 Client Credentials",
175
+ description: "Authenticates actions in all Microsoft's Graph API services."
176
+ },
177
+ inputs: (0, _prismatic_io_spectral.templateConnectionInputs)(Object.assign({
178
+ baseUrl: {
179
+ label: "Base URL",
180
+ placeholder: "https://graph.microsoft.com",
181
+ example: "https://graph.microsoft.com",
182
+ default: "https://graph.microsoft.com",
183
+ type: "string",
184
+ required: true,
185
+ shown: true,
186
+ comments: "The base URL for the Microsoft Graph API. Depending on your cloud environment, you can choose the correct one [here](https://learn.microsoft.com/en-us/graph/deployments#microsoft-graph-and-graph-explorer-service-root-endpoints)."
187
+ },
188
+ entraIdEndpoint: {
189
+ label: "Microsoft Entra ID Endpoint",
190
+ type: "string",
191
+ required: true,
192
+ shown: true,
193
+ comments: "The Microsoft Entra ID endpoint for the Microsoft Graph API. You can find this in the Azure portal or [here](https://learn.microsoft.com/en-us/graph/deployments#app-registration-and-token-service-root-endpoints).",
194
+ example: "https://login.microsoftonline.com",
195
+ default: "https://login.microsoftonline.com",
196
+ placeholder: "https://login.microsoftonline.com"
197
+ },
198
+ tenant: {
199
+ label: "Tenant",
200
+ type: "string",
201
+ required: true,
202
+ shown: true,
203
+ comments: (comments === null || comments === void 0 ? void 0 : comments.tenantId) || "The tenant ID or name for the Microsoft Graph API. This is the ID or name of the tenant that you are connecting to.",
204
+ example: "11111111-2222-3333-4444-555555555555",
205
+ placeholder: "11111111-2222-3333-4444-555555555555"
206
+ },
207
+ clientId: {
208
+ label: "Client ID",
209
+ placeholder: "Client ID",
210
+ type: "string",
211
+ required: true,
212
+ shown: true,
213
+ comments: (comments === null || comments === void 0 ? void 0 : comments.clientId) || "Client Id of your Azure application.",
214
+ example: "11111111-2222-3333-4444-555555555555"
215
+ },
216
+ clientSecret: {
217
+ label: "Client Secret",
218
+ placeholder: "Client Secret",
219
+ type: "password",
220
+ required: true,
221
+ shown: true,
222
+ comments: (comments === null || comments === void 0 ? void 0 : comments.clientSecret) || "Client Secret generated under 'Certificates & Secrets' in your Azure application.",
223
+ example: "11111111-2222-3333-4444-555555555555"
224
+ },
225
+ scopes: {
226
+ label: "Scopes",
227
+ placeholder: "https://graph.microsoft.com/.default",
228
+ type: "string",
229
+ required: false,
230
+ shown: true,
231
+ comments: (comments === null || comments === void 0 ? void 0 : comments.scopes) || "Microsoft Graph API Scopes.",
232
+ default: defaultScopes || "https://graph.microsoft.com/.default"
233
+ }
234
+ }, additionalInputs || {}), { tokenUrl: {
235
+ label: "Token URL",
236
+ placeholder: "Token URL",
237
+ type: "template",
238
+ required: true,
239
+ shown: false,
240
+ comments: (comments === null || comments === void 0 ? void 0 : comments.tokenUrl) || "Provide a tenant specific OAuth 2.0 token endpoint.",
241
+ templateValue: "{{#entraIdEndpoint}}/{{#tenant}}/oauth2/v2.0/token"
242
+ } }, _prismatic_io_spectral.OAuth2Type.ClientCredentials)
243
+ });
244
+ const getMicrosoftOAuth2ClientCredentialsConnection = _getMicrosoftOAuth2ClientCredentialsConnection;
245
+ //#endregion
246
+ //#region ../../packages/ms-utils/dist/connections/index.js
247
+ var ConnectionKeys;
248
+ (function(ConnectionKeys) {
249
+ ConnectionKeys["SharedOauth"] = "oauth";
250
+ ConnectionKeys["SharepointTemplatedOauth"] = "sharepointTemplatedOauth";
251
+ ConnectionKeys["MsExcelOauth"] = "ms-excel-oauth";
252
+ ConnectionKeys["OauthClientCredentials"] = "oauthClientCredentials";
253
+ ConnectionKeys["CertificateCredentials"] = "certificateCredentials";
254
+ })(ConnectionKeys || (ConnectionKeys = {}));
255
+ //#endregion
256
+ //#region ../../packages/ms-utils/dist/subscriptions/constants.js
257
+ const MAX_SUBSCRIPTION_EXPIRATION_MINUTES = 10070;
258
+ const DEFAULT_SUBSCRIPTION_EXPIRATION_MINUTES = MAX_SUBSCRIPTION_EXPIRATION_MINUTES;
259
+ //#endregion
260
+ //#region ../../packages/ms-utils/dist/utils/webhooks.js
261
+ var __awaiter$2 = function(thisArg, _arguments, P, generator) {
262
+ function adopt(value) {
263
+ return value instanceof P ? value : new P(function(resolve) {
264
+ resolve(value);
265
+ });
266
+ }
267
+ return new (P || (P = Promise))(function(resolve, reject) {
268
+ function fulfilled(value) {
269
+ try {
270
+ step(generator.next(value));
271
+ } catch (e) {
272
+ reject(e);
273
+ }
274
+ }
275
+ function rejected(value) {
276
+ try {
277
+ step(generator["throw"](value));
278
+ } catch (e) {
279
+ reject(e);
280
+ }
281
+ }
282
+ function step(result) {
283
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
284
+ }
285
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
286
+ });
287
+ };
288
+ const calculateExpirationDateTime = (minutes = DEFAULT_SUBSCRIPTION_EXPIRATION_MINUTES) => {
289
+ const cappedMinutes = Math.min(minutes, MAX_SUBSCRIPTION_EXPIRATION_MINUTES);
290
+ const expirationDate = /* @__PURE__ */ new Date();
291
+ expirationDate.setTime(expirationDate.getTime() + cappedMinutes * 60 * 1e3);
292
+ return expirationDate.toISOString();
293
+ };
294
+ const listAllSubscriptionsFN = (client) => __awaiter$2(void 0, void 0, void 0, function* () {
295
+ return (yield fetchAllData(client, "/subscriptions", true, {})).value || [];
296
+ });
297
+ const deleteSubscriptionByIdFN = (client, subscriptionId) => __awaiter$2(void 0, void 0, void 0, function* () {
298
+ yield client.delete(`/subscriptions/${subscriptionId}`);
299
+ return {
300
+ id: subscriptionId,
301
+ deleted: true
302
+ };
303
+ });
304
+ const deleteAllSubscriptionsFN = (client, notificationUrl) => __awaiter$2(void 0, void 0, void 0, function* () {
305
+ const subscriptions = yield listAllSubscriptionsFN(client);
306
+ const deletedSubscriptions = [];
307
+ yield Promise.all(subscriptions.map((subscription) => __awaiter$2(void 0, void 0, void 0, function* () {
308
+ if (subscription.id && (!notificationUrl || subscription.notificationUrl === notificationUrl)) {
309
+ const deleted = yield deleteSubscriptionByIdFN(client, subscription.id);
310
+ deletedSubscriptions.push(deleted);
311
+ }
312
+ })));
313
+ return deletedSubscriptions;
314
+ });
315
+ const createSubscriptionFN = (client_1, _a, context_1) => __awaiter$2(void 0, [
316
+ client_1,
317
+ _a,
318
+ context_1
319
+ ], void 0, function* (client, { resource, changeType, notificationUrl, expirationDateTime, allowDuplicates, clientState, customBody }, context) {
320
+ if (!allowDuplicates) {
321
+ const [existingSubscription] = (yield listAllSubscriptionsFN(client)).filter(({ notificationUrl: existingNotificationUrl }) => existingNotificationUrl === notificationUrl);
322
+ if (existingSubscription) {
323
+ context.logger.info("A Subscription with the specified Notification URL already exists. Skipping Subscription creation and returning existing Subscription.");
324
+ return existingSubscription;
325
+ }
326
+ }
327
+ const { data } = yield client.post("/subscriptions", Object.assign({
328
+ changeType,
329
+ notificationUrl,
330
+ resource,
331
+ expirationDateTime,
332
+ clientState
333
+ }, customBody || {}));
334
+ return data;
335
+ });
336
+ const renewSubscriptionFN = (client_1, subscriptionId_1, ...args_1) => __awaiter$2(void 0, [
337
+ client_1,
338
+ subscriptionId_1,
339
+ ...args_1
340
+ ], void 0, function* (client, subscriptionId, expirationMinutes = DEFAULT_SUBSCRIPTION_EXPIRATION_MINUTES) {
341
+ const expirationDateTime = calculateExpirationDateTime(expirationMinutes);
342
+ const { data } = yield client.patch(`/subscriptions/${subscriptionId}`, { expirationDateTime });
343
+ return data;
344
+ });
345
+ const fetchAllData = (client_1, url_1, fetchAll_1, ...args_1) => __awaiter$2(void 0, [
346
+ client_1,
347
+ url_1,
348
+ fetchAll_1,
349
+ ...args_1
350
+ ], void 0, function* (client, url, fetchAll, params = {}) {
351
+ const results = [];
352
+ let nextLink;
353
+ let firstResponse;
354
+ do {
355
+ const { data } = yield client.get(nextLink || url, nextLink ? void 0 : { params: fetchAll ? Object.fromEntries(Object.entries(params).filter(([key]) => !["$top", "$skip"].includes(key))) : params });
356
+ if (!firstResponse) firstResponse = data;
357
+ results.push(...data.value);
358
+ nextLink = data["@odata.nextLink"];
359
+ if (!fetchAll) break;
360
+ } while (nextLink);
361
+ if (!firstResponse) throw new Error("No response received from the API");
362
+ const response = {
363
+ "@odata.context": firstResponse["@odata.context"],
364
+ value: results
365
+ };
366
+ if (fetchAll) return response;
367
+ if (firstResponse["@odata.nextLink"]) return Object.assign(Object.assign({}, response), { "@odata.nextLink": firstResponse["@odata.nextLink"] });
368
+ return response;
369
+ });
370
+ const cleanExpirationDateTime = (input) => {
371
+ if (input) {
372
+ const date = _prismatic_io_spectral.util.types.toDate(input);
373
+ if (Number.isNaN(date.getTime())) throw new Error("Invalid date format for expiration date/time.");
374
+ return date.toISOString();
375
+ }
376
+ const expirationDate = /* @__PURE__ */ new Date();
377
+ expirationDate.setTime(expirationDate.getTime() + DEFAULT_SUBSCRIPTION_EXPIRATION_MINUTES * 60 * 1e3);
378
+ return expirationDate.toISOString();
379
+ };
380
+ //#endregion
381
+ //#region ../../packages/ms-utils/dist/subscriptions/triggerFunctions.js
382
+ var __awaiter$1 = function(thisArg, _arguments, P, generator) {
383
+ function adopt(value) {
384
+ return value instanceof P ? value : new P(function(resolve) {
385
+ resolve(value);
386
+ });
387
+ }
388
+ return new (P || (P = Promise))(function(resolve, reject) {
389
+ function fulfilled(value) {
390
+ try {
391
+ step(generator.next(value));
392
+ } catch (e) {
393
+ reject(e);
394
+ }
395
+ }
396
+ function rejected(value) {
397
+ try {
398
+ step(generator["throw"](value));
399
+ } catch (e) {
400
+ reject(e);
401
+ }
402
+ }
403
+ function step(result) {
404
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
405
+ }
406
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
407
+ });
408
+ };
409
+ const createSubscriptionTrigger = (client_1, _a, context_1) => __awaiter$1(void 0, [
410
+ client_1,
411
+ _a,
412
+ context_1
413
+ ], void 0, function* (client, { resource, changeType, customHeaders, clientState, expirationDateTime, allowDuplicates, notificationUrl }, context) {
414
+ const flowId = context.flow.id;
415
+ const flowName = context.flow.name;
416
+ const webhookUrl = context.webhookUrls[flowName];
417
+ const subscription = yield createSubscriptionFN(client, {
418
+ resource,
419
+ changeType,
420
+ notificationUrl: notificationUrl || webhookUrl,
421
+ expirationDateTime: expirationDateTime || calculateExpirationDateTime(),
422
+ clientState,
423
+ customHeaders,
424
+ allowDuplicates
425
+ }, context);
426
+ context.logger.info(`Created Graph subscription ${subscription.id} for flow ${flowName} (${flowId})`);
427
+ return subscription;
428
+ });
429
+ const deleteSubscriptionTrigger = (client, context) => __awaiter$1(void 0, void 0, void 0, function* () {
430
+ const flowId = context.flow.id;
431
+ const flowName = context.flow.name;
432
+ const webhookUrl = context.webhookUrls[flowName];
433
+ const deletedSubscriptions = yield deleteAllSubscriptionsFN(client, webhookUrl);
434
+ context.logger.info(`Deleted ${deletedSubscriptions.length} Graph subscription(s) for flow ${flowName} (${flowId})`);
435
+ });
436
+ const DEFAULT_SCOPES = "Sites.ReadWrite.All Sites.Manage.All offline_access";
437
+ const DELTA_NEXT_LINK_SUFFIX = ":nextLink";
438
+ //#endregion
439
+ //#region src/connections.ts
440
+ const source = {
441
+ label: "Source",
442
+ type: "string",
443
+ required: true,
444
+ shown: false,
445
+ default: "SharePoint"
446
+ };
447
+ const templatedOauth = getMicrosoftOAuth2AuthorizationCodeConnection({
448
+ key: ConnectionKeys.SharepointTemplatedOauth,
449
+ defaultScopes: DEFAULT_SCOPES,
450
+ additionalInputs: { source }
451
+ });
452
+ const oauthClientCredentials = getMicrosoftOAuth2ClientCredentialsConnection({ key: ConnectionKeys.OauthClientCredentials });
453
+ const certificateCredentials = getMicrosoftCertificateCredentialsConnection({ key: ConnectionKeys.CertificateCredentials });
454
+ var connections_default = [
455
+ templatedOauth,
456
+ oauthClientCredentials,
457
+ certificateCredentials,
458
+ (0, _prismatic_io_spectral.oauth2Connection)({
459
+ key: ConnectionKeys.SharedOauth,
460
+ display: {
461
+ label: "Microsoft SharePoint OAuth 2.0 (Deprecated)",
462
+ description: "Authenticates actions in the Microsoft SharePoint component."
463
+ },
464
+ oauth2Type: _prismatic_io_spectral.OAuth2Type.AuthorizationCode,
465
+ inputs: {
466
+ baseUrl: {
467
+ label: "Base URL",
468
+ placeholder: "https://graph.microsoft.com",
469
+ example: "https://graph.microsoft.com",
470
+ default: "https://graph.microsoft.com",
471
+ type: "string",
472
+ required: true,
473
+ shown: true,
474
+ comments: "The base URL for the Microsoft Graph API. Depending on your cloud environment, you can choose the correct one [here](https://learn.microsoft.com/en-us/graph/deployments#microsoft-graph-and-graph-explorer-service-root-endpoints)."
475
+ },
476
+ authorizeUrl: {
477
+ label: "Authorize URL",
478
+ placeholder: "Enter authorize URL",
479
+ type: "string",
480
+ required: true,
481
+ shown: true,
482
+ comments: "Provide a tenant specific OAuth 2.0 authorize endpoint.",
483
+ default: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
484
+ },
485
+ tokenUrl: {
486
+ label: "Token URL",
487
+ placeholder: "Enter token URL",
488
+ type: "string",
489
+ required: true,
490
+ shown: true,
491
+ comments: "Provide a tenant specific OAuth 2.0 token endpoint.",
492
+ default: "https://login.microsoftonline.com/common/oauth2/v2.0/token"
493
+ },
494
+ scopes: {
495
+ label: "Scopes",
496
+ placeholder: "Enter space-separated scopes",
497
+ type: "string",
498
+ required: true,
499
+ shown: true,
500
+ comments: "Space separated OAuth 2.0 permission scopes.",
501
+ default: DEFAULT_SCOPES
502
+ },
503
+ clientId: {
504
+ label: "Client ID",
505
+ placeholder: "Enter Client ID",
506
+ type: "string",
507
+ required: true,
508
+ shown: true,
509
+ comments: "Client Id of your Azure application."
510
+ },
511
+ clientSecret: {
512
+ label: "Client Secret",
513
+ placeholder: "Enter Client Secret",
514
+ type: "password",
515
+ required: true,
516
+ shown: true,
517
+ comments: "Client Secret generated under 'Certificates & Secrets' in your Azure application."
518
+ },
519
+ source
520
+ }
521
+ })
522
+ ];
523
+ //#endregion
524
+ //#region src/utils.ts
525
+ const validateConnection = (connection) => {
526
+ if (!connections_default.map((c) => c.key).includes(connection.key)) throw new _prismatic_io_spectral.ConnectionError(connection, `Unsupported connection method ${connection.key}.`);
527
+ };
528
+ const paginateResults = async (client, endpoint, { returnFullData = false, useTop = true, excludeParents = false } = {}) => {
529
+ const results = [];
530
+ let nextLink = endpoint;
531
+ let isFirstTime = true;
532
+ let fullData;
533
+ do {
534
+ const { data } = await client.get(nextLink, {
535
+ params: isFirstTime && useTop ? { $top: 100 } : void 0,
536
+ headers: { Prefer: excludeParents ? "deltaExcludeParent" : void 0 }
537
+ });
538
+ const existent = results.map((r) => r.id);
539
+ const toAdd = data.value.filter((r) => !existent.includes(r.id));
540
+ results.push(...toAdd);
541
+ nextLink = data["@odata.nextLink"];
542
+ isFirstTime = false;
543
+ fullData = data;
544
+ } while (nextLink);
545
+ if (returnFullData) {
546
+ fullData.value = results;
547
+ return fullData;
548
+ }
549
+ return results;
550
+ };
551
+ const sortArray = (array) => {
552
+ return array.sort((a, b) => (a.label || "") < (b.label || "") ? -1 : 1);
553
+ };
554
+ const getFilesFromDriveFN = async (client, driveId, drives = []) => {
555
+ const allFiles = [];
556
+ let rootContext;
557
+ const processFolder = async (folderId) => {
558
+ const folderFiles = [];
559
+ let nextLink;
560
+ do {
561
+ const endpoint = folderId === "root" ? `/drives/${driveId}/root/children` : `/drives/${driveId}/items/${folderId}/children`;
562
+ const { data } = await client.get(nextLink || endpoint);
563
+ if (folderId === "root" && !rootContext) rootContext = data["@odata.context"];
564
+ const folders = [];
565
+ for (const item of data.value) if (item.folder) folders.push(item);
566
+ else folderFiles.push(item);
567
+ if (folders.length > 0) {
568
+ const subFolderResults = await Promise.all(folders.map((folder) => processFolder(folder.id)));
569
+ folderFiles.push(...subFolderResults.flat());
570
+ }
571
+ nextLink = data["@odata.nextLink"];
572
+ } while (nextLink);
573
+ return folderFiles;
574
+ };
575
+ if (drives.length > 0) {
576
+ const driveResults = await Promise.all(drives.map(async (drive) => {
577
+ if (drive.folder) return processFolder(drive.id);
578
+ return [drive];
579
+ }));
580
+ allFiles.push(...driveResults.flat());
581
+ } else {
582
+ const rootFiles = await processFolder("root");
583
+ allFiles.push(...rootFiles);
584
+ }
585
+ return {
586
+ value: allFiles,
587
+ ...rootContext ? { "@odata.context": rootContext } : {}
588
+ };
589
+ };
590
+ const getAccessToken = async (connection) => {
591
+ if (connection.key === certificateCredentials.key) {
592
+ const authority = `${connection.fields.entraIdEndpoint}/${connection.fields.tenant}`;
593
+ const result = await new _azure_msal_node.ConfidentialClientApplication({ auth: {
594
+ clientId: _prismatic_io_spectral.util.types.toString(connection.fields.clientId),
595
+ clientCertificate: {
596
+ privateKey: _prismatic_io_spectral.util.types.toString(connection.fields.certificate).replace(/\\n/g, "\n"),
597
+ thumbprint: _prismatic_io_spectral.util.types.toString(connection.fields.certificateThumbprint)
598
+ },
599
+ authority
600
+ } }).acquireTokenByClientCredential({ scopes: _prismatic_io_spectral.util.types.toString(connection.fields.scopes).split(",").map((s) => s.trim()) });
601
+ if (!result) throw new _prismatic_io_spectral.ConnectionError(connection, "Could not acquire access token with certificate.");
602
+ return result?.accessToken;
603
+ }
604
+ return _prismatic_io_spectral.util.types.toString(connection.token?.access_token);
605
+ };
606
+ const addDeleted = ({ change, isDeleted, separatedChanges }) => {
607
+ if (isDeleted) {
608
+ if (!separatedChanges.deleted) separatedChanges.deleted = [];
609
+ separatedChanges.deleted.push(change);
610
+ }
611
+ };
612
+ const addUpdated = ({ change, isDeleted, separatedChanges }) => {
613
+ if (change.lastModifiedDateTime && change.createdDateTime && new Date(change.lastModifiedDateTime) > new Date(change.createdDateTime) && !isDeleted) {
614
+ if (!separatedChanges.updated) separatedChanges.updated = [];
615
+ separatedChanges.updated.push(change);
616
+ }
617
+ };
618
+ const addCreated = ({ change, isDeleted, separatedChanges }) => {
619
+ if (change.lastModifiedDateTime === change.createdDateTime && !isDeleted) {
620
+ if (!separatedChanges.added) separatedChanges.added = [];
621
+ separatedChanges.added.push(change);
622
+ }
623
+ };
624
+ const separateDriveChanges = (items, isMatch = () => true) => {
625
+ const separatedChanges = {};
626
+ for (const change of items) {
627
+ const isDeleted = Object.keys(change).includes("deleted");
628
+ if (Object.keys(change).includes("root") || !isMatch(change)) continue;
629
+ addDeleted({
630
+ isDeleted,
631
+ separatedChanges,
632
+ change
633
+ });
634
+ addUpdated({
635
+ isDeleted,
636
+ separatedChanges,
637
+ change
638
+ });
639
+ addCreated({
640
+ isDeleted,
641
+ separatedChanges,
642
+ change
643
+ });
644
+ }
645
+ return separatedChanges;
646
+ };
647
+ const deltaNextLinkKey = (key) => `${key}${DELTA_NEXT_LINK_SUFFIX}`;
648
+ const resolveDeltaUrl = (state, key, rootDelta, incomingNextLink) => incomingNextLink ?? state[deltaNextLinkKey(key)] ?? state[key] ?? rootDelta;
649
+ const resyncLocation = (error) => {
650
+ const response = error?.response;
651
+ if (response?.status !== 410) return null;
652
+ const location = response.headers?.location;
653
+ return typeof location === "string" && location ? location : void 0;
654
+ };
655
+ const fetchDeltaPage = async (client, url, rootDelta) => {
656
+ const get = async (target) => {
657
+ const { data } = await client.get(target, {
658
+ params: void 0,
659
+ headers: { Prefer: "deltaExcludeParent" }
660
+ });
661
+ return data;
662
+ };
663
+ try {
664
+ return await get(url);
665
+ } catch (error) {
666
+ const location = resyncLocation(error);
667
+ if (location === null) throw error;
668
+ return get(location ?? rootDelta);
669
+ }
670
+ };
671
+ const fetchDeltaRound = async (client, state, key, rootDelta, incoming) => {
672
+ const page = await fetchDeltaPage(client, resolveDeltaUrl(state, key, rootDelta, incoming?.nextLink), rootDelta);
673
+ const nextLink = page["@odata.nextLink"];
674
+ if (nextLink) return {
675
+ page,
676
+ next: { nextLink },
677
+ cursorState: {
678
+ ...state[key] ? { [key]: state[key] } : {},
679
+ [deltaNextLinkKey(key)]: nextLink
680
+ }
681
+ };
682
+ return {
683
+ page,
684
+ next: null,
685
+ cursorState: { [key]: page["@odata.deltaLink"] }
686
+ };
687
+ };
688
+ const folderPathFrom = (items, folderId, current) => {
689
+ const targetFolder = items.find((item) => item.id === folderId);
690
+ if (!targetFolder) return current;
691
+ return targetFolder.parentReference?.path ? `${targetFolder.parentReference.path}/${targetFolder.name}` : `/root:/${targetFolder.name}`;
692
+ };
693
+ const folderMatcher = (folderId, includeSubfolders, folderPath) => (change) => {
694
+ const isFolderItself = change.id === folderId;
695
+ if (includeSubfolders && folderPath) return isFolderItself || change.parentReference.path.includes(folderPath);
696
+ return isFolderItself || change.parentReference?.id === folderId;
697
+ };
698
+ const fetchSiteDeltaRound = async (client, state, rootDeltaFor, drives, incoming) => {
699
+ const drivesById = new Map(drives.map((drive) => [drive.id, drive]));
700
+ let remaining = (incoming?.remaining ?? drives.map((drive) => drive.id)).filter((id) => drivesById.has(id));
701
+ let resume = incoming?.nextLink && incoming.remaining[0] === remaining[0] ? { nextLink: incoming.nextLink } : void 0;
702
+ const newPollingState = {};
703
+ for (const drive of drives) for (const key of [drive.id, deltaNextLinkKey(drive.id)]) if (state[key]) newPollingState[key] = state[key];
704
+ const changes = {};
705
+ while (remaining.length > 0) {
706
+ const drive = drivesById.get(remaining[0]);
707
+ const { page, next, cursorState } = await fetchDeltaRound(client, state, drive.id, rootDeltaFor(drive.id), resume);
708
+ resume = void 0;
709
+ delete newPollingState[deltaNextLinkKey(drive.id)];
710
+ Object.assign(newPollingState, cursorState);
711
+ const driveChanges = separateDriveChanges(page.value);
712
+ const hasChanges = Object.keys(driveChanges).length > 0;
713
+ if (hasChanges) changes[drive.name] = driveChanges;
714
+ if (next) return {
715
+ changes,
716
+ next: {
717
+ remaining,
718
+ nextLink: next.nextLink
719
+ },
720
+ newPollingState
721
+ };
722
+ remaining = remaining.slice(1);
723
+ if (hasChanges) break;
724
+ }
725
+ return {
726
+ changes,
727
+ next: remaining.length > 0 ? { remaining } : null,
728
+ newPollingState
729
+ };
730
+ };
731
+ const resolvePollingRecordChanges = (data) => {
732
+ const changesObject = data ?? {};
733
+ return [
734
+ ...(changesObject.deleted ?? []).map((record) => ({
735
+ changeType: "deleted",
736
+ record
737
+ })),
738
+ ...(changesObject.added ?? []).map((record) => ({
739
+ changeType: "added",
740
+ record
741
+ })),
742
+ ...(changesObject.updated ?? []).map((record) => ({
743
+ changeType: "updated",
744
+ record
745
+ })),
746
+ ...(changesObject.moved ?? []).map((record) => ({
747
+ changeType: "moved",
748
+ record
749
+ }))
750
+ ];
751
+ };
752
+ const resolveSitePollingRecordChanges = (data) => Object.values(data ?? {}).flatMap((driveChanges) => resolvePollingRecordChanges(driveChanges));
753
+ //#endregion
754
+ //#region src/client.ts
755
+ const createClient = async (connection, debug) => {
756
+ validateConnection(connection);
757
+ const baseUrl = `${_prismatic_io_spectral.util.types.toString(connection.fields.baseUrl) || "https://graph.microsoft.com"}/v1.0`;
758
+ const accessToken = await getAccessToken(connection);
759
+ if (!accessToken) throw new _prismatic_io_spectral.ConnectionError(connection, "Received a Connection without a valid access token.");
760
+ return (0, _prismatic_io_spectral_http.createClient)({
761
+ baseUrl,
762
+ headers: {
763
+ Authorization: `Bearer ${accessToken}`,
764
+ Accept: "application/json"
765
+ },
766
+ responseType: "json",
767
+ debug
768
+ });
769
+ };
770
+ //#endregion
771
+ //#region src/inputs.ts
772
+ const connection = (0, _prismatic_io_spectral.input)({
773
+ label: "Connection",
774
+ type: "connection",
775
+ required: true,
776
+ comments: "The Microsoft SharePoint connection to use."
777
+ });
778
+ const siteId = (0, _prismatic_io_spectral.input)({
779
+ label: "Site Id",
780
+ type: "string",
781
+ required: true,
782
+ placeholder: "Enter SharePoint site ID",
783
+ comments: "The unique identifier of a SharePoint site.",
784
+ dataSource: "listSites",
785
+ example: "example.sharepoint.com,c45de8832-a4969-479d-aeb2-7nAh8321,48bf81d7-2d37-40a9-b47b-c1d1960d00f87"
786
+ });
787
+ const driveId = (0, _prismatic_io_spectral.input)({
788
+ label: "Drive",
789
+ type: "string",
790
+ required: true,
791
+ placeholder: "Enter drive ID",
792
+ comments: "The unique identifier of a SharePoint drive.",
793
+ example: "b!WumF-zsD8ku93Y0QqhKM9jVTjPefo6RGrpVCkPpe547Qrf38sox_TYIFuj9sqJhv",
794
+ dataSource: "listDrives",
795
+ clean: _prismatic_io_spectral.util.types.toString
796
+ });
797
+ const folderId = (0, _prismatic_io_spectral.input)({
798
+ label: "Folder ID",
799
+ placeholder: "Enter folder ID",
800
+ type: "string",
801
+ required: false,
802
+ example: "01Q7VXAXZW7LCB32ODBRCKZNSJIC544FXU",
803
+ comments: "The unique identifier of a SharePoint folder. Leave empty to use root folder.",
804
+ dataSource: "listFolders",
805
+ clean: (value) => {
806
+ const folderId = _prismatic_io_spectral.util.types.toString(value);
807
+ if (folderId.trim() === "") return "root";
808
+ return folderId;
809
+ }
810
+ });
811
+ const listId = (0, _prismatic_io_spectral.input)({
812
+ label: "List Id",
813
+ type: "string",
814
+ required: true,
815
+ placeholder: "Enter list ID",
816
+ comments: "The unique identifier of a SharePoint site list.",
817
+ example: "48bf81d7-2d37-40a9-b47b-c1d1960d00f87",
818
+ dataSource: "selectSiteList"
819
+ });
820
+ const itemId = (0, _prismatic_io_spectral.input)({
821
+ label: "Item Id",
822
+ type: "string",
823
+ required: true,
824
+ placeholder: "Enter item ID",
825
+ comments: "The unique identifier of a SharePoint item.",
826
+ dataSource: "listItemsInSiteList",
827
+ example: "01Q7VXROAW7LCB32ODBRCKZNSJIC544XAQ"
828
+ });
829
+ const pageLimit = (0, _prismatic_io_spectral.input)({
830
+ label: "Page Limit",
831
+ type: "string",
832
+ required: false,
833
+ placeholder: "Enter page limit",
834
+ example: "100",
835
+ comments: "The maximum number of results to return per page.",
836
+ clean: _prismatic_io_spectral.util.types.toNumber
837
+ });
838
+ const pageToken = (0, _prismatic_io_spectral.input)({
839
+ label: "Page Token",
840
+ type: "string",
841
+ required: false,
842
+ placeholder: "Enter pagination token",
843
+ example: "X%2744537079ghv",
844
+ comments: "The token for the desired page from a previous response.",
845
+ clean: _prismatic_io_spectral.util.types.toString
846
+ });
847
+ const optInFields = (0, _prismatic_io_spectral.input)({
848
+ label: "Opt In Fields",
849
+ type: "string",
850
+ required: false,
851
+ placeholder: "Enter comma-separated field names",
852
+ example: "name, description, id",
853
+ comments: "Comma-separated list of fields to return. Overrides the default result set.",
854
+ clean: _prismatic_io_spectral.util.types.toString
855
+ });
856
+ const fileName = (0, _prismatic_io_spectral.input)({
857
+ label: "File Name",
858
+ type: "string",
859
+ required: true,
860
+ placeholder: "Enter file name",
861
+ comments: "The name of the file including extension.",
862
+ example: "reports.csv"
863
+ });
864
+ const fileData = (0, _prismatic_io_spectral.input)({
865
+ label: "File Data",
866
+ type: "data",
867
+ required: true,
868
+ comments: "The file content to upload to SharePoint. Reference a file from a previous step or provide file data.",
869
+ clean: _prismatic_io_spectral.util.types.toData
870
+ });
871
+ (0, _prismatic_io_spectral.input)({
872
+ label: "Parent Id",
873
+ type: "string",
874
+ required: true,
875
+ placeholder: "Enter parent ID",
876
+ comments: "The unique identifier of the parent folder or drive item.",
877
+ example: "48bf81d7-2d37-40a9-b47b-c1d1960d00f87"
878
+ });
879
+ const fields = (0, _prismatic_io_spectral.input)({
880
+ label: "Fields",
881
+ type: "string",
882
+ required: true,
883
+ collection: "keyvaluelist",
884
+ placeholder: "Enter field key-value pairs",
885
+ comments: "Key-value pairs to set as properties on the drive item. Each key represents a field name and its corresponding value."
886
+ });
887
+ const changeType = (0, _prismatic_io_spectral.input)({
888
+ label: "Change Type",
889
+ type: "string",
890
+ required: true,
891
+ placeholder: "Enter change type",
892
+ comments: "The type of changes that should generate notifications. Common values: updated, created, deleted.",
893
+ example: "updated",
894
+ default: "updated",
895
+ clean: _prismatic_io_spectral.util.types.toString
896
+ });
897
+ const notificationUrl = (0, _prismatic_io_spectral.input)({
898
+ label: "Notification URL",
899
+ type: "string",
900
+ required: true,
901
+ placeholder: "Enter notification URL",
902
+ comments: "The URL where Microsoft Graph will deliver webhook notifications when changes occur.",
903
+ example: "https://contoso.azurewebsites.net/api/webhook-receiver",
904
+ clean: _prismatic_io_spectral.util.types.toString
905
+ });
906
+ const resource = (0, _prismatic_io_spectral.input)({
907
+ label: "Resource",
908
+ type: "string",
909
+ required: true,
910
+ placeholder: "Enter resource path",
911
+ comments: "The Microsoft Graph resource path to monitor for changes.",
912
+ example: "/me/drive/root",
913
+ clean: _prismatic_io_spectral.util.types.toString
914
+ });
915
+ const expirationDateTime = (0, _prismatic_io_spectral.input)({
916
+ label: "Expiration Date Time",
917
+ type: "string",
918
+ required: true,
919
+ placeholder: "Enter expiration date/time",
920
+ comments: "The date and time when the subscription will expire if not updated or renewed.",
921
+ example: "2018-01-01T11:23:00.000Z",
922
+ clean: cleanExpirationDateTime
923
+ });
924
+ const clientState = (0, _prismatic_io_spectral.input)({
925
+ label: "Client State",
926
+ type: "string",
927
+ required: false,
928
+ placeholder: "Enter client state value",
929
+ comments: "An optional validation token included in each notification to verify the notification source.",
930
+ example: "client-specific string",
931
+ clean: _prismatic_io_spectral.util.types.toString
932
+ });
933
+ const subscriptionId = (0, _prismatic_io_spectral.input)({
934
+ label: "Subscription Id",
935
+ type: "string",
936
+ required: true,
937
+ placeholder: "Enter subscription ID",
938
+ comments: "The unique identifier of the subscription to manage.",
939
+ example: "48bf81d7-2d37-40a9-b47b-c1d1960d00f87",
940
+ dataSource: "listSubscriptions",
941
+ clean: _prismatic_io_spectral.util.types.toString
942
+ });
943
+ const allowDuplicates = (0, _prismatic_io_spectral.input)({
944
+ label: "Allow Duplicates",
945
+ type: "boolean",
946
+ required: false,
947
+ default: "false",
948
+ comments: "When true, allows creating multiple subscriptions for the same endpoint.",
949
+ clean: _prismatic_io_spectral.util.types.toBool
950
+ });
951
+ const showInstanceSubscriptions = (0, _prismatic_io_spectral.input)({
952
+ label: "Show Instance Subscriptions",
953
+ type: "boolean",
954
+ required: false,
955
+ default: "true",
956
+ comments: "When true, filters results to show only subscriptions created by this instance.",
957
+ clean: _prismatic_io_spectral.util.types.toBool
958
+ });
959
+ const deltaURL = (0, _prismatic_io_spectral.input)({
960
+ label: "URL to fetch for delta",
961
+ type: "string",
962
+ required: true,
963
+ placeholder: "Enter delta URL or link",
964
+ comments: "The URL to track changes in a driveItem and its children over time. You can also paste the @odata.nextLink or @odata.deltaLink from a previous response to resume tracking changes.",
965
+ example: "/drives/{drive-id}/root/delta",
966
+ default: "/drives/{drive-id}/root/delta",
967
+ clean: _prismatic_io_spectral.util.types.toString
968
+ });
969
+ const $select = (0, _prismatic_io_spectral.input)({
970
+ label: "$select Parameter",
971
+ type: "string",
972
+ required: false,
973
+ placeholder: "Enter comma-separated field names",
974
+ comments: "Filters properties (columns). https://learn.microsoft.com/en-us/graph/query-parameters?tabs=http#select-parameter",
975
+ example: "givenName,surname",
976
+ clean: _prismatic_io_spectral.util.types.toString
977
+ });
978
+ const $expand = (0, _prismatic_io_spectral.input)({
979
+ label: "$expand Parameter",
980
+ type: "string",
981
+ required: false,
982
+ placeholder: "Enter relationship to expand",
983
+ comments: "Retrieves related resources. https://learn.microsoft.com/en-us/graph/query-parameters?tabs=http#expand-parameter",
984
+ example: "members",
985
+ clean: _prismatic_io_spectral.util.types.toString
986
+ });
987
+ const $top = (0, _prismatic_io_spectral.input)({
988
+ label: "$top Parameter",
989
+ type: "string",
990
+ required: false,
991
+ placeholder: "Enter page size",
992
+ comments: "Sets the page size of results. https://learn.microsoft.com/en-us/graph/query-parameters?tabs=http#top-parameter",
993
+ example: "5",
994
+ clean: _prismatic_io_spectral.util.types.toString
995
+ });
996
+ const fetchAll = (0, _prismatic_io_spectral.input)({
997
+ label: "Fetch All",
998
+ type: "boolean",
999
+ required: false,
1000
+ comments: "When true, retrieves all results by automatically following pagination.",
1001
+ clean: _prismatic_io_spectral.util.types.toBool
1002
+ });
1003
+ const recursive = (0, _prismatic_io_spectral.input)({
1004
+ label: "Recursive",
1005
+ type: "boolean",
1006
+ required: false,
1007
+ comments: "When true, returns files from all subfolders in addition to the specified folder.",
1008
+ clean: _prismatic_io_spectral.util.types.toBool
1009
+ });
1010
+ const parentItemId = (0, _prismatic_io_spectral.input)({
1011
+ label: "Parent Item Id",
1012
+ type: "string",
1013
+ required: true,
1014
+ placeholder: "Enter parent item ID",
1015
+ comments: "The unique identifier of the parent folder. Use 'root' for the drive root.",
1016
+ example: "root",
1017
+ clean: _prismatic_io_spectral.util.types.toString
1018
+ });
1019
+ const folderName = (0, _prismatic_io_spectral.input)({
1020
+ label: "Folder Name",
1021
+ type: "string",
1022
+ required: true,
1023
+ example: "MyFolder",
1024
+ placeholder: "Enter folder name",
1025
+ comments: "The name of the folder.",
1026
+ clean: _prismatic_io_spectral.util.types.toString
1027
+ });
1028
+ const createFolderInputs = {
1029
+ connection,
1030
+ siteId: {
1031
+ ...siteId,
1032
+ comments: "Provide the id of the site to create the folder in."
1033
+ },
1034
+ driveId: {
1035
+ ...driveId,
1036
+ comments: "Provide the id of the drive to create the folder in."
1037
+ },
1038
+ parentItemId: {
1039
+ ...parentItemId,
1040
+ comments: "Provide the id of the parent element to create the folder in."
1041
+ },
1042
+ folderName: {
1043
+ ...folderName,
1044
+ comments: "Provide the name of the new folder."
1045
+ }
1046
+ };
1047
+ const moveFileInputs = {
1048
+ connection,
1049
+ siteId: {
1050
+ ...siteId,
1051
+ required: false
1052
+ },
1053
+ listId: {
1054
+ ...listId,
1055
+ required: false
1056
+ },
1057
+ driveId: {
1058
+ ...driveId,
1059
+ comments: "Provide the id of the drive to move the file in."
1060
+ },
1061
+ itemId: {
1062
+ ...itemId,
1063
+ comments: "Provide the id of the file to move."
1064
+ },
1065
+ parentItemId: {
1066
+ ...parentItemId,
1067
+ label: "Destination Parent Id",
1068
+ comments: "Provide the Id of the destination parent element to move file to."
1069
+ }
1070
+ };
1071
+ const listItemsInputs = {
1072
+ connection,
1073
+ siteId: {
1074
+ ...siteId,
1075
+ required: false
1076
+ },
1077
+ driveId: {
1078
+ ...driveId,
1079
+ comments: "Provide the id of the drive to list the items in."
1080
+ },
1081
+ folderId: {
1082
+ ...folderId,
1083
+ comments: "Provide the id of the folder to list the items in.",
1084
+ required: true
1085
+ }
1086
+ };
1087
+ const renameFolderInputs = {
1088
+ connection,
1089
+ siteId: {
1090
+ ...siteId,
1091
+ comments: "Provide the id of the site to rename the folder in."
1092
+ },
1093
+ driveId: {
1094
+ ...driveId,
1095
+ comments: "Provide the id of the drive to rename the folder in."
1096
+ },
1097
+ folderId: {
1098
+ ...folderId,
1099
+ comments: "Provide the id of the folder to rename.",
1100
+ required: true
1101
+ },
1102
+ folderName: {
1103
+ ...folderName,
1104
+ comments: "Provide the new name of the folder."
1105
+ }
1106
+ };
1107
+ const query = (0, _prismatic_io_spectral.input)({
1108
+ label: "Query",
1109
+ type: "string",
1110
+ required: true,
1111
+ example: "Invoices",
1112
+ placeholder: "Enter search query",
1113
+ comments: "The search query to find items by name.",
1114
+ clean: _prismatic_io_spectral.util.types.toString
1115
+ });
1116
+ const searchItemsInputs = {
1117
+ connection,
1118
+ siteId: {
1119
+ ...siteId,
1120
+ comments: "Provide the id of the site to search the items in."
1121
+ },
1122
+ query: {
1123
+ ...query,
1124
+ comments: "Provide the query to search for items by name."
1125
+ }
1126
+ };
1127
+ const itemPath = (0, _prismatic_io_spectral.input)({
1128
+ label: "Item Path",
1129
+ type: "string",
1130
+ required: true,
1131
+ example: "MyFolder/example.txt",
1132
+ placeholder: "Enter item path",
1133
+ comments: "The path to the file or folder, relative to the drive root.",
1134
+ clean: _prismatic_io_spectral.util.types.toString
1135
+ });
1136
+ const expirationDays = (0, _prismatic_io_spectral.input)({
1137
+ label: "Expiration Days",
1138
+ type: "string",
1139
+ placeholder: "Enter number of days",
1140
+ comments: "Number of days to extend the subscription. Maximum is 30 days for SharePoint/OneDrive resources.",
1141
+ example: "3",
1142
+ default: "3",
1143
+ required: false,
1144
+ clean: (value) => {
1145
+ const days = _prismatic_io_spectral.util.types.toNumber(value);
1146
+ return days > 0 && days <= 30 ? days : 3;
1147
+ }
1148
+ });
1149
+ const includeSubfolders = (0, _prismatic_io_spectral.input)({
1150
+ label: "Include Subfolders",
1151
+ type: "boolean",
1152
+ required: false,
1153
+ default: "false",
1154
+ comments: "When enabled, changes in subfolders will also be tracked recursively.",
1155
+ clean: _prismatic_io_spectral.util.types.toBool
1156
+ });
1157
+ const checkItemExistsInputs = {
1158
+ connection,
1159
+ siteId: {
1160
+ ...siteId,
1161
+ comments: "Provide the id of the site to check the item in."
1162
+ },
1163
+ driveId: {
1164
+ ...driveId,
1165
+ comments: "Provide the id of the drive to check the item in."
1166
+ },
1167
+ itemPath: {
1168
+ ...itemPath,
1169
+ comments: "Provide the path to the file or folder, relative to the drive root."
1170
+ }
1171
+ };
1172
+ const instanceDeployWebhookInputs = {
1173
+ connection,
1174
+ resource: {
1175
+ ...resource,
1176
+ comments: "The Microsoft Graph resource path to monitor. Examples: /me/drive/root, /sites/{site-id}/drive/root, /drives/{drive-id}/root"
1177
+ },
1178
+ changeType,
1179
+ clientState: {
1180
+ ...clientState,
1181
+ comments: "Optional validation token sent with each notification. Use to verify notifications originate from Microsoft Graph."
1182
+ },
1183
+ expirationDateTime: {
1184
+ ...expirationDateTime,
1185
+ required: false,
1186
+ comments: "Optional expiration date/time for the subscription. If not provided, defaults to 3 days from now. Maximum is 30 days for SharePoint/OneDrive resources."
1187
+ }
1188
+ };
1189
+ const deleteAllSubscriptionsInputs = {
1190
+ connection,
1191
+ notificationUrl: {
1192
+ ...notificationUrl,
1193
+ comments: "The notification URL used when creating subscriptions for this instance. Only subscriptions with this URL will be deleted. If not provided, all subscriptions for this flow will be deleted.",
1194
+ required: false
1195
+ }
1196
+ };
1197
+ const renewSubscriptionInputs = {
1198
+ connection,
1199
+ subscriptionId,
1200
+ expirationDays
1201
+ };
1202
+ const folderPollingTriggerInputs = {
1203
+ connection,
1204
+ siteId: {
1205
+ ...siteId,
1206
+ required: false
1207
+ },
1208
+ driveId,
1209
+ folderId: {
1210
+ ...folderId,
1211
+ comments: "The ID of the folder to monitor for changes.",
1212
+ required: true
1213
+ },
1214
+ includeSubfolders
1215
+ };
1216
+ //#endregion
1217
+ //#region src/actions/drive.ts
1218
+ const listDrives$1 = (0, _prismatic_io_spectral.action)({
1219
+ display: {
1220
+ label: "List Drives",
1221
+ description: "List all drives within any given SharePoint site"
1222
+ },
1223
+ inputs: {
1224
+ connection,
1225
+ siteId,
1226
+ pageLimit,
1227
+ pageToken,
1228
+ fetchAll
1229
+ },
1230
+ perform: async ({ debug: { enabled: debug } }, params) => {
1231
+ const client = await createClient(params.connection, debug);
1232
+ const endpoint = `/sites/${params.siteId}/drives`;
1233
+ if (params.fetchAll) return { data: await paginateResults(client, endpoint, { returnFullData: true }) };
1234
+ const { data } = await client.get(endpoint, { params: params.pageLimit || params.pageToken ? {
1235
+ $top: params.pageLimit,
1236
+ $skipToken: params.pageToken
1237
+ } : void 0 });
1238
+ if (data["@odata.nextLink"]) data["@odata.nextToken"] = new node_url.URL(data["@odata.nextLink"]).searchParams.get("$skipToken");
1239
+ return { data };
1240
+ },
1241
+ examplePayload: { data: {
1242
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",
1243
+ value: [{
1244
+ createdDateTime: "2025-06-14T05:14:52Z",
1245
+ description: "",
1246
+ id: "b!o2UaIfdNxk-5091VjGz1sDVso2efo6RGrpVCkPpe547Qrf38sox_TYIFuj9QrJhv",
1247
+ lastModifiedDateTime: "2025-12-09T08:30:00Z",
1248
+ name: "Documents",
1249
+ webUrl: "https://example.sharepoint.com/Shared%20Documents",
1250
+ driveType: "documentLibrary",
1251
+ createdBy: { user: { displayName: "System Account" } },
1252
+ owner: { group: {
1253
+ id: "9705118a-6ce1-4fa3-adba-09f94b69d568",
1254
+ displayName: "Example Team Site Owners"
1255
+ } },
1256
+ quota: {
1257
+ deleted: 0,
1258
+ remaining: 27487789251101,
1259
+ state: "normal",
1260
+ total: 27487790694400,
1261
+ used: 1443299
1262
+ }
1263
+ }]
1264
+ } }
1265
+ });
1266
+ const getDrive = (0, _prismatic_io_spectral.action)({
1267
+ display: {
1268
+ label: "Get Drive",
1269
+ description: "Returns the information and metadata of a SharePoint drive"
1270
+ },
1271
+ inputs: {
1272
+ connection,
1273
+ siteId: {
1274
+ ...siteId,
1275
+ required: false
1276
+ },
1277
+ driveId
1278
+ },
1279
+ perform: async ({ debug: { enabled: debug } }, params) => {
1280
+ const { data } = await (await createClient(params.connection, debug)).get(`/drives/${params.driveId}`);
1281
+ return { data };
1282
+ }
1283
+ });
1284
+ const getFilesFromDriveWithPagination = (0, _prismatic_io_spectral.action)({
1285
+ display: {
1286
+ label: "List Files in Drive",
1287
+ description: "List all the files from a Drive"
1288
+ },
1289
+ inputs: {
1290
+ connection,
1291
+ siteId: {
1292
+ ...siteId,
1293
+ required: false
1294
+ },
1295
+ driveId,
1296
+ pageLimit,
1297
+ pageToken,
1298
+ fetchAll,
1299
+ recursive
1300
+ },
1301
+ perform: async (context, { connection, siteId, driveId, pageLimit, pageToken, fetchAll, recursive }) => {
1302
+ const client = await createClient(connection, context.debug.enabled);
1303
+ const endpoint = `/drives/${driveId}/root/children`;
1304
+ if (fetchAll) {
1305
+ if (recursive) {
1306
+ const { data } = await getFilesFromDriveRecursive.perform(context, {
1307
+ connection,
1308
+ siteId,
1309
+ driveId
1310
+ });
1311
+ return { data };
1312
+ }
1313
+ return { data: await paginateResults(client, endpoint, { returnFullData: true }) };
1314
+ }
1315
+ const { data } = await client.get(endpoint, { params: {
1316
+ $top: pageLimit,
1317
+ $skipToken: pageToken
1318
+ } });
1319
+ if (data["@odata.nextLink"]) data["@odata.nextToken"] = new node_url.URL(data["@odata.nextLink"]).searchParams.get("$skipToken");
1320
+ if (recursive) {
1321
+ const { value: allFiles } = await getFilesFromDriveFN(client, driveId, data.value);
1322
+ return { data: {
1323
+ ...data,
1324
+ value: allFiles
1325
+ } };
1326
+ }
1327
+ return { data };
1328
+ }
1329
+ });
1330
+ const getFilesFromDriveFolderWithPagination = (0, _prismatic_io_spectral.action)({
1331
+ display: {
1332
+ label: "List Folder Files in Drive",
1333
+ description: "List all the files inside of a folder from a Drive"
1334
+ },
1335
+ inputs: {
1336
+ connection,
1337
+ siteId: {
1338
+ ...siteId,
1339
+ required: false
1340
+ },
1341
+ driveId,
1342
+ folderId,
1343
+ pageLimit,
1344
+ pageToken,
1345
+ fetchAll
1346
+ },
1347
+ perform: async ({ debug: { enabled: debug } }, { connection, folderId, driveId, pageLimit, pageToken, fetchAll }) => {
1348
+ const endpoint = `/drives/${driveId}/items/${folderId}/children`;
1349
+ const client = await createClient(connection, debug);
1350
+ if (fetchAll) return { data: await paginateResults(client, endpoint, { returnFullData: true }) };
1351
+ const { data } = await client.get(endpoint, { params: {
1352
+ $top: pageLimit,
1353
+ $skipToken: pageToken
1354
+ } });
1355
+ if (data["@odata.nextLink"]) data["@odata.nextToken"] = new node_url.URL(data["@odata.nextLink"]).searchParams.get("$skipToken");
1356
+ return { data };
1357
+ }
1358
+ });
1359
+ const getFile = (0, _prismatic_io_spectral.action)({
1360
+ display: {
1361
+ label: "Get File",
1362
+ description: "Get a file from a Drive"
1363
+ },
1364
+ inputs: {
1365
+ connection,
1366
+ siteId: {
1367
+ ...siteId,
1368
+ required: false
1369
+ },
1370
+ listId: {
1371
+ ...listId,
1372
+ required: false
1373
+ },
1374
+ driveId,
1375
+ itemId
1376
+ },
1377
+ perform: async ({ debug: { enabled: debug } }, { connection, driveId, itemId }) => {
1378
+ const client = await createClient(connection, debug);
1379
+ try {
1380
+ const { data } = await client.get(`/drives/${driveId}/items/${itemId}/content`);
1381
+ return { data };
1382
+ } catch (err) {
1383
+ throw new Error(err.message);
1384
+ }
1385
+ }
1386
+ });
1387
+ const uploadFile = (0, _prismatic_io_spectral.action)({
1388
+ display: {
1389
+ label: "Upload File",
1390
+ description: "Upload a file to the specified drive or folder's drive"
1391
+ },
1392
+ inputs: {
1393
+ connection,
1394
+ siteId: {
1395
+ ...siteId,
1396
+ required: false
1397
+ },
1398
+ driveId,
1399
+ fileName,
1400
+ fileData,
1401
+ folderId
1402
+ },
1403
+ perform: async ({ debug: { enabled: debug } }, { connection, driveId, fileName, folderId, fileData }) => {
1404
+ const client = await createClient(connection, debug);
1405
+ const { data } = _prismatic_io_spectral.util.types.toData(fileData);
1406
+ const { data: uploadedData } = await client.put(`/drives/${driveId}/items/${folderId}:/${fileName}:/content`, node_stream.Readable.from(data));
1407
+ return { data: uploadedData };
1408
+ }
1409
+ });
1410
+ const updateFile = (0, _prismatic_io_spectral.action)({
1411
+ display: {
1412
+ label: "Update File",
1413
+ description: "Update a file to the specified drive"
1414
+ },
1415
+ inputs: {
1416
+ connection,
1417
+ siteId: {
1418
+ ...siteId,
1419
+ required: false
1420
+ },
1421
+ listId: {
1422
+ ...listId,
1423
+ required: false
1424
+ },
1425
+ driveId,
1426
+ itemId,
1427
+ fileData
1428
+ },
1429
+ perform: async ({ debug: { enabled: debug } }, { connection, driveId, itemId, fileData }) => {
1430
+ const client = await createClient(connection, debug);
1431
+ const { data } = _prismatic_io_spectral.util.types.toData(fileData);
1432
+ const { data: updatedData } = await client.put(`/drives/${driveId}/items/${itemId}/content`, node_stream.Readable.from(data));
1433
+ return { data: updatedData };
1434
+ }
1435
+ });
1436
+ const downloadFile = (0, _prismatic_io_spectral.action)({
1437
+ display: {
1438
+ label: "Download File",
1439
+ description: "Download a file from the specified drive"
1440
+ },
1441
+ inputs: {
1442
+ connection,
1443
+ siteId: {
1444
+ ...siteId,
1445
+ required: false
1446
+ },
1447
+ listId: {
1448
+ ...listId,
1449
+ required: false
1450
+ },
1451
+ driveId,
1452
+ itemId
1453
+ },
1454
+ perform: async ({ debug: { enabled: debug } }, { connection, itemId, driveId }) => {
1455
+ const client = await createClient(connection, debug);
1456
+ try {
1457
+ const { data } = await client.get(`/drives/${driveId}/items/${itemId}`);
1458
+ const downloadURL = data["@microsoft.graph.downloadUrl"];
1459
+ const mimeType = data.file.mimeType;
1460
+ const { data: downloadedFile } = await client.get(downloadURL, { responseType: "arraybuffer" });
1461
+ return {
1462
+ data: downloadedFile,
1463
+ contentType: mimeType
1464
+ };
1465
+ } catch (err) {
1466
+ throw new Error(err.message);
1467
+ }
1468
+ }
1469
+ });
1470
+ const getFilesFromDriveRecursive = (0, _prismatic_io_spectral.action)({
1471
+ display: {
1472
+ label: "List All Files in Drive (Recursive)",
1473
+ description: "List all files from a Drive, including files in all subfolders"
1474
+ },
1475
+ inputs: {
1476
+ connection,
1477
+ siteId: {
1478
+ ...siteId,
1479
+ required: false
1480
+ },
1481
+ driveId
1482
+ },
1483
+ perform: async ({ debug: { enabled: debug } }, { connection, driveId }) => {
1484
+ return { data: await getFilesFromDriveFN(await createClient(connection, debug), driveId) };
1485
+ }
1486
+ });
1487
+ var drive_default = {
1488
+ listDrives: listDrives$1,
1489
+ getDrive,
1490
+ getFile,
1491
+ uploadFile,
1492
+ updateFile,
1493
+ downloadFile,
1494
+ getFilesFromDriveFolderWithPagination,
1495
+ getFilesFromDriveWithPagination
1496
+ };
1497
+ //#endregion
1498
+ //#region src/examplePayloads/actions.ts
1499
+ const listChangesExamplePayload = { data: {
1500
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)",
1501
+ "@odata.deltaLink": "https://graph.microsoft.com/v1.0/drives/b!ExampleDriveId/root/delta?token=MzslMjM0OyUyMzE7MDslMjM",
1502
+ value: [{
1503
+ id: "01EXAMPLENEWITEMID1234567890",
1504
+ name: "NewReport.xlsx",
1505
+ createdDateTime: "2025-12-09T14:30:00Z",
1506
+ lastModifiedDateTime: "2025-12-09T14:30:00Z",
1507
+ size: 45678,
1508
+ webUrl: "https://example.sharepoint.com/sites/ExampleSite/Shared%20Documents/NewReport.xlsx",
1509
+ file: {
1510
+ mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
1511
+ hashes: { quickXorHash: "ExampleHashValue123==" }
1512
+ },
1513
+ parentReference: {
1514
+ driveId: "b!ExampleDriveId123456789",
1515
+ id: "01EXAMPLEPARENTID",
1516
+ path: "/drives/b!ExampleDriveId123456789/root:"
1517
+ }
1518
+ }, {
1519
+ id: "01EXAMPLEUPDATEDITEM987654321",
1520
+ name: "UpdatedPresentation.pptx",
1521
+ createdDateTime: "2025-12-01T10:00:00Z",
1522
+ lastModifiedDateTime: "2025-12-09T16:45:00Z",
1523
+ size: 234567,
1524
+ webUrl: "https://example.sharepoint.com/sites/ExampleSite/Shared%20Documents/UpdatedPresentation.pptx",
1525
+ file: {
1526
+ mimeType: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
1527
+ hashes: { quickXorHash: "UpdatedHashValue456==" }
1528
+ },
1529
+ parentReference: {
1530
+ driveId: "b!ExampleDriveId123456789",
1531
+ id: "01EXAMPLEPARENTID",
1532
+ path: "/drives/b!ExampleDriveId123456789/root:"
1533
+ }
1534
+ }]
1535
+ } };
1536
+ const rawRequestExamplePayload = { data: {
1537
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites",
1538
+ value: [{
1539
+ id: "example.sharepoint.com,a1b2c3d4-e5f6-7890-abcd-ef1234567890,f1e2d3c4-b5a6-7890-1234-567890abcdef",
1540
+ displayName: "Example Team Site",
1541
+ name: "ExampleTeamSite",
1542
+ createdDateTime: "2025-06-15T08:30:00Z",
1543
+ lastModifiedDateTime: "2025-12-09T14:22:00Z",
1544
+ webUrl: "https://example.sharepoint.com/sites/ExampleTeamSite",
1545
+ siteCollection: { hostname: "example.sharepoint.com" }
1546
+ }]
1547
+ } };
1548
+ const listSharedDocumentsExamplePayload = { data: {
1549
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#me/insights/shared",
1550
+ value: [{
1551
+ id: "AWExampleInsightId1234567890",
1552
+ lastShared: {
1553
+ sharedDateTime: "2025-12-09T10:15:00Z",
1554
+ sharingSubject: "Project Update Document",
1555
+ sharingType: "Direct",
1556
+ sharedBy: {
1557
+ displayName: "Jane Smith",
1558
+ address: "jane.smith@example.com",
1559
+ id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
1560
+ }
1561
+ },
1562
+ resourceVisualization: {
1563
+ title: "Q4 Project Update.docx",
1564
+ type: "Word",
1565
+ mediaType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
1566
+ previewImageUrl: "https://example.sharepoint.com/_api/v2.0/drives/b!ExampleDriveId/items/01EXAMPLEITEMID/thumbnails/0/c400x999/content",
1567
+ previewText: "This document contains the Q4 project status update...",
1568
+ containerWebUrl: "https://example.sharepoint.com/sites/ExampleSite/Shared%20Documents",
1569
+ containerDisplayName: "Example Team Site - Documents",
1570
+ containerType: "Site"
1571
+ },
1572
+ resourceReference: {
1573
+ id: "01EXAMPLESHAREDITEMID1234567",
1574
+ webUrl: "https://example.sharepoint.com/sites/ExampleSite/Shared%20Documents/Q4%20Project%20Update.docx",
1575
+ type: "microsoft.graph.driveItem"
1576
+ }
1577
+ }, {
1578
+ id: "AWExampleInsightId9876543210",
1579
+ lastShared: {
1580
+ sharedDateTime: "2025-12-08T14:30:00Z",
1581
+ sharingSubject: "Budget Spreadsheet",
1582
+ sharingType: "Link",
1583
+ sharedBy: {
1584
+ displayName: "John Doe",
1585
+ address: "john.doe@example.com",
1586
+ id: "b2c3d4e5-f6g7-8901-bcde-f23456789012"
1587
+ }
1588
+ },
1589
+ resourceVisualization: {
1590
+ title: "2025 Budget.xlsx",
1591
+ type: "Excel",
1592
+ mediaType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
1593
+ previewImageUrl: "https://example.sharepoint.com/_api/v2.0/drives/b!ExampleDriveId/items/01EXAMPLEITEMID2/thumbnails/0/c400x999/content",
1594
+ previewText: "Annual budget spreadsheet for 2025...",
1595
+ containerWebUrl: "https://example.sharepoint.com/sites/Finance",
1596
+ containerDisplayName: "Finance Team Site",
1597
+ containerType: "Site"
1598
+ },
1599
+ resourceReference: {
1600
+ id: "01EXAMPLESHAREDITEMID9876543",
1601
+ webUrl: "https://example.sharepoint.com/sites/Finance/Documents/2025%20Budget.xlsx",
1602
+ type: "microsoft.graph.driveItem"
1603
+ }
1604
+ }]
1605
+ } };
1606
+ const listSiteListsExamplePayload = { data: {
1607
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('example.sharepoint.com%2Ca1b2c3d4-e5f6-7890-abcd-ef1234567890%2Cf1e2d3c4-b5a6-7890-1234-567890abcdef')/lists",
1608
+ value: [{
1609
+ "@odata.etag": "\"a1b2c3d4-e5f6-7890-abcd-ef1234567890,1\"",
1610
+ id: "f1e2d3c4-b5a6-7890-1234-567890abcdef",
1611
+ displayName: "Tasks",
1612
+ name: "Tasks",
1613
+ createdDateTime: "2025-06-15T08:30:00Z",
1614
+ lastModifiedDateTime: "2025-12-09T10:15:00Z",
1615
+ webUrl: "https://example.sharepoint.com/sites/ExampleSite/Lists/Tasks",
1616
+ list: {
1617
+ contentTypesEnabled: true,
1618
+ hidden: false,
1619
+ template: "genericList"
1620
+ }
1621
+ }, {
1622
+ "@odata.etag": "\"b2c3d4e5-f6g7-8901-bcde-f23456789012,2\"",
1623
+ id: "g2f3e4d5-c6b7-8901-2345-678901bcdefg",
1624
+ displayName: "Announcements",
1625
+ name: "Announcements",
1626
+ createdDateTime: "2025-07-20T12:00:00Z",
1627
+ lastModifiedDateTime: "2025-12-08T16:30:00Z",
1628
+ webUrl: "https://example.sharepoint.com/sites/ExampleSite/Lists/Announcements",
1629
+ list: {
1630
+ contentTypesEnabled: true,
1631
+ hidden: false,
1632
+ template: "announcements"
1633
+ }
1634
+ }]
1635
+ } };
1636
+ const getSiteListExamplePayload = { data: {
1637
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('example.sharepoint.com%2Ca1b2c3d4-e5f6-7890-abcd-ef1234567890%2Cf1e2d3c4-b5a6-7890-1234-567890abcdef')/lists/$entity",
1638
+ "@odata.etag": "\"a1b2c3d4-e5f6-7890-abcd-ef1234567890,3\"",
1639
+ id: "f1e2d3c4-b5a6-7890-1234-567890abcdef",
1640
+ displayName: "Project Tasks",
1641
+ name: "ProjectTasks",
1642
+ createdDateTime: "2025-06-15T08:30:00Z",
1643
+ lastModifiedDateTime: "2025-12-09T10:15:00Z",
1644
+ webUrl: "https://example.sharepoint.com/sites/ExampleSite/Lists/ProjectTasks",
1645
+ list: {
1646
+ contentTypesEnabled: true,
1647
+ hidden: false,
1648
+ template: "genericList"
1649
+ },
1650
+ columns: [{
1651
+ name: "Title",
1652
+ displayName: "Title",
1653
+ required: true,
1654
+ text: {
1655
+ allowMultipleLines: false,
1656
+ appendChangesToExistingText: false,
1657
+ linesForEditing: 0,
1658
+ maxLength: 255
1659
+ }
1660
+ }, {
1661
+ name: "Status",
1662
+ displayName: "Status",
1663
+ required: false,
1664
+ choice: {
1665
+ allowTextEntry: false,
1666
+ choices: [
1667
+ "Not Started",
1668
+ "In Progress",
1669
+ "Completed"
1670
+ ],
1671
+ displayAs: "dropDownMenu"
1672
+ }
1673
+ }]
1674
+ } };
1675
+ const listItemsInSiteListExamplePayload = { data: {
1676
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('example.sharepoint.com%2Ca1b2c3d4-e5f6-7890-abcd-ef1234567890%2Cf1e2d3c4-b5a6-7890-1234-567890abcdef')/lists('f1e2d3c4-b5a6-7890-1234-567890abcdef')/items",
1677
+ value: [{
1678
+ "@odata.etag": "\"a1b2c3d4-e5f6-7890-abcd-ef1234567890,1\"",
1679
+ id: "1",
1680
+ createdDateTime: "2025-12-01T09:00:00Z",
1681
+ lastModifiedDateTime: "2025-12-09T11:30:00Z",
1682
+ webUrl: "https://example.sharepoint.com/sites/ExampleSite/Lists/ProjectTasks/1_.000",
1683
+ fields: {
1684
+ "@odata.etag": "\"a1b2c3d4-e5f6-7890-abcd-ef1234567890,1\"",
1685
+ id: "1",
1686
+ Title: "Design new homepage",
1687
+ Status: "In Progress",
1688
+ AssignedTo: "john.doe@example.com",
1689
+ DueDate: "2025-12-15T00:00:00Z"
1690
+ }
1691
+ }, {
1692
+ "@odata.etag": "\"b2c3d4e5-f6g7-8901-bcde-f23456789012,2\"",
1693
+ id: "2",
1694
+ createdDateTime: "2025-12-05T14:20:00Z",
1695
+ lastModifiedDateTime: "2025-12-09T16:45:00Z",
1696
+ webUrl: "https://example.sharepoint.com/sites/ExampleSite/Lists/ProjectTasks/2_.000",
1697
+ fields: {
1698
+ "@odata.etag": "\"b2c3d4e5-f6g7-8901-bcde-f23456789012,2\"",
1699
+ id: "2",
1700
+ Title: "Update documentation",
1701
+ Status: "Not Started",
1702
+ AssignedTo: "jane.smith@example.com",
1703
+ DueDate: "2025-12-20T00:00:00Z"
1704
+ }
1705
+ }]
1706
+ } };
1707
+ const getItemFromSiteListExamplePayload = { data: {
1708
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('example.sharepoint.com%2Ca1b2c3d4-e5f6-7890-abcd-ef1234567890%2Cf1e2d3c4-b5a6-7890-1234-567890abcdef')/lists('f1e2d3c4-b5a6-7890-1234-567890abcdef')/items/$entity",
1709
+ "@odata.etag": "\"a1b2c3d4-e5f6-7890-abcd-ef1234567890,3\"",
1710
+ id: "5",
1711
+ createdDateTime: "2025-12-08T10:30:00Z",
1712
+ lastModifiedDateTime: "2025-12-09T14:15:00Z",
1713
+ webUrl: "https://example.sharepoint.com/sites/ExampleSite/Lists/ProjectTasks/5_.000",
1714
+ fields: {
1715
+ "@odata.etag": "\"a1b2c3d4-e5f6-7890-abcd-ef1234567890,3\"",
1716
+ id: "5",
1717
+ Title: "Review Q4 metrics",
1718
+ Status: "Completed",
1719
+ AssignedTo: "john.doe@example.com",
1720
+ DueDate: "2025-12-09T00:00:00Z",
1721
+ CompletedDate: "2025-12-09T14:15:00Z"
1722
+ }
1723
+ } };
1724
+ const createItemInSiteListExamplePayload = { data: {
1725
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('example.sharepoint.com%2Ca1b2c3d4-e5f6-7890-abcd-ef1234567890%2Cf1e2d3c4-b5a6-7890-1234-567890abcdef')/lists('f1e2d3c4-b5a6-7890-1234-567890abcdef')/items/$entity",
1726
+ "@odata.etag": "\"a1b2c3d4-e5f6-7890-abcd-ef1234567890,1\"",
1727
+ id: "15",
1728
+ createdDateTime: "2025-12-09T16:30:00Z",
1729
+ lastModifiedDateTime: "2025-12-09T16:30:00Z",
1730
+ webUrl: "https://example.sharepoint.com/sites/ExampleSite/Lists/ProjectTasks/15_.000",
1731
+ fields: {
1732
+ "@odata.etag": "\"a1b2c3d4-e5f6-7890-abcd-ef1234567890,1\"",
1733
+ id: "15",
1734
+ Title: "Prepare presentation",
1735
+ Status: "Not Started",
1736
+ AssignedTo: "jane.smith@example.com",
1737
+ DueDate: "2025-12-18T00:00:00Z"
1738
+ }
1739
+ } };
1740
+ //#endregion
1741
+ //#region src/actions/lists.ts
1742
+ const listSiteLists = (0, _prismatic_io_spectral.action)({
1743
+ display: {
1744
+ label: "List Site Lists",
1745
+ description: "List all Site Lists"
1746
+ },
1747
+ inputs: {
1748
+ connection,
1749
+ siteId,
1750
+ fetchAll
1751
+ },
1752
+ perform: async ({ debug: { enabled: debug } }, params) => {
1753
+ const client = await createClient(params.connection, debug);
1754
+ const endpoint = `/sites/${params.siteId}/lists`;
1755
+ if (params.fetchAll) return { data: await paginateResults(client, endpoint, { returnFullData: true }) };
1756
+ const { data } = await client.get(endpoint);
1757
+ return { data };
1758
+ },
1759
+ examplePayload: listSiteListsExamplePayload
1760
+ });
1761
+ const getList = (0, _prismatic_io_spectral.action)({
1762
+ display: {
1763
+ label: "Get Site List",
1764
+ description: "Returns the information and metadata of an existing site list"
1765
+ },
1766
+ inputs: {
1767
+ connection,
1768
+ siteId,
1769
+ listId
1770
+ },
1771
+ perform: async ({ debug: { enabled: debug } }, params) => {
1772
+ const { data } = await (await createClient(params.connection, debug)).get(`/sites/${params.siteId}/lists/${params.listId}`);
1773
+ return { data };
1774
+ },
1775
+ examplePayload: getSiteListExamplePayload
1776
+ });
1777
+ const getListItemsInSite = (0, _prismatic_io_spectral.action)({
1778
+ display: {
1779
+ label: "List Items in Site List",
1780
+ description: "Return all items inside the given site list"
1781
+ },
1782
+ perform: async ({ debug: { enabled: debug } }, params) => {
1783
+ const { data } = await (await createClient(params.connection, debug)).get(`/sites/${params.siteId}/lists/${params.listId}/items`, { params: params.pageLimit || params.pageToken ? {
1784
+ $top: params.pageLimit,
1785
+ $skipToken: params.pageToken,
1786
+ $select: params.optInFields
1787
+ } : void 0 });
1788
+ return { data };
1789
+ },
1790
+ inputs: {
1791
+ connection,
1792
+ siteId,
1793
+ listId,
1794
+ pageLimit,
1795
+ pageToken,
1796
+ optInFields
1797
+ },
1798
+ examplePayload: listItemsInSiteListExamplePayload
1799
+ });
1800
+ const getItemInSite = (0, _prismatic_io_spectral.action)({
1801
+ display: {
1802
+ label: "Get Item from Site List",
1803
+ description: "Returns the information and metadata of the given item"
1804
+ },
1805
+ perform: async ({ debug: { enabled: debug } }, params) => {
1806
+ const { data } = await (await createClient(params.connection, debug)).get(`/sites/${params.siteId}/lists/${params.listId}/items/${params.itemId}`, { params: params.optInFields ? { $select: params.optInFields } : void 0 });
1807
+ return { data };
1808
+ },
1809
+ inputs: {
1810
+ connection,
1811
+ siteId,
1812
+ listId,
1813
+ itemId,
1814
+ optInFields
1815
+ },
1816
+ examplePayload: getItemFromSiteListExamplePayload
1817
+ });
1818
+ var lists_default = {
1819
+ listSiteLists,
1820
+ getListItemsInSite,
1821
+ createItemInSite: (0, _prismatic_io_spectral.action)({
1822
+ display: {
1823
+ label: "Create Item in Site List",
1824
+ description: "Create a new item inside the given site list"
1825
+ },
1826
+ perform: async ({ debug: { enabled: debug } }, params) => {
1827
+ const { data } = await (await createClient(params.connection, debug)).post(`/sites/${params.siteId}/lists/${params.listId}/items`, { fields: _prismatic_io_spectral.util.types.keyValPairListToObject(params.fields) });
1828
+ return { data };
1829
+ },
1830
+ inputs: {
1831
+ connection,
1832
+ siteId,
1833
+ listId,
1834
+ fields
1835
+ },
1836
+ examplePayload: createItemInSiteListExamplePayload
1837
+ }),
1838
+ getList,
1839
+ getItemInSite
1840
+ };
1841
+ //#endregion
1842
+ //#region src/actions/sites.ts
1843
+ const listFollowedSites = (0, _prismatic_io_spectral.action)({
1844
+ display: {
1845
+ label: "List Followed Sites",
1846
+ description: "List all Followed Sites"
1847
+ },
1848
+ inputs: {
1849
+ connection,
1850
+ pageLimit,
1851
+ pageToken,
1852
+ fetchAll
1853
+ },
1854
+ perform: async ({ debug: { enabled: debug } }, params) => {
1855
+ const client = await createClient(params.connection, debug);
1856
+ const endpoint = "/me/followedSites";
1857
+ if (params.fetchAll) return { data: await paginateResults(client, endpoint, { returnFullData: true }) };
1858
+ const { data } = await client.get("/me/followedSites", { params: params.pageLimit || params.pageToken ? {
1859
+ $top: params.pageLimit,
1860
+ $skipToken: params.pageToken
1861
+ } : void 0 });
1862
+ return { data };
1863
+ },
1864
+ examplePayload: { data: {
1865
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites",
1866
+ value: [{
1867
+ displayName: "Example",
1868
+ id: "example.sharepoint.com,6c44888f-5883-4ef0-c542-d21a802cfea6,ed2d5d06-e192-4047-afa6-a5d7f25b3418",
1869
+ sharepointIds: {
1870
+ siteId: "6c44888f-5883-4ef0-c542-d21a802cfea6",
1871
+ webId: "ed2d5d06-e192-4047-afa6-a5d7f25b3418"
1872
+ },
1873
+ siteCollection: { hostname: "example.sharepoint.com" },
1874
+ webUrl: "https://example.sharepoint.com/sites/Example"
1875
+ }]
1876
+ } }
1877
+ });
1878
+ var sites_default = {
1879
+ listSites: (0, _prismatic_io_spectral.action)({
1880
+ display: {
1881
+ label: "List Sites",
1882
+ description: "List all SharePoint sites"
1883
+ },
1884
+ perform: async ({ debug: { enabled: debug } }, params) => {
1885
+ const client = await createClient(params.connection, debug);
1886
+ const endpoint = "/sites";
1887
+ if (params.fetchAll) return { data: await paginateResults(client, `${endpoint}?search=`, { returnFullData: true }) };
1888
+ const { data } = await client.get(endpoint, { params: params.pageLimit || params.pageToken ? {
1889
+ search: "",
1890
+ $top: params.pageLimit,
1891
+ $skipToken: params.pageToken
1892
+ } : { search: "" } });
1893
+ return { data };
1894
+ },
1895
+ inputs: {
1896
+ connection,
1897
+ pageLimit,
1898
+ pageToken,
1899
+ fetchAll
1900
+ },
1901
+ examplePayload: { data: { value: [{
1902
+ description: "Example description",
1903
+ id: "example.sharepoint.com,c45e332-a998-479d-aeb2-2a",
1904
+ name: "Example SharePoint Site",
1905
+ webUrl: "https://example.sharepoint.com",
1906
+ displayName: "Communication Site",
1907
+ root: void 0,
1908
+ siteCollection: { hostname: "https://example.sharepoint.com" }
1909
+ }] } }
1910
+ }),
1911
+ listFollowedSites,
1912
+ getRootSite: (0, _prismatic_io_spectral.action)({
1913
+ display: {
1914
+ label: "Get Root Site",
1915
+ description: "Returns the information and metadata of the root SharePoint site in your tenant"
1916
+ },
1917
+ perform: async ({ debug: { enabled: debug } }, params) => {
1918
+ const { data } = await (await createClient(params.connection, debug)).get("/sites/root");
1919
+ return { data };
1920
+ },
1921
+ inputs: { connection },
1922
+ examplePayload: { data: {
1923
+ description: "Example description",
1924
+ id: "example.sharepoint.com,c45e332-a998-479d-aeb2-2a",
1925
+ name: "Example SharePoint Site",
1926
+ webUrl: "https://example.sharepoint.com",
1927
+ displayName: "Communication Site",
1928
+ root: void 0,
1929
+ siteCollection: { hostname: "https://example.sharepoint.com" }
1930
+ } }
1931
+ }),
1932
+ getSite: (0, _prismatic_io_spectral.action)({
1933
+ display: {
1934
+ label: "Get Site",
1935
+ description: "Returns the information and metadata of the given SharePoint site"
1936
+ },
1937
+ perform: async ({ debug: { enabled: debug } }, params) => {
1938
+ const { data } = await (await createClient(params.connection, debug)).get(`/sites/${params.siteId}`);
1939
+ return { data };
1940
+ },
1941
+ inputs: {
1942
+ connection,
1943
+ siteId
1944
+ },
1945
+ examplePayload: { data: {
1946
+ description: "Example description",
1947
+ id: "example.sharepoint.com,c45e332-a998-479d-aeb2-2a",
1948
+ name: "Example SharePoint Site",
1949
+ webUrl: "https://example.sharepoint.com",
1950
+ displayName: "Communication Site",
1951
+ root: void 0,
1952
+ siteCollection: { hostname: "https://example.sharepoint.com" }
1953
+ } }
1954
+ })
1955
+ };
1956
+ var listShared_default = { listSharedDocuments: (0, _prismatic_io_spectral.action)({
1957
+ display: {
1958
+ label: "List Shared Documents",
1959
+ description: "Lists documents shared with the user."
1960
+ },
1961
+ inputs: { connection },
1962
+ perform: async ({ debug: { enabled: debug } }, params) => {
1963
+ const { data } = await (await createClient(params.connection, debug)).get("/me/insights/shared");
1964
+ return { data };
1965
+ },
1966
+ examplePayload: listSharedDocumentsExamplePayload
1967
+ }) };
1968
+ //#endregion
1969
+ //#region src/actions/subscriptions.ts
1970
+ const notificationUrlInput = (0, _prismatic_io_spectral.input)({
1971
+ label: "Notification URL",
1972
+ type: "string",
1973
+ required: true,
1974
+ comments: "URL to send events of this Subscription to",
1975
+ clean: _prismatic_io_spectral.util.types.toString
1976
+ });
1977
+ const expirationDateTimeInput = (0, _prismatic_io_spectral.input)({
1978
+ label: "Expiration Date/Time",
1979
+ type: "string",
1980
+ required: false,
1981
+ comments: "Expiration date/time for subscription. If unspecified the default will be the current date/time plus 29 days (close to the maximum permitted by the Graph API).",
1982
+ clean: (rawValue) => {
1983
+ const defaultDate = /* @__PURE__ */ new Date();
1984
+ defaultDate.setDate(defaultDate.getDate() + 29);
1985
+ const value = rawValue || defaultDate;
1986
+ if (value instanceof Date) return value.toISOString();
1987
+ return _prismatic_io_spectral.util.types.toString(value);
1988
+ }
1989
+ });
1990
+ const subscriptionIdInput = (0, _prismatic_io_spectral.input)({
1991
+ label: "Subscription ID",
1992
+ type: "string",
1993
+ required: true,
1994
+ comments: "Subscription ID to manage",
1995
+ dataSource: "listSubscriptions",
1996
+ clean: _prismatic_io_spectral.util.types.toString
1997
+ });
1998
+ (0, _prismatic_io_spectral.action)({
1999
+ display: {
2000
+ label: "List Subscriptions",
2001
+ description: "List all subscriptions for Microsoft SharePoint"
2002
+ },
2003
+ inputs: {
2004
+ connection,
2005
+ showInstanceWebhooks: (0, _prismatic_io_spectral.input)({
2006
+ label: "Show Instance Webhooks",
2007
+ type: "boolean",
2008
+ required: true,
2009
+ default: "true",
2010
+ comments: "Show only subscriptions for this Instance's webhooks",
2011
+ clean: _prismatic_io_spectral.util.types.toBool
2012
+ })
2013
+ },
2014
+ perform: async (context, params) => {
2015
+ const { data } = await (await createClient(params.connection, context.debug.enabled)).get("/subscriptions");
2016
+ if (params.showInstanceWebhooks) {
2017
+ const instanceWebhooks = new Set(Object.values(context.webhookUrls));
2018
+ const instanceSubscriptions = data.value.filter(({ notificationUrl }) => instanceWebhooks.has(notificationUrl));
2019
+ return { data: {
2020
+ ...data,
2021
+ value: instanceSubscriptions
2022
+ } };
2023
+ }
2024
+ return { data };
2025
+ },
2026
+ examplePayload: { data: {
2027
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#subscriptions",
2028
+ value: [{
2029
+ id: "e9d5b726-4478-4412-bfba-268530484566",
2030
+ resource: "sites/example.sharepoint.com,17cd4ada-1a76-420e-a7ec-4adaa3327c86,87742bc7-2d2f-404c-8255-d3d9fa9a6561/lists/3a3c0f6a-86da-4567-94d4-3b939da63200",
2031
+ applicationId: "e76615c0-13e3-4cd2-8235-a2d628ad13de",
2032
+ changeType: "updated",
2033
+ clientState: null,
2034
+ notificationUrl: "https://example.com/webhook/",
2035
+ notificationQueryOptions: null,
2036
+ lifecycleNotificationUrl: null,
2037
+ expirationDateTime: "2022-11-22T23:32:10.231Z",
2038
+ creatorId: "c8edbeda-c453-446c-91ce-c6d5c7310a6c",
2039
+ includeResourceData: null,
2040
+ latestSupportedTlsVersion: "v1_2",
2041
+ encryptionCertificate: null,
2042
+ encryptionCertificateId: null,
2043
+ notificationUrlAppId: null
2044
+ }]
2045
+ } }
2046
+ });
2047
+ const createSiteListSubscription = (0, _prismatic_io_spectral.action)({
2048
+ display: {
2049
+ label: "Create Site List Subscription",
2050
+ description: "Create a Site List subscription for Microsoft SharePoint"
2051
+ },
2052
+ inputs: {
2053
+ connection,
2054
+ siteId,
2055
+ listId,
2056
+ notificationUrl: notificationUrlInput,
2057
+ expirationDateTime: expirationDateTimeInput,
2058
+ allowDuplicates: (0, _prismatic_io_spectral.input)({
2059
+ label: "Allow Duplicates",
2060
+ type: "boolean",
2061
+ required: false,
2062
+ default: "false",
2063
+ comments: "Enable to allow more than one webhook per endpoint",
2064
+ clean: _prismatic_io_spectral.util.types.toBool
2065
+ })
2066
+ },
2067
+ perform: async (context, params) => {
2068
+ const client = await createClient(params.connection, context.debug.enabled);
2069
+ if (!params.allowDuplicates) {
2070
+ const { data: { value: subscriptions } } = await client.get("/subscriptions");
2071
+ const [existingSubscription] = subscriptions.filter(({ notificationUrl }) => params.notificationUrl === notificationUrl);
2072
+ if (existingSubscription) {
2073
+ context.logger.info("A webhook with the specified Notification URL already exists. Skipping webhook creation and returning existing webhook.");
2074
+ return { data: existingSubscription };
2075
+ }
2076
+ }
2077
+ const { data } = await client.post("/subscriptions", {
2078
+ resource: `sites/${params.siteId}/lists/${params.listId}`,
2079
+ notificationUrl: params.notificationUrl,
2080
+ changeType: "updated",
2081
+ expirationDateTime: params.expirationDateTime
2082
+ });
2083
+ return { data };
2084
+ },
2085
+ examplePayload: { data: {
2086
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#subscriptions/$entity",
2087
+ id: "e9d5b726-4478-4412-bfba-268530484566",
2088
+ resource: "sites/example.sharepoint.com,17cd4ada-1a76-420e-a7ec-4adaa3327c86,87742bc7-2d2f-404c-8255-d3d9fa9a6561/lists/3a3c0f6a-86da-4567-94d4-3b939da63200",
2089
+ applicationId: "e76615c0-13e3-4cd2-8235-a2d628ad13de",
2090
+ changeType: "updated",
2091
+ clientState: null,
2092
+ notificationUrl: "https://example.com/webhook/",
2093
+ notificationQueryOptions: null,
2094
+ lifecycleNotificationUrl: null,
2095
+ expirationDateTime: "2022-11-22T23:32:10.231Z",
2096
+ creatorId: "c8edbeda-c453-446c-91ce-c6d5c7310a6c",
2097
+ includeResourceData: null,
2098
+ latestSupportedTlsVersion: "v1_2",
2099
+ encryptionCertificate: null,
2100
+ encryptionCertificateId: null,
2101
+ notificationUrlAppId: null
2102
+ } }
2103
+ });
2104
+ const updateSiteListSubscriptionExpiration = (0, _prismatic_io_spectral.action)({
2105
+ display: {
2106
+ label: "Update Site List Subscription Expiration",
2107
+ description: "Update existing Site List subscription expiration for Microsoft SharePoint"
2108
+ },
2109
+ inputs: {
2110
+ connection,
2111
+ subscriptionId: subscriptionIdInput,
2112
+ expirationDateTime: expirationDateTimeInput
2113
+ },
2114
+ perform: async ({ debug: { enabled: debug } }, params) => {
2115
+ const { data } = await (await createClient(params.connection, debug)).patch(`/subscriptions/${params.subscriptionId}`, { expirationDateTime: params.expirationDateTime });
2116
+ return { data };
2117
+ },
2118
+ examplePayload: { data: {
2119
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#subscriptions/$entity",
2120
+ id: "e9d5b726-4478-4412-bfba-268530484566",
2121
+ resource: "sites/example.sharepoint.com,17cd4ada-1a76-420e-a7ec-4adaa3327c86,87742bc7-2d2f-404c-8255-d3d9fa9a6561/lists/3a3c0f6a-86da-4567-94d4-3b939da63200",
2122
+ applicationId: "e76615c0-13e3-4cd2-8235-a2d628ad13de",
2123
+ changeType: "updated",
2124
+ clientState: null,
2125
+ notificationUrl: "https://example.com/webhook/",
2126
+ notificationQueryOptions: null,
2127
+ lifecycleNotificationUrl: null,
2128
+ expirationDateTime: "2022-11-22T23:32:10.231Z",
2129
+ creatorId: "c8edbeda-c453-446c-91ce-c6d5c7310a6c",
2130
+ includeResourceData: null,
2131
+ latestSupportedTlsVersion: "v1_2",
2132
+ encryptionCertificate: null,
2133
+ encryptionCertificateId: null,
2134
+ notificationUrlAppId: null
2135
+ } }
2136
+ });
2137
+ (0, _prismatic_io_spectral.action)({
2138
+ display: {
2139
+ label: "Delete Subscription",
2140
+ description: "Delete existing subscription for Microsoft SharePoint"
2141
+ },
2142
+ inputs: {
2143
+ connection,
2144
+ subscriptionId: subscriptionIdInput
2145
+ },
2146
+ perform: async ({ debug: { enabled: debug } }, params) => {
2147
+ const { data } = await (await createClient(params.connection, debug)).delete(`/subscriptions/${params.subscriptionId}`);
2148
+ return { data };
2149
+ },
2150
+ examplePayload: { data: "" }
2151
+ });
2152
+ (0, _prismatic_io_spectral.action)({
2153
+ display: {
2154
+ label: "Delete All Instance Subscriptions",
2155
+ description: "Delete all subscriptions pointed at this instance"
2156
+ },
2157
+ inputs: { connection },
2158
+ perform: async (context, params) => {
2159
+ const client = await createClient(params.connection, context.debug.enabled);
2160
+ const { data: { value: subscriptions } } = await client.get("/subscriptions");
2161
+ const instanceWebhooks = new Set(Object.values(context.webhookUrls));
2162
+ const subscriptionsToRemove = subscriptions.filter(({ notificationUrl }) => instanceWebhooks.has(notificationUrl)).map(({ id }) => id);
2163
+ await Promise.all(subscriptionsToRemove.map((id) => client.delete(`/subscriptions/${id}`)));
2164
+ return { data: { subscriptionsRemoved: subscriptionsToRemove } };
2165
+ },
2166
+ examplePayload: { data: { subscriptionsRemoved: ["26ebd1e9-c54a-4bbe-9583-fc05974952a4", "b9b27172-ee2e-4248-86df-fc98cb71d914"] } }
2167
+ });
2168
+ var subscriptions_default = {
2169
+ createSiteListSubscription,
2170
+ updateSiteListSubscriptionExpiration
2171
+ };
2172
+ var users_default = { getCurrentUser: (0, _prismatic_io_spectral.action)({
2173
+ display: {
2174
+ label: "Get Current User",
2175
+ description: "Get the information and metadata of the user that is currently logged in"
2176
+ },
2177
+ perform: async ({ debug: { enabled: debug } }, params) => {
2178
+ const { data } = await (await createClient(params.connection, debug)).get("/me");
2179
+ return { data };
2180
+ },
2181
+ inputs: { connection },
2182
+ examplePayload: { data: {
2183
+ businessPhones: ["+1 555 555 5555"],
2184
+ displayName: "exampleUser",
2185
+ givenName: "exampleUser",
2186
+ jobTitle: "Retail Manager",
2187
+ mail: "someoneV@example.onmicrosoft.com",
2188
+ mobilePhone: "+1 555 555 5555",
2189
+ officeLocation: "example",
2190
+ preferredLanguage: "en-US",
2191
+ surname: "Example",
2192
+ id: "3693-4789-a1c3-f4de565f"
2193
+ } }
2194
+ }) };
2195
+ //#endregion
2196
+ //#region src/actions/webhooks/index.ts
2197
+ var webhooks_default = {
2198
+ createSubscription: (0, _prismatic_io_spectral.action)({
2199
+ display: {
2200
+ label: "Create a Subscription",
2201
+ description: "Create a Subscription to notify you of changes to a resource"
2202
+ },
2203
+ inputs: {
2204
+ connection,
2205
+ changeType,
2206
+ notificationUrl,
2207
+ resource,
2208
+ expirationDateTime,
2209
+ clientState,
2210
+ allowDuplicates
2211
+ },
2212
+ perform: async (context, { connection, changeType, notificationUrl, resource, expirationDateTime, clientState, allowDuplicates }) => {
2213
+ return { data: await createSubscriptionFN(await createClient(connection, context.debug.enabled), {
2214
+ resource,
2215
+ changeType,
2216
+ notificationUrl,
2217
+ expirationDateTime,
2218
+ clientState,
2219
+ allowDuplicates
2220
+ }, context) };
2221
+ },
2222
+ examplePayload: { data: {
2223
+ id: "38031b7d-16b1-448a-8e68-68b8aec62315",
2224
+ resource: "/me/drive/root",
2225
+ changeType: "updated",
2226
+ clientState: "client-specific-string",
2227
+ notificationUrl: "https://hooks.example.com/trigger/SW5z",
2228
+ expirationDateTime: "2025-12-12T11:23:00.0000000Z",
2229
+ creatorId: "6219df3c-04d4-4b39-b2a4-ad162a5dcb8f",
2230
+ latestSupportedTlsVersion: "v1_2"
2231
+ } }
2232
+ }),
2233
+ deleteAllInstanceSubscriptions: (0, _prismatic_io_spectral.action)({
2234
+ display: {
2235
+ label: "Delete All Instance Subscriptions",
2236
+ description: "Delete all SharePoint subscriptions pointed at this instance"
2237
+ },
2238
+ inputs: deleteAllSubscriptionsInputs,
2239
+ perform: async (context, { connection, notificationUrl }) => {
2240
+ const deletedSubscriptions = await deleteAllSubscriptionsFN(await createClient(connection, context.debug.enabled), notificationUrl || context.webhookUrls[context.flow.name]);
2241
+ return { data: {
2242
+ subscriptionsRemoved: deletedSubscriptions.map((s) => s.id),
2243
+ count: deletedSubscriptions.length
2244
+ } };
2245
+ },
2246
+ examplePayload: { data: {
2247
+ subscriptionsRemoved: ["38031b7d-16b1-448a-8e68-68b8aec62315", "a1b2c3d4-5678-90ab-cdef-1234567890ab"],
2248
+ count: 2
2249
+ } }
2250
+ }),
2251
+ deleteSubscription: (0, _prismatic_io_spectral.action)({
2252
+ display: {
2253
+ label: "Delete a Subscription",
2254
+ description: "Delete a Subscription by ID"
2255
+ },
2256
+ inputs: {
2257
+ connection,
2258
+ subscriptionId
2259
+ },
2260
+ perform: async ({ debug: { enabled: debug } }, { connection, subscriptionId }) => {
2261
+ const { data } = await (await createClient(connection, debug)).delete(`/subscriptions/${subscriptionId}`);
2262
+ return { data };
2263
+ },
2264
+ examplePayload: { data: {} }
2265
+ }),
2266
+ listSubscriptions: (0, _prismatic_io_spectral.action)({
2267
+ display: {
2268
+ label: "List Subscriptions",
2269
+ description: "List all available Subscriptions"
2270
+ },
2271
+ inputs: {
2272
+ connection,
2273
+ showInstanceSubscriptions
2274
+ },
2275
+ perform: async (context, { connection, showInstanceSubscriptions }) => {
2276
+ const { data } = await (await createClient(connection, context.debug.enabled)).get("/subscriptions");
2277
+ if (showInstanceSubscriptions) {
2278
+ const instanceWebhooks = new Set(Object.values(context.webhookUrls));
2279
+ const instanceSubscriptions = data.value.filter(({ notificationUrl }) => instanceWebhooks.has(notificationUrl));
2280
+ return { data: {
2281
+ ...data,
2282
+ value: instanceSubscriptions
2283
+ } };
2284
+ }
2285
+ return { data };
2286
+ },
2287
+ examplePayload: { data: {
2288
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#subscriptions",
2289
+ value: [{
2290
+ id: "38031b7d-16b1-448a-8e68-68b8aec6df45",
2291
+ resource: "/me/drive/root",
2292
+ applicationId: "0fed8223-8c47-4c71-ba78-92c6f9441235",
2293
+ changeType: "updated",
2294
+ clientState: null,
2295
+ notificationUrl: "https://hooks.example.com/trigger/SW5",
2296
+ notificationQueryOptions: null,
2297
+ lifecycleNotificationUrl: null,
2298
+ expirationDateTime: "2025-12-12T11:23:00.0000000Z",
2299
+ creatorId: "62162f3c-04d4-4b39-b2a4-ad891a5dcb8f",
2300
+ includeResourceData: null,
2301
+ latestSupportedTlsVersion: "v1_2",
2302
+ encryptionCertificate: null,
2303
+ encryptionCertificateId: null,
2304
+ notificationUrlAppId: null
2305
+ }]
2306
+ } }
2307
+ }),
2308
+ renewSubscription: (0, _prismatic_io_spectral.action)({
2309
+ display: {
2310
+ label: "Renew Subscription",
2311
+ description: "Extend the expiration date of an existing SharePoint subscription"
2312
+ },
2313
+ inputs: renewSubscriptionInputs,
2314
+ perform: async (context, { connection, subscriptionId, expirationDays }) => {
2315
+ return { data: await renewSubscriptionFN(await createClient(connection, context.debug.enabled), subscriptionId, expirationDays) };
2316
+ },
2317
+ examplePayload: { data: {
2318
+ id: "38031b7d-16b1-448a-8e68-68b8aec62315",
2319
+ resource: "/me/drive/root",
2320
+ changeType: "updated",
2321
+ clientState: "client-specific-string",
2322
+ notificationUrl: "https://hooks.example.com/trigger/SW5z",
2323
+ expirationDateTime: "2025-12-12T11:23:00.0000000Z",
2324
+ creatorId: "6219df3c-04d4-4b39-b2a4-ad162a5dcb8f",
2325
+ latestSupportedTlsVersion: "v1_2"
2326
+ } }
2327
+ })
2328
+ };
2329
+ //#endregion
2330
+ //#region src/actions/rawRequest.ts
2331
+ const { debugRequest, ...rawRequestInputs } = _prismatic_io_spectral_http.inputs;
2332
+ const rawRequest = (0, _prismatic_io_spectral.action)({
2333
+ display: {
2334
+ label: "Raw Request",
2335
+ description: "Send raw HTTP request to Microsoft Sharepoint"
2336
+ },
2337
+ perform: async ({ debug: { enabled: debug } }, { connection, ...httpClientInputs }) => {
2338
+ const baseUrl = "https://graph.microsoft.com/v1.0";
2339
+ const headers = { Authorization: `Bearer ${await getAccessToken(connection)}` };
2340
+ const { data } = await (0, _prismatic_io_spectral_http.sendRawRequest)(baseUrl, {
2341
+ ...httpClientInputs,
2342
+ debugRequest: debug
2343
+ }, headers);
2344
+ return { data };
2345
+ },
2346
+ inputs: {
2347
+ connection,
2348
+ ...rawRequestInputs,
2349
+ url: {
2350
+ ...rawRequestInputs.url,
2351
+ comments: "Input the path only (/me/followedSites), The base URL is already included (https://graph.microsoft.com/v1.0). For example, to connect to https://graph.microsoft.com/v1.0/me/followedSites, only /me/followedSites is entered in this field.",
2352
+ example: "/me/followedSites"
2353
+ }
2354
+ },
2355
+ examplePayload: rawRequestExamplePayload
2356
+ });
2357
+ //#endregion
2358
+ //#region src/actions/listChanges.ts
2359
+ const listChanges = (0, _prismatic_io_spectral.action)({
2360
+ display: {
2361
+ label: "List Changes",
2362
+ description: "Track changes in a driveItem and its children over time."
2363
+ },
2364
+ inputs: {
2365
+ connection,
2366
+ deltaURL,
2367
+ $select,
2368
+ $expand,
2369
+ $top,
2370
+ fetchAll
2371
+ },
2372
+ perform: async ({ debug: { enabled: debug } }, { connection, deltaURL, $expand, $select, $top, fetchAll }) => {
2373
+ const client = await createClient(connection, debug);
2374
+ if (fetchAll) return { data: await paginateResults(client, deltaURL, {
2375
+ returnFullData: true,
2376
+ useTop: false,
2377
+ excludeParents: true
2378
+ }) };
2379
+ const { data } = await client.get(deltaURL, {
2380
+ params: {
2381
+ $expand: $expand || void 0,
2382
+ $select: $select || void 0,
2383
+ $top: $top || void 0
2384
+ },
2385
+ headers: { Prefer: "deltaExcludeParent" }
2386
+ });
2387
+ return { data };
2388
+ },
2389
+ examplePayload: listChangesExamplePayload
2390
+ });
2391
+ //#endregion
2392
+ //#region src/actions/folders/index.ts
2393
+ var folders_default = {
2394
+ createFolder: (0, _prismatic_io_spectral.action)({
2395
+ display: {
2396
+ label: "Create a Folder",
2397
+ description: "Create a Folder in a Drive"
2398
+ },
2399
+ inputs: createFolderInputs,
2400
+ perform: async (context, { connection, siteId, driveId, parentItemId, folderName }) => {
2401
+ const { data } = await (await createClient(connection, context.debug.enabled)).post(`/sites/${siteId}/drives/${driveId}/items/${parentItemId}/children`, {
2402
+ name: folderName,
2403
+ folder: {},
2404
+ "@microsoft.graph.conflictBehavior": "rename"
2405
+ });
2406
+ return { data };
2407
+ },
2408
+ examplePayload: { data: {
2409
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('example.sharepoint.com%2Cexample-site-id%2Cexample-web-id')/drives('b%21exampleDriveId')/items('root')/children/$entity",
2410
+ "@odata.etag": "\"{EXAMPLE-ETAG-ID},1\"",
2411
+ createdDateTime: "2025-06-12T22:28:24Z",
2412
+ eTag: "\"{EXAMPLE-ETAG-ID},1\"",
2413
+ id: "exampleItemId123456",
2414
+ lastModifiedDateTime: "2025-06-12T22:28:24Z",
2415
+ name: "NewFolder",
2416
+ size: 0,
2417
+ webUrl: "https://example.sharepoint.com/sites/ExampleSite/Shared%20Documents/NewFolder",
2418
+ cTag: "\"c:{EXAMPLE-ETAG-ID},0\"",
2419
+ commentSettings: { commentingDisabled: { isDisabled: false } },
2420
+ createdBy: {
2421
+ application: {
2422
+ displayName: "ExampleApp",
2423
+ id: "example-app-id-1234"
2424
+ },
2425
+ user: {
2426
+ displayName: "Example User",
2427
+ email: "example.user@example.com",
2428
+ id: "example-user-id-1234"
2429
+ }
2430
+ },
2431
+ lastModifiedBy: {
2432
+ application: {
2433
+ displayName: "ExampleApp",
2434
+ id: "example-app-id-1234"
2435
+ },
2436
+ user: {
2437
+ displayName: "Example User",
2438
+ email: "example.user@example.com",
2439
+ id: "example-user-id-1234"
2440
+ }
2441
+ },
2442
+ parentReference: {
2443
+ driveId: "b!exampleDriveId",
2444
+ driveType: "documentLibrary",
2445
+ id: "exampleParentItemId123456",
2446
+ path: "/drives/b!exampleDriveId/root:",
2447
+ sharepointIds: {
2448
+ listId: "example-list-id-1234",
2449
+ listItemUniqueId: "example-list-item-id-1234",
2450
+ siteId: "example-site-id-1234",
2451
+ siteUrl: "https://example.sharepoint.com/sites/ExampleSite",
2452
+ tenantId: "example-tenant-id-1234",
2453
+ webId: "example-web-id-1234"
2454
+ }
2455
+ },
2456
+ fileSystemInfo: {
2457
+ createdDateTime: "2025-06-12T22:28:24Z",
2458
+ lastModifiedDateTime: "2025-06-12T22:28:24Z"
2459
+ },
2460
+ folder: { childCount: 0 },
2461
+ shared: { scope: "unknown" }
2462
+ } }
2463
+ }),
2464
+ renameFolder: (0, _prismatic_io_spectral.action)({
2465
+ display: {
2466
+ label: "Rename a Folder",
2467
+ description: "Rename a Folder in a Drive"
2468
+ },
2469
+ inputs: renameFolderInputs,
2470
+ perform: async (context, { connection, siteId, driveId, folderId, folderName }) => {
2471
+ const { data } = await (await createClient(connection, context.debug.enabled)).patch(`/sites/${siteId}/drives/${driveId}/items/${folderId}`, { name: folderName });
2472
+ return { data };
2473
+ },
2474
+ examplePayload: { data: {
2475
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('example.sharepoint.com%2Cexample-site-id%2Cexample-web-id')/drives('b%21exampleDriveId')/items('root')/children/$entity",
2476
+ "@odata.etag": "\"{EXAMPLE-ETAG-ID},1\"",
2477
+ createdDateTime: "2025-06-12T22:28:24Z",
2478
+ eTag: "\"{EXAMPLE-ETAG-ID},1\"",
2479
+ id: "exampleItemId123456",
2480
+ lastModifiedDateTime: "2025-06-12T22:28:24Z",
2481
+ name: "NewFolder",
2482
+ size: 0,
2483
+ webUrl: "https://example.sharepoint.com/sites/ExampleSite/Shared%20Documents/NewFolder",
2484
+ cTag: "\"c:{EXAMPLE-ETAG-ID},0\"",
2485
+ commentSettings: { commentingDisabled: { isDisabled: false } },
2486
+ createdBy: {
2487
+ application: {
2488
+ displayName: "ExampleApp",
2489
+ id: "example-app-id-1234"
2490
+ },
2491
+ user: {
2492
+ displayName: "Example User",
2493
+ email: "example.user@example.com",
2494
+ id: "example-user-id-1234"
2495
+ }
2496
+ },
2497
+ lastModifiedBy: {
2498
+ application: {
2499
+ displayName: "ExampleApp",
2500
+ id: "example-app-id-1234"
2501
+ },
2502
+ user: {
2503
+ displayName: "Example User",
2504
+ email: "example.user@example.com",
2505
+ id: "example-user-id-1234"
2506
+ }
2507
+ },
2508
+ parentReference: {
2509
+ driveId: "b!exampleDriveId",
2510
+ driveType: "documentLibrary",
2511
+ id: "exampleParentItemId123456",
2512
+ path: "/drives/b!exampleDriveId/root:",
2513
+ sharepointIds: {
2514
+ listId: "example-list-id-1234",
2515
+ listItemUniqueId: "example-list-item-id-1234",
2516
+ siteId: "example-site-id-1234",
2517
+ siteUrl: "https://example.sharepoint.com/sites/ExampleSite",
2518
+ tenantId: "example-tenant-id-1234",
2519
+ webId: "example-web-id-1234"
2520
+ }
2521
+ },
2522
+ fileSystemInfo: {
2523
+ createdDateTime: "2025-06-12T22:28:24Z",
2524
+ lastModifiedDateTime: "2025-06-12T22:28:24Z"
2525
+ },
2526
+ folder: { childCount: 0 },
2527
+ shared: { scope: "unknown" }
2528
+ } }
2529
+ })
2530
+ };
2531
+ //#endregion
2532
+ //#region src/actions/files/index.ts
2533
+ var files_default = { moveFile: (0, _prismatic_io_spectral.action)({
2534
+ display: {
2535
+ label: "Move a File",
2536
+ description: "Move a File in a Drive"
2537
+ },
2538
+ inputs: moveFileInputs,
2539
+ perform: async (context, { connection, driveId, itemId, parentItemId }) => {
2540
+ const { data } = await (await createClient(connection, context.debug.enabled)).patch(`/drives/${driveId}/items/${itemId}`, { parentReference: { id: parentItemId } });
2541
+ return { data };
2542
+ },
2543
+ examplePayload: { data: {
2544
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('drive-id')/items/$entity",
2545
+ "@microsoft.graph.downloadUrl": "https://example.sharepoint.com/sites/ExampleSite/_layouts/15/download.aspx?UniqueId=example-unique-id&Translate=false&tempauth=example-tempauth-token&ApiVersion=2.0",
2546
+ createdDateTime: "2025-06-12T23:24:20Z",
2547
+ eTag: "\"{EXAMPLE-ETAG},7\"",
2548
+ id: "example-file-id",
2549
+ lastModifiedDateTime: "2025-06-12T23:24:49Z",
2550
+ name: "example.docx",
2551
+ webUrl: "https://example.sharepoint.com/sites/ExampleSite/_layouts/15/Doc.aspx?sourcedoc=%7BEXAMPLE-ID%7D&file=example.docx&action=default&mobileredirect=true",
2552
+ cTag: "\"c:{EXAMPLE-CTAG},8\"",
2553
+ size: 19802,
2554
+ createdBy: { user: {
2555
+ email: "user@example.com",
2556
+ id: "00000000-0000-0000-0000-000000000000",
2557
+ displayName: "Example User"
2558
+ } },
2559
+ lastModifiedBy: { user: {
2560
+ email: "user@example.com",
2561
+ id: "00000000-0000-0000-0000-000000000000",
2562
+ displayName: "Example User"
2563
+ } },
2564
+ parentReference: {
2565
+ driveType: "documentLibrary",
2566
+ driveId: "example-drive-id",
2567
+ id: "example-parent-id",
2568
+ name: "Shared Documents",
2569
+ path: "/drives/example-drive-id/root:",
2570
+ siteId: "00000000-0000-0000-0000-000000000000"
2571
+ },
2572
+ file: {
2573
+ mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
2574
+ hashes: { quickXorHash: "exampleBase64Hash==" }
2575
+ },
2576
+ fileSystemInfo: {
2577
+ createdDateTime: "2025-06-12T23:24:20Z",
2578
+ lastModifiedDateTime: "2025-06-12T23:24:49Z"
2579
+ },
2580
+ shared: { scope: "users" }
2581
+ } }
2582
+ }) };
2583
+ //#endregion
2584
+ //#region src/actions/items/index.ts
2585
+ var items_default = {
2586
+ listItems: (0, _prismatic_io_spectral.action)({
2587
+ display: {
2588
+ label: "List Items",
2589
+ description: "List Items in a Folder"
2590
+ },
2591
+ inputs: listItemsInputs,
2592
+ perform: async (context, { connection, driveId, folderId }) => {
2593
+ const { data } = await (await createClient(connection, context.debug.enabled)).get(`/drives/${driveId}/items/${folderId}/children`);
2594
+ return { data };
2595
+ },
2596
+ examplePayload: { data: {
2597
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)",
2598
+ value: [{
2599
+ "@microsoft.graph.downloadUrl": "https://example.sharepoint.com/sites/ExampleSite/_layouts/15/download.aspx?UniqueId=example-unique-id&Translate=false&tempauth=example-auth-token&ApiVersion=2.0",
2600
+ createdBy: { user: {
2601
+ email: "example.user@example.onmicrosoft.com",
2602
+ id: "00000000-0000-0000-0000-000000000000",
2603
+ displayName: "Example User"
2604
+ } },
2605
+ createdDateTime: "2025-06-12T23:24:20Z",
2606
+ eTag: "\"{EXAMPLE-ID},5\"",
2607
+ id: "EXAMPLE-FILE-ID-12345",
2608
+ lastModifiedBy: { user: {
2609
+ email: "example.user@example.onmicrosoft.com",
2610
+ id: "00000000-0000-0000-0000-000000000000",
2611
+ displayName: "Example User"
2612
+ } },
2613
+ lastModifiedDateTime: "2025-06-12T23:24:49Z",
2614
+ name: "example-file.docx",
2615
+ parentReference: {
2616
+ driveType: "documentLibrary",
2617
+ driveId: "b!ExampleDriveId123456789",
2618
+ id: "EXAMPLE-FOLDER-ID-12345",
2619
+ name: "ExampleFolder",
2620
+ path: "/drives/b!ExampleDriveId123456789/root:/ExampleFolder",
2621
+ siteId: "00000000-0000-0000-0000-000000000000"
2622
+ },
2623
+ webUrl: "https://example.sharepoint.com/sites/ExampleSite/_layouts/15/Doc.aspx?sourcedoc=%7BEXAMPLE-ID%7D&file=example-file.docx&action=default&mobileredirect=true",
2624
+ cTag: "\"c:{EXAMPLE-ID},7\"",
2625
+ file: {
2626
+ hashes: { quickXorHash: "ExampleHashBase64==" },
2627
+ mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
2628
+ },
2629
+ fileSystemInfo: {
2630
+ createdDateTime: "2025-06-12T23:24:20Z",
2631
+ lastModifiedDateTime: "2025-06-12T23:24:49Z"
2632
+ },
2633
+ shared: { scope: "users" },
2634
+ size: 19802
2635
+ }]
2636
+ } }
2637
+ }),
2638
+ searchItems: (0, _prismatic_io_spectral.action)({
2639
+ display: {
2640
+ label: "Search Items",
2641
+ description: "Search for items across all drives in a SharePoint site"
2642
+ },
2643
+ inputs: searchItemsInputs,
2644
+ perform: async (context, { connection, siteId, query }) => {
2645
+ const client = await createClient(connection, context.debug.enabled);
2646
+ const allDrives = await paginateResults(client, `/sites/${siteId}/drives?$select=id,name`);
2647
+ const searchResults = await Promise.all(allDrives.map(async (drive) => {
2648
+ try {
2649
+ const nameMatchedItems = (await paginateResults(client, `/drives/${drive.id}/root/search(q='${query}')`)).filter((item) => item.name.toLowerCase().includes(query.toLowerCase()));
2650
+ if (nameMatchedItems.length > 0) return {
2651
+ driveName: drive.name,
2652
+ items: nameMatchedItems
2653
+ };
2654
+ } catch (error) {
2655
+ throw new Error(`Search failed for drive "${drive.name}" (id: ${drive.id}): ${error}`);
2656
+ }
2657
+ }));
2658
+ const data = {};
2659
+ for (const result of searchResults) if (result) data[result.driveName] = result.items;
2660
+ return { data };
2661
+ },
2662
+ examplePayload: { data: { Documents: [{
2663
+ createdDateTime: "2025-06-11T22:08:54Z",
2664
+ id: "0125EXAMPLERANDOMFOLDERID1234567890",
2665
+ lastModifiedDateTime: "2025-06-12T23:48:54Z",
2666
+ name: "renamedFolder",
2667
+ webUrl: "https://example.sharepoint.com/sites/ExampleSite/Shared%20Documents/renamedFolder",
2668
+ size: 0,
2669
+ createdBy: { user: {
2670
+ email: "user@example.com",
2671
+ displayName: "Example User"
2672
+ } },
2673
+ lastModifiedBy: { user: {
2674
+ email: "user@example.com",
2675
+ displayName: "Example User"
2676
+ } },
2677
+ parentReference: {
2678
+ driveType: "documentLibrary",
2679
+ driveId: "b!ExampleDriveIDRandomString12345",
2680
+ id: "0125EXAMPLEPARENTID0987654321",
2681
+ siteId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
2682
+ },
2683
+ fileSystemInfo: {
2684
+ createdDateTime: "2025-06-11T22:08:54Z",
2685
+ lastModifiedDateTime: "2025-06-12T23:48:54Z"
2686
+ },
2687
+ folder: { childCount: 0 },
2688
+ searchResult: {}
2689
+ }] } }
2690
+ }),
2691
+ checkItemExists: (0, _prismatic_io_spectral.action)({
2692
+ display: {
2693
+ label: "Check Item Exists",
2694
+ description: "Check if a file or folder exists in a SharePoint drive"
2695
+ },
2696
+ inputs: checkItemExistsInputs,
2697
+ perform: async (context, { connection, siteId, driveId, itemPath }) => {
2698
+ const client = await createClient(connection, context.debug.enabled);
2699
+ try {
2700
+ const { data } = await client.get(`/sites/${siteId}/drives/${driveId}/root:/${itemPath}`);
2701
+ return { data: {
2702
+ exists: true,
2703
+ message: `Item "${itemPath}" exists in the specified drive`,
2704
+ item: data
2705
+ } };
2706
+ } catch (error) {
2707
+ if (error.status === 404) return { data: {
2708
+ exists: false,
2709
+ message: `Item "${itemPath}" does not exist in the specified drive`
2710
+ } };
2711
+ throw error;
2712
+ }
2713
+ },
2714
+ examplePayload: { data: {
2715
+ exists: true,
2716
+ message: "Item \"MyFolder\" exists in the specified drive",
2717
+ item: {
2718
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)/$entity",
2719
+ createdBy: { user: {
2720
+ email: "User@example.com",
2721
+ id: "00000000-0000-0000-0000-000000000001",
2722
+ displayName: "Example User"
2723
+ } },
2724
+ createdDateTime: "2025-06-11T22:08:54Z",
2725
+ eTag: "\"{DRIVE-ITEM-ETAG},2\"",
2726
+ id: "ITEM-ID-001",
2727
+ lastModifiedBy: { user: {
2728
+ email: "User@example.com",
2729
+ id: "00000000-0000-0000-0000-000000000001",
2730
+ displayName: "Example User"
2731
+ } },
2732
+ lastModifiedDateTime: "2025-06-12T23:48:54Z",
2733
+ name: "MyFolder",
2734
+ parentReference: {
2735
+ driveType: "documentLibrary",
2736
+ driveId: "DRIVE-ID-001",
2737
+ id: "ITEM-ID-002",
2738
+ name: "Shared Documents",
2739
+ path: "/drives/DRIVE-ID-001/root:",
2740
+ siteId: "SITE-ID-001"
2741
+ },
2742
+ webUrl: "https://example.sharepoint.com/sites/ExampleSite/Shared%20Documents/MyFolder",
2743
+ cTag: "\"c:{DRIVE-ITEM-CTAG},0\"",
2744
+ fileSystemInfo: {
2745
+ createdDateTime: "2025-06-11T22:08:54Z",
2746
+ lastModifiedDateTime: "2025-06-12T23:48:54Z"
2747
+ },
2748
+ folder: { childCount: 2 },
2749
+ shared: { scope: "users" },
2750
+ size: 46758
2751
+ }
2752
+ } }
2753
+ })
2754
+ };
2755
+ //#endregion
2756
+ //#region src/actions/index.ts
2757
+ var actions_default = {
2758
+ ...drive_default,
2759
+ ...lists_default,
2760
+ ...sites_default,
2761
+ ...listShared_default,
2762
+ ...subscriptions_default,
2763
+ ...users_default,
2764
+ ...webhooks_default,
2765
+ rawRequest,
2766
+ listChanges,
2767
+ ...folders_default,
2768
+ ...files_default,
2769
+ ...items_default
2770
+ };
2771
+ //#endregion
2772
+ //#region src/triggers/drivePollingTrigger.ts
2773
+ const drivePollingTrigger = (0, _prismatic_io_spectral.pollingTrigger)({
2774
+ display: {
2775
+ label: "New and Updated Drive Items",
2776
+ description: "Checks for new and updated items in a specified SharePoint drive on a configured schedule."
2777
+ },
2778
+ inputs: {
2779
+ connection,
2780
+ siteId: {
2781
+ ...siteId,
2782
+ required: false
2783
+ },
2784
+ driveId
2785
+ },
2786
+ triggerResolverSupport: "valid",
2787
+ batchConfig: { batchSize: 50 },
2788
+ triggerResolver: {
2789
+ resolveItems: (_context, { payload }) => resolvePollingRecordChanges(payload.body.data),
2790
+ getNextPaginationState: (_context, { payload }) => payload.paginationState ?? null
2791
+ },
2792
+ perform: async (context, payload, { connection, driveId }) => {
2793
+ const { logger, polling, debug } = context;
2794
+ const client = await createClient(connection, debug.enabled);
2795
+ const state = polling.getState();
2796
+ const rootDelta = `/drives/${driveId}/root/delta`;
2797
+ if (context.batch?.enabled === true) {
2798
+ const { page, next, cursorState } = await fetchDeltaRound(client, state, driveId, rootDelta, payload.paginationState);
2799
+ polling.setState(cursorState);
2800
+ return { payload: {
2801
+ ...payload,
2802
+ paginationState: next ?? void 0,
2803
+ body: { data: separateDriveChanges(page.value) }
2804
+ } };
2805
+ }
2806
+ let allChanges = {};
2807
+ const data = await paginateResults(client, resolveDeltaUrl(state, driveId, rootDelta), {
2808
+ returnFullData: true,
2809
+ useTop: false,
2810
+ excludeParents: true
2811
+ });
2812
+ const newPollingState = {};
2813
+ if (data.value.length > 0) allChanges = separateDriveChanges(data.value);
2814
+ newPollingState[driveId] = data["@odata.deltaLink"];
2815
+ polling.setState(newPollingState);
2816
+ if (debug.enabled) logger.debug("Polling state:", newPollingState);
2817
+ return Promise.resolve({ payload: {
2818
+ ...payload,
2819
+ body: { data: allChanges }
2820
+ } });
2821
+ }
2822
+ });
2823
+ //#endregion
2824
+ //#region src/triggers/folderPollingTrigger.ts
2825
+ const folderPollingTrigger = (0, _prismatic_io_spectral.pollingTrigger)({
2826
+ display: {
2827
+ label: "New and Updated Folder Items",
2828
+ description: "Checks for new and updated items in a specified folder within a SharePoint drive on a configured schedule."
2829
+ },
2830
+ inputs: folderPollingTriggerInputs,
2831
+ triggerResolverSupport: "valid",
2832
+ batchConfig: { batchSize: 50 },
2833
+ triggerResolver: {
2834
+ resolveItems: (_context, { payload }) => resolvePollingRecordChanges(payload.body.data),
2835
+ getNextPaginationState: (_context, { payload }) => payload.paginationState ?? null
2836
+ },
2837
+ perform: async (context, payload, { connection, driveId, folderId, includeSubfolders }) => {
2838
+ const { logger, polling, debug } = context;
2839
+ const client = await createClient(connection, debug.enabled);
2840
+ const stateKey = `${driveId}:${folderId}`;
2841
+ const pathKey = `${stateKey}:path`;
2842
+ const state = polling.getState();
2843
+ const rootDelta = `/drives/${driveId}/root/delta`;
2844
+ let folderPath = state[pathKey];
2845
+ if (context.batch?.enabled === true) {
2846
+ const { page, next, cursorState } = await fetchDeltaRound(client, state, stateKey, rootDelta, payload.paginationState);
2847
+ folderPath = folderPathFrom(page.value, folderId, folderPath);
2848
+ polling.setState({
2849
+ ...cursorState,
2850
+ ...folderPath ? { [pathKey]: folderPath } : {}
2851
+ });
2852
+ return { payload: {
2853
+ ...payload,
2854
+ paginationState: next ?? void 0,
2855
+ body: { data: separateDriveChanges(page.value, folderMatcher(folderId, includeSubfolders, folderPath)) }
2856
+ } };
2857
+ }
2858
+ let allChanges = {};
2859
+ const data = await paginateResults(client, resolveDeltaUrl(state, stateKey, rootDelta), {
2860
+ returnFullData: true,
2861
+ useTop: false,
2862
+ excludeParents: true
2863
+ });
2864
+ const newPollingState = {};
2865
+ if (data.value.length > 0) {
2866
+ folderPath = folderPathFrom(data.value, folderId, folderPath);
2867
+ allChanges = separateDriveChanges(data.value, folderMatcher(folderId, includeSubfolders, folderPath));
2868
+ }
2869
+ if (folderPath) newPollingState[pathKey] = folderPath;
2870
+ newPollingState[stateKey] = data["@odata.deltaLink"];
2871
+ polling.setState(newPollingState);
2872
+ if (debug.enabled) logger.debug("Polling state:", newPollingState);
2873
+ return Promise.resolve({ payload: {
2874
+ ...payload,
2875
+ body: { data: allChanges }
2876
+ } });
2877
+ }
2878
+ });
2879
+ //#endregion
2880
+ //#region src/triggers/instanceDeployWebhook.ts
2881
+ const instanceDeployWebhook = (0, _prismatic_io_spectral.trigger)({
2882
+ display: {
2883
+ label: "Drive Subscription",
2884
+ description: "Receive webhook notifications from SharePoint drives. Automatically creates and manages a webhook subscription when the instance is deployed, and removes the subscription when the instance is deleted."
2885
+ },
2886
+ scheduleSupport: "invalid",
2887
+ synchronousResponseSupport: "valid",
2888
+ allowsBranching: true,
2889
+ inputs: instanceDeployWebhookInputs,
2890
+ staticBranchNames: ["Notification", "URL Validation"],
2891
+ perform: async (context, payload, params) => {
2892
+ const rawValidationToken = payload.queryParameters?.validationToken;
2893
+ const validationToken = _prismatic_io_spectral.util.types.toString(rawValidationToken);
2894
+ const expectedClientState = params.clientState;
2895
+ if (expectedClientState) {
2896
+ const notifications = (payload.body?.data)?.value;
2897
+ if (Array.isArray(notifications) && notifications.length > 0) {
2898
+ if (notifications[0]?.clientState !== expectedClientState) context.logger.warn("ClientState mismatch in webhook notification.");
2899
+ }
2900
+ }
2901
+ if (validationToken) return Promise.resolve({
2902
+ payload,
2903
+ response: {
2904
+ statusCode: 200,
2905
+ contentType: "text/plain",
2906
+ body: validationToken
2907
+ },
2908
+ branch: "URL Validation"
2909
+ });
2910
+ return Promise.resolve({
2911
+ payload,
2912
+ branch: "Notification"
2913
+ });
2914
+ },
2915
+ webhookLifecycleHandlers: {
2916
+ create: async (context, params) => {
2917
+ const client = await createClient(params.connection, context.debug.enabled);
2918
+ const expiration = params.expirationDateTime || calculateExpirationDateTime(3);
2919
+ context.logger.info(`Creating SharePoint subscription for resource: ${params.resource}`);
2920
+ await createSubscriptionTrigger(client, {
2921
+ resource: params.resource,
2922
+ changeType: params.changeType,
2923
+ clientState: params.clientState,
2924
+ expirationDateTime: expiration,
2925
+ allowDuplicates: false
2926
+ }, context);
2927
+ },
2928
+ delete: async (context, params) => {
2929
+ const client = await createClient(params.connection, context.debug.enabled);
2930
+ context.logger.info("Deleting SharePoint subscription(s) for this flow");
2931
+ await deleteSubscriptionTrigger(client, context);
2932
+ }
2933
+ }
2934
+ });
2935
+ //#endregion
2936
+ //#region src/triggers/pollSiteChanges.ts
2937
+ const pollSiteChanges = (0, _prismatic_io_spectral.pollingTrigger)({
2938
+ display: {
2939
+ label: "New and Updated Site Items",
2940
+ description: "Checks for new and updated items across all drives in a SharePoint site on a configured schedule."
2941
+ },
2942
+ inputs: {
2943
+ connection,
2944
+ siteId
2945
+ },
2946
+ triggerResolverSupport: "valid",
2947
+ batchConfig: { batchSize: 50 },
2948
+ triggerResolver: {
2949
+ resolveItems: (_context, { payload }) => resolveSitePollingRecordChanges(payload.body.data),
2950
+ getNextPaginationState: (_context, { payload }) => payload.paginationState ?? null
2951
+ },
2952
+ perform: async (context, payload, { connection, siteId }) => {
2953
+ const { logger, polling, debug } = context;
2954
+ const client = await createClient(connection, debug.enabled);
2955
+ const state = polling.getState();
2956
+ const rootDeltaFor = (driveId) => `/sites/${siteId}/drives/${driveId}/root/delta`;
2957
+ const allDrives = await paginateResults(client, `/sites/${siteId}/drives?$select=id,name`);
2958
+ if (context.batch?.enabled === true) {
2959
+ const incoming = payload.paginationState;
2960
+ const { changes, next, newPollingState } = await fetchSiteDeltaRound(client, state, rootDeltaFor, allDrives, incoming);
2961
+ polling.setState(newPollingState);
2962
+ return {
2963
+ payload: {
2964
+ ...payload,
2965
+ paginationState: next ?? void 0,
2966
+ body: { data: changes }
2967
+ },
2968
+ polledNoChanges: Object.keys(changes).length === 0 && next === null && !incoming
2969
+ };
2970
+ }
2971
+ let polledNoChanges = true;
2972
+ const allChanges = {};
2973
+ for (const drive of allDrives) {
2974
+ const endpoint = resolveDeltaUrl(state, drive.id, rootDeltaFor(drive.id));
2975
+ allChanges[drive.name] = paginateResults(client, endpoint, {
2976
+ returnFullData: true,
2977
+ useTop: false,
2978
+ excludeParents: true
2979
+ });
2980
+ }
2981
+ const allChangesResults = await Promise.all(Object.values(allChanges));
2982
+ const newPollingState = {};
2983
+ allChangesResults.forEach((result, index) => {
2984
+ if (result.value.length > 0) {
2985
+ allChanges[allDrives[index].name] = separateDriveChanges(result.value);
2986
+ if (polledNoChanges === true) polledNoChanges = false;
2987
+ } else delete allChanges[allDrives[index].name];
2988
+ newPollingState[allDrives[index].id] = result["@odata.deltaLink"];
2989
+ });
2990
+ polling.setState(newPollingState);
2991
+ if (debug.enabled) logger.debug("Polling state:", newPollingState);
2992
+ return Promise.resolve({
2993
+ payload: {
2994
+ ...payload,
2995
+ body: { data: allChanges }
2996
+ },
2997
+ polledNoChanges
2998
+ });
2999
+ }
3000
+ });
3001
+ //#endregion
3002
+ //#region src/triggers/index.ts
3003
+ var triggers_default = {
3004
+ webhook: (0, _prismatic_io_spectral.trigger)({
3005
+ display: {
3006
+ label: "Webhook",
3007
+ description: "Receive and validate webhook requests from SharePoint for manually configured webhook subscriptions."
3008
+ },
3009
+ scheduleSupport: "invalid",
3010
+ synchronousResponseSupport: "valid",
3011
+ allowsBranching: true,
3012
+ inputs: {},
3013
+ staticBranchNames: ["Notification", "URL Validation"],
3014
+ perform: async (_context, payload) => {
3015
+ const rawValidationToken = payload.queryParameters?.validationToken;
3016
+ const validationToken = _prismatic_io_spectral.util.types.toString(rawValidationToken);
3017
+ if (validationToken) return Promise.resolve({
3018
+ payload,
3019
+ response: {
3020
+ statusCode: 200,
3021
+ contentType: "text/plain",
3022
+ body: validationToken
3023
+ },
3024
+ branch: "URL Validation"
3025
+ });
3026
+ return Promise.resolve({
3027
+ payload,
3028
+ branch: "Notification"
3029
+ });
3030
+ }
3031
+ }),
3032
+ instanceDeployWebhook,
3033
+ pollSiteChanges,
3034
+ drivePollingTrigger,
3035
+ folderPollingTrigger
3036
+ };
3037
+ //#endregion
3038
+ //#region src/actions/datasources/listDrives.ts
3039
+ const listDrives = (0, _prismatic_io_spectral.dataSource)({
3040
+ display: {
3041
+ label: "List Drives",
3042
+ description: "A picklist of drives for a given site"
3043
+ },
3044
+ inputs: {
3045
+ connection,
3046
+ siteId: {
3047
+ ...siteId,
3048
+ dataSource: void 0
3049
+ }
3050
+ },
3051
+ perform: async (_context, { connection, siteId }) => {
3052
+ const client = await createClient(connection, false);
3053
+ const path = `/sites/${siteId}/drives`;
3054
+ const drives = [];
3055
+ let nextLink = `${client.defaults.baseURL}${path}`;
3056
+ client.defaults.baseURL = void 0;
3057
+ do {
3058
+ const { data } = await client.get(nextLink);
3059
+ drives.push(...data.value || []);
3060
+ nextLink = data?.["@odata.nextLink"];
3061
+ } while (nextLink);
3062
+ return { result: sortArray(drives.map((drive) => ({
3063
+ key: drive.id,
3064
+ label: drive.name
3065
+ }))) };
3066
+ },
3067
+ dataSourceType: "picklist"
3068
+ });
3069
+ //#endregion
3070
+ //#region src/actions/datasources/listFolders.ts
3071
+ const listFolders = (0, _prismatic_io_spectral.dataSource)({
3072
+ display: {
3073
+ label: "List Folders from Source",
3074
+ description: "A picklist of folders in a given directory"
3075
+ },
3076
+ inputs: {
3077
+ connection,
3078
+ driveId: {
3079
+ ...driveId,
3080
+ dataSource: void 0
3081
+ }
3082
+ },
3083
+ perform: async (_context, { connection, driveId }) => {
3084
+ const client = await createClient(connection, false);
3085
+ const path = `/drives/${driveId}/root/children`;
3086
+ const files = [];
3087
+ let nextLink = `${client.defaults.baseURL}${path}`;
3088
+ client.defaults.baseURL = void 0;
3089
+ do {
3090
+ const { data } = await client.get(nextLink);
3091
+ files.push(...data?.value.filter((record) => record.folder) || []);
3092
+ nextLink = data?.["@odata.nextLink"];
3093
+ } while (nextLink);
3094
+ return { result: sortArray(files.map((record) => ({
3095
+ key: record.id,
3096
+ label: record.name
3097
+ }))) };
3098
+ },
3099
+ dataSourceType: "picklist"
3100
+ });
3101
+ //#endregion
3102
+ //#region src/actions/datasources/listSites.ts
3103
+ const mapToElement = (site) => ({
3104
+ key: site.id,
3105
+ label: site.displayName
3106
+ });
3107
+ //#endregion
3108
+ //#region src/actions/datasources/index.ts
3109
+ var datasources_default = {
3110
+ listDrives,
3111
+ listFolders,
3112
+ listSites: (0, _prismatic_io_spectral.dataSource)({
3113
+ display: {
3114
+ label: "List Sites from Sharepoint",
3115
+ description: "A picklist of Sites"
3116
+ },
3117
+ inputs: { connection },
3118
+ perform: async (_context, { connection }) => {
3119
+ const client = await createClient(connection, false);
3120
+ const { data } = await client.get("/sites", { params: { search: "" } });
3121
+ const sites = (data.value || []).map((site) => mapToElement(site));
3122
+ let nextLink = data?.["@odata.nextLink"];
3123
+ while (nextLink) {
3124
+ const { data } = await client.get(nextLink);
3125
+ sites.push(...(data.value || []).map((site) => mapToElement(site)));
3126
+ nextLink = data?.["@odata.nextLink"];
3127
+ }
3128
+ return { result: sortArray(sites) };
3129
+ },
3130
+ dataSourceType: "picklist"
3131
+ }),
3132
+ listItemsInSiteList: (0, _prismatic_io_spectral.dataSource)({
3133
+ display: {
3134
+ label: "List Items in Site List",
3135
+ description: "A picklist of items in a given site list"
3136
+ },
3137
+ inputs: {
3138
+ connection,
3139
+ siteId: {
3140
+ ...siteId,
3141
+ dataSource: void 0
3142
+ },
3143
+ listId: {
3144
+ ...listId,
3145
+ dataSource: void 0
3146
+ }
3147
+ },
3148
+ perform: async (_context, { connection, siteId, listId }) => {
3149
+ const client = await createClient(connection, false);
3150
+ const path = `/sites/${siteId}/lists/${listId}/items?$expand=fields`;
3151
+ const items = [];
3152
+ let nextLink = `${client.defaults.baseURL}${path}`;
3153
+ client.defaults.baseURL = void 0;
3154
+ do {
3155
+ const { data } = await client.get(nextLink);
3156
+ items.push(...data?.value || []);
3157
+ nextLink = data?.["@odata.nextLink"];
3158
+ } while (nextLink);
3159
+ return { result: sortArray(items.map((item) => {
3160
+ return {
3161
+ key: item.id,
3162
+ label: item.fields.Title
3163
+ };
3164
+ })) };
3165
+ },
3166
+ dataSourceType: "picklist"
3167
+ }),
3168
+ listSubscriptions: (0, _prismatic_io_spectral.dataSource)({
3169
+ display: {
3170
+ label: "List Subscriptions",
3171
+ description: "A picklist of subscriptions"
3172
+ },
3173
+ inputs: { connection },
3174
+ perform: async (_context, { connection }) => {
3175
+ const { data } = await (await createClient(connection, false)).get("/subscriptions");
3176
+ return { result: sortArray(data.value.map((subscription) => {
3177
+ return {
3178
+ key: subscription.id,
3179
+ label: `Resource: ${subscription.resource} - Change Type: ${subscription.changeType}`
3180
+ };
3181
+ })) };
3182
+ },
3183
+ dataSourceType: "picklist"
3184
+ }),
3185
+ selectSiteList: (0, _prismatic_io_spectral.dataSource)({
3186
+ display: {
3187
+ label: "Select Site List",
3188
+ description: "A picklist of lists in a given site"
3189
+ },
3190
+ inputs: {
3191
+ connection,
3192
+ siteId: {
3193
+ ...siteId,
3194
+ dataSource: void 0
3195
+ }
3196
+ },
3197
+ perform: async (_context, { connection, siteId }) => {
3198
+ const client = await createClient(connection, false);
3199
+ const path = `/sites/${siteId}/lists`;
3200
+ const items = [];
3201
+ let nextLink = `${client.defaults.baseURL}${path}`;
3202
+ client.defaults.baseURL = void 0;
3203
+ do {
3204
+ const { data } = await client.get(nextLink);
3205
+ items.push(...data?.value || []);
3206
+ nextLink = data?.["@odata.nextLink"];
3207
+ } while (nextLink);
3208
+ return { result: sortArray(items.map((item) => ({
3209
+ key: item.id,
3210
+ label: item.displayName || item.name
3211
+ }))) };
3212
+ },
3213
+ dataSourceType: "picklist"
3214
+ })
3215
+ };
3216
+ //#endregion
3217
+ //#region src/index.ts
3218
+ var src_default = (0, _prismatic_io_spectral.component)({
3219
+ key: "ms-sharepoint",
3220
+ public: true,
3221
+ documentationUrl: "https://prismatic.io/docs/components/ms-sharepoint/",
3222
+ display: {
3223
+ category: "Application Connectors",
3224
+ label: "Microsoft SharePoint",
3225
+ description: "Manage sites, drives, files, and lists in Microsoft SharePoint.",
3226
+ iconPath: "icon.png"
3227
+ },
3228
+ hooks: { error: _prismatic_io_spectral_http.handleErrors },
3229
+ actions: actions_default,
3230
+ triggers: triggers_default,
3231
+ connections: connections_default,
3232
+ dataSources: datasources_default
3233
+ });
3234
+ //#endregion
3235
+ //#region npm-dist/.entry.ts
3236
+ var _entry_default = (0, _prismatic_io_spectral.callableComponent)(src_default);
3237
+ //#endregion
3238
+ module.exports = _entry_default;