@klardaten/n8n-nodes-datevconnect 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +7 -10
  2. package/dist/credentials/DatevConnectApi.credentials.js +68 -95
  3. package/dist/nodes/Accounting/Accounting.config.js +1373 -0
  4. package/dist/nodes/Accounting/Accounting.node.js +180 -5153
  5. package/dist/nodes/Accounting/handlers/AccountPostingResourceHandler.js +40 -0
  6. package/dist/nodes/Accounting/handlers/AccountingSequenceResourceHandler.js +72 -0
  7. package/dist/nodes/Accounting/handlers/AccountingStatisticsResourceHandler.js +38 -0
  8. package/dist/nodes/Accounting/handlers/AccountingSumsAndBalancesResourceHandler.js +52 -0
  9. package/dist/nodes/Accounting/handlers/AccountingTransactionKeysResourceHandler.js +53 -0
  10. package/dist/nodes/Accounting/handlers/AccountsPayableResourceHandler.js +67 -0
  11. package/dist/nodes/Accounting/handlers/AccountsReceivableResourceHandler.js +48 -0
  12. package/dist/nodes/Accounting/handlers/BaseResourceHandler.js +148 -0
  13. package/dist/nodes/Accounting/handlers/BusinessPartnersResourceHandler.js +207 -0
  14. package/dist/nodes/Accounting/handlers/ClientResourceHandler.js +52 -0
  15. package/dist/nodes/Accounting/handlers/CostCenterPropertiesResourceHandler.js +55 -0
  16. package/dist/nodes/Accounting/handlers/CostCentersUnitsResourceHandler.js +55 -0
  17. package/dist/nodes/Accounting/handlers/CostSequencesResourceHandler.js +88 -0
  18. package/dist/nodes/Accounting/handlers/CostSystemsResourceHandler.js +62 -0
  19. package/dist/nodes/Accounting/handlers/FiscalYearResourceHandler.js +49 -0
  20. package/dist/nodes/Accounting/handlers/GeneralLedgerAccountsResourceHandler.js +67 -0
  21. package/dist/nodes/Accounting/handlers/InternalCostServicesResourceHandler.js +40 -0
  22. package/dist/nodes/Accounting/handlers/PostingProposalsResourceHandler.js +98 -0
  23. package/dist/nodes/Accounting/handlers/StocktakingDataResourceHandler.js +57 -0
  24. package/dist/nodes/Accounting/handlers/TermsOfPaymentResourceHandler.js +69 -0
  25. package/dist/nodes/Accounting/handlers/VariousAddressesResourceHandler.js +56 -0
  26. package/dist/nodes/Accounting/handlers/index.js +45 -0
  27. package/dist/nodes/Accounting/types.js +5 -0
  28. package/dist/nodes/DocumentManagement/DocumentManagement.config.js +598 -0
  29. package/dist/nodes/DocumentManagement/DocumentManagement.node.js +96 -3513
  30. package/dist/nodes/DocumentManagement/handlers/BaseResourceHandler.js +121 -0
  31. package/dist/nodes/DocumentManagement/handlers/DocumentFileResourceHandler.js +126 -0
  32. package/dist/nodes/DocumentManagement/handlers/DocumentResourceHandler.js +184 -0
  33. package/dist/nodes/DocumentManagement/handlers/DocumentStateResourceHandler.js +58 -0
  34. package/dist/nodes/DocumentManagement/handlers/DomainResourceHandler.js +32 -0
  35. package/dist/nodes/DocumentManagement/handlers/IndividualPropertyResourceHandler.js +32 -0
  36. package/dist/nodes/DocumentManagement/handlers/IndividualReference1ResourceHandler.js +49 -0
  37. package/dist/nodes/DocumentManagement/handlers/IndividualReference2ResourceHandler.js +49 -0
  38. package/dist/nodes/DocumentManagement/handlers/InfoResourceHandler.js +30 -0
  39. package/dist/nodes/DocumentManagement/handlers/PropertyTemplateResourceHandler.js +34 -0
  40. package/dist/nodes/DocumentManagement/handlers/SecureAreaResourceHandler.js +32 -0
  41. package/dist/nodes/DocumentManagement/types.js +2 -0
  42. package/dist/nodes/DocumentManagement/utils.js +116 -0
  43. package/dist/nodes/IdentityAndAccessManagement/IdentityAndAccessManagement.config.js +368 -0
  44. package/dist/nodes/IdentityAndAccessManagement/IdentityAndAccessManagement.node.js +77 -2774
  45. package/dist/nodes/IdentityAndAccessManagement/handlers/BaseResourceHandler.js +87 -0
  46. package/dist/nodes/IdentityAndAccessManagement/handlers/CurrentUserResourceHandler.js +17 -0
  47. package/dist/nodes/IdentityAndAccessManagement/handlers/GroupResourceHandler.js +63 -0
  48. package/dist/nodes/IdentityAndAccessManagement/handlers/ResourceTypeResourceHandler.js +17 -0
  49. package/dist/nodes/IdentityAndAccessManagement/handlers/SchemaResourceHandler.js +30 -0
  50. package/dist/nodes/IdentityAndAccessManagement/handlers/ServiceProviderConfigResourceHandler.js +17 -0
  51. package/dist/nodes/IdentityAndAccessManagement/handlers/UserResourceHandler.js +73 -0
  52. package/dist/nodes/IdentityAndAccessManagement/types.js +2 -0
  53. package/dist/nodes/IdentityAndAccessManagement/utils.js +89 -0
  54. package/dist/nodes/MasterData/MasterData.config.js +902 -0
  55. package/dist/nodes/MasterData/MasterData.node.js +107 -3561
  56. package/dist/nodes/MasterData/handlers/AddresseeResourceHandler.js +98 -0
  57. package/dist/nodes/MasterData/handlers/AreaOfResponsibilityResourceHandler.js +42 -0
  58. package/dist/nodes/MasterData/handlers/BankResourceHandler.js +42 -0
  59. package/dist/nodes/MasterData/handlers/BaseResourceHandler.js +91 -0
  60. package/dist/nodes/MasterData/handlers/ClientCategoryTypeResourceHandler.js +78 -0
  61. package/dist/nodes/MasterData/handlers/ClientGroupTypeResourceHandler.js +78 -0
  62. package/dist/nodes/MasterData/handlers/ClientResourceHandler.js +183 -0
  63. package/dist/nodes/MasterData/handlers/CorporateStructureResourceHandler.js +68 -0
  64. package/dist/nodes/MasterData/handlers/CountryCodeResourceHandler.js +42 -0
  65. package/dist/nodes/MasterData/handlers/EmployeeResourceHandler.js +78 -0
  66. package/dist/nodes/MasterData/handlers/LegalFormResourceHandler.js +42 -0
  67. package/dist/nodes/MasterData/handlers/RelationshipResourceHandler.js +54 -0
  68. package/dist/nodes/MasterData/handlers/TaxAuthorityResourceHandler.js +42 -0
  69. package/dist/nodes/MasterData/types.js +2 -0
  70. package/dist/nodes/MasterData/utils.js +92 -0
  71. package/dist/src/services/accountingClient.js +766 -0
  72. package/dist/src/services/datevConnectClient.js +1809 -0
  73. package/dist/src/services/documentManagementClient.js +546 -0
  74. package/dist/src/services/identityAndAccessManagementClient.js +293 -0
  75. package/package.json +38 -39
  76. package/dist/nodes/Accounting/Accounting.node.json +0 -25
  77. package/dist/nodes/DocumentManagement/DocumentManagement.node.json +0 -25
  78. package/dist/nodes/IdentityAndAccessManagement/IdentityAndAccessManagement.node.json +0 -25
  79. package/dist/nodes/MasterData/MasterData.node.json +0 -25
