Add Slack integration request and response type definitions

Co-authored-by: dallin <dallin@buster.so>
This commit is contained in:
Cursor Agent 2025-07-03 22:04:11 +00:00
parent a4f255d19b
commit 3a3836761f
2 changed files with 114 additions and 0 deletions

View File

@ -0,0 +1,45 @@
import { z } from 'zod';
// POST /api/v2/slack/auth/init
export const InitiateOAuthSchema = z.object({
metadata: z
.object({
returnUrl: z.string().optional(),
source: z.string().optional(),
projectId: z.string().uuid().optional(),
})
.optional(),
});
export type InitiateOAuthRequest = z.infer<typeof InitiateOAuthSchema>;
// GET /api/v2/slack/auth/callback
export const OAuthCallbackSchema = z.object({
code: z.string(),
state: z.string(),
});
export type OAuthCallbackRequest = z.infer<typeof OAuthCallbackSchema>;
// PUT /api/v2/slack/integration
export const UpdateIntegrationSchema = z.object({
default_channel: z
.object({
name: z.string().min(1),
id: z.string().min(1),
})
.optional(),
});
export type UpdateIntegrationRequest = z.infer<typeof UpdateIntegrationSchema>;
// OAuth metadata schema (used internally)
export const OAuthMetadataSchema = z.object({
returnUrl: z.string().optional(),
source: z.string().optional(),
projectId: z.string().uuid().optional(),
initiatedAt: z.string().datetime().optional(),
ipAddress: z.string().optional(),
});
export type OAuthMetadata = z.infer<typeof OAuthMetadataSchema>;

View File

@ -0,0 +1,69 @@
// Error response type
export interface SlackErrorResponse {
error: string;
code?: string;
}
// POST /api/v2/slack/auth/init
export interface InitiateOAuthResponse {
authUrl: string;
state: string;
}
// GET /api/v2/slack/auth/callback
// This endpoint returns a redirect, not JSON
// GET /api/v2/slack/integration
export interface GetIntegrationResponse {
connected: boolean;
integration?: {
id: string;
teamName: string;
teamDomain?: string;
installedAt: string;
lastUsedAt?: string;
};
}
// DELETE /api/v2/slack/integration
export interface RemoveIntegrationResponse {
message: string;
}
// PUT /api/v2/slack/integration
export interface UpdateIntegrationResponse {
message: string;
default_channel?: {
name: string;
id: string;
};
}
// GET /api/v2/slack/channels
export interface GetChannelsResponse {
channels: Array<{
id: string;
name: string;
}>;
}
// OAuth callback result (used internally)
export interface OAuthCallbackResult {
success: boolean;
integrationId: string;
metadata?: {
returnUrl?: string;
source?: string;
projectId?: string;
initiatedAt?: string;
ipAddress?: string;
};
teamName?: string;
error?: string;
}
// Remove integration result (used internally)
export interface RemoveIntegrationResult {
success: boolean;
error?: string;
}