@thegraphitelab/n8n-nodes-toolbox 1.0.0 → 1.1.0

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 (183) hide show
  1. package/dist/core/handlers/execHandler.js +6 -7
  2. package/dist/core/handlers/execHandler.js.map +1 -1
  3. package/dist/core/handlers/pollHandler.js +6 -7
  4. package/dist/core/handlers/pollHandler.js.map +1 -1
  5. package/dist/core/handlers/utils.d.ts +6 -6
  6. package/dist/core/handlers/utils.js +11 -11
  7. package/dist/core/handlers/utils.js.map +1 -1
  8. package/dist/core/handlers/webhookHandler.d.ts +14 -0
  9. package/dist/core/handlers/webhookHandler.js +57 -0
  10. package/dist/core/handlers/webhookHandler.js.map +1 -0
  11. package/dist/core/parameters/utils.d.ts +14 -3
  12. package/dist/core/parameters/utils.js +63 -1
  13. package/dist/core/parameters/utils.js.map +1 -1
  14. package/dist/core/transport/index.d.ts +1 -12
  15. package/dist/core/transport/index.js +3 -42
  16. package/dist/core/transport/index.js.map +1 -1
  17. package/dist/core/transport/jerboa.d.ts +14 -0
  18. package/dist/core/transport/jerboa.js +89 -0
  19. package/dist/core/transport/jerboa.js.map +1 -0
  20. package/dist/core/transport/toolbox.d.ts +12 -0
  21. package/dist/core/transport/toolbox.js +18 -0
  22. package/dist/core/transport/toolbox.js.map +1 -0
  23. package/dist/core/transport/utils.d.ts +2 -0
  24. package/dist/core/transport/utils.js +31 -0
  25. package/dist/core/transport/utils.js.map +1 -0
  26. package/dist/core/utils/array.d.ts +1 -0
  27. package/dist/core/utils/array.js +9 -0
  28. package/dist/core/utils/array.js.map +1 -0
  29. package/dist/core/utils/file.d.ts +5 -0
  30. package/dist/core/utils/file.js +25 -0
  31. package/dist/core/utils/file.js.map +1 -0
  32. package/dist/core/utils/string.d.ts +2 -0
  33. package/dist/core/utils/string.js +10 -0
  34. package/dist/core/utils/string.js.map +1 -0
  35. package/dist/credentials/JerboaApi.credentials.d.ts +10 -0
  36. package/dist/credentials/JerboaApi.credentials.js +28 -0
  37. package/dist/credentials/JerboaApi.credentials.js.map +1 -0
  38. package/dist/nodes/CallIQ/v1/CallIqPollTriggerV1.node.js +0 -1
  39. package/dist/nodes/CallIQ/v1/CallIqPollTriggerV1.node.js.map +1 -1
  40. package/dist/nodes/CallIQ/v1/actions/call/get/description.js +1 -1
  41. package/dist/nodes/CallIQ/v1/actions/call/get/execution.js +2 -2
  42. package/dist/nodes/CallIQ/v1/actions/call/get/execution.js.map +1 -1
  43. package/dist/nodes/CallIQ/v1/triggers/poll/onCallCompletion/description.js +1 -1
  44. package/dist/nodes/CallIQ/v1/triggers/poll/onCallCompletion/polling.js +1 -1
  45. package/dist/nodes/CallIQ/v1/triggers/poll/onCallCompletion/polling.js.map +1 -1
  46. package/dist/nodes/PurchasingAssistant/PurchasingAssistant.node.d.ts +4 -0
  47. package/dist/nodes/PurchasingAssistant/PurchasingAssistant.node.js +24 -0
  48. package/dist/nodes/PurchasingAssistant/PurchasingAssistant.node.js.map +1 -0
  49. package/dist/nodes/PurchasingAssistant/PurchasingAssistant.node.json +18 -0
  50. package/dist/nodes/PurchasingAssistant/PurchasingAssistantWhTrigger.node.d.ts +4 -0
  51. package/dist/nodes/PurchasingAssistant/PurchasingAssistantWhTrigger.node.js +24 -0
  52. package/dist/nodes/PurchasingAssistant/PurchasingAssistantWhTrigger.node.js.map +1 -0
  53. package/dist/nodes/PurchasingAssistant/PurchasingAssistantWhTrigger.node.json +18 -0
  54. package/dist/nodes/PurchasingAssistant/eli.svg +106 -0
  55. package/dist/nodes/PurchasingAssistant/v1/PurchasingAssistantV1.node.d.ts +6 -0
  56. package/dist/nodes/PurchasingAssistant/v1/PurchasingAssistantV1.node.js +68 -0
  57. package/dist/nodes/PurchasingAssistant/v1/PurchasingAssistantV1.node.js.map +1 -0
  58. package/dist/nodes/PurchasingAssistant/v1/PurchasingAssistantWhTriggerV1.node.d.ts +13 -0
  59. package/dist/nodes/PurchasingAssistant/v1/PurchasingAssistantWhTriggerV1.node.js +66 -0
  60. package/dist/nodes/PurchasingAssistant/v1/PurchasingAssistantWhTriggerV1.node.js.map +1 -0
  61. package/dist/nodes/PurchasingAssistant/v1/actions/index.d.ts +20 -0
  62. package/dist/nodes/PurchasingAssistant/v1/actions/index.js +30 -0
  63. package/dist/nodes/PurchasingAssistant/v1/actions/index.js.map +1 -0
  64. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/const.d.ts +2 -0
  65. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/const.js +6 -0
  66. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/const.js.map +1 -0
  67. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/create/description.d.ts +29 -0
  68. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/create/description.js +20 -0
  69. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/create/description.js.map +1 -0
  70. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/create/execution.d.ts +6 -0
  71. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/create/execution.js +39 -0
  72. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/create/execution.js.map +1 -0
  73. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/get/description.d.ts +29 -0
  74. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/get/description.js +19 -0
  75. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/get/description.js.map +1 -0
  76. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/get/execution.d.ts +6 -0
  77. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/get/execution.js +16 -0
  78. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/get/execution.js.map +1 -0
  79. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/getMany/description.d.ts +29 -0
  80. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/getMany/description.js +19 -0
  81. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/getMany/description.js.map +1 -0
  82. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/getMany/execution.d.ts +6 -0
  83. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/getMany/execution.js +23 -0
  84. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/getMany/execution.js.map +1 -0
  85. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/index.d.ts +13 -0
  86. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/index.js +51 -0
  87. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/index.js.map +1 -0
  88. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/update/description.d.ts +29 -0
  89. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/update/description.js +23 -0
  90. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/update/description.js.map +1 -0
  91. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/update/execution.d.ts +6 -0
  92. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/update/execution.js +35 -0
  93. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/update/execution.js.map +1 -0
  94. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/utils.d.ts +10 -0
  95. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/utils.js +21 -0
  96. package/dist/nodes/PurchasingAssistant/v1/actions/transaction/utils.js.map +1 -0
  97. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/const.d.ts +2 -0
  98. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/const.js +6 -0
  99. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/const.js.map +1 -0
  100. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/create/description.d.ts +29 -0
  101. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/create/description.js +23 -0
  102. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/create/description.js.map +1 -0
  103. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/create/execution.d.ts +6 -0
  104. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/create/execution.js +24 -0
  105. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/create/execution.js.map +1 -0
  106. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/get/description.d.ts +29 -0
  107. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/get/description.js +19 -0
  108. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/get/description.js.map +1 -0
  109. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/get/execution.d.ts +6 -0
  110. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/get/execution.js +23 -0
  111. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/get/execution.js.map +1 -0
  112. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/getMany/description.d.ts +29 -0
  113. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/getMany/description.js +27 -0
  114. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/getMany/description.js.map +1 -0
  115. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/getMany/execution.d.ts +6 -0
  116. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/getMany/execution.js +23 -0
  117. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/getMany/execution.js.map +1 -0
  118. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/index.d.ts +13 -0
  119. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/index.js +51 -0
  120. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/index.js.map +1 -0
  121. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/update/description.d.ts +29 -0
  122. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/update/description.js +19 -0
  123. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/update/description.js.map +1 -0
  124. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/update/execution.d.ts +6 -0
  125. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/update/execution.js +22 -0
  126. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/update/execution.js.map +1 -0
  127. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/utils.d.ts +1 -0
  128. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/utils.js +7 -0
  129. package/dist/nodes/PurchasingAssistant/v1/actions/transactionNote/utils.js.map +1 -0
  130. package/dist/nodes/PurchasingAssistant/v1/parameters/index.d.ts +3 -0
  131. package/dist/nodes/PurchasingAssistant/v1/parameters/index.js +68 -0
  132. package/dist/nodes/PurchasingAssistant/v1/parameters/index.js.map +1 -0
  133. package/dist/nodes/PurchasingAssistant/v1/parameters/options.d.ts +22 -0
  134. package/dist/nodes/PurchasingAssistant/v1/parameters/options.js +34 -0
  135. package/dist/nodes/PurchasingAssistant/v1/parameters/options.js.map +1 -0
  136. package/dist/nodes/PurchasingAssistant/v1/parameters/types.d.ts +1 -0
  137. package/dist/nodes/PurchasingAssistant/v1/parameters/types.js +3 -0
  138. package/dist/nodes/PurchasingAssistant/v1/parameters/types.js.map +1 -0
  139. package/dist/nodes/PurchasingAssistant/v1/triggers/index.d.ts +8 -0
  140. package/dist/nodes/PurchasingAssistant/v1/triggers/index.js +26 -0
  141. package/dist/nodes/PurchasingAssistant/v1/triggers/index.js.map +1 -0
  142. package/dist/nodes/PurchasingAssistant/v1/triggers/webhook/index.d.ts +3 -0
  143. package/dist/nodes/PurchasingAssistant/v1/triggers/webhook/index.js +23 -0
  144. package/dist/nodes/PurchasingAssistant/v1/triggers/webhook/index.js.map +1 -0
  145. package/dist/nodes/PurchasingAssistant/v1/triggers/webhook/onTransactionCreation/description.d.ts +3 -0
  146. package/dist/nodes/PurchasingAssistant/v1/triggers/webhook/onTransactionCreation/description.js +15 -0
  147. package/dist/nodes/PurchasingAssistant/v1/triggers/webhook/onTransactionCreation/description.js.map +1 -0
  148. package/dist/nodes/PurchasingAssistant/v1/triggers/webhook/onTransactionCreation/webhookMethods.d.ts +1 -0
  149. package/dist/nodes/PurchasingAssistant/v1/triggers/webhook/onTransactionCreation/webhookMethods.js +10 -0
  150. package/dist/nodes/PurchasingAssistant/v1/triggers/webhook/onTransactionCreation/webhookMethods.js.map +1 -0
  151. package/dist/nodes/PurchasingAssistant/v1/triggers/webhook/onTransactionStatusChange/description.d.ts +3 -0
  152. package/dist/nodes/PurchasingAssistant/v1/triggers/webhook/onTransactionStatusChange/description.js +16 -0
  153. package/dist/nodes/PurchasingAssistant/v1/triggers/webhook/onTransactionStatusChange/description.js.map +1 -0
  154. package/dist/nodes/PurchasingAssistant/v1/triggers/webhook/onTransactionStatusChange/webhookMethods.d.ts +3 -0
  155. package/dist/nodes/PurchasingAssistant/v1/triggers/webhook/onTransactionStatusChange/webhookMethods.js +14 -0
  156. package/dist/nodes/PurchasingAssistant/v1/triggers/webhook/onTransactionStatusChange/webhookMethods.js.map +1 -0
  157. package/dist/nodes/Toolbox/eli.svg +51 -106
  158. package/dist/nodes/Toolbox/v1/transport/index.js +0 -2
  159. package/dist/nodes/Toolbox/v1/transport/index.js.map +1 -1
  160. package/dist/nodes/Webhooks/v1/WebhooksV1.node.js +0 -1
  161. package/dist/nodes/Webhooks/v1/WebhooksV1.node.js.map +1 -1
  162. package/dist/nodes/Webhooks/v1/actions/webhookInstance/create/description.js +2 -2
  163. package/dist/nodes/Webhooks/v1/actions/webhookInstance/create/description.js.map +1 -1
  164. package/dist/nodes/Webhooks/v1/actions/webhookInstance/create/execution.js +3 -3
  165. package/dist/nodes/Webhooks/v1/actions/webhookInstance/create/execution.js.map +1 -1
  166. package/dist/nodes/Webhooks/v1/actions/webhookInstance/deactivate/description.js +1 -1
  167. package/dist/nodes/Webhooks/v1/actions/webhookInstance/deactivate/execution.js +2 -2
  168. package/dist/nodes/Webhooks/v1/actions/webhookInstance/deactivate/execution.js.map +1 -1
  169. package/dist/nodes/Webhooks/v1/actions/webhookInstance/get/description.js +1 -1
  170. package/dist/nodes/Webhooks/v1/actions/webhookInstance/get/execution.js +3 -3
  171. package/dist/nodes/Webhooks/v1/actions/webhookInstance/get/execution.js.map +1 -1
  172. package/dist/nodes/Webhooks/v1/actions/webhookInstance/update/description.js +1 -1
  173. package/dist/nodes/Webhooks/v1/actions/webhookInstance/update/execution.js +3 -3
  174. package/dist/nodes/Webhooks/v1/actions/webhookInstance/update/execution.js.map +1 -1
  175. package/dist/nodes/Webhooks/v1/methods/loadOptions.js +1 -1
  176. package/dist/nodes/Webhooks/v1/methods/loadOptions.js.map +1 -1
  177. package/dist/nodes/Webhooks/v1/methods/resourceMapping.js +1 -1
  178. package/dist/nodes/Webhooks/v1/methods/resourceMapping.js.map +1 -1
  179. package/dist/nodes/Webhooks/v1/triggers/webhook/onWebhookEvent/description.js +1 -1
  180. package/dist/nodes/Webhooks/v1/triggers/webhook/onWebhookEvent/webhookMethods.js +2 -2
  181. package/dist/nodes/Webhooks/v1/triggers/webhook/onWebhookEvent/webhookMethods.js.map +1 -1
  182. package/dist/package.json +8 -2
  183. package/package.json +8 -2
