n8n-bookstack-agent-tool
Version:
Comprehensive BookStack API integration tool for n8n AI Agent with MCP framework compatibility
49 lines • 2.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AttachmentsResource = void 0;
const client_js_1 = require("../auth/client.js");
const zod_1 = require("zod");
const AttachmentSchema = zod_1.z.object({
id: zod_1.z.number().optional(),
name: zod_1.z.string().optional(),
uploaded_to: zod_1.z.number().min(1, 'uploaded_to page ID is required'),
link: zod_1.z.string().url().optional(),
file: zod_1.z.string().optional()
});
const ListAttachmentsParamsSchema = zod_1.z.object({
count: zod_1.z.number().min(1).max(500).optional(),
offset: zod_1.z.number().min(0).optional(),
sort: zod_1.z.string().optional()
});
const AttachmentIdParamsSchema = zod_1.z.object({
id: zod_1.z.number().min(1, 'Attachment ID is required')
});
class AttachmentsResource {
constructor(config) {
this.client = new client_js_1.BookStackClient(config);
}
async listAttachments(params = {}) {
const validatedParams = ListAttachmentsParamsSchema.parse(params);
return await this.client.get('/api/attachments', validatedParams);
}
async getAttachment(params) {
const validatedParams = AttachmentIdParamsSchema.parse(params);
return await this.client.get('/api/attachments/{id}', validatedParams);
}
async createAttachment(params) {
const validatedParams = AttachmentSchema.parse(params);
return await this.client.post('/api/attachments', validatedParams);
}
async updateAttachment(params) {
const { id, ...attachmentData } = params;
const validatedId = AttachmentIdParamsSchema.parse({ id });
const validatedData = AttachmentSchema.partial().parse(attachmentData);
return await this.client.put('/api/attachments/{id}', { ...validatedId, ...validatedData });
}
async deleteAttachment(params) {
const validatedParams = AttachmentIdParamsSchema.parse(params);
return await this.client.delete('/api/attachments/{id}', validatedParams);
}
}
exports.AttachmentsResource = AttachmentsResource;
//# sourceMappingURL=attachments.js.map