@@ -1,2775 +1,78 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __moduleCache = /* @__PURE__ */ new WeakMap;
6
- var __toCommonJS = (from) => {
7
- var entry = __moduleCache.get(from), desc;
8
- if (entry)
9
- return entry;
10
- entry = __defProp({}, "__esModule", { value: true });
11
- if (from && typeof from === "object" || typeof from === "function")
12
- __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
13
- get: () => from[key],
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- }));
16
- __moduleCache.set(from, entry);
17
- return entry;
18
- };
19
- var __export = (target, all) => {
20
- for (var name in all)
21
- __defProp(target, name, {
22
- get: all[name],
23
- enumerable: true,
24
- configurable: true,
25
- set: (newValue) => all[name] = () => newValue
26
- });
27
- };
28
-
29
- // nodes/IdentityAndAccessManagement/IdentityAndAccessManagement.node.ts
30
- var exports_IdentityAndAccessManagement_node = {};
31
- __export(exports_IdentityAndAccessManagement_node, {
32
- IdentityAndAccessManagement: () => IdentityAndAccessManagement
33
- });
34
- module.exports = __toCommonJS(exports_IdentityAndAccessManagement_node);
35
- var import_n8n_workflow8 = require("n8n-workflow");
36
-
37
- // src/services/datevConnectClient.ts
38
- var JSON_CONTENT_TYPE = "application/json";
39
- var DEFAULT_ERROR_PREFIX = "DATEVconnect request failed";
40
- function normaliseBaseUrl(host) {
41
- if (!host) {
42
- throw new Error("DATEVconnect host must be provided");
43
- }
44
- return host.endsWith("/") ? host : `${host}/`;
45
- }
46
- function buildHeaders(headers) {
47
- return Object.entries(headers).reduce((acc, [key, value]) => {
48
- if (value) {
49
- acc[key] = value;
50
- }
51
- return acc;
52
- }, {});
53
- }
54
- async function readResponseBody(response) {
55
- const contentType = response.headers.get("content-type") ?? "";
56
- if (contentType.toLowerCase().includes(JSON_CONTENT_TYPE)) {
57
- try {
58
- return await response.json();
59
- } catch {
60
- return;
61
- }
62
- }
63
- try {
64
- const text = await response.text();
65
- return text.length > 0 ? text : undefined;
66
- } catch {
67
- return;
68
- }
69
- }
70
- function extractErrorMessage(response, body) {
71
- const statusPart = `${response.status}${response.statusText ? ` ${response.statusText}` : ""}`.trim();
72
- const prefix = `${DEFAULT_ERROR_PREFIX}${statusPart ? ` (${statusPart})` : ""}`;
73
- if (typeof body === "string" && body.trim().length > 0) {
74
- return `${prefix}: ${body.trim()}`;
75
- }
76
- if (body && typeof body === "object") {
77
- const errorDescription = "error_description" in body && typeof body.error_description === "string" ? body.error_description : undefined;
78
- const message = ("message" in body && typeof body.message === "string" ? body.message : undefined) || ("error" in body && typeof body.error === "string" ? body.error : undefined);
79
- if (message) {
80
- return `${prefix}: ${message}${errorDescription ? `: ${errorDescription}` : ""}`;
81
- }
82
- }
83
- return prefix;
84
- }
85
- async function ensureSuccess(response) {
86
- const body = await readResponseBody(response);
87
- if (!response.ok) {
88
- throw new Error(extractErrorMessage(response, body));
89
- }
90
- if (body && typeof body === "object") {
91
- return body;
92
- }
93
- if (body === undefined) {
94
- return;
95
- }
96
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected JSON response body.`);
97
- }
98
- async function authenticate(options) {
99
- const { host, email, password, fetchImpl = fetch } = options;
100
- const baseUrl = normaliseBaseUrl(host);
101
- const url = new URL("api/auth/login", baseUrl);
102
- const response = await fetchImpl(url, {
103
- method: "POST",
104
- headers: buildHeaders({
105
- "content-type": JSON_CONTENT_TYPE
106
- }),
107
- body: JSON.stringify({ email, password })
108
- });
109
- const body = await ensureSuccess(response);
110
- if (!body || typeof body !== "object" || !("access_token" in body) || typeof body.access_token !== "string") {
111
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Authentication response missing access_token.`);
112
- }
113
- return body;
114
- }
115
- var MASTER_DATA_BASE_PATH = "datevconnect/master-data/v1";
116
- var CLIENTS_PATH = `${MASTER_DATA_BASE_PATH}/clients`;
117
- var TAX_AUTHORITIES_PATH = `${MASTER_DATA_BASE_PATH}/tax-authorities`;
118
- var RELATIONSHIPS_PATH = `${MASTER_DATA_BASE_PATH}/relationships`;
119
- var RELATIONSHIP_TYPES_PATH = `${MASTER_DATA_BASE_PATH}/relationship-types`;
120
- var LEGAL_FORMS_PATH = `${MASTER_DATA_BASE_PATH}/legal-forms`;
121
- var CORPORATE_STRUCTURES_PATH = `${MASTER_DATA_BASE_PATH}/corporate-structures`;
122
- var EMPLOYEES_PATH = `${MASTER_DATA_BASE_PATH}/employees`;
123
- var COUNTRY_CODES_PATH = `${MASTER_DATA_BASE_PATH}/country-codes`;
124
- var CLIENT_GROUP_TYPES_PATH = `${MASTER_DATA_BASE_PATH}/client-group-types`;
125
- var CLIENT_CATEGORY_TYPES_PATH = `${MASTER_DATA_BASE_PATH}/client-category-types`;
126
- var BANKS_PATH = `${MASTER_DATA_BASE_PATH}/banks`;
127
- var AREA_OF_RESPONSIBILITIES_PATH = `${MASTER_DATA_BASE_PATH}/area-of-responsibilities`;
128
- var ADDRESSEES_PATH = `${MASTER_DATA_BASE_PATH}/addressees`;
129
- var ADDRESSEES_DELETION_LOG_PATH = `${ADDRESSEES_PATH}/deletion-log`;
130
- function buildApiUrl(host, path) {
131
- const baseUrl = normaliseBaseUrl(host);
132
- const trimmedPath = path.startsWith("/") ? path.slice(1) : path;
133
- return new URL(trimmedPath, baseUrl);
134
- }
135
- async function sendMasterDataRequest(options) {
136
- const { host, token, clientInstanceId, path, method, query, body, fetchImpl = fetch } = options;
137
- const url = buildApiUrl(host, path);
138
- if (query) {
139
- for (const [key, value] of Object.entries(query)) {
140
- if (value === undefined || value === null) {
141
- continue;
142
- }
143
- url.searchParams.set(key, String(value));
144
- }
145
- }
146
- const response = await fetchImpl(url, {
147
- method,
148
- headers: buildHeaders({
149
- accept: JSON_CONTENT_TYPE,
150
- authorization: `Bearer ${token}`,
151
- "content-type": JSON_CONTENT_TYPE,
152
- "x-client-instance-id": clientInstanceId
153
- }),
154
- body: body === undefined ? undefined : JSON.stringify(body)
155
- });
156
- return ensureSuccess(response);
157
- }
158
- async function fetchClients(options) {
159
- const { top, skip, select, filter } = options;
160
- const body = await sendMasterDataRequest({
161
- ...options,
162
- path: CLIENTS_PATH,
163
- method: "GET",
164
- query: {
165
- top,
166
- skip,
167
- select,
168
- filter
169
- }
170
- });
171
- if (body === undefined) {
172
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected clients payload.`);
173
- }
174
- return body;
175
- }
176
- async function fetchClient(options) {
177
- const { clientId, select } = options;
178
- const body = await sendMasterDataRequest({
179
- ...options,
180
- path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}`,
181
- method: "GET",
182
- query: {
183
- select
184
- }
185
- });
186
- if (body === undefined) {
187
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client payload.`);
188
- }
189
- return body;
190
- }
191
- async function createClient(options) {
192
- const { client, maxNumber } = options;
193
- return sendMasterDataRequest({
194
- ...options,
195
- path: CLIENTS_PATH,
196
- method: "POST",
197
- query: {
198
- "max-number": maxNumber
199
- },
200
- body: client
201
- });
202
- }
203
- async function updateClient(options) {
204
- const { clientId, client } = options;
205
- return sendMasterDataRequest({
206
- ...options,
207
- path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}`,
208
- method: "PUT",
209
- body: client
210
- });
211
- }
212
- async function fetchClientResponsibilities(options) {
213
- const { clientId, select } = options;
214
- const body = await sendMasterDataRequest({
215
- ...options,
216
- path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/responsibilities`,
217
- method: "GET",
218
- query: {
219
- select
220
- }
221
- });
222
- if (body === undefined) {
223
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected responsibilities payload.`);
224
- }
225
- return body;
226
- }
227
- async function updateClientResponsibilities(options) {
228
- const { clientId, responsibilities } = options;
229
- return sendMasterDataRequest({
230
- ...options,
231
- path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/responsibilities`,
232
- method: "PUT",
233
- body: responsibilities
234
- });
235
- }
236
- async function fetchClientCategories(options) {
237
- const { clientId, select } = options;
238
- const body = await sendMasterDataRequest({
239
- ...options,
240
- path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/client-categories`,
241
- method: "GET",
242
- query: {
243
- select
244
- }
245
- });
246
- if (body === undefined) {
247
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client categories payload.`);
248
- }
249
- return body;
250
- }
251
- async function updateClientCategories(options) {
252
- const { clientId, categories } = options;
253
- return sendMasterDataRequest({
254
- ...options,
255
- path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/client-categories`,
256
- method: "PUT",
257
- body: categories
258
- });
259
- }
260
- async function fetchClientGroups(options) {
261
- const { clientId, select } = options;
262
- const body = await sendMasterDataRequest({
263
- ...options,
264
- path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/client-groups`,
265
- method: "GET",
266
- query: {
267
- select
268
- }
269
- });
270
- if (body === undefined) {
271
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client groups payload.`);
272
- }
273
- return body;
274
- }
275
- async function updateClientGroups(options) {
276
- const { clientId, groups } = options;
277
- return sendMasterDataRequest({
278
- ...options,
279
- path: `${CLIENTS_PATH}/${encodeURIComponent(clientId)}/client-groups`,
280
- method: "PUT",
281
- body: groups
282
- });
283
- }
284
- async function fetchClientDeletionLog(options) {
285
- const { select, filter, top, skip } = options;
286
- const body = await sendMasterDataRequest({
287
- ...options,
288
- path: `${CLIENTS_PATH}/deletion-log`,
289
- method: "GET",
290
- query: {
291
- select,
292
- filter,
293
- top,
294
- skip
295
- }
296
- });
297
- if (body === undefined) {
298
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client deletion log payload.`);
299
- }
300
- return body;
301
- }
302
- async function fetchNextFreeClientNumber(options) {
303
- const { start, range } = options;
304
- const body = await sendMasterDataRequest({
305
- ...options,
306
- path: `${CLIENTS_PATH}/next-free-number`,
307
- method: "GET",
308
- query: {
309
- start,
310
- range
311
- }
312
- });
313
- if (body === undefined) {
314
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected next free number payload.`);
315
- }
316
- return body;
317
- }
318
- async function fetchTaxAuthorities(options) {
319
- const { select, filter, top, skip } = options;
320
- const body = await sendMasterDataRequest({
321
- ...options,
322
- path: TAX_AUTHORITIES_PATH,
323
- method: "GET",
324
- query: {
325
- select,
326
- filter,
327
- top,
328
- skip
329
- }
330
- });
331
- if (body === undefined) {
332
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected tax authorities payload.`);
333
- }
334
- return body;
335
- }
336
- async function fetchRelationships(options) {
337
- const { select, filter, top, skip } = options;
338
- const body = await sendMasterDataRequest({
339
- ...options,
340
- path: RELATIONSHIPS_PATH,
341
- method: "GET",
342
- query: {
343
- select,
344
- filter,
345
- top,
346
- skip
347
- }
348
- });
349
- if (body === undefined) {
350
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected relationships payload.`);
351
- }
352
- return body;
353
- }
354
- async function fetchRelationshipTypes(options) {
355
- const { select, filter } = options;
356
- const body = await sendMasterDataRequest({
357
- ...options,
358
- path: RELATIONSHIP_TYPES_PATH,
359
- method: "GET",
360
- query: {
361
- select,
362
- filter
363
- }
364
- });
365
- if (body === undefined) {
366
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected relationship types payload.`);
367
- }
368
- return body;
369
- }
370
- async function fetchLegalForms(options) {
371
- const { select, nationalRight, top, skip } = options;
372
- const body = await sendMasterDataRequest({
373
- ...options,
374
- path: LEGAL_FORMS_PATH,
375
- method: "GET",
376
- query: {
377
- select,
378
- "national-right": nationalRight,
379
- top,
380
- skip
381
- }
382
- });
383
- if (body === undefined) {
384
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected legal forms payload.`);
385
- }
386
- return body;
387
- }
388
- async function fetchCorporateStructures(options) {
389
- const { select, filter, top, skip } = options;
390
- const body = await sendMasterDataRequest({
391
- ...options,
392
- path: CORPORATE_STRUCTURES_PATH,
393
- method: "GET",
394
- query: {
395
- select,
396
- filter,
397
- top,
398
- skip
399
- }
400
- });
401
- if (body === undefined) {
402
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected corporate structures payload.`);
403
- }
404
- return body;
405
- }
406
- async function fetchCorporateStructure(options) {
407
- const { organizationId, select } = options;
408
- const body = await sendMasterDataRequest({
409
- ...options,
410
- path: `${CORPORATE_STRUCTURES_PATH}/${encodeURIComponent(organizationId)}`,
411
- method: "GET",
412
- query: {
413
- select
414
- }
415
- });
416
- if (body === undefined) {
417
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected corporate structure payload.`);
418
- }
419
- return body;
420
- }
421
- async function fetchEstablishment(options) {
422
- const { organizationId, establishmentId, select } = options;
423
- const body = await sendMasterDataRequest({
424
- ...options,
425
- path: `${CORPORATE_STRUCTURES_PATH}/${encodeURIComponent(organizationId)}/establishments/${encodeURIComponent(establishmentId)}`,
426
- method: "GET",
427
- query: {
428
- select
429
- }
430
- });
431
- if (body === undefined) {
432
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected establishment payload.`);
433
- }
434
- return body;
435
- }
436
- async function fetchEmployees(options) {
437
- const { select, filter, top, skip } = options;
438
- const body = await sendMasterDataRequest({
439
- ...options,
440
- path: EMPLOYEES_PATH,
441
- method: "GET",
442
- query: {
443
- select,
444
- filter,
445
- top,
446
- skip
447
- }
448
- });
449
- if (body === undefined) {
450
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected employees payload.`);
451
- }
452
- return body;
453
- }
454
- async function fetchEmployee(options) {
455
- const { employeeId, select } = options;
456
- const body = await sendMasterDataRequest({
457
- ...options,
458
- path: `${EMPLOYEES_PATH}/${encodeURIComponent(employeeId)}`,
459
- method: "GET",
460
- query: {
461
- select
462
- }
463
- });
464
- if (body === undefined) {
465
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected employee payload.`);
466
- }
467
- return body;
468
- }
469
- async function createEmployee(options) {
470
- const { employee } = options;
471
- return sendMasterDataRequest({
472
- ...options,
473
- path: EMPLOYEES_PATH,
474
- method: "POST",
475
- body: employee
476
- });
477
- }
478
- async function updateEmployee(options) {
479
- const { employeeId, employee } = options;
480
- return sendMasterDataRequest({
481
- ...options,
482
- path: `${EMPLOYEES_PATH}/${encodeURIComponent(employeeId)}`,
483
- method: "PUT",
484
- body: employee
485
- });
486
- }
487
- async function fetchCountryCodes(options) {
488
- const { select, filter, top, skip } = options;
489
- const body = await sendMasterDataRequest({
490
- ...options,
491
- path: COUNTRY_CODES_PATH,
492
- method: "GET",
493
- query: {
494
- select,
495
- filter,
496
- top,
497
- skip
498
- }
499
- });
500
- if (body === undefined) {
501
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected country codes payload.`);
502
- }
503
- return body;
504
- }
505
- async function fetchClientGroupTypes(options) {
506
- const { select, filter, top, skip } = options;
507
- const body = await sendMasterDataRequest({
508
- ...options,
509
- path: CLIENT_GROUP_TYPES_PATH,
510
- method: "GET",
511
- query: {
512
- select,
513
- filter,
514
- top,
515
- skip
516
- }
517
- });
518
- if (body === undefined) {
519
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client group types payload.`);
520
- }
521
- return body;
522
- }
523
- async function fetchClientGroupType(options) {
524
- const { clientGroupTypeId, select } = options;
525
- const body = await sendMasterDataRequest({
526
- ...options,
527
- path: `${CLIENT_GROUP_TYPES_PATH}/${clientGroupTypeId}`,
528
- method: "GET",
529
- query: {
530
- select
531
- }
532
- });
533
- if (body === undefined) {
534
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client group type payload.`);
535
- }
536
- return body;
537
- }
538
- async function createClientGroupType(options) {
539
- const { clientGroupType } = options;
540
- const body = await sendMasterDataRequest({
541
- ...options,
542
- path: CLIENT_GROUP_TYPES_PATH,
543
- method: "POST",
544
- body: clientGroupType
545
- });
546
- return body;
547
- }
548
- async function updateClientGroupType(options) {
549
- const { clientGroupTypeId, clientGroupType } = options;
550
- const body = await sendMasterDataRequest({
551
- ...options,
552
- path: `${CLIENT_GROUP_TYPES_PATH}/${clientGroupTypeId}`,
553
- method: "PUT",
554
- body: clientGroupType
555
- });
556
- return body;
557
- }
558
- async function fetchClientCategoryTypes(options) {
559
- const { select, filter, top, skip } = options;
560
- const body = await sendMasterDataRequest({
561
- ...options,
562
- path: CLIENT_CATEGORY_TYPES_PATH,
563
- method: "GET",
564
- query: {
565
- select,
566
- filter,
567
- top,
568
- skip
569
- }
570
- });
571
- if (body === undefined) {
572
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client category types payload.`);
573
- }
574
- return body;
575
- }
576
- async function fetchClientCategoryType(options) {
577
- const { clientCategoryTypeId, select } = options;
578
- const body = await sendMasterDataRequest({
579
- ...options,
580
- path: `${CLIENT_CATEGORY_TYPES_PATH}/${clientCategoryTypeId}`,
581
- method: "GET",
582
- query: {
583
- select
584
- }
585
- });
586
- if (body === undefined) {
587
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected client category type payload.`);
588
- }
589
- return body;
590
- }
591
- async function createClientCategoryType(options) {
592
- const { clientCategoryType } = options;
593
- const body = await sendMasterDataRequest({
594
- ...options,
595
- path: CLIENT_CATEGORY_TYPES_PATH,
596
- method: "POST",
597
- body: clientCategoryType
598
- });
599
- return body;
600
- }
601
- async function updateClientCategoryType(options) {
602
- const { clientCategoryTypeId, clientCategoryType } = options;
603
- const body = await sendMasterDataRequest({
604
- ...options,
605
- path: `${CLIENT_CATEGORY_TYPES_PATH}/${clientCategoryTypeId}`,
606
- method: "PUT",
607
- body: clientCategoryType
608
- });
609
- return body;
610
- }
611
- async function fetchBanks(options) {
612
- const { select, filter, top, skip } = options;
613
- const body = await sendMasterDataRequest({
614
- ...options,
615
- path: BANKS_PATH,
616
- method: "GET",
617
- query: {
618
- select,
619
- filter,
620
- top,
621
- skip
622
- }
623
- });
624
- if (body === undefined) {
625
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected banks payload.`);
626
- }
627
- return body;
628
- }
629
- async function fetchAreaOfResponsibilities(options) {
630
- const { select, filter, top, skip } = options;
631
- const body = await sendMasterDataRequest({
632
- ...options,
633
- path: AREA_OF_RESPONSIBILITIES_PATH,
634
- method: "GET",
635
- query: {
636
- select,
637
- filter,
638
- top,
639
- skip
640
- }
641
- });
642
- if (body === undefined) {
643
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected area of responsibilities payload.`);
644
- }
645
- return body;
646
- }
647
- async function fetchAddressees(options) {
648
- const { select, filter, top, skip } = options;
649
- const body = await sendMasterDataRequest({
650
- ...options,
651
- path: ADDRESSEES_PATH,
652
- method: "GET",
653
- query: {
654
- select,
655
- filter,
656
- top,
657
- skip
658
- }
659
- });
660
- if (body === undefined) {
661
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected addressees payload.`);
662
- }
663
- return body;
664
- }
665
- async function fetchAddressee(options) {
666
- const { addresseeId, select, expand } = options;
667
- const body = await sendMasterDataRequest({
668
- ...options,
669
- path: `${ADDRESSEES_PATH}/${addresseeId}`,
670
- method: "GET",
671
- query: {
672
- select,
673
- expand
674
- }
675
- });
676
- if (body === undefined) {
677
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected addressee payload.`);
678
- }
679
- return body;
680
- }
681
- async function createAddressee(options) {
682
- const { addressee, nationalRight } = options;
683
- const body = await sendMasterDataRequest({
684
- ...options,
685
- path: ADDRESSEES_PATH,
686
- method: "POST",
687
- query: {
688
- "national-right": nationalRight
689
- },
690
- body: addressee
691
- });
692
- return body;
693
- }
694
- async function updateAddressee(options) {
695
- const { addresseeId, addressee } = options;
696
- const body = await sendMasterDataRequest({
697
- ...options,
698
- path: `${ADDRESSEES_PATH}/${addresseeId}`,
699
- method: "PUT",
700
- body: addressee
701
- });
702
- return body;
703
- }
704
- async function fetchAddresseesDeletionLog(options) {
705
- const { select, filter, top, skip } = options;
706
- const body = await sendMasterDataRequest({
707
- ...options,
708
- path: ADDRESSEES_DELETION_LOG_PATH,
709
- method: "GET",
710
- query: {
711
- select,
712
- filter,
713
- top,
714
- skip
715
- }
716
- });
717
- if (body === undefined) {
718
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected addressees deletion log payload.`);
719
- }
720
- return body;
721
- }
722
- var ACCOUNTING_BASE_PATH = "datevconnect/accounting/v1";
723
- async function sendAccountingRequest(options) {
724
- const { host, token, clientInstanceId, path, method, query, body, fetchImpl = fetch } = options;
725
- const url = buildApiUrl(host, path);
726
- if (query) {
727
- for (const [key, value] of Object.entries(query)) {
728
- if (value === undefined || value === null) {
729
- continue;
730
- }
731
- url.searchParams.set(key, String(value));
732
- }
733
- }
734
- const response = await fetchImpl(url, {
735
- method,
736
- headers: buildHeaders({
737
- accept: JSON_CONTENT_TYPE,
738
- authorization: `Bearer ${token}`,
739
- "content-type": JSON_CONTENT_TYPE,
740
- "x-client-instance-id": clientInstanceId
741
- }),
742
- body: body === undefined ? undefined : JSON.stringify(body)
743
- });
744
- return ensureSuccess(response);
745
- }
746
- async function fetchAccountingClients(options) {
747
- const { select, filter, top, skip, expand } = options;
748
- const body = await sendAccountingRequest({
749
- ...options,
750
- path: `${ACCOUNTING_BASE_PATH}/clients`,
751
- method: "GET",
752
- query: {
753
- select,
754
- filter,
755
- top,
756
- skip,
757
- expand
758
- }
759
- });
760
- if (body === undefined) {
761
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting clients payload.`);
762
- }
763
- return body;
764
- }
765
- async function fetchAccountingClient(options) {
766
- const { clientId, select, expand } = options;
767
- const body = await sendAccountingRequest({
768
- ...options,
769
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}`,
770
- method: "GET",
771
- query: {
772
- select,
773
- expand
774
- }
775
- });
776
- if (body === undefined) {
777
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting client payload.`);
778
- }
779
- return body;
780
- }
781
- async function fetchFiscalYears(options) {
782
- const { clientId, select, filter, top, skip } = options;
783
- const body = await sendAccountingRequest({
784
- ...options,
785
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years`,
786
- method: "GET",
787
- query: {
788
- select,
789
- filter,
790
- top,
791
- skip
792
- }
793
- });
794
- if (body === undefined) {
795
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected fiscal years payload.`);
796
- }
797
- return body;
798
- }
799
- async function fetchFiscalYear(options) {
800
- const { clientId, fiscalYearId, select } = options;
801
- const body = await sendAccountingRequest({
802
- ...options,
803
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}`,
804
- method: "GET",
805
- query: {
806
- select
807
- }
808
- });
809
- if (body === undefined) {
810
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected fiscal year payload.`);
811
- }
812
- return body;
813
- }
814
- async function fetchAccountsReceivable(options) {
815
- const { clientId, fiscalYearId, select, filter, top, skip, expand } = options;
816
- const body = await sendAccountingRequest({
817
- ...options,
818
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-receivable`,
819
- method: "GET",
820
- query: {
821
- select,
822
- filter,
823
- top,
824
- skip,
825
- expand
826
- }
827
- });
828
- if (body === undefined) {
829
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounts receivable payload.`);
830
- }
831
- return body;
832
- }
833
- async function fetchAccountsReceivableCondensed(options) {
834
- const { clientId, fiscalYearId, select, filter, top, skip } = options;
835
- const body = await sendAccountingRequest({
836
- ...options,
837
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-receivable/condensed`,
838
- method: "GET",
839
- query: {
840
- select,
841
- filter,
842
- top,
843
- skip
844
- }
845
- });
846
- if (body === undefined) {
847
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected condensed accounts receivable payload.`);
848
- }
849
- return body;
850
- }
851
- async function fetchAccountReceivable(options) {
852
- const { clientId, fiscalYearId, accountsReceivableId, select, expand } = options;
853
- const body = await sendAccountingRequest({
854
- ...options,
855
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-receivable/${encodeURIComponent(accountsReceivableId)}`,
856
- method: "GET",
857
- query: {
858
- select,
859
- expand
860
- }
861
- });
862
- if (body === undefined) {
863
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected account receivable payload.`);
864
- }
865
- return body;
866
- }
867
- async function fetchAccountsPayable(options) {
868
- const { clientId, fiscalYearId, select, filter, top, skip, expand } = options;
869
- const body = await sendAccountingRequest({
870
- ...options,
871
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-payable`,
872
- method: "GET",
873
- query: {
874
- select,
875
- filter,
876
- top,
877
- skip,
878
- expand
879
- }
880
- });
881
- if (body === undefined) {
882
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounts payable payload.`);
883
- }
884
- return body;
885
- }
886
- async function fetchAccountsPayableCondensed(options) {
887
- const { clientId, fiscalYearId, select, filter, top, skip } = options;
888
- const body = await sendAccountingRequest({
889
- ...options,
890
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-payable/condense`,
891
- method: "GET",
892
- query: {
893
- select,
894
- filter,
895
- top,
896
- skip
897
- }
898
- });
899
- if (body === undefined) {
900
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected condensed accounts payable payload.`);
901
- }
902
- return body;
903
- }
904
- async function fetchAccountPayable(options) {
905
- const { clientId, fiscalYearId, accountsPayableId, select, expand } = options;
906
- const body = await sendAccountingRequest({
907
- ...options,
908
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounts-payable/${encodeURIComponent(accountsPayableId)}`,
909
- method: "GET",
910
- query: {
911
- select,
912
- expand
913
- }
914
- });
915
- if (body === undefined) {
916
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected account payable payload.`);
917
- }
918
- return body;
919
- }
920
- async function fetchAccountPostings(options) {
921
- const { clientId, fiscalYearId, select, filter, top, skip } = options;
922
- const body = await sendAccountingRequest({
923
- ...options,
924
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/account-postings`,
925
- method: "GET",
926
- query: {
927
- select,
928
- filter,
929
- top,
930
- skip
931
- }
932
- });
933
- if (body === undefined) {
934
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected account postings payload.`);
935
- }
936
- return body;
937
- }
938
- async function fetchAccountPosting(options) {
939
- const { clientId, fiscalYearId, accountPostingId, select } = options;
940
- const body = await sendAccountingRequest({
941
- ...options,
942
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/account-postings/${encodeURIComponent(accountPostingId)}`,
943
- method: "GET",
944
- query: {
945
- select
946
- }
947
- });
948
- if (body === undefined) {
949
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected account posting payload.`);
950
- }
951
- return body;
952
- }
953
- async function fetchAccountingSequences(options) {
954
- const { clientId, fiscalYearId, select, top, skip } = options;
955
- const body = await sendAccountingRequest({
956
- ...options,
957
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sequences-processed`,
958
- method: "GET",
959
- query: {
960
- select,
961
- top,
962
- skip
963
- }
964
- });
965
- if (body === undefined) {
966
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting sequences payload.`);
967
- }
968
- return body;
969
- }
970
- async function fetchAccountingSequence(options) {
971
- const { clientId, fiscalYearId, accountingSequenceId, select } = options;
972
- const body = await sendAccountingRequest({
973
- ...options,
974
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sequences-processed/${encodeURIComponent(accountingSequenceId)}`,
975
- method: "GET",
976
- query: {
977
- select
978
- }
979
- });
980
- if (body === undefined) {
981
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting sequence payload.`);
982
- }
983
- return body;
984
- }
985
- async function createAccountingSequence(options) {
986
- const { clientId, fiscalYearId, accountingSequence } = options;
987
- return sendAccountingRequest({
988
- ...options,
989
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sequences`,
990
- method: "POST",
991
- body: accountingSequence
992
- });
993
- }
994
- async function fetchAccountingRecords(options) {
995
- const { clientId, fiscalYearId, accountingSequenceId, select, filter, top, skip } = options;
996
- const body = await sendAccountingRequest({
997
- ...options,
998
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sequences-processed/${encodeURIComponent(accountingSequenceId)}/accounting-records`,
999
- method: "GET",
1000
- query: {
1001
- select,
1002
- filter,
1003
- top,
1004
- skip
1005
- }
1006
- });
1007
- if (body === undefined) {
1008
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting records payload.`);
1009
- }
1010
- return body;
1011
- }
1012
- async function fetchAccountingRecord(options) {
1013
- const { clientId, fiscalYearId, accountingSequenceId, accountingRecordId, select } = options;
1014
- const body = await sendAccountingRequest({
1015
- ...options,
1016
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sequences-processed/${encodeURIComponent(accountingSequenceId)}/accounting-records/${encodeURIComponent(accountingRecordId)}`,
1017
- method: "GET",
1018
- query: {
1019
- select
1020
- }
1021
- });
1022
- if (body === undefined) {
1023
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting record payload.`);
1024
- }
1025
- return body;
1026
- }
1027
- async function fetchPostingProposalRulesIncoming(options) {
1028
- const { clientId, fiscalYearId, select, top, skip } = options;
1029
- const body = await sendAccountingRequest({
1030
- ...options,
1031
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-incoming-invoices`,
1032
- method: "GET",
1033
- query: {
1034
- select,
1035
- top,
1036
- skip
1037
- }
1038
- });
1039
- if (body === undefined) {
1040
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rules incoming payload.`);
1041
- }
1042
- return body;
1043
- }
1044
- async function fetchPostingProposalRulesOutgoing(options) {
1045
- const { clientId, fiscalYearId, select, top, skip } = options;
1046
- const body = await sendAccountingRequest({
1047
- ...options,
1048
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-outgoing-invoices`,
1049
- method: "GET",
1050
- query: {
1051
- select,
1052
- top,
1053
- skip
1054
- }
1055
- });
1056
- if (body === undefined) {
1057
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rules outgoing payload.`);
1058
- }
1059
- return body;
1060
- }
1061
- async function fetchPostingProposalRulesCashRegister(options) {
1062
- const { clientId, fiscalYearId, select, top, skip } = options;
1063
- const body = await sendAccountingRequest({
1064
- ...options,
1065
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-cash-register`,
1066
- method: "GET",
1067
- query: {
1068
- select,
1069
- top,
1070
- skip
1071
- }
1072
- });
1073
- if (body === undefined) {
1074
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rules cash register payload.`);
1075
- }
1076
- return body;
1077
- }
1078
- async function fetchPostingProposalRuleIncoming(options) {
1079
- const { clientId, fiscalYearId, ruleId, select } = options;
1080
- const body = await sendAccountingRequest({
1081
- ...options,
1082
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-incoming-invoices/${encodeURIComponent(ruleId)}`,
1083
- method: "GET",
1084
- query: {
1085
- select
1086
- }
1087
- });
1088
- if (body === undefined) {
1089
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rule incoming payload.`);
1090
- }
1091
- return body;
1092
- }
1093
- async function fetchPostingProposalRuleOutgoing(options) {
1094
- const { clientId, fiscalYearId, ruleId, select } = options;
1095
- const body = await sendAccountingRequest({
1096
- ...options,
1097
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-outgoing-invoices/${encodeURIComponent(ruleId)}`,
1098
- method: "GET",
1099
- query: {
1100
- select
1101
- }
1102
- });
1103
- if (body === undefined) {
1104
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rule outgoing payload.`);
1105
- }
1106
- return body;
1107
- }
1108
- async function fetchPostingProposalRuleCashRegister(options) {
1109
- const { clientId, fiscalYearId, ruleId, select } = options;
1110
- const body = await sendAccountingRequest({
1111
- ...options,
1112
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposal-rules-cash-register/${encodeURIComponent(ruleId)}`,
1113
- method: "GET",
1114
- query: {
1115
- select
1116
- }
1117
- });
1118
- if (body === undefined) {
1119
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected posting proposal rule cash register payload.`);
1120
- }
1121
- return body;
1122
- }
1123
- async function batchPostingProposalsIncoming(options) {
1124
- const { clientId, fiscalYearId, postingProposals } = options;
1125
- return sendAccountingRequest({
1126
- ...options,
1127
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposals-incoming-invoices/batch`,
1128
- method: "POST",
1129
- body: postingProposals
1130
- });
1131
- }
1132
- async function batchPostingProposalsOutgoing(options) {
1133
- const { clientId, fiscalYearId, postingProposals } = options;
1134
- return sendAccountingRequest({
1135
- ...options,
1136
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposals-outgoing-invoices/batch`,
1137
- method: "POST",
1138
- body: postingProposals
1139
- });
1140
- }
1141
- async function batchPostingProposalsCashRegister(options) {
1142
- const { clientId, fiscalYearId, postingProposals } = options;
1143
- return sendAccountingRequest({
1144
- ...options,
1145
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/posting-proposals-cash-register/batch`,
1146
- method: "POST",
1147
- body: postingProposals
1148
- });
1149
- }
1150
- async function fetchAccountingSumsAndBalances(options) {
1151
- const { clientId, fiscalYearId, select, filter, top, skip } = options;
1152
- const body = await sendAccountingRequest({
1153
- ...options,
1154
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sums-and-balances`,
1155
- method: "GET",
1156
- query: {
1157
- select,
1158
- filter,
1159
- top,
1160
- skip
1161
- }
1162
- });
1163
- if (body === undefined) {
1164
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting sums and balances payload.`);
1165
- }
1166
- return body;
1167
- }
1168
- async function fetchAccountingSumsAndBalance(options) {
1169
- const { clientId, fiscalYearId, accountingSumsAndBalancesId } = options;
1170
- const body = await sendAccountingRequest({
1171
- ...options,
1172
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-sums-and-balances/${encodeURIComponent(accountingSumsAndBalancesId)}`,
1173
- method: "GET"
1174
- });
1175
- if (body === undefined) {
1176
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting sums and balance payload.`);
1177
- }
1178
- return body;
1179
- }
1180
- async function fetchDebitors(options) {
1181
- const { clientId, fiscalYearId, select, filter, top, skip, expand } = options;
1182
- const body = await sendAccountingRequest({
1183
- ...options,
1184
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/debitors`,
1185
- method: "GET",
1186
- query: {
1187
- select,
1188
- filter,
1189
- top,
1190
- skip,
1191
- expand
1192
- }
1193
- });
1194
- if (body === undefined) {
1195
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected debitors payload.`);
1196
- }
1197
- return body;
1198
- }
1199
- async function fetchDebitor(options) {
1200
- const { clientId, fiscalYearId, debitorId, select, expand } = options;
1201
- const body = await sendAccountingRequest({
1202
- ...options,
1203
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/debitors/${encodeURIComponent(debitorId)}`,
1204
- method: "GET",
1205
- query: {
1206
- select,
1207
- expand
1208
- }
1209
- });
1210
- if (body === undefined) {
1211
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected debitor payload.`);
1212
- }
1213
- return body;
1214
- }
1215
- async function createDebitor(options) {
1216
- const { clientId, fiscalYearId, debitor } = options;
1217
- return sendAccountingRequest({
1218
- ...options,
1219
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/debitors`,
1220
- method: "POST",
1221
- body: debitor
1222
- });
1223
- }
1224
- async function updateDebitor(options) {
1225
- const { clientId, fiscalYearId, debitorId, debitor } = options;
1226
- return sendAccountingRequest({
1227
- ...options,
1228
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/debitors/${encodeURIComponent(debitorId)}`,
1229
- method: "PUT",
1230
- body: debitor
1231
- });
1232
- }
1233
- async function fetchNextAvailableDebitor(options) {
1234
- const { clientId, fiscalYearId, startAt } = options;
1235
- const body = await sendAccountingRequest({
1236
- ...options,
1237
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/debitors/next-available`,
1238
- method: "GET",
1239
- query: {
1240
- "start-at": startAt
1241
- }
1242
- });
1243
- if (body === undefined) {
1244
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected next available debitor payload.`);
1245
- }
1246
- return body;
1247
- }
1248
- async function fetchCreditors(options) {
1249
- const { clientId, fiscalYearId, select, filter, top, skip, expand } = options;
1250
- const body = await sendAccountingRequest({
1251
- ...options,
1252
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/creditors`,
1253
- method: "GET",
1254
- query: {
1255
- select,
1256
- filter,
1257
- top,
1258
- skip,
1259
- expand
1260
- }
1261
- });
1262
- if (body === undefined) {
1263
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected creditors payload.`);
1264
- }
1265
- return body;
1266
- }
1267
- async function fetchCreditor(options) {
1268
- const { clientId, fiscalYearId, creditorId, select, expand } = options;
1269
- const body = await sendAccountingRequest({
1270
- ...options,
1271
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/creditors/${encodeURIComponent(creditorId)}`,
1272
- method: "GET",
1273
- query: {
1274
- select,
1275
- expand
1276
- }
1277
- });
1278
- if (body === undefined) {
1279
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected creditor payload.`);
1280
- }
1281
- return body;
1282
- }
1283
- async function createCreditor(options) {
1284
- const { clientId, fiscalYearId, creditor } = options;
1285
- return sendAccountingRequest({
1286
- ...options,
1287
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/creditors`,
1288
- method: "POST",
1289
- body: creditor
1290
- });
1291
- }
1292
- async function updateCreditor(options) {
1293
- const { clientId, fiscalYearId, creditorId, creditor } = options;
1294
- return sendAccountingRequest({
1295
- ...options,
1296
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/creditors/${encodeURIComponent(creditorId)}`,
1297
- method: "PUT",
1298
- body: creditor
1299
- });
1300
- }
1301
- async function fetchNextAvailableCreditor(options) {
1302
- const { clientId, fiscalYearId, startAt } = options;
1303
- const body = await sendAccountingRequest({
1304
- ...options,
1305
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/creditors/next-available`,
1306
- method: "GET",
1307
- query: {
1308
- "start-at": startAt
1309
- }
1310
- });
1311
- if (body === undefined) {
1312
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected next available creditor payload.`);
1313
- }
1314
- return body;
1315
- }
1316
- async function fetchGeneralLedgerAccounts(options) {
1317
- const { clientId, fiscalYearId, select, filter, top, skip } = options;
1318
- const body = await sendAccountingRequest({
1319
- ...options,
1320
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/general-ledger-accounts`,
1321
- method: "GET",
1322
- query: {
1323
- select,
1324
- filter,
1325
- top,
1326
- skip
1327
- }
1328
- });
1329
- if (body === undefined) {
1330
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected general ledger accounts payload.`);
1331
- }
1332
- return body;
1333
- }
1334
- async function fetchGeneralLedgerAccount(options) {
1335
- const { clientId, fiscalYearId, generalLedgerAccountId, select } = options;
1336
- const body = await sendAccountingRequest({
1337
- ...options,
1338
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/general-ledger-accounts/${encodeURIComponent(generalLedgerAccountId)}`,
1339
- method: "GET",
1340
- query: {
1341
- select
1342
- }
1343
- });
1344
- if (body === undefined) {
1345
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected general ledger account payload.`);
1346
- }
1347
- return body;
1348
- }
1349
- async function fetchUtilizedGeneralLedgerAccounts(options) {
1350
- const { clientId, fiscalYearId, select, top, skip } = options;
1351
- const body = await sendAccountingRequest({
1352
- ...options,
1353
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/general-ledger-accounts/utilized`,
1354
- method: "GET",
1355
- query: {
1356
- select,
1357
- top,
1358
- skip
1359
- }
1360
- });
1361
- if (body === undefined) {
1362
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected utilized general ledger accounts payload.`);
1363
- }
1364
- return body;
1365
- }
1366
- async function fetchTermsOfPayment(options) {
1367
- const { clientId, fiscalYearId, select, filter, skip, top } = options;
1368
- const body = await sendAccountingRequest({
1369
- ...options,
1370
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/terms-of-payment`,
1371
- method: "GET",
1372
- query: {
1373
- select,
1374
- filter,
1375
- skip,
1376
- top
1377
- }
1378
- });
1379
- if (body === undefined) {
1380
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected terms of payment payload.`);
1381
- }
1382
- return body;
1383
- }
1384
- async function fetchTermOfPayment(options) {
1385
- const { clientId, fiscalYearId, termOfPaymentId, select } = options;
1386
- const body = await sendAccountingRequest({
1387
- ...options,
1388
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/terms-of-payment/${encodeURIComponent(termOfPaymentId)}`,
1389
- method: "GET",
1390
- query: {
1391
- select
1392
- }
1393
- });
1394
- if (body === undefined) {
1395
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected term of payment payload.`);
1396
- }
1397
- return body;
1398
- }
1399
- async function createTermOfPayment(options) {
1400
- const { clientId, fiscalYearId, termOfPaymentData } = options;
1401
- return sendAccountingRequest({
1402
- ...options,
1403
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/terms-of-payment`,
1404
- method: "POST",
1405
- body: termOfPaymentData
1406
- });
1407
- }
1408
- async function updateTermOfPayment(options) {
1409
- const { clientId, fiscalYearId, termOfPaymentId, termOfPaymentData } = options;
1410
- return sendAccountingRequest({
1411
- ...options,
1412
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/terms-of-payment/${encodeURIComponent(termOfPaymentId)}`,
1413
- method: "PUT",
1414
- body: termOfPaymentData
1415
- });
1416
- }
1417
- async function fetchStocktakingData(options) {
1418
- const { clientId, fiscalYearId, filter, select, skip, top } = options;
1419
- const body = await sendAccountingRequest({
1420
- ...options,
1421
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/assets/stocktakings`,
1422
- method: "GET",
1423
- query: {
1424
- filter,
1425
- select,
1426
- skip,
1427
- top
1428
- }
1429
- });
1430
- if (body === undefined) {
1431
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected stocktaking data payload.`);
1432
- }
1433
- return body;
1434
- }
1435
- async function fetchStocktakingDataByAsset(options) {
1436
- const { clientId, fiscalYearId, assetId, select, skip, top } = options;
1437
- const body = await sendAccountingRequest({
1438
- ...options,
1439
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/assets/${encodeURIComponent(assetId)}/stocktaking/`,
1440
- method: "GET",
1441
- query: {
1442
- select,
1443
- skip,
1444
- top
1445
- }
1446
- });
1447
- if (body === undefined) {
1448
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected stocktaking data by asset payload.`);
1449
- }
1450
- return body;
1451
- }
1452
- async function updateStocktakingData(options) {
1453
- const { clientId, fiscalYearId, assetId, stocktakingData } = options;
1454
- return sendAccountingRequest({
1455
- ...options,
1456
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/assets/${encodeURIComponent(assetId)}/stocktaking/`,
1457
- method: "PUT",
1458
- body: stocktakingData
1459
- });
1460
- }
1461
- async function fetchCostSystems(options) {
1462
- const { clientId, fiscalYearId, select, skip, top } = options;
1463
- const body = await sendAccountingRequest({
1464
- ...options,
1465
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems`,
1466
- method: "GET",
1467
- query: {
1468
- select,
1469
- skip,
1470
- top
1471
- }
1472
- });
1473
- if (body === undefined) {
1474
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost systems payload.`);
1475
- }
1476
- return body;
1477
- }
1478
- async function fetchCostSystem(options) {
1479
- const { clientId, fiscalYearId, costSystemId, select } = options;
1480
- const body = await sendAccountingRequest({
1481
- ...options,
1482
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}`,
1483
- method: "GET",
1484
- query: {
1485
- select
1486
- }
1487
- });
1488
- if (body === undefined) {
1489
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost system payload.`);
1490
- }
1491
- return body;
1492
- }
1493
- async function fetchCostCenters(options) {
1494
- const { clientId, fiscalYearId, costSystemId, select, top, skip } = options;
1495
- const body = await sendAccountingRequest({
1496
- ...options,
1497
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-centers`,
1498
- method: "GET",
1499
- query: {
1500
- select,
1501
- top,
1502
- skip
1503
- }
1504
- });
1505
- if (body === undefined) {
1506
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost centers payload.`);
1507
- }
1508
- return body;
1509
- }
1510
- async function fetchCostCenter(options) {
1511
- const { clientId, fiscalYearId, costSystemId, costCenterId, select } = options;
1512
- const body = await sendAccountingRequest({
1513
- ...options,
1514
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-centers/${encodeURIComponent(costCenterId)}`,
1515
- method: "GET",
1516
- query: {
1517
- select
1518
- }
1519
- });
1520
- if (body === undefined) {
1521
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost center payload.`);
1522
- }
1523
- return body;
1524
- }
1525
- async function fetchCostCenterProperties(options) {
1526
- const { clientId, fiscalYearId, costSystemId, select, skip, top } = options;
1527
- const body = await sendAccountingRequest({
1528
- ...options,
1529
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-center-properties`,
1530
- method: "GET",
1531
- query: {
1532
- select,
1533
- skip,
1534
- top
1535
- }
1536
- });
1537
- if (body === undefined) {
1538
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost center properties payload.`);
1539
- }
1540
- return body;
1541
- }
1542
- async function fetchCostCenterProperty(options) {
1543
- const { clientId, fiscalYearId, costSystemId, costCenterPropertyId, select } = options;
1544
- const body = await sendAccountingRequest({
1545
- ...options,
1546
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-center-properties/${encodeURIComponent(costCenterPropertyId)}`,
1547
- method: "GET",
1548
- query: {
1549
- select
1550
- }
1551
- });
1552
- if (body === undefined) {
1553
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost center property payload.`);
1554
- }
1555
- return body;
1556
- }
1557
- async function createInternalCostService(options) {
1558
- const { clientId, fiscalYearId, costSystemId, internalCostServiceData } = options;
1559
- return sendAccountingRequest({
1560
- ...options,
1561
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/internal-cost-services`,
1562
- method: "POST",
1563
- body: internalCostServiceData
1564
- });
1565
- }
1566
- async function fetchCostSequences(options) {
1567
- const { clientId, fiscalYearId, costSystemId, select, skip, top } = options;
1568
- const body = await sendAccountingRequest({
1569
- ...options,
1570
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-sequences`,
1571
- method: "GET",
1572
- query: {
1573
- select,
1574
- skip,
1575
- top
1576
- }
1577
- });
1578
- if (body === undefined) {
1579
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost sequences payload.`);
1580
- }
1581
- return body;
1582
- }
1583
- async function fetchCostSequence(options) {
1584
- const { clientId, fiscalYearId, costSystemId, costSequenceId, select } = options;
1585
- const body = await sendAccountingRequest({
1586
- ...options,
1587
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-sequences/${encodeURIComponent(costSequenceId)}`,
1588
- method: "GET",
1589
- query: {
1590
- select
1591
- }
1592
- });
1593
- if (body === undefined) {
1594
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost sequence payload.`);
1595
- }
1596
- return body;
1597
- }
1598
- async function createCostSequence(options) {
1599
- const { clientId, fiscalYearId, costSystemId, costSequenceId, costSequenceData } = options;
1600
- return sendAccountingRequest({
1601
- ...options,
1602
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-sequences/${encodeURIComponent(costSequenceId)}`,
1603
- method: "POST",
1604
- body: costSequenceData
1605
- });
1606
- }
1607
- async function fetchCostAccountingRecords(options) {
1608
- const { clientId, fiscalYearId, costSystemId, costSequenceId, select, skip, top } = options;
1609
- const body = await sendAccountingRequest({
1610
- ...options,
1611
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/cost-systems/${encodeURIComponent(costSystemId)}/cost-sequences/${encodeURIComponent(costSequenceId)}/cost-accounting-records`,
1612
- method: "GET",
1613
- query: {
1614
- select,
1615
- skip,
1616
- top
1617
- }
1618
- });
1619
- if (body === undefined) {
1620
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected cost accounting records payload.`);
1621
- }
1622
- return body;
1623
- }
1624
- async function fetchAccountingStatistics(options) {
1625
- const { clientId, fiscalYearId, select, filter, skip, top } = options;
1626
- const body = await sendAccountingRequest({
1627
- ...options,
1628
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-statistics`,
1629
- method: "GET",
1630
- query: {
1631
- select,
1632
- filter,
1633
- skip,
1634
- top
1635
- }
1636
- });
1637
- if (body === undefined) {
1638
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting statistics payload.`);
1639
- }
1640
- return body;
1641
- }
1642
- async function fetchAccountingTransactionKeys(options) {
1643
- const { clientId, fiscalYearId, select, skip, top } = options;
1644
- const body = await sendAccountingRequest({
1645
- ...options,
1646
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-transaction-keys`,
1647
- method: "GET",
1648
- query: {
1649
- select,
1650
- skip,
1651
- top
1652
- }
1653
- });
1654
- if (body === undefined) {
1655
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting transaction keys payload.`);
1656
- }
1657
- return body;
1658
- }
1659
- async function fetchAccountingTransactionKey(options) {
1660
- const { clientId, fiscalYearId, accountingTransactionKeyId, select, filter, skip, top } = options;
1661
- const body = await sendAccountingRequest({
1662
- ...options,
1663
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/accounting-transaction-keys/${encodeURIComponent(accountingTransactionKeyId)}`,
1664
- method: "GET",
1665
- query: {
1666
- select,
1667
- filter,
1668
- skip,
1669
- top
1670
- }
1671
- });
1672
- if (body === undefined) {
1673
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected accounting transaction key payload.`);
1674
- }
1675
- return body;
1676
- }
1677
- async function fetchVariousAddresses(options) {
1678
- const { clientId, fiscalYearId, select, skip, top, expand } = options;
1679
- const body = await sendAccountingRequest({
1680
- ...options,
1681
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/various-addresses`,
1682
- method: "GET",
1683
- query: {
1684
- select,
1685
- skip,
1686
- top,
1687
- expand
1688
- }
1689
- });
1690
- if (body === undefined) {
1691
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected various addresses payload.`);
1692
- }
1693
- return body;
1694
- }
1695
- async function fetchVariousAddress(options) {
1696
- const { clientId, fiscalYearId, variousAddressId, select, skip, top, expand } = options;
1697
- const body = await sendAccountingRequest({
1698
- ...options,
1699
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/various-addresses/${encodeURIComponent(variousAddressId)}`,
1700
- method: "GET",
1701
- query: {
1702
- select,
1703
- skip,
1704
- top,
1705
- expand
1706
- }
1707
- });
1708
- if (body === undefined) {
1709
- throw new Error(`${DEFAULT_ERROR_PREFIX}: Expected various address payload.`);
1710
- }
1711
- return body;
1712
- }
1713
- async function createVariousAddress(options) {
1714
- const { clientId, fiscalYearId, variousAddressData } = options;
1715
- return sendAccountingRequest({
1716
- ...options,
1717
- path: `${ACCOUNTING_BASE_PATH}/clients/${encodeURIComponent(clientId)}/fiscal-years/${encodeURIComponent(fiscalYearId)}/various-addresses`,
1718
- method: "POST",
1719
- body: variousAddressData
1720
- });
1721
- }
1722
-
1723
- // nodes/IdentityAndAccessManagement/IdentityAndAccessManagement.config.ts
1724
- var identityAndAccessManagementNodeDescription = {
1725
- displayName: "Klardaten DATEVconnect: Identity & Access",
1726
- name: "identityAndAccessManagement",
1727
- icon: "file:../klardaten.svg",
1728
- group: ["transform"],
1729
- version: 1,
1730
- description: "Work with DATEV Identity and Access Management (SCIM) endpoints",
1731
- defaults: {
1732
- name: "Identity & Access Management"
1733
- },
1734
- inputs: ["main"],
1735
- outputs: ["main"],
1736
- credentials: [
1737
- {
1738
- name: "datevConnectApi",
1739
- required: true
1740
- }
1741
- ],
1742
- properties: [
1743
- {
1744
- displayName: "Resource",
1745
- name: "resource",
1746
- type: "options",
1747
- options: [
1748
- {
1749
- name: "Service Provider Config",
1750
- value: "serviceProviderConfig"
1751
- },
1752
- {
1753
- name: "Resource Type",
1754
- value: "resourceType"
1755
- },
1756
- {
1757
- name: "Schema",
1758
- value: "schema"
1759
- },
1760
- {
1761
- name: "User",
1762
- value: "user"
1763
- },
1764
- {
1765
- name: "Current User",
1766
- value: "currentUser"
1767
- },
1768
- {
1769
- name: "Group",
1770
- value: "group"
1771
- }
1772
- ],
1773
- default: "user",
1774
- description: "Which IAM resource to operate on"
1775
- },
1776
- {
1777
- displayName: "Operation",
1778
- name: "operation",
1779
- type: "options",
1780
- displayOptions: {
1781
- show: {
1782
- resource: ["serviceProviderConfig"]
1783
- }
1784
- },
1785
- options: [
1786
- {
1787
- name: "Get",
1788
- value: "get",
1789
- action: "Get service provider config",
1790
- description: "Retrieve the SCIM service provider configuration"
1791
- }
1792
- ],
1793
- default: "get"
1794
- },
1795
- {
1796
- displayName: "Operation",
1797
- name: "operation",
1798
- type: "options",
1799
- displayOptions: {
1800
- show: {
1801
- resource: ["resourceType"]
1802
- }
1803
- },
1804
- options: [
1805
- {
1806
- name: "Get Many",
1807
- value: "getAll",
1808
- action: "Get many resource types",
1809
- description: "Retrieve the available SCIM resource types"
1810
- }
1811
- ],
1812
- default: "getAll"
1813
- },
1814
- {
1815
- displayName: "Operation",
1816
- name: "operation",
1817
- type: "options",
1818
- displayOptions: {
1819
- show: {
1820
- resource: ["schema"]
1821
- }
1822
- },
1823
- options: [
1824
- {
1825
- name: "Get Many",
1826
- value: "getAll",
1827
- action: "Get many schemas",
1828
- description: "List the supported SCIM schemas"
1829
- },
1830
- {
1831
- name: "Get",
1832
- value: "get",
1833
- action: "Get schema",
1834
- description: "Retrieve a single SCIM schema by ID"
1835
- }
1836
- ],
1837
- default: "getAll"
1838
- },
1839
- {
1840
- displayName: "Operation",
1841
- name: "operation",
1842
- type: "options",
1843
- displayOptions: {
1844
- show: {
1845
- resource: ["user"]
1846
- }
1847
- },
1848
- options: [
1849
- {
1850
- name: "Get Many",
1851
- value: "getAll",
1852
- action: "Get many users",
1853
- description: "List DATEV IAM users"
1854
- },
1855
- {
1856
- name: "Get",
1857
- value: "get",
1858
- action: "Get a user",
1859
- description: "Retrieve a single DATEV IAM user"
1860
- },
1861
- {
1862
- name: "Create",
1863
- value: "create",
1864
- action: "Create a user",
1865
- description: "Create a new DATEV IAM user"
1866
- },
1867
- {
1868
- name: "Update",
1869
- value: "update",
1870
- action: "Update a user",
1871
- description: "Update an existing DATEV IAM user"
1872
- },
1873
- {
1874
- name: "Delete",
1875
- value: "delete",
1876
- action: "Delete a user",
1877
- description: "Delete a DATEV IAM user"
1878
- }
1879
- ],
1880
- default: "getAll"
1881
- },
1882
- {
1883
- displayName: "Operation",
1884
- name: "operation",
1885
- type: "options",
1886
- displayOptions: {
1887
- show: {
1888
- resource: ["currentUser"]
1889
- }
1890
- },
1891
- options: [
1892
- {
1893
- name: "Get",
1894
- value: "get",
1895
- action: "Get current user",
1896
- description: "Fetch the currently authenticated DATEV IAM user"
1897
- }
1898
- ],
1899
- default: "get"
1900
- },
1901
- {
1902
- displayName: "Operation",
1903
- name: "operation",
1904
- type: "options",
1905
- displayOptions: {
1906
- show: {
1907
- resource: ["group"]
1908
- }
1909
- },
1910
- options: [
1911
- {
1912
- name: "Get Many",
1913
- value: "getAll",
1914
- action: "Get many groups",
1915
- description: "List DATEV IAM groups"
1916
- },
1917
- {
1918
- name: "Get",
1919
- value: "get",
1920
- action: "Get a group",
1921
- description: "Retrieve a single DATEV IAM group"
1922
- },
1923
- {
1924
- name: "Create",
1925
- value: "create",
1926
- action: "Create a group",
1927
- description: "Create a new DATEV IAM group"
1928
- },
1929
- {
1930
- name: "Update",
1931
- value: "update",
1932
- action: "Update a group",
1933
- description: "Update an existing DATEV IAM group"
1934
- },
1935
- {
1936
- name: "Delete",
1937
- value: "delete",
1938
- action: "Delete a group",
1939
- description: "Delete a DATEV IAM group"
1940
- }
1941
- ],
1942
- default: "getAll"
1943
- },
1944
- {
1945
- displayName: "Schema ID",
1946
- name: "schemaId",
1947
- type: "string",
1948
- required: true,
1949
- default: "",
1950
- description: "Full SCIM schema ID (e.g. urn:ietf:params:scim:schemas:core:2.0:User)",
1951
- displayOptions: {
1952
- show: {
1953
- resource: ["schema"],
1954
- operation: ["get"]
1955
- }
1956
- }
1957
- },
1958
- {
1959
- displayName: "User ID",
1960
- name: "userId",
1961
- type: "string",
1962
- required: true,
1963
- default: "",
1964
- description: "ID of the DATEV IAM user",
1965
- displayOptions: {
1966
- show: {
1967
- resource: ["user"],
1968
- operation: ["get", "update", "delete"]
1969
- }
1970
- }
1971
- },
1972
- {
1973
- displayName: "Filter",
1974
- name: "filter",
1975
- type: "string",
1976
- default: "",
1977
- description: "Optional SCIM filter expression",
1978
- displayOptions: {
1979
- show: {
1980
- resource: ["user"],
1981
- operation: ["getAll"]
1982
- }
1983
- }
1984
- },
1985
- {
1986
- displayName: "Attributes",
1987
- name: "attributes",
1988
- type: "string",
1989
- default: "",
1990
- description: "Optional comma-separated list of SCIM attributes to return",
1991
- displayOptions: {
1992
- show: {
1993
- resource: ["user"],
1994
- operation: ["getAll"]
1995
- }
1996
- }
1997
- },
1998
- {
1999
- displayName: "Start Index",
2000
- name: "startIndex",
2001
- type: "number",
2002
- typeOptions: {
2003
- minValue: 1
2004
- },
2005
- default: 1,
2006
- description: "1-based index of the first result to return",
2007
- displayOptions: {
2008
- show: {
2009
- resource: ["user"],
2010
- operation: ["getAll"]
2011
- }
2012
- }
2013
- },
2014
- {
2015
- displayName: "Count",
2016
- name: "count",
2017
- type: "number",
2018
- typeOptions: {
2019
- minValue: 1
2020
- },
2021
- default: 100,
2022
- description: "Maximum number of results to return",
2023
- displayOptions: {
2024
- show: {
2025
- resource: ["user"],
2026
- operation: ["getAll"]
2027
- }
2028
- }
2029
- },
2030
- {
2031
- displayName: "User Data",
2032
- name: "userData",
2033
- type: "json",
2034
- required: true,
2035
- default: "{}",
2036
- description: "Full SCIM user payload",
2037
- displayOptions: {
2038
- show: {
2039
- resource: ["user"],
2040
- operation: ["create", "update"]
2041
- }
2042
- }
2043
- },
2044
- {
2045
- displayName: "Group ID",
2046
- name: "groupId",
2047
- type: "string",
2048
- required: true,
2049
- default: "",
2050
- description: "ID of the DATEV IAM group",
2051
- displayOptions: {
2052
- show: {
2053
- resource: ["group"],
2054
- operation: ["get", "update", "delete"]
2055
- }
2056
- }
2057
- },
2058
- {
2059
- displayName: "Group Data",
2060
- name: "groupData",
2061
- type: "json",
2062
- required: true,
2063
- default: "{}",
2064
- description: "Full SCIM group payload",
2065
- displayOptions: {
2066
- show: {
2067
- resource: ["group"],
2068
- operation: ["create", "update"]
2069
- }
2070
- }
2071
- }
2072
- ]
2073
- };
2074
-
2075
- // nodes/IdentityAndAccessManagement/handlers/ServiceProviderConfigResourceHandler.ts
2076
- var import_n8n_workflow2 = require("n8n-workflow");
2077
-
2078
- // src/services/identityAndAccessManagementClient.ts
2079
- var JSON_CONTENT_TYPE2 = "application/json;charset=utf-8";
2080
- var DEFAULT_ERROR_PREFIX2 = "DATEV IAM request failed";
2081
- var IAM_BASE_PATH = "datevconnect/iam/v1";
2082
- var SERVICE_PROVIDER_CONFIG_PATH = `${IAM_BASE_PATH}/ServiceProviderConfig`;
2083
- var RESOURCE_TYPES_PATH = `${IAM_BASE_PATH}/ResourceTypes`;
2084
- var SCHEMAS_PATH = `${IAM_BASE_PATH}/Schemas`;
2085
- var USERS_PATH = `${IAM_BASE_PATH}/Users`;
2086
- var CURRENT_USER_PATH = `${USERS_PATH}/me`;
2087
- var GROUPS_PATH = `${IAM_BASE_PATH}/Groups`;
2088
- function normaliseBaseUrl2(host) {
2089
- if (!host) {
2090
- throw new Error("DATEVconnect host must be provided");
2091
- }
2092
- return host.endsWith("/") ? host : `${host}/`;
2093
- }
2094
- function buildUrl(host, path, query) {
2095
- const baseUrl = normaliseBaseUrl2(host);
2096
- const trimmedPath = path.startsWith("/") ? path.slice(1) : path;
2097
- const url = new URL(trimmedPath, baseUrl);
2098
- if (query) {
2099
- for (const [key, value] of Object.entries(query)) {
2100
- if (value === undefined || value === null || value === "") {
2101
- continue;
2102
- }
2103
- url.searchParams.set(key, String(value));
2104
- }
2105
- }
2106
- return url;
2107
- }
2108
- async function readResponseBody2(response) {
2109
- if (response.status === 204 || response.status === 205) {
2110
- return;
2111
- }
2112
- const contentType = response.headers.get("content-type") ?? "";
2113
- if (contentType.toLowerCase().includes("application/json")) {
2114
- try {
2115
- return await response.json();
2116
- } catch {
2117
- return;
2118
- }
2119
- }
2120
- try {
2121
- const text = await response.text();
2122
- return text.length > 0 ? text : undefined;
2123
- } catch {
2124
- return;
2125
- }
2126
- }
2127
- function buildErrorMessage(response, body) {
2128
- const statusPart = `${response.status}${response.statusText ? ` ${response.statusText}` : ""}`.trim();
2129
- const prefix = `${DEFAULT_ERROR_PREFIX2}${statusPart ? ` (${statusPart})` : ""}`;
2130
- if (body && typeof body === "object") {
2131
- const message = ("message" in body && typeof body.message === "string" ? body.message : undefined) || ("detail" in body && typeof body.detail === "string" ? body.detail : undefined) || ("error" in body && typeof body.error === "string" ? body.error : undefined);
2132
- if (message) {
2133
- return `${prefix}: ${message}`;
2134
- }
2135
- }
2136
- if (typeof body === "string") {
2137
- return `${prefix}: ${body}`;
2138
- }
2139
- return prefix;
2140
- }
2141
- async function sendRequest(options) {
2142
- const { host, token, clientInstanceId, path, method, query, body, fetchImpl = fetch } = options;
2143
- const url = buildUrl(host, path, query);
2144
- const headers = {
2145
- Authorization: `Bearer ${token}`,
2146
- "x-client-instance-id": clientInstanceId,
2147
- Accept: JSON_CONTENT_TYPE2
2148
- };
2149
- const requestInit = {
2150
- method,
2151
- headers
2152
- };
2153
- if (body !== undefined) {
2154
- headers["content-type"] = JSON_CONTENT_TYPE2;
2155
- requestInit.body = JSON.stringify(body);
2156
- }
2157
- const response = await fetchImpl(url, requestInit);
2158
- const responseBody = await readResponseBody2(response);
2159
- if (!response.ok) {
2160
- throw new Error(buildErrorMessage(response, responseBody));
2161
- }
2162
- return { data: responseBody, response };
2163
- }
2164
- function extractLocationHeader(response) {
2165
- return response.headers.get("Location") ?? response.headers.get("Link") ?? undefined;
2166
- }
2167
-
2168
- class IdentityAndAccessManagementClient {
2169
- static async fetchServiceProviderConfig(options) {
2170
- const result = await sendRequest({
2171
- ...options,
2172
- path: SERVICE_PROVIDER_CONFIG_PATH,
2173
- method: "GET"
2174
- });
2175
- if (result.data === undefined) {
2176
- throw new Error(`${DEFAULT_ERROR_PREFIX2}: Expected service provider configuration.`);
2177
- }
2178
- return result.data;
2179
- }
2180
- static async fetchResourceTypes(options) {
2181
- const result = await sendRequest({
2182
- ...options,
2183
- path: RESOURCE_TYPES_PATH,
2184
- method: "GET"
2185
- });
2186
- if (result.data === undefined) {
2187
- throw new Error(`${DEFAULT_ERROR_PREFIX2}: Expected resource types response.`);
2188
- }
2189
- return result.data;
2190
- }
2191
- static async fetchSchemas(options) {
2192
- const result = await sendRequest({
2193
- ...options,
2194
- path: SCHEMAS_PATH,
2195
- method: "GET"
2196
- });
2197
- if (result.data === undefined) {
2198
- throw new Error(`${DEFAULT_ERROR_PREFIX2}: Expected schema list response.`);
2199
- }
2200
- return result.data;
2201
- }
2202
- static async fetchSchema(options) {
2203
- const result = await sendRequest({
2204
- ...options,
2205
- path: `${SCHEMAS_PATH}/${encodeURIComponent(options.schemaId)}`,
2206
- method: "GET"
2207
- });
2208
- if (result.data === undefined) {
2209
- throw new Error(`${DEFAULT_ERROR_PREFIX2}: Expected schema response.`);
2210
- }
2211
- return result.data;
2212
- }
2213
- static async fetchUsers(options) {
2214
- const result = await sendRequest({
2215
- ...options,
2216
- path: USERS_PATH,
2217
- method: "GET",
2218
- query: {
2219
- filter: options.filter,
2220
- startIndex: options.startIndex,
2221
- count: options.count,
2222
- attributes: options.attributes
2223
- }
2224
- });
2225
- if (result.data === undefined) {
2226
- throw new Error(`${DEFAULT_ERROR_PREFIX2}: Expected users response.`);
2227
- }
2228
- return result.data;
2229
- }
2230
- static async fetchUser(options) {
2231
- const result = await sendRequest({
2232
- ...options,
2233
- path: `${USERS_PATH}/${encodeURIComponent(options.userId)}`,
2234
- method: "GET"
2235
- });
2236
- if (result.data === undefined) {
2237
- throw new Error(`${DEFAULT_ERROR_PREFIX2}: Expected user response.`);
2238
- }
2239
- return result.data;
2240
- }
2241
- static async createUser(options) {
2242
- const result = await sendRequest({
2243
- ...options,
2244
- path: USERS_PATH,
2245
- method: "POST",
2246
- body: options.user
2247
- });
2248
- if (result.data !== undefined) {
2249
- return result.data;
2250
- }
2251
- const location = extractLocationHeader(result.response);
2252
- return {
2253
- success: true,
2254
- location
2255
- };
2256
- }
2257
- static async updateUser(options) {
2258
- const result = await sendRequest({
2259
- ...options,
2260
- path: `${USERS_PATH}/${encodeURIComponent(options.userId)}`,
2261
- method: "PUT",
2262
- body: options.user
2263
- });
2264
- if (result.data !== undefined) {
2265
- return result.data;
2266
- }
2267
- const location = extractLocationHeader(result.response);
2268
- return {
2269
- success: true,
2270
- userId: options.userId,
2271
- location
2272
- };
2273
- }
2274
- static async deleteUser(options) {
2275
- const result = await sendRequest({
2276
- ...options,
2277
- path: `${USERS_PATH}/${encodeURIComponent(options.userId)}`,
2278
- method: "DELETE"
2279
- });
2280
- return {
2281
- location: extractLocationHeader(result.response) ?? undefined
2282
- };
2283
- }
2284
- static async fetchCurrentUser(options) {
2285
- const result = await sendRequest({
2286
- ...options,
2287
- path: CURRENT_USER_PATH,
2288
- method: "GET"
2289
- });
2290
- if (result.data === undefined) {
2291
- throw new Error(`${DEFAULT_ERROR_PREFIX2}: Expected current user response.`);
2292
- }
2293
- return result.data;
2294
- }
2295
- static async fetchGroups(options) {
2296
- const result = await sendRequest({
2297
- ...options,
2298
- path: GROUPS_PATH,
2299
- method: "GET"
2300
- });
2301
- if (result.data === undefined) {
2302
- throw new Error(`${DEFAULT_ERROR_PREFIX2}: Expected groups response.`);
2303
- }
2304
- return result.data;
2305
- }
2306
- static async fetchGroup(options) {
2307
- const result = await sendRequest({
2308
- ...options,
2309
- path: `${GROUPS_PATH}/${encodeURIComponent(options.groupId)}`,
2310
- method: "GET"
2311
- });
2312
- if (result.data === undefined) {
2313
- throw new Error(`${DEFAULT_ERROR_PREFIX2}: Expected group response.`);
2314
- }
2315
- return result.data;
2316
- }
2317
- static async createGroup(options) {
2318
- const result = await sendRequest({
2319
- ...options,
2320
- path: GROUPS_PATH,
2321
- method: "POST",
2322
- body: options.group
2323
- });
2324
- if (result.data !== undefined) {
2325
- return result.data;
2326
- }
2327
- const location = extractLocationHeader(result.response);
2328
- return {
2329
- success: true,
2330
- location
2331
- };
2332
- }
2333
- static async updateGroup(options) {
2334
- const result = await sendRequest({
2335
- ...options,
2336
- path: `${GROUPS_PATH}/${encodeURIComponent(options.groupId)}`,
2337
- method: "PUT",
2338
- body: options.group
2339
- });
2340
- if (result.data !== undefined) {
2341
- return result.data;
2342
- }
2343
- const location = extractLocationHeader(result.response);
2344
- return {
2345
- success: true,
2346
- groupId: options.groupId,
2347
- location
2348
- };
2349
- }
2350
- static async deleteGroup(options) {
2351
- const result = await sendRequest({
2352
- ...options,
2353
- path: `${GROUPS_PATH}/${encodeURIComponent(options.groupId)}`,
2354
- method: "DELETE"
2355
- });
2356
- return {
2357
- location: extractLocationHeader(result.response) ?? undefined
2358
- };
2359
- }
2360
- }
2361
-
2362
- // nodes/IdentityAndAccessManagement/handlers/BaseResourceHandler.ts
2363
- var import_n8n_workflow = require("n8n-workflow");
2364
-
2365
- // nodes/IdentityAndAccessManagement/utils.ts
2366
- function toErrorObject(error) {
2367
- if (error instanceof Error) {
2368
- return { message: error.message };
2369
- }
2370
- if (typeof error === "string") {
2371
- return { message: error };
2372
- }
2373
- if (error && typeof error === "object" && "message" in error) {
2374
- return { message: String(error.message) };
2375
- }
2376
- return { message: "An unknown error occurred" };
2377
- }
2378
- function toErrorMessage(error) {
2379
- return toErrorObject(error).message;
2380
- }
2381
- function normaliseToObjects(data) {
2382
- if (data === null || data === undefined) {
2383
- return [];
2384
- }
2385
- if (Array.isArray(data)) {
2386
- return data.map((item) => {
2387
- if (item === null || item === undefined) {
2388
- return {};
2389
- }
2390
- if (typeof item === "object") {
2391
- return item;
2392
- }
2393
- return { value: item };
2394
- });
2395
- }
2396
- if (typeof data === "object") {
2397
- return [data];
2398
- }
2399
- return [{ value: data }];
2400
- }
2401
- function parseJsonParameter(value, parameterName, _context, _itemIndex) {
2402
- if (typeof value === "string") {
2403
- try {
2404
- return JSON.parse(value);
2405
- } catch (error) {
2406
- throw new Error(`Invalid JSON in parameter '${parameterName}': ${toErrorMessage(error)}`);
2407
- }
2408
- }
2409
- return value;
2410
- }
2411
- function getOptionalString(context, parameterName, itemIndex) {
2412
- const value = context.getNodeParameter(parameterName, itemIndex, "");
2413
- return value.trim() || undefined;
2414
- }
2415
- function getRequiredString(context, parameterName, itemIndex) {
2416
- const value = getOptionalString(context, parameterName, itemIndex);
2417
- if (!value) {
2418
- throw new Error(`Parameter '${parameterName}' is required`);
2419
- }
2420
- return value;
2421
- }
2422
- function getNumberParameter(context, parameterName, itemIndex, defaultValue) {
2423
- const value = context.getNodeParameter(parameterName, itemIndex, defaultValue);
2424
- return value;
2425
- }
2426
- function buildQueryParams(params) {
2427
- const query = {};
2428
- for (const [key, value] of Object.entries(params)) {
2429
- if (value !== undefined && value !== null && value !== "") {
2430
- query[key] = String(value);
2431
- }
2432
- }
2433
- return query;
2434
- }
2435
- function getRequiredJsonData(context, parameterName, itemIndex) {
2436
- const rawValue = context.getNodeParameter(parameterName, itemIndex);
2437
- if (!rawValue) {
2438
- throw new Error(`Parameter '${parameterName}' is required`);
2439
- }
2440
- return parseJsonParameter(rawValue, parameterName, context, itemIndex);
2441
- }
2442
-
2443
- // nodes/IdentityAndAccessManagement/handlers/BaseResourceHandler.ts
2444
- class BaseResourceHandler {
2445
- context;
2446
- itemIndex;
2447
- constructor(context, itemIndex) {
2448
- this.context = context;
2449
- this.itemIndex = itemIndex;
2450
- }
2451
- async execute(operation, authContext, returnData) {
2452
- try {
2453
- const sendSuccess = (payload) => {
2454
- const data = payload ? normaliseToObjects(payload) : [{}];
2455
- data.forEach((item) => {
2456
- returnData.push({
2457
- json: {
2458
- success: true,
2459
- ...item
2460
- },
2461
- pairedItem: { item: this.itemIndex }
2462
- });
2463
- });
2464
- };
2465
- await this.executeOperation(operation, authContext, sendSuccess);
2466
- } catch (error) {
2467
- if (this.context.continueOnFail()) {
2468
- returnData.push({
2469
- json: {
2470
- error: toErrorMessage(error)
2471
- },
2472
- pairedItem: { item: this.itemIndex }
2473
- });
2474
- return;
2475
- }
2476
- if (error instanceof import_n8n_workflow.NodeApiError || error instanceof import_n8n_workflow.NodeOperationError) {
2477
- throw error;
2478
- }
2479
- throw new import_n8n_workflow.NodeApiError(this.context.getNode(), toErrorObject(error), {
2480
- itemIndex: this.itemIndex
2481
- });
2482
- }
2483
- }
2484
- async getCredentials() {
2485
- const credentials = await this.context.getCredentials("datevConnectApi");
2486
- if (!credentials) {
2487
- throw new import_n8n_workflow.NodeOperationError(this.context.getNode(), "DATEVconnect credentials are missing");
2488
- }
2489
- const { host, email, password, clientInstanceId } = credentials;
2490
- if (!host || !email || !password || !clientInstanceId) {
2491
- throw new import_n8n_workflow.NodeOperationError(this.context.getNode(), "All DATEVconnect credential fields must be provided");
2492
- }
2493
- return credentials;
2494
- }
2495
- createAuthContext(credentials, token) {
2496
- return {
2497
- host: credentials.host,
2498
- token,
2499
- clientInstanceId: credentials.clientInstanceId
2500
- };
2501
- }
2502
- getOptionalString(name) {
2503
- return getOptionalString(this.context, name, this.itemIndex);
2504
- }
2505
- getRequiredString(name) {
2506
- return getRequiredString(this.context, name, this.itemIndex);
2507
- }
2508
- getNumberParameter(name, defaultValue) {
2509
- return getNumberParameter(this.context, name, this.itemIndex, defaultValue);
2510
- }
2511
- parseJsonParameter(rawValue, parameterLabel) {
2512
- return parseJsonParameter(rawValue, parameterLabel, this.context, this.itemIndex);
2513
- }
2514
- getRequiredJsonData(name) {
2515
- return getRequiredJsonData(this.context, name, this.itemIndex);
2516
- }
2517
- buildQueryParams(params) {
2518
- return buildQueryParams(params);
2519
- }
2520
- validateRequestContext(authContext) {
2521
- if (!authContext.host || !authContext.token || !authContext.clientInstanceId) {
2522
- throw new import_n8n_workflow.NodeOperationError(this.context.getNode(), "Authentication context is incomplete");
2523
- }
2524
- }
2525
- }
2526
-
2527
- // nodes/IdentityAndAccessManagement/handlers/ServiceProviderConfigResourceHandler.ts
2528
- class ServiceProviderConfigResourceHandler extends BaseResourceHandler {
2529
- async executeOperation(operation, authContext, sendSuccess) {
2530
- this.validateRequestContext(authContext);
2531
- if (operation !== "get") {
2532
- throw new import_n8n_workflow2.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for serviceProviderConfig.`, { itemIndex: this.itemIndex });
2533
- }
2534
- const response = await IdentityAndAccessManagementClient.fetchServiceProviderConfig(authContext);
2535
- sendSuccess(response);
2536
- }
2537
- }
2538
-
2539
- // nodes/IdentityAndAccessManagement/handlers/ResourceTypeResourceHandler.ts
2540
- var import_n8n_workflow3 = require("n8n-workflow");
2541
- class ResourceTypeResourceHandler extends BaseResourceHandler {
2542
- async executeOperation(operation, authContext, sendSuccess) {
2543
- this.validateRequestContext(authContext);
2544
- if (operation !== "getAll") {
2545
- throw new import_n8n_workflow3.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for resourceType.`, { itemIndex: this.itemIndex });
2546
- }
2547
- const response = await IdentityAndAccessManagementClient.fetchResourceTypes(authContext);
2548
- sendSuccess(response);
2549
- }
2550
- }
2551
-
2552
- // nodes/IdentityAndAccessManagement/handlers/SchemaResourceHandler.ts
2553
- var import_n8n_workflow4 = require("n8n-workflow");
2554
- class SchemaResourceHandler extends BaseResourceHandler {
2555
- async executeOperation(operation, authContext, sendSuccess) {
2556
- this.validateRequestContext(authContext);
2557
- switch (operation) {
2558
- case "getAll": {
2559
- const response = await IdentityAndAccessManagementClient.fetchSchemas(authContext);
2560
- sendSuccess(response);
2561
- return;
2562
- }
2563
- case "get": {
2564
- const schemaId = this.getRequiredString("schemaId");
2565
- const response = await IdentityAndAccessManagementClient.fetchSchema({
2566
- ...authContext,
2567
- schemaId
2568
- });
2569
- sendSuccess(response);
2570
- return;
2571
- }
2572
- default:
2573
- throw new import_n8n_workflow4.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for schema.`, { itemIndex: this.itemIndex });
2574
- }
2575
- }
2576
- }
2577
-
2578
- // nodes/IdentityAndAccessManagement/handlers/UserResourceHandler.ts
2579
- var import_n8n_workflow5 = require("n8n-workflow");
2580
- class UserResourceHandler extends BaseResourceHandler {
2581
- async executeOperation(operation, authContext, sendSuccess) {
2582
- this.validateRequestContext(authContext);
2583
- switch (operation) {
2584
- case "getAll": {
2585
- const filter = this.getOptionalString("filter");
2586
- const attributes = this.getOptionalString("attributes");
2587
- const startIndex = this.getNumberParameter("startIndex", 1);
2588
- const count = this.getNumberParameter("count", 100);
2589
- const response = await IdentityAndAccessManagementClient.fetchUsers({
2590
- ...authContext,
2591
- filter,
2592
- attributes,
2593
- startIndex,
2594
- count
2595
- });
2596
- sendSuccess(response);
2597
- return;
2598
- }
2599
- case "get": {
2600
- const userId = this.getRequiredString("userId");
2601
- const response = await IdentityAndAccessManagementClient.fetchUser({
2602
- ...authContext,
2603
- userId
2604
- });
2605
- sendSuccess(response);
2606
- return;
2607
- }
2608
- case "create": {
2609
- const userData = this.getRequiredJsonData("userData");
2610
- const response = await IdentityAndAccessManagementClient.createUser({
2611
- ...authContext,
2612
- user: userData
2613
- });
2614
- sendSuccess(response);
2615
- return;
2616
- }
2617
- case "update": {
2618
- const userId = this.getRequiredString("userId");
2619
- const userData = this.getRequiredJsonData("userData");
2620
- const response = await IdentityAndAccessManagementClient.updateUser({
2621
- ...authContext,
2622
- userId,
2623
- user: userData
2624
- });
2625
- sendSuccess(response);
2626
- return;
2627
- }
2628
- case "delete": {
2629
- const userId = this.getRequiredString("userId");
2630
- const result = await IdentityAndAccessManagementClient.deleteUser({
2631
- ...authContext,
2632
- userId
2633
- });
2634
- sendSuccess({
2635
- userId,
2636
- deleted: true,
2637
- ...result.location ? { location: result.location } : {}
2638
- });
2639
- return;
2640
- }
2641
- default:
2642
- throw new import_n8n_workflow5.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for user.`, { itemIndex: this.itemIndex });
2643
- }
2644
- }
2645
- }
2646
-
2647
- // nodes/IdentityAndAccessManagement/handlers/CurrentUserResourceHandler.ts
2648
- var import_n8n_workflow6 = require("n8n-workflow");
2649
- class CurrentUserResourceHandler extends BaseResourceHandler {
2650
- async executeOperation(operation, authContext, sendSuccess) {
2651
- this.validateRequestContext(authContext);
2652
- if (operation !== "get") {
2653
- throw new import_n8n_workflow6.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for currentUser.`, { itemIndex: this.itemIndex });
2654
- }
2655
- const response = await IdentityAndAccessManagementClient.fetchCurrentUser(authContext);
2656
- sendSuccess(response);
2657
- }
2658
- }
2659
-
2660
- // nodes/IdentityAndAccessManagement/handlers/GroupResourceHandler.ts
2661
- var import_n8n_workflow7 = require("n8n-workflow");
2662
- class GroupResourceHandler extends BaseResourceHandler {
2663
- async executeOperation(operation, authContext, sendSuccess) {
2664
- this.validateRequestContext(authContext);
2665
- switch (operation) {
2666
- case "getAll": {
2667
- const response = await IdentityAndAccessManagementClient.fetchGroups(authContext);
2668
- sendSuccess(response);
2669
- return;
2670
- }
2671
- case "get": {
2672
- const groupId = this.getRequiredString("groupId");
2673
- const response = await IdentityAndAccessManagementClient.fetchGroup({
2674
- ...authContext,
2675
- groupId
2676
- });
2677
- sendSuccess(response);
2678
- return;
2679
- }
2680
- case "create": {
2681
- const groupData = this.getRequiredJsonData("groupData");
2682
- const response = await IdentityAndAccessManagementClient.createGroup({
2683
- ...authContext,
2684
- group: groupData
2685
- });
2686
- sendSuccess(response);
2687
- return;
2688
- }
2689
- case "update": {
2690
- const groupId = this.getRequiredString("groupId");
2691
- const groupData = this.getRequiredJsonData("groupData");
2692
- const response = await IdentityAndAccessManagementClient.updateGroup({
2693
- ...authContext,
2694
- groupId,
2695
- group: groupData
2696
- });
2697
- sendSuccess(response);
2698
- return;
2699
- }
2700
- case "delete": {
2701
- const groupId = this.getRequiredString("groupId");
2702
- const result = await IdentityAndAccessManagementClient.deleteGroup({
2703
- ...authContext,
2704
- groupId
2705
- });
2706
- sendSuccess({
2707
- groupId,
2708
- deleted: true,
2709
- ...result.location ? { location: result.location } : {}
2710
- });
2711
- return;
2712
- }
2713
- default:
2714
- throw new import_n8n_workflow7.NodeOperationError(this.context.getNode(), `The operation "${operation}" is not supported for group.`, { itemIndex: this.itemIndex });
2715
- }
2716
- }
2717
- }
2718
-
2719
- // nodes/IdentityAndAccessManagement/IdentityAndAccessManagement.node.ts
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IdentityAndAccessManagement = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const datevConnectClient_1 = require("../../src/services/datevConnectClient");
6
+ const IdentityAndAccessManagement_config_1 = require("./IdentityAndAccessManagement.config");
7
+ const ServiceProviderConfigResourceHandler_1 = require("./handlers/ServiceProviderConfigResourceHandler");
8
+ const ResourceTypeResourceHandler_1 = require("./handlers/ResourceTypeResourceHandler");
9
+ const SchemaResourceHandler_1 = require("./handlers/SchemaResourceHandler");
10
+ const UserResourceHandler_1 = require("./handlers/UserResourceHandler");
11
+ const CurrentUserResourceHandler_1 = require("./handlers/CurrentUserResourceHandler");
12
+ const GroupResourceHandler_1 = require("./handlers/GroupResourceHandler");
13
+ const utils_1 = require("./utils");
2720
14
  class IdentityAndAccessManagement {
2721
- description = identityAndAccessManagementNodeDescription;
2722
- async execute() {
2723
- const items = this.getInputData();
2724
- const returnData = [];
2725
- const credentials = await this.getCredentials("datevConnectApi");
2726
- if (!credentials) {
2727
- throw new import_n8n_workflow8.NodeOperationError(this.getNode(), "DATEVconnect credentials are missing");
2728
- }
2729
- const { host, email, password, clientInstanceId } = credentials;
2730
- if (!host || !email || !password || !clientInstanceId) {
2731
- throw new import_n8n_workflow8.NodeOperationError(this.getNode(), "All DATEVconnect credential fields must be provided");
2732
- }
2733
- let token;
2734
- try {
2735
- const authResponse = await authenticate({
2736
- host,
2737
- email,
2738
- password
2739
- });
2740
- token = authResponse.access_token;
2741
- } catch (error) {
2742
- throw new import_n8n_workflow8.NodeApiError(this.getNode(), toErrorObject(error));
2743
- }
2744
- const authContext = { host, token, clientInstanceId };
2745
- for (let itemIndex = 0;itemIndex < items.length; itemIndex++) {
2746
- const resource = this.getNodeParameter("resource", itemIndex);
2747
- const operation = this.getNodeParameter("operation", itemIndex);
2748
- let handler;
2749
- switch (resource) {
2750
- case "serviceProviderConfig":
2751
- handler = new ServiceProviderConfigResourceHandler(this, itemIndex);
2752
- break;
2753
- case "resourceType":
2754
- handler = new ResourceTypeResourceHandler(this, itemIndex);
2755
- break;
2756
- case "schema":
2757
- handler = new SchemaResourceHandler(this, itemIndex);
2758
- break;
2759
- case "user":
2760
- handler = new UserResourceHandler(this, itemIndex);
2761
- break;
2762
- case "currentUser":
2763
- handler = new CurrentUserResourceHandler(this, itemIndex);
2764
- break;
2765
- case "group":
2766
- handler = new GroupResourceHandler(this, itemIndex);
2767
- break;
2768
- default:
2769
- throw new import_n8n_workflow8.NodeOperationError(this.getNode(), `The resource "${resource}" is not supported.`, { itemIndex });
2770
- }
2771
- await handler.execute(operation, authContext, returnData);
2772
- }
2773
- return [returnData];
2774
- }
2775
- }
15
+ constructor() {
16
+ var _a;
17
+ this.description = {
18
+ ...IdentityAndAccessManagement_config_1.identityAndAccessManagementNodeDescription,
19
+ icon: (_a = IdentityAndAccessManagement_config_1.identityAndAccessManagementNodeDescription.icon) !== null && _a !== void 0 ? _a : "file:../klardaten.svg",
20
+ usableAsTool: true,
21
+ };
22
+ }
23
+ async execute() {
24
+ const items = this.getInputData();
25
+ const returnData = [];
26
+ const credentials = (await this.getCredentials("datevConnectApi"));
27
+ if (!credentials) {
28
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "DATEVconnect credentials are missing");
29
+ }
30
+ const { host, email, password, clientInstanceId } = credentials;
31
+ if (!host || !email || !password || !clientInstanceId) {
32
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "All DATEVconnect credential fields must be provided");
33
+ }
34
+ let token;
35
+ try {
36
+ const authResponse = await (0, datevConnectClient_1.authenticate)({
37
+ host,
38
+ email,
39
+ password,
40
+ });
41
+ token = authResponse.access_token;
42
+ }
43
+ catch (error) {
44
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), (0, utils_1.toErrorObject)(error));
45
+ }
46
+ const authContext = { host, token, clientInstanceId };
47
+ for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
48
+ const resource = this.getNodeParameter("resource", itemIndex);
49
+ const operation = this.getNodeParameter("operation", itemIndex);
50
+ let handler;
51
+ switch (resource) {
52
+ case "serviceProviderConfig":
53
+ handler = new ServiceProviderConfigResourceHandler_1.ServiceProviderConfigResourceHandler(this, itemIndex);
54
+ break;
55
+ case "resourceType":
56
+ handler = new ResourceTypeResourceHandler_1.ResourceTypeResourceHandler(this, itemIndex);
57
+ break;
58
+ case "schema":
59
+ handler = new SchemaResourceHandler_1.SchemaResourceHandler(this, itemIndex);
60
+ break;
61
+ case "user":
62
+ handler = new UserResourceHandler_1.UserResourceHandler(this, itemIndex);
63
+ break;
64
+ case "currentUser":
65
+ handler = new CurrentUserResourceHandler_1.CurrentUserResourceHandler(this, itemIndex);
66
+ break;
67
+ case "group":
68
+ handler = new GroupResourceHandler_1.GroupResourceHandler(this, itemIndex);
69
+ break;
70
+ default:
71
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `The resource "${resource}" is not supported.`, { itemIndex });
72
+ }
73
+ await handler.execute(operation, authContext, returnData);
74
+ }
75
+ return [returnData];
76
+ }
77
+ }
78
+ exports.IdentityAndAccessManagement = IdentityAndAccessManagement;