lokalise-mcp
Version:
The Lokalise MCP Server brings Lokalise's localization power to Claude and AI assistants—manage projects, keys, and translations by chat.
108 lines (107 loc) • 3.44 kB
JavaScript
import { z } from "zod";
// ============================================================================
// Process Status Types
// ============================================================================
/**
* Valid process status values from the SDK
*/
export const ProcessStatus = {
QUEUED: "queued",
PROCESSING: "processing",
FINISHED: "finished",
FAILED: "failed",
CANCELLED: "cancelled",
};
/**
* Valid process type values from the SDK
*/
export const ProcessType = {
FILE_UPLOAD: "file-upload",
FILE_DOWNLOAD: "file-download",
PROJECT_EXPORT: "project-export",
PROJECT_IMPORT: "project-import",
};
// ============================================================================
// Process Details Types
// ============================================================================
// Note: Using SDK types directly - UploadedFileProcessDetails and DownloadedFileProcessDetails
// These are imported from @lokalise/node-api above
// ============================================================================
// Zod Schemas
// ============================================================================
/**
* Zod schema for the list queued processes tool arguments.
* Validates input for listing background processes in a project.
*/
export const ListQueuedprocessesToolArgs = z
.object({
projectId: z
.string()
.min(1)
.describe("Project ID to list queued processes for (supports branch notation: projectId:branchName)"),
limit: z
.number()
.int()
.min(1)
.max(100)
.optional()
.default(100)
.describe("Number of processes to return (1-100, default: 100)"),
page: z
.number()
.int()
.positive()
.optional()
.default(1)
.describe("Page number for pagination (default: 1)"),
})
.strict()
.describe("Arguments for listing queued processes");
/**
* Zod schema for the get queued process details tool arguments.
* Validates input for retrieving specific process information.
*/
export const GetQueuedprocessesToolArgs = z
.object({
projectId: z.string().min(1).describe("Project ID containing the process"),
processId: z
.string()
.min(1)
.describe("Process ID to get details for (unique string identifier)"),
})
.strict()
.describe("Arguments for getting queued process details");
// ============================================================================
// Type Guards
// ============================================================================
/**
* Type guard to check if process details are for an upload
*/
export function isUploadProcessDetails(details) {
if (!details)
return false;
const obj = details;
return "files" in obj && Array.isArray(obj.files);
}
/**
* Type guard to check if process details are for a download
*/
export function isDownloadProcessDetails(details) {
if (!details)
return false;
return ("download_url" in details &&
"file_size_kb" in details &&
"total_number_of_keys" in details);
}
/**
* Type guard to check if a status is valid
*/
export function isValidProcessStatus(status) {
return Object.values(ProcessStatus).includes(status);
}
/**
* Type guard to check if a type is valid
*/
export function isValidProcessType(type) {
return Object.values(ProcessType).includes(type);
}