n8n-nodes-nextcloud-deck
Version:
n8n Node für die Integration mit Nextcloud Deck - AI Agent Tool Support
602 lines (601 loc) • 27.9 kB
JavaScript
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AttachmentHandler = exports.CommentHandler = exports.LabelHandler = exports.CardHandler = exports.StackHandler = exports.BoardHandler = exports.getResourceString = exports.getResourceId = void 0;
const boardActions = __importStar(require("../actions/board"));
const stackActions = __importStar(require("../actions/stack"));
const cardActions = __importStar(require("../actions/card"));
const commentActions = __importStar(require("../actions/comment"));
const attachmentActions = __importStar(require("../actions/attachment"));
const getResourceId = (resourceParam) => {
if (typeof resourceParam === 'object' && resourceParam !== null) {
const resourceLocator = resourceParam;
return parseInt(resourceLocator.value, 10);
}
return parseInt(resourceParam, 10);
};
exports.getResourceId = getResourceId;
const getResourceString = (resourceParam) => {
if (typeof resourceParam === 'object' && resourceParam !== null) {
const resourceLocator = resourceParam;
return resourceLocator.value;
}
return resourceParam;
};
exports.getResourceString = getResourceString;
class BoardHandler {
static async execute(operation, i) {
if (operation === 'getAll') {
const boards = await boardActions.getBoards.call(this);
return {
success: true,
operation: 'getAll',
resource: 'board',
data: { boards },
};
}
else if (operation === 'get') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const board = await boardActions.getBoard.call(this, boardId);
return {
success: true,
operation: 'get',
resource: 'board',
data: { board },
};
}
else if (operation === 'create') {
const title = this.getNodeParameter('title', i);
const color = this.getNodeParameter('color', i);
const boardData = { title, color };
const board = await boardActions.createBoard.call(this, boardData);
return {
success: true,
operation: 'create',
resource: 'board',
message: 'Board erfolgreich erstellt',
data: { board },
};
}
else if (operation === 'update') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const title = this.getNodeParameter('title', i, '');
const color = this.getNodeParameter('color', i, '');
const boardData = { id: boardId };
if (title)
boardData.title = title;
if (color)
boardData.color = color;
const board = await boardActions.updateBoard.call(this, boardData);
return {
success: true,
operation: 'update',
resource: 'board',
message: 'Board erfolgreich aktualisiert',
data: { board },
};
}
else if (operation === 'delete') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const response = await boardActions.deleteBoard.call(this, boardId);
return {
success: true,
operation: 'delete',
resource: 'board',
message: 'Board erfolgreich gelöscht',
data: response,
};
}
throw new Error(`Unbekannte Operation: ${operation}`);
}
}
exports.BoardHandler = BoardHandler;
class StackHandler {
static async execute(operation, i) {
if (operation === 'getAll') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stacks = await stackActions.getStacks.call(this, boardId);
return {
success: true,
operation: 'getAll',
resource: 'stack',
data: { stacks },
};
}
else if (operation === 'get') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const stack = await stackActions.getStack.call(this, boardId, stackId);
return {
success: true,
operation: 'get',
resource: 'stack',
data: { stack },
};
}
else if (operation === 'create') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const title = this.getNodeParameter('title', i);
const order = this.getNodeParameter('order', i, 0);
const stackData = { title, boardId, order };
const stack = await stackActions.createStack.call(this, boardId, stackData);
return {
success: true,
operation: 'create',
resource: 'stack',
message: 'Stack erfolgreich erstellt',
data: { stack },
};
}
else if (operation === 'update') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const title = this.getNodeParameter('title', i, '');
const order = this.getNodeParameter('order', i, 0);
let finalOrder = order;
if (order === 0) {
const currentStack = await stackActions.getStack.call(this, boardId, stackId);
finalOrder = currentStack.order || 0;
}
const stackData = { id: stackId, boardId, order: finalOrder };
if (title)
stackData.title = title;
const stack = await stackActions.updateStack.call(this, boardId, stackData);
return {
success: true,
operation: 'update',
resource: 'stack',
message: 'Stack erfolgreich aktualisiert',
data: { stack },
};
}
else if (operation === 'delete') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const response = await stackActions.deleteStack.call(this, boardId, stackId);
return {
success: true,
operation: 'delete',
resource: 'stack',
message: 'Stack erfolgreich gelöscht',
data: response,
};
}
throw new Error(`Unbekannte Operation: ${operation}`);
}
}
exports.StackHandler = StackHandler;
class CardHandler {
static async execute(operation, i) {
if (operation === 'getAll') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const cards = await cardActions.getCards.call(this, boardId, stackId);
return {
success: true,
operation: 'getAll',
resource: 'card',
message: `${cards.length} Karten im Stack gefunden`,
data: { cards, boardId, stackId },
};
}
else if (operation === 'get') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const card = await cardActions.getCard.call(this, boardId, stackId, cardId);
return {
success: true,
operation: 'get',
resource: 'card',
data: { card },
};
}
else if (operation === 'create') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const title = this.getNodeParameter('title', i);
const description = this.getNodeParameter('description', i, '');
const type = this.getNodeParameter('type', i, 'plain');
const order = this.getNodeParameter('order', i, 0);
const duedate = this.getNodeParameter('duedate', i, '');
const assignUser = this.getNodeParameter('assignUser', i, '');
const cardData = { title };
if (description)
cardData.description = description;
if (type && type !== 'plain')
cardData.type = type;
if (order > 0)
cardData.order = order;
if (duedate)
cardData.duedate = duedate;
const card = await cardActions.createCard.call(this, boardId, stackId, cardData);
const cardId = card.id;
if (assignUser) {
const userId = (0, exports.getResourceString)(assignUser);
if (userId) {
try {
await cardActions.assignUserToCard.call(this, boardId, stackId, cardId, userId);
}
catch (assignError) {
}
}
}
return {
success: true,
operation: 'create',
resource: 'card',
message: (() => {
let msg = 'Karte erfolgreich erstellt';
if (assignUser && (0, exports.getResourceString)(assignUser))
msg += ' und Benutzer zugewiesen';
return msg;
})(),
data: { card },
};
}
else if (operation === 'update') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const title = this.getNodeParameter('title', i, '');
const description = this.getNodeParameter('description', i, '');
const type = this.getNodeParameter('type', i, '');
const order = this.getNodeParameter('order', i, 0);
const duedate = this.getNodeParameter('duedate', i, '');
const assignUser = this.getNodeParameter('assignUser', i, '');
let finalOrder = order;
if (order === 0) {
const currentCard = await cardActions.getCard.call(this, boardId, stackId, cardId);
finalOrder = currentCard.order || 0;
}
const cardData = { id: cardId, order: finalOrder };
if (title)
cardData.title = title;
if (description)
cardData.description = description;
if (type)
cardData.type = type;
if (duedate)
cardData.duedate = duedate;
const card = await cardActions.updateCard.call(this, boardId, stackId, cardData);
if (assignUser) {
const userId = (0, exports.getResourceString)(assignUser);
if (userId) {
try {
await cardActions.assignUserToCard.call(this, boardId, stackId, cardId, userId);
}
catch (assignError) {
}
}
}
return {
success: true,
operation: 'update',
resource: 'card',
message: (() => {
let msg = 'Karte erfolgreich aktualisiert';
if (assignUser && (0, exports.getResourceString)(assignUser))
msg += ' und Benutzer zugewiesen';
return msg;
})(),
data: { card },
};
}
else if (operation === 'delete') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const response = await cardActions.deleteCard.call(this, boardId, stackId, cardId);
return {
success: true,
operation: 'delete',
resource: 'card',
message: 'Karte erfolgreich gelöscht',
data: response,
};
}
else if (operation === 'assignUser') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const userId = (0, exports.getResourceString)(this.getNodeParameter('userId', i));
const response = await cardActions.assignUserToCard.call(this, boardId, stackId, cardId, userId);
return {
success: true,
operation: 'assignUser',
resource: 'card',
message: 'Benutzer erfolgreich zugewiesen',
data: response,
};
}
else if (operation === 'unassignUser') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const userId = (0, exports.getResourceString)(this.getNodeParameter('userId', i));
const response = await cardActions.unassignUserFromCard.call(this, boardId, stackId, cardId, userId);
return {
success: true,
operation: 'unassignUser',
resource: 'card',
message: 'Benutzer erfolgreich entfernt',
data: response,
};
}
throw new Error(`Unbekannte Operation: ${operation}`);
}
}
exports.CardHandler = CardHandler;
class LabelHandler {
static async execute(operation, i) {
if (operation === 'getAll') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const labels = await boardActions.getLabels.call(this, boardId);
return {
success: true,
operation: 'getAll',
resource: 'label',
message: `${labels.length} Labels im Board gefunden`,
data: { labels, boardId },
};
}
else if (operation === 'get') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const labelId = (0, exports.getResourceId)(this.getNodeParameter('labelId', i));
const label = await boardActions.getLabel.call(this, boardId, labelId);
return {
success: true,
operation: 'get',
resource: 'label',
data: { label },
};
}
else if (operation === 'create') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const title = this.getNodeParameter('title', i);
const color = this.getNodeParameter('color', i);
const cleanColor = color.replace('#', '');
const labelData = { title, color: cleanColor };
const label = await boardActions.createLabel.call(this, boardId, labelData);
return {
success: true,
operation: 'create',
resource: 'label',
message: 'Label erfolgreich erstellt',
data: { label },
};
}
else if (operation === 'update') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const labelId = (0, exports.getResourceId)(this.getNodeParameter('labelId', i));
const title = this.getNodeParameter('title', i, '');
const color = this.getNodeParameter('color', i, '');
const labelData = { id: labelId };
if (title)
labelData.title = title;
if (color) {
labelData.color = color.replace('#', '');
}
const label = await boardActions.updateLabel.call(this, boardId, labelData);
return {
success: true,
operation: 'update',
resource: 'label',
message: 'Label erfolgreich aktualisiert',
data: { label },
};
}
else if (operation === 'delete') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const labelId = (0, exports.getResourceId)(this.getNodeParameter('labelId', i));
const response = await boardActions.deleteLabel.call(this, boardId, labelId);
return {
success: true,
operation: 'delete',
resource: 'label',
message: 'Label erfolgreich gelöscht',
data: response,
};
}
else if (operation === 'assignToCard') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const labelId = (0, exports.getResourceId)(this.getNodeParameter('labelId', i));
const response = await cardActions.addLabelToCard.call(this, boardId, stackId, cardId, labelId);
return {
success: true,
operation: 'assignToCard',
resource: 'label',
message: 'Label erfolgreich zu Karte zugewiesen',
data: response,
};
}
else if (operation === 'removeFromCard') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const labelId = (0, exports.getResourceId)(this.getNodeParameter('labelId', i));
const response = await cardActions.removeLabelFromCard.call(this, boardId, stackId, cardId, labelId);
return {
success: true,
operation: 'removeFromCard',
resource: 'label',
message: 'Label erfolgreich von Karte entfernt',
data: response,
};
}
throw new Error(`Unbekannte Operation: ${operation}`);
}
}
exports.LabelHandler = LabelHandler;
class CommentHandler {
static async execute(operation, i) {
if (operation === 'getAll') {
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const comments = await commentActions.getComments.call(this, cardId);
return {
success: true,
operation: 'getAll',
resource: 'comment',
message: `${comments.length} Kommentare in der Karte gefunden`,
data: { comments, cardId },
};
}
else if (operation === 'get') {
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const commentId = parseInt(this.getNodeParameter('commentId', i), 10);
const comment = await commentActions.getComment.call(this, cardId, commentId);
return {
success: true,
operation: 'get',
resource: 'comment',
data: { comment },
};
}
else if (operation === 'create') {
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const message = this.getNodeParameter('message', i);
const commentData = { message };
const comment = await commentActions.createComment.call(this, cardId, commentData);
return {
success: true,
operation: 'create',
resource: 'comment',
message: 'Kommentar erfolgreich erstellt',
data: { comment },
};
}
else if (operation === 'update') {
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const commentId = parseInt(this.getNodeParameter('commentId', i), 10);
const message = this.getNodeParameter('message', i);
const commentData = { message };
const comment = await commentActions.updateComment.call(this, cardId, commentId, commentData);
return {
success: true,
operation: 'update',
resource: 'comment',
message: 'Kommentar erfolgreich aktualisiert',
data: { comment },
};
}
else if (operation === 'delete') {
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const commentId = parseInt(this.getNodeParameter('commentId', i), 10);
const response = await commentActions.deleteComment.call(this, cardId, commentId);
return {
success: true,
operation: 'delete',
resource: 'comment',
message: 'Kommentar erfolgreich gelöscht',
data: response,
};
}
throw new Error(`Unbekannte Operation: ${operation}`);
}
}
exports.CommentHandler = CommentHandler;
class AttachmentHandler {
static async execute(operation, i) {
if (operation === 'getAll') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const attachments = await attachmentActions.getAttachments.call(this, boardId, stackId, cardId);
return {
success: true,
operation: 'getAll',
resource: 'attachment',
message: `${attachments.length} Anhänge in der Karte gefunden`,
data: { attachments, boardId, stackId, cardId },
};
}
else if (operation === 'get') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const attachmentId = parseInt(this.getNodeParameter('attachmentId', i), 10);
const attachment = await attachmentActions.getAttachment.call(this, boardId, stackId, cardId, attachmentId);
return {
success: true,
operation: 'get',
resource: 'attachment',
data: { attachment },
};
}
else if (operation === 'create') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const type = this.getNodeParameter('type', i);
const data = this.getNodeParameter('data', i);
const attachmentData = { type, data };
const attachment = await attachmentActions.createAttachment.call(this, boardId, stackId, cardId, attachmentData, i);
return {
success: true,
operation: 'create',
resource: 'attachment',
message: 'Anhang erfolgreich erstellt',
data: { attachment },
};
}
else if (operation === 'update') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const attachmentId = parseInt(this.getNodeParameter('attachmentId', i), 10);
const data = this.getNodeParameter('data', i, '');
const attachmentData = { id: attachmentId };
if (data)
attachmentData.data = data;
const attachment = await attachmentActions.updateAttachment.call(this, boardId, stackId, cardId, attachmentData);
return {
success: true,
operation: 'update',
resource: 'attachment',
message: 'Anhang erfolgreich aktualisiert',
data: { attachment },
};
}
else if (operation === 'delete') {
const boardId = (0, exports.getResourceId)(this.getNodeParameter('boardId', i));
const stackId = (0, exports.getResourceId)(this.getNodeParameter('stackId', i));
const cardId = (0, exports.getResourceId)(this.getNodeParameter('cardId', i));
const attachmentId = parseInt(this.getNodeParameter('attachmentId', i), 10);
const response = await attachmentActions.deleteAttachment.call(this, boardId, stackId, cardId, attachmentId);
return {
success: true,
operation: 'delete',
resource: 'attachment',
message: 'Anhang erfolgreich gelöscht',
data: response,
};
}
throw new Error(`Unbekannte Operation: ${operation}`);
}
}
exports.AttachmentHandler = AttachmentHandler;