n8n-nodes-base 1.88.0 → 1.90.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.
- package/dist/credentials/Aws.credentials.js +16 -2
- package/dist/credentials/Aws.credentials.js.map +1 -1
- package/dist/credentials/CustomerIoApi.credentials.js +2 -2
- package/dist/credentials/CustomerIoApi.credentials.js.map +1 -1
- package/dist/nodes/Airtable/v2/actions/record/update.operation.js +15 -3
- package/dist/nodes/Airtable/v2/actions/record/update.operation.js.map +1 -1
- package/dist/nodes/Aws/__tests__/credentials.js +35 -0
- package/dist/nodes/Aws/__tests__/credentials.js.map +1 -0
- package/dist/nodes/Code/Pyodide.js +16 -1
- package/dist/nodes/Code/Pyodide.js.map +1 -1
- package/dist/nodes/EmailReadImap/v2/EmailReadImapV2.node.js +1 -1
- package/dist/nodes/EmailReadImap/v2/EmailReadImapV2.node.js.map +1 -1
- package/dist/nodes/ExecuteWorkflow/ExecuteWorkflow/methods/localResourceMapping.js +3 -1
- package/dist/nodes/ExecuteWorkflow/ExecuteWorkflow/methods/localResourceMapping.js.map +1 -1
- package/dist/nodes/Form/formCompletionUtils.js +1 -3
- package/dist/nodes/Form/formCompletionUtils.js.map +1 -1
- package/dist/nodes/Form/utils.js +2 -7
- package/dist/nodes/Form/utils.js.map +1 -1
- package/dist/nodes/Freshdesk/Freshdesk.node.js +3 -6
- package/dist/nodes/Freshdesk/Freshdesk.node.js.map +1 -1
- package/dist/nodes/Google/Sheet/GoogleSheetsTrigger.node.js +12 -4
- package/dist/nodes/Google/Sheet/GoogleSheetsTrigger.node.js.map +1 -1
- package/dist/nodes/HttpRequest/V3/Description.js +8 -0
- package/dist/nodes/HttpRequest/V3/Description.js.map +1 -1
- package/dist/nodes/HttpRequest/V3/HttpRequestV3.node.js +23 -5
- package/dist/nodes/HttpRequest/V3/HttpRequestV3.node.js.map +1 -1
- package/dist/nodes/HttpRequest/shared/optimizeResponse.js +387 -0
- package/dist/nodes/HttpRequest/shared/optimizeResponse.js.map +1 -0
- package/dist/nodes/Hubspot/V2/HubspotV2.node.js +10 -2
- package/dist/nodes/Hubspot/V2/HubspotV2.node.js.map +1 -1
- package/dist/nodes/Jira/GenericFunctions.js +7 -3
- package/dist/nodes/Jira/GenericFunctions.js.map +1 -1
- package/dist/nodes/Jira/Jira.node.js +4 -6
- package/dist/nodes/Jira/Jira.node.js.map +1 -1
- package/dist/nodes/LinkedIn/GenericFunctions.js +1 -1
- package/dist/nodes/LinkedIn/GenericFunctions.js.map +1 -1
- package/dist/nodes/Microsoft/AzureCosmosDb/test/credentials.js +36 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/test/credentials.js.map +1 -0
- package/dist/nodes/Microsoft/Excel/test/credentials.js +36 -0
- package/dist/nodes/Microsoft/Excel/test/credentials.js.map +1 -0
- package/dist/nodes/Microsoft/Storage/test/credentials.js +57 -0
- package/dist/nodes/Microsoft/Storage/test/credentials.js.map +1 -0
- package/dist/nodes/Microsoft/Teams/test/credentials.js +36 -0
- package/dist/nodes/Microsoft/Teams/test/credentials.js.map +1 -0
- package/dist/nodes/Postgres/v2/helpers/utils.js +3 -1
- package/dist/nodes/Postgres/v2/helpers/utils.js.map +1 -1
- package/dist/nodes/RespondToWebhook/RespondToWebhook.node.js +57 -48
- package/dist/nodes/RespondToWebhook/RespondToWebhook.node.js.map +1 -1
- package/dist/nodes/SplitInBatches/v3/SplitInBatchesV3.node.js +1 -1
- package/dist/nodes/SplitInBatches/v3/SplitInBatchesV3.node.js.map +1 -1
- package/dist/nodes/Supabase/GenericFunctions.js +13 -4
- package/dist/nodes/Supabase/GenericFunctions.js.map +1 -1
- package/dist/nodes/Supabase/RowDescription.js +1 -0
- package/dist/nodes/Supabase/RowDescription.js.map +1 -1
- package/dist/nodes/Supabase/Supabase.node.js +17 -0
- package/dist/nodes/Supabase/Supabase.node.js.map +1 -1
- package/dist/nodes/Telegram/TelegramTrigger.node.js +4 -60
- package/dist/nodes/Telegram/TelegramTrigger.node.js.map +1 -1
- package/dist/nodes/Telegram/util/triggerUtils.js +88 -0
- package/dist/nodes/Telegram/util/triggerUtils.js.map +1 -0
- package/dist/nodes/Wait/Wait.node.js +5 -6
- package/dist/nodes/Wait/Wait.node.js.map +1 -1
- package/dist/nodes/Wordpress/__tests__/workflow/credentials.js +36 -0
- package/dist/nodes/Wordpress/__tests__/workflow/credentials.js.map +1 -0
- package/dist/test/globalSetup.js +3 -0
- package/dist/test/globalSetup.js.map +1 -1
- package/dist/test/nodes/ExecuteWorkflow.js +3 -2
- package/dist/test/nodes/ExecuteWorkflow.js.map +1 -1
- package/dist/test/nodes/Helpers.js +4 -15
- package/dist/test/nodes/Helpers.js.map +1 -1
- package/dist/test/nodes/TriggerHelpers.js +5 -2
- package/dist/test/nodes/TriggerHelpers.js.map +1 -1
- package/dist/test/nodes/credentials-helper.js +9 -13
- package/dist/test/nodes/credentials-helper.js.map +1 -1
- package/dist/types/nodes.json +6 -6
- package/dist/utils/workflowInputsResourceMapping/GenericFunctions.js +6 -1
- package/dist/utils/workflowInputsResourceMapping/GenericFunctions.js.map +1 -1
- package/package.json +14 -11
- package/dist/test/nodes/FakeCredentialsMap.js +0 -313
- package/dist/test/nodes/FakeCredentialsMap.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../nodes/Wait/Wait.node.ts"],"sourcesContent":["import { DateTime } from 'luxon';\nimport type {\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeTypeDescription,\n\tINodeProperties,\n\tIDisplayOptions,\n\tIWebhookFunctions,\n} from 'n8n-workflow';\nimport {\n\tNodeOperationError,\n\tNodeConnectionTypes,\n\tWAIT_INDEFINITELY,\n\tFORM_TRIGGER_NODE_TYPE,\n} from 'n8n-workflow';\n\nimport { updateDisplayOptions } from '../../utils/utilities';\nimport {\n\tformDescription,\n\tformFields,\n\trespondWithOptions,\n\tformRespondMode,\n\tformTitle,\n\tappendAttributionToForm,\n} from '../Form/common.descriptions';\nimport { formWebhook } from '../Form/utils';\nimport {\n\tauthenticationProperty,\n\tcredentialsProperty,\n\tdefaultWebhookDescription,\n\thttpMethodsProperty,\n\toptionsProperty,\n\tresponseBinaryPropertyNameProperty,\n\tresponseCodeProperty,\n\tresponseDataProperty,\n\tresponseModeProperty,\n} from '../Webhook/description';\nimport { Webhook } from '../Webhook/Webhook.node';\n\nconst toWaitAmount: INodeProperties = {\n\tdisplayName: 'Wait Amount',\n\tname: 'amount',\n\ttype: 'number',\n\ttypeOptions: {\n\t\tminValue: 0,\n\t\tnumberPrecision: 2,\n\t},\n\tdefault: 1,\n\tdescription: 'The time to wait',\n};\n\nconst unitSelector: INodeProperties = {\n\tdisplayName: 'Wait Unit',\n\tname: 'unit',\n\ttype: 'options',\n\toptions: [\n\t\t{\n\t\t\tname: 'Seconds',\n\t\t\tvalue: 'seconds',\n\t\t},\n\t\t{\n\t\t\tname: 'Minutes',\n\t\t\tvalue: 'minutes',\n\t\t},\n\t\t{\n\t\t\tname: 'Hours',\n\t\t\tvalue: 'hours',\n\t\t},\n\t\t{\n\t\t\tname: 'Days',\n\t\t\tvalue: 'days',\n\t\t},\n\t],\n\tdefault: 'hours',\n\tdescription: 'The time unit of the Wait Amount value',\n};\n\nconst waitTimeProperties: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Limit Wait Time',\n\t\tname: 'limitWaitTime',\n\t\ttype: 'boolean',\n\t\tdefault: false,\n\t\tdescription:\n\t\t\t'Whether to limit the time this node should wait for a user response before execution resumes',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tresume: ['webhook', 'form'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Limit Type',\n\t\tname: 'limitType',\n\t\ttype: 'options',\n\t\tdefault: 'afterTimeInterval',\n\t\tdescription:\n\t\t\t'Sets the condition for the execution to resume. Can be a specified date or after some time.',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tlimitWaitTime: [true],\n\t\t\t\tresume: ['webhook', 'form'],\n\t\t\t},\n\t\t},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'After Time Interval',\n\t\t\t\tdescription: 'Waits for a certain amount of time',\n\t\t\t\tvalue: 'afterTimeInterval',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'At Specified Time',\n\t\t\t\tdescription: 'Waits until the set date and time to continue',\n\t\t\t\tvalue: 'atSpecifiedTime',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tdisplayName: 'Amount',\n\t\tname: 'resumeAmount',\n\t\ttype: 'number',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tlimitType: ['afterTimeInterval'],\n\t\t\t\tlimitWaitTime: [true],\n\t\t\t\tresume: ['webhook', 'form'],\n\t\t\t},\n\t\t},\n\t\ttypeOptions: {\n\t\t\tminValue: 0,\n\t\t\tnumberPrecision: 2,\n\t\t},\n\t\tdefault: 1,\n\t\tdescription: 'The time to wait',\n\t},\n\t{\n\t\tdisplayName: 'Unit',\n\t\tname: 'resumeUnit',\n\t\ttype: 'options',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tlimitType: ['afterTimeInterval'],\n\t\t\t\tlimitWaitTime: [true],\n\t\t\t\tresume: ['webhook', 'form'],\n\t\t\t},\n\t\t},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Seconds',\n\t\t\t\tvalue: 'seconds',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Minutes',\n\t\t\t\tvalue: 'minutes',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Hours',\n\t\t\t\tvalue: 'hours',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Days',\n\t\t\t\tvalue: 'days',\n\t\t\t},\n\t\t],\n\t\tdefault: 'hours',\n\t\tdescription: 'Unit of the interval value',\n\t},\n\t{\n\t\tdisplayName: 'Max Date and Time',\n\t\tname: 'maxDateAndTime',\n\t\ttype: 'dateTime',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tlimitType: ['atSpecifiedTime'],\n\t\t\t\tlimitWaitTime: [true],\n\t\t\t\tresume: ['webhook', 'form'],\n\t\t\t},\n\t\t},\n\t\tdefault: '',\n\t\tdescription: 'Continue execution after the specified date and time',\n\t},\n];\n\nconst webhookSuffix: INodeProperties = {\n\tdisplayName: 'Webhook Suffix',\n\tname: 'webhookSuffix',\n\ttype: 'string',\n\tdefault: '',\n\tplaceholder: 'webhook',\n\tnoDataExpression: true,\n\tdescription:\n\t\t'This suffix path will be appended to the restart URL. Helpful when using multiple wait nodes.',\n};\n\nconst displayOnWebhook: IDisplayOptions = {\n\tshow: {\n\t\tresume: ['webhook'],\n\t},\n};\n\nconst displayOnFormSubmission = {\n\tshow: {\n\t\tresume: ['form'],\n\t},\n};\n\nconst onFormSubmitProperties = updateDisplayOptions(displayOnFormSubmission, [\n\tformTitle,\n\tformDescription,\n\tformFields,\n\tformRespondMode,\n]);\n\nconst onWebhookCallProperties = updateDisplayOptions(displayOnWebhook, [\n\t{\n\t\t...httpMethodsProperty,\n\t\tdescription: 'The HTTP method of the Webhook call',\n\t},\n\tresponseCodeProperty,\n\tresponseModeProperty,\n\tresponseDataProperty,\n\tresponseBinaryPropertyNameProperty,\n]);\n\nconst webhookPath = '={{$parameter[\"options\"][\"webhookSuffix\"] || \"\"}}';\n\nexport class Wait extends Webhook {\n\tauthPropertyName = 'incomingAuthentication';\n\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Wait',\n\t\tname: 'wait',\n\t\ticon: 'fa:pause-circle',\n\t\ticonColor: 'crimson',\n\t\tgroup: ['organization'],\n\t\tversion: [1, 1.1],\n\t\tdescription: 'Wait before continue with execution',\n\t\tdefaults: {\n\t\t\tname: 'Wait',\n\t\t\tcolor: '#804050',\n\t\t},\n\t\tinputs: [NodeConnectionTypes.Main],\n\t\toutputs: [NodeConnectionTypes.Main],\n\t\tcredentials: credentialsProperty(this.authPropertyName),\n\t\twebhooks: [\n\t\t\t{\n\t\t\t\t...defaultWebhookDescription,\n\t\t\t\tresponseData: '={{$parameter[\"responseData\"]}}',\n\t\t\t\tpath: webhookPath,\n\t\t\t\trestartWebhook: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'default',\n\t\t\t\thttpMethod: 'GET',\n\t\t\t\tresponseMode: 'onReceived',\n\t\t\t\tpath: webhookPath,\n\t\t\t\trestartWebhook: true,\n\t\t\t\tisFullPath: true,\n\t\t\t\tnodeType: 'form',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'default',\n\t\t\t\thttpMethod: 'POST',\n\t\t\t\tresponseMode: '={{$parameter[\"responseMode\"]}}',\n\t\t\t\tresponseData: '={{$parameter[\"responseMode\"] === \"lastNode\" ? \"noData\" : undefined}}',\n\t\t\t\tpath: webhookPath,\n\t\t\t\trestartWebhook: true,\n\t\t\t\tisFullPath: true,\n\t\t\t\tnodeType: 'form',\n\t\t\t},\n\t\t],\n\t\tproperties: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Resume',\n\t\t\t\tname: 'resume',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'After Time Interval',\n\t\t\t\t\t\tvalue: 'timeInterval',\n\t\t\t\t\t\tdescription: 'Waits for a certain amount of time',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'At Specified Time',\n\t\t\t\t\t\tvalue: 'specificTime',\n\t\t\t\t\t\tdescription: 'Waits until a specific date and time to continue',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'On Webhook Call',\n\t\t\t\t\t\tvalue: 'webhook',\n\t\t\t\t\t\tdescription: 'Waits for a webhook call before continuing',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'On Form Submitted',\n\t\t\t\t\t\tvalue: 'form',\n\t\t\t\t\t\tdescription: 'Waits for a form submission before continuing',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'timeInterval',\n\t\t\t\tdescription: 'Determines the waiting mode to use before the workflow continues',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Authentication',\n\t\t\t\tname: 'incomingAuthentication',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Basic Auth',\n\t\t\t\t\t\tvalue: 'basicAuth',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'None',\n\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'none',\n\t\t\t\tdescription:\n\t\t\t\t\t'If and how incoming resume-webhook-requests to $execution.resumeFormUrl should be authenticated for additional security',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tresume: ['form'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...authenticationProperty(this.authPropertyName),\n\t\t\t\tdescription:\n\t\t\t\t\t'If and how incoming resume-webhook-requests to $execution.resumeUrl should be authenticated for additional security',\n\t\t\t\tdisplayOptions: displayOnWebhook,\n\t\t\t},\n\n\t\t\t// ----------------------------------\n\t\t\t// resume:specificTime\n\t\t\t// ----------------------------------\n\t\t\t{\n\t\t\t\tdisplayName: 'Date and Time',\n\t\t\t\tname: 'dateTime',\n\t\t\t\ttype: 'dateTime',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tresume: ['specificTime'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '',\n\t\t\t\tdescription: 'The date and time to wait for before continuing',\n\t\t\t\trequired: true,\n\t\t\t},\n\n\t\t\t// ----------------------------------\n\t\t\t// resume:timeInterval\n\t\t\t// ----------------------------------\n\t\t\t{\n\t\t\t\t...toWaitAmount,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tresume: ['timeInterval'],\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...toWaitAmount,\n\t\t\t\tdefault: 5,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tresume: ['timeInterval'],\n\t\t\t\t\t},\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...unitSelector,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tresume: ['timeInterval'],\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...unitSelector,\n\t\t\t\tdefault: 'seconds',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tresume: ['timeInterval'],\n\t\t\t\t\t},\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t// ----------------------------------\n\t\t\t// resume:webhook & form\n\t\t\t// ----------------------------------\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'The webhook URL will be generated at run time. It can be referenced with the <strong>$execution.resumeUrl</strong> variable. Send it somewhere before getting to this node. <a href=\"https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.wait/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.wait\" target=\"_blank\">More info</a>',\n\t\t\t\tname: 'webhookNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdisplayOptions: displayOnWebhook,\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'The form url will be generated at run time. It can be referenced with the <strong>$execution.resumeFormUrl</strong> variable. Send it somewhere before getting to this node. <a href=\"https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.wait/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.wait\" target=\"_blank\">More info</a>',\n\t\t\t\tname: 'formNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdisplayOptions: displayOnFormSubmission,\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t...onFormSubmitProperties,\n\t\t\t...onWebhookCallProperties,\n\t\t\t...waitTimeProperties,\n\t\t\t{\n\t\t\t\t...optionsProperty,\n\t\t\t\tdisplayOptions: displayOnWebhook,\n\t\t\t\toptions: [...(optionsProperty.options as INodeProperties[]), webhookSuffix],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tplaceholder: 'Add option',\n\t\t\t\tdefault: {},\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tresume: ['form'],\n\t\t\t\t\t},\n\t\t\t\t\thide: {\n\t\t\t\t\t\tresponseMode: ['responseNode'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\toptions: [appendAttributionToForm, respondWithOptions, webhookSuffix],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tplaceholder: 'Add option',\n\t\t\t\tdefault: {},\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tresume: ['form'],\n\t\t\t\t\t},\n\t\t\t\t\thide: {\n\t\t\t\t\t\tresponseMode: ['onReceived', 'lastNode'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\toptions: [appendAttributionToForm, webhookSuffix],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync webhook(context: IWebhookFunctions) {\n\t\tconst resume = context.getNodeParameter('resume', 0) as string;\n\t\tif (resume === 'form') return await formWebhook(context, this.authPropertyName);\n\t\treturn await super.webhook(context);\n\t}\n\n\tasync execute(context: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\tconst resume = context.getNodeParameter('resume', 0) as string;\n\n\t\tif (['webhook', 'form'].includes(resume)) {\n\t\t\tlet hasFormTrigger = false;\n\n\t\t\tif (resume === 'form') {\n\t\t\t\tconst parentNodes = context.getParentNodes(context.getNode().name);\n\t\t\t\thasFormTrigger = parentNodes.some((node) => node.type === FORM_TRIGGER_NODE_TYPE);\n\t\t\t}\n\n\t\t\tconst returnData = await this.configureAndPutToWait(context);\n\n\t\t\tif (resume === 'form' && hasFormTrigger) {\n\t\t\t\tcontext.sendResponse({\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tlocation: context.evaluateExpression('{{ $execution.resumeFormUrl }}', 0),\n\t\t\t\t\t},\n\t\t\t\t\tstatusCode: 307,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn returnData;\n\t\t}\n\n\t\tlet waitTill: Date;\n\t\tif (resume === 'timeInterval') {\n\t\t\tconst unit = context.getNodeParameter('unit', 0) as string;\n\n\t\t\tlet waitAmount = context.getNodeParameter('amount', 0) as number;\n\t\t\tif (unit === 'minutes') {\n\t\t\t\twaitAmount *= 60;\n\t\t\t}\n\t\t\tif (unit === 'hours') {\n\t\t\t\twaitAmount *= 60 * 60;\n\t\t\t}\n\t\t\tif (unit === 'days') {\n\t\t\t\twaitAmount *= 60 * 60 * 24;\n\t\t\t}\n\n\t\t\twaitAmount *= 1000;\n\n\t\t\t// Timezone does not change relative dates, since they are just\n\t\t\t// a number of seconds added to the current timestamp\n\t\t\twaitTill = new Date(new Date().getTime() + waitAmount);\n\t\t} else {\n\t\t\tconst dateTimeStr = context.getNodeParameter('dateTime', 0) as string;\n\n\t\t\tif (isNaN(Date.parse(dateTimeStr))) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tcontext.getNode(),\n\t\t\t\t\t'[Wait node] Cannot put execution to wait because `dateTime` parameter is not a valid date. Please pick a specific date and time to wait until.',\n\t\t\t\t);\n\t\t\t}\n\n\t\t\twaitTill = DateTime.fromFormat(dateTimeStr, \"yyyy-MM-dd'T'HH:mm:ss\", {\n\t\t\t\tzone: context.getTimezone(),\n\t\t\t})\n\t\t\t\t.toUTC()\n\t\t\t\t.toJSDate();\n\t\t}\n\n\t\tconst waitValue = Math.max(waitTill.getTime() - new Date().getTime(), 0);\n\n\t\tif (waitValue < 65000) {\n\t\t\t// If wait time is shorter than 65 seconds leave execution active because\n\t\t\t// we just check the database every 60 seconds.\n\t\t\treturn await new Promise((resolve) => {\n\t\t\t\tconst timer = setTimeout(() => resolve([context.getInputData()]), waitValue);\n\t\t\t\tcontext.onExecutionCancellation(() => clearTimeout(timer));\n\t\t\t});\n\t\t}\n\n\t\t// If longer than 65 seconds put execution to wait\n\t\treturn await this.putToWait(context, waitTill);\n\t}\n\n\tprivate async configureAndPutToWait(context: IExecuteFunctions) {\n\t\tlet waitTill = WAIT_INDEFINITELY;\n\t\tconst limitWaitTime = context.getNodeParameter('limitWaitTime', 0);\n\n\t\tif (limitWaitTime === true) {\n\t\t\tconst limitType = context.getNodeParameter('limitType', 0);\n\n\t\t\tif (limitType === 'afterTimeInterval') {\n\t\t\t\tlet waitAmount = context.getNodeParameter('resumeAmount', 0) as number;\n\t\t\t\tconst resumeUnit = context.getNodeParameter('resumeUnit', 0);\n\n\t\t\t\tif (resumeUnit === 'minutes') {\n\t\t\t\t\twaitAmount *= 60;\n\t\t\t\t}\n\t\t\t\tif (resumeUnit === 'hours') {\n\t\t\t\t\twaitAmount *= 60 * 60;\n\t\t\t\t}\n\t\t\t\tif (resumeUnit === 'days') {\n\t\t\t\t\twaitAmount *= 60 * 60 * 24;\n\t\t\t\t}\n\n\t\t\t\twaitAmount *= 1000;\n\t\t\t\twaitTill = new Date(new Date().getTime() + waitAmount);\n\t\t\t} else {\n\t\t\t\twaitTill = new Date(context.getNodeParameter('maxDateAndTime', 0) as string);\n\t\t\t}\n\t\t}\n\n\t\treturn await this.putToWait(context, waitTill);\n\t}\n\n\tprivate async putToWait(context: IExecuteFunctions, waitTill: Date) {\n\t\tawait context.putExecutionToWait(waitTill);\n\t\treturn [context.getInputData()];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyB;AASzB,0BAKO;AAEP,uBAAqC;AACrC,oBAOO;AACP,mBAA4B;AAC5B,yBAUO;AACP,qBAAwB;AAExB,MAAM,eAAgC;AAAA,EACrC,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,aAAa;AAAA,IACZ,UAAU;AAAA,IACV,iBAAiB;AAAA,EAClB;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AACd;AAEA,MAAM,eAAgC;AAAA,EACrC,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,IACR;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,IACR;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,IACR;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,IACR;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,IACR;AAAA,EACD;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AACd;AAEA,MAAM,qBAAwC;AAAA,EAC7C;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aACC;AAAA,IACD,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,QAAQ,CAAC,WAAW,MAAM;AAAA,MAC3B;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aACC;AAAA,IACD,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,eAAe,CAAC,IAAI;AAA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;AAGA,WAAO,MAAM,KAAK,UAAU,SAAS,QAAQ;AAAA,EAC9C;AAAA,EAEA,MAAc,sBAAsB,SAA4B;AAC/D,QAAI,WAAW;AACf,UAAM,gBAAgB,QAAQ,iBAAiB,iBAAiB,CAAC;AAEjE,QAAI,kBAAkB,MAAM;AAC3B,YAAM,YAAY,QAAQ,iBAAiB,aAAa,CAAC;AAEzD,UAAI,cAAc,qBAAqB;AACtC,YAAI,aAAa,QAAQ,iBAAiB,gBAAgB,CAAC;AAC3D,cAAM,aAAa,QAAQ,iBAAiB,cAAc,CAAC;AAE3D,YAAI,eAAe,WAAW;AAC7B,wBAAc;AAAA,QACf;AACA,YAAI,eAAe,SAAS;AAC3B,wBAAc,KAAK;AAAA,QACpB;AACA,YAAI,eAAe,QAAQ;AAC1B,wBAAc,KAAK,KAAK;AAAA,QACzB;AAEA,sBAAc;AACd,mBAAW,IAAI,MAAK,oBAAI,KAAK,GAAE,QAAQ,IAAI,UAAU;AAAA,MACtD,OAAO;AACN,mBAAW,IAAI,KAAK,QAAQ,iBAAiB,kBAAkB,CAAC,CAAW;AAAA,MAC5E;AAAA,IACD;AAEA,WAAO,MAAM,KAAK,UAAU,SAAS,QAAQ;AAAA,EAC9C;AAAA,EAEA,MAAc,UAAU,SAA4B,UAAgB;AACnE,UAAM,QAAQ,mBAAmB,QAAQ;AACzC,WAAO,CAAC,QAAQ,aAAa,CAAC;AAAA,EAC/B;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../nodes/Wait/Wait.node.ts"],"sourcesContent":["import type {\n\tIExecuteFunctions,\n\tINodeExecutionData,\n\tINodeTypeDescription,\n\tINodeProperties,\n\tIDisplayOptions,\n\tIWebhookFunctions,\n} from 'n8n-workflow';\nimport {\n\tNodeConnectionTypes,\n\tWAIT_INDEFINITELY,\n\tFORM_TRIGGER_NODE_TYPE,\n\ttryToParseDateTime,\n\tNodeOperationError,\n} from 'n8n-workflow';\n\nimport { updateDisplayOptions } from '../../utils/utilities';\nimport {\n\tformDescription,\n\tformFields,\n\trespondWithOptions,\n\tformRespondMode,\n\tformTitle,\n\tappendAttributionToForm,\n} from '../Form/common.descriptions';\nimport { formWebhook } from '../Form/utils';\nimport {\n\tauthenticationProperty,\n\tcredentialsProperty,\n\tdefaultWebhookDescription,\n\thttpMethodsProperty,\n\toptionsProperty,\n\tresponseBinaryPropertyNameProperty,\n\tresponseCodeProperty,\n\tresponseDataProperty,\n\tresponseModeProperty,\n} from '../Webhook/description';\nimport { Webhook } from '../Webhook/Webhook.node';\n\nconst toWaitAmount: INodeProperties = {\n\tdisplayName: 'Wait Amount',\n\tname: 'amount',\n\ttype: 'number',\n\ttypeOptions: {\n\t\tminValue: 0,\n\t\tnumberPrecision: 2,\n\t},\n\tdefault: 1,\n\tdescription: 'The time to wait',\n};\n\nconst unitSelector: INodeProperties = {\n\tdisplayName: 'Wait Unit',\n\tname: 'unit',\n\ttype: 'options',\n\toptions: [\n\t\t{\n\t\t\tname: 'Seconds',\n\t\t\tvalue: 'seconds',\n\t\t},\n\t\t{\n\t\t\tname: 'Minutes',\n\t\t\tvalue: 'minutes',\n\t\t},\n\t\t{\n\t\t\tname: 'Hours',\n\t\t\tvalue: 'hours',\n\t\t},\n\t\t{\n\t\t\tname: 'Days',\n\t\t\tvalue: 'days',\n\t\t},\n\t],\n\tdefault: 'hours',\n\tdescription: 'The time unit of the Wait Amount value',\n};\n\nconst waitTimeProperties: INodeProperties[] = [\n\t{\n\t\tdisplayName: 'Limit Wait Time',\n\t\tname: 'limitWaitTime',\n\t\ttype: 'boolean',\n\t\tdefault: false,\n\t\tdescription:\n\t\t\t'Whether to limit the time this node should wait for a user response before execution resumes',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tresume: ['webhook', 'form'],\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Limit Type',\n\t\tname: 'limitType',\n\t\ttype: 'options',\n\t\tdefault: 'afterTimeInterval',\n\t\tdescription:\n\t\t\t'Sets the condition for the execution to resume. Can be a specified date or after some time.',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tlimitWaitTime: [true],\n\t\t\t\tresume: ['webhook', 'form'],\n\t\t\t},\n\t\t},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'After Time Interval',\n\t\t\t\tdescription: 'Waits for a certain amount of time',\n\t\t\t\tvalue: 'afterTimeInterval',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'At Specified Time',\n\t\t\t\tdescription: 'Waits until the set date and time to continue',\n\t\t\t\tvalue: 'atSpecifiedTime',\n\t\t\t},\n\t\t],\n\t},\n\t{\n\t\tdisplayName: 'Amount',\n\t\tname: 'resumeAmount',\n\t\ttype: 'number',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tlimitType: ['afterTimeInterval'],\n\t\t\t\tlimitWaitTime: [true],\n\t\t\t\tresume: ['webhook', 'form'],\n\t\t\t},\n\t\t},\n\t\ttypeOptions: {\n\t\t\tminValue: 0,\n\t\t\tnumberPrecision: 2,\n\t\t},\n\t\tdefault: 1,\n\t\tdescription: 'The time to wait',\n\t},\n\t{\n\t\tdisplayName: 'Unit',\n\t\tname: 'resumeUnit',\n\t\ttype: 'options',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tlimitType: ['afterTimeInterval'],\n\t\t\t\tlimitWaitTime: [true],\n\t\t\t\tresume: ['webhook', 'form'],\n\t\t\t},\n\t\t},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tname: 'Seconds',\n\t\t\t\tvalue: 'seconds',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Minutes',\n\t\t\t\tvalue: 'minutes',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Hours',\n\t\t\t\tvalue: 'hours',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'Days',\n\t\t\t\tvalue: 'days',\n\t\t\t},\n\t\t],\n\t\tdefault: 'hours',\n\t\tdescription: 'Unit of the interval value',\n\t},\n\t{\n\t\tdisplayName: 'Max Date and Time',\n\t\tname: 'maxDateAndTime',\n\t\ttype: 'dateTime',\n\t\tdisplayOptions: {\n\t\t\tshow: {\n\t\t\t\tlimitType: ['atSpecifiedTime'],\n\t\t\t\tlimitWaitTime: [true],\n\t\t\t\tresume: ['webhook', 'form'],\n\t\t\t},\n\t\t},\n\t\tdefault: '',\n\t\tdescription: 'Continue execution after the specified date and time',\n\t},\n];\n\nconst webhookSuffix: INodeProperties = {\n\tdisplayName: 'Webhook Suffix',\n\tname: 'webhookSuffix',\n\ttype: 'string',\n\tdefault: '',\n\tplaceholder: 'webhook',\n\tnoDataExpression: true,\n\tdescription:\n\t\t'This suffix path will be appended to the restart URL. Helpful when using multiple wait nodes.',\n};\n\nconst displayOnWebhook: IDisplayOptions = {\n\tshow: {\n\t\tresume: ['webhook'],\n\t},\n};\n\nconst displayOnFormSubmission = {\n\tshow: {\n\t\tresume: ['form'],\n\t},\n};\n\nconst onFormSubmitProperties = updateDisplayOptions(displayOnFormSubmission, [\n\tformTitle,\n\tformDescription,\n\tformFields,\n\tformRespondMode,\n]);\n\nconst onWebhookCallProperties = updateDisplayOptions(displayOnWebhook, [\n\t{\n\t\t...httpMethodsProperty,\n\t\tdescription: 'The HTTP method of the Webhook call',\n\t},\n\tresponseCodeProperty,\n\tresponseModeProperty,\n\tresponseDataProperty,\n\tresponseBinaryPropertyNameProperty,\n]);\n\nconst webhookPath = '={{$parameter[\"options\"][\"webhookSuffix\"] || \"\"}}';\n\nexport class Wait extends Webhook {\n\tauthPropertyName = 'incomingAuthentication';\n\n\tdescription: INodeTypeDescription = {\n\t\tdisplayName: 'Wait',\n\t\tname: 'wait',\n\t\ticon: 'fa:pause-circle',\n\t\ticonColor: 'crimson',\n\t\tgroup: ['organization'],\n\t\tversion: [1, 1.1],\n\t\tdescription: 'Wait before continue with execution',\n\t\tdefaults: {\n\t\t\tname: 'Wait',\n\t\t\tcolor: '#804050',\n\t\t},\n\t\tinputs: [NodeConnectionTypes.Main],\n\t\toutputs: [NodeConnectionTypes.Main],\n\t\tcredentials: credentialsProperty(this.authPropertyName),\n\t\twebhooks: [\n\t\t\t{\n\t\t\t\t...defaultWebhookDescription,\n\t\t\t\tresponseData: '={{$parameter[\"responseData\"]}}',\n\t\t\t\tpath: webhookPath,\n\t\t\t\trestartWebhook: true,\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'default',\n\t\t\t\thttpMethod: 'GET',\n\t\t\t\tresponseMode: 'onReceived',\n\t\t\t\tpath: webhookPath,\n\t\t\t\trestartWebhook: true,\n\t\t\t\tisFullPath: true,\n\t\t\t\tnodeType: 'form',\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'default',\n\t\t\t\thttpMethod: 'POST',\n\t\t\t\tresponseMode: '={{$parameter[\"responseMode\"]}}',\n\t\t\t\tresponseData: '={{$parameter[\"responseMode\"] === \"lastNode\" ? \"noData\" : undefined}}',\n\t\t\t\tpath: webhookPath,\n\t\t\t\trestartWebhook: true,\n\t\t\t\tisFullPath: true,\n\t\t\t\tnodeType: 'form',\n\t\t\t},\n\t\t],\n\t\tproperties: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Resume',\n\t\t\t\tname: 'resume',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'After Time Interval',\n\t\t\t\t\t\tvalue: 'timeInterval',\n\t\t\t\t\t\tdescription: 'Waits for a certain amount of time',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'At Specified Time',\n\t\t\t\t\t\tvalue: 'specificTime',\n\t\t\t\t\t\tdescription: 'Waits until a specific date and time to continue',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'On Webhook Call',\n\t\t\t\t\t\tvalue: 'webhook',\n\t\t\t\t\t\tdescription: 'Waits for a webhook call before continuing',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'On Form Submitted',\n\t\t\t\t\t\tvalue: 'form',\n\t\t\t\t\t\tdescription: 'Waits for a form submission before continuing',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'timeInterval',\n\t\t\t\tdescription: 'Determines the waiting mode to use before the workflow continues',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Authentication',\n\t\t\t\tname: 'incomingAuthentication',\n\t\t\t\ttype: 'options',\n\t\t\t\toptions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'Basic Auth',\n\t\t\t\t\t\tvalue: 'basicAuth',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: 'None',\n\t\t\t\t\t\tvalue: 'none',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdefault: 'none',\n\t\t\t\tdescription:\n\t\t\t\t\t'If and how incoming resume-webhook-requests to $execution.resumeFormUrl should be authenticated for additional security',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tresume: ['form'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...authenticationProperty(this.authPropertyName),\n\t\t\t\tdescription:\n\t\t\t\t\t'If and how incoming resume-webhook-requests to $execution.resumeUrl should be authenticated for additional security',\n\t\t\t\tdisplayOptions: displayOnWebhook,\n\t\t\t},\n\n\t\t\t// ----------------------------------\n\t\t\t// resume:specificTime\n\t\t\t// ----------------------------------\n\t\t\t{\n\t\t\t\tdisplayName: 'Date and Time',\n\t\t\t\tname: 'dateTime',\n\t\t\t\ttype: 'dateTime',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tresume: ['specificTime'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tdefault: '',\n\t\t\t\tdescription: 'The date and time to wait for before continuing',\n\t\t\t\trequired: true,\n\t\t\t},\n\n\t\t\t// ----------------------------------\n\t\t\t// resume:timeInterval\n\t\t\t// ----------------------------------\n\t\t\t{\n\t\t\t\t...toWaitAmount,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tresume: ['timeInterval'],\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...toWaitAmount,\n\t\t\t\tdefault: 5,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tresume: ['timeInterval'],\n\t\t\t\t\t},\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...unitSelector,\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tresume: ['timeInterval'],\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\t...unitSelector,\n\t\t\t\tdefault: 'seconds',\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tresume: ['timeInterval'],\n\t\t\t\t\t},\n\t\t\t\t\thide: {\n\t\t\t\t\t\t'@version': [1],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\n\t\t\t// ----------------------------------\n\t\t\t// resume:webhook & form\n\t\t\t// ----------------------------------\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'The webhook URL will be generated at run time. It can be referenced with the <strong>$execution.resumeUrl</strong> variable. Send it somewhere before getting to this node. <a href=\"https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.wait/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.wait\" target=\"_blank\">More info</a>',\n\t\t\t\tname: 'webhookNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdisplayOptions: displayOnWebhook,\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName:\n\t\t\t\t\t'The form url will be generated at run time. It can be referenced with the <strong>$execution.resumeFormUrl</strong> variable. Send it somewhere before getting to this node. <a href=\"https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.wait/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.wait\" target=\"_blank\">More info</a>',\n\t\t\t\tname: 'formNotice',\n\t\t\t\ttype: 'notice',\n\t\t\t\tdisplayOptions: displayOnFormSubmission,\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t\t...onFormSubmitProperties,\n\t\t\t...onWebhookCallProperties,\n\t\t\t...waitTimeProperties,\n\t\t\t{\n\t\t\t\t...optionsProperty,\n\t\t\t\tdisplayOptions: displayOnWebhook,\n\t\t\t\toptions: [...(optionsProperty.options as INodeProperties[]), webhookSuffix],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tplaceholder: 'Add option',\n\t\t\t\tdefault: {},\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tresume: ['form'],\n\t\t\t\t\t},\n\t\t\t\t\thide: {\n\t\t\t\t\t\tresponseMode: ['responseNode'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\toptions: [appendAttributionToForm, respondWithOptions, webhookSuffix],\n\t\t\t},\n\t\t\t{\n\t\t\t\tdisplayName: 'Options',\n\t\t\t\tname: 'options',\n\t\t\t\ttype: 'collection',\n\t\t\t\tplaceholder: 'Add option',\n\t\t\t\tdefault: {},\n\t\t\t\tdisplayOptions: {\n\t\t\t\t\tshow: {\n\t\t\t\t\t\tresume: ['form'],\n\t\t\t\t\t},\n\t\t\t\t\thide: {\n\t\t\t\t\t\tresponseMode: ['onReceived', 'lastNode'],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\toptions: [appendAttributionToForm, webhookSuffix],\n\t\t\t},\n\t\t],\n\t};\n\n\tasync webhook(context: IWebhookFunctions) {\n\t\tconst resume = context.getNodeParameter('resume', 0) as string;\n\t\tif (resume === 'form') return await formWebhook(context, this.authPropertyName);\n\t\treturn await super.webhook(context);\n\t}\n\n\tasync execute(context: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\tconst resume = context.getNodeParameter('resume', 0) as string;\n\n\t\tif (['webhook', 'form'].includes(resume)) {\n\t\t\tlet hasFormTrigger = false;\n\n\t\t\tif (resume === 'form') {\n\t\t\t\tconst parentNodes = context.getParentNodes(context.getNode().name);\n\t\t\t\thasFormTrigger = parentNodes.some((node) => node.type === FORM_TRIGGER_NODE_TYPE);\n\t\t\t}\n\n\t\t\tconst returnData = await this.configureAndPutToWait(context);\n\n\t\t\tif (resume === 'form' && hasFormTrigger) {\n\t\t\t\tcontext.sendResponse({\n\t\t\t\t\theaders: {\n\t\t\t\t\t\tlocation: context.evaluateExpression('{{ $execution.resumeFormUrl }}', 0),\n\t\t\t\t\t},\n\t\t\t\t\tstatusCode: 307,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn returnData;\n\t\t}\n\n\t\tlet waitTill: Date;\n\t\tif (resume === 'timeInterval') {\n\t\t\tconst unit = context.getNodeParameter('unit', 0) as string;\n\n\t\t\tlet waitAmount = context.getNodeParameter('amount', 0) as number;\n\t\t\tif (unit === 'minutes') {\n\t\t\t\twaitAmount *= 60;\n\t\t\t}\n\t\t\tif (unit === 'hours') {\n\t\t\t\twaitAmount *= 60 * 60;\n\t\t\t}\n\t\t\tif (unit === 'days') {\n\t\t\t\twaitAmount *= 60 * 60 * 24;\n\t\t\t}\n\n\t\t\twaitAmount *= 1000;\n\n\t\t\t// Timezone does not change relative dates, since they are just\n\t\t\t// a number of seconds added to the current timestamp\n\t\t\twaitTill = new Date(new Date().getTime() + waitAmount);\n\t\t} else {\n\t\t\ttry {\n\t\t\t\tconst dateTimeStrRaw = context.getNodeParameter('dateTime', 0);\n\t\t\t\tconst parsedDateTime = tryToParseDateTime(dateTimeStrRaw, context.getTimezone());\n\n\t\t\t\twaitTill = parsedDateTime.toUTC().toJSDate();\n\t\t\t} catch (e) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tcontext.getNode(),\n\t\t\t\t\t'[Wait node] Cannot put execution to wait because `dateTime` parameter is not a valid date. Please pick a specific date and time to wait until.',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst waitValue = Math.max(waitTill.getTime() - new Date().getTime(), 0);\n\n\t\tif (waitValue < 65000) {\n\t\t\t// If wait time is shorter than 65 seconds leave execution active because\n\t\t\t// we just check the database every 60 seconds.\n\t\t\treturn await new Promise((resolve) => {\n\t\t\t\tconst timer = setTimeout(() => resolve([context.getInputData()]), waitValue);\n\t\t\t\tcontext.onExecutionCancellation(() => clearTimeout(timer));\n\t\t\t});\n\t\t}\n\n\t\t// If longer than 65 seconds put execution to wait\n\t\treturn await this.putToWait(context, waitTill);\n\t}\n\n\tprivate async configureAndPutToWait(context: IExecuteFunctions) {\n\t\tlet waitTill = WAIT_INDEFINITELY;\n\t\tconst limitWaitTime = context.getNodeParameter('limitWaitTime', 0);\n\n\t\tif (limitWaitTime === true) {\n\t\t\tconst limitType = context.getNodeParameter('limitType', 0);\n\n\t\t\tif (limitType === 'afterTimeInterval') {\n\t\t\t\tlet waitAmount = context.getNodeParameter('resumeAmount', 0) as number;\n\t\t\t\tconst resumeUnit = context.getNodeParameter('resumeUnit', 0);\n\n\t\t\t\tif (resumeUnit === 'minutes') {\n\t\t\t\t\twaitAmount *= 60;\n\t\t\t\t}\n\t\t\t\tif (resumeUnit === 'hours') {\n\t\t\t\t\twaitAmount *= 60 * 60;\n\t\t\t\t}\n\t\t\t\tif (resumeUnit === 'days') {\n\t\t\t\t\twaitAmount *= 60 * 60 * 24;\n\t\t\t\t}\n\n\t\t\t\twaitAmount *= 1000;\n\t\t\t\twaitTill = new Date(new Date().getTime() + waitAmount);\n\t\t\t} else {\n\t\t\t\twaitTill = new Date(context.getNodeParameter('maxDateAndTime', 0) as string);\n\t\t\t}\n\t\t}\n\n\t\treturn await this.putToWait(context, waitTill);\n\t}\n\n\tprivate async putToWait(context: IExecuteFunctions, waitTill: Date) {\n\t\tawait context.putExecutionToWait(waitTill);\n\t\treturn [context.getInputData()];\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,0BAMO;AAEP,uBAAqC;AACrC,oBAOO;AACP,mBAA4B;AAC5B,yBAUO;AACP,qBAAwB;AAExB,MAAM,eAAgC;AAAA,EACrC,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,aAAa;AAAA,IACZ,UAAU;AAAA,IACV,iBAAiB;AAAA,EAClB;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AACd;AAEA,MAAM,eAAgC;AAAA,EACrC,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,SAAS;AAAA,IACR;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,IACR;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,IACR;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,IACR;AAAA,IACA;AAAA,MACC,MAAM;AAAA,MACN,OAAO;AAAA,IACR;AAAA,EACD;AAAA,EACA,SAAS;AAAA,EACT,aAAa;AACd;AAEA,MAAM,qBAAwC;AAAA,EAC7C;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aACC;AAAA,IACD,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,QAAQ,CAAC,WAAW,MAAM;AAAA,MAC3B;AAAA,IACD;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aACC;AAAA,IACD,gBAAgB;AAAA,MACf,MAAM;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ACF;AAGA,WAAO,MAAM,KAAK,UAAU,SAAS,QAAQ;AAAA,EAC9C;AAAA,EAEA,MAAc,sBAAsB,SAA4B;AAC/D,QAAI,WAAW;AACf,UAAM,gBAAgB,QAAQ,iBAAiB,iBAAiB,CAAC;AAEjE,QAAI,kBAAkB,MAAM;AAC3B,YAAM,YAAY,QAAQ,iBAAiB,aAAa,CAAC;AAEzD,UAAI,cAAc,qBAAqB;AACtC,YAAI,aAAa,QAAQ,iBAAiB,gBAAgB,CAAC;AAC3D,cAAM,aAAa,QAAQ,iBAAiB,cAAc,CAAC;AAE3D,YAAI,eAAe,WAAW;AAC7B,wBAAc;AAAA,QACf;AACA,YAAI,eAAe,SAAS;AAC3B,wBAAc,KAAK;AAAA,QACpB;AACA,YAAI,eAAe,QAAQ;AAC1B,wBAAc,KAAK,KAAK;AAAA,QACzB;AAEA,sBAAc;AACd,mBAAW,IAAI,MAAK,oBAAI,KAAK,GAAE,QAAQ,IAAI,UAAU;AAAA,MACtD,OAAO;AACN,mBAAW,IAAI,KAAK,QAAQ,iBAAiB,kBAAkB,CAAC,CAAW;AAAA,MAC5E;AAAA,IACD;AAEA,WAAO,MAAM,KAAK,UAAU,SAAS,QAAQ;AAAA,EAC9C;AAAA,EAEA,MAAc,UAAU,SAA4B,UAAgB;AACnE,UAAM,QAAQ,mBAAmB,QAAQ;AACzC,WAAO,CAAC,QAAQ,aAAa,CAAC;AAAA,EAC/B;AACD;","names":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var credentials_exports = {};
|
|
20
|
+
__export(credentials_exports, {
|
|
21
|
+
credentials: () => credentials
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(credentials_exports);
|
|
24
|
+
const credentials = {
|
|
25
|
+
wordpressApi: {
|
|
26
|
+
url: "https://myblog.com",
|
|
27
|
+
allowUnauthorizedCerts: false,
|
|
28
|
+
username: "nodeqa",
|
|
29
|
+
password: "fake-password"
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
credentials
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../nodes/Wordpress/__tests__/workflow/credentials.ts"],"sourcesContent":["export const credentials = {\n\twordpressApi: {\n\t\turl: 'https://myblog.com',\n\t\tallowUnauthorizedCerts: false,\n\t\tusername: 'nodeqa',\n\t\tpassword: 'fake-password',\n\t},\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc;AAAA,EAC1B,cAAc;AAAA,IACb,KAAK;AAAA,IACL,wBAAwB;AAAA,IACxB,UAAU;AAAA,IACV,UAAU;AAAA,EACX;AACD;","names":[]}
|
package/dist/test/globalSetup.js
CHANGED
|
@@ -34,5 +34,8 @@ module.exports = __toCommonJS(globalSetup_exports);
|
|
|
34
34
|
var import_nock = __toESM(require("nock"));
|
|
35
35
|
var globalSetup_default = async () => {
|
|
36
36
|
import_nock.default.disableNetConnect();
|
|
37
|
+
import_nock.default.emitter.on("no match", (req) => {
|
|
38
|
+
console.error("No mock for network request: ", req);
|
|
39
|
+
});
|
|
37
40
|
};
|
|
38
41
|
//# sourceMappingURL=globalSetup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../test/globalSetup.ts"],"sourcesContent":["import nock from 'nock';\n\nexport default async () => {\n\tnock.disableNetConnect();\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,IAAO,sBAAQ,YAAY;AAC1B,cAAAA,QAAK,kBAAkB;
|
|
1
|
+
{"version":3,"sources":["../../test/globalSetup.ts"],"sourcesContent":["import nock from 'nock';\n\nexport default async () => {\n\tnock.disableNetConnect();\n\n\tnock.emitter.on('no match', (req) => {\n\t\tconsole.error('No mock for network request: ', req);\n\t});\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAEjB,IAAO,sBAAQ,YAAY;AAC1B,cAAAA,QAAK,kBAAkB;AAEvB,cAAAA,QAAK,QAAQ,GAAG,YAAY,CAAC,QAAQ;AACpC,YAAQ,MAAM,iCAAiC,GAAG;AAAA,EACnD,CAAC;AACF;","names":["nock"]}
|
|
@@ -38,9 +38,10 @@ var import_n8n_workflow = require("n8n-workflow");
|
|
|
38
38
|
var import_nock = __toESM(require("nock"));
|
|
39
39
|
var import_credentials_helper = require("./credentials-helper");
|
|
40
40
|
var import_node_types = require("./node-types");
|
|
41
|
-
var import_Helpers = require("./Helpers");
|
|
42
41
|
async function executeWorkflow(testData) {
|
|
43
42
|
const nodeTypes = import_di.Container.get(import_node_types.NodeTypes);
|
|
43
|
+
const credentialsHelper = import_di.Container.get(import_credentials_helper.CredentialsHelper);
|
|
44
|
+
credentialsHelper.setCredentials(testData.credentials ?? {});
|
|
44
45
|
if (testData.nock) {
|
|
45
46
|
const { baseUrl, mocks } = testData.nock;
|
|
46
47
|
const agent = (0, import_nock.default)(baseUrl);
|
|
@@ -81,11 +82,11 @@ async function executeWorkflow(testData) {
|
|
|
81
82
|
});
|
|
82
83
|
hooks.addHandler("workflowExecuteAfter", (fullRunData) => waitPromise.resolve(fullRunData));
|
|
83
84
|
const additionalData = (0, import_jest_mock_extended.mock)({
|
|
84
|
-
credentialsHelper: import_di.Container.get(import_credentials_helper.CredentialsHelper),
|
|
85
85
|
hooks,
|
|
86
86
|
// Get from node.parameters
|
|
87
87
|
currentNodeParameters: void 0
|
|
88
88
|
});
|
|
89
|
+
additionalData.credentialsHelper = credentialsHelper;
|
|
89
90
|
let executionData;
|
|
90
91
|
const runExecutionData = {
|
|
91
92
|
resultData: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../test/nodes/ExecuteWorkflow.ts"],"sourcesContent":["import { Container } from '@n8n/di';\nimport { mock } from 'jest-mock-extended';\nimport { ExecutionLifecycleHooks, WorkflowExecute } from 'n8n-core';\nimport type {\n\tIRun,\n\tIRunExecutionData,\n\tIWorkflowExecuteAdditionalData,\n\tWorkflowTestData,\n} from 'n8n-workflow';\nimport { createDeferredPromise, Workflow } from 'n8n-workflow';\nimport nock from 'nock';\n\nimport { CredentialsHelper } from './credentials-helper';\nimport { NodeTypes } from './node-types';\n\
|
|
1
|
+
{"version":3,"sources":["../../../test/nodes/ExecuteWorkflow.ts"],"sourcesContent":["import { Container } from '@n8n/di';\nimport { mock } from 'jest-mock-extended';\nimport { ExecutionLifecycleHooks, WorkflowExecute } from 'n8n-core';\nimport type {\n\tIRun,\n\tIRunExecutionData,\n\tIWorkflowExecuteAdditionalData,\n\tWorkflowTestData,\n} from 'n8n-workflow';\nimport { createDeferredPromise, Workflow } from 'n8n-workflow';\nimport nock from 'nock';\n\nimport { CredentialsHelper } from './credentials-helper';\nimport { NodeTypes } from './node-types';\n\nexport async function executeWorkflow(testData: WorkflowTestData) {\n\tconst nodeTypes = Container.get(NodeTypes);\n\n\tconst credentialsHelper = Container.get(CredentialsHelper);\n\tcredentialsHelper.setCredentials(testData.credentials ?? {});\n\n\tif (testData.nock) {\n\t\tconst { baseUrl, mocks } = testData.nock;\n\t\tconst agent = nock(baseUrl);\n\t\tmocks.forEach(\n\t\t\t({\n\t\t\t\tmethod,\n\t\t\t\tpath,\n\t\t\t\tstatusCode,\n\t\t\t\trequestBody,\n\t\t\t\trequestHeaders,\n\t\t\t\tresponseBody,\n\t\t\t\tresponseHeaders,\n\t\t\t}) => {\n\t\t\t\tlet mock = agent[method](path, requestBody);\n\n\t\t\t\t// nock interceptor reqheaders option is ignored, so we chain matchHeader()\n\t\t\t\t// agent[method](path, requestBody, { reqheaders: requestHeaders }).reply(statusCode, responseBody, responseHeaders)\n\t\t\t\t// https://github.com/nock/nock/issues/2545\n\t\t\t\tif (requestHeaders && Object.keys(requestHeaders).length > 0) {\n\t\t\t\t\tObject.entries(requestHeaders).forEach(([key, value]) => {\n\t\t\t\t\t\tmock = mock.matchHeader(key, value);\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tmock.reply(statusCode, responseBody, responseHeaders);\n\t\t\t},\n\t\t);\n\t}\n\n\tconst executionMode = testData.trigger?.mode ?? 'manual';\n\tconst workflowInstance = new Workflow({\n\t\tid: 'test',\n\t\tnodes: testData.input.workflowData.nodes,\n\t\tconnections: testData.input.workflowData.connections,\n\t\tactive: false,\n\t\tnodeTypes,\n\t\tsettings: testData.input.workflowData.settings,\n\t});\n\tconst waitPromise = createDeferredPromise<IRun>();\n\tconst nodeExecutionOrder: string[] = [];\n\n\tconst hooks = new ExecutionLifecycleHooks('trigger', '1', mock());\n\thooks.addHandler('nodeExecuteAfter', (nodeName) => {\n\t\tnodeExecutionOrder.push(nodeName);\n\t});\n\thooks.addHandler('workflowExecuteAfter', (fullRunData) => waitPromise.resolve(fullRunData));\n\n\tconst additionalData = mock<IWorkflowExecuteAdditionalData>({\n\t\thooks,\n\t\t// Get from node.parameters\n\t\tcurrentNodeParameters: undefined,\n\t});\n\tadditionalData.credentialsHelper = credentialsHelper;\n\n\tlet executionData: IRun;\n\tconst runExecutionData: IRunExecutionData = {\n\t\tresultData: {\n\t\t\trunData: {},\n\t\t},\n\t\texecutionData: {\n\t\t\tmetadata: {},\n\t\t\tcontextData: {},\n\t\t\twaitingExecution: {},\n\t\t\twaitingExecutionSource: null,\n\t\t\tnodeExecutionStack: [\n\t\t\t\t{\n\t\t\t\t\tnode: workflowInstance.getStartNode()!,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tmain: [[testData.trigger?.input ?? { json: {} }]],\n\t\t\t\t\t},\n\t\t\t\t\tsource: null,\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t};\n\tconst workflowExecute = new WorkflowExecute(additionalData, executionMode, runExecutionData);\n\texecutionData = await workflowExecute.processRunExecutionData(workflowInstance);\n\n\tconst result = await waitPromise.promise;\n\treturn { executionData, result, nodeExecutionOrder };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA0B;AAC1B,gCAAqB;AACrB,sBAAyD;AAOzD,0BAAgD;AAChD,kBAAiB;AAEjB,gCAAkC;AAClC,wBAA0B;AAE1B,eAAsB,gBAAgB,UAA4B;AACjE,QAAM,YAAY,oBAAU,IAAI,2BAAS;AAEzC,QAAM,oBAAoB,oBAAU,IAAI,2CAAiB;AACzD,oBAAkB,eAAe,SAAS,eAAe,CAAC,CAAC;AAE3D,MAAI,SAAS,MAAM;AAClB,UAAM,EAAE,SAAS,MAAM,IAAI,SAAS;AACpC,UAAM,YAAQ,YAAAA,SAAK,OAAO;AAC1B,UAAM;AAAA,MACL,CAAC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AA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AM,iBAAiB,aAAa;AAAA,UACpC,MAAM;AAAA,YACL,MAAM,CAAC,CAAC,SAAS,SAAS,SAAS,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;AAAA,UACjD;AAAA,UACA,QAAQ;AAAA,QACT;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACA,QAAM,kBAAkB,IAAI,gCAAgB,gBAAgB,eAAe,gBAAgB;AAC3F,kBAAgB,MAAM,gBAAgB,wBAAwB,gBAAgB;AAE9E,QAAM,SAAS,MAAM,YAAY;AACjC,SAAO,EAAE,eAAe,QAAQ,mBAAmB;AACpD;","names":["nock","mock"]}
|
|
@@ -33,7 +33,6 @@ __export(Helpers_exports, {
|
|
|
33
33
|
equalityTest: () => equalityTest,
|
|
34
34
|
getResultNodeData: () => getResultNodeData,
|
|
35
35
|
getWorkflowFilenames: () => getWorkflowFilenames,
|
|
36
|
-
initBinaryDataService: () => initBinaryDataService,
|
|
37
36
|
readJsonFileSync: () => readJsonFileSync,
|
|
38
37
|
testWorkflows: () => testWorkflows,
|
|
39
38
|
workflowToTests: () => workflowToTests
|
|
@@ -59,15 +58,6 @@ beforeEach(() => import_nock.default.disableNetConnect());
|
|
|
59
58
|
function createTemporaryDir(prefix = "n8n") {
|
|
60
59
|
return (0, import_fs.mkdtempSync)(import_path.default.join((0, import_os.tmpdir)(), prefix));
|
|
61
60
|
}
|
|
62
|
-
async function initBinaryDataService() {
|
|
63
|
-
const binaryDataService = new import_n8n_core.BinaryDataService();
|
|
64
|
-
await binaryDataService.init({
|
|
65
|
-
mode: "default",
|
|
66
|
-
availableModes: ["default"],
|
|
67
|
-
localStoragePath: createTemporaryDir()
|
|
68
|
-
});
|
|
69
|
-
import_di.Container.set(import_n8n_core.BinaryDataService, binaryDataService);
|
|
70
|
-
}
|
|
71
61
|
function getResultNodeData(result, testData) {
|
|
72
62
|
return Object.keys(testData.output.nodeData).map((nodeName) => {
|
|
73
63
|
const error = result.data.resultData.error;
|
|
@@ -132,7 +122,7 @@ const preparePinData = (pinData) => {
|
|
|
132
122
|
);
|
|
133
123
|
return returnData;
|
|
134
124
|
};
|
|
135
|
-
const workflowToTests = (workflowFiles) => {
|
|
125
|
+
const workflowToTests = (workflowFiles, credentials) => {
|
|
136
126
|
const testCases = [];
|
|
137
127
|
for (const filePath of workflowFiles) {
|
|
138
128
|
const description = filePath.replace(".json", "");
|
|
@@ -156,12 +146,12 @@ const workflowToTests = (workflowFiles) => {
|
|
|
156
146
|
delete workflowData.trigger;
|
|
157
147
|
const input = { workflowData };
|
|
158
148
|
const output = { nodeData };
|
|
159
|
-
testCases.push({ description, input, output, trigger });
|
|
149
|
+
testCases.push({ description, input, output, trigger, credentials });
|
|
160
150
|
}
|
|
161
151
|
return testCases;
|
|
162
152
|
};
|
|
163
|
-
const testWorkflows = (workflows) => {
|
|
164
|
-
const tests = workflowToTests(workflows);
|
|
153
|
+
const testWorkflows = (workflows, credentials) => {
|
|
154
|
+
const tests = workflowToTests(workflows, credentials);
|
|
165
155
|
for (const testData of tests) {
|
|
166
156
|
test(testData.description, async () => await equalityTest(testData));
|
|
167
157
|
}
|
|
@@ -202,7 +192,6 @@ const createMockExecuteFunction = (nodeParameters, nodeMock, continueBool = fals
|
|
|
202
192
|
equalityTest,
|
|
203
193
|
getResultNodeData,
|
|
204
194
|
getWorkflowFilenames,
|
|
205
|
-
initBinaryDataService,
|
|
206
195
|
readJsonFileSync,
|
|
207
196
|
testWorkflows,
|
|
208
197
|
workflowToTests
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../test/nodes/Helpers.ts"],"sourcesContent":["import { Container } from '@n8n/di';\nimport { readFileSync, readdirSync, mkdtempSync } from 'fs';\nimport { get } from 'lodash';\nimport { isEmpty } from 'lodash';\nimport { BinaryDataService, constructExecutionMetaData } from 'n8n-core';\nimport type {\n\tIDataObject,\n\tIExecuteFunctions,\n\tIGetNodeParameterOptions,\n\tINode,\n\tIRun,\n\tIWorkflowBase,\n\tWorkflowTestData,\n} from 'n8n-workflow';\nimport { ApplicationError } from 'n8n-workflow';\nimport nock from 'nock';\nimport { tmpdir } from 'os';\nimport path from 'path';\n\nimport { executeWorkflow } from './ExecuteWorkflow';\nimport { LoadNodesAndCredentials } from './load-nodes-and-credentials';\n\nconst baseDir = path.resolve(__dirname, '../..');\n\nexport const readJsonFileSync = <T = any>(filePath: string) =>\n\tJSON.parse(readFileSync(path.join(baseDir, filePath), 'utf-8')) as T;\n\nconst loadNodesAndCredentials = new LoadNodesAndCredentials(baseDir);\nContainer.set(LoadNodesAndCredentials, loadNodesAndCredentials);\n\nbeforeAll(async () => await loadNodesAndCredentials.init());\nbeforeEach(() => nock.disableNetConnect());\n\nexport function createTemporaryDir(prefix = 'n8n') {\n\treturn mkdtempSync(path.join(tmpdir(), prefix));\n}\n\nexport async function initBinaryDataService() {\n\tconst binaryDataService = new BinaryDataService();\n\tawait binaryDataService.init({\n\t\tmode: 'default',\n\t\tavailableModes: ['default'],\n\t\tlocalStoragePath: createTemporaryDir(),\n\t});\n\tContainer.set(BinaryDataService, binaryDataService);\n}\n\nexport function getResultNodeData(result: IRun, testData: WorkflowTestData) {\n\treturn Object.keys(testData.output.nodeData).map((nodeName) => {\n\t\tconst error = result.data.resultData.error;\n\t\t// If there was an error running the workflow throw it for easier debugging\n\t\t// and to surface all issues\n\t\tif (error?.cause) throw error.cause;\n\t\tif (error) throw error;\n\n\t\tif (result.data.resultData.runData[nodeName] === undefined) {\n\t\t\t// log errors from other nodes\n\t\t\tObject.keys(result.data.resultData.runData).forEach((key) => {\n\t\t\t\tconst error = result.data.resultData.runData[key][0]?.error;\n\t\t\t\tif (error) {\n\t\t\t\t\tconsole.log(`Node ${key}\\n`, error);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tthrow new ApplicationError(`Data for node \"${nodeName}\" is missing!`, { level: 'warning' });\n\t\t}\n\t\tconst resultData = result.data.resultData.runData[nodeName].map((nodeData) => {\n\t\t\tif (nodeData.data === undefined) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn nodeData.data.main[0]!.map((entry) => {\n\t\t\t\tif (entry.binary && isEmpty(entry.binary)) delete entry.binary;\n\t\t\t\tdelete entry.pairedItem;\n\t\t\t\treturn entry;\n\t\t\t});\n\t\t});\n\t\treturn {\n\t\t\tnodeName,\n\t\t\tresultData,\n\t\t};\n\t});\n}\n\nexport const equalityTest = async (testData: WorkflowTestData) => {\n\t// execute workflow\n\tconst { result } = await executeWorkflow(testData);\n\n\t// check if result node data matches expected test data\n\tconst resultNodeData = getResultNodeData(result, testData);\n\tresultNodeData.forEach(({ nodeName, resultData }) => {\n\t\tconst msg = `Equality failed for \"${testData.description}\" at node \"${nodeName}\"`;\n\t\tresultData.forEach((item) => {\n\t\t\titem?.forEach(({ binary, json }) => {\n\t\t\t\tif (binary) {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tdelete binary.data.data;\n\t\t\t\t\tdelete binary.data.directory;\n\t\t\t\t}\n\n\t\t\t\t// Convert errors to JSON so tests can compare\n\t\t\t\tif (json?.error instanceof Error) {\n\t\t\t\t\tjson.error = JSON.parse(\n\t\t\t\t\t\tJSON.stringify(json.error, ['message', 'name', 'description', 'context']),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t\treturn expect(resultData, msg).toEqual(testData.output.nodeData[nodeName]);\n\t});\n\n\texpect(result.finished || result.status === 'waiting').toEqual(true);\n};\n\nconst preparePinData = (pinData: IDataObject) => {\n\tconst returnData = Object.keys(pinData).reduce(\n\t\t(acc, key) => {\n\t\t\tconst data = pinData[key] as IDataObject[];\n\t\t\tacc[key] = [data];\n\t\t\treturn acc;\n\t\t},\n\t\t{} as {\n\t\t\t[key: string]: IDataObject[][];\n\t\t},\n\t);\n\treturn returnData;\n};\n\nexport const workflowToTests = (workflowFiles: string[]) => {\n\tconst testCases: WorkflowTestData[] = [];\n\tfor (const filePath of workflowFiles) {\n\t\tconst description = filePath.replace('.json', '');\n\t\tconst workflowData = readJsonFileSync<IWorkflowBase & Pick<WorkflowTestData, 'trigger'>>(\n\t\t\tfilePath,\n\t\t);\n\t\tconst testDir = path.join(baseDir, path.dirname(filePath));\n\t\tworkflowData.nodes.forEach((node) => {\n\t\t\tif (node.parameters) {\n\t\t\t\tnode.parameters = JSON.parse(\n\t\t\t\t\tJSON.stringify(node.parameters).replace(/\"C:\\\\\\\\Test\\\\\\\\(.*)\"/, `\"${testDir}/$1\"`),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t\tif (workflowData.pinData === undefined) {\n\t\t\tthrow new ApplicationError('Workflow data does not contain pinData', { level: 'warning' });\n\t\t}\n\n\t\tconst nodeData = preparePinData(workflowData.pinData);\n\t\tdelete workflowData.pinData;\n\n\t\tconst { trigger } = workflowData;\n\t\tdelete workflowData.trigger;\n\n\t\tconst input = { workflowData };\n\t\tconst output = { nodeData };\n\n\t\ttestCases.push({ description, input, output, trigger });\n\t}\n\treturn testCases;\n};\n\nexport const testWorkflows = (workflows: string[]) => {\n\tconst tests = workflowToTests(workflows);\n\n\tfor (const testData of tests) {\n\t\ttest(testData.description, async () => await equalityTest(testData));\n\t}\n};\n\nexport const getWorkflowFilenames = (dirname: string) => {\n\tconst workflows: string[] = [];\n\n\tconst filenames = readdirSync(dirname);\n\tconst testFolder = dirname.split(`${path.sep}nodes-base${path.sep}`)[1];\n\tfilenames.forEach((file) => {\n\t\tif (file.endsWith('.json')) {\n\t\t\tworkflows.push(path.join(testFolder, file));\n\t\t}\n\t});\n\n\treturn workflows;\n};\n\nexport const createMockExecuteFunction = <T = IExecuteFunctions>(\n\tnodeParameters: IDataObject,\n\tnodeMock: INode,\n\tcontinueBool = false,\n) => {\n\tconst fakeExecuteFunction = {\n\t\tgetNodeParameter(\n\t\t\tparameterName: string,\n\t\t\t_itemIndex: number,\n\t\t\tfallbackValue?: IDataObject | undefined,\n\t\t\toptions?: IGetNodeParameterOptions | undefined,\n\t\t) {\n\t\t\tconst parameter = options?.extractValue ? `${parameterName}.value` : parameterName;\n\t\t\treturn get(nodeParameters, parameter, fallbackValue);\n\t\t},\n\t\tgetNode() {\n\t\t\treturn nodeMock;\n\t\t},\n\t\tcontinueOnFail() {\n\t\t\treturn continueBool;\n\t\t},\n\t\thelpers: {\n\t\t\tconstructExecutionMetaData,\n\t\t},\n\t} as unknown as T;\n\treturn fakeExecuteFunction;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA0B;AAC1B,gBAAuD;AACvD,oBAAoB;AACpB,IAAAA,iBAAwB;AACxB,sBAA8D;AAU9D,0BAAiC;AACjC,kBAAiB;AACjB,gBAAuB;AACvB,kBAAiB;AAEjB,6BAAgC;AAChC,wCAAwC;AAExC,MAAM,UAAU,YAAAC,QAAK,QAAQ,WAAW,OAAO;AAExC,MAAM,mBAAmB,CAAU,aACzC,KAAK,UAAM,wBAAa,YAAAA,QAAK,KAAK,SAAS,QAAQ,GAAG,OAAO,CAAC;AAE/D,MAAM,0BAA0B,IAAI,0DAAwB,OAAO;AACnE,oBAAU,IAAI,2DAAyB,uBAAuB;AAE9D,UAAU,YAAY,MAAM,wBAAwB,KAAK,CAAC;AAC1D,WAAW,MAAM,YAAAC,QAAK,kBAAkB,CAAC;AAElC,SAAS,mBAAmB,SAAS,OAAO;AAClD,aAAO,uBAAY,YAAAD,QAAK,SAAK,kBAAO,GAAG,MAAM,CAAC;AAC/C;AAEA,eAAsB,wBAAwB;AAC7C,QAAM,oBAAoB,IAAI,kCAAkB;AAChD,QAAM,kBAAkB,KAAK;AAAA,IAC5B,MAAM;AAAA,IACN,gBAAgB,CAAC,SAAS;AAAA,IAC1B,kBAAkB,mBAAmB;AAAA,EACtC,CAAC;AACD,sBAAU,IAAI,mCAAmB,iBAAiB;AACnD;AAEO,SAAS,kBAAkB,QAAc,UAA4B;AAC3E,SAAO,OAAO,KAAK,SAAS,OAA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;AACpD,WAAO,aAAa;AAEpB,UAAM,EAAE,QAAQ,IAAI;AACpB,WAAO,aAAa;AAEpB,UAAM,QAAQ,EAAE,aAAa;AAC7B,UAAM,SAAS,EAAE,SAAS;AAE1B,cAAU,KAAK,EAAE,aAAa,OAAO,QAAQ,QAAQ,CAAC;AAAA,EACvD;AACA,SAAO;AACR;AAEO,MAAM,gBAAgB,CAAC,cAAwB;AACrD,QAAM,QAAQ,gBAAgB,SAAS;AAEvC,aAAW,YAAY,OAAO;AAC7B,SAAK,SAAS,aAAa,YAAY,MAAM,aAAa,QAAQ,CAAC;AAAA,EACpE;AACD;AAEO,MAAM,uBAAuB,CAAC,YAAoB;AACxD,QAAM,YAAsB,CAAC;AAE7B,QAAM,gBAAY,uBAAY,OAAO;AACrC,QAAM,aAAa,QAAQ,MAAM,GAAG,YAAAA,QAAK,GAAG,aAAa,YAAAA,QAAK,GAAG,EAAE,EAAE,CAAC;AACtE,YAAU,QAAQ,CAAC,SAAS;AAC3B,QAAI,KAAK,SAAS,OAAO,GAAG;AAC3B,gBAAU,KAAK,YAAAA,QAAK,KAAK,YAAY,IAAI,CAAC;AAAA,IAC3C;AAAA,EACD,CAAC;AAED,SAAO;AACR;AAEO,MAAM,4BAA4B,CACxC,gBACA,UACA,eAAe,UACX;AACJ,QAAM,sBAAsB;AAAA,IAC3B,iBACC,eACA,YACA,eACA,SACC;AACD,YAAM,YAAY,SAAS,eAAe,GAAG,aAAa,WAAW;AACrE,iBAAO,mBAAI,gBAAgB,WAAW,aAAa;AAAA,IACpD;AAAA,IACA,UAAU;AACT,aAAO;AAAA,IACR;AAAA,IACA,iBAAiB;AAChB,aAAO;AAAA,IACR;AAAA,IACA,SAAS;AAAA,MACR;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;","names":["import_lodash","path","nock","error"]}
|
|
1
|
+
{"version":3,"sources":["../../../test/nodes/Helpers.ts"],"sourcesContent":["import { Container } from '@n8n/di';\nimport { readFileSync, readdirSync, mkdtempSync } from 'fs';\nimport { get } from 'lodash';\nimport { isEmpty } from 'lodash';\nimport { constructExecutionMetaData } from 'n8n-core';\nimport type {\n\tICredentialDataDecryptedObject,\n\tIDataObject,\n\tIExecuteFunctions,\n\tIGetNodeParameterOptions,\n\tINode,\n\tIRun,\n\tIWorkflowBase,\n\tWorkflowTestData,\n} from 'n8n-workflow';\nimport { ApplicationError } from 'n8n-workflow';\nimport nock from 'nock';\nimport { tmpdir } from 'os';\nimport path from 'path';\n\nimport { executeWorkflow } from './ExecuteWorkflow';\nimport { LoadNodesAndCredentials } from './load-nodes-and-credentials';\n\nconst baseDir = path.resolve(__dirname, '../..');\n\nexport const readJsonFileSync = <T = any>(filePath: string) =>\n\tJSON.parse(readFileSync(path.join(baseDir, filePath), 'utf-8')) as T;\n\nconst loadNodesAndCredentials = new LoadNodesAndCredentials(baseDir);\nContainer.set(LoadNodesAndCredentials, loadNodesAndCredentials);\n\nbeforeAll(async () => await loadNodesAndCredentials.init());\nbeforeEach(() => nock.disableNetConnect());\n\nexport function createTemporaryDir(prefix = 'n8n') {\n\treturn mkdtempSync(path.join(tmpdir(), prefix));\n}\n\nexport function getResultNodeData(result: IRun, testData: WorkflowTestData) {\n\treturn Object.keys(testData.output.nodeData).map((nodeName) => {\n\t\tconst error = result.data.resultData.error;\n\t\t// If there was an error running the workflow throw it for easier debugging\n\t\t// and to surface all issues\n\t\tif (error?.cause) throw error.cause;\n\t\tif (error) throw error;\n\n\t\tif (result.data.resultData.runData[nodeName] === undefined) {\n\t\t\t// log errors from other nodes\n\t\t\tObject.keys(result.data.resultData.runData).forEach((key) => {\n\t\t\t\tconst error = result.data.resultData.runData[key][0]?.error;\n\t\t\t\tif (error) {\n\t\t\t\t\tconsole.log(`Node ${key}\\n`, error);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tthrow new ApplicationError(`Data for node \"${nodeName}\" is missing!`, { level: 'warning' });\n\t\t}\n\t\tconst resultData = result.data.resultData.runData[nodeName].map((nodeData) => {\n\t\t\tif (nodeData.data === undefined) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn nodeData.data.main[0]!.map((entry) => {\n\t\t\t\tif (entry.binary && isEmpty(entry.binary)) delete entry.binary;\n\t\t\t\tdelete entry.pairedItem;\n\t\t\t\treturn entry;\n\t\t\t});\n\t\t});\n\t\treturn {\n\t\t\tnodeName,\n\t\t\tresultData,\n\t\t};\n\t});\n}\n\nexport const equalityTest = async (testData: WorkflowTestData) => {\n\t// execute workflow\n\tconst { result } = await executeWorkflow(testData);\n\n\t// check if result node data matches expected test data\n\tconst resultNodeData = getResultNodeData(result, testData);\n\tresultNodeData.forEach(({ nodeName, resultData }) => {\n\t\tconst msg = `Equality failed for \"${testData.description}\" at node \"${nodeName}\"`;\n\t\tresultData.forEach((item) => {\n\t\t\titem?.forEach(({ binary, json }) => {\n\t\t\t\tif (binary) {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tdelete binary.data.data;\n\t\t\t\t\tdelete binary.data.directory;\n\t\t\t\t}\n\n\t\t\t\t// Convert errors to JSON so tests can compare\n\t\t\t\tif (json?.error instanceof Error) {\n\t\t\t\t\tjson.error = JSON.parse(\n\t\t\t\t\t\tJSON.stringify(json.error, ['message', 'name', 'description', 'context']),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t\treturn expect(resultData, msg).toEqual(testData.output.nodeData[nodeName]);\n\t});\n\n\texpect(result.finished || result.status === 'waiting').toEqual(true);\n};\n\nconst preparePinData = (pinData: IDataObject) => {\n\tconst returnData = Object.keys(pinData).reduce(\n\t\t(acc, key) => {\n\t\t\tconst data = pinData[key] as IDataObject[];\n\t\t\tacc[key] = [data];\n\t\t\treturn acc;\n\t\t},\n\t\t{} as {\n\t\t\t[key: string]: IDataObject[][];\n\t\t},\n\t);\n\treturn returnData;\n};\n\nexport const workflowToTests = (\n\tworkflowFiles: string[],\n\tcredentials?: Record<string, ICredentialDataDecryptedObject>,\n) => {\n\tconst testCases: WorkflowTestData[] = [];\n\tfor (const filePath of workflowFiles) {\n\t\tconst description = filePath.replace('.json', '');\n\t\tconst workflowData = readJsonFileSync<IWorkflowBase & Pick<WorkflowTestData, 'trigger'>>(\n\t\t\tfilePath,\n\t\t);\n\t\tconst testDir = path.join(baseDir, path.dirname(filePath));\n\t\tworkflowData.nodes.forEach((node) => {\n\t\t\tif (node.parameters) {\n\t\t\t\tnode.parameters = JSON.parse(\n\t\t\t\t\tJSON.stringify(node.parameters).replace(/\"C:\\\\\\\\Test\\\\\\\\(.*)\"/, `\"${testDir}/$1\"`),\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\t\tif (workflowData.pinData === undefined) {\n\t\t\tthrow new ApplicationError('Workflow data does not contain pinData', { level: 'warning' });\n\t\t}\n\n\t\tconst nodeData = preparePinData(workflowData.pinData);\n\t\tdelete workflowData.pinData;\n\n\t\tconst { trigger } = workflowData;\n\t\tdelete workflowData.trigger;\n\n\t\tconst input = { workflowData };\n\t\tconst output = { nodeData };\n\n\t\ttestCases.push({ description, input, output, trigger, credentials });\n\t}\n\treturn testCases;\n};\n\nexport const testWorkflows = (\n\tworkflows: string[],\n\tcredentials?: Record<string, ICredentialDataDecryptedObject>,\n) => {\n\tconst tests = workflowToTests(workflows, credentials);\n\n\tfor (const testData of tests) {\n\t\ttest(testData.description, async () => await equalityTest(testData));\n\t}\n};\n\nexport const getWorkflowFilenames = (dirname: string) => {\n\tconst workflows: string[] = [];\n\n\tconst filenames = readdirSync(dirname);\n\tconst testFolder = dirname.split(`${path.sep}nodes-base${path.sep}`)[1];\n\tfilenames.forEach((file) => {\n\t\tif (file.endsWith('.json')) {\n\t\t\tworkflows.push(path.join(testFolder, file));\n\t\t}\n\t});\n\n\treturn workflows;\n};\n\nexport const createMockExecuteFunction = <T = IExecuteFunctions>(\n\tnodeParameters: IDataObject,\n\tnodeMock: INode,\n\tcontinueBool = false,\n) => {\n\tconst fakeExecuteFunction = {\n\t\tgetNodeParameter(\n\t\t\tparameterName: string,\n\t\t\t_itemIndex: number,\n\t\t\tfallbackValue?: IDataObject | undefined,\n\t\t\toptions?: IGetNodeParameterOptions | undefined,\n\t\t) {\n\t\t\tconst parameter = options?.extractValue ? `${parameterName}.value` : parameterName;\n\t\t\treturn get(nodeParameters, parameter, fallbackValue);\n\t\t},\n\t\tgetNode() {\n\t\t\treturn nodeMock;\n\t\t},\n\t\tcontinueOnFail() {\n\t\t\treturn continueBool;\n\t\t},\n\t\thelpers: {\n\t\t\tconstructExecutionMetaData,\n\t\t},\n\t} as unknown as T;\n\treturn fakeExecuteFunction;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA0B;AAC1B,gBAAuD;AACvD,oBAAoB;AACpB,IAAAA,iBAAwB;AACxB,sBAA2C;AAW3C,0BAAiC;AACjC,kBAAiB;AACjB,gBAAuB;AACvB,kBAAiB;AAEjB,6BAAgC;AAChC,wCAAwC;AAExC,MAAM,UAAU,YAAAC,QAAK,QAAQ,WAAW,OAAO;AAExC,MAAM,mBAAmB,CAAU,aACzC,KAAK,UAAM,wBAAa,YAAAA,QAAK,KAAK,SAAS,QAAQ,GAAG,OAAO,CAAC;AAE/D,MAAM,0BAA0B,IAAI,0DAAwB,OAAO;AACnE,oBAAU,IAAI,2DAAyB,uBAAuB;AAE9D,UAAU,YAAY,MAAM,wBAAwB,KAAK,CAAC;AAC1D,WAAW,MAAM,YAAAC,QAAK,kBAAkB,CAAC;AAElC,SAAS,mBAAmB,SAAS,OAAO;AAClD,aAAO,uBAAY,YAAAD,QAAK,SAAK,kBAAO,GAAG,MAAM,CAAC;AAC/C;AAEO,SAAS,kBAAkB,QAAc,UAA4B;AAC3E,SAAO,OAAO,KAAK,SAAS,OAAO,QAAQ,EAAE,IAAI,CAAC,aAAa;AAC9D,UAAM,QAAQ,OAAO,KAAK,WAAW;AAGrC,QAAI,OAAO,MAAO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E,aAAa;AAC7B,UAAM,SAAS,EAAE,SAAS;AAE1B,cAAU,KAAK,EAAE,aAAa,OAAO,QAAQ,SAAS,YAAY,CAAC;AAAA,EACpE;AACA,SAAO;AACR;AAEO,MAAM,gBAAgB,CAC5B,WACA,gBACI;AACJ,QAAM,QAAQ,gBAAgB,WAAW,WAAW;AAEpD,aAAW,YAAY,OAAO;AAC7B,SAAK,SAAS,aAAa,YAAY,MAAM,aAAa,QAAQ,CAAC;AAAA,EACpE;AACD;AAEO,MAAM,uBAAuB,CAAC,YAAoB;AACxD,QAAM,YAAsB,CAAC;AAE7B,QAAM,gBAAY,uBAAY,OAAO;AACrC,QAAM,aAAa,QAAQ,MAAM,GAAG,YAAAA,QAAK,GAAG,aAAa,YAAAA,QAAK,GAAG,EAAE,EAAE,CAAC;AACtE,YAAU,QAAQ,CAAC,SAAS;AAC3B,QAAI,KAAK,SAAS,OAAO,GAAG;AAC3B,gBAAU,KAAK,YAAAA,QAAK,KAAK,YAAY,IAAI,CAAC;AAAA,IAC3C;AAAA,EACD,CAAC;AAED,SAAO;AACR;AAEO,MAAM,4BAA4B,CACxC,gBACA,UACA,eAAe,UACX;AACJ,QAAM,sBAAsB;AAAA,IAC3B,iBACC,eACA,YACA,eACA,SACC;AACD,YAAM,YAAY,SAAS,eAAe,GAAG,aAAa,WAAW;AACrE,iBAAO,mBAAI,gBAAgB,WAAW,aAAa;AAAA,IACpD;AAAA,IACA,UAAU;AACT,aAAO;AAAA,IACR;AAAA,IACA,iBAAiB;AAChB,aAAO;AAAA,IACR;AAAA,IACA,SAAS;AAAA,MACR;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;","names":["import_lodash","path","nock","error"]}
|
|
@@ -94,6 +94,7 @@ async function testWebhookTriggerNode(Trigger, options = {}) {
|
|
|
94
94
|
const version = trigger.description.version;
|
|
95
95
|
const node = (0, import_merge.default)(
|
|
96
96
|
{
|
|
97
|
+
id: options.node?.id ?? "1",
|
|
97
98
|
type: trigger.description.name,
|
|
98
99
|
name: trigger.description.defaults.name ?? `Test Node (${trigger.description.name})`,
|
|
99
100
|
typeVersion: typeof version === "number" ? version : version.at(-1)
|
|
@@ -104,7 +105,8 @@ async function testWebhookTriggerNode(Trigger, options = {}) {
|
|
|
104
105
|
const scheduledTaskManager = new import_scheduled_task_manager.ScheduledTaskManager((0, import_jest_mock_extended.mock)());
|
|
105
106
|
const helpers = (0, import_jest_mock_extended.mock)({
|
|
106
107
|
returnJsonArray: import_n8n_core.returnJsonArray,
|
|
107
|
-
registerCron: (cronExpression, onTick) => scheduledTaskManager.registerCron(workflow, cronExpression, onTick)
|
|
108
|
+
registerCron: (cronExpression, onTick) => scheduledTaskManager.registerCron(workflow, cronExpression, onTick),
|
|
109
|
+
prepareBinaryData: options.helpers?.prepareBinaryData ?? jest.fn()
|
|
108
110
|
});
|
|
109
111
|
const request = (0, import_jest_mock_extended.mock)({
|
|
110
112
|
method: "GET",
|
|
@@ -121,13 +123,14 @@ async function testWebhookTriggerNode(Trigger, options = {}) {
|
|
|
121
123
|
getMode: () => options.mode ?? "trigger",
|
|
122
124
|
getInstanceId: () => "instanceId",
|
|
123
125
|
getBodyData: () => options.bodyData ?? {},
|
|
124
|
-
getHeaderData: () =>
|
|
126
|
+
getHeaderData: () => options.headerData ?? {},
|
|
125
127
|
getInputConnectionData: async () => ({}),
|
|
126
128
|
getNodeWebhookUrl: (name) => `/test-webhook-url/${name}`,
|
|
127
129
|
getParamsData: () => ({}),
|
|
128
130
|
getQueryData: () => ({}),
|
|
129
131
|
getRequestObject: () => request,
|
|
130
132
|
getResponseObject: () => response,
|
|
133
|
+
getWorkflow: () => options.workflow ?? (0, import_jest_mock_extended.mock)(),
|
|
131
134
|
getWebhookName: () => options.webhookName ?? "default",
|
|
132
135
|
getWorkflowStaticData: () => options.workflowStaticData ?? {},
|
|
133
136
|
getNodeParameter: (parameterName, fallback) => (0, import_get.default)(node.parameters, parameterName) ?? fallback,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../test/nodes/TriggerHelpers.ts"],"sourcesContent":["import type * as express from 'express';\nimport { mock } from 'jest-mock-extended';\nimport get from 'lodash/get';\nimport merge from 'lodash/merge';\nimport set from 'lodash/set';\nimport { PollContext, returnJsonArray } from 'n8n-core';\nimport type { InstanceSettings, ExecutionLifecycleHooks } from 'n8n-core';\nimport { ScheduledTaskManager } from 'n8n-core/dist/execution-engine/scheduled-task-manager';\nimport {\n\tcreateDeferredPromise,\n\ttype IBinaryData,\n\ttype ICredentialDataDecryptedObject,\n\ttype IDataObject,\n\ttype IHttpRequestOptions,\n\ttype INode,\n\ttype INodeType,\n\ttype INodeTypes,\n\ttype ITriggerFunctions,\n\ttype IWebhookFunctions,\n\ttype IWorkflowExecuteAdditionalData,\n\ttype NodeTypeAndVersion,\n\ttype VersionedNodeType,\n\ttype Workflow,\n} from 'n8n-workflow';\n\ntype MockDeepPartial<T> = Parameters<typeof mock<T>>[0];\n\ntype TestTriggerNodeOptions = {\n\tmode?: 'manual' | 'trigger';\n\tnode?: MockDeepPartial<INode>;\n\ttimezone?: string;\n\tworkflowStaticData?: IDataObject;\n\tcredential?: ICredentialDataDecryptedObject;\n};\n\ntype TestWebhookTriggerNodeOptions = TestTriggerNodeOptions & {\n\twebhookName?: string;\n\trequest?: MockDeepPartial<express.Request>;\n\tbodyData?: IDataObject;\n\tchildNodes?: NodeTypeAndVersion[];\n};\n\ntype TestPollingTriggerNodeOptions = TestTriggerNodeOptions & {};\n\nfunction getNodeVersion(Trigger: new () => VersionedNodeType, version?: number) {\n\tconst instance = new Trigger();\n\treturn instance.nodeVersions[version ?? instance.currentVersion];\n}\n\nexport async function testTriggerNode(\n\tTrigger: (new () => INodeType) | INodeType,\n\toptions: TestTriggerNodeOptions = {},\n) {\n\tconst trigger = 'description' in Trigger ? Trigger : new Trigger();\n\tconst emit: jest.MockedFunction<ITriggerFunctions['emit']> = jest.fn();\n\n\tconst timezone = options.timezone ?? 'Europe/Berlin';\n\tconst version = trigger.description.version;\n\tconst node = merge(\n\t\t{\n\t\t\ttype: trigger.description.name,\n\t\t\tname: trigger.description.defaults.name ?? `Test Node (${trigger.description.name})`,\n\t\t\ttypeVersion: typeof version === 'number' ? version : version.at(-1),\n\t\t} satisfies Partial<INode>,\n\t\toptions.node,\n\t) as INode;\n\tconst workflow = mock<Workflow>({ timezone: options.timezone ?? 'Europe/Berlin' });\n\n\tconst scheduledTaskManager = new ScheduledTaskManager(mock<InstanceSettings>());\n\tconst helpers = mock<ITriggerFunctions['helpers']>({\n\t\tcreateDeferredPromise,\n\t\treturnJsonArray,\n\t\tregisterCron: (cronExpression, onTick) =>\n\t\t\tscheduledTaskManager.registerCron(workflow, cronExpression, onTick),\n\t});\n\n\tconst triggerFunctions = mock<ITriggerFunctions>({\n\t\thelpers,\n\t\temit,\n\t\tgetTimezone: () => timezone,\n\t\tgetNode: () => node,\n\t\tgetCredentials: async <T extends object = ICredentialDataDecryptedObject>() =>\n\t\t\t(options.credential ?? {}) as T,\n\t\tgetMode: () => options.mode ?? 'trigger',\n\t\tgetWorkflowStaticData: () => options.workflowStaticData ?? {},\n\t\tgetNodeParameter: (parameterName, fallback) => get(node.parameters, parameterName) ?? fallback,\n\t});\n\n\tconst response = await trigger.trigger?.call(triggerFunctions);\n\n\tif (options.mode === 'manual') {\n\t\texpect(response?.manualTriggerFunction).toBeInstanceOf(Function);\n\t\tawait response?.manualTriggerFunction?.();\n\t}\n\n\treturn {\n\t\tclose: jest.fn(response?.closeFunction),\n\t\temit,\n\t};\n}\n\nexport async function testVersionedWebhookTriggerNode(\n\tTrigger: new () => VersionedNodeType,\n\tversion?: number,\n\toptions: TestWebhookTriggerNodeOptions = {},\n) {\n\treturn await testWebhookTriggerNode(getNodeVersion(Trigger, version), options);\n}\n\nexport async function testWebhookTriggerNode(\n\tTrigger: (new () => INodeType) | INodeType,\n\toptions: TestWebhookTriggerNodeOptions = {},\n) {\n\tconst trigger = 'description' in Trigger ? Trigger : new Trigger();\n\n\tconst timezone = options.timezone ?? 'Europe/Berlin';\n\tconst version = trigger.description.version;\n\tconst node = merge(\n\t\t{\n\t\t\ttype: trigger.description.name,\n\t\t\tname: trigger.description.defaults.name ?? `Test Node (${trigger.description.name})`,\n\t\t\ttypeVersion: typeof version === 'number' ? version : version.at(-1),\n\t\t} satisfies Partial<INode>,\n\t\toptions.node,\n\t) as INode;\n\tconst workflow = mock<Workflow>({ timezone: options.timezone ?? 'Europe/Berlin' });\n\n\tconst scheduledTaskManager = new ScheduledTaskManager(mock<InstanceSettings>());\n\tconst helpers = mock<ITriggerFunctions['helpers']>({\n\t\treturnJsonArray,\n\t\tregisterCron: (cronExpression, onTick) =>\n\t\t\tscheduledTaskManager.registerCron(workflow, cronExpression, onTick),\n\t});\n\n\tconst request = mock<express.Request>({\n\t\tmethod: 'GET',\n\t\t...options.request,\n\t});\n\tconst response = mock<express.Response>({ status: jest.fn(() => mock<express.Response>()) });\n\tconst webhookFunctions = mock<IWebhookFunctions>({\n\t\thelpers,\n\t\tnodeHelpers: {\n\t\t\tcopyBinaryFile: jest.fn(async () => mock<IBinaryData>()),\n\t\t},\n\t\tgetTimezone: () => timezone,\n\t\tgetNode: () => node,\n\t\tgetMode: () => options.mode ?? 'trigger',\n\t\tgetInstanceId: () => 'instanceId',\n\t\tgetBodyData: () => options.bodyData ?? {},\n\t\tgetHeaderData: () => ({}),\n\t\tgetInputConnectionData: async () => ({}),\n\t\tgetNodeWebhookUrl: (name) => `/test-webhook-url/${name}`,\n\t\tgetParamsData: () => ({}),\n\t\tgetQueryData: () => ({}),\n\t\tgetRequestObject: () => request,\n\t\tgetResponseObject: () => response,\n\t\tgetWebhookName: () => options.webhookName ?? 'default',\n\t\tgetWorkflowStaticData: () => options.workflowStaticData ?? {},\n\t\tgetNodeParameter: (parameterName, fallback) => get(node.parameters, parameterName) ?? fallback,\n\t\tgetChildNodes: () => options.childNodes ?? [],\n\t\tgetCredentials: async <T extends object = ICredentialDataDecryptedObject>() =>\n\t\t\t(options.credential ?? {}) as T,\n\t});\n\n\tconst responseData = await trigger.webhook?.call(webhookFunctions);\n\n\treturn {\n\t\tresponseData,\n\t\tresponse: webhookFunctions.getResponseObject(),\n\t};\n}\n\nexport async function testPollingTriggerNode(\n\tTrigger: (new () => INodeType) | INodeType,\n\toptions: TestPollingTriggerNodeOptions = {},\n) {\n\tconst trigger = 'description' in Trigger ? Trigger : new Trigger();\n\n\tconst timezone = options.timezone ?? 'Europe/Berlin';\n\tconst version = trigger.description.version;\n\tconst node = merge(\n\t\t{\n\t\t\ttype: trigger.description.name,\n\t\t\tname: trigger.description.defaults.name ?? `Test Node (${trigger.description.name})`,\n\t\t\ttypeVersion: typeof version === 'number' ? version : version.at(-1),\n\t\t\tcredentials: {},\n\t\t} satisfies Partial<INode>,\n\t\toptions.node,\n\t) as INode;\n\tconst workflow = mock<Workflow>({\n\t\ttimezone,\n\t\tnodeTypes: mock<INodeTypes>({\n\t\t\tgetByNameAndVersion: () => mock<INodeType>({ description: trigger.description }),\n\t\t}),\n\t\tgetStaticData: () => options.workflowStaticData ?? {},\n\t});\n\tconst mode = options.mode ?? 'trigger';\n\n\tconst pollContext = new PollContext(\n\t\tworkflow,\n\t\tnode,\n\t\tmock<IWorkflowExecuteAdditionalData>({\n\t\t\tcurrentNodeParameters: node.parameters,\n\t\t\tcredentialsHelper: mock<IWorkflowExecuteAdditionalData['credentialsHelper']>({\n\t\t\t\tgetParentTypes: () => [],\n\t\t\t\tauthenticate: async (_creds, _type, options) => {\n\t\t\t\t\tset(options, 'headers.authorization', 'mockAuth');\n\t\t\t\t\treturn options as IHttpRequestOptions;\n\t\t\t\t},\n\t\t\t}),\n\t\t\thooks: mock<ExecutionLifecycleHooks>(),\n\t\t}),\n\t\tmode,\n\t\t'init',\n\t);\n\n\tpollContext.getNode = () => node;\n\tpollContext.getCredentials = async <T extends object = ICredentialDataDecryptedObject>() =>\n\t\t(options.credential ?? {}) as T;\n\tpollContext.getNodeParameter = (parameterName, fallback) =>\n\t\tget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,QAAQ,YAAY;AAAA,MAC1B,MAAM,QAAQ,YAAY,SAAS,QAAQ,cAAc,QAAQ,YAAY,IAAI;AAAA,MACjF,aAAa,OAAO,YAAY,WAAW,UAAU,QAAQ,GAAG,EAAE;AAAA,MAClE,aAAa,CAAC;AAAA,IACf;AAAA,IACA,QAAQ;AAAA,EACT;AACA,QAAM,eAAW,gCAAe;AAAA,IAC/B;AAAA,IACA,eAAW,gCAAiB;AAAA,MAC3B,qBAAqB,UAAM,gCAAgB,EAAE,aAAa,QAAQ,YAAY,CAAC;AAAA,IAChF,CAAC;AAAA,IACD,eAAe,MAAM,QAAQ,sBAAsB,CAAC;AAAA,EACrD,CAAC;AACD,QAAM,OAAO,QAAQ,QAAQ;AAE7B,QAAM,cAAc,IAAI;AAAA,IACvB;AAAA,IACA;AAAA,QACA,gCAAqC;AAAA,MACpC,uBAAuB,KAAK;AAAA,MAC5B,uBAAmB,gCAA0D;AAAA,QAC5E,gBAAgB,MAAM,CAAC;AAAA,QACvB,cAAc,OAAO,QAAQ,OAAOE,aAAY;AAC/C,yBAAAC,SAAID,UAAS,yBAAyB,UAAU;AAChD,iBAAOA;AAAA,QACR;AAAA,MACD,CAAC;AAAA,MACD,WAAO,gCAA8B;AAAA,IACtC,CAAC;AAAA,IACD;AAAA,IACA;AAAA,EACD;AAEA,cAAY,UAAU,MAAM;AAC5B,cAAY,iBAAiB,YAC3B,QAAQ,cAAc,CAAC;AACzB,cAAY,mBAAmB,CAAC,eAAe,iBAC9C,WAAAD,SAAI,KAAK,YAAY,aAAa,KAAK;AAExC,QAAM,WAAW,MAAM,QAAQ,MAAM,KAAK,WAAW;AAErD,SAAO;AAAA,IACN;AAAA,EACD;AACD;","names":["merge","get","options","set"]}
|
|
1
|
+
{"version":3,"sources":["../../../test/nodes/TriggerHelpers.ts"],"sourcesContent":["import type * as express from 'express';\nimport { type IncomingHttpHeaders } from 'http';\nimport { mock } from 'jest-mock-extended';\nimport get from 'lodash/get';\nimport merge from 'lodash/merge';\nimport set from 'lodash/set';\nimport { PollContext, returnJsonArray } from 'n8n-core';\nimport type { InstanceSettings, ExecutionLifecycleHooks } from 'n8n-core';\nimport { ScheduledTaskManager } from 'n8n-core/dist/execution-engine/scheduled-task-manager';\nimport {\n\tcreateDeferredPromise,\n\ttype IBinaryData,\n\ttype ICredentialDataDecryptedObject,\n\ttype IDataObject,\n\ttype IHttpRequestOptions,\n\ttype INode,\n\ttype INodeType,\n\ttype INodeTypes,\n\ttype ITriggerFunctions,\n\ttype IWebhookFunctions,\n\ttype IWorkflowExecuteAdditionalData,\n\ttype NodeTypeAndVersion,\n\ttype VersionedNodeType,\n\ttype Workflow,\n} from 'n8n-workflow';\n\ntype MockDeepPartial<T> = Parameters<typeof mock<T>>[0];\n\ntype TestTriggerNodeOptions = {\n\tmode?: 'manual' | 'trigger';\n\tnode?: MockDeepPartial<INode>;\n\ttimezone?: string;\n\tworkflowStaticData?: IDataObject;\n\tcredential?: ICredentialDataDecryptedObject;\n\thelpers?: Partial<ITriggerFunctions['helpers']>;\n};\n\ntype TestWebhookTriggerNodeOptions = TestTriggerNodeOptions & {\n\twebhookName?: string;\n\trequest?: MockDeepPartial<express.Request>;\n\tbodyData?: IDataObject;\n\tchildNodes?: NodeTypeAndVersion[];\n\tworkflow?: Workflow;\n\theaderData?: IncomingHttpHeaders;\n};\n\ntype TestPollingTriggerNodeOptions = TestTriggerNodeOptions & {};\n\nfunction getNodeVersion(Trigger: new () => VersionedNodeType, version?: number) {\n\tconst instance = new Trigger();\n\treturn instance.nodeVersions[version ?? instance.currentVersion];\n}\n\nexport async function testTriggerNode(\n\tTrigger: (new () => INodeType) | INodeType,\n\toptions: TestTriggerNodeOptions = {},\n) {\n\tconst trigger = 'description' in Trigger ? Trigger : new Trigger();\n\tconst emit: jest.MockedFunction<ITriggerFunctions['emit']> = jest.fn();\n\n\tconst timezone = options.timezone ?? 'Europe/Berlin';\n\tconst version = trigger.description.version;\n\tconst node = merge(\n\t\t{\n\t\t\ttype: trigger.description.name,\n\t\t\tname: trigger.description.defaults.name ?? `Test Node (${trigger.description.name})`,\n\t\t\ttypeVersion: typeof version === 'number' ? version : version.at(-1),\n\t\t} satisfies Partial<INode>,\n\t\toptions.node,\n\t) as INode;\n\tconst workflow = mock<Workflow>({ timezone: options.timezone ?? 'Europe/Berlin' });\n\n\tconst scheduledTaskManager = new ScheduledTaskManager(mock<InstanceSettings>());\n\tconst helpers = mock<ITriggerFunctions['helpers']>({\n\t\tcreateDeferredPromise,\n\t\treturnJsonArray,\n\t\tregisterCron: (cronExpression, onTick) =>\n\t\t\tscheduledTaskManager.registerCron(workflow, cronExpression, onTick),\n\t});\n\n\tconst triggerFunctions = mock<ITriggerFunctions>({\n\t\thelpers,\n\t\temit,\n\t\tgetTimezone: () => timezone,\n\t\tgetNode: () => node,\n\t\tgetCredentials: async <T extends object = ICredentialDataDecryptedObject>() =>\n\t\t\t(options.credential ?? {}) as T,\n\t\tgetMode: () => options.mode ?? 'trigger',\n\t\tgetWorkflowStaticData: () => options.workflowStaticData ?? {},\n\t\tgetNodeParameter: (parameterName, fallback) => get(node.parameters, parameterName) ?? fallback,\n\t});\n\n\tconst response = await trigger.trigger?.call(triggerFunctions);\n\n\tif (options.mode === 'manual') {\n\t\texpect(response?.manualTriggerFunction).toBeInstanceOf(Function);\n\t\tawait response?.manualTriggerFunction?.();\n\t}\n\n\treturn {\n\t\tclose: jest.fn(response?.closeFunction),\n\t\temit,\n\t};\n}\n\nexport async function testVersionedWebhookTriggerNode(\n\tTrigger: new () => VersionedNodeType,\n\tversion?: number,\n\toptions: TestWebhookTriggerNodeOptions = {},\n) {\n\treturn await testWebhookTriggerNode(getNodeVersion(Trigger, version), options);\n}\n\nexport async function testWebhookTriggerNode(\n\tTrigger: (new () => INodeType) | INodeType,\n\toptions: TestWebhookTriggerNodeOptions = {},\n) {\n\tconst trigger = 'description' in Trigger ? Trigger : new Trigger();\n\n\tconst timezone = options.timezone ?? 'Europe/Berlin';\n\tconst version = trigger.description.version;\n\tconst node = merge(\n\t\t{\n\t\t\tid: options.node?.id ?? '1',\n\t\t\ttype: trigger.description.name,\n\t\t\tname: trigger.description.defaults.name ?? `Test Node (${trigger.description.name})`,\n\t\t\ttypeVersion: typeof version === 'number' ? version : version.at(-1),\n\t\t} satisfies Partial<INode>,\n\t\toptions.node,\n\t) as INode;\n\tconst workflow = mock<Workflow>({ timezone: options.timezone ?? 'Europe/Berlin' });\n\n\tconst scheduledTaskManager = new ScheduledTaskManager(mock<InstanceSettings>());\n\tconst helpers = mock<ITriggerFunctions['helpers']>({\n\t\treturnJsonArray,\n\t\tregisterCron: (cronExpression, onTick) =>\n\t\t\tscheduledTaskManager.registerCron(workflow, cronExpression, onTick),\n\t\tprepareBinaryData: options.helpers?.prepareBinaryData ?? jest.fn(),\n\t});\n\n\tconst request = mock<express.Request>({\n\t\tmethod: 'GET',\n\t\t...options.request,\n\t});\n\tconst response = mock<express.Response>({ status: jest.fn(() => mock<express.Response>()) });\n\tconst webhookFunctions = mock<IWebhookFunctions>({\n\t\thelpers,\n\t\tnodeHelpers: {\n\t\t\tcopyBinaryFile: jest.fn(async () => mock<IBinaryData>()),\n\t\t},\n\t\tgetTimezone: () => timezone,\n\t\tgetNode: () => node,\n\t\tgetMode: () => options.mode ?? 'trigger',\n\t\tgetInstanceId: () => 'instanceId',\n\t\tgetBodyData: () => options.bodyData ?? {},\n\t\tgetHeaderData: () => options.headerData ?? {},\n\t\tgetInputConnectionData: async () => ({}),\n\t\tgetNodeWebhookUrl: (name) => `/test-webhook-url/${name}`,\n\t\tgetParamsData: () => ({}),\n\t\tgetQueryData: () => ({}),\n\t\tgetRequestObject: () => request,\n\t\tgetResponseObject: () => response,\n\t\tgetWorkflow: () => options.workflow ?? mock<Workflow>(),\n\t\tgetWebhookName: () => options.webhookName ?? 'default',\n\t\tgetWorkflowStaticData: () => options.workflowStaticData ?? {},\n\t\tgetNodeParameter: (parameterName, fallback) => get(node.parameters, parameterName) ?? fallback,\n\t\tgetChildNodes: () => options.childNodes ?? [],\n\t\tgetCredentials: async <T extends object = ICredentialDataDecryptedObject>() =>\n\t\t\t(options.credential ?? {}) as T,\n\t});\n\n\tconst responseData = await trigger.webhook?.call(webhookFunctions);\n\n\treturn {\n\t\tresponseData,\n\t\tresponse: webhookFunctions.getResponseObject(),\n\t};\n}\n\nexport async function testPollingTriggerNode(\n\tTrigger: (new () => INodeType) | INodeType,\n\toptions: TestPollingTriggerNodeOptions = {},\n) {\n\tconst trigger = 'description' in Trigger ? Trigger : new Trigger();\n\n\tconst timezone = options.timezone ?? 'Europe/Berlin';\n\tconst version = trigger.description.version;\n\tconst node = merge(\n\t\t{\n\t\t\ttype: trigger.description.name,\n\t\t\tname: trigger.description.defaults.name ?? `Test Node (${trigger.description.name})`,\n\t\t\ttypeVersion: typeof version === 'number' ? version : version.at(-1),\n\t\t\tcredentials: {},\n\t\t} satisfies Partial<INode>,\n\t\toptions.node,\n\t) as INode;\n\tconst workflow = mock<Workflow>({\n\t\ttimezone,\n\t\tnodeTypes: mock<INodeTypes>({\n\t\t\tgetByNameAndVersion: () => mock<INodeType>({ description: trigger.description }),\n\t\t}),\n\t\tgetStaticData: () => options.workflowStaticData ?? {},\n\t});\n\tconst mode = options.mode ?? 'trigger';\n\n\tconst pollContext = new PollContext(\n\t\tworkflow,\n\t\tnode,\n\t\tmock<IWorkflowExecuteAdditionalData>({\n\t\t\tcurrentNodeParameters: node.parameters,\n\t\t\tcredentialsHelper: mock<IWorkflowExecuteAdditionalData['credentialsHelper']>({\n\t\t\t\tgetParentTypes: () => [],\n\t\t\t\tauthenticate: async (_creds, _type, options) => {\n\t\t\t\t\tset(options, 'headers.authorization', 'mockAuth');\n\t\t\t\t\treturn options as IHttpRequestOptions;\n\t\t\t\t},\n\t\t\t}),\n\t\t\thooks: mock<ExecutionLifecycleHooks>(),\n\t\t}),\n\t\tmode,\n\t\t'init',\n\t);\n\n\tpollContext.getNode = () => node;\n\tpollContext.getCredentials = async <T extends object = ICredentialDataDecryptedObject>() =>\n\t\t(options.credential ?? {}) as T;\n\tpollContext.getNodeParameter = (parameterName, fallback) =>\n\t\tget(node.parameters, parameterName) ?? fallback;\n\n\tconst response = await trigger.poll?.call(pollContext);\n\n\treturn {\n\t\tresponse,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,gCAAqB;AACrB,iBAAgB;AAChB,mBAAkB;AAClB,iBAAgB;AAChB,sBAA6C;AAE7C,oCAAqC;AACrC,0BAeO;AAwBP,SAAS,eAAe,SAAsC,SAAkB;AAC/E,QAAM,WAAW,IAAI,QAAQ;AAC7B,SAAO,SAAS,aAAa,WAAW,SAAS,cAAc;AAChE;AAEA,eAAsB,gBACrB,SACA,UAAkC,CAAC,GAClC;AACD,QAAM,UAAU,iBAAiB,UAAU,UAAU,IAAI,QAAQ;AACjE,QAAM,OAAuD,KAAK,GAAG;AAErE,QAAM,WAAW,QAAQ,YAAY;AACrC,QAAM,UAAU,QAAQ,YAAY;AACpC,QAAM,WAAO,aAAAA;AAAA,IACZ;AAAA,MACC,MAAM,QAAQ,YAAY;AAAA,MAC1B,MAAM,QAAQ,YAAY,SAAS,QAAQ,cAAc,QAAQ,YAAY,IAAI;AAAA,MACjF,aAAa,OAAO,YAAY,WAAW,UAAU,QAAQ,GAAG,EAAE;AAAA,IACnE;AAAA,IACA,QAAQ;AAAA,EACT;AACA,QAAM,eAAW,gCAAe,EAAE,UAAU,QAAQ,YAAY,gBAAgB,CAAC;AAEjF,QAAM,uBAAuB,IAAI,uDAAqB,gCAAuB,CAAC;AAC9E,QAAM,cAAU,gCAAmC;AAAA,IAClD;AAAA,IACA;AAAA,IACA,cAAc,CAAC,gBAAgB,WAC9B,qBAAqB,aAAa,UAAU,gBAAgB,MAAM;AAAA,EACpE,CAAC;AAED,QAAM,uBAAmB,gCAAwB;AAAA,IAChD;AAAA,IACA;AAAA,IACA,aAAa,MAA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M,KAAK,WAAW;AAErD,SAAO;AAAA,IACN;AAAA,EACD;AACD;","names":["merge","get","options","set"]}
|
|
@@ -33,8 +33,14 @@ var import_di = require("@n8n/di");
|
|
|
33
33
|
var import_n8n_core = require("n8n-core");
|
|
34
34
|
var import_n8n_workflow = require("n8n-workflow");
|
|
35
35
|
var import_credential_types = require("./credential-types");
|
|
36
|
-
var import_FakeCredentialsMap = require("./FakeCredentialsMap");
|
|
37
36
|
let CredentialsHelper = class extends import_n8n_workflow.ICredentialsHelper {
|
|
37
|
+
constructor() {
|
|
38
|
+
super(...arguments);
|
|
39
|
+
this.credentialsMap = {};
|
|
40
|
+
}
|
|
41
|
+
setCredentials(credentialsMap) {
|
|
42
|
+
this.credentialsMap = credentialsMap;
|
|
43
|
+
}
|
|
38
44
|
getCredentialsProperties() {
|
|
39
45
|
return [];
|
|
40
46
|
}
|
|
@@ -51,24 +57,14 @@ let CredentialsHelper = class extends import_n8n_workflow.ICredentialsHelper {
|
|
|
51
57
|
getParentTypes(_name) {
|
|
52
58
|
return [];
|
|
53
59
|
}
|
|
54
|
-
async getDecrypted(_additionalData,
|
|
55
|
-
return this.
|
|
60
|
+
async getDecrypted(_additionalData, _nodeCredentials, type) {
|
|
61
|
+
return this.credentialsMap[type] ?? {};
|
|
56
62
|
}
|
|
57
63
|
async getCredentials(_nodeCredentials, _type) {
|
|
58
64
|
return new import_n8n_core.Credentials({ id: null, name: "" }, "", "");
|
|
59
65
|
}
|
|
60
66
|
async updateCredentials(_nodeCredentials, _type, _data) {
|
|
61
67
|
}
|
|
62
|
-
getFakeDecryptedCredentials(nodeCredentials, type) {
|
|
63
|
-
const credentialsMap = import_FakeCredentialsMap.FAKE_CREDENTIALS_DATA;
|
|
64
|
-
if (nodeCredentials && credentialsMap[JSON.stringify(nodeCredentials)]) {
|
|
65
|
-
return credentialsMap[JSON.stringify(nodeCredentials)];
|
|
66
|
-
}
|
|
67
|
-
if (type && credentialsMap[type]) {
|
|
68
|
-
return credentialsMap[type];
|
|
69
|
-
}
|
|
70
|
-
return {};
|
|
71
|
-
}
|
|
72
68
|
};
|
|
73
69
|
CredentialsHelper = __decorateClass([
|
|
74
70
|
(0, import_di.Service)()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../test/nodes/credentials-helper.ts"],"sourcesContent":["import { Container, Service } from '@n8n/di';\nimport { Credentials } from 'n8n-core';\nimport { ICredentialsHelper } from 'n8n-workflow';\nimport type {\n\tICredentialDataDecryptedObject,\n\
|
|
1
|
+
{"version":3,"sources":["../../../test/nodes/credentials-helper.ts"],"sourcesContent":["import { Container, Service } from '@n8n/di';\nimport { Credentials } from 'n8n-core';\nimport { ICredentialsHelper } from 'n8n-workflow';\nimport type {\n\tICredentialDataDecryptedObject,\n\tIHttpRequestHelper,\n\tIHttpRequestOptions,\n\tINode,\n\tINodeCredentialsDetails,\n\tIWorkflowExecuteAdditionalData,\n} from 'n8n-workflow';\n\nimport { CredentialTypes } from './credential-types';\n\n@Service()\nexport class CredentialsHelper extends ICredentialsHelper {\n\tprivate credentialsMap: Record<string, ICredentialDataDecryptedObject> = {};\n\n\tsetCredentials(credentialsMap: Record<string, ICredentialDataDecryptedObject>) {\n\t\tthis.credentialsMap = credentialsMap;\n\t}\n\n\tgetCredentialsProperties() {\n\t\treturn [];\n\t}\n\n\tasync authenticate(\n\t\tcredentials: ICredentialDataDecryptedObject,\n\t\ttypeName: string,\n\t\trequestParams: IHttpRequestOptions,\n\t): Promise<IHttpRequestOptions> {\n\t\tconst credentialType = Container.get(CredentialTypes).getByName(typeName);\n\t\tif (typeof credentialType.authenticate === 'function') {\n\t\t\treturn await credentialType.authenticate(credentials, requestParams);\n\t\t}\n\t\treturn requestParams;\n\t}\n\n\tasync preAuthentication(\n\t\t_helpers: IHttpRequestHelper,\n\t\t_credentials: ICredentialDataDecryptedObject,\n\t\t_typeName: string,\n\t\t_node: INode,\n\t\t_credentialsExpired: boolean,\n\t): Promise<ICredentialDataDecryptedObject | undefined> {\n\t\treturn undefined;\n\t}\n\n\tgetParentTypes(_name: string): string[] {\n\t\treturn [];\n\t}\n\n\tasync getDecrypted(\n\t\t_additionalData: IWorkflowExecuteAdditionalData,\n\t\t_nodeCredentials: INodeCredentialsDetails,\n\t\ttype: string,\n\t): Promise<ICredentialDataDecryptedObject> {\n\t\treturn this.credentialsMap[type] ?? {};\n\t}\n\n\tasync getCredentials(\n\t\t_nodeCredentials: INodeCredentialsDetails,\n\t\t_type: string,\n\t): Promise<Credentials> {\n\t\treturn new Credentials({ id: null, name: '' }, '', '');\n\t}\n\n\tasync updateCredentials(\n\t\t_nodeCredentials: INodeCredentialsDetails,\n\t\t_type: string,\n\t\t_data: ICredentialDataDecryptedObject,\n\t): Promise<void> {}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAmC;AACnC,sBAA4B;AAC5B,0BAAmC;AAUnC,8BAAgC;AAGzB,IAAM,oBAAN,cAAgC,uCAAmB;AAAA,EAAnD;AAAA;AACN,SAAQ,iBAAiE,CAAC;AAAA;AAAA,EAE1E,eAAe,gBAAgE;AAC9E,SAAK,iBAAiB;AAAA,EACvB;AAAA,EAEA,2BAA2B;AAC1B,WAAO,CAAC;AAAA,EACT;AAAA,EAEA,MAAM,aACL,aACA,UACA,eAC+B;AAC/B,UAAM,iBAAiB,oBAAU,IAAI,uCAAe,EAAE,UAAU,QAAQ;AACxE,QAAI,OAAO,eAAe,iBAAiB,YAAY;AACtD,aAAO,MAAM,eAAe,aAAa,aAAa,aAAa;AAAA,IACpE;AACA,WAAO;AAAA,EACR;AAAA,EAEA,MAAM,kBACL,UACA,cACA,WACA,OACA,qBACsD;AACtD,WAAO;AAAA,EACR;AAAA,EAEA,eAAe,OAAyB;AACvC,WAAO,CAAC;AAAA,EACT;AAAA,EAEA,MAAM,aACL,iBACA,kBACA,MAC0C;AAC1C,WAAO,KAAK,eAAe,IAAI,KAAK,CAAC;AAAA,EACtC;AAAA,EAEA,MAAM,eACL,kBACA,OACuB;AACvB,WAAO,IAAI,4BAAY,EAAE,IAAI,MAAM,MAAM,GAAG,GAAG,IAAI,EAAE;AAAA,EACtD;AAAA,EAEA,MAAM,kBACL,kBACA,OACA,OACgB;AAAA,EAAC;AACnB;AAzDa,oBAAN;AAAA,MADN,mBAAQ;AAAA,GACI;","names":[]}
|