UNPKG

n8n-bookstack-agent-tool

Version:

Comprehensive BookStack API integration tool for n8n AI Agent with MCP framework compatibility

69 lines โ€ข 2.85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PagesTester = void 0; const index_js_1 = require("../index.js"); class PagesTester { constructor() { const config = { baseUrl: 'https://wiki.l7cloud.io', authType: 'bearer', token: 'EnRkbVwqzNSyLaVo7olU8Wx8umGznKuE', tokenSecret: 'TyaJ0JHAenwRIgScmsffrCeSIlon4fZ2', timeout: 30000, retryAttempts: 3, retryDelay: 1000 }; this.tool = new index_js_1.BookStackN8nTool(config); } async testPages() { console.log('\n๐Ÿงช Testing Resource: PAGES'); console.log('='.repeat(50)); await this.testCrudOperations(); await this.testErrorHandling(); console.log('โœ… Pages testing completed'); } async testCrudOperations() { console.log('\n๐Ÿ“‹ Testing CRUD operations for pages...'); const operations = [ { name: 'listPages', params: { count: 5 } }, { name: 'getPage', params: { id: 1 } }, { name: 'createPage', params: { name: `Test Page ${Date.now()}`, book_id: 1, html: '<p>Test content</p>' } }, { name: 'updatePage', params: { id: 1, name: 'Updated Test Page', html: '<p>Updated content</p>' } }, { name: 'deletePage', params: { id: 1 } } ]; for (const operation of operations) { try { console.log(` Testing ${operation.name}...`); const result = await this.tool.execCommand(operation.name, operation.params); console.log(` โœ… ${operation.name}: Success`); console.log(` ๐Ÿ“„ Result: ${JSON.stringify(result, null, 2).substring(0, 200)}...`); } catch (error) { console.log(` โŒ ${operation.name}: ${error.message}`); } } } async testErrorHandling() { console.log('\nโŒ Testing error handling for pages...'); const errorTests = [ { name: 'Invalid ID', command: 'getPage', params: { id: 999999 } }, { name: 'Missing required fields', command: 'createPage', params: {} } ]; for (const test of errorTests) { try { console.log(` Testing ${test.name}...`); await this.tool.execCommand(test.command, test.params); console.log(` โš ๏ธ ${test.name}: No error thrown`); } catch (error) { console.log(` โœ… ${test.name}: Error properly handled - ${error.constructor?.name}`); } } } } exports.PagesTester = PagesTester; if (require.main === module) { const tester = new PagesTester(); tester.testPages().catch(console.error); } //# sourceMappingURL=pages-tester.js.map