@teleporthq/teleport-plugin-next-workflows 0.44.11 → 0.45.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/__tests__/_helpers/fake-fetch.ts +75 -0
- package/__tests__/_helpers/gui-place-order-statements.ts +17 -0
- package/__tests__/_helpers/inserted-lines.ts +22 -0
- package/__tests__/_helpers/invoice-store.ts +10 -1
- package/__tests__/_helpers/load-security-runtime.ts +45 -0
- package/__tests__/_helpers/load-server-runtime.ts +26 -3
- package/__tests__/_helpers/run-account-delete-route.ts +3 -1
- package/__tests__/_helpers/run-generated-middleware.ts +7 -2
- package/__tests__/account-delete-owned-rows.test.ts +3 -1
- package/__tests__/adopted-element-trigger-code.test.ts +128 -0
- package/__tests__/analytics-track-outcome.test.ts +145 -0
- package/__tests__/auth-password-change-ends-sessions.test.ts +8 -1
- package/__tests__/auth-password-security.test.ts +2275 -0
- package/__tests__/auth-session-cost.test.ts +31 -0
- package/__tests__/auth-signup-route.test.ts +960 -0
- package/__tests__/authored-code-every-path.test.ts +247 -0
- package/__tests__/automations-bus.test.ts +3820 -0
- package/__tests__/automations-catalog-drift.test.ts +97 -0
- package/__tests__/booking-calendar-feed-route.test.ts +20 -3
- package/__tests__/cart-price-order.test.ts +336 -1
- package/__tests__/code-lookup-rate-limit-route.test.ts +189 -0
- package/__tests__/cost-bearing-node-types.test.ts +119 -0
- package/__tests__/credential-columns-reply.test.ts +9 -0
- package/__tests__/credential-result-reply.test.ts +19 -5
- package/__tests__/cron-route-loop-templateparams.test.ts +6 -3
- package/__tests__/custom-js-authored-code.test.ts +304 -0
- package/__tests__/custom-node-custom-code-gate.test.ts +136 -0
- package/__tests__/custom-node-step-handlers.test.ts +251 -0
- package/__tests__/custom-node-step-reach.test.ts +63 -0
- package/__tests__/data-api-anon-user-id-fallback.test.ts +7 -2
- package/__tests__/data-api-browser-reads.test.ts +7 -0
- package/__tests__/data-api-business-events.test.ts +403 -0
- package/__tests__/data-api-invalid-body.test.ts +7 -0
- package/__tests__/data-api-low-stock-autofire.test.ts +30 -4
- package/__tests__/data-api-optional-feature-columns.test.ts +44 -0
- package/__tests__/data-api-owner-scope-credentials.test.ts +1324 -0
- package/__tests__/data-api-protected-tables.test.ts +48 -15
- package/__tests__/data-api-retired-table-and-account-fields.test.ts +208 -0
- package/__tests__/email-locale-senders.test.ts +5 -3
- package/__tests__/expression-injection.test.ts +343 -0
- package/__tests__/fixtures/admin-file-workflows.json +242 -0
- package/__tests__/form-confirmation-email-template.test.ts +44 -0
- package/__tests__/internal-request-headers.test.ts +25 -0
- package/__tests__/invoice-pdf-service-project-header.test.ts +120 -0
- package/__tests__/invoice-self-call-origin.test.ts +57 -1
- package/__tests__/legacy-webhook-self-calls.test.ts +86 -1
- package/__tests__/middleware-home-route-protection.test.ts +3 -1
- package/__tests__/middleware-subscriber-access.test.ts +1 -1
- package/__tests__/newsletter-admin-route.test.ts +649 -0
- package/__tests__/newsletter-plugin.test.ts +1248 -0
- package/__tests__/outbound-nodes-security.test.ts +1929 -0
- package/__tests__/page-access-guard.test.ts +217 -0
- package/__tests__/page-access-route-table.test.ts +231 -0
- package/__tests__/payment-drivers-module.test.ts +23 -0
- package/__tests__/payment-legacy-webhook-routes.test.ts +100 -5
- package/__tests__/payment-webhook-route.test.ts +4 -1
- package/__tests__/paypal-webhook-signature-verification.test.ts +44 -0
- package/__tests__/place-order-guards.test.ts +506 -0
- package/__tests__/public-step-guards.test.ts +310 -0
- package/__tests__/publish-refusals.test.ts +505 -0
- package/__tests__/realtime-identity-routes.test.ts +492 -0
- package/__tests__/record-event-writer-server-only.test.ts +975 -0
- package/__tests__/resolve-config-template-params.test.ts +3 -3
- package/__tests__/runtime-storage-upload-access.test.ts +280 -17
- package/__tests__/security-integration-env-names.test.ts +74 -0
- package/__tests__/security-lists-parity.test.ts +245 -0
- package/__tests__/security-runtime-shadow.test.ts +224 -1
- package/__tests__/security-runtime.test.ts +893 -0
- package/__tests__/segment-rate-limit-error-branch.test.ts +284 -0
- package/__tests__/segment-route-abuse-gate.test.ts +309 -0
- package/__tests__/server-job-hops-real-data-api.test.ts +669 -0
- package/__tests__/server-session-identity.test.ts +522 -0
- package/__tests__/server-step-chain.test.ts +222 -0
- package/__tests__/server-step-signing.test.ts +107 -2
- package/__tests__/session-cookie-resolver.test.ts +62 -106
- package/__tests__/signup-event.test.ts +649 -0
- package/__tests__/signup-reply-identical.test.ts +144 -0
- package/__tests__/slack-message-escaping.test.ts +123 -0
- package/__tests__/visitor-step-limits.test.ts +318 -0
- package/__tests__/webhook-delivery-lease.test.ts +4 -1
- package/__tests__/webpack-safe-handlers.test.ts +57 -8
- package/__tests__/workflow-auth-guard.test.ts +9 -1
- package/dist/cjs/account-delete-route-generator.d.ts +1 -0
- package/dist/cjs/account-delete-route-generator.d.ts.map +1 -1
- package/dist/cjs/account-delete-route-generator.js +18 -3
- package/dist/cjs/account-delete-route-generator.js.map +1 -1
- package/dist/cjs/api-route-generator.d.ts +52 -3
- package/dist/cjs/api-route-generator.d.ts.map +1 -1
- package/dist/cjs/api-route-generator.js +600 -145
- package/dist/cjs/api-route-generator.js.map +1 -1
- package/dist/cjs/auth-generator.d.ts +126 -3
- package/dist/cjs/auth-generator.d.ts.map +1 -1
- package/dist/cjs/auth-generator.js +1353 -139
- package/dist/cjs/auth-generator.js.map +1 -1
- package/dist/cjs/automations/activity-kicks.d.ts +12 -0
- package/dist/cjs/automations/activity-kicks.d.ts.map +1 -0
- package/dist/cjs/automations/activity-kicks.js +123 -0
- package/dist/cjs/automations/activity-kicks.js.map +1 -0
- package/dist/cjs/automations/app-events-source.d.ts +33 -0
- package/dist/cjs/automations/app-events-source.d.ts.map +1 -0
- package/dist/cjs/automations/app-events-source.js +109 -0
- package/dist/cjs/automations/app-events-source.js.map +1 -0
- package/dist/cjs/automations/automations-project-plugin.d.ts +21 -0
- package/dist/cjs/automations/automations-project-plugin.d.ts.map +1 -0
- package/dist/cjs/automations/automations-project-plugin.js +102 -0
- package/dist/cjs/automations/automations-project-plugin.js.map +1 -0
- package/dist/cjs/automations/automations-scope.d.ts +104 -0
- package/dist/cjs/automations/automations-scope.d.ts.map +1 -0
- package/dist/cjs/automations/automations-scope.js +176 -0
- package/dist/cjs/automations/automations-scope.js.map +1 -0
- package/dist/cjs/automations/dispatcher-source.d.ts +72 -0
- package/dist/cjs/automations/dispatcher-source.d.ts.map +1 -0
- package/dist/cjs/automations/dispatcher-source.js +1008 -0
- package/dist/cjs/automations/dispatcher-source.js.map +1 -0
- package/dist/cjs/automations/event-bus-source.d.ts +44 -0
- package/dist/cjs/automations/event-bus-source.d.ts.map +1 -0
- package/dist/cjs/automations/event-bus-source.js +427 -0
- package/dist/cjs/automations/event-bus-source.js.map +1 -0
- package/dist/cjs/automations/handler-module-generator.d.ts +25 -0
- package/dist/cjs/automations/handler-module-generator.d.ts.map +1 -0
- package/dist/cjs/automations/handler-module-generator.js +78 -0
- package/dist/cjs/automations/handler-module-generator.js.map +1 -0
- package/dist/cjs/automations/hydrators-source.d.ts +33 -0
- package/dist/cjs/automations/hydrators-source.d.ts.map +1 -0
- package/dist/cjs/automations/hydrators-source.js +571 -0
- package/dist/cjs/automations/hydrators-source.js.map +1 -0
- package/dist/cjs/booking-calendar-feed-route-generator.d.ts.map +1 -1
- package/dist/cjs/booking-calendar-feed-route-generator.js +8 -0
- package/dist/cjs/booking-calendar-feed-route-generator.js.map +1 -1
- package/dist/cjs/configured-nextauth-url.d.ts +17 -0
- package/dist/cjs/configured-nextauth-url.d.ts.map +1 -0
- package/dist/cjs/configured-nextauth-url.js +20 -0
- package/dist/cjs/configured-nextauth-url.js.map +1 -0
- package/dist/cjs/cron-request-verification.d.ts +22 -1
- package/dist/cjs/cron-request-verification.d.ts.map +1 -1
- package/dist/cjs/cron-request-verification.js +50 -6
- package/dist/cjs/cron-request-verification.js.map +1 -1
- package/dist/cjs/data-api-route-generator.d.ts +19 -0
- package/dist/cjs/data-api-route-generator.d.ts.map +1 -1
- package/dist/cjs/data-api-route-generator.js +711 -43
- package/dist/cjs/data-api-route-generator.js.map +1 -1
- package/dist/cjs/ecommerce/parameterized-stock-chain.d.ts +3 -1
- package/dist/cjs/ecommerce/parameterized-stock-chain.d.ts.map +1 -1
- package/dist/cjs/ecommerce/parameterized-stock-chain.js +45 -5
- package/dist/cjs/ecommerce/parameterized-stock-chain.js.map +1 -1
- package/dist/cjs/ecommerce/place-order-guards.d.ts +126 -0
- package/dist/cjs/ecommerce/place-order-guards.d.ts.map +1 -0
- package/dist/cjs/ecommerce/place-order-guards.js +670 -0
- package/dist/cjs/ecommerce/place-order-guards.js.map +1 -0
- package/dist/cjs/ecommerce-customhandler-rewriter.d.ts +2 -0
- package/dist/cjs/ecommerce-customhandler-rewriter.d.ts.map +1 -1
- package/dist/cjs/ecommerce-customhandler-rewriter.js +38 -2
- package/dist/cjs/ecommerce-customhandler-rewriter.js.map +1 -1
- package/dist/cjs/executor-generator.d.ts.map +1 -1
- package/dist/cjs/executor-generator.js +368 -60
- package/dist/cjs/executor-generator.js.map +1 -1
- package/dist/cjs/graph-utils.d.ts +9 -0
- package/dist/cjs/graph-utils.d.ts.map +1 -1
- package/dist/cjs/graph-utils.js +32 -1
- package/dist/cjs/graph-utils.js.map +1 -1
- package/dist/cjs/index.d.ts +20 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +72 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/invoice/api-routes-code.d.ts +9 -3
- package/dist/cjs/invoice/api-routes-code.d.ts.map +1 -1
- package/dist/cjs/invoice/api-routes-code.js +9 -7
- package/dist/cjs/invoice/api-routes-code.js.map +1 -1
- package/dist/cjs/invoice/index.d.ts.map +1 -1
- package/dist/cjs/invoice/index.js +12 -7
- package/dist/cjs/invoice/index.js.map +1 -1
- package/dist/cjs/invoice/invoice-assembly-code.d.ts.map +1 -1
- package/dist/cjs/invoice/invoice-assembly-code.js +8 -3
- package/dist/cjs/invoice/invoice-assembly-code.js.map +1 -1
- package/dist/cjs/invoice/pdf-generator-code.d.ts.map +1 -1
- package/dist/cjs/invoice/pdf-generator-code.js +2 -1
- package/dist/cjs/invoice/pdf-generator-code.js.map +1 -1
- package/dist/cjs/invoice/pdf-service-client-code.d.ts.map +1 -1
- package/dist/cjs/invoice/pdf-service-client-code.js +15 -7
- package/dist/cjs/invoice/pdf-service-client-code.js.map +1 -1
- package/dist/cjs/newsletter/admin-route-code.d.ts +60 -0
- package/dist/cjs/newsletter/admin-route-code.d.ts.map +1 -0
- package/dist/cjs/newsletter/admin-route-code.js +300 -0
- package/dist/cjs/newsletter/admin-route-code.js.map +1 -0
- package/dist/cjs/newsletter/helper-code.d.ts +109 -0
- package/dist/cjs/newsletter/helper-code.d.ts.map +1 -0
- package/dist/cjs/newsletter/helper-code.js +662 -0
- package/dist/cjs/newsletter/helper-code.js.map +1 -0
- package/dist/cjs/newsletter/newsletter-scope.d.ts +65 -0
- package/dist/cjs/newsletter/newsletter-scope.d.ts.map +1 -0
- package/dist/cjs/newsletter/newsletter-scope.js +103 -0
- package/dist/cjs/newsletter/newsletter-scope.js.map +1 -0
- package/dist/cjs/newsletter/project-plugin.d.ts +18 -0
- package/dist/cjs/newsletter/project-plugin.d.ts.map +1 -0
- package/dist/cjs/newsletter/project-plugin.js +97 -0
- package/dist/cjs/newsletter/project-plugin.js.map +1 -0
- package/dist/cjs/newsletter/routes-code.d.ts +6 -0
- package/dist/cjs/newsletter/routes-code.d.ts.map +1 -0
- package/dist/cjs/newsletter/routes-code.js +181 -0
- package/dist/cjs/newsletter/routes-code.js.map +1 -0
- package/dist/cjs/nodes/account/account-compare-passwords.d.ts.map +1 -1
- package/dist/cjs/nodes/account/account-compare-passwords.js +16 -6
- package/dist/cjs/nodes/account/account-compare-passwords.js.map +1 -1
- package/dist/cjs/nodes/account/account-delete-current.js +1 -1
- package/dist/cjs/nodes/account/account-get-current.js +1 -1
- package/dist/cjs/nodes/account/account-hash-password.d.ts.map +1 -1
- package/dist/cjs/nodes/account/account-hash-password.js +15 -3
- package/dist/cjs/nodes/account/account-hash-password.js.map +1 -1
- package/dist/cjs/nodes/account/account-login.d.ts.map +1 -1
- package/dist/cjs/nodes/account/account-login.js +23 -6
- package/dist/cjs/nodes/account/account-login.js.map +1 -1
- package/dist/cjs/nodes/account/account-logout.js +1 -1
- package/dist/cjs/nodes/account/account-refresh-session.js +1 -1
- package/dist/cjs/nodes/account/account-request-password-reset.d.ts +3 -0
- package/dist/cjs/nodes/account/account-request-password-reset.d.ts.map +1 -0
- package/dist/cjs/nodes/account/account-request-password-reset.js +46 -0
- package/dist/cjs/nodes/account/account-request-password-reset.js.map +1 -0
- package/dist/cjs/nodes/account/account-reset-password.d.ts +3 -0
- package/dist/cjs/nodes/account/account-reset-password.d.ts.map +1 -0
- package/dist/cjs/nodes/account/account-reset-password.js +44 -0
- package/dist/cjs/nodes/account/account-reset-password.js.map +1 -0
- package/dist/cjs/nodes/account/account-signup.d.ts.map +1 -1
- package/dist/cjs/nodes/account/account-signup.js +82 -19
- package/dist/cjs/nodes/account/account-signup.js.map +1 -1
- package/dist/cjs/nodes/account/account-social-login.js +1 -1
- package/dist/cjs/nodes/ai/ai-custom-prompt.d.ts.map +1 -1
- package/dist/cjs/nodes/ai/ai-custom-prompt.js +20 -5
- package/dist/cjs/nodes/ai/ai-custom-prompt.js.map +1 -1
- package/dist/cjs/nodes/ai/ai-detect-language.d.ts.map +1 -1
- package/dist/cjs/nodes/ai/ai-detect-language.js +20 -5
- package/dist/cjs/nodes/ai/ai-detect-language.js.map +1 -1
- package/dist/cjs/nodes/ai/ai-generate-text-embedding.d.ts.map +1 -1
- package/dist/cjs/nodes/ai/ai-generate-text-embedding.js +10 -2
- package/dist/cjs/nodes/ai/ai-generate-text-embedding.js.map +1 -1
- package/dist/cjs/nodes/ai/ai-provider-utils-sources.generated.js +2 -2
- package/dist/cjs/nodes/ai/ai-provider-utils-sources.generated.js.map +1 -1
- package/dist/cjs/nodes/ai/ai-provider-utils.d.ts +31 -2
- package/dist/cjs/nodes/ai/ai-provider-utils.d.ts.map +1 -1
- package/dist/cjs/nodes/ai/ai-provider-utils.js +125 -11
- package/dist/cjs/nodes/ai/ai-provider-utils.js.map +1 -1
- package/dist/cjs/nodes/ai/ai-select-database-data.d.ts.map +1 -1
- package/dist/cjs/nodes/ai/ai-select-database-data.js +6 -2
- package/dist/cjs/nodes/ai/ai-select-database-data.js.map +1 -1
- package/dist/cjs/nodes/ai/ai-sentiment-analysis.d.ts.map +1 -1
- package/dist/cjs/nodes/ai/ai-sentiment-analysis.js +20 -5
- package/dist/cjs/nodes/ai/ai-sentiment-analysis.js.map +1 -1
- package/dist/cjs/nodes/ai/ai-summarization.d.ts.map +1 -1
- package/dist/cjs/nodes/ai/ai-summarization.js +20 -5
- package/dist/cjs/nodes/ai/ai-summarization.js.map +1 -1
- package/dist/cjs/nodes/ai/ai-text-classifier.d.ts.map +1 -1
- package/dist/cjs/nodes/ai/ai-text-classifier.js +20 -5
- package/dist/cjs/nodes/ai/ai-text-classifier.js.map +1 -1
- package/dist/cjs/nodes/ai/ai-text-transform.d.ts.map +1 -1
- package/dist/cjs/nodes/ai/ai-text-transform.js +20 -5
- package/dist/cjs/nodes/ai/ai-text-transform.js.map +1 -1
- package/dist/cjs/nodes/analytics/analytics-track-outcome.d.ts +3 -0
- package/dist/cjs/nodes/analytics/analytics-track-outcome.d.ts.map +1 -0
- package/dist/cjs/nodes/analytics/analytics-track-outcome.js +110 -0
- package/dist/cjs/nodes/analytics/analytics-track-outcome.js.map +1 -0
- package/dist/cjs/nodes/cart/cart-price-order.d.ts.map +1 -1
- package/dist/cjs/nodes/cart/cart-price-order.js +161 -2
- package/dist/cjs/nodes/cart/cart-price-order.js.map +1 -1
- package/dist/cjs/nodes/cost-bearing-node-types.d.ts +4 -0
- package/dist/cjs/nodes/cost-bearing-node-types.d.ts.map +1 -0
- package/dist/cjs/nodes/cost-bearing-node-types.js +43 -0
- package/dist/cjs/nodes/cost-bearing-node-types.js.map +1 -0
- package/dist/cjs/nodes/data/data-select.d.ts.map +1 -1
- package/dist/cjs/nodes/data/data-select.js +12 -2
- package/dist/cjs/nodes/data/data-select.js.map +1 -1
- package/dist/cjs/nodes/email/email-mailersend.d.ts.map +1 -1
- package/dist/cjs/nodes/email/email-mailersend.js +15 -11
- package/dist/cjs/nodes/email/email-mailersend.js.map +1 -1
- package/dist/cjs/nodes/email/email-mailgun.d.ts.map +1 -1
- package/dist/cjs/nodes/email/email-mailgun.js +15 -15
- package/dist/cjs/nodes/email/email-mailgun.js.map +1 -1
- package/dist/cjs/nodes/email/email-postmark.d.ts.map +1 -1
- package/dist/cjs/nodes/email/email-postmark.js +15 -15
- package/dist/cjs/nodes/email/email-postmark.js.map +1 -1
- package/dist/cjs/nodes/email/email-resend.d.ts.map +1 -1
- package/dist/cjs/nodes/email/email-resend.js +15 -15
- package/dist/cjs/nodes/email/email-resend.js.map +1 -1
- package/dist/cjs/nodes/email/email-sendgrid.d.ts.map +1 -1
- package/dist/cjs/nodes/email/email-sendgrid.js +15 -15
- package/dist/cjs/nodes/email/email-sendgrid.js.map +1 -1
- package/dist/cjs/nodes/email/html-escape-code.d.ts +3 -0
- package/dist/cjs/nodes/email/html-escape-code.d.ts.map +1 -0
- package/dist/cjs/nodes/email/html-escape-code.js +23 -0
- package/dist/cjs/nodes/email/html-escape-code.js.map +1 -0
- package/dist/cjs/nodes/email/message-trust.d.ts +40 -0
- package/dist/cjs/nodes/email/message-trust.d.ts.map +1 -0
- package/dist/cjs/nodes/email/message-trust.js +167 -0
- package/dist/cjs/nodes/email/message-trust.js.map +1 -0
- package/dist/cjs/nodes/email/outbound-message-guard.d.ts +113 -0
- package/dist/cjs/nodes/email/outbound-message-guard.d.ts.map +1 -0
- package/dist/cjs/nodes/email/outbound-message-guard.js +460 -0
- package/dist/cjs/nodes/email/outbound-message-guard.js.map +1 -0
- package/dist/cjs/nodes/email/trusted-html-code.d.ts +22 -0
- package/dist/cjs/nodes/email/trusted-html-code.d.ts.map +1 -0
- package/dist/cjs/nodes/email/trusted-html-code.js +52 -0
- package/dist/cjs/nodes/email/trusted-html-code.js.map +1 -0
- package/dist/cjs/nodes/general/general-custom-js.d.ts.map +1 -1
- package/dist/cjs/nodes/general/general-custom-js.js +44 -7
- package/dist/cjs/nodes/general/general-custom-js.js.map +1 -1
- package/dist/cjs/nodes/general/general-http-request.d.ts.map +1 -1
- package/dist/cjs/nodes/general/general-http-request.js +431 -45
- package/dist/cjs/nodes/general/general-http-request.js.map +1 -1
- package/dist/cjs/nodes/general/general-rate-limiter.d.ts.map +1 -1
- package/dist/cjs/nodes/general/general-rate-limiter.js +46 -78
- package/dist/cjs/nodes/general/general-rate-limiter.js.map +1 -1
- package/dist/cjs/nodes/general/general-wait.d.ts +3 -0
- package/dist/cjs/nodes/general/general-wait.d.ts.map +1 -0
- package/dist/cjs/nodes/general/general-wait.js +81 -0
- package/dist/cjs/nodes/general/general-wait.js.map +1 -0
- package/dist/cjs/nodes/general/visitor-request.d.ts +44 -0
- package/dist/cjs/nodes/general/visitor-request.d.ts.map +1 -0
- package/dist/cjs/nodes/general/visitor-request.js +72 -0
- package/dist/cjs/nodes/general/visitor-request.js.map +1 -0
- package/dist/cjs/nodes/index.d.ts.map +1 -1
- package/dist/cjs/nodes/index.js +7 -1
- package/dist/cjs/nodes/index.js.map +1 -1
- package/dist/cjs/nodes/integrations/integration-slack.d.ts.map +1 -1
- package/dist/cjs/nodes/integrations/integration-slack.js +17 -6
- package/dist/cjs/nodes/integrations/integration-slack.js.map +1 -1
- package/dist/cjs/nodes/newsletter/newsletter-confirm.d.ts +3 -0
- package/dist/cjs/nodes/newsletter/newsletter-confirm.d.ts.map +1 -0
- package/dist/cjs/nodes/newsletter/newsletter-confirm.js +41 -0
- package/dist/cjs/nodes/newsletter/newsletter-confirm.js.map +1 -0
- package/dist/cjs/nodes/newsletter/newsletter-subscribe.d.ts +7 -0
- package/dist/cjs/nodes/newsletter/newsletter-subscribe.d.ts.map +1 -0
- package/dist/cjs/nodes/newsletter/newsletter-subscribe.js +69 -0
- package/dist/cjs/nodes/newsletter/newsletter-subscribe.js.map +1 -0
- package/dist/cjs/nodes/newsletter/newsletter-unsubscribe.d.ts +3 -0
- package/dist/cjs/nodes/newsletter/newsletter-unsubscribe.d.ts.map +1 -0
- package/dist/cjs/nodes/newsletter/newsletter-unsubscribe.js +42 -0
- package/dist/cjs/nodes/newsletter/newsletter-unsubscribe.js.map +1 -0
- package/dist/cjs/nodes/realtime/realtime-join-channel.d.ts.map +1 -1
- package/dist/cjs/nodes/realtime/realtime-join-channel.js +5 -4
- package/dist/cjs/nodes/realtime/realtime-join-channel.js.map +1 -1
- package/dist/cjs/nodes/realtime/realtime-send-channel-event.d.ts.map +1 -1
- package/dist/cjs/nodes/realtime/realtime-send-channel-event.js +11 -2
- package/dist/cjs/nodes/realtime/realtime-send-channel-event.js.map +1 -1
- package/dist/cjs/nodes/realtime/realtime-send-channel-message.d.ts.map +1 -1
- package/dist/cjs/nodes/realtime/realtime-send-channel-message.js +11 -2
- package/dist/cjs/nodes/realtime/realtime-send-channel-message.js.map +1 -1
- package/dist/cjs/nodes/sms/sms-infobip.d.ts.map +1 -1
- package/dist/cjs/nodes/sms/sms-infobip.js +11 -8
- package/dist/cjs/nodes/sms/sms-infobip.js.map +1 -1
- package/dist/cjs/nodes/sms/sms-smsapi.d.ts.map +1 -1
- package/dist/cjs/nodes/sms/sms-smsapi.js +11 -8
- package/dist/cjs/nodes/sms/sms-smsapi.js.map +1 -1
- package/dist/cjs/nodes/sms/sms-textmagic.d.ts.map +1 -1
- package/dist/cjs/nodes/sms/sms-textmagic.js +11 -8
- package/dist/cjs/nodes/sms/sms-textmagic.js.map +1 -1
- package/dist/cjs/nodes/sms/sms-twilio.d.ts.map +1 -1
- package/dist/cjs/nodes/sms/sms-twilio.js +12 -10
- package/dist/cjs/nodes/sms/sms-twilio.js.map +1 -1
- package/dist/cjs/nodes/types.d.ts +8 -1
- package/dist/cjs/nodes/types.d.ts.map +1 -1
- package/dist/cjs/nodes/utility/utility-similarity-scoring.d.ts.map +1 -1
- package/dist/cjs/nodes/utility/utility-similarity-scoring.js +29 -10
- package/dist/cjs/nodes/utility/utility-similarity-scoring.js.map +1 -1
- package/dist/cjs/page-access-guard-generator.d.ts +23 -0
- package/dist/cjs/page-access-guard-generator.d.ts.map +1 -0
- package/dist/cjs/page-access-guard-generator.js +135 -0
- package/dist/cjs/page-access-guard-generator.js.map +1 -0
- package/dist/cjs/password-reset-route-generator.d.ts +119 -0
- package/dist/cjs/password-reset-route-generator.d.ts.map +1 -0
- package/dist/cjs/password-reset-route-generator.js +460 -0
- package/dist/cjs/password-reset-route-generator.js.map +1 -0
- package/dist/cjs/payments/payment-core-code.d.ts.map +1 -1
- package/dist/cjs/payments/payment-core-code.js +12 -7
- package/dist/cjs/payments/payment-core-code.js.map +1 -1
- package/dist/cjs/project-code-scanner.d.ts +11 -0
- package/dist/cjs/project-code-scanner.d.ts.map +1 -0
- package/dist/cjs/project-code-scanner.js +80 -0
- package/dist/cjs/project-code-scanner.js.map +1 -0
- package/dist/cjs/public-step-guards.d.ts +122 -0
- package/dist/cjs/public-step-guards.d.ts.map +1 -0
- package/dist/cjs/public-step-guards.js +288 -0
- package/dist/cjs/public-step-guards.js.map +1 -0
- package/dist/cjs/publish-refusals.d.ts +66 -0
- package/dist/cjs/publish-refusals.d.ts.map +1 -0
- package/dist/cjs/publish-refusals.js +278 -0
- package/dist/cjs/publish-refusals.js.map +1 -0
- package/dist/cjs/realtime-generator.d.ts +63 -1
- package/dist/cjs/realtime-generator.d.ts.map +1 -1
- package/dist/cjs/realtime-generator.js +404 -230
- package/dist/cjs/realtime-generator.js.map +1 -1
- package/dist/cjs/runtime-storage-generator.d.ts +32 -1
- package/dist/cjs/runtime-storage-generator.d.ts.map +1 -1
- package/dist/cjs/runtime-storage-generator.js +265 -12
- package/dist/cjs/runtime-storage-generator.js.map +1 -1
- package/dist/cjs/security-runtime/index.d.ts +14 -0
- package/dist/cjs/security-runtime/index.d.ts.map +1 -0
- package/dist/cjs/security-runtime/index.js +48 -0
- package/dist/cjs/security-runtime/index.js.map +1 -0
- package/dist/cjs/security-runtime/security-runtime-code.d.ts +53 -0
- package/dist/cjs/security-runtime/security-runtime-code.d.ts.map +1 -0
- package/dist/cjs/security-runtime/security-runtime-code.js +580 -0
- package/dist/cjs/security-runtime/security-runtime-code.js.map +1 -0
- package/dist/cjs/security-scanner.d.ts +72 -3
- package/dist/cjs/security-scanner.d.ts.map +1 -1
- package/dist/cjs/security-scanner.js +220 -8
- package/dist/cjs/security-scanner.js.map +1 -1
- package/dist/cjs/segment-splitter.d.ts.map +1 -1
- package/dist/cjs/segment-splitter.js +10 -2
- package/dist/cjs/segment-splitter.js.map +1 -1
- package/dist/cjs/segment-trust.d.ts +36 -0
- package/dist/cjs/segment-trust.d.ts.map +1 -1
- package/dist/cjs/segment-trust.js +147 -3
- package/dist/cjs/segment-trust.js.map +1 -1
- package/dist/cjs/self-call-headers.d.ts +31 -0
- package/dist/cjs/self-call-headers.d.ts.map +1 -0
- package/dist/cjs/self-call-headers.js +48 -0
- package/dist/cjs/self-call-headers.js.map +1 -0
- package/dist/cjs/sent-email-log/index.d.ts +7 -0
- package/dist/cjs/sent-email-log/index.d.ts.map +1 -1
- package/dist/cjs/sent-email-log/index.js +17 -1
- package/dist/cjs/sent-email-log/index.js.map +1 -1
- package/dist/cjs/sent-email-log/sent-email-log-code.d.ts +7 -0
- package/dist/cjs/sent-email-log/sent-email-log-code.d.ts.map +1 -1
- package/dist/cjs/sent-email-log/sent-email-log-code.js +17 -3
- package/dist/cjs/sent-email-log/sent-email-log-code.js.map +1 -1
- package/dist/cjs/server-custom-node-call.d.ts +79 -0
- package/dist/cjs/server-custom-node-call.d.ts.map +1 -0
- package/dist/cjs/server-custom-node-call.js +285 -0
- package/dist/cjs/server-custom-node-call.js.map +1 -0
- package/dist/cjs/server-runtime-code.d.ts +39 -12
- package/dist/cjs/server-runtime-code.d.ts.map +1 -1
- package/dist/cjs/server-runtime-code.js +484 -41
- package/dist/cjs/server-runtime-code.js.map +1 -1
- package/dist/cjs/session-cookie-resolver.d.ts +3 -1
- package/dist/cjs/session-cookie-resolver.d.ts.map +1 -1
- package/dist/cjs/session-revocation-generator.d.ts +39 -0
- package/dist/cjs/session-revocation-generator.d.ts.map +1 -0
- package/dist/cjs/session-revocation-generator.js +177 -0
- package/dist/cjs/session-revocation-generator.js.map +1 -0
- package/dist/cjs/slack-message-values.d.ts +6 -0
- package/dist/cjs/slack-message-values.d.ts.map +1 -0
- package/dist/cjs/slack-message-values.js +73 -0
- package/dist/cjs/slack-message-values.js.map +1 -0
- package/dist/cjs/transactional-email-code.d.ts +11 -0
- package/dist/cjs/transactional-email-code.d.ts.map +1 -1
- package/dist/cjs/transactional-email-code.js +29 -5
- package/dist/cjs/transactional-email-code.js.map +1 -1
- package/dist/cjs/trigger-generator.d.ts +2 -0
- package/dist/cjs/trigger-generator.d.ts.map +1 -1
- package/dist/cjs/trigger-generator.js +17 -4
- package/dist/cjs/trigger-generator.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/cjs/visitor-step-limits.d.ts +66 -0
- package/dist/cjs/visitor-step-limits.d.ts.map +1 -0
- package/dist/cjs/visitor-step-limits.js +187 -0
- package/dist/cjs/visitor-step-limits.js.map +1 -0
- package/dist/cjs/webhook-generator.d.ts.map +1 -1
- package/dist/cjs/webhook-generator.js +93 -15
- package/dist/cjs/webhook-generator.js.map +1 -1
- package/dist/cjs/webhook-signature-verification.d.ts.map +1 -1
- package/dist/cjs/webhook-signature-verification.js +13 -3
- package/dist/cjs/webhook-signature-verification.js.map +1 -1
- package/dist/cjs/workflow-auth-generator.d.ts +4 -1
- package/dist/cjs/workflow-auth-generator.d.ts.map +1 -1
- package/dist/cjs/workflow-auth-generator.js +8 -3
- package/dist/cjs/workflow-auth-generator.js.map +1 -1
- package/dist/cjs/workflow-component-plugin.js +11 -3
- package/dist/cjs/workflow-component-plugin.js.map +1 -1
- package/dist/cjs/workflow-project-plugin.d.ts.map +1 -1
- package/dist/cjs/workflow-project-plugin.js +302 -56
- package/dist/cjs/workflow-project-plugin.js.map +1 -1
- package/dist/cjs/workflow-scope.d.ts.map +1 -1
- package/dist/cjs/workflow-scope.js +5 -0
- package/dist/cjs/workflow-scope.js.map +1 -1
- package/dist/esm/account-delete-route-generator.d.ts +1 -0
- package/dist/esm/account-delete-route-generator.d.ts.map +1 -1
- package/dist/esm/account-delete-route-generator.js +18 -3
- package/dist/esm/account-delete-route-generator.js.map +1 -1
- package/dist/esm/api-route-generator.d.ts +52 -3
- package/dist/esm/api-route-generator.d.ts.map +1 -1
- package/dist/esm/api-route-generator.js +595 -142
- package/dist/esm/api-route-generator.js.map +1 -1
- package/dist/esm/auth-generator.d.ts +126 -3
- package/dist/esm/auth-generator.d.ts.map +1 -1
- package/dist/esm/auth-generator.js +1350 -140
- package/dist/esm/auth-generator.js.map +1 -1
- package/dist/esm/automations/activity-kicks.d.ts +12 -0
- package/dist/esm/automations/activity-kicks.d.ts.map +1 -0
- package/dist/esm/automations/activity-kicks.js +118 -0
- package/dist/esm/automations/activity-kicks.js.map +1 -0
- package/dist/esm/automations/app-events-source.d.ts +33 -0
- package/dist/esm/automations/app-events-source.d.ts.map +1 -0
- package/dist/esm/automations/app-events-source.js +104 -0
- package/dist/esm/automations/app-events-source.js.map +1 -0
- package/dist/esm/automations/automations-project-plugin.d.ts +21 -0
- package/dist/esm/automations/automations-project-plugin.d.ts.map +1 -0
- package/dist/esm/automations/automations-project-plugin.js +98 -0
- package/dist/esm/automations/automations-project-plugin.js.map +1 -0
- package/dist/esm/automations/automations-scope.d.ts +104 -0
- package/dist/esm/automations/automations-scope.d.ts.map +1 -0
- package/dist/esm/automations/automations-scope.js +165 -0
- package/dist/esm/automations/automations-scope.js.map +1 -0
- package/dist/esm/automations/dispatcher-source.d.ts +72 -0
- package/dist/esm/automations/dispatcher-source.d.ts.map +1 -0
- package/dist/esm/automations/dispatcher-source.js +999 -0
- package/dist/esm/automations/dispatcher-source.js.map +1 -0
- package/dist/esm/automations/event-bus-source.d.ts +44 -0
- package/dist/esm/automations/event-bus-source.d.ts.map +1 -0
- package/dist/esm/automations/event-bus-source.js +421 -0
- package/dist/esm/automations/event-bus-source.js.map +1 -0
- package/dist/esm/automations/handler-module-generator.d.ts +25 -0
- package/dist/esm/automations/handler-module-generator.d.ts.map +1 -0
- package/dist/esm/automations/handler-module-generator.js +71 -0
- package/dist/esm/automations/handler-module-generator.js.map +1 -0
- package/dist/esm/automations/hydrators-source.d.ts +33 -0
- package/dist/esm/automations/hydrators-source.d.ts.map +1 -0
- package/dist/esm/automations/hydrators-source.js +567 -0
- package/dist/esm/automations/hydrators-source.js.map +1 -0
- package/dist/esm/booking-calendar-feed-route-generator.d.ts.map +1 -1
- package/dist/esm/booking-calendar-feed-route-generator.js +8 -0
- package/dist/esm/booking-calendar-feed-route-generator.js.map +1 -1
- package/dist/esm/configured-nextauth-url.d.ts +17 -0
- package/dist/esm/configured-nextauth-url.d.ts.map +1 -0
- package/dist/esm/configured-nextauth-url.js +17 -0
- package/dist/esm/configured-nextauth-url.js.map +1 -0
- package/dist/esm/cron-request-verification.d.ts +22 -1
- package/dist/esm/cron-request-verification.d.ts.map +1 -1
- package/dist/esm/cron-request-verification.js +48 -5
- package/dist/esm/cron-request-verification.js.map +1 -1
- package/dist/esm/data-api-route-generator.d.ts +19 -0
- package/dist/esm/data-api-route-generator.d.ts.map +1 -1
- package/dist/esm/data-api-route-generator.js +710 -43
- package/dist/esm/data-api-route-generator.js.map +1 -1
- package/dist/esm/ecommerce/parameterized-stock-chain.d.ts +3 -1
- package/dist/esm/ecommerce/parameterized-stock-chain.d.ts.map +1 -1
- package/dist/esm/ecommerce/parameterized-stock-chain.js +43 -4
- package/dist/esm/ecommerce/parameterized-stock-chain.js.map +1 -1
- package/dist/esm/ecommerce/place-order-guards.d.ts +126 -0
- package/dist/esm/ecommerce/place-order-guards.d.ts.map +1 -0
- package/dist/esm/ecommerce/place-order-guards.js +655 -0
- package/dist/esm/ecommerce/place-order-guards.js.map +1 -0
- package/dist/esm/ecommerce-customhandler-rewriter.d.ts +2 -0
- package/dist/esm/ecommerce-customhandler-rewriter.d.ts.map +1 -1
- package/dist/esm/ecommerce-customhandler-rewriter.js +38 -2
- package/dist/esm/ecommerce-customhandler-rewriter.js.map +1 -1
- package/dist/esm/executor-generator.d.ts.map +1 -1
- package/dist/esm/executor-generator.js +368 -60
- package/dist/esm/executor-generator.js.map +1 -1
- package/dist/esm/graph-utils.d.ts +9 -0
- package/dist/esm/graph-utils.d.ts.map +1 -1
- package/dist/esm/graph-utils.js +30 -0
- package/dist/esm/graph-utils.js.map +1 -1
- package/dist/esm/index.d.ts +20 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +27 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/invoice/api-routes-code.d.ts +9 -3
- package/dist/esm/invoice/api-routes-code.d.ts.map +1 -1
- package/dist/esm/invoice/api-routes-code.js +9 -7
- package/dist/esm/invoice/api-routes-code.js.map +1 -1
- package/dist/esm/invoice/index.d.ts.map +1 -1
- package/dist/esm/invoice/index.js +12 -7
- package/dist/esm/invoice/index.js.map +1 -1
- package/dist/esm/invoice/invoice-assembly-code.d.ts.map +1 -1
- package/dist/esm/invoice/invoice-assembly-code.js +8 -3
- package/dist/esm/invoice/invoice-assembly-code.js.map +1 -1
- package/dist/esm/invoice/pdf-generator-code.d.ts.map +1 -1
- package/dist/esm/invoice/pdf-generator-code.js +2 -1
- package/dist/esm/invoice/pdf-generator-code.js.map +1 -1
- package/dist/esm/invoice/pdf-service-client-code.d.ts.map +1 -1
- package/dist/esm/invoice/pdf-service-client-code.js +15 -7
- package/dist/esm/invoice/pdf-service-client-code.js.map +1 -1
- package/dist/esm/newsletter/admin-route-code.d.ts +60 -0
- package/dist/esm/newsletter/admin-route-code.d.ts.map +1 -0
- package/dist/esm/newsletter/admin-route-code.js +295 -0
- package/dist/esm/newsletter/admin-route-code.js.map +1 -0
- package/dist/esm/newsletter/helper-code.d.ts +109 -0
- package/dist/esm/newsletter/helper-code.d.ts.map +1 -0
- package/dist/esm/newsletter/helper-code.js +656 -0
- package/dist/esm/newsletter/helper-code.js.map +1 -0
- package/dist/esm/newsletter/newsletter-scope.d.ts +65 -0
- package/dist/esm/newsletter/newsletter-scope.d.ts.map +1 -0
- package/dist/esm/newsletter/newsletter-scope.js +97 -0
- package/dist/esm/newsletter/newsletter-scope.js.map +1 -0
- package/dist/esm/newsletter/project-plugin.d.ts +18 -0
- package/dist/esm/newsletter/project-plugin.d.ts.map +1 -0
- package/dist/esm/newsletter/project-plugin.js +93 -0
- package/dist/esm/newsletter/project-plugin.js.map +1 -0
- package/dist/esm/newsletter/routes-code.d.ts +6 -0
- package/dist/esm/newsletter/routes-code.d.ts.map +1 -0
- package/dist/esm/newsletter/routes-code.js +175 -0
- package/dist/esm/newsletter/routes-code.js.map +1 -0
- package/dist/esm/nodes/account/account-compare-passwords.d.ts.map +1 -1
- package/dist/esm/nodes/account/account-compare-passwords.js +16 -6
- package/dist/esm/nodes/account/account-compare-passwords.js.map +1 -1
- package/dist/esm/nodes/account/account-delete-current.js +1 -1
- package/dist/esm/nodes/account/account-get-current.js +1 -1
- package/dist/esm/nodes/account/account-hash-password.d.ts.map +1 -1
- package/dist/esm/nodes/account/account-hash-password.js +15 -3
- package/dist/esm/nodes/account/account-hash-password.js.map +1 -1
- package/dist/esm/nodes/account/account-login.d.ts.map +1 -1
- package/dist/esm/nodes/account/account-login.js +23 -6
- package/dist/esm/nodes/account/account-login.js.map +1 -1
- package/dist/esm/nodes/account/account-logout.js +1 -1
- package/dist/esm/nodes/account/account-refresh-session.js +1 -1
- package/dist/esm/nodes/account/account-request-password-reset.d.ts +3 -0
- package/dist/esm/nodes/account/account-request-password-reset.d.ts.map +1 -0
- package/dist/esm/nodes/account/account-request-password-reset.js +43 -0
- package/dist/esm/nodes/account/account-request-password-reset.js.map +1 -0
- package/dist/esm/nodes/account/account-reset-password.d.ts +3 -0
- package/dist/esm/nodes/account/account-reset-password.d.ts.map +1 -0
- package/dist/esm/nodes/account/account-reset-password.js +41 -0
- package/dist/esm/nodes/account/account-reset-password.js.map +1 -0
- package/dist/esm/nodes/account/account-signup.d.ts.map +1 -1
- package/dist/esm/nodes/account/account-signup.js +82 -19
- package/dist/esm/nodes/account/account-signup.js.map +1 -1
- package/dist/esm/nodes/account/account-social-login.js +1 -1
- package/dist/esm/nodes/ai/ai-custom-prompt.d.ts.map +1 -1
- package/dist/esm/nodes/ai/ai-custom-prompt.js +20 -5
- package/dist/esm/nodes/ai/ai-custom-prompt.js.map +1 -1
- package/dist/esm/nodes/ai/ai-detect-language.d.ts.map +1 -1
- package/dist/esm/nodes/ai/ai-detect-language.js +20 -5
- package/dist/esm/nodes/ai/ai-detect-language.js.map +1 -1
- package/dist/esm/nodes/ai/ai-generate-text-embedding.d.ts.map +1 -1
- package/dist/esm/nodes/ai/ai-generate-text-embedding.js +10 -2
- package/dist/esm/nodes/ai/ai-generate-text-embedding.js.map +1 -1
- package/dist/esm/nodes/ai/ai-provider-utils-sources.generated.js +2 -2
- package/dist/esm/nodes/ai/ai-provider-utils-sources.generated.js.map +1 -1
- package/dist/esm/nodes/ai/ai-provider-utils.d.ts +31 -2
- package/dist/esm/nodes/ai/ai-provider-utils.d.ts.map +1 -1
- package/dist/esm/nodes/ai/ai-provider-utils.js +124 -10
- package/dist/esm/nodes/ai/ai-provider-utils.js.map +1 -1
- package/dist/esm/nodes/ai/ai-select-database-data.d.ts.map +1 -1
- package/dist/esm/nodes/ai/ai-select-database-data.js +6 -2
- package/dist/esm/nodes/ai/ai-select-database-data.js.map +1 -1
- package/dist/esm/nodes/ai/ai-sentiment-analysis.d.ts.map +1 -1
- package/dist/esm/nodes/ai/ai-sentiment-analysis.js +20 -5
- package/dist/esm/nodes/ai/ai-sentiment-analysis.js.map +1 -1
- package/dist/esm/nodes/ai/ai-summarization.d.ts.map +1 -1
- package/dist/esm/nodes/ai/ai-summarization.js +20 -5
- package/dist/esm/nodes/ai/ai-summarization.js.map +1 -1
- package/dist/esm/nodes/ai/ai-text-classifier.d.ts.map +1 -1
- package/dist/esm/nodes/ai/ai-text-classifier.js +20 -5
- package/dist/esm/nodes/ai/ai-text-classifier.js.map +1 -1
- package/dist/esm/nodes/ai/ai-text-transform.d.ts.map +1 -1
- package/dist/esm/nodes/ai/ai-text-transform.js +20 -5
- package/dist/esm/nodes/ai/ai-text-transform.js.map +1 -1
- package/dist/esm/nodes/analytics/analytics-track-outcome.d.ts +3 -0
- package/dist/esm/nodes/analytics/analytics-track-outcome.d.ts.map +1 -0
- package/dist/esm/nodes/analytics/analytics-track-outcome.js +107 -0
- package/dist/esm/nodes/analytics/analytics-track-outcome.js.map +1 -0
- package/dist/esm/nodes/cart/cart-price-order.d.ts.map +1 -1
- package/dist/esm/nodes/cart/cart-price-order.js +161 -2
- package/dist/esm/nodes/cart/cart-price-order.js.map +1 -1
- package/dist/esm/nodes/cost-bearing-node-types.d.ts +4 -0
- package/dist/esm/nodes/cost-bearing-node-types.d.ts.map +1 -0
- package/dist/esm/nodes/cost-bearing-node-types.js +39 -0
- package/dist/esm/nodes/cost-bearing-node-types.js.map +1 -0
- package/dist/esm/nodes/data/data-select.d.ts.map +1 -1
- package/dist/esm/nodes/data/data-select.js +12 -2
- package/dist/esm/nodes/data/data-select.js.map +1 -1
- package/dist/esm/nodes/email/email-mailersend.d.ts.map +1 -1
- package/dist/esm/nodes/email/email-mailersend.js +15 -11
- package/dist/esm/nodes/email/email-mailersend.js.map +1 -1
- package/dist/esm/nodes/email/email-mailgun.d.ts.map +1 -1
- package/dist/esm/nodes/email/email-mailgun.js +15 -15
- package/dist/esm/nodes/email/email-mailgun.js.map +1 -1
- package/dist/esm/nodes/email/email-postmark.d.ts.map +1 -1
- package/dist/esm/nodes/email/email-postmark.js +15 -15
- package/dist/esm/nodes/email/email-postmark.js.map +1 -1
- package/dist/esm/nodes/email/email-resend.d.ts.map +1 -1
- package/dist/esm/nodes/email/email-resend.js +15 -15
- package/dist/esm/nodes/email/email-resend.js.map +1 -1
- package/dist/esm/nodes/email/email-sendgrid.d.ts.map +1 -1
- package/dist/esm/nodes/email/email-sendgrid.js +15 -15
- package/dist/esm/nodes/email/email-sendgrid.js.map +1 -1
- package/dist/esm/nodes/email/html-escape-code.d.ts +3 -0
- package/dist/esm/nodes/email/html-escape-code.d.ts.map +1 -0
- package/dist/esm/nodes/email/html-escape-code.js +18 -0
- package/dist/esm/nodes/email/html-escape-code.js.map +1 -0
- package/dist/esm/nodes/email/message-trust.d.ts +40 -0
- package/dist/esm/nodes/email/message-trust.d.ts.map +1 -0
- package/dist/esm/nodes/email/message-trust.js +161 -0
- package/dist/esm/nodes/email/message-trust.js.map +1 -0
- package/dist/esm/nodes/email/outbound-message-guard.d.ts +113 -0
- package/dist/esm/nodes/email/outbound-message-guard.d.ts.map +1 -0
- package/dist/esm/nodes/email/outbound-message-guard.js +452 -0
- package/dist/esm/nodes/email/outbound-message-guard.js.map +1 -0
- package/dist/esm/nodes/email/trusted-html-code.d.ts +22 -0
- package/dist/esm/nodes/email/trusted-html-code.d.ts.map +1 -0
- package/dist/esm/nodes/email/trusted-html-code.js +49 -0
- package/dist/esm/nodes/email/trusted-html-code.js.map +1 -0
- package/dist/esm/nodes/general/general-custom-js.d.ts.map +1 -1
- package/dist/esm/nodes/general/general-custom-js.js +44 -7
- package/dist/esm/nodes/general/general-custom-js.js.map +1 -1
- package/dist/esm/nodes/general/general-http-request.d.ts.map +1 -1
- package/dist/esm/nodes/general/general-http-request.js +431 -45
- package/dist/esm/nodes/general/general-http-request.js.map +1 -1
- package/dist/esm/nodes/general/general-rate-limiter.d.ts.map +1 -1
- package/dist/esm/nodes/general/general-rate-limiter.js +46 -78
- package/dist/esm/nodes/general/general-rate-limiter.js.map +1 -1
- package/dist/esm/nodes/general/general-wait.d.ts +3 -0
- package/dist/esm/nodes/general/general-wait.d.ts.map +1 -0
- package/dist/esm/nodes/general/general-wait.js +78 -0
- package/dist/esm/nodes/general/general-wait.js.map +1 -0
- package/dist/esm/nodes/general/visitor-request.d.ts +44 -0
- package/dist/esm/nodes/general/visitor-request.d.ts.map +1 -0
- package/dist/esm/nodes/general/visitor-request.js +65 -0
- package/dist/esm/nodes/general/visitor-request.js.map +1 -0
- package/dist/esm/nodes/index.d.ts.map +1 -1
- package/dist/esm/nodes/index.js +7 -1
- package/dist/esm/nodes/index.js.map +1 -1
- package/dist/esm/nodes/integrations/integration-slack.d.ts.map +1 -1
- package/dist/esm/nodes/integrations/integration-slack.js +17 -6
- package/dist/esm/nodes/integrations/integration-slack.js.map +1 -1
- package/dist/esm/nodes/newsletter/newsletter-confirm.d.ts +3 -0
- package/dist/esm/nodes/newsletter/newsletter-confirm.d.ts.map +1 -0
- package/dist/esm/nodes/newsletter/newsletter-confirm.js +38 -0
- package/dist/esm/nodes/newsletter/newsletter-confirm.js.map +1 -0
- package/dist/esm/nodes/newsletter/newsletter-subscribe.d.ts +7 -0
- package/dist/esm/nodes/newsletter/newsletter-subscribe.d.ts.map +1 -0
- package/dist/esm/nodes/newsletter/newsletter-subscribe.js +66 -0
- package/dist/esm/nodes/newsletter/newsletter-subscribe.js.map +1 -0
- package/dist/esm/nodes/newsletter/newsletter-unsubscribe.d.ts +3 -0
- package/dist/esm/nodes/newsletter/newsletter-unsubscribe.d.ts.map +1 -0
- package/dist/esm/nodes/newsletter/newsletter-unsubscribe.js +39 -0
- package/dist/esm/nodes/newsletter/newsletter-unsubscribe.js.map +1 -0
- package/dist/esm/nodes/realtime/realtime-join-channel.d.ts.map +1 -1
- package/dist/esm/nodes/realtime/realtime-join-channel.js +5 -4
- package/dist/esm/nodes/realtime/realtime-join-channel.js.map +1 -1
- package/dist/esm/nodes/realtime/realtime-send-channel-event.d.ts.map +1 -1
- package/dist/esm/nodes/realtime/realtime-send-channel-event.js +11 -2
- package/dist/esm/nodes/realtime/realtime-send-channel-event.js.map +1 -1
- package/dist/esm/nodes/realtime/realtime-send-channel-message.d.ts.map +1 -1
- package/dist/esm/nodes/realtime/realtime-send-channel-message.js +11 -2
- package/dist/esm/nodes/realtime/realtime-send-channel-message.js.map +1 -1
- package/dist/esm/nodes/sms/sms-infobip.d.ts.map +1 -1
- package/dist/esm/nodes/sms/sms-infobip.js +11 -8
- package/dist/esm/nodes/sms/sms-infobip.js.map +1 -1
- package/dist/esm/nodes/sms/sms-smsapi.d.ts.map +1 -1
- package/dist/esm/nodes/sms/sms-smsapi.js +11 -8
- package/dist/esm/nodes/sms/sms-smsapi.js.map +1 -1
- package/dist/esm/nodes/sms/sms-textmagic.d.ts.map +1 -1
- package/dist/esm/nodes/sms/sms-textmagic.js +11 -8
- package/dist/esm/nodes/sms/sms-textmagic.js.map +1 -1
- package/dist/esm/nodes/sms/sms-twilio.d.ts.map +1 -1
- package/dist/esm/nodes/sms/sms-twilio.js +12 -10
- package/dist/esm/nodes/sms/sms-twilio.js.map +1 -1
- package/dist/esm/nodes/types.d.ts +8 -1
- package/dist/esm/nodes/types.d.ts.map +1 -1
- package/dist/esm/nodes/utility/utility-similarity-scoring.d.ts.map +1 -1
- package/dist/esm/nodes/utility/utility-similarity-scoring.js +29 -10
- package/dist/esm/nodes/utility/utility-similarity-scoring.js.map +1 -1
- package/dist/esm/page-access-guard-generator.d.ts +23 -0
- package/dist/esm/page-access-guard-generator.d.ts.map +1 -0
- package/dist/esm/page-access-guard-generator.js +131 -0
- package/dist/esm/page-access-guard-generator.js.map +1 -0
- package/dist/esm/password-reset-route-generator.d.ts +119 -0
- package/dist/esm/password-reset-route-generator.d.ts.map +1 -0
- package/dist/esm/password-reset-route-generator.js +448 -0
- package/dist/esm/password-reset-route-generator.js.map +1 -0
- package/dist/esm/payments/payment-core-code.d.ts.map +1 -1
- package/dist/esm/payments/payment-core-code.js +12 -7
- package/dist/esm/payments/payment-core-code.js.map +1 -1
- package/dist/esm/project-code-scanner.d.ts +11 -0
- package/dist/esm/project-code-scanner.d.ts.map +1 -0
- package/dist/esm/project-code-scanner.js +75 -0
- package/dist/esm/project-code-scanner.js.map +1 -0
- package/dist/esm/public-step-guards.d.ts +122 -0
- package/dist/esm/public-step-guards.d.ts.map +1 -0
- package/dist/esm/public-step-guards.js +280 -0
- package/dist/esm/public-step-guards.js.map +1 -0
- package/dist/esm/publish-refusals.d.ts +66 -0
- package/dist/esm/publish-refusals.d.ts.map +1 -0
- package/dist/esm/publish-refusals.js +271 -0
- package/dist/esm/publish-refusals.js.map +1 -0
- package/dist/esm/realtime-generator.d.ts +63 -1
- package/dist/esm/realtime-generator.d.ts.map +1 -1
- package/dist/esm/realtime-generator.js +401 -229
- package/dist/esm/realtime-generator.js.map +1 -1
- package/dist/esm/runtime-storage-generator.d.ts +32 -1
- package/dist/esm/runtime-storage-generator.d.ts.map +1 -1
- package/dist/esm/runtime-storage-generator.js +264 -11
- package/dist/esm/runtime-storage-generator.js.map +1 -1
- package/dist/esm/security-runtime/index.d.ts +14 -0
- package/dist/esm/security-runtime/index.d.ts.map +1 -0
- package/dist/esm/security-runtime/index.js +37 -0
- package/dist/esm/security-runtime/index.js.map +1 -0
- package/dist/esm/security-runtime/security-runtime-code.d.ts +53 -0
- package/dist/esm/security-runtime/security-runtime-code.d.ts.map +1 -0
- package/dist/esm/security-runtime/security-runtime-code.js +575 -0
- package/dist/esm/security-runtime/security-runtime-code.js.map +1 -0
- package/dist/esm/security-scanner.d.ts +72 -3
- package/dist/esm/security-scanner.d.ts.map +1 -1
- package/dist/esm/security-scanner.js +217 -8
- package/dist/esm/security-scanner.js.map +1 -1
- package/dist/esm/segment-splitter.d.ts.map +1 -1
- package/dist/esm/segment-splitter.js +10 -2
- package/dist/esm/segment-splitter.js.map +1 -1
- package/dist/esm/segment-trust.d.ts +36 -0
- package/dist/esm/segment-trust.d.ts.map +1 -1
- package/dist/esm/segment-trust.js +146 -2
- package/dist/esm/segment-trust.js.map +1 -1
- package/dist/esm/self-call-headers.d.ts +31 -0
- package/dist/esm/self-call-headers.d.ts.map +1 -0
- package/dist/esm/self-call-headers.js +43 -0
- package/dist/esm/self-call-headers.js.map +1 -0
- package/dist/esm/sent-email-log/index.d.ts +7 -0
- package/dist/esm/sent-email-log/index.d.ts.map +1 -1
- package/dist/esm/sent-email-log/index.js +15 -0
- package/dist/esm/sent-email-log/index.js.map +1 -1
- package/dist/esm/sent-email-log/sent-email-log-code.d.ts +7 -0
- package/dist/esm/sent-email-log/sent-email-log-code.d.ts.map +1 -1
- package/dist/esm/sent-email-log/sent-email-log-code.js +17 -3
- package/dist/esm/sent-email-log/sent-email-log-code.js.map +1 -1
- package/dist/esm/server-custom-node-call.d.ts +79 -0
- package/dist/esm/server-custom-node-call.d.ts.map +1 -0
- package/dist/esm/server-custom-node-call.js +278 -0
- package/dist/esm/server-custom-node-call.js.map +1 -0
- package/dist/esm/server-runtime-code.d.ts +39 -12
- package/dist/esm/server-runtime-code.d.ts.map +1 -1
- package/dist/esm/server-runtime-code.js +483 -40
- package/dist/esm/server-runtime-code.js.map +1 -1
- package/dist/esm/session-cookie-resolver.d.ts +3 -1
- package/dist/esm/session-cookie-resolver.d.ts.map +1 -1
- package/dist/esm/session-revocation-generator.d.ts +39 -0
- package/dist/esm/session-revocation-generator.d.ts.map +1 -0
- package/dist/esm/session-revocation-generator.js +172 -0
- package/dist/esm/session-revocation-generator.js.map +1 -0
- package/dist/esm/slack-message-values.d.ts +6 -0
- package/dist/esm/slack-message-values.d.ts.map +1 -0
- package/dist/esm/slack-message-values.js +68 -0
- package/dist/esm/slack-message-values.js.map +1 -0
- package/dist/esm/transactional-email-code.d.ts +11 -0
- package/dist/esm/transactional-email-code.d.ts.map +1 -1
- package/dist/esm/transactional-email-code.js +28 -4
- package/dist/esm/transactional-email-code.js.map +1 -1
- package/dist/esm/trigger-generator.d.ts +2 -0
- package/dist/esm/trigger-generator.d.ts.map +1 -1
- package/dist/esm/trigger-generator.js +15 -3
- package/dist/esm/trigger-generator.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/visitor-step-limits.d.ts +66 -0
- package/dist/esm/visitor-step-limits.d.ts.map +1 -0
- package/dist/esm/visitor-step-limits.js +181 -0
- package/dist/esm/visitor-step-limits.js.map +1 -0
- package/dist/esm/webhook-generator.d.ts.map +1 -1
- package/dist/esm/webhook-generator.js +93 -15
- package/dist/esm/webhook-generator.js.map +1 -1
- package/dist/esm/webhook-signature-verification.d.ts.map +1 -1
- package/dist/esm/webhook-signature-verification.js +13 -3
- package/dist/esm/webhook-signature-verification.js.map +1 -1
- package/dist/esm/workflow-auth-generator.d.ts +4 -1
- package/dist/esm/workflow-auth-generator.d.ts.map +1 -1
- package/dist/esm/workflow-auth-generator.js +8 -3
- package/dist/esm/workflow-auth-generator.js.map +1 -1
- package/dist/esm/workflow-component-plugin.js +12 -4
- package/dist/esm/workflow-component-plugin.js.map +1 -1
- package/dist/esm/workflow-project-plugin.d.ts.map +1 -1
- package/dist/esm/workflow-project-plugin.js +306 -60
- package/dist/esm/workflow-project-plugin.js.map +1 -1
- package/dist/esm/workflow-scope.d.ts.map +1 -1
- package/dist/esm/workflow-scope.js +5 -0
- package/dist/esm/workflow-scope.js.map +1 -1
- package/package.json +4 -4
- package/src/account-delete-route-generator.ts +28 -4
- package/src/api-route-generator.ts +712 -134
- package/src/auth-generator.ts +1471 -142
- package/src/automations/activity-kicks.ts +139 -0
- package/src/automations/app-events-source.ts +117 -0
- package/src/automations/automations-project-plugin.ts +202 -0
- package/src/automations/automations-scope.ts +196 -0
- package/src/automations/dispatcher-source.ts +1072 -0
- package/src/automations/event-bus-source.ts +428 -0
- package/src/automations/handler-module-generator.ts +107 -0
- package/src/automations/hydrators-source.ts +647 -0
- package/src/booking-calendar-feed-route-generator.ts +8 -0
- package/src/configured-nextauth-url.ts +17 -0
- package/src/cron-request-verification.ts +55 -5
- package/src/data-api-route-generator.ts +780 -43
- package/src/ecommerce/parameterized-stock-chain.ts +52 -5
- package/src/ecommerce/place-order-guards.ts +785 -0
- package/src/ecommerce-customhandler-rewriter.ts +55 -2
- package/src/executor-generator.ts +372 -60
- package/src/graph-utils.ts +33 -0
- package/src/index.ts +70 -0
- package/src/invoice/api-routes-code.ts +20 -7
- package/src/invoice/index.ts +11 -6
- package/src/invoice/invoice-assembly-code.ts +8 -3
- package/src/invoice/pdf-generator-code.ts +2 -1
- package/src/invoice/pdf-service-client-code.ts +15 -7
- package/src/newsletter/admin-route-code.ts +319 -0
- package/src/newsletter/helper-code.ts +748 -0
- package/src/newsletter/newsletter-scope.ts +116 -0
- package/src/newsletter/project-plugin.ts +119 -0
- package/src/newsletter/routes-code.ts +186 -0
- package/src/nodes/account/account-compare-passwords.ts +17 -6
- package/src/nodes/account/account-delete-current.ts +1 -1
- package/src/nodes/account/account-get-current.ts +1 -1
- package/src/nodes/account/account-hash-password.ts +19 -3
- package/src/nodes/account/account-login.ts +24 -7
- package/src/nodes/account/account-logout.ts +1 -1
- package/src/nodes/account/account-refresh-session.ts +1 -1
- package/src/nodes/account/account-request-password-reset.ts +47 -0
- package/src/nodes/account/account-reset-password.ts +45 -0
- package/src/nodes/account/account-signup.ts +86 -20
- package/src/nodes/account/account-social-login.ts +1 -1
- package/src/nodes/ai/ai-custom-prompt.ts +25 -6
- package/src/nodes/ai/ai-detect-language.ts +25 -6
- package/src/nodes/ai/ai-generate-text-embedding.ts +16 -3
- package/src/nodes/ai/ai-provider-utils-sources.generated.ts +2 -2
- package/src/nodes/ai/ai-provider-utils.ts +135 -10
- package/src/nodes/ai/ai-select-database-data.ts +8 -3
- package/src/nodes/ai/ai-sentiment-analysis.ts +25 -6
- package/src/nodes/ai/ai-summarization.ts +25 -6
- package/src/nodes/ai/ai-text-classifier.ts +25 -6
- package/src/nodes/ai/ai-text-transform.ts +25 -6
- package/src/nodes/analytics/analytics-track-outcome.ts +111 -0
- package/src/nodes/cart/cart-price-order.ts +200 -2
- package/src/nodes/cost-bearing-node-types.ts +45 -0
- package/src/nodes/data/data-select.ts +11 -2
- package/src/nodes/email/email-mailersend.ts +16 -8
- package/src/nodes/email/email-mailgun.ts +17 -12
- package/src/nodes/email/email-postmark.ts +17 -12
- package/src/nodes/email/email-resend.ts +17 -12
- package/src/nodes/email/email-sendgrid.ts +17 -12
- package/src/nodes/email/html-escape-code.ts +21 -0
- package/src/nodes/email/message-trust.ts +198 -0
- package/src/nodes/email/outbound-message-guard.ts +572 -0
- package/src/nodes/email/trusted-html-code.ts +49 -0
- package/src/nodes/general/general-custom-js.ts +46 -7
- package/src/nodes/general/general-http-request.ts +449 -46
- package/src/nodes/general/general-rate-limiter.ts +54 -81
- package/src/nodes/general/general-wait.ts +80 -0
- package/src/nodes/general/visitor-request.ts +79 -0
- package/src/nodes/index.ts +12 -0
- package/src/nodes/integrations/integration-slack.ts +21 -6
- package/src/nodes/newsletter/newsletter-confirm.ts +44 -0
- package/src/nodes/newsletter/newsletter-subscribe.ts +78 -0
- package/src/nodes/newsletter/newsletter-unsubscribe.ts +43 -0
- package/src/nodes/realtime/realtime-join-channel.ts +5 -4
- package/src/nodes/realtime/realtime-send-channel-event.ts +13 -2
- package/src/nodes/realtime/realtime-send-channel-message.ts +13 -2
- package/src/nodes/sms/sms-infobip.ts +14 -4
- package/src/nodes/sms/sms-smsapi.ts +14 -4
- package/src/nodes/sms/sms-textmagic.ts +14 -4
- package/src/nodes/sms/sms-twilio.ts +14 -4
- package/src/nodes/types.ts +9 -1
- package/src/nodes/utility/utility-similarity-scoring.ts +33 -12
- package/src/page-access-guard-generator.ts +154 -0
- package/src/password-reset-route-generator.ts +531 -0
- package/src/payments/payment-core-code.ts +12 -7
- package/src/project-code-scanner.ts +98 -0
- package/src/public-step-guards.ts +448 -0
- package/src/publish-refusals.ts +459 -0
- package/src/realtime-generator.ts +457 -234
- package/src/runtime-storage-generator.ts +270 -11
- package/src/security-runtime/index.ts +53 -0
- package/src/security-runtime/security-runtime-code.ts +579 -0
- package/src/security-scanner.ts +253 -10
- package/src/segment-splitter.ts +10 -2
- package/src/segment-trust.ts +205 -2
- package/src/self-call-headers.ts +46 -0
- package/src/sent-email-log/index.ts +16 -0
- package/src/sent-email-log/sent-email-log-code.ts +30 -4
- package/src/server-custom-node-call.ts +331 -0
- package/src/server-runtime-code.ts +488 -40
- package/src/session-revocation-generator.ts +177 -0
- package/src/slack-message-values.ts +84 -0
- package/src/transactional-email-code.ts +30 -4
- package/src/trigger-generator.ts +19 -3
- package/src/visitor-step-limits.ts +228 -0
- package/src/webhook-generator.ts +94 -14
- package/src/webhook-signature-verification.ts +13 -3
- package/src/workflow-auth-generator.ts +9 -4
- package/src/workflow-component-plugin.ts +14 -4
- package/src/workflow-project-plugin.ts +374 -61
- package/src/workflow-scope.ts +6 -0
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
import { securityRuntimeSpecifier } from './security-runtime/security-runtime-code';
|
|
2
|
+
import { isCostBearingNodeType } from './nodes/cost-bearing-node-types';
|
|
1
3
|
import { nodeRegistry } from './nodes';
|
|
2
4
|
import { resolveHandlerEntryName } from './nodes/types';
|
|
3
|
-
import {
|
|
5
|
+
import { generalWait } from './nodes/general/general-wait';
|
|
6
|
+
import { needsVisitorRequest, VISITOR_REQUEST_INJECTION } from './nodes/general/visitor-request';
|
|
7
|
+
import { markVisitorBoundMessageNodes, markWebhookMessageNodes, PUBLIC_CALLER_INJECTION, } from './nodes/email/outbound-message-guard';
|
|
8
|
+
import { AI_PUBLIC_REFUSALS } from './nodes/ai/ai-provider-utils';
|
|
9
|
+
import { AUTOMATION_HANDLERS_PATH, automationEventType } from './automations/automations-scope';
|
|
10
|
+
import { AI_NODE_TYPES, collectCalledCustomNodeTypes } from './graph-utils';
|
|
4
11
|
import { generateWebhookBodyCode, generateAllSignatureVerificationCode, generatePaymentWebhookVerificationCode, } from './webhook-signature-verification';
|
|
5
12
|
import { buildWorkflowAuthInjection } from './workflow-auth-generator';
|
|
13
|
+
import { buildVisitorStepLimitGuard } from './visitor-step-limits';
|
|
6
14
|
import { hasEmailSendingNodeType, isEmailSendingNodeType, } from './sent-email-log/sent-email-log-scope';
|
|
7
15
|
import { workflowUtilsAliasLine } from './workflow-utils-alias';
|
|
8
16
|
import { adminCustomNodesRequireLine } from './custom-node-modules';
|
|
17
|
+
import { generateServerCustomNodeCallCode } from './server-custom-node-call';
|
|
9
18
|
import { generatePaymentDriversPreamble, isPaymentWebhookConfig, readWebhookPaymentProvider, } from './payments';
|
|
10
19
|
import { usesPaymentDriverNode } from './payments/payment-drivers-scope';
|
|
11
20
|
import { generateCartPricingPreamble } from './cart-pricing-preamble';
|
|
@@ -34,26 +43,203 @@ const resolveSegmentEntryNodeIds = (segment) => {
|
|
|
34
43
|
const targets = new Set(segment.edges.map((e) => e.target));
|
|
35
44
|
return segment.nodes.filter((n) => !targets.has(n.id)).map((n) => n.id);
|
|
36
45
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
export { isCostBearingNodeType };
|
|
47
|
+
/** Per visitor address, per route: a minute's and a day's allowance. */
|
|
48
|
+
export const COST_BEARING_STEP_LIMITS = { perMinute: 30, perDay: 300 };
|
|
49
|
+
/** What a visitor sees when a step fails; the detail stays in the server log. */
|
|
50
|
+
export const SEGMENT_PUBLIC_ERROR = 'Something went wrong. Please try again.';
|
|
51
|
+
/**
|
|
52
|
+
* The visitor's identity a route reads: what the graph says (current-user
|
|
53
|
+
* readers, identity-filtered reads, {{Current User.*}} tokens — see
|
|
54
|
+
* segment-trust.ts) plus the route's `userScoped` identity columns, which the
|
|
55
|
+
* route binds again after the node that produces them has run.
|
|
56
|
+
*/
|
|
57
|
+
const resolveSegmentSession = (options, protection) => {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
const needs = (_a = options.trust) === null || _a === void 0 ? void 0 : _a.session;
|
|
60
|
+
const bindings = (((_b = protection === null || protection === void 0 ? void 0 : protection.userScoped) === null || _b === void 0 ? void 0 : _b.bindings) || []);
|
|
61
|
+
if (!needs && bindings.length === 0) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
return Object.assign({ identityNodes: (needs === null || needs === void 0 ? void 0 : needs.identityNodes) || {}, identityReads: (needs === null || needs === void 0 ? void 0 : needs.identityReads) || {} }, (bindings.length > 0 ? { bindings } : {}));
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* The env var names a segment's node configs reference (project-secret
|
|
68
|
+
* references): a reply never carries one, even inside a node's error result.
|
|
69
|
+
*/
|
|
70
|
+
const collectSecretNames = (segment) => {
|
|
71
|
+
const names = new Set();
|
|
72
|
+
const walk = (value) => {
|
|
73
|
+
if (typeof value === 'string') {
|
|
74
|
+
if (/^WORKFLOW_SECRET_[A-Za-z0-9_]+$/.test(value)) {
|
|
75
|
+
names.add(value);
|
|
76
|
+
}
|
|
77
|
+
else if (value.indexOf('teleporthq.secrets.') === 0 && value.length > 19) {
|
|
78
|
+
names.add(value.slice(19));
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (!value || typeof value !== 'object') {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const ref = value;
|
|
86
|
+
if (ref.type === 'dynamic' &&
|
|
87
|
+
ref.content &&
|
|
88
|
+
ref.content.referenceType === 'secret' &&
|
|
89
|
+
typeof ref.content.id === 'string' &&
|
|
90
|
+
ref.content.id) {
|
|
91
|
+
names.add(ref.content.id);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
Object.keys(value).forEach((key) => walk(value[key]));
|
|
95
|
+
};
|
|
96
|
+
segment.nodes.forEach((n) => walk(n.config));
|
|
97
|
+
return Array.from(names).sort();
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Whether `nodes` run a cost-bearing step, themselves or through a custom node
|
|
101
|
+
* they call (transitively): in-process, a server-only custom node's own
|
|
102
|
+
* segments are internal calls, which the gate does not count.
|
|
103
|
+
*/
|
|
104
|
+
const runsCostBearingStep = (nodes, customNodes, visited = new Set()) => nodes.some((n) => {
|
|
105
|
+
if (isCostBearingNodeType(n.type)) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
const customNodeId = (n.config || {}).customNodeId;
|
|
109
|
+
if (n.type !== 'general-custom-node' || typeof customNodeId !== 'string') {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
if (visited.has(customNodeId)) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
visited.add(customNodeId);
|
|
116
|
+
const called = customNodes ? customNodes[customNodeId] : undefined;
|
|
117
|
+
return !!called && runsCostBearingStep(called.nodes || [], customNodes, visited);
|
|
118
|
+
});
|
|
119
|
+
/**
|
|
120
|
+
* The rate-limit scope of a segment route that runs a cost-bearing step, else
|
|
121
|
+
* null. Its own prefix: `workflow-step:<nodeId>` is a step's declared visitor
|
|
122
|
+
* limit (visitor-step-limits.ts).
|
|
123
|
+
*/
|
|
124
|
+
const resolveAbuseScope = (segment, workflowName, options) => {
|
|
125
|
+
var _a;
|
|
126
|
+
if (!runsCostBearingStep(segment.nodes, options.customNodes)) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
const owner = ((_a = options.trust) === null || _a === void 0 ? void 0 : _a.workflowId) || workflowName || 'workflow';
|
|
130
|
+
return `workflow-route:${owner}:${segment.id}`;
|
|
131
|
+
};
|
|
132
|
+
const SEGMENT_SECURITY_RUNTIME = securityRuntimeSpecifier('../../..');
|
|
133
|
+
/**
|
|
134
|
+
* Module-level code every segment route carries: the shared security runtime
|
|
135
|
+
* (required guarded, so a route still loads where it is absent — the abuse
|
|
136
|
+
* gate then refuses), the generic error a visitor sees, and the log line its
|
|
137
|
+
* detail goes to under the same opaque id.
|
|
138
|
+
*/
|
|
139
|
+
const SEGMENT_SECURITY_PREAMBLE = `// The shared security runtime: the generic error a visitor is shown (its detail
|
|
140
|
+
// stays in the server log, under the id the visitor sees) and the rate limit of
|
|
141
|
+
// a step that spends the site's money.
|
|
142
|
+
var __security = null;
|
|
143
|
+
try { __security = require('${SEGMENT_SECURITY_RUNTIME}'); } catch (_e) { __security = null; }
|
|
144
|
+
var __PUBLIC_ERROR = ${JSON.stringify(SEGMENT_PUBLIC_ERROR)};
|
|
145
|
+
// The refusals that name nothing secret (an AI step: a prompt too long, the
|
|
146
|
+
// site's daily AI budget spent, AI unavailable) are shown as they are, with
|
|
147
|
+
// their status; any other error is the generic one.
|
|
148
|
+
var __PUBLIC_REFUSALS = ${JSON.stringify(AI_PUBLIC_REFUSALS)};
|
|
149
|
+
function __publicRefusal(error) {
|
|
150
|
+
var message = error && typeof error.message === 'string' ? error.message : '';
|
|
151
|
+
return Object.prototype.hasOwnProperty.call(__PUBLIC_REFUSALS, message) ? message : null;
|
|
152
|
+
}
|
|
153
|
+
// Answers the generic error (when \`res\` can still answer) and logs \`error\`;
|
|
154
|
+
// returns the id the log line carries. An error the server runtime raised for
|
|
155
|
+
// the visitor to read (\`__tqPublic\`: a run that expired) keeps its message.
|
|
156
|
+
function __clientError(res, error) {
|
|
157
|
+
var own = error && error.__tqPublic && typeof error.__tqPublic.message === 'string' ? error.__tqPublic : null;
|
|
158
|
+
var refusal = own ? own.message : __publicRefusal(error);
|
|
159
|
+
var status = own ? own.status : refusal ? __PUBLIC_REFUSALS[refusal] : 500;
|
|
160
|
+
var message = refusal || __PUBLIC_ERROR;
|
|
161
|
+
if (__security && typeof __security.sendClientError === 'function') {
|
|
162
|
+
return __security.sendClientError(res, status, message, error);
|
|
163
|
+
}
|
|
164
|
+
console.error('Workflow segment error:', error);
|
|
165
|
+
if (res && !res.headersSent && typeof res.status === 'function') {
|
|
166
|
+
res.status(status).json({ error: message });
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
// What a parallel branch that failed reports: the generic error and its log id.
|
|
171
|
+
function __branchError(error) {
|
|
172
|
+
var id = __clientError({ headersSent: true }, error);
|
|
173
|
+
var message = __publicRefusal(error) || __PUBLIC_ERROR;
|
|
174
|
+
return id ? message + ' (' + id + ')' : message;
|
|
175
|
+
}
|
|
176
|
+
`;
|
|
177
|
+
/**
|
|
178
|
+
* First thing a segment route does when its segment spends the site's money
|
|
179
|
+
* or reaches outside it: count the visitor against this route, whatever the
|
|
180
|
+
* page's protection. This deployment's own server code (a webhook or cron
|
|
181
|
+
* running a custom node) carries the internal-call token and is not counted.
|
|
182
|
+
*/
|
|
183
|
+
const generateAbuseGateCode = (scope) => {
|
|
184
|
+
if (!scope) {
|
|
185
|
+
return '';
|
|
186
|
+
}
|
|
187
|
+
const { perMinute, perDay } = COST_BEARING_STEP_LIMITS;
|
|
188
|
+
const scopeLiteral = JSON.stringify(scope);
|
|
189
|
+
return `
|
|
190
|
+
// This step spends the site's money or reaches outside it (an AI model, a
|
|
191
|
+
// mail, SMS or payment provider, another site): every visitor address is
|
|
192
|
+
// allowed ${perMinute} calls a minute and ${perDay} a day here, whatever the page's
|
|
193
|
+
// protection. This deployment's own server code is not a visitor.
|
|
194
|
+
if (!utils.isInternalCall(req)) {
|
|
195
|
+
if (!__security) {
|
|
196
|
+
res.status(503).json({ error: 'This action is unavailable right now.' });
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
var __minute = { scope: ${scopeLiteral}, limit: ${perMinute}, windowSeconds: 60 };
|
|
200
|
+
if (!(await __security.rateLimitRequest(req, res, __minute))) return;
|
|
201
|
+
var __day = { scope: ${scopeLiteral}, limit: ${perDay}, windowSeconds: 86400 };
|
|
202
|
+
if (!(await __security.rateLimitRequest(req, res, __day))) return;
|
|
203
|
+
}`;
|
|
204
|
+
};
|
|
205
|
+
/** The session binding a route that reads the visitor runs before its guard and its nodes. */
|
|
206
|
+
const generateSessionBindCode = (session) => session
|
|
207
|
+
? `
|
|
208
|
+
// Who the visitor is comes from the session cookie, never from the request
|
|
209
|
+
// (see bindSessionIdentity in the server runtime).
|
|
210
|
+
await utils.bindSessionIdentity(req, SEGMENT_CONFIG, context);`
|
|
211
|
+
: '';
|
|
212
|
+
/** Module-level: the handlers that read or bind the visitor's identity, wrapped. */
|
|
213
|
+
const generateSessionHandlersCode = (session) => session && (Object.keys(session.identityReads).length > 0 || (session.bindings || []).length > 0)
|
|
214
|
+
? `// Identity-filtered reads and userScoped identity columns (see
|
|
215
|
+
// bindSessionHandlers in the server runtime).
|
|
216
|
+
utils.bindSessionHandlers(SEGMENT_CONFIG, nodeHandlers);
|
|
217
|
+
`
|
|
218
|
+
: '';
|
|
219
|
+
const buildSegmentConfig = (segment, options, session) => {
|
|
220
|
+
const secretNames = collectSecretNames(segment);
|
|
221
|
+
return JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (options.trust || {})), { session }), (secretNames.length > 0 ? { secretNames } : {})), { nodes: segment.nodes.map((n) => ({
|
|
222
|
+
id: n.id,
|
|
223
|
+
type: n.type,
|
|
224
|
+
config: n.config,
|
|
225
|
+
stepNumber: n.stepNumber,
|
|
226
|
+
label: n.label,
|
|
227
|
+
})), edges: segment.edges.map((e) => ({
|
|
228
|
+
id: e.id,
|
|
229
|
+
source: e.source,
|
|
230
|
+
target: e.target,
|
|
231
|
+
sourceHandle: e.sourceHandle,
|
|
232
|
+
targetHandle: e.targetHandle,
|
|
233
|
+
data: e.data,
|
|
234
|
+
})), entryNodeIds: resolveSegmentEntryNodeIds(segment) }), (options.customNodeIds ? { customNodeIds: options.customNodeIds } : {})), null, 2);
|
|
235
|
+
};
|
|
51
236
|
export const generateServerSegmentAPIRoute = (segment, workflowName, protection, options = {}) => {
|
|
52
237
|
const usedNodeTypes = new Set(segment.nodes.map((n) => n.type));
|
|
53
238
|
const nodeHandlersEntries = generateNodeHandlersForSegment(usedNodeTypes, true);
|
|
54
|
-
const hasRateLimiter = usedNodeTypes.has('general-rate-limiter');
|
|
55
239
|
const auth = buildWorkflowAuthInjection(protection);
|
|
56
|
-
const
|
|
240
|
+
const session = resolveSegmentSession(options, protection);
|
|
241
|
+
const abuseScope = resolveAbuseScope(segment, workflowName, options);
|
|
242
|
+
const segmentConfig = buildSegmentConfig(markVisitorBoundMessageNodes(segment, options.trust, protection, workflowName), options, session);
|
|
57
243
|
const header = workflowName
|
|
58
244
|
? `/**
|
|
59
245
|
* Workflow Server Segment API Route
|
|
@@ -66,20 +252,19 @@ export const generateServerSegmentAPIRoute = (segment, workflowName, protection,
|
|
|
66
252
|
* Segment ID: ${sanitizeForBlockComment(segment.id)}
|
|
67
253
|
*/
|
|
68
254
|
`;
|
|
69
|
-
const requestInjection =
|
|
70
|
-
? `\n context.__request = { ip: __getClientIp(req), headers: req.headers || {} };`
|
|
71
|
-
: '';
|
|
255
|
+
const requestInjection = needsVisitorRequest(usedNodeTypes) ? VISITOR_REQUEST_INJECTION : '';
|
|
72
256
|
return `${header}
|
|
73
257
|
const utils = require('../../../utils/workflows/server-runtime');
|
|
74
|
-
${auth.requireLine}const
|
|
258
|
+
${auth.requireLine}const resolveNodeConfig = utils.resolveNodeConfig;
|
|
75
259
|
${workflowUtilsAliasLine('utils')}
|
|
76
260
|
${generateCartPricingPreamble(usedNodeTypes, '../../..')}${generateSentEmailLogPreamble(usedNodeTypes, '../../..')}${generatePaymentDriversPreamble(usesPaymentDriverNode(usedNodeTypes), '../../..')}
|
|
261
|
+
${SEGMENT_SECURITY_PREAMBLE}
|
|
77
262
|
const SEGMENT_CONFIG = ${segmentConfig};
|
|
78
263
|
${auth.policyConst}
|
|
79
264
|
const nodeHandlers = {
|
|
80
265
|
${nodeHandlersEntries}
|
|
81
266
|
};
|
|
82
|
-
|
|
267
|
+
${generateServerCustomNodeCallCode(segment, '../../..')}${generateSessionHandlersCode(session)}
|
|
83
268
|
module.exports = async function handler(req, res) {
|
|
84
269
|
if (req.method !== 'POST') {
|
|
85
270
|
res.status(405).json({ error: 'Method not allowed' });
|
|
@@ -88,7 +273,7 @@ module.exports = async function handler(req, res) {
|
|
|
88
273
|
// Kept outside the try so the catch below can still drain any fire-and-forget
|
|
89
274
|
// query this segment started before it failed.
|
|
90
275
|
var __wfContext = null;
|
|
91
|
-
try {
|
|
276
|
+
try {${generateAbuseGateCode(abuseScope)}
|
|
92
277
|
const body = typeof req.body === 'string' ? JSON.parse(req.body) : req.body;
|
|
93
278
|
const incomingContext = body.context || {};
|
|
94
279
|
// What the caller already holds, so the reply below carries only what this
|
|
@@ -97,7 +282,7 @@ module.exports = async function handler(req, res) {
|
|
|
97
282
|
|
|
98
283
|
const context = Object.assign({}, incomingContext);
|
|
99
284
|
utils.claimSegmentContext(SEGMENT_CONFIG, context);
|
|
100
|
-
__wfContext = context
|
|
285
|
+
__wfContext = context;${generateSessionBindCode(session)}
|
|
101
286
|
// Created eagerly so a custom node invoked from here shares the SAME
|
|
102
287
|
// fire-and-forget queue (it shallow-copies this context) and its queries
|
|
103
288
|
// are drained by the settle below rather than being lost when we reply.
|
|
@@ -109,10 +294,18 @@ module.exports = async function handler(req, res) {
|
|
|
109
294
|
// without them a protected deployment 401s itself and every data node
|
|
110
295
|
// returns no rows. See internalRequestHeaders in runtime-utils.
|
|
111
296
|
context.__internalHeaders = utils.internalRequestHeaders(req);
|
|
297
|
+
// A server job's hop — a webhook, cron or automation running a custom
|
|
298
|
+
// node, which calls this route with the internal-call token only this
|
|
299
|
+
// deployment's server code can mint — stays the job's: its data calls keep
|
|
300
|
+
// the server-job flag (see __dataIsServerJob). A browser's request never
|
|
301
|
+
// carries the token, so never the flag.
|
|
302
|
+
if (utils.isInternalCall(req) && req.headers && req.headers['x-tq-server-job'] === '1') {
|
|
303
|
+
context.__internalHeaders['x-tq-server-job'] = '1';
|
|
304
|
+
}
|
|
112
305
|
// The language of the page this run started on — carried by the client
|
|
113
306
|
// context, else read off the request — so a customer email node sends the
|
|
114
307
|
// copy that matches the storefront the visitor is browsing.
|
|
115
|
-
context.__locale = utils.resolveWorkflowLocale(req, incomingContext);${auth.guardCall}
|
|
308
|
+
context.__locale = utils.resolveWorkflowLocale(req, incomingContext);${auth.guardCall}${buildVisitorStepLimitGuard(segment)}
|
|
116
309
|
const sortedNodes = SEGMENT_CONFIG.nodes.slice().sort(function(a, b) { return a.stepNumber - b.stepNumber; });
|
|
117
310
|
|
|
118
311
|
for (let i = 0; i < sortedNodes.length; i++) {
|
|
@@ -122,7 +315,7 @@ module.exports = async function handler(req, res) {
|
|
|
122
315
|
// the caller as if that branch had run (a custom node answers the output
|
|
123
316
|
// of the last node it ran).
|
|
124
317
|
if (context.__skippedNodes && context.__skippedNodes[node.id]) continue;
|
|
125
|
-
const resolved =
|
|
318
|
+
const resolved = resolveNodeConfig(node, context);
|
|
126
319
|
// Every data node lives in a SERVER segment, so this guard — which turns an
|
|
127
320
|
// unresolved {{…}} into a validation error instead of letting the literal
|
|
128
321
|
// token reach SQL — was doing nothing at all: it ran only in the CLIENT
|
|
@@ -135,7 +328,7 @@ module.exports = async function handler(req, res) {
|
|
|
135
328
|
// rather than the stub handler, which always returns { result: true }.
|
|
136
329
|
// After evaluating, mark the non-taken branch nodes as skipped.
|
|
137
330
|
if (node.type === 'general-if-statement') {
|
|
138
|
-
const condResult = utils.evaluateCondition(resolved, context);
|
|
331
|
+
const condResult = utils.evaluateCondition(resolved, context, node.config);
|
|
139
332
|
context[node.id] = { result: condResult };
|
|
140
333
|
var skipHandle = condResult ? 'false' : 'true';
|
|
141
334
|
var segEdgesIf = SEGMENT_CONFIG.edges || [];
|
|
@@ -214,10 +407,10 @@ module.exports = async function handler(req, res) {
|
|
|
214
407
|
context[node.id] = utils.loopIterationContext(collection, li);
|
|
215
408
|
for (var bi = 0; bi < bodyNodes.length; bi++) {
|
|
216
409
|
var bNode = bodyNodes[bi];
|
|
217
|
-
var bResolved =
|
|
410
|
+
var bResolved = resolveNodeConfig(bNode, context);
|
|
218
411
|
bResolved.__nodeId = bNode.id;
|
|
219
412
|
if (bNode.type === 'general-if-statement') {
|
|
220
|
-
context[bNode.id] = { result: utils.evaluateCondition(bResolved, context) };
|
|
413
|
+
context[bNode.id] = { result: utils.evaluateCondition(bResolved, context, bNode.config) };
|
|
221
414
|
continue;
|
|
222
415
|
}
|
|
223
416
|
var bHandler = nodeHandlers[bNode.type];
|
|
@@ -252,17 +445,9 @@ module.exports = async function handler(req, res) {
|
|
|
252
445
|
|
|
253
446
|
// Switch nodes evaluate a value, match a case, execute that branch, skip all others
|
|
254
447
|
if (node.type === 'general-switch') {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
var matchedCase =
|
|
258
|
-
for (var swci = 0; swci < switchCases.length; swci++) {
|
|
259
|
-
var caseVal = utils.resolveValue(switchCases[swci].condition, context);
|
|
260
|
-
if (resolved.comparisonMode === 'expression') {
|
|
261
|
-
try { if (new Function('value', 'context', 'return (' + caseVal + ')')(switchVal, context)) { matchedCase = switchCases[swci].id; break; } } catch(e) {}
|
|
262
|
-
} else {
|
|
263
|
-
if (switchVal === caseVal) { matchedCase = switchCases[swci].id; break; }
|
|
264
|
-
}
|
|
265
|
-
}
|
|
448
|
+
// Only an authored case expression is compiled; request text is data
|
|
449
|
+
// (see matchSwitchCase in runtime-utils).
|
|
450
|
+
var matchedCase = utils.matchSwitchCase(node.config, resolved, context);
|
|
266
451
|
context[node.id] = { matchedCase: matchedCase };
|
|
267
452
|
var segSwitchEdges = SEGMENT_CONFIG.edges || [];
|
|
268
453
|
var allSwitchBranchEdges = segSwitchEdges.filter(function(e) { return e.source === node.id; });
|
|
@@ -308,7 +493,7 @@ module.exports = async function handler(req, res) {
|
|
|
308
493
|
return (async function() {
|
|
309
494
|
for (var pbi = 0; pbi < branchNodes.length; pbi++) {
|
|
310
495
|
var pNode = branchNodes[pbi];
|
|
311
|
-
var pRes =
|
|
496
|
+
var pRes = resolveNodeConfig(pNode, branchCtx);
|
|
312
497
|
pRes.__nodeId = pNode.id;
|
|
313
498
|
var pHandler = nodeHandlers[pNode.type];
|
|
314
499
|
if (!pHandler) continue;
|
|
@@ -327,7 +512,8 @@ module.exports = async function handler(req, res) {
|
|
|
327
512
|
branchNodes.forEach(function(bn) { context[bn.id] = bc[bn.id]; });
|
|
328
513
|
return { success: true };
|
|
329
514
|
}).catch(function(err) {
|
|
330
|
-
|
|
515
|
+
// The branch result reaches the browser: the detail stays in the log.
|
|
516
|
+
return { success: false, error: __branchError(err) };
|
|
331
517
|
});
|
|
332
518
|
});
|
|
333
519
|
var parallelResults;
|
|
@@ -404,9 +590,10 @@ module.exports = async function handler(req, res) {
|
|
|
404
590
|
delete context.__internalHeaders;
|
|
405
591
|
res.status(200).json({ success: true, results: utils.segmentReply(SEGMENT_CONFIG, context, __incomingSnapshot) });
|
|
406
592
|
} catch (error) {
|
|
407
|
-
console.error('Workflow segment error:', error);
|
|
408
593
|
if (__wfContext) { await utils.handOffPendingNodePromises(__wfContext); }
|
|
409
|
-
|
|
594
|
+
// A generic error and an opaque id: a driver, provider or secret-name
|
|
595
|
+
// detail never reaches the browser (it is logged under the same id).
|
|
596
|
+
__clientError(res, error);
|
|
410
597
|
}
|
|
411
598
|
};
|
|
412
599
|
`;
|
|
@@ -417,27 +604,27 @@ export const hasStreamingAINode = (segment) => {
|
|
|
417
604
|
export const generateStreamingServerSegmentAPIRoute = (segment, workflowName, protection, options = {}) => {
|
|
418
605
|
const usedNodeTypes = new Set(segment.nodes.map((n) => n.type));
|
|
419
606
|
const nodeHandlersEntries = generateNodeHandlersForSegment(usedNodeTypes, true);
|
|
420
|
-
const hasRateLimiter = usedNodeTypes.has('general-rate-limiter');
|
|
421
607
|
const auth = buildWorkflowAuthInjection(protection);
|
|
422
|
-
const
|
|
608
|
+
const session = resolveSegmentSession(options, protection);
|
|
609
|
+
const abuseScope = resolveAbuseScope(segment, workflowName, options);
|
|
610
|
+
const segmentConfig = buildSegmentConfig(markVisitorBoundMessageNodes(segment, options.trust, protection, workflowName), options, session);
|
|
423
611
|
const aiNodeTypes = JSON.stringify(Array.from(AI_NODE_TYPES));
|
|
424
612
|
const header = workflowName
|
|
425
613
|
? `/**\n * Workflow Streaming Server Segment API Route\n * Workflow: ${sanitizeForBlockComment(workflowName)}\n * Segment ID: ${sanitizeForBlockComment(segment.id)}\n */\n`
|
|
426
614
|
: `/**\n * Workflow Streaming Server Segment API Route\n * Segment ID: ${sanitizeForBlockComment(segment.id)}\n */\n`;
|
|
427
|
-
const requestInjection =
|
|
428
|
-
? `\n context.__request = { ip: __getClientIp(req), headers: req.headers || {} };`
|
|
429
|
-
: '';
|
|
615
|
+
const requestInjection = needsVisitorRequest(usedNodeTypes) ? VISITOR_REQUEST_INJECTION : '';
|
|
430
616
|
return `${header}
|
|
431
617
|
const utils = require('../../../utils/workflows/server-runtime');
|
|
432
|
-
${auth.requireLine}const
|
|
618
|
+
${auth.requireLine}const resolveNodeConfig = utils.resolveNodeConfig;
|
|
433
619
|
${workflowUtilsAliasLine('utils')}
|
|
434
620
|
${generateCartPricingPreamble(usedNodeTypes, '../../..')}${generateSentEmailLogPreamble(usedNodeTypes, '../../..')}${generatePaymentDriversPreamble(usesPaymentDriverNode(usedNodeTypes), '../../..')}
|
|
621
|
+
${SEGMENT_SECURITY_PREAMBLE}
|
|
435
622
|
const SEGMENT_CONFIG = ${segmentConfig};
|
|
436
623
|
${auth.policyConst}
|
|
437
624
|
const nodeHandlers = {
|
|
438
625
|
${nodeHandlersEntries}
|
|
439
626
|
};
|
|
440
|
-
|
|
627
|
+
${generateServerCustomNodeCallCode(segment, '../../..')}${generateSessionHandlersCode(session)}
|
|
441
628
|
const __streamingAITypes = ${aiNodeTypes};
|
|
442
629
|
|
|
443
630
|
function __isStreamingAI(node, config) {
|
|
@@ -452,7 +639,7 @@ function __streamNodeResult(res, nodeId, result) {
|
|
|
452
639
|
if (__credentialResultIds[nodeId]) return;
|
|
453
640
|
const kept = SEGMENT_CONFIG.nodes.find(function(nd) { return nd.id === nodeId; });
|
|
454
641
|
if (kept && kept.config && kept.config.keepResultOnServer === true && !utils.isBranchingNodeType(kept.type)) return;
|
|
455
|
-
res.write('data: ' + JSON.stringify({ type: 'node-result', nodeId: nodeId, result: utils.withoutCredentialColumns(kept, result) }) + '\\n\\n');
|
|
642
|
+
res.write('data: ' + JSON.stringify({ type: 'node-result', nodeId: nodeId, result: utils.scrubSecretNames(SEGMENT_CONFIG, utils.withoutCredentialColumns(kept, result)) }) + '\\n\\n');
|
|
456
643
|
}
|
|
457
644
|
|
|
458
645
|
function __collectSegBranchNodes(startId, excludeId) {
|
|
@@ -493,13 +680,13 @@ module.exports = async function handler(req, res) {
|
|
|
493
680
|
// Kept outside the try so the catch below can still drain any fire-and-forget
|
|
494
681
|
// query this segment started before it failed.
|
|
495
682
|
var __wfContext = null;
|
|
496
|
-
try {
|
|
683
|
+
try {${generateAbuseGateCode(abuseScope)}
|
|
497
684
|
const body = typeof req.body === 'string' ? JSON.parse(req.body) : req.body;
|
|
498
685
|
const context = Object.assign({}, body.context || {});
|
|
499
686
|
// See the non-streaming segment route: the reply carries only what changed.
|
|
500
687
|
const __incomingSnapshot = utils.snapshotIncomingContext(body.context || {});
|
|
501
688
|
utils.claimSegmentContext(SEGMENT_CONFIG, context);
|
|
502
|
-
__wfContext = context
|
|
689
|
+
__wfContext = context;${generateSessionBindCode(session)}
|
|
503
690
|
// See the non-streaming segment route — shared queue for nested custom nodes.
|
|
504
691
|
context.__pendingNodePromises = [];${requestInjection}
|
|
505
692
|
// Where this deployment calls its own routes — never a host the request
|
|
@@ -509,15 +696,23 @@ module.exports = async function handler(req, res) {
|
|
|
509
696
|
// without them a protected deployment 401s itself and every data node
|
|
510
697
|
// returns no rows. See internalRequestHeaders in runtime-utils.
|
|
511
698
|
context.__internalHeaders = utils.internalRequestHeaders(req);
|
|
699
|
+
// A server job's hop — a webhook, cron or automation running a custom
|
|
700
|
+
// node, which calls this route with the internal-call token only this
|
|
701
|
+
// deployment's server code can mint — stays the job's: its data calls keep
|
|
702
|
+
// the server-job flag (see __dataIsServerJob). A browser's request never
|
|
703
|
+
// carries the token, so never the flag.
|
|
704
|
+
if (utils.isInternalCall(req) && req.headers && req.headers['x-tq-server-job'] === '1') {
|
|
705
|
+
context.__internalHeaders['x-tq-server-job'] = '1';
|
|
706
|
+
}
|
|
512
707
|
// See the non-streaming segment route: the run's language.
|
|
513
|
-
context.__locale = utils.resolveWorkflowLocale(req, body.context);${auth.guardCall}
|
|
708
|
+
context.__locale = utils.resolveWorkflowLocale(req, body.context);${auth.guardCall}${buildVisitorStepLimitGuard(segment)}
|
|
514
709
|
const sortedNodes = SEGMENT_CONFIG.nodes.slice().sort(function(a, b) { return a.stepNumber - b.stepNumber; });
|
|
515
710
|
const executed = {};
|
|
516
711
|
|
|
517
712
|
for (let i = 0; i < sortedNodes.length; i++) {
|
|
518
713
|
const node = sortedNodes[i];
|
|
519
714
|
if (executed[node.id]) continue;
|
|
520
|
-
const resolved =
|
|
715
|
+
const resolved = resolveNodeConfig(node, context);
|
|
521
716
|
// See the non-streaming segment above — without this the unresolved-token
|
|
522
717
|
// guard never runs on the server, which is where every data node executes.
|
|
523
718
|
const __configError = utils.finalizeResolvedConfig(node.type, resolved);
|
|
@@ -526,7 +721,7 @@ module.exports = async function handler(req, res) {
|
|
|
526
721
|
|
|
527
722
|
// If-statement nodes must be evaluated using the runtime's evaluateCondition
|
|
528
723
|
if (node.type === 'general-if-statement') {
|
|
529
|
-
const condResult = utils.evaluateCondition(resolved, context);
|
|
724
|
+
const condResult = utils.evaluateCondition(resolved, context, node.config);
|
|
530
725
|
context[node.id] = { result: condResult };
|
|
531
726
|
executed[node.id] = true;
|
|
532
727
|
if (streamStarted) {
|
|
@@ -572,10 +767,10 @@ module.exports = async function handler(req, res) {
|
|
|
572
767
|
context[node.id] = utils.loopIterationContext(ssLoopCollection, ssli);
|
|
573
768
|
for (var ssbi = 0; ssbi < ssBodyNodes.length; ssbi++) {
|
|
574
769
|
var ssbNode = ssBodyNodes[ssbi];
|
|
575
|
-
var ssbRes =
|
|
770
|
+
var ssbRes = resolveNodeConfig(ssbNode, context);
|
|
576
771
|
ssbRes.__nodeId = ssbNode.id;
|
|
577
772
|
if (ssbNode.type === 'general-if-statement') {
|
|
578
|
-
context[ssbNode.id] = { result: utils.evaluateCondition(ssbRes, context) };
|
|
773
|
+
context[ssbNode.id] = { result: utils.evaluateCondition(ssbRes, context, ssbNode.config) };
|
|
579
774
|
continue;
|
|
580
775
|
}
|
|
581
776
|
var ssbHandler = nodeHandlers[ssbNode.type];
|
|
@@ -604,17 +799,8 @@ module.exports = async function handler(req, res) {
|
|
|
604
799
|
|
|
605
800
|
// Switch nodes in streaming segments
|
|
606
801
|
if (node.type === 'general-switch') {
|
|
607
|
-
|
|
608
|
-
var
|
|
609
|
-
var ssMatchedCase = 'default';
|
|
610
|
-
for (var ssswci = 0; ssswci < ssSwitchCases.length; ssswci++) {
|
|
611
|
-
var ssCaseVal = utils.resolveValue(ssSwitchCases[ssswci].condition, context);
|
|
612
|
-
if (resolved.comparisonMode === 'expression') {
|
|
613
|
-
try { if (new Function('value', 'context', 'return (' + ssCaseVal + ')')(ssSwitchVal, context)) { ssMatchedCase = ssSwitchCases[ssswci].id; break; } } catch(e) {}
|
|
614
|
-
} else {
|
|
615
|
-
if (ssSwitchVal === ssCaseVal) { ssMatchedCase = ssSwitchCases[ssswci].id; break; }
|
|
616
|
-
}
|
|
617
|
-
}
|
|
802
|
+
// See the non-streaming segment route: only authored expressions run.
|
|
803
|
+
var ssMatchedCase = utils.matchSwitchCase(node.config, resolved, context);
|
|
618
804
|
context[node.id] = { matchedCase: ssMatchedCase };
|
|
619
805
|
executed[node.id] = true;
|
|
620
806
|
var ssSwitchEdges = SEGMENT_CONFIG.edges || [];
|
|
@@ -664,7 +850,7 @@ module.exports = async function handler(req, res) {
|
|
|
664
850
|
return (async function() {
|
|
665
851
|
for (var sspbi = 0; sspbi < ssPBranchNodes.length; sspbi++) {
|
|
666
852
|
var sspNode = ssPBranchNodes[sspbi];
|
|
667
|
-
var sspRes =
|
|
853
|
+
var sspRes = resolveNodeConfig(sspNode, ssPBranchCtx);
|
|
668
854
|
sspRes.__nodeId = sspNode.id;
|
|
669
855
|
var sspHandler = nodeHandlers[sspNode.type];
|
|
670
856
|
if (!sspHandler) continue;
|
|
@@ -683,7 +869,8 @@ module.exports = async function handler(req, res) {
|
|
|
683
869
|
ssPBranchNodes.forEach(function(bn) { context[bn.id] = bc[bn.id]; });
|
|
684
870
|
return { success: true };
|
|
685
871
|
}).catch(function(err) {
|
|
686
|
-
|
|
872
|
+
// The branch result reaches the browser: the detail stays in the log.
|
|
873
|
+
return { success: false, error: __branchError(err) };
|
|
687
874
|
});
|
|
688
875
|
});
|
|
689
876
|
var ssParallelResults;
|
|
@@ -746,7 +933,8 @@ module.exports = async function handler(req, res) {
|
|
|
746
933
|
const sn = onStreamNodes[si];
|
|
747
934
|
const snHandler = nodeHandlers[sn.type];
|
|
748
935
|
if (!snHandler) continue;
|
|
749
|
-
const snResolved =
|
|
936
|
+
const snResolved = resolveNodeConfig(sn, context);
|
|
937
|
+
snResolved.__nodeId = sn.id;
|
|
750
938
|
if (utils.isFireAndForgetNode(sn)) {
|
|
751
939
|
utils.registerPendingNodePromise(context, utils.startFireAndForgetNode(sn, snHandler, snResolved, context));
|
|
752
940
|
context[sn.id] = null;
|
|
@@ -770,7 +958,8 @@ module.exports = async function handler(req, res) {
|
|
|
770
958
|
const en = onEndNodes[oi];
|
|
771
959
|
const enHandler = nodeHandlers[en.type];
|
|
772
960
|
if (!enHandler) continue;
|
|
773
|
-
const enResolved =
|
|
961
|
+
const enResolved = resolveNodeConfig(en, context);
|
|
962
|
+
enResolved.__nodeId = en.id;
|
|
774
963
|
if (utils.isFireAndForgetNode(en)) {
|
|
775
964
|
utils.registerPendingNodePromise(context, utils.startFireAndForgetNode(en, enHandler, enResolved, context));
|
|
776
965
|
context[en.id] = null;
|
|
@@ -837,20 +1026,51 @@ module.exports = async function handler(req, res) {
|
|
|
837
1026
|
res.status(200).json({ success: true, results: __reply });
|
|
838
1027
|
}
|
|
839
1028
|
} catch (error) {
|
|
840
|
-
console.error('Streaming workflow segment error:', error);
|
|
841
1029
|
if (__wfContext) { await utils.handOffPendingNodePromises(__wfContext); }
|
|
1030
|
+
// See the non-streaming segment route: a generic error and an opaque id.
|
|
842
1031
|
if (streamStarted) {
|
|
1032
|
+
var __errorId = __clientError({ headersSent: true }, error);
|
|
843
1033
|
try {
|
|
844
|
-
res.write('data: ' + JSON.stringify({ type: 'error', error: error
|
|
1034
|
+
res.write('data: ' + JSON.stringify({ type: 'error', error: __publicRefusal(error) || __PUBLIC_ERROR, id: __errorId }) + '\\n\\n');
|
|
845
1035
|
} catch(e) {}
|
|
846
1036
|
res.end();
|
|
847
1037
|
} else {
|
|
848
|
-
res
|
|
1038
|
+
__clientError(res, error);
|
|
849
1039
|
}
|
|
850
1040
|
}
|
|
851
1041
|
};
|
|
852
1042
|
`;
|
|
853
1043
|
};
|
|
1044
|
+
/**
|
|
1045
|
+
* A node an automation cannot run: one that only works in a visitor's
|
|
1046
|
+
* browser. The editor refuses them in automations; a handler module that
|
|
1047
|
+
* still meets one fails the run with the reason instead of stubbing it the
|
|
1048
|
+
* way a webhook route does (a stub would report a step that never happened).
|
|
1049
|
+
*/
|
|
1050
|
+
const isBrowserOnlyNode = (nodeType, generator) => CLIENT_ONLY_NODES.has(nodeType) ||
|
|
1051
|
+
(!!generator && generator.executionEnv === 'client' && !generator.generateServerHandler);
|
|
1052
|
+
/**
|
|
1053
|
+
* The step types a cron, webhook or automation route needs handlers for: its
|
|
1054
|
+
* own, and those of every custom node it calls, recursively — it runs them in
|
|
1055
|
+
* process (`utils/workflows/custom-nodes.js`) with this route's handler map. A
|
|
1056
|
+
* custom node's browser-only steps stay without one, as before (the runner
|
|
1057
|
+
* skips a step it has no handler for).
|
|
1058
|
+
*/
|
|
1059
|
+
const jobRouteNodeTypes = (ownNodes, customNodes) => {
|
|
1060
|
+
const types = new Set(ownNodes.map((n) => n.type));
|
|
1061
|
+
for (const type of collectCalledCustomNodeTypes(ownNodes, customNodes)) {
|
|
1062
|
+
if (!isBrowserOnlyNode(type, nodeRegistry[type])) {
|
|
1063
|
+
types.add(type);
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
return types;
|
|
1067
|
+
};
|
|
1068
|
+
const generateBrowserOnlyAutomationHandler = (nodeType) => {
|
|
1069
|
+
const fnName = nodeType.replace(/-/g, '_');
|
|
1070
|
+
return `async function ${fnName}(config, context) {
|
|
1071
|
+
throw new Error(${JSON.stringify(`The ${nodeType} step only runs in a visitor's browser, so an automation cannot run it`)});
|
|
1072
|
+
}`;
|
|
1073
|
+
};
|
|
854
1074
|
const generateClientOnlyServerStub = (nodeType) => {
|
|
855
1075
|
const fnName = nodeType.replace(/-/g, '_');
|
|
856
1076
|
return `async function ${fnName}(config, context) {
|
|
@@ -906,14 +1126,17 @@ function __wrapEmailHandler(nodeType, handler) {
|
|
|
906
1126
|
}
|
|
907
1127
|
`;
|
|
908
1128
|
};
|
|
909
|
-
const generateNodeHandlersForSegment = (usedNodeTypes, forServer = false) => {
|
|
1129
|
+
const generateNodeHandlersForSegment = (usedNodeTypes, forServer = false, automation = false, serverHandlerOptions = {}) => {
|
|
910
1130
|
return Array.from(usedNodeTypes)
|
|
911
1131
|
.map((nodeType) => {
|
|
912
|
-
const generator = nodeRegistry[nodeType];
|
|
1132
|
+
const generator = automation && nodeType === generalWait.nodeType ? generalWait : nodeRegistry[nodeType];
|
|
913
1133
|
let source;
|
|
914
|
-
if (generator) {
|
|
1134
|
+
if (automation && isBrowserOnlyNode(nodeType, generator)) {
|
|
1135
|
+
source = generateBrowserOnlyAutomationHandler(nodeType);
|
|
1136
|
+
}
|
|
1137
|
+
else if (generator) {
|
|
915
1138
|
if (forServer && generator.generateServerHandler) {
|
|
916
|
-
source = generator.generateServerHandler();
|
|
1139
|
+
source = generator.generateServerHandler(serverHandlerOptions);
|
|
917
1140
|
}
|
|
918
1141
|
else if (forServer && generator.executionEnv === 'client') {
|
|
919
1142
|
source = generateClientOnlyServerStub(nodeType);
|
|
@@ -940,7 +1163,12 @@ async function ${nodeType.replace(/-/g, '_')}(config, context) {
|
|
|
940
1163
|
})
|
|
941
1164
|
.join(',\n');
|
|
942
1165
|
};
|
|
943
|
-
|
|
1166
|
+
/**
|
|
1167
|
+
* The browser-only nodes a server route drops (and an automation refuses).
|
|
1168
|
+
* The editor's copy is `CLIENT_ONLY_NODE_TYPES` in teleport-gui
|
|
1169
|
+
* `packages/workflow-schema`; automations-catalog-drift.test.ts compares them.
|
|
1170
|
+
*/
|
|
1171
|
+
export const CLIENT_ONLY_NODES = new Set([
|
|
944
1172
|
'navigation-go-to-page',
|
|
945
1173
|
'navigation-navigate-to-url',
|
|
946
1174
|
'navigation-refresh-page',
|
|
@@ -1001,11 +1229,29 @@ const CLIENT_ONLY_NODES = new Set([
|
|
|
1001
1229
|
'realtime-list-channels',
|
|
1002
1230
|
'realtime-list-channel-members',
|
|
1003
1231
|
]);
|
|
1004
|
-
|
|
1232
|
+
/**
|
|
1233
|
+
* What a cron or webhook route hands its nodes as `context.__request`: the
|
|
1234
|
+
* caller's ip for a rate limiter, and the request's headers for a signup in a
|
|
1235
|
+
* project with automations, which records its event on the origin the request
|
|
1236
|
+
* reached (see account-signup).
|
|
1237
|
+
*/
|
|
1238
|
+
const serverRouteRequestInjection = (nodeTypes, withAutomations) => {
|
|
1239
|
+
if (nodeTypes.has('general-rate-limiter')) {
|
|
1240
|
+
return VISITOR_REQUEST_INJECTION;
|
|
1241
|
+
}
|
|
1242
|
+
if (withAutomations && nodeTypes.has('account-signup')) {
|
|
1243
|
+
return `\n // The signup records its event on the origin this request reached.\n context.__request = { headers: req.headers || {} };`;
|
|
1244
|
+
}
|
|
1245
|
+
return '';
|
|
1246
|
+
};
|
|
1247
|
+
export const generateCronAPIRoute = (workflow, customNodes, options = {}) => {
|
|
1005
1248
|
const serverNodes = workflow.nodes.filter((n) => !CLIENT_ONLY_NODES.has(n.type));
|
|
1006
|
-
const allNodeTypes =
|
|
1007
|
-
|
|
1008
|
-
const
|
|
1249
|
+
const allNodeTypes = jobRouteNodeTypes(serverNodes, customNodes);
|
|
1250
|
+
// Cron routes live in pages/api/workflows.
|
|
1251
|
+
const nodeHandlersEntries = generateNodeHandlersForSegment(allNodeTypes, true, false, {
|
|
1252
|
+
withAutomations: options.withAutomations,
|
|
1253
|
+
relativePrefix: '../../..',
|
|
1254
|
+
});
|
|
1009
1255
|
const serverNodeIds = new Set(serverNodes.map((n) => n.id));
|
|
1010
1256
|
const serverEdges = workflow.edges.filter((e) => serverNodeIds.has(e.source) || serverNodeIds.has(e.target));
|
|
1011
1257
|
const hasCustomNodeUsage = serverNodes.some((n) => n.type === 'general-custom-node');
|
|
@@ -1022,9 +1268,7 @@ export const generateCronAPIRoute = (workflow, customNodes) => {
|
|
|
1022
1268
|
})),
|
|
1023
1269
|
edges: serverEdges,
|
|
1024
1270
|
}, null, 2);
|
|
1025
|
-
const requestInjection =
|
|
1026
|
-
? `\n context.__request = { ip: __getClientIp(req), headers: req.headers || {} };`
|
|
1027
|
-
: '';
|
|
1271
|
+
const requestInjection = serverRouteRequestInjection(allNodeTypes, options.withAutomations);
|
|
1028
1272
|
// Cron routes live at pages/api/workflows/<file>.js → three levels up to root.
|
|
1029
1273
|
const customNodesImport = useCustomNodes
|
|
1030
1274
|
? `var __customNodes;\ntry { __customNodes = require('../../../utils/workflows/custom-nodes'); } catch (_e) { __customNodes = {}; }\n${adminCustomNodesRequireLine(serverNodes, customNodes, '../../..')}`
|
|
@@ -1043,7 +1287,7 @@ export const generateCronAPIRoute = (workflow, customNodes) => {
|
|
|
1043
1287
|
*/
|
|
1044
1288
|
|
|
1045
1289
|
const utils = require('../../../utils/workflows/server-runtime');
|
|
1046
|
-
const
|
|
1290
|
+
const resolveNodeConfig = utils.resolveNodeConfig;
|
|
1047
1291
|
${workflowUtilsAliasLine('utils')}
|
|
1048
1292
|
${customNodesImport}${generateCartPricingPreamble(allNodeTypes, '../../..')}${generateSentEmailLogPreamble(allNodeTypes, '../../..')}${generatePaymentDriversPreamble(usesPaymentDriverNode(allNodeTypes), '../../..')}
|
|
1049
1293
|
${generateCronRequestVerificationCode()}
|
|
@@ -1053,7 +1297,6 @@ const WORKFLOW_CONFIG = ${workflowConfig};
|
|
|
1053
1297
|
const nodeHandlers = {
|
|
1054
1298
|
${nodeHandlersEntries}
|
|
1055
1299
|
};
|
|
1056
|
-
|
|
1057
1300
|
module.exports = async function handler(req, res) {
|
|
1058
1301
|
if (req.method !== 'POST' && req.method !== 'GET') {
|
|
1059
1302
|
res.status(405).json({ error: 'Method not allowed' });
|
|
@@ -1082,6 +1325,10 @@ module.exports = async function handler(req, res) {
|
|
|
1082
1325
|
// without them a protected deployment 401s itself and every data node
|
|
1083
1326
|
// returns no rows. See internalRequestHeaders in runtime-utils.
|
|
1084
1327
|
context.__internalHeaders = utils.internalRequestHeaders(req);
|
|
1328
|
+
// A server job: no visitor's request runs here, so the data API reads the
|
|
1329
|
+
// customer records unscoped (see __dataIsServerJob; the flag counts only
|
|
1330
|
+
// with the app secret, which every data node presents).
|
|
1331
|
+
context.__internalHeaders['x-tq-server-job'] = '1';
|
|
1085
1332
|
context[WORKFLOW_CONFIG.triggerNodeId] = triggerContext;${requestInjection}
|
|
1086
1333
|
|
|
1087
1334
|
${executionLoop}
|
|
@@ -1143,6 +1390,48 @@ export const getCronRouteFileName = (workflow) => {
|
|
|
1143
1390
|
* Handles if-statements, loops, early responses, custom nodes, and terminal results.
|
|
1144
1391
|
*/
|
|
1145
1392
|
const generateNodeExecutionLoop = (configVar, options) => {
|
|
1393
|
+
const automation = (options === null || options === void 0 ? void 0 : options.automation) === true;
|
|
1394
|
+
// An automation handler resumes a parked run at `resumeFrom` (the node
|
|
1395
|
+
// after its Wait): the nodes before it ran in the earlier part, and the
|
|
1396
|
+
// restored context carries their results and branch decisions.
|
|
1397
|
+
const resumeBlock = automation
|
|
1398
|
+
? `
|
|
1399
|
+
var __startIndex = 0;
|
|
1400
|
+
if (resumeFrom) {
|
|
1401
|
+
__startIndex = sortedNodes.findIndex(function(n) { return n.id === resumeFrom; });
|
|
1402
|
+
if (__startIndex === -1) { throw new Error('This automation has no step ' + resumeFrom + ' to resume at'); }
|
|
1403
|
+
}
|
|
1404
|
+
`
|
|
1405
|
+
: '';
|
|
1406
|
+
// An automation has no caller to answer, so a response node only ends the
|
|
1407
|
+
// run; a Wait stored the run (see general-wait) and nothing after it runs now.
|
|
1408
|
+
const earlyResponseBlock = automation
|
|
1409
|
+
? `
|
|
1410
|
+
if (result && result.__earlyResponse) {
|
|
1411
|
+
await utils.settlePendingNodePromises(context);
|
|
1412
|
+
return { waiting: false };
|
|
1413
|
+
}
|
|
1414
|
+
if (result && result.__wait) {
|
|
1415
|
+
await utils.settlePendingNodePromises(context);
|
|
1416
|
+
return { waiting: true, until: result.until, wouldWait: result.wouldWait || null };
|
|
1417
|
+
}`
|
|
1418
|
+
: `
|
|
1419
|
+
if (result && result.__earlyResponse) {
|
|
1420
|
+
var earlyRes = result.__earlyResponse;
|
|
1421
|
+
var hKeys = Object.keys(earlyRes.headers || {});
|
|
1422
|
+
for (var h = 0; h < hKeys.length; h++) {
|
|
1423
|
+
res.setHeader(hKeys[h], earlyRes.headers[hKeys[h]]);
|
|
1424
|
+
}
|
|
1425
|
+
await utils.settlePendingNodePromises(context);
|
|
1426
|
+
res.status(earlyRes.status || 500).json(earlyRes.body || {});
|
|
1427
|
+
return;
|
|
1428
|
+
}`;
|
|
1429
|
+
// A branch runs on a copy of the context, so a Wait there could neither
|
|
1430
|
+
// store the run nor stop it.
|
|
1431
|
+
const parallelWaitGuard = automation
|
|
1432
|
+
? `
|
|
1433
|
+
if (wlpNode.type === 'general-wait') { throw new Error('A Wait cannot run inside a parallel branch'); }`
|
|
1434
|
+
: '';
|
|
1146
1435
|
const customNodeBlock = (options === null || options === void 0 ? void 0 : options.hasCustomNodes)
|
|
1147
1436
|
? `
|
|
1148
1437
|
if (result && result.__customNode) {
|
|
@@ -1165,13 +1454,13 @@ const generateNodeExecutionLoop = (configVar, options) => {
|
|
|
1165
1454
|
}`
|
|
1166
1455
|
: '';
|
|
1167
1456
|
return ` var sortedNodes = ${configVar}.nodes.slice().sort(function(a, b) { return a.stepNumber - b.stepNumber; });
|
|
1168
|
-
|
|
1169
|
-
for (var i = 0; i < sortedNodes.length; i++) {
|
|
1457
|
+
${resumeBlock}
|
|
1458
|
+
for (var i = ${automation ? '__startIndex' : '0'}; i < sortedNodes.length; i++) {
|
|
1170
1459
|
var node = sortedNodes[i];
|
|
1171
1460
|
// Never resolved nor run on a non-taken branch, an if-statement included
|
|
1172
1461
|
// (see the segment executor above).
|
|
1173
1462
|
if (context.__skippedNodes && context.__skippedNodes[node.id]) continue;
|
|
1174
|
-
var resolved =
|
|
1463
|
+
var resolved = resolveNodeConfig(node, context);
|
|
1175
1464
|
// See the other segment executors — the unresolved-token guard must run
|
|
1176
1465
|
// wherever data nodes execute, and they all execute on the server.
|
|
1177
1466
|
var __configError = utils.finalizeResolvedConfig(node.type, resolved);
|
|
@@ -1179,7 +1468,7 @@ const generateNodeExecutionLoop = (configVar, options) => {
|
|
|
1179
1468
|
resolved.__nodeId = node.id;
|
|
1180
1469
|
|
|
1181
1470
|
if (node.type === 'general-if-statement') {
|
|
1182
|
-
var condResult = utils.evaluateCondition(resolved, context);
|
|
1471
|
+
var condResult = utils.evaluateCondition(resolved, context, node.config);
|
|
1183
1472
|
context[node.id] = { result: condResult };
|
|
1184
1473
|
var skipHandle = condResult ? 'false' : 'true';
|
|
1185
1474
|
var cfgEdges = ${configVar}.edges || [];
|
|
@@ -1243,10 +1532,10 @@ const generateNodeExecutionLoop = (configVar, options) => {
|
|
|
1243
1532
|
context[node.id] = utils.loopIterationContext(collection, li);
|
|
1244
1533
|
for (var bi = 0; bi < bodyNodes.length; bi++) {
|
|
1245
1534
|
var bNode = bodyNodes[bi];
|
|
1246
|
-
var bResolved =
|
|
1535
|
+
var bResolved = resolveNodeConfig(bNode, context);
|
|
1247
1536
|
bResolved.__nodeId = bNode.id;
|
|
1248
1537
|
if (bNode.type === 'general-if-statement') {
|
|
1249
|
-
context[bNode.id] = { result: utils.evaluateCondition(bResolved, context) };
|
|
1538
|
+
context[bNode.id] = { result: utils.evaluateCondition(bResolved, context, bNode.config) };
|
|
1250
1539
|
continue;
|
|
1251
1540
|
}
|
|
1252
1541
|
var bHandler = nodeHandlers[bNode.type];
|
|
@@ -1278,17 +1567,8 @@ const generateNodeExecutionLoop = (configVar, options) => {
|
|
|
1278
1567
|
if (context.__loopBodyNodeIds && context.__loopBodyNodeIds[node.id]) continue;
|
|
1279
1568
|
|
|
1280
1569
|
if (node.type === 'general-switch') {
|
|
1281
|
-
|
|
1282
|
-
var
|
|
1283
|
-
var swMatchedCase = 'default';
|
|
1284
|
-
for (var swci = 0; swci < swCases.length; swci++) {
|
|
1285
|
-
var swCaseVal = utils.resolveValue(swCases[swci].condition, context);
|
|
1286
|
-
if (resolved.comparisonMode === 'expression') {
|
|
1287
|
-
try { if (new Function('value', 'context', 'return (' + swCaseVal + ')')(swVal, context)) { swMatchedCase = swCases[swci].id; break; } } catch(e) {}
|
|
1288
|
-
} else {
|
|
1289
|
-
if (swVal === swCaseVal) { swMatchedCase = swCases[swci].id; break; }
|
|
1290
|
-
}
|
|
1291
|
-
}
|
|
1570
|
+
// Only an authored case expression is compiled (see matchSwitchCase).
|
|
1571
|
+
var swMatchedCase = utils.matchSwitchCase(node.config, resolved, context);
|
|
1292
1572
|
context[node.id] = { matchedCase: swMatchedCase };
|
|
1293
1573
|
var swEdges = ${configVar}.edges || [];
|
|
1294
1574
|
var swBranchEdges = swEdges.filter(function(e) { return e.source === node.id; });
|
|
@@ -1332,8 +1612,8 @@ const generateNodeExecutionLoop = (configVar, options) => {
|
|
|
1332
1612
|
var wlBranchCtx = Object.assign({}, context);
|
|
1333
1613
|
return (async function() {
|
|
1334
1614
|
for (var wlpbi = 0; wlpbi < wlBranchNodes.length; wlpbi++) {
|
|
1335
|
-
var wlpNode = wlBranchNodes[wlpbi]
|
|
1336
|
-
var wlpRes =
|
|
1615
|
+
var wlpNode = wlBranchNodes[wlpbi];${parallelWaitGuard}
|
|
1616
|
+
var wlpRes = resolveNodeConfig(wlpNode, wlBranchCtx);
|
|
1337
1617
|
wlpRes.__nodeId = wlpNode.id;
|
|
1338
1618
|
var wlpHandler = nodeHandlers[wlpNode.type];
|
|
1339
1619
|
if (!wlpHandler) continue;
|
|
@@ -1396,17 +1676,7 @@ const generateNodeExecutionLoop = (configVar, options) => {
|
|
|
1396
1676
|
context[node.id] = null;
|
|
1397
1677
|
continue;
|
|
1398
1678
|
}
|
|
1399
|
-
var result = await handler(resolved, context)
|
|
1400
|
-
if (result && result.__earlyResponse) {
|
|
1401
|
-
var earlyRes = result.__earlyResponse;
|
|
1402
|
-
var hKeys = Object.keys(earlyRes.headers || {});
|
|
1403
|
-
for (var h = 0; h < hKeys.length; h++) {
|
|
1404
|
-
res.setHeader(hKeys[h], earlyRes.headers[hKeys[h]]);
|
|
1405
|
-
}
|
|
1406
|
-
await utils.settlePendingNodePromises(context);
|
|
1407
|
-
res.status(earlyRes.status || 500).json(earlyRes.body || {});
|
|
1408
|
-
return;
|
|
1409
|
-
}${customNodeBlock}
|
|
1679
|
+
var result = await handler(resolved, context);${earlyResponseBlock}${customNodeBlock}
|
|
1410
1680
|
if (utils.isFatalNodeResult(result) && !utils.continuesOnError(node)) {
|
|
1411
1681
|
throw new Error(utils.fatalNodeResultMessage(result));
|
|
1412
1682
|
}
|
|
@@ -1418,20 +1688,32 @@ const generateNodeExecutionLoop = (configVar, options) => {
|
|
|
1418
1688
|
// serverless function can be frozen the instant it replies.
|
|
1419
1689
|
await utils.settlePendingNodePromises(context);`;
|
|
1420
1690
|
};
|
|
1421
|
-
|
|
1691
|
+
/** A webhook whose payload a signature vouches for: a payment provider's, or a verified scheme other than `custom`. */
|
|
1692
|
+
export const isVerifiedWebhookConfig = (webhookConfig) => isPaymentWebhookConfig(webhookConfig) ||
|
|
1693
|
+
(!!webhookConfig.verifySignature && webhookConfig.signatureAlgorithm !== 'custom');
|
|
1694
|
+
export const generateWebhookWorkflowAPIRoute = (workflow, customNodes, options = {}) => {
|
|
1422
1695
|
var _a;
|
|
1423
1696
|
const webhookConfig = workflow.webhookConfig;
|
|
1424
1697
|
const serverNodes = workflow.nodes.filter((n) => !CLIENT_ONLY_NODES.has(n.type));
|
|
1425
|
-
const allNodeTypes =
|
|
1426
|
-
const nodeHandlersEntries = generateNodeHandlersForSegment(allNodeTypes, true
|
|
1427
|
-
|
|
1698
|
+
const allNodeTypes = jobRouteNodeTypes(serverNodes, customNodes);
|
|
1699
|
+
const nodeHandlersEntries = generateNodeHandlersForSegment(allNodeTypes, true, false, {
|
|
1700
|
+
withAutomations: options.withAutomations,
|
|
1701
|
+
relativePrefix: getWebhookRoutePath(workflow)
|
|
1702
|
+
.map(() => '..')
|
|
1703
|
+
.join('/'),
|
|
1704
|
+
});
|
|
1428
1705
|
const serverNodeIds = new Set(serverNodes.map((n) => n.id));
|
|
1429
1706
|
const serverEdges = workflow.edges.filter((e) => serverNodeIds.has(e.source) || serverNodeIds.has(e.target));
|
|
1430
1707
|
const hasCustomNodeUsage = serverNodes.some((n) => n.type === 'general-custom-node');
|
|
1431
1708
|
const hasCustomNodeDefs = customNodes && Object.keys(customNodes).length > 0;
|
|
1709
|
+
// Without a verified signature the payload is anyone's: email/SMS nodes are
|
|
1710
|
+
// marked for the send guard as on a page's route, and so are the sends of
|
|
1711
|
+
// the custom nodes it calls (see PUBLIC_CALLER_INJECTION).
|
|
1712
|
+
const webhookVerified = isVerifiedWebhookConfig(webhookConfig);
|
|
1713
|
+
const webhookMessages = markWebhookMessageNodes(workflow, serverNodes, serverEdges, webhookVerified);
|
|
1432
1714
|
const workflowConfig = JSON.stringify({
|
|
1433
1715
|
triggerNodeId: workflow.trigger.nodeId,
|
|
1434
|
-
nodes:
|
|
1716
|
+
nodes: webhookMessages.nodes.map((n) => ({
|
|
1435
1717
|
id: n.id,
|
|
1436
1718
|
type: n.type,
|
|
1437
1719
|
config: n.config,
|
|
@@ -1498,9 +1780,10 @@ export const generateWebhookWorkflowAPIRoute = (workflow, customNodes) => {
|
|
|
1498
1780
|
const customNodesImport = hasCustomNodeUsage && hasCustomNodeDefs
|
|
1499
1781
|
? `var __customNodes;\ntry { __customNodes = require('${relativePrefix}/utils/workflows/custom-nodes'); } catch (_e) { __customNodes = {}; }\n${adminCustomNodesRequireLine(serverNodes, customNodes, relativePrefix)}`
|
|
1500
1782
|
: '';
|
|
1501
|
-
const requestInjection =
|
|
1502
|
-
?
|
|
1503
|
-
:
|
|
1783
|
+
const requestInjection = (webhookMessages.marked
|
|
1784
|
+
? VISITOR_REQUEST_INJECTION
|
|
1785
|
+
: serverRouteRequestInjection(allNodeTypes, options.withAutomations)) +
|
|
1786
|
+
(!webhookVerified && hasCustomNodeUsage ? PUBLIC_CALLER_INJECTION : '');
|
|
1504
1787
|
const executionLoop = generateNodeExecutionLoop('WORKFLOW_CONFIG', {
|
|
1505
1788
|
hasCustomNodes: hasCustomNodeUsage && hasCustomNodeDefs,
|
|
1506
1789
|
});
|
|
@@ -1515,7 +1798,7 @@ if (typeof globalThis.fetch === 'undefined') {
|
|
|
1515
1798
|
}
|
|
1516
1799
|
|
|
1517
1800
|
const utils = require('${relativePrefix}/utils/workflows/server-runtime');
|
|
1518
|
-
const
|
|
1801
|
+
const resolveNodeConfig = utils.resolveNodeConfig;
|
|
1519
1802
|
${workflowUtilsAliasLine('utils')}
|
|
1520
1803
|
${customNodesImport}${generateCartPricingPreamble(allNodeTypes, relativePrefix)}${generateSentEmailLogPreamble(allNodeTypes, relativePrefix)}${generatePaymentDriversPreamble(usesPaymentDriverNode(allNodeTypes) || isPaymentWebhook, relativePrefix)}${deliveryLease.preamble}
|
|
1521
1804
|
${webhookBodyCode}
|
|
@@ -1531,7 +1814,6 @@ var ERROR_HANDLER_NODES = ${errorHandlerNodesJson};
|
|
|
1531
1814
|
const nodeHandlers = {
|
|
1532
1815
|
${nodeHandlersEntries}
|
|
1533
1816
|
};
|
|
1534
|
-
|
|
1535
1817
|
module.exports = async function handler(req, res) {
|
|
1536
1818
|
if (req.method !== '${webhookConfig.httpMethod}') {
|
|
1537
1819
|
res.status(405).json({ error: 'Method not allowed' });
|
|
@@ -1567,14 +1849,34 @@ ${generateSignatureVerificationBlock(normalisedWebhookConfig)}${deliveryLease.cl
|
|
|
1567
1849
|
// Credentials for this deployment's calls to its own /api/data routes —
|
|
1568
1850
|
// without them a protected deployment 401s itself and every data node
|
|
1569
1851
|
// returns no rows. See internalRequestHeaders in runtime-utils.
|
|
1570
|
-
context.__internalHeaders = utils.internalRequestHeaders(req)
|
|
1852
|
+
context.__internalHeaders = utils.internalRequestHeaders(req);
|
|
1853
|
+
// A server job: no visitor's request runs here, so the data API reads the
|
|
1854
|
+
// customer records unscoped (see __dataIsServerJob; the flag counts only
|
|
1855
|
+
// with the app secret, which every data node presents).
|
|
1856
|
+
context.__internalHeaders['x-tq-server-job'] = '1';${requestInjection}
|
|
1571
1857
|
|
|
1572
1858
|
${executionLoop}
|
|
1573
1859
|
${deliveryLease.release}
|
|
1574
1860
|
res.status(200).json({ received: true });
|
|
1575
1861
|
} catch (error) {
|
|
1576
1862
|
console.error('Webhook workflow error:', error);
|
|
1577
|
-
|
|
1863
|
+
${generateErrorHandlerRunBlock('Webhook error handler failed:')}
|
|
1864
|
+
// Land whatever the main run started (an email's ledger row, a
|
|
1865
|
+
// fire-and-forget write) before replying — see the segment routes.
|
|
1866
|
+
if (typeof context !== 'undefined' && context) { await utils.settlePendingNodePromises(context); }${deliveryLease.release}
|
|
1867
|
+
res.status(500).json({ error: 'Webhook processing failed' });
|
|
1868
|
+
}
|
|
1869
|
+
};
|
|
1870
|
+
|
|
1871
|
+
module.exports.config = { api: { bodyParser: false } };
|
|
1872
|
+
`;
|
|
1873
|
+
};
|
|
1874
|
+
/**
|
|
1875
|
+
* Runs the workflow's error-handler branch (`ERROR_HANDLER_NODES`) after the
|
|
1876
|
+
* main run threw `error`, on a copy of `context` that carries the error. A
|
|
1877
|
+
* failure of the branch itself is only logged, with `failureLabel`.
|
|
1878
|
+
*/
|
|
1879
|
+
const generateErrorHandlerRunBlock = (failureLabel) => ` if (ERROR_HANDLER_NODES) {
|
|
1578
1880
|
try {
|
|
1579
1881
|
var errCtx = Object.assign({}, context || {});
|
|
1580
1882
|
if (WORKFLOW_CONFIG.errorHandlerNodeId) {
|
|
@@ -1585,7 +1887,7 @@ ${deliveryLease.release}
|
|
|
1585
1887
|
}
|
|
1586
1888
|
for (var ei = 0; ei < ERROR_HANDLER_NODES.length; ei++) {
|
|
1587
1889
|
var eNode = ERROR_HANDLER_NODES[ei];
|
|
1588
|
-
var eResolved =
|
|
1890
|
+
var eResolved = resolveNodeConfig(eNode, errCtx);
|
|
1589
1891
|
eResolved.__nodeId = eNode.id;
|
|
1590
1892
|
var eHandler = nodeHandlers[eNode.type];
|
|
1591
1893
|
if (eHandler) {
|
|
@@ -1600,17 +1902,168 @@ ${deliveryLease.release}
|
|
|
1600
1902
|
}
|
|
1601
1903
|
await utils.settlePendingNodePromises(errCtx);
|
|
1602
1904
|
} catch (innerErr) {
|
|
1603
|
-
console.error('
|
|
1905
|
+
console.error('${failureLabel}', innerErr);
|
|
1604
1906
|
}
|
|
1605
|
-
}
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1907
|
+
}`;
|
|
1908
|
+
/**
|
|
1909
|
+
* An automation's handler module (`lib/automations/handlers/<file>.js`, see
|
|
1910
|
+
* automations/handler-module-generator.ts): the webhook route's node loop as
|
|
1911
|
+
* an importable function, `module.exports.run = async (event, context,
|
|
1912
|
+
* resumeFrom)`, which the in-app dispatcher awaits.
|
|
1913
|
+
*
|
|
1914
|
+
* - `event` is the event envelope (`{ event, actor, <entity> }`): the trigger
|
|
1915
|
+
* node's output. A resumed run passes it again, read afresh.
|
|
1916
|
+
* - `context` is `{}` for a new run (plus `__baseUrl` when the dispatcher
|
|
1917
|
+
* knows the app's origin), or the context a Wait stored.
|
|
1918
|
+
* - `resumeFrom` is the node to resume at; every node before it ran already.
|
|
1919
|
+
*
|
|
1920
|
+
* Every node runs as in a webhook route — server handlers, the same
|
|
1921
|
+
* `__baseUrl` / internal headers, the error-handler branch — except the
|
|
1922
|
+
* browser-only ones, which fail the run, and a Wait (`general-wait`), which
|
|
1923
|
+
* stores the run and resolves `{ waiting: true }` (a test event's Wait stores
|
|
1924
|
+
* nothing and resolves `{ waiting: true, wouldWait }`; a Wait with no step
|
|
1925
|
+
* after it stores nothing and the run ends there). A run that fails rejects,
|
|
1926
|
+
* after the error-handler branch ran, so the dispatcher records the failure.
|
|
1927
|
+
*/
|
|
1928
|
+
export const generateHandlerFunction = (workflow, customNodes) => {
|
|
1929
|
+
var _a;
|
|
1930
|
+
const relativePrefix = AUTOMATION_HANDLERS_PATH.map(() => '..').join('/');
|
|
1931
|
+
const nodes = workflow.nodes || [];
|
|
1932
|
+
const allNodeTypes = jobRouteNodeTypes(nodes, customNodes);
|
|
1933
|
+
// An automation runs only in a project that has the event bus.
|
|
1934
|
+
const nodeHandlersEntries = generateNodeHandlersForSegment(allNodeTypes, true, true, {
|
|
1935
|
+
withAutomations: true,
|
|
1936
|
+
relativePrefix,
|
|
1937
|
+
});
|
|
1938
|
+
const hasCustomNodeUsage = nodes.some((n) => n.type === 'general-custom-node');
|
|
1939
|
+
const useCustomNodes = hasCustomNodeUsage && !!customNodes && Object.keys(customNodes).length > 0;
|
|
1940
|
+
const workflowConfig = JSON.stringify({
|
|
1941
|
+
triggerNodeId: workflow.trigger.nodeId,
|
|
1942
|
+
nodes: nodes.map((n) => ({
|
|
1943
|
+
id: n.id,
|
|
1944
|
+
type: n.type,
|
|
1945
|
+
config: n.config,
|
|
1946
|
+
stepNumber: n.stepNumber,
|
|
1947
|
+
label: n.label,
|
|
1948
|
+
})),
|
|
1949
|
+
edges: workflow.edges || [],
|
|
1950
|
+
errorHandlerNodeId: ((_a = workflow.errorHandler) === null || _a === void 0 ? void 0 : _a.nodeId) || null,
|
|
1951
|
+
}, null, 2);
|
|
1952
|
+
const errorHandlerNodes = workflow.errorHandler ? getErrorHandlerNodes(workflow) : null;
|
|
1953
|
+
const errorHandlerNodesJson = errorHandlerNodes
|
|
1954
|
+
? JSON.stringify(errorHandlerNodes, null, 2)
|
|
1955
|
+
: 'null';
|
|
1956
|
+
const customNodesImport = useCustomNodes
|
|
1957
|
+
? `var __customNodes;\ntry { __customNodes = require('${relativePrefix}/utils/workflows/custom-nodes'); } catch (_e) { __customNodes = {}; }\n${adminCustomNodesRequireLine(nodes, customNodes, relativePrefix)}`
|
|
1958
|
+
: '';
|
|
1959
|
+
const executionLoop = generateNodeExecutionLoop('WORKFLOW_CONFIG', {
|
|
1960
|
+
hasCustomNodes: useCustomNodes,
|
|
1961
|
+
automation: true,
|
|
1962
|
+
});
|
|
1963
|
+
return `/**
|
|
1964
|
+
* Automation handler
|
|
1965
|
+
* Workflow: ${sanitizeForBlockComment(workflow.name || workflow.id)}
|
|
1966
|
+
* Event: ${sanitizeForBlockComment(automationEventType(workflow) || 'none')}
|
|
1967
|
+
*/
|
|
1968
|
+
if (typeof globalThis.fetch === 'undefined') {
|
|
1969
|
+
globalThis.fetch = require('node-fetch');
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
const utils = require('${relativePrefix}/utils/workflows/server-runtime');
|
|
1973
|
+
const resolveNodeConfig = utils.resolveNodeConfig;
|
|
1974
|
+
${workflowUtilsAliasLine('utils')}
|
|
1975
|
+
${customNodesImport}${generateCartPricingPreamble(allNodeTypes, relativePrefix)}${generateSentEmailLogPreamble(allNodeTypes, relativePrefix)}${generatePaymentDriversPreamble(usesPaymentDriverNode(allNodeTypes), relativePrefix)}
|
|
1976
|
+
var __automationStore = require('../store');
|
|
1977
|
+
|
|
1978
|
+
var WORKFLOW_ID = ${JSON.stringify(workflow.id)};
|
|
1979
|
+
|
|
1980
|
+
const WORKFLOW_CONFIG = ${workflowConfig};
|
|
1981
|
+
|
|
1982
|
+
var ERROR_HANDLER_NODES = ${errorHandlerNodesJson};
|
|
1983
|
+
|
|
1984
|
+
const nodeHandlers = {
|
|
1985
|
+
${nodeHandlersEntries}
|
|
1611
1986
|
};
|
|
1987
|
+
// Rebuilt by every run, so never stored with a parked one: the queue of
|
|
1988
|
+
// fire-and-forget work, where and with which credentials the run calls the
|
|
1989
|
+
// app's own routes, and the run itself.
|
|
1990
|
+
var RUNTIME_CONTEXT_KEYS = ['__pendingNodePromises', '__baseUrl', '__internalHeaders', '__automation', '__request', '__emailAttribution'];
|
|
1991
|
+
|
|
1992
|
+
var SORTED_NODE_IDS = WORKFLOW_CONFIG.nodes
|
|
1993
|
+
.slice()
|
|
1994
|
+
.sort(function(a, b) { return a.stepNumber - b.stepNumber; })
|
|
1995
|
+
.map(function(n) { return n.id; });
|
|
1996
|
+
|
|
1997
|
+
// Stores the run at a Wait: the next node, and the context so far.
|
|
1998
|
+
async function park(context, nodeId, until) {
|
|
1999
|
+
var at = SORTED_NODE_IDS.indexOf(nodeId);
|
|
2000
|
+
var resumeNodeId = at === -1 ? null : SORTED_NODE_IDS[at + 1] || null;
|
|
2001
|
+
// Nothing after the Wait: the run is over.
|
|
2002
|
+
if (!resumeNodeId) return null;
|
|
2003
|
+
if (!context.__automation.eventId) {
|
|
2004
|
+
throw new Error('A Wait needs the event the automation runs for');
|
|
2005
|
+
}
|
|
2006
|
+
var saved = {};
|
|
2007
|
+
Object.keys(context).forEach(function(key) {
|
|
2008
|
+
if (RUNTIME_CONTEXT_KEYS.indexOf(key) === -1) saved[key] = context[key];
|
|
2009
|
+
});
|
|
2010
|
+
await __automationStore.saveWait({
|
|
2011
|
+
eventId: context.__automation.eventId,
|
|
2012
|
+
workflowId: WORKFLOW_ID,
|
|
2013
|
+
resumeNodeId: resumeNodeId,
|
|
2014
|
+
context: JSON.stringify(saved),
|
|
2015
|
+
runAt: until,
|
|
2016
|
+
});
|
|
2017
|
+
return resumeNodeId;
|
|
2018
|
+
}
|
|
1612
2019
|
|
|
1613
|
-
|
|
2020
|
+
async function runNodes(context, resumeFrom) {
|
|
2021
|
+
${executionLoop}
|
|
2022
|
+
return { waiting: false };
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
async function run(event, context, resumeFrom) {
|
|
2026
|
+
context = context && typeof context === 'object' ? context : {};
|
|
2027
|
+
// Shared fire-and-forget queue — drained before the run settles.
|
|
2028
|
+
context.__pendingNodePromises = [];
|
|
2029
|
+
// Where this deployment calls its own routes, and with which credentials
|
|
2030
|
+
// (see the webhook routes).
|
|
2031
|
+
if (!context.__baseUrl) {
|
|
2032
|
+
context.__baseUrl = __automationStore.appBaseUrl();
|
|
2033
|
+
}
|
|
2034
|
+
context.__internalHeaders = utils.internalRequestHeaders(null);
|
|
2035
|
+
// A server job: no visitor's request runs here, so the data API reads the
|
|
2036
|
+
// customer records unscoped (see __dataIsServerJob; the flag counts only
|
|
2037
|
+
// with the app secret, which every data node presents).
|
|
2038
|
+
context.__internalHeaders['x-tq-server-job'] = '1';
|
|
2039
|
+
if (event) {
|
|
2040
|
+
context[WORKFLOW_CONFIG.triggerNodeId] = event;
|
|
2041
|
+
}
|
|
2042
|
+
var trigger = context[WORKFLOW_CONFIG.triggerNodeId] || {};
|
|
2043
|
+
context.__automation = {
|
|
2044
|
+
workflowId: WORKFLOW_ID,
|
|
2045
|
+
eventId: trigger.event && trigger.event.id ? String(trigger.event.id) : '',
|
|
2046
|
+
// A test event runs once and never parks at a Wait (see general-wait).
|
|
2047
|
+
test: !!(trigger.event && trigger.event.test === true),
|
|
2048
|
+
park: function(nodeId, until) { return park(context, nodeId, until); },
|
|
2049
|
+
};
|
|
2050
|
+
// The mail this run sends is filed under the automation, and under the
|
|
2051
|
+
// event's order when it has one (the sent-email ledger reads this).
|
|
2052
|
+
context.__emailAttribution = {
|
|
2053
|
+
source: 'automation',
|
|
2054
|
+
sourceRef: WORKFLOW_ID,
|
|
2055
|
+
orderId: trigger.order && trigger.order.id ? String(trigger.order.id) : null,
|
|
2056
|
+
};
|
|
2057
|
+
try {
|
|
2058
|
+
return await runNodes(context, resumeFrom || null);
|
|
2059
|
+
} catch (error) {
|
|
2060
|
+
${generateErrorHandlerRunBlock('Automation error handler failed:')}
|
|
2061
|
+
await utils.settlePendingNodePromises(context);
|
|
2062
|
+
throw error;
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
module.exports.run = run;
|
|
1614
2067
|
`;
|
|
1615
2068
|
};
|
|
1616
2069
|
export const getWebhookRouteFileName = (workflow) => {
|