@weslink/n8n-nodes-kibi-connect 0.1.2 → 1.0.1

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 +250 -18
  2. package/dist/nodes/KibiConnect/KibiConnect.node.d.ts +6 -0
  3. package/dist/nodes/KibiConnect/KibiConnect.node.js +89 -1
  4. package/dist/nodes/KibiConnect/KibiConnect.node.js.map +1 -1
  5. package/dist/nodes/KibiConnect/loadOptions/getAbsenceTypes.d.ts +2 -0
  6. package/dist/nodes/KibiConnect/loadOptions/getAbsenceTypes.js +13 -0
  7. package/dist/nodes/KibiConnect/loadOptions/getAbsenceTypes.js.map +1 -0
  8. package/dist/nodes/KibiConnect/loadOptions/getGroupTypes.d.ts +2 -0
  9. package/dist/nodes/KibiConnect/loadOptions/getGroupTypes.js +13 -0
  10. package/dist/nodes/KibiConnect/loadOptions/getGroupTypes.js.map +1 -0
  11. package/dist/nodes/KibiConnect/resources/callLink/index.d.ts +2 -0
  12. package/dist/nodes/KibiConnect/resources/callLink/index.js +279 -0
  13. package/dist/nodes/KibiConnect/resources/callLink/index.js.map +1 -0
  14. package/dist/nodes/KibiConnect/resources/document/index.d.ts +2 -0
  15. package/dist/nodes/KibiConnect/resources/document/index.js +238 -0
  16. package/dist/nodes/KibiConnect/resources/document/index.js.map +1 -0
  17. package/dist/nodes/KibiConnect/resources/file/index.d.ts +2 -0
  18. package/dist/nodes/KibiConnect/resources/file/index.js +616 -0
  19. package/dist/nodes/KibiConnect/resources/file/index.js.map +1 -0
  20. package/dist/nodes/KibiConnect/resources/file/shared.d.ts +3 -0
  21. package/dist/nodes/KibiConnect/resources/file/shared.js +87 -0
  22. package/dist/nodes/KibiConnect/resources/file/shared.js.map +1 -0
  23. package/dist/nodes/KibiConnect/resources/folder/index.d.ts +2 -0
  24. package/dist/nodes/KibiConnect/resources/folder/index.js +278 -0
  25. package/dist/nodes/KibiConnect/resources/folder/index.js.map +1 -0
  26. package/dist/nodes/KibiConnect/resources/group/index.d.ts +2 -0
  27. package/dist/nodes/KibiConnect/resources/group/index.js +227 -0
  28. package/dist/nodes/KibiConnect/resources/group/index.js.map +1 -0
  29. package/dist/nodes/KibiConnect/resources/media/index.d.ts +2 -0
  30. package/dist/nodes/KibiConnect/resources/media/index.js +56 -0
  31. package/dist/nodes/KibiConnect/resources/media/index.js.map +1 -0
  32. package/dist/nodes/KibiConnect/resources/search/index.d.ts +2 -0
  33. package/dist/nodes/KibiConnect/resources/search/index.js +65 -0
  34. package/dist/nodes/KibiConnect/resources/search/index.js.map +1 -0
  35. package/dist/nodes/KibiConnect/resources/shareLink/index.d.ts +2 -0
  36. package/dist/nodes/KibiConnect/resources/shareLink/index.js +228 -0
  37. package/dist/nodes/KibiConnect/resources/shareLink/index.js.map +1 -0
  38. package/dist/nodes/KibiConnect/resources/sharedWiki/index.d.ts +2 -0
  39. package/dist/nodes/KibiConnect/resources/sharedWiki/index.js +66 -0
  40. package/dist/nodes/KibiConnect/resources/sharedWiki/index.js.map +1 -0
  41. package/dist/nodes/KibiConnect/resources/survey/index.d.ts +2 -0
  42. package/dist/nodes/KibiConnect/resources/survey/index.js +49 -0
  43. package/dist/nodes/KibiConnect/resources/survey/index.js.map +1 -0
  44. package/dist/nodes/KibiConnect/resources/timeTracking/index.d.ts +2 -0
  45. package/dist/nodes/KibiConnect/resources/timeTracking/index.js +642 -0
  46. package/dist/nodes/KibiConnect/resources/timeTracking/index.js.map +1 -0
  47. package/dist/nodes/KibiConnect/shared/binary.d.ts +4 -0
  48. package/dist/nodes/KibiConnect/shared/binary.js +57 -0
  49. package/dist/nodes/KibiConnect/shared/binary.js.map +1 -0
  50. package/dist/nodes/KibiConnect/shared/descriptions.d.ts +3 -0
  51. package/dist/nodes/KibiConnect/shared/descriptions.js +17 -16
  52. package/dist/nodes/KibiConnect/shared/descriptions.js.map +1 -1
  53. package/dist/nodes/KibiConnect/shared/fields.js +3 -3
  54. package/dist/nodes/KibiConnect/shared/fields.js.map +1 -1
  55. package/dist/nodes/KibiConnect/shared/routing.d.ts +2 -0
  56. package/dist/nodes/KibiConnect/shared/routing.js +47 -0
  57. package/dist/nodes/KibiConnect/shared/routing.js.map +1 -0
  58. package/dist/nodes/KibiConnect/shared/transport.d.ts +8 -1
  59. package/dist/nodes/KibiConnect/shared/transport.js +72 -14
  60. package/dist/nodes/KibiConnect/shared/transport.js.map +1 -1
  61. package/dist/nodes/KibiConnectTrigger/KibiConnectTrigger.node.d.ts +18 -0
  62. package/dist/nodes/KibiConnectTrigger/KibiConnectTrigger.node.js +237 -0
  63. package/dist/nodes/KibiConnectTrigger/KibiConnectTrigger.node.js.map +1 -0
  64. package/dist/nodes/KibiConnectTrigger/KibiConnectTrigger.node.json +18 -0
  65. package/dist/nodes/KibiConnectTrigger/filter.d.ts +8 -0
  66. package/dist/nodes/KibiConnectTrigger/filter.js +15 -0
  67. package/dist/nodes/KibiConnectTrigger/filter.js.map +1 -0
  68. package/dist/nodes/KibiConnectTrigger/loadOptions/getWebhookEvents.d.ts +4 -0
  69. package/dist/nodes/KibiConnectTrigger/loadOptions/getWebhookEvents.js +42 -0
  70. package/dist/nodes/KibiConnectTrigger/loadOptions/getWebhookEvents.js.map +1 -0
  71. package/dist/nodes/KibiConnectTrigger/registration.d.ts +4 -0
  72. package/dist/nodes/KibiConnectTrigger/registration.js +31 -0
  73. package/dist/nodes/KibiConnectTrigger/registration.js.map +1 -0
  74. package/dist/nodes/KibiConnectTrigger/verify.d.ts +1 -0
  75. package/dist/nodes/KibiConnectTrigger/verify.js +27 -0
  76. package/dist/nodes/KibiConnectTrigger/verify.js.map +1 -0
  77. package/dist/package.json +6 -4
  78. package/dist/tsconfig.tsbuildinfo +1 -1
  79. package/package.json +6 -4
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uploadBinary = uploadBinary;
4
+ exports.downloadBinary = downloadBinary;
5
+ exports.extractFileName = extractFileName;
6
+ async function uploadBinary(requestOptions) {
7
+ var _a;
8
+ const binaryProperty = this.getNodeParameter('binaryPropertyName');
9
+ const binaryData = this.helpers.assertBinaryData(binaryProperty);
10
+ const buffer = await this.helpers.getBinaryDataBuffer(binaryProperty);
11
+ const fields = typeof requestOptions.body === 'object' && requestOptions.body !== null
12
+ ? requestOptions.body
13
+ : {};
14
+ const form = new FormData();
15
+ for (const [name, value] of Object.entries(fields)) {
16
+ if (value === undefined || value === null || value === '') {
17
+ continue;
18
+ }
19
+ form.append(name, typeof value === 'string' ? value : String(value));
20
+ }
21
+ form.append('file', new Blob([new Uint8Array(buffer)], { type: binaryData.mimeType }), (_a = binaryData.fileName) !== null && _a !== void 0 ? _a : 'upload');
22
+ requestOptions.body = form;
23
+ if (requestOptions.headers !== undefined) {
24
+ delete requestOptions.headers['Content-Type'];
25
+ }
26
+ requestOptions.json = false;
27
+ return requestOptions;
28
+ }
29
+ async function downloadBinary(_items, responseData) {
30
+ const headers = responseData.headers;
31
+ const fileName = extractFileName(headers['content-disposition']);
32
+ const body = responseData.body;
33
+ const buffer = Buffer.isBuffer(body) ? body : Buffer.from(body);
34
+ const binary = await this.helpers.prepareBinaryData(buffer, fileName, headers['content-type']);
35
+ return [
36
+ {
37
+ json: { fileName, mimeType: binary.mimeType, fileSize: binary.fileSize },
38
+ binary: { data: binary },
39
+ },
40
+ ];
41
+ }
42
+ function extractFileName(contentDisposition) {
43
+ if (contentDisposition === undefined) {
44
+ return 'download';
45
+ }
46
+ const encoded = /filename\*=UTF-8''([^;]+)/i.exec(contentDisposition);
47
+ if (encoded !== null) {
48
+ try {
49
+ return decodeURIComponent(encoded[1]);
50
+ }
51
+ catch {
52
+ }
53
+ }
54
+ const plain = /filename="?([^";]+)"?/i.exec(contentDisposition);
55
+ return plain !== null ? plain[1] : 'download';
56
+ }
57
+ //# sourceMappingURL=binary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binary.js","sourceRoot":"","sources":["../../../../nodes/KibiCon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AAC;IACD,MAAM,KAAK,GAAG,wBAAwB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAChE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;AAC/C,CAAC"}
@@ -1,3 +1,6 @@
1
1
  import type { INodeProperties, PostReceiveAction } from 'n8n-workflow';
