Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions tools/v2/team/mail-to-ticket-converter/execution.fixtures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import type { MailToTicketInput } from "./execution";

export const successfulInput: MailToTicketInput = {
emailId: "email-001",
subject: "Login page not loading",
description: "Users report that the login page shows a white screen after entering credentials.",
priority: "high",
category: "bug",
assignedTo: "member-1",
createdBy: "support@example.com",
};

export const missingEmailIdInput: MailToTicketInput = {
emailId: "",
subject: "Test ticket",
description: "Description",
priority: "medium",
category: "support",
createdBy: "user@example.com",
};

export const invalidPriorityInput: MailToTicketInput = {
emailId: "email-002",
subject: "Feature request",
description: "Add dark mode support",
priority: "urgent" as any,
category: "feature-request",
createdBy: "user@example.com",
};

export const missingCreatedByInput: MailToTicketInput = {
emailId: "email-003",
subject: "Billing question",
description: "Need invoice clarification",
priority: "low",
category: "billing",
createdBy: "",
};

export const unassignedInput: MailToTicketInput = {
emailId: "email-004",
subject: "General inquiry",
description: "How do I reset my password?",
priority: "low",
category: "support",
createdBy: "user@example.com",
};

export const criticalBugInput: MailToTicketInput = {
emailId: "email-005",
subject: "Payment gateway down",
description: "All payments are failing with 500 errors since 10:00 AM UTC.",
priority: "critical",
category: "bug",
assignedTo: "member-2",
createdBy: "ops@example.com",
};
75 changes: 75 additions & 0 deletions tools/v2/team/mail-to-ticket-converter/execution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* Execution contract for Mail-to-Ticket Converter.
* Non-UI, backend-facing types for mail-to-ticket execution.
*/

/** Error codes for mail-to-ticket execution failures */
export type MailToTicketErrorCode =
| "INVALID_INPUT"
| "EMAIL_NOT_FOUND"
| "DUPLICATE_TICKET"
| "ASSIGNMENT_FAILED"
| "STATUS_TRANSITION_INVALID"
| "PERSISTENCE_FAILED"
| "INTERNAL_ERROR";

/** Input for converting an email to a ticket */
export interface MailToTicketInput {
/** ID of the source email */
emailId: string;
/** Ticket subject */
subject: string;
/** Ticket description */
description: string;
/** Priority level */
priority: "low" | "medium" | "high" | "critical";
/** Ticket category */
category: "bug" | "feature-request" | "support" | "billing" | "other";
/** Optional team member to assign */
assignedTo?: string;
/** Identity creating the ticket */
createdBy: string;
}

/** Output from successful ticket creation */
export interface MailToTicketOutput {
/** Unique ticket identifier */
id: string;
/** Reference to source email */
emailId: string;
/** Ticket subject */
subject: string;
/** Ticket description */
description: string;
/** Priority level */
priority: "low" | "medium" | "high" | "critical";
/** Current status */
status: "open" | "in-progress" | "resolved" | "closed";
/** Ticket category */
category: "bug" | "feature-request" | "support" | "billing" | "other";
/** Assigned team member id */
assignedTo: string | null;
/** Creator identity */
createdBy: string;
/** Creation timestamp */
createdAt: string;
/** Last update timestamp */
updatedAt: string;
/** Resolution notes */
resolution: string | null;
}

/** Error result structure */
export interface MailToTicketError {
code: MailToTicketErrorCode;
message: string;
/** Dot-path to invalid field when applicable */
field?: string;
}

/** Discriminated union result type */
export type MailToTicketResult =
{ ok: true; data: MailToTicketOutput } | { ok: false; error: MailToTicketError };

/** Execution function type signature */
export type ExecuteMailToTicket = (input: MailToTicketInput) => Promise<MailToTicketResult>;
10 changes: 10 additions & 0 deletions tools/v2/team/mail-to-ticket-converter/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,13 @@ export interface IMailToTicketService {
assignTicket(ticketId: string, memberId: string): Promise<Ticket>;
getMetrics(): Promise<TicketMetrics>;
}

// Execution contract exports
export type {
MailToTicketErrorCode,
MailToTicketInput,
MailToTicketOutput,
MailToTicketError,
MailToTicketResult,
ExecuteMailToTicket,
} from "./execution";
Loading