barsa 1b944f57aa Update Configuration Files and Refactor Code Structure
- Adjusted .prettierrc to ensure consistent formatting with a newline at the end of the file.
- Reformatted eslint.config.mjs for improved readability by aligning array elements.
- Updated pnpm-lock.yaml to use single quotes for consistency across dependencies.
- Simplified worktree setup in .cursor/worktrees.json for cleaner configuration.
- Enhanced documentation in .cursor/plans to clarify architecture refactoring.
- Refactored various service files for improved readability and maintainability, including rate-limiting and auth services.
- Updated imports and exports across multiple files for consistency and clarity.
- Improved error handling and logging in service methods to enhance debugging capabilities.
- Streamlined utility functions for better performance and maintainability across the domain packages.
2025-12-25 17:30:02 +09:00

56 lines
1.5 KiB
TypeScript

/**
* Common WHMCS Provider Types
*
* Generic WHMCS API response structures used across multiple domains.
*/
import { z } from "zod";
// ============================================================================
// WHMCS Generic Response Wrapper
// ============================================================================
/**
* Base schema for WHMCS API response wrapper
*/
const whmcsResponseBaseSchema = z.object({
result: z.enum(["success", "error"]),
message: z.string().optional(),
});
type WhmcsResponseBase = z.infer<typeof whmcsResponseBaseSchema>;
/**
* Generic type for WHMCS API responses derived from schema
* All WHMCS API endpoints return this structure
*
* Usage: WhmcsResponse<InvoiceData>
*/
export type WhmcsResponse<T> = WhmcsResponseBase & {
data?: T;
};
/**
* Schema factory for validating WHMCS responses
* Usage: whmcsResponseSchema(invoiceSchema)
*/
export const whmcsResponseSchema = <T extends z.ZodTypeAny>(dataSchema: T) =>
whmcsResponseBaseSchema.extend({
data: dataSchema.optional(),
});
// ============================================================================
// WHMCS Error Response
// ============================================================================
/**
* WHMCS error response schema
*/
export const whmcsErrorResponseSchema = z.object({
result: z.literal("error"),
message: z.string(),
errorcode: z.string().optional(),
});
export type WhmcsErrorResponse = z.infer<typeof whmcsErrorResponseSchema>;