@@ -2,14 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.execHandler = execHandler;
4
4
  const utils_1 = require("./utils");
5
- // TODO: pass three tests on exec run
6
- function getResourceOperationPair(index) {
7
- const resource = this.getNodeParameter("resource", index);
8
- const operation = this.getNodeParameter("operation", index);
5
+ function getResourceOperationPair(ctx, index) {
6
+ const resource = ctx.getNodeParameter("resource", index);
7
+ const operation = ctx.getNodeParameter("operation", index);
9
8
  return { resource, operation };
10
9
  }
11
10
  function getExecFn(ctx, assertValidResource, assertValidOperation, router) {
12
- const { resource, operation } = getResourceOperationPair.call(ctx, 0);
11
+ const { resource, operation } = getResourceOperationPair(ctx, 0);
13
12
  assertValidResource(resource); // throws on invalid resource
14
13
  assertValidOperation(resource, operation); // throws on invalid resource from operation
15
14
  return router(resource, operation); // returns the
@@ -24,9 +23,9 @@ async function execHandler(ctx, assertValidResource, assertValidOperation, route
24
23
  returnData.push(...responseData);
25
24
  }
26
25
  catch (thrown) {
27
- const err = utils_1.normalizeError.call(ctx, thrown);
26
+ const err = (0, utils_1.normalizeError)(ctx, thrown);
28
27
  if (ctx.continueOnFail()) {
29
- returnData.push(...utils_1.constructErrorExecutionMetaData.call(ctx, i, err));
28
+ returnData.push(...(0, utils_1.constructErrorExecutionMetaData)(ctx, i, err));
30
29
  continue;
31
30
  }
32
31
  throw (0, utils_1.addIndexToError)(err, i);
@@ -1 +1 @@
1
- {"version":3,"file":"execHandler.js","sourceRoot":"","sources":["../../../core/handlers/execHandler.ts"],"names":[],"mappings":";;AAkCA,kCAoCC;AApED,mCAIiB;AAEjB,qCAAqC;AAErC,SAAS,wBAAwB,CAA0B,KAAa;IACpE,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC5D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACnC,CAAC;AAED,SAAS,SAAS,CACd,GAAsB,EACtB,mBAAgE,EAChE,oBAG2B,EAC3B,MAAwD;IAExD,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,wBAAwB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAEtE,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,6BAA6B;IAE5D,oBAAoB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,4CAA4C;IAEvF,OAAO,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,cAAc;AACtD,CAAC;AAEM,KAAK,UAAU,WAAW,CAC7B,GAAsB,EACtB,mBAAgE,EAChE,oBAG2B,EAC3B,MAAwD;IAExD,MAAM,MAAM,GAAG,SAAS,CACpB,GAAG,EACH,mBAAmB,EACnB,oBAAoB,EACpB,MAAM,CACT,CAAC;IAEF,MAAM,UAAU,GAAgC,EAAE,CAAC;IAEnD,4CAA4C;IAC5C,KAAK,MAAM,CAAC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C,QAAQ,CAAC,CAAC,CAAC,6BAA6B;IAE5D,oBAAoB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,4CAA4C;IAEvF,OAAO,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,cAAc;AACtD,CAAC;AAEM,KAAK,UAAU,WAAW,CAC7B,GAAsB,EACtB,mBAAgE,EAChE,oBAG2B,EAC3B,MAAwD;IAExD,MAAM,MAAM,GAAG,SAAS,CACpB,GAAG,EACH,mBAAmB,EACnB,oBAAoB,EACpB,MAAM,CACT,CAAC;IAEF,MAAM,UAAU,GAAgC,EAAE,CAAC;IAEnD,4CAA4C;IAC5C,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,YAAY,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC;QAC7C,IAAI,CAAC;YACD,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC/C,UAAU,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,MAAe,EAAE,CAAC;YACvB,MAAM,GAAG,GAAG,IAAA,sBAAc,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACxC,IAAI,GAAG,CAAC,cAAc,EAAE,EAAE,CAAC;gBACvB,UAAU,CAAC,IAAI,CACX,GAAG,IAAA,uCAA+B,EAAC,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,CAClD,CAAC;gBACF,SAAS;YACb,CAAC;YACD,MAAM,IAAA,uBAAe,EAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QAClC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,UAAU,CAAC,CAAC;AACxB,CAAC"}
@@ -18,16 +18,15 @@ function getPollFn(ctx, assertValidEvent, router) {
18
18
  assertValidEvent(event); // throws on invalid resource
19
19
  return router(event);
20
20
  }
21
- function returnPollResult(records) {
22
- return [this.helpers.returnJsonArray(records)];
21
+ function returnPollResult(ctx, records) {
22
+ return [ctx.helpers.returnJsonArray(records)];
23
23
  }
24
- // TODO: standardize ctx vs this as var name
25
24
  async function pollHandler(ctx, assertValidEvent, router) {
26
25
  const pollFn = getPollFn(ctx, assertValidEvent, router);
27
26
  // for "TEST" case
28
27
  if (ctx.getMode() === "manual") {
29
28
  const result = await pollFn.call(ctx);
30
- return returnPollResult.call(ctx, result);
29
+ return returnPollResult(ctx, result);
31
30
  }
32
31
  const cursor = getCursor(ctx);
33
32
  if (!cursor) {
@@ -36,13 +35,13 @@ async function pollHandler(ctx, assertValidEvent, router) {
36
35
  }
37
36
  try {
38
37
  const resultDuped = await pollFn.call(ctx);
39
- const resultDeduped = utils_1.dedupeBySeenId.call(ctx, resultDuped);
38
+ const resultDeduped = (0, utils_1.dedupeBySeenId)(ctx, resultDuped);
40
39
  setCursorNow(ctx);
41
- return returnPollResult.call(ctx, resultDeduped);
40
+ return returnPollResult(ctx, resultDeduped);
42
41
  }
43
42
  catch (thrown) {
44
43
  // do not set cursor on failure to allow for trying again...?
45
- const err = utils_1.normalizeError.call(ctx, thrown);
44
+ const err = (0, utils_1.normalizeError)(ctx, thrown);
46
45
  throw (0, utils_1.addIndexToError)(err, 0);
47
46
  }
48
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pollHandler.js","sourceRoot":"","sources":["../../../core/handlers/pollHandler.ts"],"names":[],"mappings":";;AAiCA,kCA6BC;AA5DD,mCAA0E;AAE1E,SAAS,SAAS,CAAC,GAAmB;IAClC,MAAM,YAAY,GAAG,GAAG,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACvD,OAAO,YAAY,CAAC,MAAM,CAAC;AAC/B,CAAC;AACD,SAAS,SAAS,CAAC,GAAmB,EAAE,MAAc;IAClD,MAAM,YAAY,GAAG,GAAG,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACvD,YAAY,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC;AACpC,CAAC;AACD,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,EACnB,gBAAuD,EACvD,MAAkC;IAElC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC;IAExD,kBAAkB;IAClB,IAAI,GAAG,CAAC,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACtC,OAAO,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,YAAY,CAAC,GAAG,CAAC,CAAC;QAClB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACD,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3C,MAAM,aAAa,GAAG,IAAA,sBAAc,EAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QACvD,YAAY,CAAC,GAAG,CAAC,CAAC;QAClB,OAAO,gBAAgB,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,MAAe,EAAE,CAAC;QACvB,6DAA6D;QAC7D,MAAM,GAAG,GAAG,IAAA,sBAAc,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACxC,MAAM,IAAA,uBAAe,EAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAClC,CAAC;AACL,CAAC"}
@@ -1,12 +1,12 @@
1
1
  import { IDataObject, IExecuteFunctions, IPollFunctions, NodeApiError, NodeExecutionWithMetadata, NodeOperationError } from "n8n-workflow";
2
- export declare function constructExecutionMetaData(this: IExecuteFunctions, index: number, responseData: IDataObject): NodeExecutionWithMetadata[];
3
- export declare function constructErrorExecutionMetaData(this: IExecuteFunctions, index: number, error: Error): NodeExecutionWithMetadata[];
4
- export declare function normalizeError(this: IExecuteFunctions | IPollFunctions, err: unknown): NodeOperationError | NodeApiError;
5
- export type ExecFunction = (this: IExecuteFunctions, index: number) => Promise<NodeExecutionWithMetadata[]>;
2
+ export declare function constructExecutionMetaData(ctx: IExecuteFunctions, index: number, responseData: IDataObject | IDataObject[]): NodeExecutionWithMetadata[];
3
+ export declare function constructErrorExecutionMetaData(ctx: IExecuteFunctions, index: number, error: Error): NodeExecutionWithMetadata[];
4
+ export declare function normalizeError(ctx: IExecuteFunctions | IPollFunctions, err: unknown): NodeOperationError | NodeApiError;
5
+ export type ExecFunction = (ctx: IExecuteFunctions, index: number) => Promise<NodeExecutionWithMetadata[]>;
6
6
  interface DedupeOptions {
7
7
  dedupeDuration?: number;
8
8
  }
9
- export declare function dedupeBySeenId(this: IPollFunctions, records: IDataObject[], opts?: DedupeOptions): IDataObject[];
10
- export declare function getBinaryDataBase64(this: IExecuteFunctions, fileKey: string, index: number): Promise<string>;
9
+ export declare function dedupeBySeenId(ctx: IPollFunctions, records: IDataObject[], opts?: DedupeOptions): IDataObject[];
10
+ export declare function getBinaryDataBase64(ctx: IExecuteFunctions, fileKey: string, index: number): Promise<string>;
11
11
  export declare function addIndexToError(err: NodeApiError | NodeOperationError, index: number): NodeApiError | NodeOperationError;
12
12
  export {};
@@ -8,29 +8,29 @@ exports.getBinaryDataBase64 = getBinaryDataBase64;
8
8
  exports.addIndexToError = addIndexToError;
9
9
  const n8n_workflow_1 = require("n8n-workflow");
10
10
  const error_1 = require("../utils/error");
11
- function constructExecutionMetaData(index, responseData) {
12
- return this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), {
11
+ function constructExecutionMetaData(ctx, index, responseData) {
12
+ return ctx.helpers.constructExecutionMetaData(ctx.helpers.returnJsonArray(responseData), {
13
13
  itemData: { item: index },
14
14
  });
15
15
  }
16
- function constructErrorExecutionMetaData(index, error) {
17
- return this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: index } });
16
+ function constructErrorExecutionMetaData(ctx, index, error) {
17
+ return ctx.helpers.constructExecutionMetaData(ctx.helpers.returnJsonArray({ error: error.message }), { itemData: { item: index } });
18
18
  }
19
19
  // Coerce anything thrown by a handler into a proper node error. Non-Errors are
20
20
  // a dev mistake, so we surface that loudly; valid node errors pass through.
21
- function normalizeError(err) {
21
+ function normalizeError(ctx, err) {
22
22
  if (!(0, error_1.isError)(err)) {
23
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), "A dev has thrown an object that isn't an error. Don't worry, this isn't your fault. Let dev know they need to fix that 🤡");
23
+ throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), "A dev has thrown an object that isn't an error. Don't worry, ctx isn't your fault. Let dev know they need to fix that 🤡");
24
24
  }
25
25
  const e = err;
26
26
  return (0, error_1.isValidError)(e)
27
27
  ? e
28
- : new n8n_workflow_1.NodeOperationError(this.getNode(), e);
28
+ : new n8n_workflow_1.NodeOperationError(ctx.getNode(), e);
29
29
  }
30
30
  const ONE_DAY = 24 * 60 * 60 * 1000;
31
- function dedupeBySeenId(records, opts) {
31
+ function dedupeBySeenId(ctx, records, opts) {
32
32
  const ttl = opts?.dedupeDuration ?? ONE_DAY;
33
- const workflowData = this.getWorkflowStaticData("node");
33
+ const workflowData = ctx.getWorkflowStaticData("node");
34
34
  const now = Date.now();
35
35
  const previouslySeen = workflowData.seenIds ?? {};
36
36
  const seenAt = {};
@@ -44,8 +44,8 @@ function dedupeBySeenId(records, opts) {
44
44
  workflowData["seenIds"] = seenAt;
45
45
  return fresh;
46
46
  }
47
- async function getBinaryDataBase64(fileKey, index) {
48
- const buffer = await this.helpers.getBinaryDataBuffer(index, fileKey);
47
+ async function getBinaryDataBase64(ctx, fileKey, index) {
48
+ const buffer = await ctx.helpers.getBinaryDataBuffer(index, fileKey);
49
49
  return buffer.toString("base64");
50
50
  }
51
51
  function addIndexToError(err, index) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../core/handlers/utils.ts"],"names":[],"m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,IAAI,GAAG,EAAE,OAAO,EAAE,SAAS,KAAK,SAAS,EAAE,CAAC;QACxC,IAAI,GAAG,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAC5B,GAAG,CAAC,OAAO,GAAG,EAAE,CAAC;QACrB,CAAC;QACD,GAAG,CAAC,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC;IAClC,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { IHookFunctions } from "n8n-workflow";
2
+ type ClientSetting<T> = T & {
3
+ clientID: string;
4
+ };
5
+ export declare function webhookHandler<T>({ getFilterCriteria, }: {
6
+ getFilterCriteria: (clientSettings: ClientSetting<T>[]) => Record<string, object>;
7
+ }): {
8
+ default: {
9
+ checkExists(this: IHookFunctions): Promise<boolean>;
10
+ create(this: IHookFunctions): Promise<boolean>;
11
+ delete(this: IHookFunctions): Promise<boolean>;
12
+ };
13
+ };
14
+ export {};
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.webhookHandler = webhookHandler;
4
+ const crypto_1 = require("crypto");
5
+ const n8n_workflow_1 = require("n8n-workflow");
6
+ const jerboa_1 = require("../transport/jerboa");
7
+ const array_1 = require("../utils/array");
8
+ function getWebhookSubscriptionID(ctx) {
9
+ const webhookData = ctx.getWorkflowStaticData("node");
10
+ return webhookData.webhookSubscriptionID;
11
+ }
12
+ function setWebhookSubscriptionID(ctx, webhookSubscriptionID) {
13
+ const webhookData = ctx.getWorkflowStaticData("node");
14
+ webhookData.webhookSubscriptionID = webhookSubscriptionID;
15
+ }
16
+ function deleteWebhookSubscriptionID(ctx) {
17
+ const webhookData = ctx.getWorkflowStaticData("node");
18
+ delete webhookData.webhookSubscriptionID;
19
+ }
20
+ function getClientSettings(ctx) {
21
+ const { clientSettings = [] } = ctx.getNodeParameter("clientSettingsUI", {});
22
+ return clientSettings;
23
+ }
24
+ async function checkExists() {
25
+ const webhookSubscriptionID = getWebhookSubscriptionID(this);
26
+ if (!webhookSubscriptionID)
27
+ return false;
28
+ return await (0, jerboa_1.requestWebhookSubscriptionExistence)(this, webhookSubscriptionID);
29
+ }
30
+ async function deletion() {
31
+ const webhookSubscriptionID = getWebhookSubscriptionID(this);
32
+ if (!webhookSubscriptionID)
33
+ return true;
34
+ await (0, jerboa_1.requestWebhookSubscriptionDeletion)(this, webhookSubscriptionID);
35
+ deleteWebhookSubscriptionID(this);
36
+ return true;
37
+ }
38
+ // TODO: fix type
39
+ function webhookHandler({ getFilterCriteria, }) {
40
+ async function create() {
41
+ const webhookURL = this.getNodeWebhookUrl("default");
42
+ const webhookSubscriptionID = (0, crypto_1.randomUUID)();
43
+ const clientSettings = getClientSettings(this);
44
+ if (clientSettings.length === 0) {
45
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Add at least one client under Client Settings.");
46
+ }
47
+ if (!(0, array_1.allElementsUnique)(clientSettings.map(({ clientID }) => clientID))) {
48
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Ensure all clientIDs are unique in your Client Settings.");
49
+ }
50
+ const webhookFilterCriteria = getFilterCriteria(clientSettings);
51
+ await (0, jerboa_1.requestWebhookSubscription)(this, webhookSubscriptionID, webhookURL, webhookFilterCriteria, "AIBPA:onTransactionStatusChange");
52
+ setWebhookSubscriptionID(this, webhookSubscriptionID);
53
+ return true;
54
+ }
55
+ return { default: { checkExists, delete: deletion, create } };
56
+ }
57
+ //# sourceMappingURL=webhookHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhookHandler.js","sourceRoot":"","sources":["../../../core/handlers/webhookHandler.ts"],"names":[],"mappings":";;AAwDA,wCAmDC;AA3GD,mCAA0C;AAC1C,+CAAkE;AAClE,gDAI6B;AAC7B,0CAAmD;AAEnD,SAAS,wBAAwB,CAAC,GAAmB;IACjD,MAAM,WAAW,GAAG,GAAG,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACtD,OAAO,WAAW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GAAE,CAAC;QAE3C,MAAM,cAAc,GAAG,iBAAiB,CAAI,IAAI,CAAC,CAAC;QAElD,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,iCAAkB,CACxB,IAAI,CAAC,OAAO,EAAE,EACd,gDAAgD,CACnD,CAAC;QACN,CAAC;QAED,IACI,CAAC,IAAA,yBAAiB,EAAC,cAAc,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EACpE,CAAC;YACC,MAAM,IAAI,iCAAkB,CACxB,IAAI,CAAC,OAAO,EAAE,EACd,0DAA0D,CAC7D,CAAC;QACN,CAAC;QAED,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,cAAc,CAAC,CAAC;QAEhE,MAAM,IAAA,mCAA0B,EAC5B,IAAI,EACJ,qBAAqB,EACrB,UAAU,EACV,qBAAqB,EACrB,iCAAiC,CACpC,CAAC;QAEF,wBAAwB,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;QAEtD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC;AAClE,CAAC"}
@@ -1,12 +1,12 @@
1
1
  import { INodeProperties, IDisplayOptions } from "n8n-workflow";
2
2
  export declare function wrapOptionsInAdditionalFields(optionalInputs: INodeProperties[], displayOptions: IDisplayOptions): INodeProperties;
3
3
  interface DescriptionConstructor {
4
- requiredInputs?: INodeProperties[];
5
- optionalInputs?: INodeProperties[];
4
+ mainParameters?: INodeProperties[];
5
+ advancedParameters?: INodeProperties[];
6
6
  displayOptions: IDisplayOptions;
7
7
  hints?: INodeProperties[];
8
8
  }
9
- export declare function getDescription({ requiredInputs, optionalInputs, displayOptions, hints, }: DescriptionConstructor): {
9
+ export declare function getDescription({ mainParameters: requiredInputs, advancedParameters: optionalInputs, displayOptions, hints, }: DescriptionConstructor): {
10
10
  displayOptions: IDisplayOptions;
11
11
  displayName: string;
12
12
  name: string;
@@ -33,4 +33,15 @@ export declare function getDescription({ requiredInputs, optionalInputs, display
33
33
  allowArbitraryValues?: boolean;
34
34
  resolvableField?: boolean;
35
35
  }[];
36
+ export declare function getWebhookDescription({ mainParameters: requiredInputs, advancedParameters: optionalInputs, displayOptions, hints, }: DescriptionConstructor): INodeProperties[];
37
+ type Option = {
38
+ name: string;
39
+ value: string;
40
+ };
41
+ export declare function deriveAllOptionTypes(displayName: string, name: string, optionChoices: Option[], defaultOptionChoice?: string): {
42
+ options: INodeProperties;
43
+ optionalOptions: INodeProperties;
44
+ multiOptions: INodeProperties;
45
+ multiOptionalOptions: INodeProperties;
46
+ };
36
47
  export {};
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.wrapOptionsInAdditionalFields = wrapOptionsInAdditionalFields;
4
4
  exports.getDescription = getDescription;
5
+ exports.getWebhookDescription = getWebhookDescription;
6
+ exports.deriveAllOptionTypes = deriveAllOptionTypes;
5
7
  const n8n_workflow_1 = require("n8n-workflow");
6
8
  function wrapOptionsInAdditionalFields(optionalInputs, displayOptions) {
7
9
  return {
@@ -14,7 +16,7 @@ function wrapOptionsInAdditionalFields(optionalInputs, displayOptions) {
14
16
  displayOptions,
15
17
  };
16
18
  }
17
- function getDescription({ requiredInputs = [], optionalInputs = [], displayOptions, hints, }) {
19
+ function getDescription({ mainParameters: requiredInputs = [], advancedParameters: optionalInputs = [], displayOptions, hints, }) {
18
20
  const optionalInputsWrapped = wrapOptionsInAdditionalFields(optionalInputs, displayOptions);
19
21
  const properties = [
20
22
  ...requiredInputs,
@@ -23,4 +25,64 @@ function getDescription({ requiredInputs = [], optionalInputs = [], displayOptio
23
25
  ];
24
26
  return (0, n8n_workflow_1.updateDisplayOptions)(displayOptions, properties);
25
27
  }
28
+ function getWebhookDescription({ mainParameters: requiredInputs = [], advancedParameters: optionalInputs = [], displayOptions, hints, }) {
29
+ // TODO: make helper between this and getWebhook()
30
+ const optionalInputsWrapped = wrapOptionsInAdditionalFields(optionalInputs, displayOptions);
31
+ const properties = [
32
+ {
33
+ displayName: "Client ID",
34
+ name: "clientID",
35
+ type: "string",
36
+ default: "",
37
+ required: true,
38
+ },
39
+ ...requiredInputs,
40
+ ...(optionalInputs.length > 0 ? [optionalInputsWrapped] : []),
41
+ ...(hints ?? []),
42
+ ];
43
+ const wrappedByClient = [
44
+ {
45
+ displayName: "Client Settings",
46
+ name: "clientSettingsUI",
47
+ type: "fixedCollection",
48
+ default: {},
49
+ options: [
50
+ {
51
+ displayName: "Client Settings",
52
+ name: "clientSettings",
53
+ values: properties,
54
+ },
55
+ ],
56
+ typeOptions: { multipleValues: true },
57
+ },
58
+ ];
59
+ return wrappedByClient;
60
+ }
61
+ function deriveAllOptionTypes(displayName, name, optionChoices, defaultOptionChoice = "") {
62
+ const options = {
63
+ displayName,
64
+ name,
65
+ type: "options",
66
+ options: optionChoices,
67
+ default: defaultOptionChoice,
68
+ };
69
+ const optionalOptions = {
70
+ ...options,
71
+ options: [...optionChoices, { name: "(None of the Above)", value: "" }],
72
+ name: options.name + "Optional",
73
+ };
74
+ const multiOptions = {
75
+ ...options,
76
+ type: "multiOptions",
77
+ default: [],
78
+ name: options.name + "Multi",
79
+ };
80
+ const multiOptionalOptions = {
81
+ ...options,
82
+ type: "multiOptions",
83
+ default: [],
84
+ name: options.name + "MultiOptional",
85
+ };
86
+ return { options, optionalOptions, multiOptions, multiOptionalOptions };
87
+ }
26
88
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../core/parameters/utils.ts"],"names":[],"mappings":";;AAMA,sEAaC;AAQD,wCAgBC;AA3CD,+CAIsB;AAEtB,SAAgB,6BAA6B,CACzC,cAAiC,EACjC,cAA+B;IAE/B,OAAO;QACH,WAAW,EAAE,mBAAmB;QAChC,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,WAAW;QACxB,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,cAAc;QACvB,cAAc;KACjB,CAAC;AACN,CAAC;AAQD,SAAgB,cAAc,CAAC,EAC3B,cAAc,GAAG,EAAE,EACnB,cAAc,GAAG,EAAE,EACnB,cAAc,EACd,KAAK,GACgB;IACrB,MAAM,qBAAqB,GACvB,6BAA6B,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IAElE,MAAM,UAAU,GAAsB;QAClC,GAAG,cAAc;QACjB,GAAG,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;KACnB,CAAC;IAEF,OAAO,IAAA,mCAAoB,EAAC,cAAc,EAAE,UAAU,CAAC,CAAC;AAC5D,CAAC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../core/parameters/utils.ts"],"names":[],"mappings":";;AAMA,sEAaC;AAQD,wCAgBC;AAED,sDAwCC;AAID,oDAwCC;AAjID,+CAIsB;AAEtB,SAAgB,6BAA6B,CACzC,cAAiC,EACjC,cAA+B;IAE/B,OAAO;QACH,WAAW,EAAE,mBAAmB;QAChC,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,WAAW;QACxB,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,cAAc;QACvB,cAAc;KACjB,CAAC;AACN,CAAC;AAQD,SAAgB,cAAc,CAAC,EAC3B,cAAc,EAAE,cAAc,GAAG,EAAE,EACnC,kBAAkB,EAAE,cAAc,GAAG,EAAE,EACvC,cAAc,EACd,KAAK,GACgB;IACrB,MAAM,qBAAqB,GACvB,6BAA6B,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IAElE,MAAM,UAAU,GAAsB;QAClC,GAAG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,mBAAmB,GAAG,EAAE;IAOxB,MAAM,OAAO,GAAoB;QAC7B,WAAW;QACX,IAAI;QACJ,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,aAAa;QACtB,OAAO,EAAE,mBAAmB;KAC/B,CAAC;IAEF,MAAM,eAAe,GAAoB;QACrC,GAAG,OAAO;QACV,OAAO,EAAE,CAAC,GAAG,aAAa,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;QACvE,IAAI,EAAE,OAAO,CAAC,IAAI,GAAG,UAAU;KAClC,CAAC;IAEF,MAAM,YAAY,GAAoB;QAClC,GAAG,OAAO;QACV,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE,EAAE;QACX,IAAI,EAAE,OAAO,CAAC,IAAI,GAAG,OAAO;KAC/B,CAAC;IAEF,MAAM,oBAAoB,GAAoB;QAC1C,GAAG,OAAO;QACV,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE,EAAE;QACX,IAAI,EAAE,OAAO,CAAC,IAAI,GAAG,eAAe;KACvC,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,oBAAoB,EAAE,CAAC;AAC5E,CAAC"}
@@ -1,12 +1 @@
1
- import { IDataObject, IExecuteFunctions, IHookFunctions, IHttpRequestMethods, ILoadOptionsFunctions, IPollFunctions } from "n8n-workflow";
2
- type Caller = IExecuteFunctions | IPollFunctions | ILoadOptionsFunctions | IHookFunctions;
3
- export interface IToolboxApiRequest {
4
- method: IHttpRequestMethods;
5
- endpoint: string;
6
- body?: IDataObject;
7
- qs?: IDataObject;
8
- headers?: IDataObject;
9
- option?: IDataObject;
10
- }
11
- export declare function toolboxApiRequest(this: Caller, { method, endpoint, body, qs, headers, option }: IToolboxApiRequest): Promise<any>;
12
- export {};
1
+ export { toolboxApiRequest, IToolboxApiRequest } from "./toolbox";
@@ -1,45 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toolboxApiRequest = toolboxApiRequest;
4
- const n8n_workflow_1 = require("n8n-workflow");
5
- const object_1 = require("../utils/object");
6
- const pipe_1 = require("../utils/pipe");
7
- function populateOptions(method, apiUrl, body = {}, qs = {}, headers = {}, option = { json: true }) {
8
- const withPopulatedOptions = (option) => (options) => (0, object_1.copyInto)(options, option);
9
- const withPopulatedHeaders = (headers) => (options) => {
10
- if (Object.keys(headers).length > 0) {
11
- options.headers = Object.assign({}, options.headers, headers);
12
- }
13
- return options;
14
- };
15
- const withSanitizedBody = (body) => (options) => {
16
- if (Object.keys(body).length === 0) {
17
- return (0, object_1.omit)(options, "body");
18
- }
19
- return options;
20
- };
21
- // TODO: Content-Type is set here, merged again via populateOptions, and also
22
- // declared in the node's requestDefaults. Consolidate to a single source.
23
- const baseOptions = {
24
- headers: {
25
- "Content-Type": "application/json",
26
- },
27
- method,
28
- body,
29
- qs,
30
- url: apiUrl,
31
- };
32
- return (0, pipe_1.pipe)(withPopulatedOptions(option), withPopulatedHeaders(headers), withSanitizedBody(body))(baseOptions);
33
- }
34
- async function toolboxApiRequest({ method, endpoint, body, qs, headers, option }) {
35
- const baseUrl = "https://api.thegraphitelab.com";
36
- const apiUrl = `${baseUrl}/${endpoint}`;
37
- const options = populateOptions.call(this, method, apiUrl, body, qs, headers, option);
38
- try {
39
- return await this.helpers.httpRequestWithAuthentication.call(this, "toolboxApi", options);
40
- }
41
- catch (e) {
42
- throw new n8n_workflow_1.NodeApiError(this.getNode(), e);
43
- }
44
- }
3
+ exports.toolboxApiRequest = void 0;
4
+ var toolbox_1 = require("./toolbox");
5
+ Object.defineProperty(exports, "toolboxApiRequest", { enumerable: true, get: function () { return toolbox_1.toolboxApiRequest; } });
45
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../core/transport/index.ts"],"names":[],"mappings":";;AA2EA,8CAyBC;AApGD,+CASsB;AAEtB,4CAAiD;AACjD,wC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ACnB,CAAC;AASM,KAAK,UAAU,iBAAiB,CAEnC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAsB;IAEnE,MAAM,OAAO,GAAG,gCAAgC,CAAC;IACjD,MAAM,MAAM,GAAG,GAAG,OAAO,IAAI,QAAQ,EAAE,CAAC;IACxC,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAChC,IAAI,EACJ,MAAM,EACN,MAAM,EACN,IAAI,EACJ,EAAE,EACF,OAAO,EACP,MAAM,CACT,CAAC;IAEF,IAAI,CAAC;QACD,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,6BAA6B,CAAC,IAAI,CACxD,IAAI,EACJ,YAAY,EACZ,OAAO,CACV,CAAC;IACN,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,IAAI,2BAAY,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC9C,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../core/transport/index.ts"],"names":[],"mappings":";;;AAAA,qCAAkE;AAAzD,4GAAA,iBAAiB,OAAA"}
@@ -0,0 +1,14 @@
1
+ import { IDataObject, IHttpRequestMethods } from "n8n-workflow";
2
+ import { Caller } from "../../nodes/Toolbox/v1/types";
3
+ export interface IJerboaApiRequest {
4
+ method: IHttpRequestMethods;
5
+ endpoint: string;
6
+ body?: IDataObject;
7
+ qs?: IDataObject;
8
+ headers?: IDataObject;
9
+ option?: IDataObject;
10
+ }
11
+ export declare function requestWebhookSubscriptionExistence(ctx: Caller, webhookSubscriptionID: string): Promise<any>;
12
+ export declare function requestWebhookSubscription(ctx: Caller, webhookSubscriptionID: string, webhookURL: string, webhookFilterCriteria: Record<string, object>, // TODO: fix type
13
+ webhookType: string): Promise<void>;
14
+ export declare function requestWebhookSubscriptionDeletion(ctx: Caller, webhookSubscriptionID: string): Promise<void>;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requestWebhookSubscriptionExistence = requestWebhookSubscriptionExistence;
4
+ exports.requestWebhookSubscription = requestWebhookSubscription;
5
+ exports.requestWebhookSubscriptionDeletion = requestWebhookSubscriptionDeletion;
6
+ const n8n_workflow_1 = require("n8n-workflow");
7
+ const utils_1 = require("./utils");
8
+ async function jerboaRequest(ctx, { endpoint, body, method }) {
9
+ const url = `https://api.trigger.dev/api/v1/${endpoint}`;
10
+ const options = (0, utils_1.populateOptions)(method, url, body);
11
+ try {
12
+ return await ctx.helpers.httpRequestWithAuthentication.call(ctx, "jerboaApi", options);
13
+ }
14
+ catch (e) {
15
+ throw new n8n_workflow_1.NodeApiError(ctx.getNode(), e);
16
+ }
17
+ }
18
+ async function sleep(seconds) {
19
+ return new Promise((resolve) => {
20
+ // TODO: figure out a better way to poll here
21
+ /* eslint-disable @n8n/community-nodes/no-restricted-globals */
22
+ setTimeout(resolve, seconds * 1000);
23
+ });
24
+ }
25
+ async function pollWebhookSubscriptionExistence(ctx, runID, attempts = 1) {
26
+ // TODO: make this less bad
27
+ try {
28
+ const res = await jerboaRequest(ctx, {
29
+ endpoint: `runs/${runID}`,
30
+ method: "GET",
31
+ });
32
+ if (res.status === "COMPLETED")
33
+ return res.output;
34
+ if (res.status === "FAILED" ||
35
+ res.status === "CANCELED" ||
36
+ res.status === "CRASHED" ||
37
+ res.status === "SYSTEM_FAILURE") {
38
+ throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), `Run ${runID} ended with status ${res.status}`);
39
+ }
40
+ // Any other status (QUEUED / EXECUTING / …) means keep polling.
41
+ }
42
+ catch (e) {
43
+ const message = e instanceof Error ? e.message : e;
44
+ if (!message.includes("found"))
45
+ throw e;
46
+ }
47
+ await sleep((attempts * attempts) / 2);
48
+ if (attempts > 5) {
49
+ throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), "Existence cannot be confirmed nor denied");
50
+ }
51
+ return pollWebhookSubscriptionExistence(ctx, runID, attempts + 1);
52
+ }
53
+ async function requestWebhookSubscriptionExistence(ctx, webhookSubscriptionID) {
54
+ const run = await jerboaRequest(ctx, {
55
+ method: "POST",
56
+ endpoint: "tasks/webhook-subscription-check-exists/trigger",
57
+ body: { payload: { webhookSubscriptionID } },
58
+ });
59
+ if (!run?.id)
60
+ throw new n8n_workflow_1.NodeOperationError(ctx.getNode(), "Run ID not found");
61
+ return await pollWebhookSubscriptionExistence(ctx, run.id);
62
+ }
63
+ // TODO: add check to make sure webhook subscription successfully happened
64
+ async function requestWebhookSubscription(ctx, webhookSubscriptionID, webhookURL, webhookFilterCriteria, // TODO: fix type
65
+ webhookType) {
66
+ const body = {
67
+ webhookSubscriptionID,
68
+ webhookURL,
69
+ webhookFilterCriteria,
70
+ webhookType,
71
+ };
72
+ await jerboaRequest(ctx, {
73
+ method: "POST",
74
+ endpoint: `tasks/webhook-subscription-register/trigger`,
75
+ body: { payload: body },
76
+ });
77
+ }
78
+ async function requestWebhookSubscriptionDeletion(ctx, webhookSubscriptionID) {
79
+ await jerboaRequest(ctx, {
80
+ method: "POST",
81
+ endpoint: "tasks/webhook-subscription-unsubscribe/trigger",
82
+ body: {
83
+ payload: {
84
+ webhookSubscriptionID,
85
+ },
86
+ },
87
+ });
88
+ }
89
+ //# sourceMappingURL=jerboa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jerboa.js","sourceRoot":"","sources":["../../../core/transport/jerboa.ts"],"names":[],"mappings":";;AAmFA,kFAYC;AAGD,gEAkBC;AAED,gFAaC;AAnID,+CAKsB;AAGtB,mCAA0C;AAU1C,KAAK,UAAU,aAAa,CACxB,GAAW,EACX,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAqB;IAE7C,MAAM,GAAG,GAAG,kCAAkC,QAAQ,EAAE,CAAC;IAEzD,MAAM,OAAO,GAAG,IAAA,uBAAe,EAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAEn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ACP,CAAC;AAEM,KAAK,UAAU,kCAAkC,CACpD,GAAW,EACX,qBAA6B;IAE7B,MAAM,aAAa,CAAC,GAAG,EAAE;QACrB,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,gDAAgD;QAC1D,IAAI,EAAE;YACF,OAAO,EAAE;gBACL,qBAAqB;aACxB;SACJ;KACJ,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { IDataObject, IExecuteFunctions, IHookFunctions, IHttpRequestMethods, ILoadOptionsFunctions, IPollFunctions } from "n8n-workflow";
2
+ type Caller = IExecuteFunctions | IPollFunctions | ILoadOptionsFunctions | IHookFunctions;
3
+ export interface IToolboxApiRequest {
4
+ method: IHttpRequestMethods;
5
+ endpoint: string;
6
+ body?: IDataObject;
7
+ qs?: IDataObject;
8
+ headers?: IDataObject;
9
+ option?: IDataObject;
10
+ }
11
+ export declare function toolboxApiRequest(ctx: Caller, { method, endpoint, body, qs, headers, option }: IToolboxApiRequest): Promise<any>;
12
+ export {};
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toolboxApiRequest = toolboxApiRequest;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const utils_1 = require("./utils");
6
+ async function toolboxApiRequest(ctx, { method, endpoint, body, qs, headers, option }) {
7
+ const baseUrl = "https://api.thegraphitelab.com";
8
+ const apiUrl = `${baseUrl}/${endpoint}`;
9
+ const options = (0, utils_1.populateOptions)(method, apiUrl, body, qs, headers, option);
10
+ try {
11
+ // TODO: add {message: string} handler and throw as NodeApiError
12
+ return await ctx.helpers.httpRequestWithAuthentication.call(ctx, "toolboxApi", options);
13
+ }
14
+ catch (e) {
15
+ throw new n8n_workflow_1.NodeApiError(ctx.getNode(), e);
16
+ }
17
+ }
18
+ //# sourceMappingURL=toolbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolbox.js","sourceRoot":"","sources":["../../../core/transport/toolbox.ts"],"names":[],"mappings":";;AA0BA,8CAkBC;AA5CD,+CAQsB;AAEtB,mCAA0C;AAgBnC,KAAK,UAAU,iBAAiB,CACnC,GAAW,EACX,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAsB;IAEnE,MAAM,OAAO,GAAG,gCAAgC,CAAC;IACjD,MAAM,MAAM,GAAG,GAAG,OAAO,IAAI,QAAQ,EAAE,CAAC;IACxC,MAAM,OAAO,GAAG,IAAA,uBAAe,EAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAE3E,IAAI,CAAC;QACD,gEAAgE;QAChE,OAAO,MAAM,GAAG,CAAC,OAAO,CAAC,6BAA6B,CAAC,IAAI,CACvD,GAAG,EACH,YAAY,EACZ,OAAO,CACV,CAAC;IACN,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,IAAI,2BAAY,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC7C,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { IHttpRequestMethods, IDataObject, IHttpRequestOptions } from "n8n-workflow";
2
+ export declare function populateOptions(method: IHttpRequestMethods, apiUrl: string, body?: IDataObject, qs?: IDataObject, headers?: IDataObject, option?: IDataObject): IHttpRequestOptions;