n8n-bookstack-agent-tool
Version:
Comprehensive BookStack API integration tool for n8n AI Agent with MCP framework compatibility
839 lines • 32.2 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BookStackApiParser = void 0;
class BookStackApiParser {
static parseApiSpec() {
const operations = {};
this.ENDPOINTS.forEach(endpoint => {
const key = `${endpoint.method.toLowerCase()}_${endpoint.tags[0]}`;
if (!operations[key]) {
operations[key] = [];
}
operations[key].push(endpoint);
});
return {
endpoints: this.ENDPOINTS,
resources: this.RESOURCES,
operations
};
}
static getEndpointsByResource(resource) {
return this.ENDPOINTS.filter(endpoint => endpoint.tags.includes(resource));
}
static getEndpointByOperationId(operationId) {
return this.ENDPOINTS.find(endpoint => endpoint.operationId === operationId);
}
}
exports.BookStackApiParser = BookStackApiParser;
BookStackApiParser.RESOURCES = [
'docs',
'attachments',
'books',
'chapters',
'pages',
'image-gallery',
'search',
'shelves',
'users',
'roles',
'recycle-bin',
'content-permissions',
'audit-log'
];
BookStackApiParser.ENDPOINTS = [
{
path: '/api/docs',
method: 'GET',
operationId: 'getDocs',
summary: 'Load the docs page for the API',
description: 'Load the docs page for the API.',
responses: { '200': { description: 'Success' } },
tags: ['docs']
},
{
path: '/api/docs.json',
method: 'GET',
operationId: 'getDocsJson',
summary: 'Show a JSON view of the API docs data',
description: 'Show a JSON view of the API docs data.',
responses: { '200': { description: 'Success' } },
tags: ['docs']
},
{
path: '/api/attachments',
method: 'GET',
operationId: 'listAttachments',
summary: 'Get a listing of attachments',
description: 'Get a listing of attachments visible to the user. The external property indicates whether the attachment is simple a link.',
parameters: [
{ name: 'count', in: 'query', required: false, schema: { type: 'integer', minimum: 1, maximum: 500 }, description: 'Number of records to return' },
{ name: 'offset', in: 'query', required: false, schema: { type: 'integer', minimum: 0 }, description: 'Number of records to skip' },
{ name: 'sort', in: 'query', required: false, schema: { type: 'string' }, description: 'Field to sort by with optional +/- prefix' }
],
responses: { '200': { description: 'Success' } },
tags: ['attachments']
},
{
path: '/api/attachments',
method: 'POST',
operationId: 'createAttachment',
summary: 'Create a new attachment',
description: 'Create a new attachment in the system. An uploaded_to value must be provided containing an ID of the page.',
requestBody: {
required: true,
content: {
'multipart/form-data': {
schema: {
type: 'object',
required: ['uploaded_to'],
properties: {
name: { type: 'string' },
uploaded_to: { type: 'integer' },
link: { type: 'string' },
file: { type: 'string', format: 'binary' }
}
}
}
}
},
responses: { '201': { description: 'Created' } },
tags: ['attachments']
},
{
path: '/api/attachments/{id}',
method: 'GET',
operationId: 'getAttachment',
summary: 'Get attachment details',
description: 'Get the details & content of a single attachment of the given ID.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Attachment ID' }
],
responses: { '200': { description: 'Success' } },
tags: ['attachments']
},
{
path: '/api/attachments/{id}',
method: 'PUT',
operationId: 'updateAttachment',
summary: 'Update attachment details',
description: 'Update the details of a single attachment.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Attachment ID' }
],
requestBody: {
required: false,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
name: { type: 'string' },
link: { type: 'string' }
}
}
}
}
},
responses: { '200': { description: 'Success' } },
tags: ['attachments']
},
{
path: '/api/attachments/{id}',
method: 'DELETE',
operationId: 'deleteAttachment',
summary: 'Delete an attachment',
description: 'Delete an attachment of the given ID.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Attachment ID' }
],
responses: { '204': { description: 'No Content' } },
tags: ['attachments']
},
{
path: '/api/books',
method: 'GET',
operationId: 'listBooks',
summary: 'Get a listing of books',
description: 'Get a listing of books visible to the user.',
parameters: [
{ name: 'count', in: 'query', required: false, schema: { type: 'integer', minimum: 1, maximum: 500 }, description: 'Number of records to return' },
{ name: 'offset', in: 'query', required: false, schema: { type: 'integer', minimum: 0 }, description: 'Number of records to skip' },
{ name: 'sort', in: 'query', required: false, schema: { type: 'string' }, description: 'Field to sort by with optional +/- prefix' }
],
responses: { '200': { description: 'Success' } },
tags: ['books']
},
{
path: '/api/books',
method: 'POST',
operationId: 'createBook',
summary: 'Create a new book',
description: 'Create a new book in the system.',
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['name'],
properties: {
name: { type: 'string' },
description: { type: 'string' },
tags: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, value: { type: 'string' } } } }
}
}
}
}
},
responses: { '201': { description: 'Created' } },
tags: ['books']
},
{
path: '/api/books/{id}',
method: 'GET',
operationId: 'getBook',
summary: 'Get book details',
description: 'View the details of a single book.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Book ID' }
],
responses: { '200': { description: 'Success' } },
tags: ['books']
},
{
path: '/api/books/{id}',
method: 'PUT',
operationId: 'updateBook',
summary: 'Update book details',
description: 'Update the details of a single book.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Book ID' }
],
requestBody: {
required: false,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
name: { type: 'string' },
description: { type: 'string' },
tags: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, value: { type: 'string' } } } }
}
}
}
}
},
responses: { '200': { description: 'Success' } },
tags: ['books']
},
{
path: '/api/books/{id}',
method: 'DELETE',
operationId: 'deleteBook',
summary: 'Delete a book',
description: 'Delete a single book. This will typically send the book to the recycle bin.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Book ID' }
],
responses: { '204': { description: 'No Content' } },
tags: ['books']
},
{
path: '/api/books/{id}/export/html',
method: 'GET',
operationId: 'exportBookHtml',
summary: 'Export book as HTML',
description: 'Export a book as a contained HTML file.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Book ID' }
],
responses: { '200': { description: 'Success' } },
tags: ['books']
},
{
path: '/api/books/{id}/export/pdf',
method: 'GET',
operationId: 'exportBookPdf',
summary: 'Export book as PDF',
description: 'Export a book as a PDF file.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Book ID' }
],
responses: { '200': { description: 'Success' } },
tags: ['books']
},
{
path: '/api/books/{id}/export/plaintext',
method: 'GET',
operationId: 'exportBookPlaintext',
summary: 'Export book as plain text',
description: 'Export a book as a plain text file.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Book ID' }
],
responses: { '200': { description: 'Success' } },
tags: ['books']
},
{
path: '/api/books/{id}/export/markdown',
method: 'GET',
operationId: 'exportBookMarkdown',
summary: 'Export book as markdown',
description: 'Export a book as a markdown file.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Book ID' }
],
responses: { '200': { description: 'Success' } },
tags: ['books']
},
{
path: '/api/chapters',
method: 'GET',
operationId: 'listChapters',
summary: 'Get a listing of chapters',
description: 'Get a listing of chapters visible to the user.',
parameters: [
{ name: 'count', in: 'query', required: false, schema: { type: 'integer', minimum: 1, maximum: 500 }, description: 'Number of records to return' },
{ name: 'offset', in: 'query', required: false, schema: { type: 'integer', minimum: 0 }, description: 'Number of records to skip' },
{ name: 'sort', in: 'query', required: false, schema: { type: 'string' }, description: 'Field to sort by with optional +/- prefix' }
],
responses: { '200': { description: 'Success' } },
tags: ['chapters']
},
{
path: '/api/chapters',
method: 'POST',
operationId: 'createChapter',
summary: 'Create a new chapter',
description: 'Create a new chapter in the system.',
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['name', 'book_id'],
properties: {
name: { type: 'string' },
description: { type: 'string' },
book_id: { type: 'integer' },
tags: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, value: { type: 'string' } } } }
}
}
}
}
},
responses: { '201': { description: 'Created' } },
tags: ['chapters']
},
{
path: '/api/chapters/{id}',
method: 'GET',
operationId: 'getChapter',
summary: 'Get chapter details',
description: 'View the details of a single chapter.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Chapter ID' }
],
responses: { '200': { description: 'Success' } },
tags: ['chapters']
},
{
path: '/api/chapters/{id}',
method: 'PUT',
operationId: 'updateChapter',
summary: 'Update chapter details',
description: 'Update the details of a single chapter.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Chapter ID' }
],
requestBody: {
required: false,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
name: { type: 'string' },
description: { type: 'string' },
book_id: { type: 'integer' },
tags: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, value: { type: 'string' } } } }
}
}
}
}
},
responses: { '200': { description: 'Success' } },
tags: ['chapters']
},
{
path: '/api/chapters/{id}',
method: 'DELETE',
operationId: 'deleteChapter',
summary: 'Delete a chapter',
description: 'Delete a chapter. This will typically send the chapter to the recycle bin.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Chapter ID' }
],
responses: { '204': { description: 'No Content' } },
tags: ['chapters']
},
{
path: '/api/pages',
method: 'GET',
operationId: 'listPages',
summary: 'Get a listing of pages',
description: 'Get a listing of pages visible to the user.',
parameters: [
{ name: 'count', in: 'query', required: false, schema: { type: 'integer', minimum: 1, maximum: 500 }, description: 'Number of records to return' },
{ name: 'offset', in: 'query', required: false, schema: { type: 'integer', minimum: 0 }, description: 'Number of records to skip' },
{ name: 'sort', in: 'query', required: false, schema: { type: 'string' }, description: 'Field to sort by with optional +/- prefix' }
],
responses: { '200': { description: 'Success' } },
tags: ['pages']
},
{
path: '/api/pages',
method: 'POST',
operationId: 'createPage',
summary: 'Create a new page',
description: 'Create a new page in the system. The ID of a parent book or chapter is required.',
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['name'],
properties: {
name: { type: 'string' },
html: { type: 'string' },
markdown: { type: 'string' },
book_id: { type: 'integer' },
chapter_id: { type: 'integer' },
tags: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, value: { type: 'string' } } } }
}
}
}
}
},
responses: { '201': { description: 'Created' } },
tags: ['pages']
},
{
path: '/api/pages/{id}',
method: 'GET',
operationId: 'getPage',
summary: 'Get page details',
description: 'View the details of a single page.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Page ID' }
],
responses: { '200': { description: 'Success' } },
tags: ['pages']
},
{
path: '/api/pages/{id}',
method: 'PUT',
operationId: 'updatePage',
summary: 'Update page details',
description: 'Update the details of a single page.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Page ID' }
],
requestBody: {
required: false,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
name: { type: 'string' },
html: { type: 'string' },
markdown: { type: 'string' },
book_id: { type: 'integer' },
chapter_id: { type: 'integer' },
tags: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, value: { type: 'string' } } } }
}
}
}
}
},
responses: { '200': { description: 'Success' } },
tags: ['pages']
},
{
path: '/api/pages/{id}',
method: 'DELETE',
operationId: 'deletePage',
summary: 'Delete a page',
description: 'Delete a page. This will typically send the page to the recycle bin.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Page ID' }
],
responses: { '204': { description: 'No Content' } },
tags: ['pages']
},
{
path: '/api/shelves',
method: 'GET',
operationId: 'listShelves',
summary: 'Get a listing of shelves',
description: 'Get a listing of shelves visible to the user.',
parameters: [
{ name: 'count', in: 'query', required: false, schema: { type: 'integer', minimum: 1, maximum: 500 }, description: 'Number of records to return' },
{ name: 'offset', in: 'query', required: false, schema: { type: 'integer', minimum: 0 }, description: 'Number of records to skip' },
{ name: 'sort', in: 'query', required: false, schema: { type: 'string' }, description: 'Field to sort by with optional +/- prefix' }
],
responses: { '200': { description: 'Success' } },
tags: ['shelves']
},
{
path: '/api/shelves',
method: 'POST',
operationId: 'createShelf',
summary: 'Create a new shelf',
description: 'Create a new shelf in the system.',
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['name'],
properties: {
name: { type: 'string' },
description: { type: 'string' },
tags: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, value: { type: 'string' } } } }
}
}
}
}
},
responses: { '201': { description: 'Created' } },
tags: ['shelves']
},
{
path: '/api/shelves/{id}',
method: 'GET',
operationId: 'getShelf',
summary: 'Get shelf details',
description: 'View the details of a single shelf.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Shelf ID' }
],
responses: { '200': { description: 'Success' } },
tags: ['shelves']
},
{
path: '/api/shelves/{id}',
method: 'PUT',
operationId: 'updateShelf',
summary: 'Update shelf details',
description: 'Update the details of a single shelf.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Shelf ID' }
],
requestBody: {
required: false,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
name: { type: 'string' },
description: { type: 'string' },
tags: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, value: { type: 'string' } } } }
}
}
}
}
},
responses: { '200': { description: 'Success' } },
tags: ['shelves']
},
{
path: '/api/shelves/{id}',
method: 'DELETE',
operationId: 'deleteShelf',
summary: 'Delete a shelf',
description: 'Delete a shelf. This will typically send the shelf to the recycle bin.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Shelf ID' }
],
responses: { '204': { description: 'No Content' } },
tags: ['shelves']
},
{
path: '/api/users',
method: 'GET',
operationId: 'listUsers',
summary: 'Get a listing of users',
description: 'Get a listing of users visible to the user.',
parameters: [
{ name: 'count', in: 'query', required: false, schema: { type: 'integer', minimum: 1, maximum: 500 }, description: 'Number of records to return' },
{ name: 'offset', in: 'query', required: false, schema: { type: 'integer', minimum: 0 }, description: 'Number of records to skip' },
{ name: 'sort', in: 'query', required: false, schema: { type: 'string' }, description: 'Field to sort by with optional +/- prefix' }
],
responses: { '200': { description: 'Success' } },
tags: ['users']
},
{
path: '/api/users',
method: 'POST',
operationId: 'createUser',
summary: 'Create a new user',
description: 'Create a new user in the system.',
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['name', 'email'],
properties: {
name: { type: 'string' },
email: { type: 'string' },
password: { type: 'string' },
roles: { type: 'array', items: { type: 'integer' } }
}
}
}
}
},
responses: { '201': { description: 'Created' } },
tags: ['users']
},
{
path: '/api/users/{id}',
method: 'GET',
operationId: 'getUser',
summary: 'Get user details',
description: 'View the details of a single user.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'User ID' }
],
responses: { '200': { description: 'Success' } },
tags: ['users']
},
{
path: '/api/users/{id}',
method: 'PUT',
operationId: 'updateUser',
summary: 'Update user details',
description: 'Update the details of a single user.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'User ID' }
],
requestBody: {
required: false,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
name: { type: 'string' },
email: { type: 'string' },
password: { type: 'string' },
roles: { type: 'array', items: { type: 'integer' } }
}
}
}
}
},
responses: { '200': { description: 'Success' } },
tags: ['users']
},
{
path: '/api/users/{id}',
method: 'DELETE',
operationId: 'deleteUser',
summary: 'Delete a user',
description: 'Delete a user from the system.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'User ID' }
],
responses: { '204': { description: 'No Content' } },
tags: ['users']
},
{
path: '/api/roles',
method: 'GET',
operationId: 'listRoles',
summary: 'Get a listing of roles',
description: 'Get a listing of roles in the system.',
parameters: [
{ name: 'count', in: 'query', required: false, schema: { type: 'integer', minimum: 1, maximum: 500 }, description: 'Number of records to return' },
{ name: 'offset', in: 'query', required: false, schema: { type: 'integer', minimum: 0 }, description: 'Number of records to skip' },
{ name: 'sort', in: 'query', required: false, schema: { type: 'string' }, description: 'Field to sort by with optional +/- prefix' }
],
responses: { '200': { description: 'Success' } },
tags: ['roles']
},
{
path: '/api/roles',
method: 'POST',
operationId: 'createRole',
summary: 'Create a new role',
description: 'Create a new role in the system.',
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['display_name'],
properties: {
display_name: { type: 'string' },
description: { type: 'string' },
permissions: { type: 'array', items: { type: 'string' } }
}
}
}
}
},
responses: { '201': { description: 'Created' } },
tags: ['roles']
},
{
path: '/api/roles/{id}',
method: 'GET',
operationId: 'getRole',
summary: 'Get role details',
description: 'View the details of a single role.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Role ID' }
],
responses: { '200': { description: 'Success' } },
tags: ['roles']
},
{
path: '/api/roles/{id}',
method: 'PUT',
operationId: 'updateRole',
summary: 'Update role details',
description: 'Update the details of a single role.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Role ID' }
],
requestBody: {
required: false,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
display_name: { type: 'string' },
description: { type: 'string' },
permissions: { type: 'array', items: { type: 'string' } }
}
}
}
}
},
responses: { '200': { description: 'Success' } },
tags: ['roles']
},
{
path: '/api/roles/{id}',
method: 'DELETE',
operationId: 'deleteRole',
summary: 'Delete a role',
description: 'Delete a role from the system.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Role ID' }
],
responses: { '204': { description: 'No Content' } },
tags: ['roles']
},
{
path: '/api/tags',
method: 'GET',
operationId: 'listTags',
summary: 'Get a listing of tags',
description: 'Get a listing of tags in the system.',
parameters: [
{ name: 'count', in: 'query', required: false, schema: { type: 'integer', minimum: 1, maximum: 500 }, description: 'Number of records to return' },
{ name: 'offset', in: 'query', required: false, schema: { type: 'integer', minimum: 0 }, description: 'Number of records to skip' },
{ name: 'sort', in: 'query', required: false, schema: { type: 'string' }, description: 'Field to sort by with optional +/- prefix' }
],
responses: { '200': { description: 'Success' } },
tags: ['tags']
},
{
path: '/api/tags',
method: 'POST',
operationId: 'createTag',
summary: 'Create a new tag',
description: 'Create a new tag in the system.',
requestBody: {
required: true,
content: {
'application/json': {
schema: {
type: 'object',
required: ['name'],
properties: {
name: { type: 'string' },
value: { type: 'string' }
}
}
}
}
},
responses: { '201': { description: 'Created' } },
tags: ['tags']
},
{
path: '/api/tags/{id}',
method: 'GET',
operationId: 'getTag',
summary: 'Get tag details',
description: 'View the details of a single tag.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Tag ID' }
],
responses: { '200': { description: 'Success' } },
tags: ['tags']
},
{
path: '/api/tags/{id}',
method: 'PUT',
operationId: 'updateTag',
summary: 'Update tag details',
description: 'Update the details of a single tag.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Tag ID' }
],
requestBody: {
required: false,
content: {
'application/json': {
schema: {
type: 'object',
properties: {
name: { type: 'string' },
value: { type: 'string' }
}
}
}
}
},
responses: { '200': { description: 'Success' } },
tags: ['tags']
},
{
path: '/api/tags/{id}',
method: 'DELETE',
operationId: 'deleteTag',
summary: 'Delete a tag',
description: 'Delete a tag from the system.',
parameters: [
{ name: 'id', in: 'path', required: true, schema: { type: 'integer' }, description: 'Tag ID' }
],
responses: { '204': { description: 'No Content' } },
tags: ['tags']
}
];
//# sourceMappingURL=api-parser.js.map