@mcp-consultant-tools/sharepoint 1.0.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,171 @@
1
+ /**
2
+ * SharePoint Online Service
3
+ *
4
+ * Provides read-only access to SharePoint Online sites, document libraries, and files
5
+ * through Microsoft Graph API with comprehensive PowerPlatform validation capabilities.
6
+ *
7
+ * Authentication: Microsoft Entra ID (OAuth 2.0) via MSAL
8
+ * API: Microsoft Graph API v1.0
9
+ * Primary Use Case: PowerPlatform-SharePoint integration validation
10
+ */
11
+ import type { SharePointConfig, SharePointSiteConfig, SiteInfo, DriveInfo, ItemInfo, FolderTree, SearchResult, ConnectionTestResult, ValidationResult, MigrationVerification, SharePointDocumentLocation } from './types/sharepoint-types.js';
12
+ export type { SharePointConfig, SharePointSiteConfig, SiteInfo, DriveInfo, ItemInfo, FolderTree, SearchResult, ConnectionTestResult, ValidationResult, MigrationVerification, SharePointDocumentLocation, };
13
+ /**
14
+ * SharePoint Online Service
15
+ *
16
+ * Manages authentication, caching, and API requests to SharePoint Online via Graph API.
17
+ * Follows established patterns from ApplicationInsightsService and LogAnalyticsService.
18
+ */
19
+ export declare class SharePointService {
20
+ private config;
21
+ private msalClient;
22
+ private accessToken;
23
+ private tokenExpirationTime;
24
+ private graphClient;
25
+ private cache;
26
+ private siteIdCache;
27
+ private readonly graphBaseUrl;
28
+ constructor(config: SharePointConfig);
29
+ /**
30
+ * Get an access token for Microsoft Graph API (Entra ID auth)
31
+ * Implements 5-minute token buffer before expiry (follows ApplicationInsightsService pattern)
32
+ */
33
+ private getAccessToken;
34
+ /**
35
+ * Initialize Graph Client with MSAL token provider
36
+ */
37
+ private getGraphClient;
38
+ /**
39
+ * Get active sites
40
+ */
41
+ getActiveSites(): SharePointSiteConfig[];
42
+ /**
43
+ * Get all sites (including inactive)
44
+ */
45
+ getAllSites(): SharePointSiteConfig[];
46
+ /**
47
+ * Get site configuration by ID
48
+ */
49
+ getSiteById(siteId: string): SharePointSiteConfig;
50
+ /**
51
+ * Generate cache key for caching API responses
52
+ * Format: {method}:{siteId}:{resource}:{params}
53
+ */
54
+ private getCacheKey;
55
+ /**
56
+ * Get cached value if not expired
57
+ */
58
+ private getCached;
59
+ /**
60
+ * Set cached value with TTL
61
+ */
62
+ private setCached;
63
+ /**
64
+ * Clear cache (all entries or by pattern/siteId)
65
+ */
66
+ clearCache(pattern?: string, siteId?: string): number;
67
+ /**
68
+ * Resolve SharePoint site URL to Graph API site ID
69
+ * Format: {hostname},{site-collection-id},{web-id}
70
+ * Example: contoso.sharepoint.com,00000000-0000-0000-0000-000000000000,11111111-1111-1111-1111-111111111111
71
+ */
72
+ private resolveSiteId;
73
+ /**
74
+ * Sanitize error messages (remove sensitive information like tokens)
75
+ */
76
+ private sanitizeErrorMessage;
77
+ /**
78
+ * Handle errors with user-friendly messages
79
+ */
80
+ private handleError;
81
+ /**
82
+ * Test connection to a SharePoint site
83
+ */
84
+ testConnection(siteId: string): Promise<ConnectionTestResult>;
85
+ /**
86
+ * Get site information
87
+ */
88
+ getSiteInfo(siteId: string): Promise<SiteInfo>;
89
+ /**
90
+ * List drives (document libraries) in a site
91
+ */
92
+ listDrives(siteId: string): Promise<DriveInfo[]>;
93
+ /**
94
+ * Get drive (document library) information
95
+ */
96
+ getDriveInfo(siteId: string, driveId: string): Promise<DriveInfo>;
97
+ /**
98
+ * List items (files/folders) in a drive or folder
99
+ */
100
+ listItems(siteId: string, driveId: string, folderId?: string): Promise<ItemInfo[]>;
101
+ /**
102
+ * Get item (file/folder) by ID
103
+ */
104
+ getItem(siteId: string, driveId: string, itemId: string): Promise<ItemInfo>;
105
+ /**
106
+ * Get item by path (relative to drive root)
107
+ */
108
+ getItemByPath(siteId: string, driveId: string, path: string): Promise<ItemInfo>;
109
+ /**
110
+ * Search items in a drive or site
111
+ */
112
+ searchItems(siteId: string, query: string, driveId?: string, limit?: number): Promise<SearchResult>;
113
+ /**
114
+ * Get recent items in a drive
115
+ */
116
+ getRecentItems(siteId: string, driveId: string, limit?: number, days?: number): Promise<ItemInfo[]>;
117
+ /**
118
+ * Get folder structure (recursive)
119
+ */
120
+ getFolderStructure(siteId: string, driveId: string, folderId?: string, depth?: number): Promise<FolderTree>;
121
+ /**
122
+ * Build folder tree recursively
123
+ */
124
+ private buildFolderTree;
125
+ /**
126
+ * Get CRM document locations from PowerPlatform
127
+ *
128
+ * Queries the sharepointdocumentlocation entity in Dataverse to retrieve
129
+ * document location configurations for validation.
130
+ *
131
+ * @param powerPlatformService PowerPlatformService instance for querying Dataverse
132
+ * @param entityName Optional entity logical name to filter by (e.g., 'account', 'contact')
133
+ * @param recordId Optional record ID to filter by specific record
134
+ * @returns Array of SharePoint document location records
135
+ */
136
+ getCrmDocumentLocations(powerPlatformService: any, entityName?: string, recordId?: string): Promise<SharePointDocumentLocation[]>;
137
+ /**
138
+ * Validate a document location configuration
139
+ *
140
+ * Validates that a PowerPlatform document location configuration matches
141
+ * the actual SharePoint site structure. Checks:
142
+ * - Site exists and is accessible
143
+ * - Folder exists at the specified path
144
+ * - Folder is accessible
145
+ * - File count and empty folder detection
146
+ *
147
+ * @param powerPlatformService PowerPlatformService instance
148
+ * @param documentLocationId GUID of the sharepointdocumentlocation record
149
+ * @returns Validation result with status, issues, and recommendations
150
+ */
151
+ validateDocumentLocation(powerPlatformService: any, documentLocationId: string): Promise<ValidationResult>;
152
+ /**
153
+ * Verify document migration between two SharePoint locations
154
+ *
155
+ * Compares file counts, sizes, and names between source and target folders
156
+ * to verify successful migration.
157
+ *
158
+ * @param powerPlatformService PowerPlatformService instance (unused but kept for consistency)
159
+ * @param sourceSiteId Source SharePoint site ID
160
+ * @param sourcePath Source folder path
161
+ * @param targetSiteId Target SharePoint site ID
162
+ * @param targetPath Target folder path
163
+ * @returns Migration verification result with comparison details
164
+ */
165
+ verifyDocumentMigration(powerPlatformService: any, sourceSiteId: string, sourcePath: string, targetSiteId: string, targetPath: string): Promise<MigrationVerification>;
166
+ /**
167
+ * Close service and clear resources
168
+ */
169
+ close(): Promise<void>;
170
+ }
171
+ //# sourceMappingURL=SharePointService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SharePointService.d.ts","sourceRoot":"","sources":["../src/SharePointService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,UAAU,EACV,YAAY,EAEZ,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,6BAA6B,CAAC;AAGrC,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,GAC3B,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,mBAAmB,CAAa;IACxC,OAAO,CAAC,WAAW,CAAuB;IAG1C,OAAO,CAAC,KAAK,CAA2C;IACxD,OAAO,CAAC,WAAW,CAAkC;IAErD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAsC;gBAEvD,MAAM,EAAE,gBAAgB;IAoBpC;;;OAGG;YACW,cAAc;IAsC5B;;OAEG;YACW,cAAc;IAgB5B;;OAEG;IACH,cAAc,IAAI,oBAAoB,EAAE;IAIxC;;OAEG;IACH,WAAW,IAAI,oBAAoB,EAAE;IAIrC;;OAEG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB;IAgBjD;;;OAGG;IACH,OAAO,CAAC,WAAW;IAKnB;;OAEG;IACH,OAAO,CAAC,SAAS;IAejB;;OAEG;IACH,OAAO,CAAC,SAAS;IAMjB;;OAE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