Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/domains/contributors/contributors.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import type {
PaginatedResult,
} from "@lokalise/node-api";
import { createUnexpectedError } from "../../shared/utils/error.util.js";
import { getLokaliseApi } from "../../shared/utils/lokalise-api.util.js";
import { Logger } from "../../shared/utils/logger.util.js";
import { getLokaliseApi } from "../../shared/utils/lokalise-api.util.js";
import type {
AddContributorsToolArgsType,
GetContributorToolArgsType,
Expand Down
5 changes: 3 additions & 2 deletions src/domains/keys/keys.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import {
} from "./keys.formatter.js";
import * as keysService from "./keys.service.js";
import type {
BulkDeleteKeysToolArgsType,
BulkUpdateKeysToolArgsType,
CreateKeysToolArgsType,
DeleteKeyToolArgsType,
GetKeyToolArgsType,
ListKeysToolArgsType,
UpdateKeyToolArgsType,
BulkUpdateKeysToolArgsType,
BulkDeleteKeysToolArgsType,
} from "./keys.types.js";

/**
Expand Down Expand Up @@ -63,6 +63,7 @@ async function listKeys(
include_translations: args.includeTranslations,
filter_keys: args.filterKeys,
filter_platforms: args.filterPlatforms,
filter_filenames: args.filterFilenames,
pagination: "cursor", // Use cursor pagination for better performance
};

Expand Down
4 changes: 4 additions & 0 deletions src/domains/keys/keys.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface KeyListParams extends ApiRequestOptions {
filter_keys?: string[];
filter_platforms?: string[];
filter_tags?: string[];
filter_filenames?: string[];
pagination?: "offset" | "cursor";
cursor?: string;
}
Expand Down Expand Up @@ -161,6 +162,9 @@ export async function getKeys(
if (options.filter_tags && options.filter_tags.length > 0) {
apiParams.filter_tags = options.filter_tags.join(",");
}
if (options.filter_filenames && options.filter_filenames.length > 0) {
apiParams.filter_filenames = options.filter_filenames.join(",");
}

const result = await api.keys().list(apiParams);

Expand Down
6 changes: 6 additions & 0 deletions src/domains/keys/keys.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export const ListKeysToolArgs = z
.array(z.enum(["ios", "android", "web", "other"]))
.optional()
.describe("Filter by platforms (ios, android, web, other)"),
filterFilenames: z
.array(z.string())
.optional()
.describe(
"Filter by specific filenames (e.g., ['document.docx', 'strings.json'])",
),
})
.strict();

Expand Down
8 changes: 8 additions & 0 deletions src/domains/queuedprocesses/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Queuedprocesses domain exports
export { default as queuedprocessesCli } from "./queuedprocesses.cli.js";
export * as queuedprocessesController from "./queuedprocesses.controller.js";
export * as queuedprocessesFormatter from "./queuedprocesses.formatter.js";
export { default as queuedprocessesResource } from "./queuedprocesses.resource.js";
export * as queuedprocessesService from "./queuedprocesses.service.js";
export { default as queuedprocessesTool } from "./queuedprocesses.tool.js";
export * from "./queuedprocesses.types.js";
118 changes: 118 additions & 0 deletions src/domains/queuedprocesses/queuedprocesses.cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import type { Command } from "commander";
import type { DomainCli, DomainMeta } from "../../shared/types/domain.types.js";
import { handleCliError } from "../../shared/utils/error.util.js";
import { Logger } from "../../shared/utils/logger.util.js";
import queuedprocessesController from "./queuedprocesses.controller.js";

/**
* Queuedprocesses CLI commands implementation.
* Generated on 2025-08-11 for Monitor async operations in Lokalise.
*/

const logger = Logger.forContext("queuedprocesses.cli.ts");

/**
* Register Queuedprocesses CLI commands
* @param program The Commander program instance
*/
function register(program: Command) {
const methodLogger = logger.forMethod("register");
methodLogger.debug("Registering Queuedprocesses CLI commands...");

// List Queuedprocessess Command
program
.command("list-queuedprocessess")
.description("Lists all queuedprocesses in a Lokalise project")
.argument("<projectId>", "Project ID to list queuedprocesses for")
.option(
"-l, --limit <number>",
"Number of queuedprocesses to return (1-100, default: 100)",
(value) => {
const parsed = Number.parseInt(value, 10);
if (Number.isNaN(parsed) || parsed < 1 || parsed > 100) {
throw new Error("Limit must be a number between 1 and 100");
}
return parsed;
},
)
.option(
"-p, --page <number>",
"Page number for pagination (default: 1)",
(value) => {
const parsed = Number.parseInt(value, 10);
if (Number.isNaN(parsed) || parsed < 1) {
throw new Error("Page must be a number greater than 0");
}
return parsed;
},
)
.action(async (projectId, options) => {
const actionLogger = logger.forMethod("action:list-queuedprocessess");
try {
actionLogger.debug("CLI list-queuedprocessess called", {
projectId,
limit: options.limit,
page: options.page,
});

// Build arguments
const args = {
projectId: projectId.trim(),
limit: options.limit,
page: options.page,
};

// Call controller
const result =
await queuedprocessesController.listQueuedprocesses(args);
console.log(result.content);
} catch (error) {
handleCliError(error);
}
});

// Get Queuedprocesses Command
program
.command("get-queuedprocesses")
.description("Gets details of a specific queuedprocesses")
.argument("<projectId>", "Project ID containing the queuedprocesses")
.argument("<queuedprocessesId>", "Queuedprocesses ID to get details for")
.action(async (projectId, queuedprocessesId) => {
const actionLogger = logger.forMethod("action:get-queuedprocesses");
try {
actionLogger.debug("CLI get-queuedprocesses called", {
projectId,
queuedprocessesId,
});

// Build arguments
const args = {
projectId: projectId.trim(),
processId: queuedprocessesId.trim(),
};

// Call controller
const result = await queuedprocessesController.getQueuedprocesses(args);
console.log(result.content);
} catch (error) {
handleCliError(error);
}
});

methodLogger.debug("Queuedprocesses CLI commands registered successfully");
}

// Export the domain CLI implementation
const queuedprocessesCli: DomainCli = {
register,
getMeta(): DomainMeta {
return {
name: "queuedprocesses",
description: "Queuedprocesses CLI commands",
version: "1.0.0",
cliCommandsCount: 2,
};
},
};

export default queuedprocessesCli;
133 changes: 133 additions & 0 deletions src/domains/queuedprocesses/queuedprocesses.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import type { ControllerResponse } from "../../shared/types/common.types.js";
import { ErrorType, McpError } from "../../shared/utils/error.util.js";
import { handleControllerError } from "../../shared/utils/error-handler.util.js";
import { Logger } from "../../shared/utils/logger.util.js";
import {
formatQueuedprocessesDetails,
formatQueuedprocessesList,
} from "./queuedprocesses.formatter.js";
import { queuedprocessesService } from "./queuedprocesses.service.js";
import type {
GetQueuedprocessesToolArgsType,
ListQueuedprocessesToolArgsType,
} from "./queuedprocesses.types.js";

/**
* Controller for Queued Processes API operations
*/

/**
* List queued processes
*/
async function listQueuedprocesses(
args: ListQueuedprocessesToolArgsType,
): Promise<ControllerResponse> {
const methodLogger = Logger.forContext(
"queuedprocesses.controller.ts",
"listQueuedprocesses",
);
methodLogger.debug("Getting Lokalise queued processes list...", args);

try {
// Validate project ID
if (!args.projectId || typeof args.projectId !== "string") {
throw new McpError(
"Project ID is required and must be a string.",
ErrorType.API_ERROR,
);
}

// Validate pagination parameters
if (args.limit !== undefined && (args.limit < 1 || args.limit > 100)) {
throw new McpError(
"Invalid limit parameter. Must be between 1 and 100.",
ErrorType.API_ERROR,
);
}

if (args.page !== undefined && args.page < 1) {
throw new McpError(
"Invalid page parameter. Must be 1 or greater.",
ErrorType.API_ERROR,
);
}

// Call service layer
const result = await queuedprocessesService.list(args);

// Format response using the formatter
const formattedContent = formatQueuedprocessesList(result, args.projectId);

methodLogger.debug("Queued processes list fetched successfully", {
projectId: args.projectId,
processCount: result.items?.length || 0,
});

return {
content: formattedContent,
};
} catch (error: unknown) {
throw handleControllerError(error, {
source: "QueuedprocessesController.listQueuedprocesses",
entityType: "QueuedProcesses",
entityId: args.projectId,
operation: "listing",
});
}
}

/**
* Get details of a specific queued process
*/
async function getQueuedprocesses(
args: GetQueuedprocessesToolArgsType,
): Promise<ControllerResponse> {
const methodLogger = Logger.forContext(
"queuedprocesses.controller.ts",
"getQueuedprocesses",
);
methodLogger.debug("Getting queued process details...", args);

try {
// Validate inputs
if (!args.projectId) {
throw new McpError("Project ID is required.", ErrorType.API_ERROR);
}

if (!args.processId) {
throw new McpError("Process ID is required.", ErrorType.API_ERROR);
}

// Call service layer
const result = await queuedprocessesService.get(args);

// Format response
const formattedContent = formatQueuedprocessesDetails(result);

methodLogger.debug("Queued process details fetched successfully", {
projectId: args.projectId,
processId: args.processId,
});

return {
content: formattedContent,
};
} catch (error: unknown) {
throw handleControllerError(error, {
source: "QueuedprocessesController.getQueuedprocesses",
entityType: "QueuedProcess",
entityId: args.processId,
operation: "retrieving",
});
}
}

/**
* Controller for Lokalise Queued Processes API operations
*/
const queuedprocessesController = {
listQueuedprocesses,
getQueuedprocesses,
};

export default queuedprocessesController;
Loading