"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCredentialsOutputSchema = void 0;
const zod_1 = require("zod");
const mcpMablTool_1 = require("./mcpMablTool");
const common_1 = require("../utils/common");
exports.getCredentialsOutputSchema = zod_1.z.object({
    credentials: zod_1.z.array(zod_1.z.object({
        id: zod_1.z.string(),
        name: zod_1.z.string(),
        type: zod_1.z.string(),
        cloud_only: zod_1.z.boolean().optional(),
    })),
});
const getCredentials = (0, mcpMablTool_1.defineTool)({
    schema: {
        name: 'get_credentials',
        title: 'Get all mabl credentials',
        description: 'Get all mabl credentials and specify if they are cloud only. Example: Get my mabl credentials',
        inputSchema: zod_1.z.object({}),
        outputSchema: exports.getCredentialsOutputSchema,
        type: 'readOnly',
    },
    handle: async (_, context) => {
        const { mablApiClient, workspaceId } = context.getCurrentContext();
        const limit = 500;
        const credentials = await mablApiClient.getCredentials(workspaceId, limit);
        const credentialsResponse = credentials.map((credential) => ({
            id: credential.id,
            name: credential.name,
            type: credential.type,
            cloud_only: credential.cloud_only,
        }));
        return {
            content: [
                {
                    type: 'text',
                    text: (0, common_1.jsonPrettyPrint)({ credentials: credentialsResponse }),
                },
            ],
            structuredContent: { credentials: credentialsResponse },
        };
    },
});
exports.default = [getCredentials];
