UNPKG

n8n-nodes-nextcloud-tables

Version:

Production-Ready n8n Node für Nextcloud Tables - Vollständige API-Abdeckung mit erweiterten Filtern, Multi-Column-Sorting, CSV-Import und professioneller Datenvalidierung

87 lines 3.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TableHandler = void 0; const api_helper_1 = require("../helpers/api.helper"); class TableHandler { static async execute(context, operation, itemIndex) { switch (operation) { case 'getAll': return this.getAll(context, itemIndex); case 'get': return this.get(context, itemIndex); case 'create': return this.create(context, itemIndex); case 'update': return this.update(context, itemIndex); case 'delete': return this.delete(context, itemIndex); default: throw new Error(`Unbekannte Operation: ${operation}`); } } /** * Alle Tabellen abrufen */ static async getAll(context, itemIndex) { return api_helper_1.ApiHelper.makeApiRequest(context, 'GET', '/tables'); } /** * Eine spezifische Tabelle abrufen */ static async get(context, itemIndex) { const tableId = api_helper_1.ApiHelper.getResourceId(context.getNodeParameter('tableId', itemIndex)); return api_helper_1.ApiHelper.makeApiRequest(context, 'GET', `/tables/${tableId}`); } /** * Eine neue Tabelle erstellen */ static async create(context, itemIndex) { const title = context.getNodeParameter('title', itemIndex); const emoji = context.getNodeParameter('emoji', itemIndex, ''); const template = context.getNodeParameter('template', itemIndex, ''); const body = { title, }; if (emoji) { body.emoji = emoji; } if (template) { body.template = template; } return api_helper_1.ApiHelper.makeApiRequest(context, 'POST', '/tables', body); } /** * Eine Tabelle aktualisieren */ static async update(context, itemIndex) { const tableId = api_helper_1.ApiHelper.getResourceId(context.getNodeParameter('tableId', itemIndex)); const title = context.getNodeParameter('title', itemIndex, ''); const emoji = context.getNodeParameter('emoji', itemIndex, ''); const archived = context.getNodeParameter('archived', itemIndex, false); const body = {}; if (title) { body.title = title; } if (emoji !== undefined) { body.emoji = emoji; } if (archived !== undefined) { body.archived = archived; } // Nur aktualisieren, wenn es Änderungen gibt if (Object.keys(body).length === 0) { throw new Error('Mindestens ein Feld muss für die Aktualisierung angegeben werden'); } return api_helper_1.ApiHelper.makeApiRequest(context, 'PUT', `/tables/${tableId}`, body); } /** * Eine Tabelle löschen */ static async delete(context, itemIndex) { const tableId = api_helper_1.ApiHelper.getResourceId(context.getNodeParameter('tableId', itemIndex)); await api_helper_1.ApiHelper.makeApiRequest(context, 'DELETE', `/tables/${tableId}`); return { success: true, message: `Tabelle ${tableId} wurde erfolgreich gelöscht` }; } } exports.TableHandler = TableHandler; //# sourceMappingURL=table.handler.js.map