Skip to content

Commit 968514f

Browse files
committed
Updated readme
1 parent 5f0273f commit 968514f

1 file changed

Lines changed: 53 additions & 3 deletions

File tree

README.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,53 @@ chmod +x trigger-scheduler.sh
267267
./trigger-scheduler.sh reminders # Only check reminders
268268
```
269269

270+
## Microsoft API Schema Validation
271+
272+
External Microsoft API responses are validated at runtime using Zod schemas to ensure type safety at the boundary between this application and Microsoft services.
273+
274+
### Microsoft Graph API
275+
276+
Schemas for SharePoint permissions, sites, drives, and email operations.
277+
278+
| Schema | Description |
279+
|--------|-------------|
280+
| `GraphPermissionSchema` | Drive item and site permissions |
281+
| `GraphDriveItemSchema` | Files and folders in OneDrive/SharePoint |
282+
| `GraphDriveSchema` | Document libraries and drives |
283+
| `GraphSiteSchema` | SharePoint sites and site collections |
284+
| `GraphIdentitySetSchema` | User/group/app identities |
285+
| `GraphSharingLinkSchema` | Anonymous and organizational sharing links |
286+
| `GraphSendMailRequestSchema` | Email message structure |
287+
288+
**File:** `src/lib/microsoft/graph-schemas.ts`
289+
290+
### Office 365 Management Activity API
291+
292+
Schemas for audit log subscriptions and events.
293+
294+
| Schema | Description |
295+
|--------|-------------|
296+
| `ManagementSubscriptionSchema` | Audit log subscriptions with webhook config |
297+
| `ManagementContentBlobSchema` | Content blob references for fetching events |
298+
| `ManagementSharePointAuditEventSchema` | SharePoint audit events (file access, sharing, etc.) |
299+
300+
**File:** `src/lib/microsoft/management-api-schemas.ts`
301+
302+
### Usage
303+
304+
```typescript
305+
import { parseGraphResponse, GraphPermissionSchema } from './graph-schemas.js';
306+
import { parseManagementResponse, ManagementAuditEventsResponseSchema } from './management-api-schemas.js';
307+
308+
// Validate Graph API response
309+
const permissions = parseGraphResponse(GraphPermissionSchema, apiResponse, 'Get Permissions');
310+
311+
// Validate Management API response
312+
const events = parseManagementResponse(ManagementAuditEventsResponseSchema, apiResponse, 'Fetch Events');
313+
```
314+
315+
In development mode, validation failures throw errors. In production, failures are logged and the raw data is returned to avoid breaking changes from Microsoft API updates.
316+
270317
## Project Structure
271318

272319
```
@@ -295,9 +342,12 @@ auditsphere-api/
295342
│ ├── db/
296343
│ │ └── prisma.ts # Database client
297344
│ ├── microsoft/
298-
│ │ ├── email.ts # Microsoft Graph email client
299-
│ │ ├── permissions.ts # SharePoint permissions client
300-
│ │ └── token-manager.ts # OAuth token management
345+
│ │ ├── email.ts # Microsoft Graph email client
346+
│ │ ├── graph-schemas.ts # Zod schemas for Graph API
347+
│ │ ├── management-api.ts # Office 365 Management API client
348+
│ │ ├── management-api-schemas.ts # Zod schemas for Management API
349+
│ │ ├── permissions.ts # SharePoint permissions client
350+
│ │ └── token-manager.ts # OAuth token management
301351
│ └── access-review/
302352
│ └── pdf-report.tsx # PDF report generation
303353
├── prisma/

0 commit comments

Comments
 (0)