UNPKG

n8n-nodes-sevdesk-v2

Version:

n8n community node for SevDesk API v2 integration with 24 production-ready workflow templates. Direct API access without external dependencies - simplified, secure, and optimized for German accounting automation (n8n 1.101.1 compatible).

192 lines (191 loc) 7.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SevDeskConfigManager = void 0; class SevDeskConfigManager { static getConfig(version) { const config = this.API_CONFIGS[version]; if (!config) { throw new Error(`Unsupported SevDesk API version: ${version}. Supported versions: ${Object.keys(this.API_CONFIGS).join(', ')}`); } return { ...config }; } static getSupportedVersions() { return Object.keys(this.API_CONFIGS); } static getDefaultVersion() { return 'v2'; } static isVersionSupported(version) { return version in this.API_CONFIGS; } static getEndpoint(version, endpointKey, params) { const config = this.getConfig(version); let endpoint = config.endpoints[endpointKey]; if (!endpoint) { throw new Error(`Endpoint '${endpointKey}' not found for API version ${version}`); } if (params) { for (const [key, value] of Object.entries(params)) { endpoint = endpoint.replace(`{${key}}`, value); } } return endpoint; } static getFullUrl(version, endpointKey, params) { const config = this.getConfig(version); const endpoint = this.getEndpoint(version, endpointKey, params); return `${config.baseUrl}${endpoint}`; } static getRateLimits(version) { const config = this.getConfig(version); return { ...config.rateLimits }; } static getTimeouts(version) { const config = this.getConfig(version); return { ...config.timeouts }; } static getRetryConfig(version) { const config = this.getConfig(version); return { ...config.retryConfig }; } static validateApiVersion(version) { if (!version) { return this.getDefaultVersion(); } if (!this.isVersionSupported(version)) { throw new Error(`Invalid API version: ${version}. Supported versions: ${this.getSupportedVersions().join(', ')}`); } return version; } static getResourceEndpointMapping(version) { const config = this.getConfig(version); return { contact: config.endpoints.contacts, contactAddress: config.endpoints.contactAddresses, contactCustomField: config.endpoints.contactCustomFields, contactCustomFieldSetting: config.endpoints.contactCustomFieldSettings, contactField: config.endpoints.contactFields, invoice: config.endpoints.invoices, voucher: config.endpoints.vouchers, order: config.endpoints.orders, category: config.endpoints.categories, checkAccount: config.endpoints.checkAccounts, checkAccountTransaction: config.endpoints.checkAccountTransactions, communicationWay: config.endpoints.communicationWays, country: config.endpoints.countries, creditNote: config.endpoints.creditNotes, creditNotePos: config.endpoints.creditNotePositions, export: config.endpoints.exports, layout: config.endpoints.layouts, part: config.endpoints.parts, report: config.endpoints.reports, tag: config.endpoints.tags, tagRelation: config.endpoints.tagRelations, unit: config.endpoints.units, basics: config.endpoints.basics, }; } } exports.SevDeskConfigManager = SevDeskConfigManager; SevDeskConfigManager.API_CONFIGS = { 'v1': { version: 'v1', baseUrl: 'https://my.sevdesk.de/api/v1', endpoints: { contacts: '/Contact', contactById: '/Contact/{id}', contactAddresses: '/ContactAddress', contactCustomFields: '/ContactCustomField', contactCustomFieldSettings: '/ContactCustomFieldSetting', contactFields: '/ContactField', invoices: '/Invoice', invoiceById: '/Invoice/{id}', invoicePositions: '/InvoicePos', vouchers: '/Voucher', voucherById: '/Voucher/{id}', voucherPositions: '/VoucherPos', orders: '/Order', orderById: '/Order/{id}', orderPositions: '/OrderPos', categories: '/Category', checkAccounts: '/CheckAccount', checkAccountTransactions: '/CheckAccountTransaction', communicationWays: '/CommunicationWay', countries: '/StaticCountry', creditNotes: '/CreditNote', creditNotePositions: '/CreditNotePos', exports: '/Export', layouts: '/Layout', parts: '/Part', reports: '/Report', tags: '/Tag', tagRelations: '/TagRelation', units: '/Unity', basics: '/Basics', }, rateLimits: { requestsPerSecond: 10, requestsPerMinute: 600, requestsPerHour: 36000, }, timeouts: { request: 30000, connection: 10000, }, retryConfig: { maxRetries: 3, retryDelay: 1000, retryableStatusCodes: [429, 500, 502, 503, 504], }, }, 'v2': { version: 'v2', baseUrl: 'https://my.sevdesk.de/api/v2', endpoints: { contacts: '/Contact', contactById: '/Contact/{id}', contactAddresses: '/ContactAddress', contactCustomFields: '/ContactCustomField', contactCustomFieldSettings: '/ContactCustomFieldSetting', contactFields: '/ContactField', invoices: '/Invoice', invoiceById: '/Invoice/{id}', invoicePositions: '/InvoicePos', vouchers: '/Voucher', voucherById: '/Voucher/{id}', voucherPositions: '/VoucherPos', orders: '/Order', orderById: '/Order/{id}', orderPositions: '/OrderPos', categories: '/Category', checkAccounts: '/CheckAccount', checkAccountTransactions: '/CheckAccountTransaction', communicationWays: '/CommunicationWay', countries: '/StaticCountry', creditNotes: '/CreditNote', creditNotePositions: '/CreditNotePos', exports: '/Export', layouts: '/Layout', parts: '/Part', reports: '/Report', tags: '/Tag', tagRelations: '/TagRelation', units: '/Unity', basics: '/Basics', }, rateLimits: { requestsPerSecond: 15, requestsPerMinute: 900, requestsPerHour: 54000, }, timeouts: { request: 30000, connection: 10000, }, retryConfig: { maxRetries: 3, retryDelay: 1000, retryableStatusCodes: [429, 500, 502, 503, 504], }, }, };