@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
|
@@ -9,21 +9,34 @@ import {
|
|
|
9
9
|
} from '@teleporthq/teleport-types'
|
|
10
10
|
import { WorkflowSegment } from './types'
|
|
11
11
|
import { SegmentTrust } from './segment-trust'
|
|
12
|
+
import { securityRuntimeSpecifier } from './security-runtime/security-runtime-code'
|
|
13
|
+
import { isCostBearingNodeType } from './nodes/cost-bearing-node-types'
|
|
12
14
|
import { nodeRegistry } from './nodes'
|
|
13
|
-
import { resolveHandlerEntryName } from './nodes/types'
|
|
14
|
-
import {
|
|
15
|
+
import { NodeHandlerGenerator, ServerHandlerOptions, resolveHandlerEntryName } from './nodes/types'
|
|
16
|
+
import { generalWait } from './nodes/general/general-wait'
|
|
17
|
+
import { needsVisitorRequest, VISITOR_REQUEST_INJECTION } from './nodes/general/visitor-request'
|
|
18
|
+
import {
|
|
19
|
+
markVisitorBoundMessageNodes,
|
|
20
|
+
markWebhookMessageNodes,
|
|
21
|
+
PUBLIC_CALLER_INJECTION,
|
|
22
|
+
} from './nodes/email/outbound-message-guard'
|
|
23
|
+
import { AI_PUBLIC_REFUSALS } from './nodes/ai/ai-provider-utils'
|
|
24
|
+
import { AUTOMATION_HANDLERS_PATH, automationEventType } from './automations/automations-scope'
|
|
25
|
+
import { AI_NODE_TYPES, collectCalledCustomNodeTypes } from './graph-utils'
|
|
15
26
|
import {
|
|
16
27
|
generateWebhookBodyCode,
|
|
17
28
|
generateAllSignatureVerificationCode,
|
|
18
29
|
generatePaymentWebhookVerificationCode,
|
|
19
30
|
} from './webhook-signature-verification'
|
|
20
31
|
import { buildWorkflowAuthInjection } from './workflow-auth-generator'
|
|
32
|
+
import { buildVisitorStepLimitGuard } from './visitor-step-limits'
|
|
21
33
|
import {
|
|
22
34
|
hasEmailSendingNodeType,
|
|
23
35
|
isEmailSendingNodeType,
|
|
24
36
|
} from './sent-email-log/sent-email-log-scope'
|
|
25
37
|
import { workflowUtilsAliasLine } from './workflow-utils-alias'
|
|
26
38
|
import { adminCustomNodesRequireLine } from './custom-node-modules'
|
|
39
|
+
import { generateServerCustomNodeCallCode } from './server-custom-node-call'
|
|
27
40
|
import {
|
|
28
41
|
generatePaymentDriversPreamble,
|
|
29
42
|
isPaymentWebhookConfig,
|
|
@@ -72,12 +85,236 @@ export interface ServerSegmentRouteOptions {
|
|
|
72
85
|
* emits carries it.
|
|
73
86
|
*/
|
|
74
87
|
trust?: SegmentTrust
|
|
88
|
+
/**
|
|
89
|
+
* The project's custom nodes: a custom node this segment runs itself (a
|
|
90
|
+
* server-only one, see server-custom-node-call.ts) is gated like the steps
|
|
91
|
+
* it runs.
|
|
92
|
+
*/
|
|
93
|
+
customNodes?: Record<string, UIDLCustomWorkflowNode>
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { isCostBearingNodeType }
|
|
97
|
+
|
|
98
|
+
/** Per visitor address, per route: a minute's and a day's allowance. */
|
|
99
|
+
export const COST_BEARING_STEP_LIMITS = { perMinute: 30, perDay: 300 }
|
|
100
|
+
|
|
101
|
+
/** What a visitor sees when a step fails; the detail stays in the server log. */
|
|
102
|
+
export const SEGMENT_PUBLIC_ERROR = 'Something went wrong. Please try again.'
|
|
103
|
+
|
|
104
|
+
/** What a segment route reads about the visitor (SEGMENT_CONFIG.session). */
|
|
105
|
+
interface SegmentRouteSession {
|
|
106
|
+
identityNodes: Record<string, string>
|
|
107
|
+
identityReads: Record<string, string[]>
|
|
108
|
+
bindings?: unknown[]
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The visitor's identity a route reads: what the graph says (current-user
|
|
113
|
+
* readers, identity-filtered reads, {{Current User.*}} tokens — see
|
|
114
|
+
* segment-trust.ts) plus the route's `userScoped` identity columns, which the
|
|
115
|
+
* route binds again after the node that produces them has run.
|
|
116
|
+
*/
|
|
117
|
+
const resolveSegmentSession = (
|
|
118
|
+
options: ServerSegmentRouteOptions,
|
|
119
|
+
protection: UIDLWorkflowProtection | undefined
|
|
120
|
+
): SegmentRouteSession | undefined => {
|
|
121
|
+
const needs = options.trust?.session
|
|
122
|
+
const bindings = (protection?.userScoped?.bindings || []) as unknown[]
|
|
123
|
+
if (!needs && bindings.length === 0) {
|
|
124
|
+
return undefined
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
identityNodes: needs?.identityNodes || {},
|
|
128
|
+
identityReads: needs?.identityReads || {},
|
|
129
|
+
...(bindings.length > 0 ? { bindings } : {}),
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The env var names a segment's node configs reference (project-secret
|
|
135
|
+
* references): a reply never carries one, even inside a node's error result.
|
|
136
|
+
*/
|
|
137
|
+
const collectSecretNames = (segment: WorkflowSegment): string[] => {
|
|
138
|
+
const names = new Set<string>()
|
|
139
|
+
const walk = (value: unknown): void => {
|
|
140
|
+
if (typeof value === 'string') {
|
|
141
|
+
if (/^WORKFLOW_SECRET_[A-Za-z0-9_]+$/.test(value)) {
|
|
142
|
+
names.add(value)
|
|
143
|
+
} else if (value.indexOf('teleporthq.secrets.') === 0 && value.length > 19) {
|
|
144
|
+
names.add(value.slice(19))
|
|
145
|
+
}
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
if (!value || typeof value !== 'object') {
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
const ref = value as { type?: unknown; content?: { referenceType?: unknown; id?: unknown } }
|
|
152
|
+
if (
|
|
153
|
+
ref.type === 'dynamic' &&
|
|
154
|
+
ref.content &&
|
|
155
|
+
ref.content.referenceType === 'secret' &&
|
|
156
|
+
typeof ref.content.id === 'string' &&
|
|
157
|
+
ref.content.id
|
|
158
|
+
) {
|
|
159
|
+
names.add(ref.content.id)
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
Object.keys(value as Record<string, unknown>).forEach((key) =>
|
|
163
|
+
walk((value as Record<string, unknown>)[key])
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
segment.nodes.forEach((n) => walk(n.config))
|
|
167
|
+
return Array.from(names).sort()
|
|
75
168
|
}
|
|
76
169
|
|
|
77
|
-
|
|
78
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Whether `nodes` run a cost-bearing step, themselves or through a custom node
|
|
172
|
+
* they call (transitively): in-process, a server-only custom node's own
|
|
173
|
+
* segments are internal calls, which the gate does not count.
|
|
174
|
+
*/
|
|
175
|
+
const runsCostBearingStep = (
|
|
176
|
+
nodes: UIDLWorkflowNode[],
|
|
177
|
+
customNodes: Record<string, UIDLCustomWorkflowNode> | undefined,
|
|
178
|
+
visited: Set<string> = new Set<string>()
|
|
179
|
+
): boolean =>
|
|
180
|
+
nodes.some((n) => {
|
|
181
|
+
if (isCostBearingNodeType(n.type)) {
|
|
182
|
+
return true
|
|
183
|
+
}
|
|
184
|
+
const customNodeId = ((n.config || {}) as Record<string, unknown>).customNodeId
|
|
185
|
+
if (n.type !== 'general-custom-node' || typeof customNodeId !== 'string') {
|
|
186
|
+
return false
|
|
187
|
+
}
|
|
188
|
+
if (visited.has(customNodeId)) {
|
|
189
|
+
return false
|
|
190
|
+
}
|
|
191
|
+
visited.add(customNodeId)
|
|
192
|
+
const called = customNodes ? customNodes[customNodeId] : undefined
|
|
193
|
+
return !!called && runsCostBearingStep(called.nodes || [], customNodes, visited)
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The rate-limit scope of a segment route that runs a cost-bearing step, else
|
|
198
|
+
* null. Its own prefix: `workflow-step:<nodeId>` is a step's declared visitor
|
|
199
|
+
* limit (visitor-step-limits.ts).
|
|
200
|
+
*/
|
|
201
|
+
const resolveAbuseScope = (
|
|
202
|
+
segment: WorkflowSegment,
|
|
203
|
+
workflowName: string | undefined,
|
|
204
|
+
options: ServerSegmentRouteOptions
|
|
205
|
+
): string | null => {
|
|
206
|
+
if (!runsCostBearingStep(segment.nodes, options.customNodes)) {
|
|
207
|
+
return null
|
|
208
|
+
}
|
|
209
|
+
const owner = options.trust?.workflowId || workflowName || 'workflow'
|
|
210
|
+
return `workflow-route:${owner}:${segment.id}`
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const SEGMENT_SECURITY_RUNTIME = securityRuntimeSpecifier('../../..')
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Module-level code every segment route carries: the shared security runtime
|
|
217
|
+
* (required guarded, so a route still loads where it is absent — the abuse
|
|
218
|
+
* gate then refuses), the generic error a visitor sees, and the log line its
|
|
219
|
+
* detail goes to under the same opaque id.
|
|
220
|
+
*/
|
|
221
|
+
const SEGMENT_SECURITY_PREAMBLE = `// The shared security runtime: the generic error a visitor is shown (its detail
|
|
222
|
+
// stays in the server log, under the id the visitor sees) and the rate limit of
|
|
223
|
+
// a step that spends the site's money.
|
|
224
|
+
var __security = null;
|
|
225
|
+
try { __security = require('${SEGMENT_SECURITY_RUNTIME}'); } catch (_e) { __security = null; }
|
|
226
|
+
var __PUBLIC_ERROR = ${JSON.stringify(SEGMENT_PUBLIC_ERROR)};
|
|
227
|
+
// The refusals that name nothing secret (an AI step: a prompt too long, the
|
|
228
|
+
// site's daily AI budget spent, AI unavailable) are shown as they are, with
|
|
229
|
+
// their status; any other error is the generic one.
|
|
230
|
+
var __PUBLIC_REFUSALS = ${JSON.stringify(AI_PUBLIC_REFUSALS)};
|
|
231
|
+
function __publicRefusal(error) {
|
|
232
|
+
var message = error && typeof error.message === 'string' ? error.message : '';
|
|
233
|
+
return Object.prototype.hasOwnProperty.call(__PUBLIC_REFUSALS, message) ? message : null;
|
|
234
|
+
}
|
|
235
|
+
// Answers the generic error (when \`res\` can still answer) and logs \`error\`;
|
|
236
|
+
// returns the id the log line carries. An error the server runtime raised for
|
|
237
|
+
// the visitor to read (\`__tqPublic\`: a run that expired) keeps its message.
|
|
238
|
+
function __clientError(res, error) {
|
|
239
|
+
var own = error && error.__tqPublic && typeof error.__tqPublic.message === 'string' ? error.__tqPublic : null;
|
|
240
|
+
var refusal = own ? own.message : __publicRefusal(error);
|
|
241
|
+
var status = own ? own.status : refusal ? __PUBLIC_REFUSALS[refusal] : 500;
|
|
242
|
+
var message = refusal || __PUBLIC_ERROR;
|
|
243
|
+
if (__security && typeof __security.sendClientError === 'function') {
|
|
244
|
+
return __security.sendClientError(res, status, message, error);
|
|
245
|
+
}
|
|
246
|
+
console.error('Workflow segment error:', error);
|
|
247
|
+
if (res && !res.headersSent && typeof res.status === 'function') {
|
|
248
|
+
res.status(status).json({ error: message });
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
// What a parallel branch that failed reports: the generic error and its log id.
|
|
253
|
+
function __branchError(error) {
|
|
254
|
+
var id = __clientError({ headersSent: true }, error);
|
|
255
|
+
var message = __publicRefusal(error) || __PUBLIC_ERROR;
|
|
256
|
+
return id ? message + ' (' + id + ')' : message;
|
|
257
|
+
}
|
|
258
|
+
`
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* First thing a segment route does when its segment spends the site's money
|
|
262
|
+
* or reaches outside it: count the visitor against this route, whatever the
|
|
263
|
+
* page's protection. This deployment's own server code (a webhook or cron
|
|
264
|
+
* running a custom node) carries the internal-call token and is not counted.
|
|
265
|
+
*/
|
|
266
|
+
const generateAbuseGateCode = (scope: string | null): string => {
|
|
267
|
+
if (!scope) {
|
|
268
|
+
return ''
|
|
269
|
+
}
|
|
270
|
+
const { perMinute, perDay } = COST_BEARING_STEP_LIMITS
|
|
271
|
+
const scopeLiteral = JSON.stringify(scope)
|
|
272
|
+
return `
|
|
273
|
+
// This step spends the site's money or reaches outside it (an AI model, a
|
|
274
|
+
// mail, SMS or payment provider, another site): every visitor address is
|
|
275
|
+
// allowed ${perMinute} calls a minute and ${perDay} a day here, whatever the page's
|
|
276
|
+
// protection. This deployment's own server code is not a visitor.
|
|
277
|
+
if (!utils.isInternalCall(req)) {
|
|
278
|
+
if (!__security) {
|
|
279
|
+
res.status(503).json({ error: 'This action is unavailable right now.' });
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
var __minute = { scope: ${scopeLiteral}, limit: ${perMinute}, windowSeconds: 60 };
|
|
283
|
+
if (!(await __security.rateLimitRequest(req, res, __minute))) return;
|
|
284
|
+
var __day = { scope: ${scopeLiteral}, limit: ${perDay}, windowSeconds: 86400 };
|
|
285
|
+
if (!(await __security.rateLimitRequest(req, res, __day))) return;
|
|
286
|
+
}`
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** The session binding a route that reads the visitor runs before its guard and its nodes. */
|
|
290
|
+
const generateSessionBindCode = (session: SegmentRouteSession | undefined): string =>
|
|
291
|
+
session
|
|
292
|
+
? `
|
|
293
|
+
// Who the visitor is comes from the session cookie, never from the request
|
|
294
|
+
// (see bindSessionIdentity in the server runtime).
|
|
295
|
+
await utils.bindSessionIdentity(req, SEGMENT_CONFIG, context);`
|
|
296
|
+
: ''
|
|
297
|
+
|
|
298
|
+
/** Module-level: the handlers that read or bind the visitor's identity, wrapped. */
|
|
299
|
+
const generateSessionHandlersCode = (session: SegmentRouteSession | undefined): string =>
|
|
300
|
+
session && (Object.keys(session.identityReads).length > 0 || (session.bindings || []).length > 0)
|
|
301
|
+
? `// Identity-filtered reads and userScoped identity columns (see
|
|
302
|
+
// bindSessionHandlers in the server runtime).
|
|
303
|
+
utils.bindSessionHandlers(SEGMENT_CONFIG, nodeHandlers);
|
|
304
|
+
`
|
|
305
|
+
: ''
|
|
306
|
+
|
|
307
|
+
const buildSegmentConfig = (
|
|
308
|
+
segment: WorkflowSegment,
|
|
309
|
+
options: ServerSegmentRouteOptions,
|
|
310
|
+
session?: SegmentRouteSession
|
|
311
|
+
): string => {
|
|
312
|
+
const secretNames = collectSecretNames(segment)
|
|
313
|
+
return JSON.stringify(
|
|
79
314
|
{
|
|
80
315
|
...(options.trust || {}),
|
|
316
|
+
session,
|
|
317
|
+
...(secretNames.length > 0 ? { secretNames } : {}),
|
|
81
318
|
nodes: segment.nodes.map((n) => ({
|
|
82
319
|
id: n.id,
|
|
83
320
|
type: n.type,
|
|
@@ -99,6 +336,7 @@ const buildSegmentConfig = (segment: WorkflowSegment, options: ServerSegmentRout
|
|
|
99
336
|
null,
|
|
100
337
|
2
|
|
101
338
|
)
|
|
339
|
+
}
|
|
102
340
|
|
|
103
341
|
export const generateServerSegmentAPIRoute = (
|
|
104
342
|
segment: WorkflowSegment,
|
|
@@ -108,10 +346,15 @@ export const generateServerSegmentAPIRoute = (
|
|
|
108
346
|
): string => {
|
|
109
347
|
const usedNodeTypes = new Set(segment.nodes.map((n) => n.type))
|
|
110
348
|
const nodeHandlersEntries = generateNodeHandlersForSegment(usedNodeTypes, true)
|
|
111
|
-
const hasRateLimiter = usedNodeTypes.has('general-rate-limiter')
|
|
112
349
|
const auth = buildWorkflowAuthInjection(protection)
|
|
350
|
+
const session = resolveSegmentSession(options, protection)
|
|
351
|
+
const abuseScope = resolveAbuseScope(segment, workflowName, options)
|
|
113
352
|
|
|
114
|
-
const segmentConfig = buildSegmentConfig(
|
|
353
|
+
const segmentConfig = buildSegmentConfig(
|
|
354
|
+
markVisitorBoundMessageNodes(segment, options.trust, protection, workflowName),
|
|
355
|
+
options,
|
|
356
|
+
session
|
|
357
|
+
)
|
|
115
358
|
|
|
116
359
|
const header = workflowName
|
|
117
360
|
? `/**
|
|
@@ -126,24 +369,23 @@ export const generateServerSegmentAPIRoute = (
|
|
|
126
369
|
*/
|
|
127
370
|
`
|
|
128
371
|
|
|
129
|
-
const requestInjection =
|
|
130
|
-
? `\n context.__request = { ip: __getClientIp(req), headers: req.headers || {} };`
|
|
131
|
-
: ''
|
|
372
|
+
const requestInjection = needsVisitorRequest(usedNodeTypes) ? VISITOR_REQUEST_INJECTION : ''
|
|
132
373
|
|
|
133
374
|
return `${header}
|
|
134
375
|
const utils = require('../../../utils/workflows/server-runtime');
|
|
135
|
-
${auth.requireLine}const
|
|
376
|
+
${auth.requireLine}const resolveNodeConfig = utils.resolveNodeConfig;
|
|
136
377
|
${workflowUtilsAliasLine('utils')}
|
|
137
378
|
${generateCartPricingPreamble(usedNodeTypes, '../../..')}${generateSentEmailLogPreamble(
|
|
138
379
|
usedNodeTypes,
|
|
139
380
|
'../../..'
|
|
140
381
|
)}${generatePaymentDriversPreamble(usesPaymentDriverNode(usedNodeTypes), '../../..')}
|
|
382
|
+
${SEGMENT_SECURITY_PREAMBLE}
|
|
141
383
|
const SEGMENT_CONFIG = ${segmentConfig};
|
|
142
384
|
${auth.policyConst}
|
|
143
385
|
const nodeHandlers = {
|
|
144
386
|
${nodeHandlersEntries}
|
|
145
387
|
};
|
|
146
|
-
|
|
388
|
+
${generateServerCustomNodeCallCode(segment, '../../..')}${generateSessionHandlersCode(session)}
|
|
147
389
|
module.exports = async function handler(req, res) {
|
|
148
390
|
if (req.method !== 'POST') {
|
|
149
391
|
res.status(405).json({ error: 'Method not allowed' });
|
|
@@ -152,7 +394,7 @@ module.exports = async function handler(req, res) {
|
|
|
152
394
|
// Kept outside the try so the catch below can still drain any fire-and-forget
|
|
153
395
|
// query this segment started before it failed.
|
|
154
396
|
var __wfContext = null;
|
|
155
|
-
try {
|
|
397
|
+
try {${generateAbuseGateCode(abuseScope)}
|
|
156
398
|
const body = typeof req.body === 'string' ? JSON.parse(req.body) : req.body;
|
|
157
399
|
const incomingContext = body.context || {};
|
|
158
400
|
// What the caller already holds, so the reply below carries only what this
|
|
@@ -161,7 +403,7 @@ module.exports = async function handler(req, res) {
|
|
|
161
403
|
|
|
162
404
|
const context = Object.assign({}, incomingContext);
|
|
163
405
|
utils.claimSegmentContext(SEGMENT_CONFIG, context);
|
|
164
|
-
__wfContext = context
|
|
406
|
+
__wfContext = context;${generateSessionBindCode(session)}
|
|
165
407
|
// Created eagerly so a custom node invoked from here shares the SAME
|
|
166
408
|
// fire-and-forget queue (it shallow-copies this context) and its queries
|
|
167
409
|
// are drained by the settle below rather than being lost when we reply.
|
|
@@ -173,10 +415,20 @@ module.exports = async function handler(req, res) {
|
|
|
173
415
|
// without them a protected deployment 401s itself and every data node
|
|
174
416
|
// returns no rows. See internalRequestHeaders in runtime-utils.
|
|
175
417
|
context.__internalHeaders = utils.internalRequestHeaders(req);
|
|
418
|
+
// A server job's hop — a webhook, cron or automation running a custom
|
|
419
|
+
// node, which calls this route with the internal-call token only this
|
|
420
|
+
// deployment's server code can mint — stays the job's: its data calls keep
|
|
421
|
+
// the server-job flag (see __dataIsServerJob). A browser's request never
|
|
422
|
+
// carries the token, so never the flag.
|
|
423
|
+
if (utils.isInternalCall(req) && req.headers && req.headers['x-tq-server-job'] === '1') {
|
|
424
|
+
context.__internalHeaders['x-tq-server-job'] = '1';
|
|
425
|
+
}
|
|
176
426
|
// The language of the page this run started on — carried by the client
|
|
177
427
|
// context, else read off the request — so a customer email node sends the
|
|
178
428
|
// copy that matches the storefront the visitor is browsing.
|
|
179
|
-
context.__locale = utils.resolveWorkflowLocale(req, incomingContext);${
|
|
429
|
+
context.__locale = utils.resolveWorkflowLocale(req, incomingContext);${
|
|
430
|
+
auth.guardCall
|
|
431
|
+
}${buildVisitorStepLimitGuard(segment)}
|
|
180
432
|
const sortedNodes = SEGMENT_CONFIG.nodes.slice().sort(function(a, b) { return a.stepNumber - b.stepNumber; });
|
|
181
433
|
|
|
182
434
|
for (let i = 0; i < sortedNodes.length; i++) {
|
|
@@ -186,7 +438,7 @@ module.exports = async function handler(req, res) {
|
|
|
186
438
|
// the caller as if that branch had run (a custom node answers the output
|
|
187
439
|
// of the last node it ran).
|
|
188
440
|
if (context.__skippedNodes && context.__skippedNodes[node.id]) continue;
|
|
189
|
-
const resolved =
|
|
441
|
+
const resolved = resolveNodeConfig(node, context);
|
|
190
442
|
// Every data node lives in a SERVER segment, so this guard — which turns an
|
|
191
443
|
// unresolved {{…}} into a validation error instead of letting the literal
|
|
192
444
|
// token reach SQL — was doing nothing at all: it ran only in the CLIENT
|
|
@@ -199,7 +451,7 @@ module.exports = async function handler(req, res) {
|
|
|
199
451
|
// rather than the stub handler, which always returns { result: true }.
|
|
200
452
|
// After evaluating, mark the non-taken branch nodes as skipped.
|
|
201
453
|
if (node.type === 'general-if-statement') {
|
|
202
|
-
const condResult = utils.evaluateCondition(resolved, context);
|
|
454
|
+
const condResult = utils.evaluateCondition(resolved, context, node.config);
|
|
203
455
|
context[node.id] = { result: condResult };
|
|
204
456
|
var skipHandle = condResult ? 'false' : 'true';
|
|
205
457
|
var segEdgesIf = SEGMENT_CONFIG.edges || [];
|
|
@@ -278,10 +530,10 @@ module.exports = async function handler(req, res) {
|
|
|
278
530
|
context[node.id] = utils.loopIterationContext(collection, li);
|
|
279
531
|
for (var bi = 0; bi < bodyNodes.length; bi++) {
|
|
280
532
|
var bNode = bodyNodes[bi];
|
|
281
|
-
var bResolved =
|
|
533
|
+
var bResolved = resolveNodeConfig(bNode, context);
|
|
282
534
|
bResolved.__nodeId = bNode.id;
|
|
283
535
|
if (bNode.type === 'general-if-statement') {
|
|
284
|
-
context[bNode.id] = { result: utils.evaluateCondition(bResolved, context) };
|
|
536
|
+
context[bNode.id] = { result: utils.evaluateCondition(bResolved, context, bNode.config) };
|
|
285
537
|
continue;
|
|
286
538
|
}
|
|
287
539
|
var bHandler = nodeHandlers[bNode.type];
|
|
@@ -316,17 +568,9 @@ module.exports = async function handler(req, res) {
|
|
|
316
568
|
|
|
317
569
|
// Switch nodes evaluate a value, match a case, execute that branch, skip all others
|
|
318
570
|
if (node.type === 'general-switch') {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
var matchedCase =
|
|
322
|
-
for (var swci = 0; swci < switchCases.length; swci++) {
|
|
323
|
-
var caseVal = utils.resolveValue(switchCases[swci].condition, context);
|
|
324
|
-
if (resolved.comparisonMode === 'expression') {
|
|
325
|
-
try { if (new Function('value', 'context', 'return (' + caseVal + ')')(switchVal, context)) { matchedCase = switchCases[swci].id; break; } } catch(e) {}
|
|
326
|
-
} else {
|
|
327
|
-
if (switchVal === caseVal) { matchedCase = switchCases[swci].id; break; }
|
|
328
|
-
}
|
|
329
|
-
}
|
|
571
|
+
// Only an authored case expression is compiled; request text is data
|
|
572
|
+
// (see matchSwitchCase in runtime-utils).
|
|
573
|
+
var matchedCase = utils.matchSwitchCase(node.config, resolved, context);
|
|
330
574
|
context[node.id] = { matchedCase: matchedCase };
|
|
331
575
|
var segSwitchEdges = SEGMENT_CONFIG.edges || [];
|
|
332
576
|
var allSwitchBranchEdges = segSwitchEdges.filter(function(e) { return e.source === node.id; });
|
|
@@ -372,7 +616,7 @@ module.exports = async function handler(req, res) {
|
|
|
372
616
|
return (async function() {
|
|
373
617
|
for (var pbi = 0; pbi < branchNodes.length; pbi++) {
|
|
374
618
|
var pNode = branchNodes[pbi];
|
|
375
|
-
var pRes =
|
|
619
|
+
var pRes = resolveNodeConfig(pNode, branchCtx);
|
|
376
620
|
pRes.__nodeId = pNode.id;
|
|
377
621
|
var pHandler = nodeHandlers[pNode.type];
|
|
378
622
|
if (!pHandler) continue;
|
|
@@ -391,7 +635,8 @@ module.exports = async function handler(req, res) {
|
|
|
391
635
|
branchNodes.forEach(function(bn) { context[bn.id] = bc[bn.id]; });
|
|
392
636
|
return { success: true };
|
|
393
637
|
}).catch(function(err) {
|
|
394
|
-
|
|
638
|
+
// The branch result reaches the browser: the detail stays in the log.
|
|
639
|
+
return { success: false, error: __branchError(err) };
|
|
395
640
|
});
|
|
396
641
|
});
|
|
397
642
|
var parallelResults;
|
|
@@ -468,9 +713,10 @@ module.exports = async function handler(req, res) {
|
|
|
468
713
|
delete context.__internalHeaders;
|
|
469
714
|
res.status(200).json({ success: true, results: utils.segmentReply(SEGMENT_CONFIG, context, __incomingSnapshot) });
|
|
470
715
|
} catch (error) {
|
|
471
|
-
console.error('Workflow segment error:', error);
|
|
472
716
|
if (__wfContext) { await utils.handOffPendingNodePromises(__wfContext); }
|
|
473
|
-
|
|
717
|
+
// A generic error and an opaque id: a driver, provider or secret-name
|
|
718
|
+
// detail never reaches the browser (it is logged under the same id).
|
|
719
|
+
__clientError(res, error);
|
|
474
720
|
}
|
|
475
721
|
};
|
|
476
722
|
`
|
|
@@ -488,10 +734,15 @@ export const generateStreamingServerSegmentAPIRoute = (
|
|
|
488
734
|
): string => {
|
|
489
735
|
const usedNodeTypes = new Set(segment.nodes.map((n) => n.type))
|
|
490
736
|
const nodeHandlersEntries = generateNodeHandlersForSegment(usedNodeTypes, true)
|
|
491
|
-
const hasRateLimiter = usedNodeTypes.has('general-rate-limiter')
|
|
492
737
|
const auth = buildWorkflowAuthInjection(protection)
|
|
738
|
+
const session = resolveSegmentSession(options, protection)
|
|
739
|
+
const abuseScope = resolveAbuseScope(segment, workflowName, options)
|
|
493
740
|
|
|
494
|
-
const segmentConfig = buildSegmentConfig(
|
|
741
|
+
const segmentConfig = buildSegmentConfig(
|
|
742
|
+
markVisitorBoundMessageNodes(segment, options.trust, protection, workflowName),
|
|
743
|
+
options,
|
|
744
|
+
session
|
|
745
|
+
)
|
|
495
746
|
|
|
496
747
|
const aiNodeTypes = JSON.stringify(Array.from(AI_NODE_TYPES))
|
|
497
748
|
|
|
@@ -503,24 +754,23 @@ export const generateStreamingServerSegmentAPIRoute = (
|
|
|
503
754
|
segment.id
|
|
504
755
|
)}\n */\n`
|
|
505
756
|
|
|
506
|
-
const requestInjection =
|
|
507
|
-
? `\n context.__request = { ip: __getClientIp(req), headers: req.headers || {} };`
|
|
508
|
-
: ''
|
|
757
|
+
const requestInjection = needsVisitorRequest(usedNodeTypes) ? VISITOR_REQUEST_INJECTION : ''
|
|
509
758
|
|
|
510
759
|
return `${header}
|
|
511
760
|
const utils = require('../../../utils/workflows/server-runtime');
|
|
512
|
-
${auth.requireLine}const
|
|
761
|
+
${auth.requireLine}const resolveNodeConfig = utils.resolveNodeConfig;
|
|
513
762
|
${workflowUtilsAliasLine('utils')}
|
|
514
763
|
${generateCartPricingPreamble(usedNodeTypes, '../../..')}${generateSentEmailLogPreamble(
|
|
515
764
|
usedNodeTypes,
|
|
516
765
|
'../../..'
|
|
517
766
|
)}${generatePaymentDriversPreamble(usesPaymentDriverNode(usedNodeTypes), '../../..')}
|
|
767
|
+
${SEGMENT_SECURITY_PREAMBLE}
|
|
518
768
|
const SEGMENT_CONFIG = ${segmentConfig};
|
|
519
769
|
${auth.policyConst}
|
|
520
770
|
const nodeHandlers = {
|
|
521
771
|
${nodeHandlersEntries}
|
|
522
772
|
};
|
|
523
|
-
|
|
773
|
+
${generateServerCustomNodeCallCode(segment, '../../..')}${generateSessionHandlersCode(session)}
|
|
524
774
|
const __streamingAITypes = ${aiNodeTypes};
|
|
525
775
|
|
|
526
776
|
function __isStreamingAI(node, config) {
|
|
@@ -535,7 +785,7 @@ function __streamNodeResult(res, nodeId, result) {
|
|
|
535
785
|
if (__credentialResultIds[nodeId]) return;
|
|
536
786
|
const kept = SEGMENT_CONFIG.nodes.find(function(nd) { return nd.id === nodeId; });
|
|
537
787
|
if (kept && kept.config && kept.config.keepResultOnServer === true && !utils.isBranchingNodeType(kept.type)) return;
|
|
538
|
-
res.write('data: ' + JSON.stringify({ type: 'node-result', nodeId: nodeId, result: utils.withoutCredentialColumns(kept, result) }) + '\\n\\n');
|
|
788
|
+
res.write('data: ' + JSON.stringify({ type: 'node-result', nodeId: nodeId, result: utils.scrubSecretNames(SEGMENT_CONFIG, utils.withoutCredentialColumns(kept, result)) }) + '\\n\\n');
|
|
539
789
|
}
|
|
540
790
|
|
|
541
791
|
function __collectSegBranchNodes(startId, excludeId) {
|
|
@@ -576,13 +826,13 @@ module.exports = async function handler(req, res) {
|
|
|
576
826
|
// Kept outside the try so the catch below can still drain any fire-and-forget
|
|
577
827
|
// query this segment started before it failed.
|
|
578
828
|
var __wfContext = null;
|
|
579
|
-
try {
|
|
829
|
+
try {${generateAbuseGateCode(abuseScope)}
|
|
580
830
|
const body = typeof req.body === 'string' ? JSON.parse(req.body) : req.body;
|
|
581
831
|
const context = Object.assign({}, body.context || {});
|
|
582
832
|
// See the non-streaming segment route: the reply carries only what changed.
|
|
583
833
|
const __incomingSnapshot = utils.snapshotIncomingContext(body.context || {});
|
|
584
834
|
utils.claimSegmentContext(SEGMENT_CONFIG, context);
|
|
585
|
-
__wfContext = context
|
|
835
|
+
__wfContext = context;${generateSessionBindCode(session)}
|
|
586
836
|
// See the non-streaming segment route — shared queue for nested custom nodes.
|
|
587
837
|
context.__pendingNodePromises = [];${requestInjection}
|
|
588
838
|
// Where this deployment calls its own routes — never a host the request
|
|
@@ -592,15 +842,25 @@ module.exports = async function handler(req, res) {
|
|
|
592
842
|
// without them a protected deployment 401s itself and every data node
|
|
593
843
|
// returns no rows. See internalRequestHeaders in runtime-utils.
|
|
594
844
|
context.__internalHeaders = utils.internalRequestHeaders(req);
|
|
845
|
+
// A server job's hop — a webhook, cron or automation running a custom
|
|
846
|
+
// node, which calls this route with the internal-call token only this
|
|
847
|
+
// deployment's server code can mint — stays the job's: its data calls keep
|
|
848
|
+
// the server-job flag (see __dataIsServerJob). A browser's request never
|
|
849
|
+
// carries the token, so never the flag.
|
|
850
|
+
if (utils.isInternalCall(req) && req.headers && req.headers['x-tq-server-job'] === '1') {
|
|
851
|
+
context.__internalHeaders['x-tq-server-job'] = '1';
|
|
852
|
+
}
|
|
595
853
|
// See the non-streaming segment route: the run's language.
|
|
596
|
-
context.__locale = utils.resolveWorkflowLocale(req, body.context);${
|
|
854
|
+
context.__locale = utils.resolveWorkflowLocale(req, body.context);${
|
|
855
|
+
auth.guardCall
|
|
856
|
+
}${buildVisitorStepLimitGuard(segment)}
|
|
597
857
|
const sortedNodes = SEGMENT_CONFIG.nodes.slice().sort(function(a, b) { return a.stepNumber - b.stepNumber; });
|
|
598
858
|
const executed = {};
|
|
599
859
|
|
|
600
860
|
for (let i = 0; i < sortedNodes.length; i++) {
|
|
601
861
|
const node = sortedNodes[i];
|
|
602
862
|
if (executed[node.id]) continue;
|
|
603
|
-
const resolved =
|
|
863
|
+
const resolved = resolveNodeConfig(node, context);
|
|
604
864
|
// See the non-streaming segment above — without this the unresolved-token
|
|
605
865
|
// guard never runs on the server, which is where every data node executes.
|
|
606
866
|
const __configError = utils.finalizeResolvedConfig(node.type, resolved);
|
|
@@ -609,7 +869,7 @@ module.exports = async function handler(req, res) {
|
|
|
609
869
|
|
|
610
870
|
// If-statement nodes must be evaluated using the runtime's evaluateCondition
|
|
611
871
|
if (node.type === 'general-if-statement') {
|
|
612
|
-
const condResult = utils.evaluateCondition(resolved, context);
|
|
872
|
+
const condResult = utils.evaluateCondition(resolved, context, node.config);
|
|
613
873
|
context[node.id] = { result: condResult };
|
|
614
874
|
executed[node.id] = true;
|
|
615
875
|
if (streamStarted) {
|
|
@@ -655,10 +915,10 @@ module.exports = async function handler(req, res) {
|
|
|
655
915
|
context[node.id] = utils.loopIterationContext(ssLoopCollection, ssli);
|
|
656
916
|
for (var ssbi = 0; ssbi < ssBodyNodes.length; ssbi++) {
|
|
657
917
|
var ssbNode = ssBodyNodes[ssbi];
|
|
658
|
-
var ssbRes =
|
|
918
|
+
var ssbRes = resolveNodeConfig(ssbNode, context);
|
|
659
919
|
ssbRes.__nodeId = ssbNode.id;
|
|
660
920
|
if (ssbNode.type === 'general-if-statement') {
|
|
661
|
-
context[ssbNode.id] = { result: utils.evaluateCondition(ssbRes, context) };
|
|
921
|
+
context[ssbNode.id] = { result: utils.evaluateCondition(ssbRes, context, ssbNode.config) };
|
|
662
922
|
continue;
|
|
663
923
|
}
|
|
664
924
|
var ssbHandler = nodeHandlers[ssbNode.type];
|
|
@@ -687,17 +947,8 @@ module.exports = async function handler(req, res) {
|
|
|
687
947
|
|
|
688
948
|
// Switch nodes in streaming segments
|
|
689
949
|
if (node.type === 'general-switch') {
|
|
690
|
-
|
|
691
|
-
var
|
|
692
|
-
var ssMatchedCase = 'default';
|
|
693
|
-
for (var ssswci = 0; ssswci < ssSwitchCases.length; ssswci++) {
|
|
694
|
-
var ssCaseVal = utils.resolveValue(ssSwitchCases[ssswci].condition, context);
|
|
695
|
-
if (resolved.comparisonMode === 'expression') {
|
|
696
|
-
try { if (new Function('value', 'context', 'return (' + ssCaseVal + ')')(ssSwitchVal, context)) { ssMatchedCase = ssSwitchCases[ssswci].id; break; } } catch(e) {}
|
|
697
|
-
} else {
|
|
698
|
-
if (ssSwitchVal === ssCaseVal) { ssMatchedCase = ssSwitchCases[ssswci].id; break; }
|
|
699
|
-
}
|
|
700
|
-
}
|
|
950
|
+
// See the non-streaming segment route: only authored expressions run.
|
|
951
|
+
var ssMatchedCase = utils.matchSwitchCase(node.config, resolved, context);
|
|
701
952
|
context[node.id] = { matchedCase: ssMatchedCase };
|
|
702
953
|
executed[node.id] = true;
|
|
703
954
|
var ssSwitchEdges = SEGMENT_CONFIG.edges || [];
|
|
@@ -747,7 +998,7 @@ module.exports = async function handler(req, res) {
|
|
|
747
998
|
return (async function() {
|
|
748
999
|
for (var sspbi = 0; sspbi < ssPBranchNodes.length; sspbi++) {
|
|
749
1000
|
var sspNode = ssPBranchNodes[sspbi];
|
|
750
|
-
var sspRes =
|
|
1001
|
+
var sspRes = resolveNodeConfig(sspNode, ssPBranchCtx);
|
|
751
1002
|
sspRes.__nodeId = sspNode.id;
|
|
752
1003
|
var sspHandler = nodeHandlers[sspNode.type];
|
|
753
1004
|
if (!sspHandler) continue;
|
|
@@ -766,7 +1017,8 @@ module.exports = async function handler(req, res) {
|
|
|
766
1017
|
ssPBranchNodes.forEach(function(bn) { context[bn.id] = bc[bn.id]; });
|
|
767
1018
|
return { success: true };
|
|
768
1019
|
}).catch(function(err) {
|
|
769
|
-
|
|
1020
|
+
// The branch result reaches the browser: the detail stays in the log.
|
|
1021
|
+
return { success: false, error: __branchError(err) };
|
|
770
1022
|
});
|
|
771
1023
|
});
|
|
772
1024
|
var ssParallelResults;
|
|
@@ -829,7 +1081,8 @@ module.exports = async function handler(req, res) {
|
|
|
829
1081
|
const sn = onStreamNodes[si];
|
|
830
1082
|
const snHandler = nodeHandlers[sn.type];
|
|
831
1083
|
if (!snHandler) continue;
|
|
832
|
-
const snResolved =
|
|
1084
|
+
const snResolved = resolveNodeConfig(sn, context);
|
|
1085
|
+
snResolved.__nodeId = sn.id;
|
|
833
1086
|
if (utils.isFireAndForgetNode(sn)) {
|
|
834
1087
|
utils.registerPendingNodePromise(context, utils.startFireAndForgetNode(sn, snHandler, snResolved, context));
|
|
835
1088
|
context[sn.id] = null;
|
|
@@ -853,7 +1106,8 @@ module.exports = async function handler(req, res) {
|
|
|
853
1106
|
const en = onEndNodes[oi];
|
|
854
1107
|
const enHandler = nodeHandlers[en.type];
|
|
855
1108
|
if (!enHandler) continue;
|
|
856
|
-
const enResolved =
|
|
1109
|
+
const enResolved = resolveNodeConfig(en, context);
|
|
1110
|
+
enResolved.__nodeId = en.id;
|
|
857
1111
|
if (utils.isFireAndForgetNode(en)) {
|
|
858
1112
|
utils.registerPendingNodePromise(context, utils.startFireAndForgetNode(en, enHandler, enResolved, context));
|
|
859
1113
|
context[en.id] = null;
|
|
@@ -920,21 +1174,61 @@ module.exports = async function handler(req, res) {
|
|
|
920
1174
|
res.status(200).json({ success: true, results: __reply });
|
|
921
1175
|
}
|
|
922
1176
|
} catch (error) {
|
|
923
|
-
console.error('Streaming workflow segment error:', error);
|
|
924
1177
|
if (__wfContext) { await utils.handOffPendingNodePromises(__wfContext); }
|
|
1178
|
+
// See the non-streaming segment route: a generic error and an opaque id.
|
|
925
1179
|
if (streamStarted) {
|
|
1180
|
+
var __errorId = __clientError({ headersSent: true }, error);
|
|
926
1181
|
try {
|
|
927
|
-
res.write('data: ' + JSON.stringify({ type: 'error', error: error
|
|
1182
|
+
res.write('data: ' + JSON.stringify({ type: 'error', error: __publicRefusal(error) || __PUBLIC_ERROR, id: __errorId }) + '\\n\\n');
|
|
928
1183
|
} catch(e) {}
|
|
929
1184
|
res.end();
|
|
930
1185
|
} else {
|
|
931
|
-
res
|
|
1186
|
+
__clientError(res, error);
|
|
932
1187
|
}
|
|
933
1188
|
}
|
|
934
1189
|
};
|
|
935
1190
|
`
|
|
936
1191
|
}
|
|
937
1192
|
|
|
1193
|
+
/**
|
|
1194
|
+
* A node an automation cannot run: one that only works in a visitor's
|
|
1195
|
+
* browser. The editor refuses them in automations; a handler module that
|
|
1196
|
+
* still meets one fails the run with the reason instead of stubbing it the
|
|
1197
|
+
* way a webhook route does (a stub would report a step that never happened).
|
|
1198
|
+
*/
|
|
1199
|
+
const isBrowserOnlyNode = (nodeType: string, generator: NodeHandlerGenerator | undefined) =>
|
|
1200
|
+
CLIENT_ONLY_NODES.has(nodeType) ||
|
|
1201
|
+
(!!generator && generator.executionEnv === 'client' && !generator.generateServerHandler)
|
|
1202
|
+
|
|
1203
|
+
/**
|
|
1204
|
+
* The step types a cron, webhook or automation route needs handlers for: its
|
|
1205
|
+
* own, and those of every custom node it calls, recursively — it runs them in
|
|
1206
|
+
* process (`utils/workflows/custom-nodes.js`) with this route's handler map. A
|
|
1207
|
+
* custom node's browser-only steps stay without one, as before (the runner
|
|
1208
|
+
* skips a step it has no handler for).
|
|
1209
|
+
*/
|
|
1210
|
+
const jobRouteNodeTypes = (
|
|
1211
|
+
ownNodes: UIDLWorkflowNode[],
|
|
1212
|
+
customNodes?: Record<string, UIDLCustomWorkflowNode>
|
|
1213
|
+
): Set<string> => {
|
|
1214
|
+
const types = new Set<string>(ownNodes.map((n: UIDLWorkflowNode) => n.type))
|
|
1215
|
+
for (const type of collectCalledCustomNodeTypes(ownNodes, customNodes)) {
|
|
1216
|
+
if (!isBrowserOnlyNode(type, nodeRegistry[type])) {
|
|
1217
|
+
types.add(type)
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
return types
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
const generateBrowserOnlyAutomationHandler = (nodeType: string): string => {
|
|
1224
|
+
const fnName = nodeType.replace(/-/g, '_')
|
|
1225
|
+
return `async function ${fnName}(config, context) {
|
|
1226
|
+
throw new Error(${JSON.stringify(
|
|
1227
|
+
`The ${nodeType} step only runs in a visitor's browser, so an automation cannot run it`
|
|
1228
|
+
)});
|
|
1229
|
+
}`
|
|
1230
|
+
}
|
|
1231
|
+
|
|
938
1232
|
const generateClientOnlyServerStub = (nodeType: string): string => {
|
|
939
1233
|
const fnName = nodeType.replace(/-/g, '_')
|
|
940
1234
|
return `async function ${fnName}(config, context) {
|
|
@@ -995,14 +1289,22 @@ function __wrapEmailHandler(nodeType, handler) {
|
|
|
995
1289
|
`
|
|
996
1290
|
}
|
|
997
1291
|
|
|
998
|
-
const generateNodeHandlersForSegment = (
|
|
1292
|
+
const generateNodeHandlersForSegment = (
|
|
1293
|
+
usedNodeTypes: Set<string>,
|
|
1294
|
+
forServer = false,
|
|
1295
|
+
automation = false,
|
|
1296
|
+
serverHandlerOptions: ServerHandlerOptions = {}
|
|
1297
|
+
): string => {
|
|
999
1298
|
return Array.from(usedNodeTypes)
|
|
1000
1299
|
.map((nodeType) => {
|
|
1001
|
-
const generator =
|
|
1300
|
+
const generator =
|
|
1301
|
+
automation && nodeType === generalWait.nodeType ? generalWait : nodeRegistry[nodeType]
|
|
1002
1302
|
let source: string
|
|
1003
|
-
if (generator) {
|
|
1303
|
+
if (automation && isBrowserOnlyNode(nodeType, generator)) {
|
|
1304
|
+
source = generateBrowserOnlyAutomationHandler(nodeType)
|
|
1305
|
+
} else if (generator) {
|
|
1004
1306
|
if (forServer && generator.generateServerHandler) {
|
|
1005
|
-
source = generator.generateServerHandler()
|
|
1307
|
+
source = generator.generateServerHandler(serverHandlerOptions)
|
|
1006
1308
|
} else if (forServer && generator.executionEnv === 'client') {
|
|
1007
1309
|
source = generateClientOnlyServerStub(nodeType)
|
|
1008
1310
|
} else {
|
|
@@ -1027,7 +1329,12 @@ async function ${nodeType.replace(/-/g, '_')}(config, context) {
|
|
|
1027
1329
|
.join(',\n')
|
|
1028
1330
|
}
|
|
1029
1331
|
|
|
1030
|
-
|
|
1332
|
+
/**
|
|
1333
|
+
* The browser-only nodes a server route drops (and an automation refuses).
|
|
1334
|
+
* The editor's copy is `CLIENT_ONLY_NODE_TYPES` in teleport-gui
|
|
1335
|
+
* `packages/workflow-schema`; automations-catalog-drift.test.ts compares them.
|
|
1336
|
+
*/
|
|
1337
|
+
export const CLIENT_ONLY_NODES = new Set([
|
|
1031
1338
|
'navigation-go-to-page',
|
|
1032
1339
|
'navigation-navigate-to-url',
|
|
1033
1340
|
'navigation-refresh-page',
|
|
@@ -1089,14 +1396,43 @@ const CLIENT_ONLY_NODES = new Set([
|
|
|
1089
1396
|
'realtime-list-channel-members',
|
|
1090
1397
|
])
|
|
1091
1398
|
|
|
1399
|
+
/** What a cron or webhook route is generated for. */
|
|
1400
|
+
export interface ServerWorkflowRouteOptions {
|
|
1401
|
+
/** The project has the in-app event bus (`hasAutomationsBus`). */
|
|
1402
|
+
withAutomations?: boolean
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
/**
|
|
1406
|
+
* What a cron or webhook route hands its nodes as `context.__request`: the
|
|
1407
|
+
* caller's ip for a rate limiter, and the request's headers for a signup in a
|
|
1408
|
+
* project with automations, which records its event on the origin the request
|
|
1409
|
+
* reached (see account-signup).
|
|
1410
|
+
*/
|
|
1411
|
+
const serverRouteRequestInjection = (
|
|
1412
|
+
nodeTypes: Set<string>,
|
|
1413
|
+
withAutomations: boolean | undefined
|
|
1414
|
+
): string => {
|
|
1415
|
+
if (nodeTypes.has('general-rate-limiter')) {
|
|
1416
|
+
return VISITOR_REQUEST_INJECTION
|
|
1417
|
+
}
|
|
1418
|
+
if (withAutomations && nodeTypes.has('account-signup')) {
|
|
1419
|
+
return `\n // The signup records its event on the origin this request reached.\n context.__request = { headers: req.headers || {} };`
|
|
1420
|
+
}
|
|
1421
|
+
return ''
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1092
1424
|
export const generateCronAPIRoute = (
|
|
1093
1425
|
workflow: UIDLWorkflow,
|
|
1094
|
-
customNodes?: Record<string, UIDLCustomWorkflowNode
|
|
1426
|
+
customNodes?: Record<string, UIDLCustomWorkflowNode>,
|
|
1427
|
+
options: ServerWorkflowRouteOptions = {}
|
|
1095
1428
|
): string => {
|
|
1096
1429
|
const serverNodes = workflow.nodes.filter((n: UIDLWorkflowNode) => !CLIENT_ONLY_NODES.has(n.type))
|
|
1097
|
-
const allNodeTypes =
|
|
1098
|
-
|
|
1099
|
-
const
|
|
1430
|
+
const allNodeTypes = jobRouteNodeTypes(serverNodes, customNodes)
|
|
1431
|
+
// Cron routes live in pages/api/workflows.
|
|
1432
|
+
const nodeHandlersEntries = generateNodeHandlersForSegment(allNodeTypes, true, false, {
|
|
1433
|
+
withAutomations: options.withAutomations,
|
|
1434
|
+
relativePrefix: '../../..',
|
|
1435
|
+
})
|
|
1100
1436
|
|
|
1101
1437
|
const serverNodeIds = new Set<string>(serverNodes.map((n: UIDLWorkflowNode) => n.id))
|
|
1102
1438
|
const serverEdges = workflow.edges.filter(
|
|
@@ -1123,9 +1459,7 @@ export const generateCronAPIRoute = (
|
|
|
1123
1459
|
2
|
|
1124
1460
|
)
|
|
1125
1461
|
|
|
1126
|
-
const requestInjection =
|
|
1127
|
-
? `\n context.__request = { ip: __getClientIp(req), headers: req.headers || {} };`
|
|
1128
|
-
: ''
|
|
1462
|
+
const requestInjection = serverRouteRequestInjection(allNodeTypes, options.withAutomations)
|
|
1129
1463
|
|
|
1130
1464
|
// Cron routes live at pages/api/workflows/<file>.js → three levels up to root.
|
|
1131
1465
|
const customNodesImport = useCustomNodes
|
|
@@ -1151,7 +1485,7 @@ export const generateCronAPIRoute = (
|
|
|
1151
1485
|
*/
|
|
1152
1486
|
|
|
1153
1487
|
const utils = require('../../../utils/workflows/server-runtime');
|
|
1154
|
-
const
|
|
1488
|
+
const resolveNodeConfig = utils.resolveNodeConfig;
|
|
1155
1489
|
${workflowUtilsAliasLine('utils')}
|
|
1156
1490
|
${customNodesImport}${generateCartPricingPreamble(
|
|
1157
1491
|
allNodeTypes,
|
|
@@ -1167,7 +1501,6 @@ const WORKFLOW_CONFIG = ${workflowConfig};
|
|
|
1167
1501
|
const nodeHandlers = {
|
|
1168
1502
|
${nodeHandlersEntries}
|
|
1169
1503
|
};
|
|
1170
|
-
|
|
1171
1504
|
module.exports = async function handler(req, res) {
|
|
1172
1505
|
if (req.method !== 'POST' && req.method !== 'GET') {
|
|
1173
1506
|
res.status(405).json({ error: 'Method not allowed' });
|
|
@@ -1198,6 +1531,10 @@ module.exports = async function handler(req, res) {
|
|
|
1198
1531
|
// without them a protected deployment 401s itself and every data node
|
|
1199
1532
|
// returns no rows. See internalRequestHeaders in runtime-utils.
|
|
1200
1533
|
context.__internalHeaders = utils.internalRequestHeaders(req);
|
|
1534
|
+
// A server job: no visitor's request runs here, so the data API reads the
|
|
1535
|
+
// customer records unscoped (see __dataIsServerJob; the flag counts only
|
|
1536
|
+
// with the app secret, which every data node presents).
|
|
1537
|
+
context.__internalHeaders['x-tq-server-job'] = '1';
|
|
1201
1538
|
context[WORKFLOW_CONFIG.triggerNodeId] = triggerContext;${requestInjection}
|
|
1202
1539
|
|
|
1203
1540
|
${executionLoop}
|
|
@@ -1267,8 +1604,50 @@ export const getCronRouteFileName = (workflow: UIDLWorkflow): string => {
|
|
|
1267
1604
|
*/
|
|
1268
1605
|
const generateNodeExecutionLoop = (
|
|
1269
1606
|
configVar: string,
|
|
1270
|
-
options?: { hasCustomNodes?: boolean }
|
|
1607
|
+
options?: { hasCustomNodes?: boolean; automation?: boolean }
|
|
1271
1608
|
): string => {
|
|
1609
|
+
const automation = options?.automation === true
|
|
1610
|
+
// An automation handler resumes a parked run at `resumeFrom` (the node
|
|
1611
|
+
// after its Wait): the nodes before it ran in the earlier part, and the
|
|
1612
|
+
// restored context carries their results and branch decisions.
|
|
1613
|
+
const resumeBlock = automation
|
|
1614
|
+
? `
|
|
1615
|
+
var __startIndex = 0;
|
|
1616
|
+
if (resumeFrom) {
|
|
1617
|
+
__startIndex = sortedNodes.findIndex(function(n) { return n.id === resumeFrom; });
|
|
1618
|
+
if (__startIndex === -1) { throw new Error('This automation has no step ' + resumeFrom + ' to resume at'); }
|
|
1619
|
+
}
|
|
1620
|
+
`
|
|
1621
|
+
: ''
|
|
1622
|
+
// An automation has no caller to answer, so a response node only ends the
|
|
1623
|
+
// run; a Wait stored the run (see general-wait) and nothing after it runs now.
|
|
1624
|
+
const earlyResponseBlock = automation
|
|
1625
|
+
? `
|
|
1626
|
+
if (result && result.__earlyResponse) {
|
|
1627
|
+
await utils.settlePendingNodePromises(context);
|
|
1628
|
+
return { waiting: false };
|
|
1629
|
+
}
|
|
1630
|
+
if (result && result.__wait) {
|
|
1631
|
+
await utils.settlePendingNodePromises(context);
|
|
1632
|
+
return { waiting: true, until: result.until, wouldWait: result.wouldWait || null };
|
|
1633
|
+
}`
|
|
1634
|
+
: `
|
|
1635
|
+
if (result && result.__earlyResponse) {
|
|
1636
|
+
var earlyRes = result.__earlyResponse;
|
|
1637
|
+
var hKeys = Object.keys(earlyRes.headers || {});
|
|
1638
|
+
for (var h = 0; h < hKeys.length; h++) {
|
|
1639
|
+
res.setHeader(hKeys[h], earlyRes.headers[hKeys[h]]);
|
|
1640
|
+
}
|
|
1641
|
+
await utils.settlePendingNodePromises(context);
|
|
1642
|
+
res.status(earlyRes.status || 500).json(earlyRes.body || {});
|
|
1643
|
+
return;
|
|
1644
|
+
}`
|
|
1645
|
+
// A branch runs on a copy of the context, so a Wait there could neither
|
|
1646
|
+
// store the run nor stop it.
|
|
1647
|
+
const parallelWaitGuard = automation
|
|
1648
|
+
? `
|
|
1649
|
+
if (wlpNode.type === 'general-wait') { throw new Error('A Wait cannot run inside a parallel branch'); }`
|
|
1650
|
+
: ''
|
|
1272
1651
|
const customNodeBlock = options?.hasCustomNodes
|
|
1273
1652
|
? `
|
|
1274
1653
|
if (result && result.__customNode) {
|
|
@@ -1292,13 +1671,13 @@ const generateNodeExecutionLoop = (
|
|
|
1292
1671
|
: ''
|
|
1293
1672
|
|
|
1294
1673
|
return ` var sortedNodes = ${configVar}.nodes.slice().sort(function(a, b) { return a.stepNumber - b.stepNumber; });
|
|
1295
|
-
|
|
1296
|
-
for (var i = 0; i < sortedNodes.length; i++) {
|
|
1674
|
+
${resumeBlock}
|
|
1675
|
+
for (var i = ${automation ? '__startIndex' : '0'}; i < sortedNodes.length; i++) {
|
|
1297
1676
|
var node = sortedNodes[i];
|
|
1298
1677
|
// Never resolved nor run on a non-taken branch, an if-statement included
|
|
1299
1678
|
// (see the segment executor above).
|
|
1300
1679
|
if (context.__skippedNodes && context.__skippedNodes[node.id]) continue;
|
|
1301
|
-
var resolved =
|
|
1680
|
+
var resolved = resolveNodeConfig(node, context);
|
|
1302
1681
|
// See the other segment executors — the unresolved-token guard must run
|
|
1303
1682
|
// wherever data nodes execute, and they all execute on the server.
|
|
1304
1683
|
var __configError = utils.finalizeResolvedConfig(node.type, resolved);
|
|
@@ -1306,7 +1685,7 @@ const generateNodeExecutionLoop = (
|
|
|
1306
1685
|
resolved.__nodeId = node.id;
|
|
1307
1686
|
|
|
1308
1687
|
if (node.type === 'general-if-statement') {
|
|
1309
|
-
var condResult = utils.evaluateCondition(resolved, context);
|
|
1688
|
+
var condResult = utils.evaluateCondition(resolved, context, node.config);
|
|
1310
1689
|
context[node.id] = { result: condResult };
|
|
1311
1690
|
var skipHandle = condResult ? 'false' : 'true';
|
|
1312
1691
|
var cfgEdges = ${configVar}.edges || [];
|
|
@@ -1370,10 +1749,10 @@ const generateNodeExecutionLoop = (
|
|
|
1370
1749
|
context[node.id] = utils.loopIterationContext(collection, li);
|
|
1371
1750
|
for (var bi = 0; bi < bodyNodes.length; bi++) {
|
|
1372
1751
|
var bNode = bodyNodes[bi];
|
|
1373
|
-
var bResolved =
|
|
1752
|
+
var bResolved = resolveNodeConfig(bNode, context);
|
|
1374
1753
|
bResolved.__nodeId = bNode.id;
|
|
1375
1754
|
if (bNode.type === 'general-if-statement') {
|
|
1376
|
-
context[bNode.id] = { result: utils.evaluateCondition(bResolved, context) };
|
|
1755
|
+
context[bNode.id] = { result: utils.evaluateCondition(bResolved, context, bNode.config) };
|
|
1377
1756
|
continue;
|
|
1378
1757
|
}
|
|
1379
1758
|
var bHandler = nodeHandlers[bNode.type];
|
|
@@ -1405,17 +1784,8 @@ const generateNodeExecutionLoop = (
|
|
|
1405
1784
|
if (context.__loopBodyNodeIds && context.__loopBodyNodeIds[node.id]) continue;
|
|
1406
1785
|
|
|
1407
1786
|
if (node.type === 'general-switch') {
|
|
1408
|
-
|
|
1409
|
-
var
|
|
1410
|
-
var swMatchedCase = 'default';
|
|
1411
|
-
for (var swci = 0; swci < swCases.length; swci++) {
|
|
1412
|
-
var swCaseVal = utils.resolveValue(swCases[swci].condition, context);
|
|
1413
|
-
if (resolved.comparisonMode === 'expression') {
|
|
1414
|
-
try { if (new Function('value', 'context', 'return (' + swCaseVal + ')')(swVal, context)) { swMatchedCase = swCases[swci].id; break; } } catch(e) {}
|
|
1415
|
-
} else {
|
|
1416
|
-
if (swVal === swCaseVal) { swMatchedCase = swCases[swci].id; break; }
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1787
|
+
// Only an authored case expression is compiled (see matchSwitchCase).
|
|
1788
|
+
var swMatchedCase = utils.matchSwitchCase(node.config, resolved, context);
|
|
1419
1789
|
context[node.id] = { matchedCase: swMatchedCase };
|
|
1420
1790
|
var swEdges = ${configVar}.edges || [];
|
|
1421
1791
|
var swBranchEdges = swEdges.filter(function(e) { return e.source === node.id; });
|
|
@@ -1459,8 +1829,8 @@ const generateNodeExecutionLoop = (
|
|
|
1459
1829
|
var wlBranchCtx = Object.assign({}, context);
|
|
1460
1830
|
return (async function() {
|
|
1461
1831
|
for (var wlpbi = 0; wlpbi < wlBranchNodes.length; wlpbi++) {
|
|
1462
|
-
var wlpNode = wlBranchNodes[wlpbi]
|
|
1463
|
-
var wlpRes =
|
|
1832
|
+
var wlpNode = wlBranchNodes[wlpbi];${parallelWaitGuard}
|
|
1833
|
+
var wlpRes = resolveNodeConfig(wlpNode, wlBranchCtx);
|
|
1464
1834
|
wlpRes.__nodeId = wlpNode.id;
|
|
1465
1835
|
var wlpHandler = nodeHandlers[wlpNode.type];
|
|
1466
1836
|
if (!wlpHandler) continue;
|
|
@@ -1523,17 +1893,7 @@ const generateNodeExecutionLoop = (
|
|
|
1523
1893
|
context[node.id] = null;
|
|
1524
1894
|
continue;
|
|
1525
1895
|
}
|
|
1526
|
-
var result = await handler(resolved, context)
|
|
1527
|
-
if (result && result.__earlyResponse) {
|
|
1528
|
-
var earlyRes = result.__earlyResponse;
|
|
1529
|
-
var hKeys = Object.keys(earlyRes.headers || {});
|
|
1530
|
-
for (var h = 0; h < hKeys.length; h++) {
|
|
1531
|
-
res.setHeader(hKeys[h], earlyRes.headers[hKeys[h]]);
|
|
1532
|
-
}
|
|
1533
|
-
await utils.settlePendingNodePromises(context);
|
|
1534
|
-
res.status(earlyRes.status || 500).json(earlyRes.body || {});
|
|
1535
|
-
return;
|
|
1536
|
-
}${customNodeBlock}
|
|
1896
|
+
var result = await handler(resolved, context);${earlyResponseBlock}${customNodeBlock}
|
|
1537
1897
|
if (utils.isFatalNodeResult(result) && !utils.continuesOnError(node)) {
|
|
1538
1898
|
throw new Error(utils.fatalNodeResultMessage(result));
|
|
1539
1899
|
}
|
|
@@ -1546,15 +1906,25 @@ const generateNodeExecutionLoop = (
|
|
|
1546
1906
|
await utils.settlePendingNodePromises(context);`
|
|
1547
1907
|
}
|
|
1548
1908
|
|
|
1909
|
+
/** A webhook whose payload a signature vouches for: a payment provider's, or a verified scheme other than `custom`. */
|
|
1910
|
+
export const isVerifiedWebhookConfig = (webhookConfig: UIDLWebhookConfig): boolean =>
|
|
1911
|
+
isPaymentWebhookConfig(webhookConfig) ||
|
|
1912
|
+
(!!webhookConfig.verifySignature && webhookConfig.signatureAlgorithm !== 'custom')
|
|
1913
|
+
|
|
1549
1914
|
export const generateWebhookWorkflowAPIRoute = (
|
|
1550
1915
|
workflow: UIDLWorkflow,
|
|
1551
|
-
customNodes?: Record<string, UIDLCustomWorkflowNode
|
|
1916
|
+
customNodes?: Record<string, UIDLCustomWorkflowNode>,
|
|
1917
|
+
options: ServerWorkflowRouteOptions = {}
|
|
1552
1918
|
): string => {
|
|
1553
1919
|
const webhookConfig = workflow.webhookConfig as UIDLWebhookConfig
|
|
1554
1920
|
const serverNodes = workflow.nodes.filter((n: UIDLWorkflowNode) => !CLIENT_ONLY_NODES.has(n.type))
|
|
1555
|
-
const allNodeTypes =
|
|
1556
|
-
const nodeHandlersEntries = generateNodeHandlersForSegment(allNodeTypes, true
|
|
1557
|
-
|
|
1921
|
+
const allNodeTypes = jobRouteNodeTypes(serverNodes, customNodes)
|
|
1922
|
+
const nodeHandlersEntries = generateNodeHandlersForSegment(allNodeTypes, true, false, {
|
|
1923
|
+
withAutomations: options.withAutomations,
|
|
1924
|
+
relativePrefix: getWebhookRoutePath(workflow)
|
|
1925
|
+
.map(() => '..')
|
|
1926
|
+
.join('/'),
|
|
1927
|
+
})
|
|
1558
1928
|
|
|
1559
1929
|
const serverNodeIds = new Set<string>(serverNodes.map((n: UIDLWorkflowNode) => n.id))
|
|
1560
1930
|
const serverEdges = workflow.edges.filter(
|
|
@@ -1564,10 +1934,21 @@ export const generateWebhookWorkflowAPIRoute = (
|
|
|
1564
1934
|
const hasCustomNodeUsage = serverNodes.some((n) => n.type === 'general-custom-node')
|
|
1565
1935
|
const hasCustomNodeDefs = customNodes && Object.keys(customNodes).length > 0
|
|
1566
1936
|
|
|
1937
|
+
// Without a verified signature the payload is anyone's: email/SMS nodes are
|
|
1938
|
+
// marked for the send guard as on a page's route, and so are the sends of
|
|
1939
|
+
// the custom nodes it calls (see PUBLIC_CALLER_INJECTION).
|
|
1940
|
+
const webhookVerified = isVerifiedWebhookConfig(webhookConfig)
|
|
1941
|
+
const webhookMessages = markWebhookMessageNodes(
|
|
1942
|
+
workflow,
|
|
1943
|
+
serverNodes,
|
|
1944
|
+
serverEdges,
|
|
1945
|
+
webhookVerified
|
|
1946
|
+
)
|
|
1947
|
+
|
|
1567
1948
|
const workflowConfig = JSON.stringify(
|
|
1568
1949
|
{
|
|
1569
1950
|
triggerNodeId: workflow.trigger.nodeId,
|
|
1570
|
-
nodes:
|
|
1951
|
+
nodes: webhookMessages.nodes.map((n: UIDLWorkflowNode) => ({
|
|
1571
1952
|
id: n.id,
|
|
1572
1953
|
type: n.type,
|
|
1573
1954
|
config: n.config,
|
|
@@ -1659,9 +2040,11 @@ export const generateWebhookWorkflowAPIRoute = (
|
|
|
1659
2040
|
)}`
|
|
1660
2041
|
: ''
|
|
1661
2042
|
|
|
1662
|
-
const requestInjection =
|
|
1663
|
-
|
|
1664
|
-
|
|
2043
|
+
const requestInjection =
|
|
2044
|
+
(webhookMessages.marked
|
|
2045
|
+
? VISITOR_REQUEST_INJECTION
|
|
2046
|
+
: serverRouteRequestInjection(allNodeTypes, options.withAutomations)) +
|
|
2047
|
+
(!webhookVerified && hasCustomNodeUsage ? PUBLIC_CALLER_INJECTION : '')
|
|
1665
2048
|
|
|
1666
2049
|
const executionLoop = generateNodeExecutionLoop('WORKFLOW_CONFIG', {
|
|
1667
2050
|
hasCustomNodes: hasCustomNodeUsage && hasCustomNodeDefs,
|
|
@@ -1678,7 +2061,7 @@ if (typeof globalThis.fetch === 'undefined') {
|
|
|
1678
2061
|
}
|
|
1679
2062
|
|
|
1680
2063
|
const utils = require('${relativePrefix}/utils/workflows/server-runtime');
|
|
1681
|
-
const
|
|
2064
|
+
const resolveNodeConfig = utils.resolveNodeConfig;
|
|
1682
2065
|
${workflowUtilsAliasLine('utils')}
|
|
1683
2066
|
${customNodesImport}${generateCartPricingPreamble(
|
|
1684
2067
|
allNodeTypes,
|
|
@@ -1700,7 +2083,6 @@ var ERROR_HANDLER_NODES = ${errorHandlerNodesJson};
|
|
|
1700
2083
|
const nodeHandlers = {
|
|
1701
2084
|
${nodeHandlersEntries}
|
|
1702
2085
|
};
|
|
1703
|
-
|
|
1704
2086
|
module.exports = async function handler(req, res) {
|
|
1705
2087
|
if (req.method !== '${webhookConfig.httpMethod}') {
|
|
1706
2088
|
res.status(405).json({ error: 'Method not allowed' });
|
|
@@ -1736,14 +2118,39 @@ ${generateSignatureVerificationBlock(normalisedWebhookConfig)}${deliveryLease.cl
|
|
|
1736
2118
|
// Credentials for this deployment's calls to its own /api/data routes —
|
|
1737
2119
|
// without them a protected deployment 401s itself and every data node
|
|
1738
2120
|
// returns no rows. See internalRequestHeaders in runtime-utils.
|
|
1739
|
-
context.__internalHeaders = utils.internalRequestHeaders(req)
|
|
2121
|
+
context.__internalHeaders = utils.internalRequestHeaders(req);
|
|
2122
|
+
// A server job: no visitor's request runs here, so the data API reads the
|
|
2123
|
+
// customer records unscoped (see __dataIsServerJob; the flag counts only
|
|
2124
|
+
// with the app secret, which every data node presents).
|
|
2125
|
+
context.__internalHeaders['x-tq-server-job'] = '1';${requestInjection}
|
|
1740
2126
|
|
|
1741
2127
|
${executionLoop}
|
|
1742
2128
|
${deliveryLease.release}
|
|
1743
2129
|
res.status(200).json({ received: true });
|
|
1744
2130
|
} catch (error) {
|
|
1745
2131
|
console.error('Webhook workflow error:', error);
|
|
1746
|
-
|
|
2132
|
+
${generateErrorHandlerRunBlock('Webhook error handler failed:')}
|
|
2133
|
+
// Land whatever the main run started (an email's ledger row, a
|
|
2134
|
+
// fire-and-forget write) before replying — see the segment routes.
|
|
2135
|
+
if (typeof context !== 'undefined' && context) { await utils.settlePendingNodePromises(context); }${
|
|
2136
|
+
deliveryLease.release
|
|
2137
|
+
}
|
|
2138
|
+
res.status(500).json({ error: 'Webhook processing failed' });
|
|
2139
|
+
}
|
|
2140
|
+
};
|
|
2141
|
+
|
|
2142
|
+
module.exports.config = { api: { bodyParser: false } };
|
|
2143
|
+
`
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
/**
|
|
2147
|
+
* Runs the workflow's error-handler branch (`ERROR_HANDLER_NODES`) after the
|
|
2148
|
+
* main run threw `error`, on a copy of `context` that carries the error. A
|
|
2149
|
+
* failure of the branch itself is only logged, with `failureLabel`.
|
|
2150
|
+
*/
|
|
2151
|
+
const generateErrorHandlerRunBlock = (
|
|
2152
|
+
failureLabel: string
|
|
2153
|
+
): string => ` if (ERROR_HANDLER_NODES) {
|
|
1747
2154
|
try {
|
|
1748
2155
|
var errCtx = Object.assign({}, context || {});
|
|
1749
2156
|
if (WORKFLOW_CONFIG.errorHandlerNodeId) {
|
|
@@ -1754,7 +2161,7 @@ ${deliveryLease.release}
|
|
|
1754
2161
|
}
|
|
1755
2162
|
for (var ei = 0; ei < ERROR_HANDLER_NODES.length; ei++) {
|
|
1756
2163
|
var eNode = ERROR_HANDLER_NODES[ei];
|
|
1757
|
-
var eResolved =
|
|
2164
|
+
var eResolved = resolveNodeConfig(eNode, errCtx);
|
|
1758
2165
|
eResolved.__nodeId = eNode.id;
|
|
1759
2166
|
var eHandler = nodeHandlers[eNode.type];
|
|
1760
2167
|
if (eHandler) {
|
|
@@ -1769,19 +2176,190 @@ ${deliveryLease.release}
|
|
|
1769
2176
|
}
|
|
1770
2177
|
await utils.settlePendingNodePromises(errCtx);
|
|
1771
2178
|
} catch (innerErr) {
|
|
1772
|
-
console.error('
|
|
2179
|
+
console.error('${failureLabel}', innerErr);
|
|
1773
2180
|
}
|
|
1774
|
-
}
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
2181
|
+
}`
|
|
2182
|
+
|
|
2183
|
+
/**
|
|
2184
|
+
* An automation's handler module (`lib/automations/handlers/<file>.js`, see
|
|
2185
|
+
* automations/handler-module-generator.ts): the webhook route's node loop as
|
|
2186
|
+
* an importable function, `module.exports.run = async (event, context,
|
|
2187
|
+
* resumeFrom)`, which the in-app dispatcher awaits.
|
|
2188
|
+
*
|
|
2189
|
+
* - `event` is the event envelope (`{ event, actor, <entity> }`): the trigger
|
|
2190
|
+
* node's output. A resumed run passes it again, read afresh.
|
|
2191
|
+
* - `context` is `{}` for a new run (plus `__baseUrl` when the dispatcher
|
|
2192
|
+
* knows the app's origin), or the context a Wait stored.
|
|
2193
|
+
* - `resumeFrom` is the node to resume at; every node before it ran already.
|
|
2194
|
+
*
|
|
2195
|
+
* Every node runs as in a webhook route — server handlers, the same
|
|
2196
|
+
* `__baseUrl` / internal headers, the error-handler branch — except the
|
|
2197
|
+
* browser-only ones, which fail the run, and a Wait (`general-wait`), which
|
|
2198
|
+
* stores the run and resolves `{ waiting: true }` (a test event's Wait stores
|
|
2199
|
+
* nothing and resolves `{ waiting: true, wouldWait }`; a Wait with no step
|
|
2200
|
+
* after it stores nothing and the run ends there). A run that fails rejects,
|
|
2201
|
+
* after the error-handler branch ran, so the dispatcher records the failure.
|
|
2202
|
+
*/
|
|
2203
|
+
export const generateHandlerFunction = (
|
|
2204
|
+
workflow: UIDLWorkflow,
|
|
2205
|
+
customNodes?: Record<string, UIDLCustomWorkflowNode>
|
|
2206
|
+
): string => {
|
|
2207
|
+
const relativePrefix = AUTOMATION_HANDLERS_PATH.map(() => '..').join('/')
|
|
2208
|
+
const nodes = workflow.nodes || []
|
|
2209
|
+
const allNodeTypes = jobRouteNodeTypes(nodes, customNodes)
|
|
2210
|
+
// An automation runs only in a project that has the event bus.
|
|
2211
|
+
const nodeHandlersEntries = generateNodeHandlersForSegment(allNodeTypes, true, true, {
|
|
2212
|
+
withAutomations: true,
|
|
2213
|
+
relativePrefix,
|
|
2214
|
+
})
|
|
2215
|
+
|
|
2216
|
+
const hasCustomNodeUsage = nodes.some((n) => n.type === 'general-custom-node')
|
|
2217
|
+
const useCustomNodes = hasCustomNodeUsage && !!customNodes && Object.keys(customNodes).length > 0
|
|
2218
|
+
|
|
2219
|
+
const workflowConfig = JSON.stringify(
|
|
2220
|
+
{
|
|
2221
|
+
triggerNodeId: workflow.trigger.nodeId,
|
|
2222
|
+
nodes: nodes.map((n: UIDLWorkflowNode) => ({
|
|
2223
|
+
id: n.id,
|
|
2224
|
+
type: n.type,
|
|
2225
|
+
config: n.config,
|
|
2226
|
+
stepNumber: n.stepNumber,
|
|
2227
|
+
label: n.label,
|
|
2228
|
+
})),
|
|
2229
|
+
edges: workflow.edges || [],
|
|
2230
|
+
errorHandlerNodeId: workflow.errorHandler?.nodeId || null,
|
|
2231
|
+
},
|
|
2232
|
+
null,
|
|
2233
|
+
2
|
|
2234
|
+
)
|
|
2235
|
+
const errorHandlerNodes = workflow.errorHandler ? getErrorHandlerNodes(workflow) : null
|
|
2236
|
+
const errorHandlerNodesJson = errorHandlerNodes
|
|
2237
|
+
? JSON.stringify(errorHandlerNodes, null, 2)
|
|
2238
|
+
: 'null'
|
|
2239
|
+
|
|
2240
|
+
const customNodesImport = useCustomNodes
|
|
2241
|
+
? `var __customNodes;\ntry { __customNodes = require('${relativePrefix}/utils/workflows/custom-nodes'); } catch (_e) { __customNodes = {}; }\n${adminCustomNodesRequireLine(
|
|
2242
|
+
nodes,
|
|
2243
|
+
customNodes,
|
|
2244
|
+
relativePrefix
|
|
2245
|
+
)}`
|
|
2246
|
+
: ''
|
|
2247
|
+
|
|
2248
|
+
const executionLoop = generateNodeExecutionLoop('WORKFLOW_CONFIG', {
|
|
2249
|
+
hasCustomNodes: useCustomNodes,
|
|
2250
|
+
automation: true,
|
|
2251
|
+
})
|
|
2252
|
+
|
|
2253
|
+
return `/**
|
|
2254
|
+
* Automation handler
|
|
2255
|
+
* Workflow: ${sanitizeForBlockComment(workflow.name || workflow.id)}
|
|
2256
|
+
* Event: ${sanitizeForBlockComment(automationEventType(workflow) || 'none')}
|
|
2257
|
+
*/
|
|
2258
|
+
if (typeof globalThis.fetch === 'undefined') {
|
|
2259
|
+
globalThis.fetch = require('node-fetch');
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
const utils = require('${relativePrefix}/utils/workflows/server-runtime');
|
|
2263
|
+
const resolveNodeConfig = utils.resolveNodeConfig;
|
|
2264
|
+
${workflowUtilsAliasLine('utils')}
|
|
2265
|
+
${customNodesImport}${generateCartPricingPreamble(
|
|
2266
|
+
allNodeTypes,
|
|
2267
|
+
relativePrefix
|
|
2268
|
+
)}${generateSentEmailLogPreamble(allNodeTypes, relativePrefix)}${generatePaymentDriversPreamble(
|
|
2269
|
+
usesPaymentDriverNode(allNodeTypes),
|
|
2270
|
+
relativePrefix
|
|
2271
|
+
)}
|
|
2272
|
+
var __automationStore = require('../store');
|
|
2273
|
+
|
|
2274
|
+
var WORKFLOW_ID = ${JSON.stringify(workflow.id)};
|
|
2275
|
+
|
|
2276
|
+
const WORKFLOW_CONFIG = ${workflowConfig};
|
|
2277
|
+
|
|
2278
|
+
var ERROR_HANDLER_NODES = ${errorHandlerNodesJson};
|
|
2279
|
+
|
|
2280
|
+
const nodeHandlers = {
|
|
2281
|
+
${nodeHandlersEntries}
|
|
1782
2282
|
};
|
|
2283
|
+
// Rebuilt by every run, so never stored with a parked one: the queue of
|
|
2284
|
+
// fire-and-forget work, where and with which credentials the run calls the
|
|
2285
|
+
// app's own routes, and the run itself.
|
|
2286
|
+
var RUNTIME_CONTEXT_KEYS = ['__pendingNodePromises', '__baseUrl', '__internalHeaders', '__automation', '__request', '__emailAttribution'];
|
|
2287
|
+
|
|
2288
|
+
var SORTED_NODE_IDS = WORKFLOW_CONFIG.nodes
|
|
2289
|
+
.slice()
|
|
2290
|
+
.sort(function(a, b) { return a.stepNumber - b.stepNumber; })
|
|
2291
|
+
.map(function(n) { return n.id; });
|
|
2292
|
+
|
|
2293
|
+
// Stores the run at a Wait: the next node, and the context so far.
|
|
2294
|
+
async function park(context, nodeId, until) {
|
|
2295
|
+
var at = SORTED_NODE_IDS.indexOf(nodeId);
|
|
2296
|
+
var resumeNodeId = at === -1 ? null : SORTED_NODE_IDS[at + 1] || null;
|
|
2297
|
+
// Nothing after the Wait: the run is over.
|
|
2298
|
+
if (!resumeNodeId) return null;
|
|
2299
|
+
if (!context.__automation.eventId) {
|
|
2300
|
+
throw new Error('A Wait needs the event the automation runs for');
|
|
2301
|
+
}
|
|
2302
|
+
var saved = {};
|
|
2303
|
+
Object.keys(context).forEach(function(key) {
|
|
2304
|
+
if (RUNTIME_CONTEXT_KEYS.indexOf(key) === -1) saved[key] = context[key];
|
|
2305
|
+
});
|
|
2306
|
+
await __automationStore.saveWait({
|
|
2307
|
+
eventId: context.__automation.eventId,
|
|
2308
|
+
workflowId: WORKFLOW_ID,
|
|
2309
|
+
resumeNodeId: resumeNodeId,
|
|
2310
|
+
context: JSON.stringify(saved),
|
|
2311
|
+
runAt: until,
|
|
2312
|
+
});
|
|
2313
|
+
return resumeNodeId;
|
|
2314
|
+
}
|
|
1783
2315
|
|
|
1784
|
-
|
|
2316
|
+
async function runNodes(context, resumeFrom) {
|
|
2317
|
+
${executionLoop}
|
|
2318
|
+
return { waiting: false };
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
async function run(event, context, resumeFrom) {
|
|
2322
|
+
context = context && typeof context === 'object' ? context : {};
|
|
2323
|
+
// Shared fire-and-forget queue — drained before the run settles.
|
|
2324
|
+
context.__pendingNodePromises = [];
|
|
2325
|
+
// Where this deployment calls its own routes, and with which credentials
|
|
2326
|
+
// (see the webhook routes).
|
|
2327
|
+
if (!context.__baseUrl) {
|
|
2328
|
+
context.__baseUrl = __automationStore.appBaseUrl();
|
|
2329
|
+
}
|
|
2330
|
+
context.__internalHeaders = utils.internalRequestHeaders(null);
|
|
2331
|
+
// A server job: no visitor's request runs here, so the data API reads the
|
|
2332
|
+
// customer records unscoped (see __dataIsServerJob; the flag counts only
|
|
2333
|
+
// with the app secret, which every data node presents).
|
|
2334
|
+
context.__internalHeaders['x-tq-server-job'] = '1';
|
|
2335
|
+
if (event) {
|
|
2336
|
+
context[WORKFLOW_CONFIG.triggerNodeId] = event;
|
|
2337
|
+
}
|
|
2338
|
+
var trigger = context[WORKFLOW_CONFIG.triggerNodeId] || {};
|
|
2339
|
+
context.__automation = {
|
|
2340
|
+
workflowId: WORKFLOW_ID,
|
|
2341
|
+
eventId: trigger.event && trigger.event.id ? String(trigger.event.id) : '',
|
|
2342
|
+
// A test event runs once and never parks at a Wait (see general-wait).
|
|
2343
|
+
test: !!(trigger.event && trigger.event.test === true),
|
|
2344
|
+
park: function(nodeId, until) { return park(context, nodeId, until); },
|
|
2345
|
+
};
|
|
2346
|
+
// The mail this run sends is filed under the automation, and under the
|
|
2347
|
+
// event's order when it has one (the sent-email ledger reads this).
|
|
2348
|
+
context.__emailAttribution = {
|
|
2349
|
+
source: 'automation',
|
|
2350
|
+
sourceRef: WORKFLOW_ID,
|
|
2351
|
+
orderId: trigger.order && trigger.order.id ? String(trigger.order.id) : null,
|
|
2352
|
+
};
|
|
2353
|
+
try {
|
|
2354
|
+
return await runNodes(context, resumeFrom || null);
|
|
2355
|
+
} catch (error) {
|
|
2356
|
+
${generateErrorHandlerRunBlock('Automation error handler failed:')}
|
|
2357
|
+
await utils.settlePendingNodePromises(context);
|
|
2358
|
+
throw error;
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
module.exports.run = run;
|
|
1785
2363
|
`
|
|
1786
2364
|
}
|
|
1787
2365
|
|