2
2
  export declare const unwrapData: PostReceiveAction[];
3
+ export declare const emptySuccess: PostReceiveAction[];
3
4
  export declare function returnAll(resource: string, operation: string): INodeProperties[];
5
+ export declare const FILES_BASE_URL = "={{$credentials.baseUrl}}/api/v2";
6
+ export declare function filesReturnAll(resource: string, operation: string): INodeProperties[];
@@ -1,14 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unwrapData = void 0;
3
+ exports.FILES_BASE_URL = exports.emptySuccess = exports.unwrapData = void 0;
4
4
  exports.returnAll = returnAll;
5
+ exports.filesReturnAll = filesReturnAll;
5
6
  exports.unwrapData = [
6
7
  {
7
8
  type: 'rootProperty',
8
9
  properties: { property: 'data' },
9
10
  },
10
11
  ];
12
+ exports.emptySuccess = [
13
+ {
14
+ type: 'set',
15
+ properties: { value: '={{ { "success": true } }}' },
16
+ },
17
+ ];
11
18
  function returnAll(resource, operation) {
19
+ return returnAllFields(resource, operation, 50);
20
+ }
21
+ exports.FILES_BASE_URL = '={{$credentials.baseUrl}}/api/v2';
22
+ function filesReturnAll(resource, operation) {
23
+ return returnAllFields(resource, operation, 100);
24
+ }
25
+ function returnAllFields(resource, operation, ceiling) {
12
26
  const show = { resource: [resource], operation: [operation] };
13
27
  return [
14
28
  {
@@ -19,27 +33,14 @@ function returnAll(resource, operation) {
19
33
  description: 'Whether to return all results or only up to a given limit',
20
34
  displayOptions: { show },
21
35
  routing: {
22
- operations: {
23
- pagination: {
24
- type: 'generic',
25
- properties: {
26
- continue: '={{ $response.body.meta.current_page < $response.body.meta.last_page }}',
27
- request: {
28
- qs: {
29
- page: '={{ $pageCount + 1 }}',
30
- limit: 50,
31
- },
32
- },
33
- },
34
- },
35
- },
36
+ request: { qs: { limit: `={{ $value ? ${ceiling} : undefined }}` } },
36
37
  },
37
38
  },
38
39
  {
39
40
  displayName: 'Limit',
40
41
  name: 'limit',
41
42
  type: 'number',
42
- typeOptions: { minValue: 1, maxValue: 50 },
43
+ typeOptions: { minValue: 1, maxValue: ceiling },
43
44
  default: 50,
44
45
  description: 'Max number of results to return',
45
46
  displayOptions: { show: { ...show, returnAll: [false] } },
@@ -1 +1 @@
1
- {"version":3,"file":"descriptions.js","sourceRoot":"","sources":["../../../../nodes/KibiConnect/shared/descriptions.ts"],"names":[],"mappings":";;;AAyBA,8BA0CC;AAzDY,QAAA,UAAU,GAAwB;IAC9C;QACC,IAAI,EAAE,cAAc;QACpB,UAAU,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE;KAChC;CACD,CAAC;AAUF,SAAgB,SAAS,CAAC,QAAgB,EAAE,SAAiB;IAC5D,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;IAE9D,OAAO;QACN;YACC,WAAW,EAAE,YAAY;YACzB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,2DAA2D;YACxE,cAAc,EAAE,EAAE,IAAI,EAAE;YACxB,OAAO,EAAE;gBACR,UAAU,EAAE;oBACX,UAAU,EAAE;wBACX,IAAI,EAAE,SAAS;wBACf,UAAU,EAAE;4BACX,QAAQ,EACP,yEAAyE;4BAC1E,OAAO,EAAE;gCACR,EAAE,EAAE;oCACH,IAAI,EAAE,uBAAuB;oCAC7B,KAAK,EAAE,EAAE;iCACT;6BACD;yBACD;qBACD;iBACD;aACD;SACD;QACD;YACC,WAAW,EAAE,OAAO;YACpB,IAAI,EAAE,OAAO;YACb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Y;YACzB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,WAAW,EAAE,2DAA2D;YACxE,cAAc,EAAE,EAAE,IAAI,EAAE;YACxB,OAAO,EAAE;gBACR,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,gBAAgB,OAAO,iBAAiB,EAAE,EAAE;aACpE;SACD;QACD;YACC,WAAW,EAAE,OAAO;YACpB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE;YAC/C,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,iCAAiC;YAC9C,cAAc,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE;YACzD,OAAO,EAAE;gBACR,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE;aAC3C;SACD;KACD,CAAC;AACH,CAAC"}
@@ -43,7 +43,7 @@ function contentFormatField(resource, operations) {
43
43
  displayName: 'Content Format',
44
44
  name: 'contentFormat',
45
45
  type: 'options',
46
- default: 'json',
46
+ default: 'html',
47
47
  description: 'How the rich-text field in this request is written. Kibi stores a document tree; HTML and Markdown are parsed into one on the way in, and anything it has no node for is lost at that point.',
48
48
  options: [
49
49
  { name: 'HTML', value: 'html' },
@@ -59,7 +59,7 @@ function readFormatField(resource, operations) {
59
59
  displayName: 'Read Format',
60
60
  name: 'format',
61
61
  type: 'options',
62
- default: 'json',
62
+ default: 'html',
63
63
  description: 'Which shape rich text comes back in. Converting to Markdown or plain text discards formatting Kibi can represent but those cannot.',
64
64
  options: [
65
65
  { name: 'HTML', value: 'html' },
@@ -81,7 +81,7 @@ function changeScanFields(resource, operation) {
81
81
  default: '',
82
82
  description: 'Return only records changed after this moment. Combine with sorting by Updated At and move the watermark forward after each run.',
83
83
  displayOptions: { show },
84
- routing: { request: { qs: { updated_since: '={{ $value }}' } } },
84
+ routing: { request: { qs: { updated_since: '={{ $value || undefined }}' } } },
85
85
  },
86
86
  {
87
87
  displayName: 'Sort By',
@@ -1 +1 @@
1
- {"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../nodes/KibiConnect/shared/fields.ts"],"names":[],"mappings":";;AAcA,8BAuBC;AAWD,0CAcC;AAUD,gDAgBC;AAGD,0CAiBC;AASD,4CA8BC;AAUD,sDAkBC;AA5KD,MAAM,YAAY,GAAG,uCAAuC,CAAC;AAC7D,MAAM,YAAY,GAAG,4BAA4B,CAAC;AAUlD,SAAgB,SAAS,CACxB,WAAmB,EACnB,IAAY,EACZ,QAAgB,EAChB,UAAoB,EACpB,WAAmB;IAEnB,OAAO;QACN,WAAW;QACX,IAAI;QACJ,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,EAAE;QACX,WAAW;QACX,IAAI,EAAE,kFAAkF;QACxF,WAAW,EAAE,YAAY;QACzB,cAAc,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE;QACzE,WAAW,EAAE;YAGZ,KAAK,EAAE,YAAY;SACnB;KACD,CAAC;AACH,CAAC;AAWD,SAAgB,eAAe,CAAC,QAAgB,EAAE,UAAoB;IACrE,OAAO;QACN,WAAW,EAAE,aAAa;QAC1B,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,aAAa;QAC1B,WAAW,EACV,sLAAsL;QACvL,IAAI,EAAE,2GAA2G;QACjH,cAAc,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE;QACzE,OAAO,EAAE,EAAE,OAA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AUD,SAAgB,qBAAqB,CAAC,QAAgB,EAAE,UAAoB;IAC3E,OAAO;QACN,WAAW,EAAE,yBAAyB;QACtC,IAAI,EAAE,mBAAmB;QACzB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,EAAE;QACX,WAAW,EACV,kJAAkJ;QACnJ,IAAI,EAAE,8IAA8I;QACpJ,cAAc,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE;QACzE,OAAO,EAAE;YACR,OAAO,EAAE;gBACR,OAAO,EAAE;oBACR,qBAAqB,EAAE,4DAA4D;iBACnF;aACD;SACD;KACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { DeclarativeRestApiSettings, IExecutePaginationFunctions, INodeExecutionData } from 'n8n-workflow';
2
+ export declare function kibiRoutingRequest(this: IExecutePaginationFunctions, requestData: DeclarativeRestApiSettings.ResultOptions): Promise<INodeExecutionData[]>;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.kibiRoutingRequest = kibiRoutingRequest;
4
+ const transport_1 = require("./transport");
5
+ async function kibiRoutingRequest(requestData) {
6
+ const resource = this.getNodeParameter('resource', '');
7
+ const returnAll = this.getNodeParameter('returnAll', false);
8
+ try {
9
+ if (!returnAll) {
10
+ return await this.makeRoutingRequest(requestData);
11
+ }
12
+ return await collectAllPages.call(this, requestData);
13
+ }
14
+ catch (error) {
15
+ throw transport_1.asReadableError.call(this, error, resource);
16
+ }
17
+ }
18
+ async function collectAllPages(requestData) {
19
+ var _a, _b, _c;
20
+ const options = requestData.options;
21
+ const baseQs = { ...((_a = options.qs) !== null && _a !== void 0 ? _a : {}) };
22
+ const records = [];
23
+ let position = {};
24
+ for (;;) {
25
+ const response = (await this.helpers.httpRequestWithAuthentication.call(this, 'kibiConnectApi', {
26
+ ...options,
27
+ qs: { ...baseQs, ...position },
28
+ returnFullResponse: true,
29
+ }));
30
+ const body = (_b = response.body) !== null && _b !== void 0 ? _b : {};
31
+ const data = Array.isArray(body.data) ? body.data : body.data === undefined ? [] : [body.data];
32
+ records.push(...data.map((json) => ({ json: json })));
33
+ const meta = (_c = body.meta) !== null && _c !== void 0 ? _c : {};
34
+ if (typeof meta.next_cursor === 'string' && meta.next_cursor !== '') {
35
+ position = { cursor: meta.next_cursor };
36
+ continue;
37
+ }
38
+ if (typeof meta.current_page === 'number' &&
39
+ typeof meta.last_page === 'number' &&
40
+ meta.current_page < meta.last_page) {
41
+ position = { page: meta.current_page + 1 };
42
+ continue;
43
+ }
44
+ return records;
45
+ }
46
+ }
47
+ //# sourceMappingURL=routing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../../../nodes/KibiConnect/shared/routing.ts"],"names":[],"mappings":";;AA6BA,gDAeC;AApCD,2CAA8C;AAqBvC,KAAK,UAAU,kBAAkB,CAEvC,WAAqD;IAErD,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,EAAE,CAAW,CAAC;IACjE,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,KAAK,CAAY,CAAC;IAEvE,IAAI,CAAC;QACJ,IAAI,CAAC,SAAS,EAAE,CAAC;YAChB,OAAO,MAAM,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,MAAM,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACtD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,2BAAe,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACnD,CAAC;AACF,CAAC;AAiCD,KAAK,UAAU,eAAe,CAE7B,WAAqD;;IAErD,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;IACpC,MAAM,MAA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AAI,CAAC,YAAY,GAAG,IAAI,CAAC,SAAS,EACjC,CAAC;YACF,QAAQ,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;YAC3C,SAAS;QACV,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;AACF,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { NodeApiError } from 'n8n-workflow';
2
2
  import type { IDataObject, IExecuteFunctions, IExecuteSingleFunctions, IHookFunctions, IHttpRequestMethods, ILoadOptionsFunctions } from 'n8n-workflow';
3
+ import { type KibiErrorBody } from './errors';
3
4
  export interface ListResponse<T> {
4
5
  data: T[];
5
6
  meta?: {
@@ -10,4 +11,10 @@ export interface ListResponse<T> {
10
11
  }
11
12
  export type KibiRequestContext = IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions;
12
13
  export declare function kibiApiRequest<T>(this: KibiRequestContext, method: IHttpRequestMethods, path: string, body?: IDataObject, qs?: IDataObject): Promise<T>;
13
- export declare function asReadableError(this: KibiRequestContext, error: unknown, path: string): NodeApiError;
14
+ export declare function resourceOfPath(path: string): string;
15
+ export interface HttpFailure {
16
+ status: number;
17
+ body: KibiErrorBody;
18
+ }
19
+ export declare function extractHttpFailure(error: unknown): HttpFailure;
20
+ export declare function asReadableError(this: KibiRequestContext, error: unknown, resource: string): NodeApiError;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.kibiApiRequest = kibiApiRequest;
4
+ exports.resourceOfPath = resourceOfPath;
5
+ exports.extractHttpFailure = extractHttpFailure;
4
6
  exports.asReadableError = asReadableError;
5
7
  const n8n_workflow_1 = require("n8n-workflow");
6
8
  const errors_1 = require("./errors");
@@ -19,21 +21,77 @@ async function kibiApiRequest(method, path, body, qs) {
19
21
  return (await this.helpers.httpRequestWithAuthentication.call(this, 'kibiConnectApi', options));
20
22
  }
21
23
  catch (error) {
22
- throw asReadableError.call(this, error, path);
23
- }
24
- }
25
- function asReadableError(error, path) {
26
- var _a, _b, _c, _d, _e, _f, _g;
27
- const status = (_a = error.statusCode) !== null && _a !== void 0 ? _a : Number((_b = error.httpCode) !== null && _b !== void 0 ? _b : 0);
28
- const body = (_f = (_d = (_c = error.cause) === null || _c === void 0 ? void 0 : _c.error) !== null && _d !== void 0 ? _d : (_e = error.response) === null || _e === void 0 ? void 0 : _e.body) !== null && _f !== void 0 ? _f : {};
29
- const resource = path.startsWith('/time-tracking')
30
- ? 'timeTracking'
31
- : path.startsWith('/dms')
32
- ? 'document'
33
- : 'other';
34
- return new n8n_workflow_1.NodeApiError(this.getNode(), (_g = error) !== null && _g !== void 0 ? _g : {}, {
35
- message: (0, errors_1.describeApiError)(status, body, resource),
24
+ throw asReadableError.call(this, error, resourceOfPath(path));
25
+ }
26
+ }
27
+ function resourceOfPath(path) {
28
+ if (path.startsWith('/time-tracking')) {
29
+ return 'timeTracking';
30
+ }
31
+ if (path.startsWith('/dms')) {
32
+ return 'document';
33
+ }
34
+ return 'other';
35
+ }
36
+ function extractHttpFailure(error) {
37
+ let status = 0;
38
+ let body;
39
+ let current = error;
40
+ for (let depth = 0; depth < 4 && isRecord(current); depth++) {
41
+ status || (status = statusOf(current));
42
+ body !== null && body !== void 0 ? body : (body = bodyOf(current));
43
+ current = current.cause;
44
+ }
45
+ return { status, body: body !== null && body !== void 0 ? body : {} };
46
+ }
47
+ function asReadableError(error, resource) {
48
+ var _a;
49
+ const { status, body } = extractHttpFailure(error);
50
+ const message = status === 0 && error instanceof Error
51
+ ? error.message
52
+ : (0, errors_1.describeApiError)(status, body, resource);
53
+ if (isNodeApiError(error)) {
54
+ error.message = message;
55
+ return error;
56
+ }
57
+ return new n8n_workflow_1.NodeApiError(this.getNode(), (_a = error) !== null && _a !== void 0 ? _a : {}, {
58
+ message,
36
59
  httpCode: status ? String(status) : undefined,
37
60
  });
38
61
  }
62
+ function isNodeApiError(error) {
63
+ return (error instanceof n8n_workflow_1.NodeApiError ||
64
+ (error instanceof Error && error.constructor.name === 'NodeApiError'));
65
+ }
66
+ function isRecord(value) {
67
+ return typeof value === 'object' && value !== null;
68
+ }
69
+ function statusOf(error) {
70
+ const response = isRecord(error.response) ? error.response : undefined;
71
+ const candidates = [
72
+ error.httpCode,
73
+ error.statusCode,
74
+ error.status,
75
+ response === null || response === void 0 ? void 0 : response.status,
76
+ response === null || response === void 0 ? void 0 : response.statusCode,
77
+ ];
78
+ for (const candidate of candidates) {
79
+ const parsed = Number(candidate);
80
+ if (Number.isInteger(parsed) && parsed >= 100 && parsed <= 599) {
81
+ return parsed;
82
+ }
83
+ }
84
+ return 0;
85
+ }
86
+ function bodyOf(error) {
87
+ const context = isRecord(error.context) ? error.context : undefined;
88
+ const response = isRecord(error.response) ? error.response : undefined;
89
+ const candidates = [context === null || context === void 0 ? void 0 : context.data, response === null || response === void 0 ? void 0 : response.data, response === null || response === void 0 ? void 0 : response.body, error.error];
90
+ for (const candidate of candidates) {
91
+ if (isRecord(candidate) && !Array.isArray(candidate)) {
92
+ return candidate;
93
+ }
94
+ }
95
+ return undefined;
96
+ }
39
97
  //# sourceMappingURL=transport.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../../nodes/KibiConnect/shared/transport.ts"],"names":[],"mappings":";;AA2CA,wCA2BC;AASD,0CA6BC;AA5GD,+CAA4C;AAY5C,qCAAgE;AA+BzD,KAAK,UAAU,cAAc,CAEnC,MAA2B,EAC3B,IAAY,EACZ,IAAkB,EAClB,EAAgB;;IAEhB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAChE,MAAM,OAAO,GAAG,MAAM,CAAC,MAAA,WAAW,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAEtE,MAAM,OAAO,GAAwB;QACpC,MAAM;QACN,GAAG,EAAE,GAAG,O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Q,CAAE,IAAI,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAEhF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACpC,IAAI,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YACtD,OAAO,SAA0B,CAAC;QACnC,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { IHookFunctions, INodeType, INodeTypeDescription, IWebhookFunctions, IWebhookResponseData } from 'n8n-workflow';
2
+ import { getWebhookEvents } from './loadOptions/getWebhookEvents';
3
+ export declare class KibiConnectTrigger implements INodeType {
4
+ description: INodeTypeDescription;
5
+ methods: {
6
+ loadOptions: {
7
+ getWebhookEvents: typeof getWebhookEvents;
8
+ };
9
+ };
10
+ webhookMethods: {
11
+ default: {
12
+ checkExists(this: IHookFunctions): Promise<boolean>;
13
+ create(this: IHookFunctions): Promise<boolean>;
14
+ delete(this: IHookFunctions): Promise<boolean>;
15
+ };
16
+ };
17
+ webhook(this: IWebhookFunctions): Promise<IWebhookResponseData>;
18
+ }
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KibiConnectTrigger = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const transport_1 = require("../KibiConnect/shared/transport");
6
+ const filter_1 = require("./filter");
7
+ const getWebhookEvents_1 = require("./loadOptions/getWebhookEvents");
8
+ const registration_1 = require("./registration");
9
+ const verify_1 = require("./verify");
10
+ class KibiConnectTrigger {
11
+ constructor() {
12
+ this.description = {
13
+ displayName: 'Kibi Connect Trigger',
14
+ name: 'kibiConnectTrigger',
15
+ icon: {
16
+ light: 'file:../../icons/kibiConnect.svg',
17
+ dark: 'file:../../icons/kibiConnect.dark.svg',
18
+ },
19
+ group: ['trigger'],
20
+ version: 1,
21
+ subtitle: '={{$parameter["events"].join(", ")}}',
22
+ description: 'Starts the workflow when something happens in Kibi Connect',
23
+ defaults: {
24
+ name: 'Kibi Connect Trigger',
25
+ },
26
+ inputs: [],
27
+ outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
28
+ credentials: [
29
+ {
30
+ name: 'kibiConnectApi',
31
+ required: true,
32
+ },
33
+ ],
34
+ webhooks: [
35
+ {
36
+ name: 'default',
37
+ httpMethod: 'POST',
38
+ responseMode: 'onReceived',
39
+ path: 'webhook',
40
+ },
41
+ ],
42
+ properties: [
43
+ {
44
+ displayName: 'Register Webhook Automatically',
45
+ name: 'autoRegister',
46
+ type: 'boolean',
47
+ default: true,
48
+ description: 'Whether to create the webhook endpoint in Kibi when the workflow is activated and remove it again when it is deactivated. Requires a token with the webhooks:write scope, an integration slug, and a system administrator as its owner. Switch off to register it by hand instead.',
49
+ },
50
+ {
51
+ displayName: 'Webhook Secret',
52
+ name: 'manualSecret',
53
+ type: 'string',
54
+ typeOptions: { password: true },
55
+ default: '',
56
+ required: true,
57
+ description: 'The signing secret Kibi showed once when the endpoint was created. Every delivery is verified against it.',
58
+ displayOptions: {
59
+ show: {
60
+ autoRegister: [false],
61
+ },
62
+ },
63
+ },
64
+ {
65
+ displayName: 'Event Names or IDs',
66
+ name: 'events',
67
+ type: 'multiOptions',
68
+ typeOptions: {
69
+ loadOptionsMethod: 'getWebhookEvents',
70
+ },
71
+ default: [],
72
+ required: true,
73
+ description: 'The events to react to. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
74
+ },
75
+ {
76
+ displayName: 'Ignore Own Writes',
77
+ name: 'ignoreOwnWrites',
78
+ type: 'boolean',
79
+ default: true,
80
+ description: 'Whether to drop events this integration caused itself. Leave on for any workflow that also writes to Kibi — without it, writing triggers the webhook, which triggers the write again.',
81
+ },
82
+ ],
83
+ };
84
+ this.methods = {
85
+ loadOptions: {
86
+ getWebhookEvents: getWebhookEvents_1.getWebhookEvents,
87
+ },
88
+ };
89
+ this.webhookMethods = {
90
+ default: {
91
+ async checkExists() {
92
+ if (!autoRegisterEnabled.call(this)) {
93
+ return true;
94
+ }
95
+ const staticData = this.getWorkflowStaticData('node');
96
+ const response = await registrationRequest.call(this, 'GET', '/webhook-endpoints', undefined, { external_id: (0, registration_1.externalIdFor)(webhookIdOf.call(this)) });
97
+ const endpoints = response.data;
98
+ if (endpoints.length === 0) {
99
+ delete staticData.webhookId;
100
+ delete staticData.webhookSecret;
101
+ return false;
102
+ }
103
+ staticData.webhookId = endpoints[0].id;
104
+ return typeof staticData.webhookSecret === 'string' && staticData.webhookSecret !== '';
105
+ },
106
+ async create() {
107
+ var _a;
108
+ if (!autoRegisterEnabled.call(this)) {
109
+ return true;
110
+ }
111
+ const staticData = this.getWorkflowStaticData('node');
112
+ const webhookUrl = this.getNodeWebhookUrl('default');
113
+ if (webhookUrl === undefined) {
114
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'n8n did not provide a webhook URL for this node, so there is nothing to register in Kibi.');
115
+ }
116
+ if (typeof staticData.webhookId === 'string') {
117
+ try {
118
+ await registrationRequest.call(this, 'DELETE', `/webhook-endpoints/${staticData.webhookId}`);
119
+ }
120
+ catch (error) {
121
+ this.logger.warn(`Kibi Connect Trigger: could not remove the stale webhook endpoint ${staticData.webhookId} before re-creating it: ${error.message}`);
122
+ }
123
+ }
124
+ const response = (await registrationRequest.call(this, 'POST', '/webhook-endpoints', {
125
+ name: `n8n — ${(_a = this.getWorkflow().name) !== null && _a !== void 0 ? _a : 'workflow'}`.slice(0, 255),
126
+ url: webhookUrl,
127
+ events: await eventsToSubscribe.call(this),
128
+ external_id: (0, registration_1.externalIdFor)(webhookIdOf.call(this)),
129
+ }));
130
+ staticData.webhookId = response.data.id;
131
+ staticData.webhookSecret = response.secret;
132
+ return true;
133
+ },
134
+ async delete() {
135
+ if (!autoRegisterEnabled.call(this)) {
136
+ return true;
137
+ }
138
+ const staticData = this.getWorkflowStaticData('node');
139
+ if (typeof staticData.webhookId !== 'string') {
140
+ return true;
141
+ }
142
+ try {
143
+ await registrationRequest.call(this, 'DELETE', `/webhook-endpoints/${staticData.webhookId}`);
144
+ }
145
+ catch (error) {
146
+ if (!(0, registration_1.isNotFound)(error)) {
147
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), error);
148
+ }
149
+ this.logger.info(`Kibi Connect Trigger: webhook endpoint ${staticData.webhookId} was already gone.`);
150
+ }
151
+ delete staticData.webhookId;
152
+ delete staticData.webhookSecret;
153
+ return true;
154
+ },
155
+ },
156
+ };
157
+ }
158
+ async webhook() {
159
+ var _a, _b;
160
+ const request = this.getRequestObject();
161
+ const headers = this.getHeaderData();
162
+ const secret = await resolveSecret.call(this);
163
+ if (!(0, verify_1.verifyKibiSignature)(await rawBodyOf(request), headerValue(headers['x-kibi-signature']), secret)) {
164
+ this.getResponseObject().status(401).send('Invalid signature');
165
+ return { noWebhookResponse: true };
166
+ }
167
+ const body = this.getBodyData();
168
+ const selected = this.getNodeParameter('events', []);
169
+ if (typeof body.event !== 'string' || !(0, filter_1.matchesSelectedEvents)(body.event, selected)) {
170
+ return { webhookResponse: 'OK' };
171
+ }
172
+ if (this.getNodeParameter('ignoreOwnWrites', true)) {
173
+ const credentials = await this.getCredentials('kibiConnectApi');
174
+ if ((0, filter_1.isOwnEcho)((_a = body.data) !== null && _a !== void 0 ? _a : {}, String((_b = credentials.integrationSlug) !== null && _b !== void 0 ? _b : ''))) {
175
+ return { webhookResponse: 'OK' };
176
+ }
177
+ }
178
+ return {
179
+ workflowData: [
180
+ this.helpers.returnJsonArray([
181
+ {
182
+ ...body,
183
+ deliveryId: headerValue(headers['x-kibi-delivery-id']),
184
+ deliveredAt: headerValue(headers['x-kibi-timestamp']),
185
+ },
186
+ ]),
187
+ ],
188
+ };
189
+ }
190
+ }
191
+ exports.KibiConnectTrigger = KibiConnectTrigger;
192
+ function autoRegisterEnabled() {
193
+ return this.getNodeParameter('autoRegister', true);
194
+ }
195
+ function webhookIdOf() {
196
+ var _a;
197
+ const node = this.getNode();
198
+ return (_a = node.webhookId) !== null && _a !== void 0 ? _a : node.id;
199
+ }
200
+ async function eventsToSubscribe() {
201
+ const selected = this.getNodeParameter('events', []);
202
+ if (selected.length > 0) {
203
+ return selected;
204
+ }
205
+ const options = await getWebhookEvents_1.getWebhookEvents.call(this);
206
+ return options.map((option) => String(option.value));
207
+ }
208
+ async function registrationRequest(method, path, body, qs) {
209
+ try {
210
+ return await transport_1.kibiApiRequest.call(this, method, path, body, qs);
211
+ }
212
+ catch (error) {
213
+ const failure = (0, transport_1.extractHttpFailure)(error);
214
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, {
215
+ message: (0, registration_1.describeRegistrationError)(failure.status, failure.body),
216
+ description: 'Switch off "Register Webhook Automatically" to create the endpoint in Kibi by hand instead.',
217
+ });
218
+ }
219
+ }
220
+ async function resolveSecret() {
221
+ if (this.getNodeParameter('autoRegister', true)) {
222
+ const staticData = this.getWorkflowStaticData('node');
223
+ return typeof staticData.webhookSecret === 'string' ? staticData.webhookSecret : '';
224
+ }
225
+ return this.getNodeParameter('manualSecret', '');
226
+ }
227
+ async function rawBodyOf(request) {
228
+ var _a;
229
+ if (request.rawBody === undefined && typeof request.readRawBody === 'function') {
230
+ await request.readRawBody();
231
+ }
232
+ return (_a = request.rawBody) !== null && _a !== void 0 ? _a : Buffer.alloc(0);
233
+ }
234
+ function headerValue(value) {
235
+ return Array.isArray(value) ? value[0] : value;
236
+ }
237
+ //# sourceMappingURL=KibiConnectTrigger.node.js.map