@fluidgrids/fe-sdk 0.0.0-stage → 2026.1203.7
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/README.md +564 -2
- package/dist/ActivityOptionsFields-C2u-hY2U.js +142 -0
- package/dist/AiStudioPage-B_hNTj-_.js +1137 -0
- package/dist/ApprovalInboxPage-ClITra3n.js +1312 -0
- package/dist/ChoiceSelect-LkK-uS9J.js +65 -0
- package/dist/ConfirmActionDialog-DHWTDRbp.js +31 -0
- package/dist/ConnectionFormDialog-C0kDgcrZ.js +153 -0
- package/dist/CreateFluidgridsTagDocument-Dtp9KPLJ.js +1055 -0
- package/dist/DataSinkDashboardPage-b4ezeqa6.js +278 -0
- package/dist/DataTablesPage-C1d9YGHz.js +5575 -0
- package/dist/DateTimeField-B1qR4ruo.js +51 -0
- package/dist/Disclosure-BNKij7-v.js +45 -0
- package/dist/ElementLibraryPage-8jNO6YmE.js +2256 -0
- package/dist/ElementLibrarySequenceDocument-B-W8SPzn.js +3979 -0
- package/dist/EnsureThemeProvider-BvlNjAd0.js +24 -0
- package/dist/EntityTagBadge-1OlP6p0c.js +25 -0
- package/dist/EntityTagPicker-BBrU5cE0.js +137 -0
- package/dist/ExecuteStepDocument-B4j1mdRT.js +189 -0
- package/dist/ExecutionDetailDocument-D6QuM-kp.js +875 -0
- package/dist/ExecutionDetailPage-D4CBtFdo.js +12217 -0
- package/dist/ExecutionDetailPage-DvQ667OE.d.ts +10 -0
- package/dist/ExecutionStatusBadge-BsDVor9t.js +221 -0
- package/dist/ExecutionsListDocument-Dan7ZiqB.js +459 -0
- package/dist/ExecutionsListPage-B3XT8ITL.js +4307 -0
- package/dist/FailureTriagePanel-DOJMaJ0n.js +1285 -0
- package/dist/FileDownloadUrlDocument-CVOYKcL5.js +92 -0
- package/dist/FluidGridsDocsLink-bX0Hnhxr.js +66 -0
- package/dist/FluidGridsMark-CE2blT7K.js +74 -0
- package/dist/HeldLoadRegion-BtTxbvOW.js +34 -0
- package/dist/HistoryPage-BLoRpJ1R.d.ts +6 -0
- package/dist/HistoryPage-BSBISXoj.js +2835 -0
- package/dist/Icon-BtQ0HXLh.js +160 -0
- package/dist/InsightsPage-D7ybj8N9.js +11245 -0
- package/dist/IsolationSetting-vy911E8b.js +1153 -0
- package/dist/LibraryParts-DOeNgR8A.js +413 -0
- package/dist/ManagedAiPolicyAuthority-BxwJ3ptd.js +40 -0
- package/dist/ManagedAiPolicyAuthority-DM3t3wNr.d.ts +18 -0
- package/dist/ManagedAiPolicyAuthorityContext-CNkxIOZ1.js +10 -0
- package/dist/McpTriggerServers-BCPCAOWB.js +459 -0
- package/dist/MissingNodesInstallModal-rO_SEDrC.js +224 -0
- package/dist/NavigationV2Provider-DCDt35eG.js +17 -0
- package/dist/NodeSchemaIntrospectionDocument-C1vAIcHd.js +95 -0
- package/dist/NodesPage-DEbnz9iU.d.ts +6 -0
- package/dist/NodesPage-O7KeeKtd.js +653 -0
- package/dist/OfflineIcon-TwMKYWjA.js +207 -0
- package/dist/OpenTemplateAsCodeButton-BhWJWIF3.js +94 -0
- package/dist/PaidTemplateConfirm-_G3ag6S4.js +28 -0
- package/dist/PublishCustomNodeAction-CIySbK4c.js +134 -0
- package/dist/RecordTaskDialog-BkpCDvhR.js +2078 -0
- package/dist/RunActionsMenu-DodOgIQm.js +59 -0
- package/dist/RunnerStatusPill-C1v967iq.js +24 -0
- package/dist/RunnersPage-dB0RSdY_.js +1929 -0
- package/dist/SandboxRuntimeExhaustedNotice-BFOIF93C.js +120 -0
- package/dist/SchedulesPage-DPWr1yvf.js +1607 -0
- package/dist/SearchBox-BGtYjvfs.js +49 -0
- package/dist/SequenceEditor-CFiHeHkR.js +497 -0
- package/dist/SettingsPage-0CQBNPZV.js +8695 -0
- package/dist/StewardPages-DAJhepen.js +47 -0
- package/dist/StewardRunImportPanel-Kva2DO0u.js +2844 -0
- package/dist/StoreTemplateCardCompact-CHn5kP7A.js +2166 -0
- package/dist/TagFilterSelect-CyA8QrS7.js +42 -0
- package/dist/TaskQueuesPage-DdnDCyat.js +3571 -0
- package/dist/TechnicalDetails-B0Oi4aZw.js +19 -0
- package/dist/TemplateConfigurationModal-CdvCYJLM.js +332 -0
- package/dist/TemplateDetailPanel-CbiKciuB.js +222 -0
- package/dist/TemplatePreview-cx7-NOeG.js +868 -0
- package/dist/TemplatesPage-BG3H-6v6.d.ts +10 -0
- package/dist/TemplatesPage-BVQpGYIV.js +3251 -0
- package/dist/TerminateExecutionDocument-B_HKNVrN.js +581 -0
- package/dist/TranslationBridge-Bd4aJKMs.d.ts +11 -0
- package/dist/TranslationBridge-Da-TPgQm.js +68 -0
- package/dist/TriggerWorkflowDocument-D9Km2Vv2.js +460 -0
- package/dist/UiSequencePickerSequenceDocument-BSYnSDV7.js +607 -0
- package/dist/UiStepScreenshot-Qh4QMyUp.js +146 -0
- package/dist/UsageTimeSeriesDocument-DcInx9-z.js +177 -0
- package/dist/VariablesPage-ChfGuW22.js +2243 -0
- package/dist/VersionDiffDialog-Bd2AeUwf.js +1702 -0
- package/dist/VersionLifecycleBar-BBeWVtz-.js +143 -0
- package/dist/WebhookDeliveriesPage-D66bua0j.js +1563 -0
- package/dist/WorkflowBuilder-B6wQD1TK.js +539 -0
- package/dist/WorkflowBuilder-DR4ku8Tr.js +1611 -0
- package/dist/WorkflowDefinitionDocument-DZLbTPUZ.js +321 -0
- package/dist/WorkflowEmbed-BXfFGy0i.js +708 -0
- package/dist/WorkflowEmbed-Cbqe1s1z.d.ts +6 -0
- package/dist/WorkflowPinnedDataDocument-BODT5omd.js +782 -0
- package/dist/WorkflowProposalCard-BruukdeF.js +96 -0
- package/dist/WorkflowProposalDocument-BdUbsrd0.js +620 -0
- package/dist/WorkflowSearchRedirect-C7zJ2MKH.js +40 -0
- package/dist/WorkflowSettingsDrawer-MVU1BKfY.d.ts +18 -0
- package/dist/WorkflowSettingsDrawer-gazs97WR.js +196 -0
- package/dist/WorkflowShareDialog-e8jJtLjU.js +469 -0
- package/dist/WorkflowVersionsDocument-DRVOp8Uj.js +3213 -0
- package/dist/WorkflowsList--hR2_8gf.js +4593 -0
- package/dist/WorkflowsList-CcNDQge5.d.ts +6 -0
- package/dist/WorkflowsListPageDocument-CnzcQm_o.js +934 -0
- package/dist/addonCatalog-CbZS4deh.js +58 -0
- package/dist/addonCatalog-sjlonAmR.d.ts +15 -0
- package/dist/addons.d.ts +3 -0
- package/dist/addons.js +4 -0
- package/dist/agent-form-Bfvm32j1.js +83 -0
- package/dist/agent-tools.d.ts +3 -0
- package/dist/agent-tools.js +5 -0
- package/dist/agentTools-CyL7DLOF.js +320 -0
- package/dist/ai-usage-BrxDgvdR.js +240 -0
- package/dist/aiCreditsBridge-BuE92tKo.js +49 -0
- package/dist/api-BKq-nIOZ.js +2286 -0
- package/dist/api-Ol7I8NxE.js +8289 -0
- package/dist/apollo-type-policies.d.ts +11 -0
- package/dist/apollo-type-policies.js +64 -0
- package/dist/askAboutBridge-ByYsQams.js +106 -0
- package/dist/askQuestions-Cmx7VnMm.js +742 -0
- package/dist/assert-rules-lfYEMc99.js +318 -0
- package/dist/assistant.d.ts +94 -0
- package/dist/assistant.js +99 -0
- package/dist/attach-node-helpers-HDKQOtrD.js +32 -0
- package/dist/badge-CXfPhoMH.js +26 -0
- package/dist/basil.generated-BK-EHbwN.js +10 -0
- package/dist/browser-steps-DMpS5TyB.js +533 -0
- package/dist/builderTimings-pvGnK1m-.js +510 -0
- package/dist/button-DG7y_FVJ.js +48 -0
- package/dist/canvasNoteTools-BxuP_AYO.js +137 -0
- package/dist/card-Bomy_1UG.js +44 -0
- package/dist/catalogGrid-BOrfMgi-.js +41 -0
- package/dist/channel-CPyQ1NR1.js +212 -0
- package/dist/chips-CvNrYJZa.js +27 -0
- package/dist/client-holder-C0M5Cfwl.js +68 -0
- package/dist/cn-QqidFIgr.js +10 -0
- package/dist/code-editor-diagnostics-Zr0cIcx1.js +46 -0
- package/dist/code-editor-field-x_JrY8KR.js +113 -0
- package/dist/codec-client-DPuD6mw7.js +515 -0
- package/dist/conditionBuilder-DwfEF0Q-.js +1144 -0
- package/dist/config-DO68jw5k.js +322 -0
- package/dist/constants-DgbVc24O.d.ts +296 -0
- package/dist/constants-DlRnHBfQ.js +217 -0
- package/dist/convert-browser-action-pfecelF7.js +347 -0
- package/dist/convert-dialog-B_o22NiJ.js +382 -0
- package/dist/create-workflow-first-Azg3JUdX.js +120 -0
- package/dist/definition-canvas-Bsda-rDT.js +31 -0
- package/dist/dialog-BVd152GS.js +94 -0
- package/dist/durable-nodes-BXyYCLxT.js +91 -0
- package/dist/duration-CDb7-mT_.js +33 -0
- package/dist/edge-mapper-wEAdGVU2.js +4477 -0
- package/dist/element-library-DkSlg_VE.js +727 -0
- package/dist/entities-I_0kio3q.js +38 -0
- package/dist/error-advice-QLr5NCm7.js +65 -0
- package/dist/errors-ClKb5sEt.js +188 -0
- package/dist/executions.d.ts +3 -0
- package/dist/executions.js +5 -0
- package/dist/feature-flags-B2qetXKd.js +385 -0
- package/dist/field-label-DPZRmE_B.js +153 -0
- package/dist/firstWorkflow-C_h0KMB2.js +133 -0
- package/dist/flags.d.ts +3 -0
- package/dist/flags.js +4 -0
- package/dist/flow-builder-DIvLOhz0.js +28038 -0
- package/dist/flow-store-holder-CUN7Terz.js +52 -0
- package/dist/fluent.generated-CA_e6-4l.js +14 -0
- package/dist/fluidgridsEvents-bbEQbwU6.js +175 -0
- package/dist/fluidgridsTheme-DUhvOgoy.js +297 -0
- package/dist/global-client-BQPuFrFa.js +433 -0
- package/dist/global-operations-BG6YgxrM.js +136 -0
- package/dist/graphql-types-UTYtujY9.js +21358 -0
- package/dist/history.d.ts +3 -0
- package/dist/history.js +4 -0
- package/dist/index-AoJAa5vU.d.ts +164958 -0
- package/dist/index-DEMT3iAM.d.ts +120 -0
- package/dist/index-ROZzNGyY.d.ts +76 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +8123 -0
- package/dist/ion.generated-mbajjcAg.js +10 -0
- package/dist/label-Lzb8ZXf_.js +29 -0
- package/dist/labels-rXd9gYQz.js +1236 -0
- package/dist/liveCanvas-D5ytXDp8.js +103 -0
- package/dist/logos.generated-X6_0kjVR.js +21 -0
- package/dist/logs-panel-Cw0DkG0l.js +468 -0
- package/dist/lucide.generated-B6NVd3GT.js +29 -0
- package/dist/marksStore-a9oIMMot.js +175 -0
- package/dist/mcp-trigger-D0nRdvq5.js +307 -0
- package/dist/mdi.generated-D1BV74d6.js +292 -0
- package/dist/menus-CU3hDGYl.js +160 -0
- package/dist/mynaui.generated-DMWr5cXz.js +66 -0
- package/dist/navigation-v2.d.ts +3 -0
- package/dist/navigation-v2.js +5 -0
- package/dist/node-detail-view-Cgm5H1P-.js +1372 -0
- package/dist/node-editor-tab-body-CZ0fVuVP.js +187 -0
- package/dist/node-operation-selection-CdV3KI_V.js +3534 -0
- package/dist/node-registry-refresh-s3okf83X.js +27 -0
- package/dist/node-role-TMbnkmeP.js +132 -0
- package/dist/node-type-icon-BZa8n4iG.js +33 -0
- package/dist/nodes.d.ts +3 -0
- package/dist/nodes.js +4 -0
- package/dist/notesKey-5EaREBGA.js +12 -0
- package/dist/observability.d.ts +3 -0
- package/dist/observability.js +5 -0
- package/dist/offset-pages-zghoClB3.js +55 -0
- package/dist/operations-BBmT9ToP.js +663 -0
- package/dist/operations-WxRJWeqO.js +3133 -0
- package/dist/output-files-Ba8bu5lv.js +196 -0
- package/dist/page-operation-DrWuhd6Y.js +129 -0
- package/dist/page-twins.d.ts +13 -0
- package/dist/page-twins.js +186 -0
- package/dist/pageControlSpecs-DZJ9K37m.js +134 -0
- package/dist/pageControlsBridge-0pX9s-3k.js +54 -0
- package/dist/pageControlsBridge-DAuT3w7L.d.ts +36 -0
- package/dist/panels-PfBBAToE.js +346 -0
- package/dist/parts-B7fBcw-B.js +346 -0
- package/dist/popover-Dms9Vz3j.js +3389 -0
- package/dist/preloadable-lazy-Pp47mqQ9.js +65 -0
- package/dist/proactive.d.ts +66 -0
- package/dist/proactive.js +237 -0
- package/dist/quick-config-panel-DFd77xho.js +451 -0
- package/dist/quota-DeA_CJ2e.js +175 -0
- package/dist/quota.d.ts +3 -0
- package/dist/quota.js +4 -0
- package/dist/read-only-context-Dt9N9SIG.js +18 -0
- package/dist/relative-time-Dxt8ZIIu.js +55 -0
- package/dist/results-CwK_yDxK.js +325 -0
- package/dist/rolldown-runtime-hDbaFkMy.js +18 -0
- package/dist/route-data.d.ts +12 -0
- package/dist/route-data.js +69 -0
- package/dist/route-match-C-0_EnAt.d.ts +5 -0
- package/dist/route-match-DMkUICYV.js +41 -0
- package/dist/route-preload-C4DlGoCd.js +120 -0
- package/dist/run-display-UjLAoYqQ.js +81 -0
- package/dist/run-history-arGiHzGU.js +285 -0
- package/dist/run-list-links-DJn4Mf1T.js +98 -0
- package/dist/run-mode-USmM0-Uo.js +82 -0
- package/dist/run-parity-CWXqEJqM.js +144 -0
- package/dist/runsQuota-B6SyTbne.js +100 -0
- package/dist/runsQuota-DsniKiSg.d.ts +20 -0
- package/dist/safe-expression-Cw7-SCsm.js +1251 -0
- package/dist/save-status-store-C7nEYpfb.js +631 -0
- package/dist/schedule-panel-B4GYXzXQ.js +13774 -0
- package/dist/schedule-rules-ggVKRkBH.js +358 -0
- package/dist/secrets-Re_wSiE3.js +153 -0
- package/dist/settings.d.ts +4 -0
- package/dist/settings.js +6 -0
- package/dist/shared-DAWGGMSM.js +177 -0
- package/dist/sidebar-node-editor-6eSSgCzc.js +178 -0
- package/dist/solar.generated-CGYuUQAC.js +10 -0
- package/dist/stableTabbedDialog-BBhrfXGe.js +20 -0
- package/dist/start-url-CT6Yz96K.js +24 -0
- package/dist/status-CessxGpm.js +55 -0
- package/dist/store-icon-OctYp5zP.js +155 -0
- package/dist/styles-WGmTnZ2n.js +26 -0
- package/dist/styles.css +139 -0
- package/dist/svg-spinners.generated-CIPT7IhM.js +10 -0
- package/dist/template-code-CzN6JWNV.js +191 -0
- package/dist/template-graph-DLF9dygU.js +20 -0
- package/dist/template-preview-DcIIKOOL.js +32 -0
- package/dist/template-price-CdUHZRMF.js +40 -0
- package/dist/templates.d.ts +3 -0
- package/dist/templates.js +5 -0
- package/dist/theme-provider-CntfC4_i.js +23 -0
- package/dist/transient-DgZfhDfN.js +57 -0
- package/dist/typed-calls-C5tO03wq.js +26 -0
- package/dist/ui-script-By74Guk3.js +1094 -0
- package/dist/ui-script-editor-CqPu2bCN.js +2447 -0
- package/dist/ui-step-fix-8uM2_Hft.js +67 -0
- package/dist/ui-step-fix-store-CcO1FdRx.js +19 -0
- package/dist/ui-step-run-context-o7bLE6KP.js +46 -0
- package/dist/ui-target-editor-D2JhB_lD.js +673 -0
- package/dist/uiMarkTools-CSznnO1i.js +1054 -0
- package/dist/upgradePrompt-BAFBKKW5.js +72 -0
- package/dist/use-bare-node-registry-O6mKJO_n.js +11498 -0
- package/dist/use-browser-available-hj8wc3Kb.js +241 -0
- package/dist/use-edge-mapper-schemas-Bonofxow.js +496 -0
- package/dist/use-extension-bridge-B9ZreOkQ.js +608 -0
- package/dist/use-mobile-BTqCUjzS.js +27 -0
- package/dist/use-sdk-query-C697xZVv.js +116 -0
- package/dist/use-workflow-code-editor-CFoRFrZ5.js +753 -0
- package/dist/useActionParam-B2tU2BlY.js +85 -0
- package/dist/useAgentTokenStream-Bko_J0d0.js +4217 -0
- package/dist/useBrowserClients-3v95-gSh.js +103 -0
- package/dist/useCodeWorkflowInsights-w0tz9Ap_.js +600 -0
- package/dist/useConnections-DsgEJs05.js +439 -0
- package/dist/useDebouncedValue-BFekcv6n.js +18 -0
- package/dist/useDurableParity-8fnMZmBc.js +1787 -0
- package/dist/useEntityTags-D0spL6Ut.js +460 -0
- package/dist/useExecutions-2u5nGJJk.js +681 -0
- package/dist/useFluidGridsAnalytics-VM8lAi2x.js +238 -0
- package/dist/useGlobalStoreClient-BTdhkA2I.js +24 -0
- package/dist/useHumanRequests-zlYDp3l1.js +221 -0
- package/dist/useNavigationV2-C2WeqN7d.js +29 -0
- package/dist/useNavigationV2-DANUmg12.d.ts +9 -0
- package/dist/useObservability-BRlQ0tOA.js +285 -0
- package/dist/useRequestedProposal-B7uPXfZB.js +51 -0
- package/dist/useRunHistory-CXCMUPyf.js +2759 -0
- package/dist/useRunLive-D0JvVZT2.js +1060 -0
- package/dist/useRunnerList-Dbi59i1K.js +446 -0
- package/dist/useRunners-URUc5quU.js +173 -0
- package/dist/useRunsPage-DG656UCK.js +2709 -0
- package/dist/useVariables-BIelxcWr.js +463 -0
- package/dist/useVersionHistoryData-CTjqVw7l.js +292 -0
- package/dist/useWorkflowCodeExport-pqxyLHD1.js +522 -0
- package/dist/useWorkflowListExport-hcZNvTaB.js +232 -0
- package/dist/useWorkflowOrganization-CpBbOrs7.js +1772 -0
- package/dist/useWorkflowProposal-BH0VdNMA.js +3280 -0
- package/dist/useWorkflows-Cvg-Z_IE.js +1606 -0
- package/dist/utils-fvBb5qOD.js +89 -0
- package/dist/webhook-deliveries-AvQujaZy.js +99 -0
- package/dist/workflow-builder-CJygVkVv.d.ts +2 -0
- package/dist/workflow-builder.d.ts +3 -0
- package/dist/workflow-builder.js +8 -0
- package/dist/workflow-code-transfer-Bsy0JKAZ.js +323 -0
- package/dist/workflow-embed.d.ts +3 -0
- package/dist/workflow-embed.js +4 -0
- package/dist/workflow-git-sync--K9ZsPDC.js +263 -0
- package/dist/workflow-host.d.ts +6 -0
- package/dist/workflow-host.js +11 -0
- package/dist/workflow-pages-D-7ByLTB.d.ts +68 -0
- package/dist/workflow-pages.d.ts +3 -0
- package/dist/workflow-pages.js +115 -0
- package/dist/workflow-preview-canvas-CO8yzdE3.js +848 -0
- package/dist/workflow-preview.d.ts +65 -0
- package/dist/workflow-preview.js +4 -0
- package/dist/workflow-route.d.ts +33 -0
- package/dist/workflow-route.js +4 -0
- package/dist/workflow-save-state-D0l-DkLf.js +767 -0
- package/dist/workflow-transfer-CQnQC-ke.js +104 -0
- package/dist/workflowRouteData-BkfVOc-O.js +169 -0
- package/dist/workflows-list.d.ts +10 -0
- package/dist/workflows-list.js +5 -0
- package/package.json +320 -4
|
@@ -0,0 +1,1611 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as __exportAll } from "./rolldown-runtime-hDbaFkMy.js";
|
|
3
|
+
import { t as Icon } from "./Icon-BtQ0HXLh.js";
|
|
4
|
+
import { c as useWorkflowReloadStore, s as releaseLeaseKeptForReload, t as FlowBuilderPage } from "./flow-builder-DIvLOhz0.js";
|
|
5
|
+
import { n as registerLiveCanvasHandler } from "./liveCanvas-D5ytXDp8.js";
|
|
6
|
+
import { r as getFluidGridsConfig } from "./config-DO68jw5k.js";
|
|
7
|
+
import { n as getFluidGridsClient } from "./client-holder-C0M5Cfwl.js";
|
|
8
|
+
import { s as throwIfResultError } from "./errors-ClKb5sEt.js";
|
|
9
|
+
import { t as WorkflowDefinitionDocument } from "./WorkflowDefinitionDocument-DZLbTPUZ.js";
|
|
10
|
+
import { r as useTr } from "./TranslationBridge-Da-TPgQm.js";
|
|
11
|
+
import { O as createConfiguredNode, V as paramsFromOperation, _ as refetchStoreNodes, f as getNodeConfig, gn as resolveNodeOperation, l as ensureNodeTypesLoaded, rn as rememberRevision, v as registerNodeManifests, y as registerWorkflowNodeTypes } from "./use-bare-node-registry-O6mKJO_n.js";
|
|
12
|
+
import { U as useFlowStore } from "./node-operation-selection-CdV3KI_V.js";
|
|
13
|
+
import { r as useSaveStatusStore } from "./save-status-store-C7nEYpfb.js";
|
|
14
|
+
import { a as codeBuildIdOf, y as workflowFingerprint } from "./workflow-save-state-D0l-DkLf.js";
|
|
15
|
+
import { t as canvasFromDefinition } from "./definition-canvas-Bsda-rDT.js";
|
|
16
|
+
import { r as useCreateWorkflow, u as useLazyWorkflowDefinition } from "./useWorkflows-Cvg-Z_IE.js";
|
|
17
|
+
import { S as useInstalledNodes, d as buildRequiredNodeTypes, f as getWorkflowNodeTypes, u as buildNodeCheck } from "./StoreTemplateCardCompact-CHn5kP7A.js";
|
|
18
|
+
import { o as mergeStickyNotes } from "./field-label-DPZRmE_B.js";
|
|
19
|
+
import { i as noteBuilderLoadAbandoned, s as noteWorkflowApplied, t as cancelPendingBuilderLoad } from "./builderTimings-pvGnK1m-.js";
|
|
20
|
+
import { c as withoutGuidedTourIntent, l as decideMissingWorkflow, o as isGuidedTourIntent, s as pickGuidedTour, u as isCreateIntent } from "./firstWorkflow-C_h0KMB2.js";
|
|
21
|
+
import { n as BILLING_PLANS_PATH } from "./quota-DeA_CJ2e.js";
|
|
22
|
+
import { i as CreateWorkflowRefusalDialog } from "./useWorkflowCodeExport-pqxyLHD1.js";
|
|
23
|
+
import { r as classifyCreateRefusal, t as blankWorkflowCreateInput } from "./create-workflow-first-Azg3JUdX.js";
|
|
24
|
+
import { Suspense, lazy, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
25
|
+
import { useLocation, useNavigate, useParams } from "react-router";
|
|
26
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
27
|
+
import "@xyflow/react/dist/style.css";
|
|
28
|
+
import { toast } from "sonner";
|
|
29
|
+
import { CompactMarkOr, EmptyState } from "@burdenoff/fe-libs/ui";
|
|
30
|
+
import { ErrorBoundary } from "@burdenoff/fe-libs/shared/components";
|
|
31
|
+
import { usePlayTour, useSafeToursContext } from "@burdenoff/fe-libs/shared/tours";
|
|
32
|
+
|
|
33
|
+
// src/builder/live/canvas-base.ts
|
|
34
|
+
let base = null;
|
|
35
|
+
/** The base for the open workflow, or `null` when none was recorded for it. */
|
|
36
|
+
function currentCanvasBase() {
|
|
37
|
+
const flow = useFlowStore.getState();
|
|
38
|
+
if (!base || base.generation !== flow.loadGeneration || base.dbId !== flow.workflow.dbId) return null;
|
|
39
|
+
return base;
|
|
40
|
+
}
|
|
41
|
+
function setCanvasBase(next) {
|
|
42
|
+
base = next;
|
|
43
|
+
}
|
|
44
|
+
function snapshotOf(state) {
|
|
45
|
+
const { workflow } = state;
|
|
46
|
+
return {
|
|
47
|
+
generation: state.loadGeneration,
|
|
48
|
+
dbId: workflow.dbId,
|
|
49
|
+
nodes: workflow.nodes,
|
|
50
|
+
edges: workflow.edges,
|
|
51
|
+
name: workflow.name ?? "",
|
|
52
|
+
alias: workflow.alias ?? ""
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Record the hydrated canvas as the base when the open workflow has none yet
|
|
57
|
+
* (the load just put it in the store). Never replaces an existing base.
|
|
58
|
+
*/
|
|
59
|
+
function captureHydratedCanvasBase() {
|
|
60
|
+
const flow = useFlowStore.getState();
|
|
61
|
+
if (!flow.workflow.dbId || currentCanvasBase()) return false;
|
|
62
|
+
base = snapshotOf(flow);
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
/** Copy the canvas as the base if it matches the save baseline now. */
|
|
66
|
+
function captureCanvasBaseIfInSync() {
|
|
67
|
+
const flow = useFlowStore.getState();
|
|
68
|
+
const { baseline } = useSaveStatusStore.getState();
|
|
69
|
+
if (!baseline || baseline.generation !== flow.loadGeneration) return false;
|
|
70
|
+
if (workflowFingerprint(flow.workflow) !== baseline.fingerprint) return false;
|
|
71
|
+
base = snapshotOf(flow);
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Record the hydrated canvas and follow the save baseline until the returned
|
|
76
|
+
* function is called. A load of another workflow forgets the base at once and
|
|
77
|
+
* records the next hydrated one.
|
|
78
|
+
*
|
|
79
|
+
* The builder page mounts its watcher in the same commit as the canvas, whose
|
|
80
|
+
* hydration runs in a layout effect, i.e. before this subscribes: so the
|
|
81
|
+
* canvas already in the store is the hydrated one.
|
|
82
|
+
*/
|
|
83
|
+
function watchCanvasBase() {
|
|
84
|
+
if (!captureCanvasBaseIfInSync()) captureHydratedCanvasBase();
|
|
85
|
+
const unsubscribeStatus = useSaveStatusStore.subscribe((state, previous) => {
|
|
86
|
+
if (state.baseline !== previous.baseline) captureCanvasBaseIfInSync();
|
|
87
|
+
});
|
|
88
|
+
const unsubscribeFlow = useFlowStore.subscribe((state, previous) => {
|
|
89
|
+
if (state.loadGeneration !== previous.loadGeneration) base = null;
|
|
90
|
+
if (state.workflow.dbId && state.workflow !== previous.workflow) captureHydratedCanvasBase();
|
|
91
|
+
});
|
|
92
|
+
return () => {
|
|
93
|
+
unsubscribeStatus();
|
|
94
|
+
unsubscribeFlow();
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// src/builder/live/assistant-writes.ts
|
|
99
|
+
/**
|
|
100
|
+
* Writes that change the stored version named by their `id` argument:
|
|
101
|
+
* `updateWorkflowDefinition` replaces the whole definition, the pin mutations
|
|
102
|
+
* change pinned output data, and (de)activation changes the status (which
|
|
103
|
+
* decides whether the builder may autosave).
|
|
104
|
+
*/
|
|
105
|
+
const IN_PLACE = /* @__PURE__ */ new Set([
|
|
106
|
+
"updateWorkflowDefinition",
|
|
107
|
+
"pinNodeData",
|
|
108
|
+
"unpinNodeData",
|
|
109
|
+
"activateWorkflowDefinition",
|
|
110
|
+
"deactivateWorkflowDefinition"
|
|
111
|
+
]);
|
|
112
|
+
/** `createWorkflowVersion` / `restoreWorkflowVersion`: `{ success, workflow }`. */
|
|
113
|
+
const VERSION_RESPONSE = /* @__PURE__ */ new Set(["createWorkflowVersion", "restoreWorkflowVersion"]);
|
|
114
|
+
function isRecord$1(value) {
|
|
115
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
116
|
+
}
|
|
117
|
+
function text(value) {
|
|
118
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The response object of one root field. The preview may be the whole GraphQL
|
|
122
|
+
* envelope (`{ data: { … } }`), its `data`, or a JSON string of either.
|
|
123
|
+
*/
|
|
124
|
+
function rootFieldResult(result, responseKey, operation) {
|
|
125
|
+
let value = result;
|
|
126
|
+
if (typeof value === "string") try {
|
|
127
|
+
value = JSON.parse(value);
|
|
128
|
+
} catch {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
if (!isRecord$1(value)) return null;
|
|
132
|
+
if (Array.isArray(value.errors) && value.errors.length > 0) return null;
|
|
133
|
+
const data = isRecord$1(value.data) ? value.data : value;
|
|
134
|
+
const root = data[responseKey] ?? data[operation];
|
|
135
|
+
return isRecord$1(root) ? root : null;
|
|
136
|
+
}
|
|
137
|
+
function classifyWorkflowWrite(action) {
|
|
138
|
+
const { operation, responseKey } = action;
|
|
139
|
+
const args = action.arguments ?? {};
|
|
140
|
+
const root = rootFieldResult(action.result, responseKey, operation);
|
|
141
|
+
if (IN_PLACE.has(operation)) {
|
|
142
|
+
const dbId = text(args.id) ?? text(root?.id);
|
|
143
|
+
return dbId ? {
|
|
144
|
+
kind: "in-place",
|
|
145
|
+
dbId
|
|
146
|
+
} : null;
|
|
147
|
+
}
|
|
148
|
+
if (VERSION_RESPONSE.has(operation)) {
|
|
149
|
+
if (root?.success === false) return null;
|
|
150
|
+
const workflow = isRecord$1(root?.workflow) ? root.workflow : null;
|
|
151
|
+
const workflowKey = text(args.workflowKey) ?? text(workflow?.workflowKey);
|
|
152
|
+
if (!workflowKey) return null;
|
|
153
|
+
return {
|
|
154
|
+
kind: "new-version",
|
|
155
|
+
workflowKey,
|
|
156
|
+
version: text(workflow?.version),
|
|
157
|
+
dbId: text(workflow?.id)
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (operation === "applyWorkflowProposal") {
|
|
161
|
+
const workflowKey = text(root?.appliedWorkflowKey);
|
|
162
|
+
if (!workflowKey) return null;
|
|
163
|
+
return {
|
|
164
|
+
kind: "new-version",
|
|
165
|
+
workflowKey,
|
|
166
|
+
version: text(root?.appliedVersion),
|
|
167
|
+
dbId: text(root?.appliedWorkflowId)
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// src/builder/live/graph-merge.ts
|
|
174
|
+
/**
|
|
175
|
+
* Fields React Flow or the canvas writes by itself. Same set autosave ignores
|
|
176
|
+
* (`workflow-save-state.ts`), so "the person changed this node" means the same
|
|
177
|
+
* thing here as "the workflow has unsaved changes" means there.
|
|
178
|
+
*/
|
|
179
|
+
const VOLATILE_NODE_KEYS = /* @__PURE__ */ new Set([
|
|
180
|
+
"selected",
|
|
181
|
+
"dragging",
|
|
182
|
+
"resizing",
|
|
183
|
+
"measured",
|
|
184
|
+
"positionAbsolute"
|
|
185
|
+
]);
|
|
186
|
+
const VOLATILE_EDGE_KEYS = /* @__PURE__ */ new Set(["selected"]);
|
|
187
|
+
/** Root keys of a node that are its own, never a copy of `data`. */
|
|
188
|
+
const NODE_STRUCTURE_KEYS = /* @__PURE__ */ new Set([
|
|
189
|
+
"id",
|
|
190
|
+
"type",
|
|
191
|
+
"position",
|
|
192
|
+
"data"
|
|
193
|
+
]);
|
|
194
|
+
/**
|
|
195
|
+
* Canvas state carried from the local item when the remote version replaces
|
|
196
|
+
* it, so a replaced node stays selected and does not flash while re-measured.
|
|
197
|
+
*/
|
|
198
|
+
const CARRIED_NODE_KEYS = ["selected", "measured"];
|
|
199
|
+
const CARRIED_EDGE_KEYS = ["selected"];
|
|
200
|
+
function isRecord(value) {
|
|
201
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
202
|
+
}
|
|
203
|
+
/** JSON with object keys sorted, so key order never makes two items differ. */
|
|
204
|
+
function stableStringify(value) {
|
|
205
|
+
return JSON.stringify(value, (_key, inner) => {
|
|
206
|
+
if (isRecord(inner)) return Object.fromEntries(Object.entries(inner).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
|
|
207
|
+
return inner;
|
|
208
|
+
}) ?? "";
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* The part of a node that says what it does, in one comparable form.
|
|
212
|
+
*
|
|
213
|
+
* A save stores a node with its `data` settings copied onto the root (the
|
|
214
|
+
* worker reads them there) and `data.nodeData` slimmed to one operation
|
|
215
|
+
* (`use-save-workflow.ts`); the canvas keeps them under `data` only, with the
|
|
216
|
+
* stale root copies left over from the load. Comparing raw objects would make
|
|
217
|
+
* every saved node differ from its canvas self, so the root copies and the
|
|
218
|
+
* `nodeData` manifest (a node's schema, not its settings) are left out.
|
|
219
|
+
*/
|
|
220
|
+
function canonicalNode(node) {
|
|
221
|
+
const entries = Object.entries(node);
|
|
222
|
+
const data = node.data;
|
|
223
|
+
const dataRecord = isRecord(data) ? data : null;
|
|
224
|
+
const kept = entries.filter(([key]) => {
|
|
225
|
+
if (VOLATILE_NODE_KEYS.has(key)) return false;
|
|
226
|
+
if (NODE_STRUCTURE_KEYS.has(key)) return true;
|
|
227
|
+
return !(dataRecord && key in dataRecord);
|
|
228
|
+
});
|
|
229
|
+
const projected = Object.fromEntries(kept);
|
|
230
|
+
if (dataRecord) projected.data = savedNodeSettings(dataRecord);
|
|
231
|
+
return stableStringify(projected);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* A node's `data` as a save persists it: `data.nodeData` (the node's manifest)
|
|
235
|
+
* slimmed to the operation the node is pinned to (`data.operation_name`), or
|
|
236
|
+
* dropped when no operation matches. Mirrors `slimNodeDataToCurrentOperation`
|
|
237
|
+
* in `hooks/use-save-workflow.ts`, which cannot be imported here (that module
|
|
238
|
+
* pulls in the router and the node registry).
|
|
239
|
+
*
|
|
240
|
+
* So a node fresh from the palette (full manifest) and the same node after a
|
|
241
|
+
* save (one operation) compare equal, while a change to the saved operation
|
|
242
|
+
* entry, or to any other `nodeData` field the save keeps, still counts.
|
|
243
|
+
*/
|
|
244
|
+
function savedNodeSettings(data) {
|
|
245
|
+
const nodeData = data.nodeData;
|
|
246
|
+
if (!isRecord(nodeData)) return data;
|
|
247
|
+
const opName = data.operation_name;
|
|
248
|
+
const rawOps = nodeData.operations;
|
|
249
|
+
const ops = Array.isArray(rawOps) ? rawOps : isRecord(rawOps) && Array.isArray(rawOps.operations) ? rawOps.operations : [];
|
|
250
|
+
const current = typeof opName === "string" && opName.length > 0 ? ops.find((op) => isRecord(op) && op.name === opName) : void 0;
|
|
251
|
+
if (!current) {
|
|
252
|
+
const { nodeData: _unsaved, ...rest } = data;
|
|
253
|
+
return rest;
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
...data,
|
|
257
|
+
nodeData: {
|
|
258
|
+
...nodeData,
|
|
259
|
+
operations: [current]
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/** An edge in one comparable form: everything but the selection flag. */
|
|
264
|
+
function canonicalEdge(edge) {
|
|
265
|
+
return stableStringify(Object.fromEntries(Object.entries(edge).filter(([key]) => !VOLATILE_EDGE_KEYS.has(key))));
|
|
266
|
+
}
|
|
267
|
+
function indexById(items) {
|
|
268
|
+
const map = /* @__PURE__ */ new Map();
|
|
269
|
+
for (const item of items) if (typeof item?.id === "string" && !map.has(item.id)) map.set(item.id, item);
|
|
270
|
+
return map;
|
|
271
|
+
}
|
|
272
|
+
function carry(from, onto, keys) {
|
|
273
|
+
const carried = {};
|
|
274
|
+
for (const key of keys) if (key in from) carried[key] = from[key];
|
|
275
|
+
return Object.keys(carried).length === 0 ? onto : {
|
|
276
|
+
...onto,
|
|
277
|
+
...carried
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function mergeItems(kind, base, local, remote, canonical, carriedKeys) {
|
|
281
|
+
const baseById = indexById(base);
|
|
282
|
+
const localById = indexById(local);
|
|
283
|
+
const remoteById = indexById(remote);
|
|
284
|
+
const counts = {
|
|
285
|
+
added: 0,
|
|
286
|
+
updated: 0,
|
|
287
|
+
removed: 0
|
|
288
|
+
};
|
|
289
|
+
const touched = [];
|
|
290
|
+
const conflicts = [];
|
|
291
|
+
const items = [];
|
|
292
|
+
let localEdits = false;
|
|
293
|
+
const conflict = (id, reason) => conflicts.push({
|
|
294
|
+
kind,
|
|
295
|
+
id,
|
|
296
|
+
reason
|
|
297
|
+
});
|
|
298
|
+
for (const [id, mine] of localById) {
|
|
299
|
+
const original = baseById.get(id);
|
|
300
|
+
const theirs = remoteById.get(id);
|
|
301
|
+
const mineKey = canonical(mine);
|
|
302
|
+
if (!original) {
|
|
303
|
+
localEdits = true;
|
|
304
|
+
if (theirs && canonical(theirs) !== mineKey) conflict(id, "both-changed");
|
|
305
|
+
items.push(mine);
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
const originalKey = canonical(original);
|
|
309
|
+
const localChanged = mineKey !== originalKey;
|
|
310
|
+
if (localChanged) localEdits = true;
|
|
311
|
+
if (!theirs) {
|
|
312
|
+
if (localChanged) {
|
|
313
|
+
conflict(id, "deleted-remotely");
|
|
314
|
+
items.push(mine);
|
|
315
|
+
} else counts.removed += 1;
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
const theirsKey = canonical(theirs);
|
|
319
|
+
if (theirsKey === originalKey || theirsKey === mineKey) items.push(mine);
|
|
320
|
+
else if (!localChanged) {
|
|
321
|
+
items.push(carry(mine, theirs, carriedKeys));
|
|
322
|
+
counts.updated += 1;
|
|
323
|
+
touched.push(id);
|
|
324
|
+
} else {
|
|
325
|
+
conflict(id, "both-changed");
|
|
326
|
+
items.push(mine);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
for (const [id, original] of baseById) {
|
|
330
|
+
if (localById.has(id)) continue;
|
|
331
|
+
localEdits = true;
|
|
332
|
+
const theirs = remoteById.get(id);
|
|
333
|
+
if (theirs && canonical(theirs) !== canonical(original)) conflict(id, "deleted-locally");
|
|
334
|
+
}
|
|
335
|
+
for (const [id, theirs] of remoteById) {
|
|
336
|
+
if (localById.has(id) || baseById.has(id)) continue;
|
|
337
|
+
items.push(theirs);
|
|
338
|
+
counts.added += 1;
|
|
339
|
+
touched.push(id);
|
|
340
|
+
}
|
|
341
|
+
return {
|
|
342
|
+
items,
|
|
343
|
+
counts,
|
|
344
|
+
touched,
|
|
345
|
+
conflicts,
|
|
346
|
+
localEdits
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* With no base, nothing says which side changed an item: every difference
|
|
351
|
+
* between the canvas and the remote keeps the canvas and is reported, and
|
|
352
|
+
* nothing of the remote's is taken.
|
|
353
|
+
*/
|
|
354
|
+
function mergeItemsWithoutBase(kind, local, remote, canonical) {
|
|
355
|
+
const localById = indexById(local);
|
|
356
|
+
const remoteById = indexById(remote);
|
|
357
|
+
const conflicts = [];
|
|
358
|
+
for (const [id, mine] of localById) {
|
|
359
|
+
const theirs = remoteById.get(id);
|
|
360
|
+
if (!theirs || canonical(theirs) !== canonical(mine)) conflicts.push({
|
|
361
|
+
kind,
|
|
362
|
+
id,
|
|
363
|
+
reason: "no-base"
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
for (const id of remoteById.keys()) if (!localById.has(id)) conflicts.push({
|
|
367
|
+
kind,
|
|
368
|
+
id,
|
|
369
|
+
reason: "no-base"
|
|
370
|
+
});
|
|
371
|
+
return {
|
|
372
|
+
items: [...localById.values()],
|
|
373
|
+
counts: {
|
|
374
|
+
added: 0,
|
|
375
|
+
updated: 0,
|
|
376
|
+
removed: 0
|
|
377
|
+
},
|
|
378
|
+
touched: [],
|
|
379
|
+
conflicts,
|
|
380
|
+
localEdits: true
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Merge the assistant's version of the workflow into the canvas.
|
|
385
|
+
*
|
|
386
|
+
* After the node merge, an edge whose source or target no longer exists is
|
|
387
|
+
* dropped (React Flow cannot draw it and a save would store it dangling); one
|
|
388
|
+
* that was on the canvas counts as removed.
|
|
389
|
+
*/
|
|
390
|
+
function mergeWorkflowGraph(base, local, remote) {
|
|
391
|
+
const nodes = base ? mergeItems("node", base.nodes, local.nodes, remote.nodes, canonicalNode, CARRIED_NODE_KEYS) : mergeItemsWithoutBase("node", local.nodes, remote.nodes, canonicalNode);
|
|
392
|
+
const edges = base ? mergeItems("edge", base.edges, local.edges, remote.edges, canonicalEdge, CARRIED_EDGE_KEYS) : mergeItemsWithoutBase("edge", local.edges, remote.edges, canonicalEdge);
|
|
393
|
+
const nodeIds = new Set(nodes.items.map((node) => node.id));
|
|
394
|
+
const localEdgeIds = new Set(local.edges.map((edge) => edge.id));
|
|
395
|
+
const remoteTouched = new Set(edges.touched);
|
|
396
|
+
let detached = 0;
|
|
397
|
+
const keptEdges = edges.items.filter((edge) => {
|
|
398
|
+
const { source, target } = edge;
|
|
399
|
+
if ((typeof source !== "string" || nodeIds.has(source)) && (typeof target !== "string" || nodeIds.has(target))) return true;
|
|
400
|
+
if (!localEdgeIds.has(edge.id)) {
|
|
401
|
+
edges.counts.added -= 1;
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
if (remoteTouched.has(edge.id)) edges.counts.updated -= 1;
|
|
405
|
+
edges.conflicts.push({
|
|
406
|
+
kind: "edge",
|
|
407
|
+
id: edge.id,
|
|
408
|
+
reason: "detached"
|
|
409
|
+
});
|
|
410
|
+
detached += 1;
|
|
411
|
+
return false;
|
|
412
|
+
});
|
|
413
|
+
const total = (c) => c.added + c.updated + c.removed;
|
|
414
|
+
return {
|
|
415
|
+
nodes: nodes.items,
|
|
416
|
+
edges: keptEdges,
|
|
417
|
+
counts: {
|
|
418
|
+
nodes: nodes.counts,
|
|
419
|
+
edges: edges.counts
|
|
420
|
+
},
|
|
421
|
+
touchedNodeIds: nodes.touched,
|
|
422
|
+
conflicts: [...nodes.conflicts, ...edges.conflicts],
|
|
423
|
+
changed: total(nodes.counts) + total(edges.counts) + detached > 0,
|
|
424
|
+
localEdits: nodes.localEdits || edges.localEdits
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Merge one scalar (the workflow's name or alias) the same way: the person's
|
|
429
|
+
* change wins, otherwise the assistant's value is taken.
|
|
430
|
+
*/
|
|
431
|
+
function mergeScalar(base, local, remote) {
|
|
432
|
+
if (local === base) return {
|
|
433
|
+
value: remote,
|
|
434
|
+
conflict: false
|
|
435
|
+
};
|
|
436
|
+
return {
|
|
437
|
+
value: local,
|
|
438
|
+
conflict: remote !== base && remote !== local
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// src/builder/live/live-canvas-sync.ts
|
|
443
|
+
/** The history kind of a sync: undo groups it as one step. */
|
|
444
|
+
const ASSISTANT_SYNC_HISTORY_KIND = "assistant:sync";
|
|
445
|
+
/**
|
|
446
|
+
* Right after a sync onto a canvas with no edits of its own, the cards of new
|
|
447
|
+
* nodes settle (measured sizes, normalised operations) as after a load. Same
|
|
448
|
+
* window autosave gives a load (`use-builder-autosave.ts`).
|
|
449
|
+
*/
|
|
450
|
+
const SETTLE_MS = 1500;
|
|
451
|
+
/** How many action ids are remembered, so a replayed result is not re-applied. */
|
|
452
|
+
const SEEN_LIMIT = 200;
|
|
453
|
+
function createLiveCanvasSync(deps) {
|
|
454
|
+
const now = deps.now ?? Date.now;
|
|
455
|
+
const seen = /* @__PURE__ */ new Set();
|
|
456
|
+
let running = null;
|
|
457
|
+
let queued = false;
|
|
458
|
+
const remember = (id) => {
|
|
459
|
+
if (seen.has(id)) return false;
|
|
460
|
+
seen.add(id);
|
|
461
|
+
if (seen.size > SEEN_LIMIT) {
|
|
462
|
+
const oldest = seen.values().next().value;
|
|
463
|
+
if (oldest !== void 0) seen.delete(oldest);
|
|
464
|
+
}
|
|
465
|
+
return true;
|
|
466
|
+
};
|
|
467
|
+
async function syncOnce() {
|
|
468
|
+
const flow = useFlowStore.getState();
|
|
469
|
+
const dbId = flow.workflow.dbId;
|
|
470
|
+
if (!dbId) return;
|
|
471
|
+
const generation = flow.loadGeneration;
|
|
472
|
+
let remote;
|
|
473
|
+
try {
|
|
474
|
+
remote = await deps.fetchDefinition(dbId);
|
|
475
|
+
} catch {
|
|
476
|
+
remote = null;
|
|
477
|
+
}
|
|
478
|
+
const after = useFlowStore.getState();
|
|
479
|
+
if (after.loadGeneration !== generation || after.workflow.dbId !== dbId) return;
|
|
480
|
+
const canvas = remote ? canvasFromDefinition(remote.definitionJson) : null;
|
|
481
|
+
if (!remote || !canvas) {
|
|
482
|
+
deps.notify({ kind: "failed" });
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
applyRemote(remote, canvas);
|
|
486
|
+
}
|
|
487
|
+
function applyRemote(remote, canvas) {
|
|
488
|
+
const { workflow, actions } = useFlowStore.getState();
|
|
489
|
+
const localName = workflow.name ?? "";
|
|
490
|
+
const localAlias = workflow.alias ?? "";
|
|
491
|
+
const base = currentCanvasBase();
|
|
492
|
+
const merge = mergeWorkflowGraph(base, {
|
|
493
|
+
nodes: workflow.nodes,
|
|
494
|
+
edges: workflow.edges
|
|
495
|
+
}, canvas);
|
|
496
|
+
const remoteName = remote.name ?? localName;
|
|
497
|
+
const remoteAlias = remote.alias ?? "";
|
|
498
|
+
const name = base ? mergeScalar(base.name, localName, remoteName) : {
|
|
499
|
+
value: localName,
|
|
500
|
+
conflict: false
|
|
501
|
+
};
|
|
502
|
+
const alias = base ? mergeScalar(base.alias, localAlias, remoteAlias) : {
|
|
503
|
+
value: localAlias,
|
|
504
|
+
conflict: false
|
|
505
|
+
};
|
|
506
|
+
const localEdits = !base || merge.localEdits || localName !== base.name || localAlias !== base.alias;
|
|
507
|
+
if (merge.changed) {
|
|
508
|
+
deps.registerNodeTypes(merge.nodes);
|
|
509
|
+
actions.nodes.setNodes(merge.nodes, { historyKind: ASSISTANT_SYNC_HISTORY_KIND });
|
|
510
|
+
actions.edges.setEdges(merge.edges, { skipHistory: true });
|
|
511
|
+
}
|
|
512
|
+
const patch = {};
|
|
513
|
+
if (name.value !== localName) patch.name = name.value;
|
|
514
|
+
if (alias.value !== localAlias) patch.alias = alias.value;
|
|
515
|
+
if (remote.status && remote.status !== workflow.status) patch.status = remote.status;
|
|
516
|
+
if (Object.keys(patch).length > 0) actions.setWorkflow(patch);
|
|
517
|
+
const synced = useFlowStore.getState();
|
|
518
|
+
setCanvasBase({
|
|
519
|
+
generation: synced.loadGeneration,
|
|
520
|
+
dbId: synced.workflow.dbId,
|
|
521
|
+
nodes: canvas.nodes,
|
|
522
|
+
edges: canvas.edges,
|
|
523
|
+
name: remoteName,
|
|
524
|
+
alias: remoteAlias
|
|
525
|
+
});
|
|
526
|
+
const status = useSaveStatusStore.getState();
|
|
527
|
+
if ((merge.changed || Object.keys(patch).length > 0) && !localEdits && status.baseline && status.baseline.generation === synced.loadGeneration) status.actions.setBaseline({
|
|
528
|
+
fingerprint: workflowFingerprint(synced.workflow),
|
|
529
|
+
generation: synced.loadGeneration,
|
|
530
|
+
settleUntil: now() + SETTLE_MS,
|
|
531
|
+
editRevision: synced.editRevision
|
|
532
|
+
});
|
|
533
|
+
deps.onSynced?.(remote);
|
|
534
|
+
const renamed = patch.name !== void 0 || patch.alias !== void 0;
|
|
535
|
+
if (merge.changed || merge.conflicts.length > 0 || renamed) deps.notify({
|
|
536
|
+
kind: "applied",
|
|
537
|
+
merge,
|
|
538
|
+
renamed
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
function scheduleSync() {
|
|
542
|
+
if (running) {
|
|
543
|
+
queued = true;
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
running = (async () => {
|
|
547
|
+
try {
|
|
548
|
+
do {
|
|
549
|
+
queued = false;
|
|
550
|
+
await syncOnce();
|
|
551
|
+
} while (queued);
|
|
552
|
+
} catch (error) {
|
|
553
|
+
console.error("[FluidGrids] assistant live canvas sync:", error);
|
|
554
|
+
} finally {
|
|
555
|
+
running = null;
|
|
556
|
+
}
|
|
557
|
+
})();
|
|
558
|
+
}
|
|
559
|
+
function handle(event) {
|
|
560
|
+
try {
|
|
561
|
+
const workspaceId = deps.workspaceId();
|
|
562
|
+
if (event.run.workspaceId && workspaceId && event.run.workspaceId !== workspaceId) return;
|
|
563
|
+
const write = classifyWorkflowWrite(event.action);
|
|
564
|
+
if (!write) return;
|
|
565
|
+
const { workflow } = useFlowStore.getState();
|
|
566
|
+
if (!workflow.dbId) return;
|
|
567
|
+
if (write.kind === "in-place") {
|
|
568
|
+
if (write.dbId !== workflow.dbId) return;
|
|
569
|
+
if (!remember(event.action.id)) return;
|
|
570
|
+
scheduleSync();
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
const openKey = workflow.workflowKey || workflow.id;
|
|
574
|
+
if (write.workflowKey !== openKey) return;
|
|
575
|
+
if (write.dbId === workflow.dbId) {
|
|
576
|
+
if (remember(event.action.id)) scheduleSync();
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
if (write.version !== null && write.version === workflow.version) return;
|
|
580
|
+
if (!remember(event.action.id)) return;
|
|
581
|
+
deps.notify({
|
|
582
|
+
kind: "new-version",
|
|
583
|
+
workflowKey: write.workflowKey,
|
|
584
|
+
version: write.version
|
|
585
|
+
});
|
|
586
|
+
} catch (error) {
|
|
587
|
+
console.error("[FluidGrids] assistant live canvas:", error);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
return {
|
|
591
|
+
handle,
|
|
592
|
+
idle: async () => {
|
|
593
|
+
while (running) await running;
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// src/builder/live/sync-notice.ts
|
|
599
|
+
const KEY = "fluidgrids.builder.assistantSync";
|
|
600
|
+
const NODE_PARTS = {
|
|
601
|
+
added: ["1 node added", "{{count}} nodes added"],
|
|
602
|
+
updated: ["1 node changed", "{{count}} nodes changed"],
|
|
603
|
+
removed: ["1 node removed", "{{count}} nodes removed"]
|
|
604
|
+
};
|
|
605
|
+
const EDGE_PARTS = {
|
|
606
|
+
added: ["1 connection added", "{{count}} connections added"],
|
|
607
|
+
updated: ["1 connection changed", "{{count}} connections changed"],
|
|
608
|
+
removed: ["1 connection removed", "{{count}} connections removed"]
|
|
609
|
+
};
|
|
610
|
+
function parts(tr, counts, kind) {
|
|
611
|
+
const words = kind === "nodes" ? NODE_PARTS : EDGE_PARTS;
|
|
612
|
+
return [
|
|
613
|
+
"added",
|
|
614
|
+
"updated",
|
|
615
|
+
"removed"
|
|
616
|
+
].filter((part) => counts[part] > 0).map((part) => {
|
|
617
|
+
const count = counts[part];
|
|
618
|
+
const [one, other] = words[part];
|
|
619
|
+
return count === 1 ? tr(`${KEY}.${kind}.${part}.one`, one) : tr(`${KEY}.${kind}.${part}.other`, other, { count });
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
function describeAppliedSync(tr, merge, renamed) {
|
|
623
|
+
const changes = [...parts(tr, merge.counts.nodes, "nodes"), ...parts(tr, merge.counts.edges, "edges")];
|
|
624
|
+
if (renamed) changes.push(tr(`${KEY}.renamed`, "name changed"));
|
|
625
|
+
const nodeConflicts = merge.conflicts.filter((c) => c.kind === "node").length;
|
|
626
|
+
const edgeConflicts = merge.conflicts.length - nodeConflicts;
|
|
627
|
+
let conflicts = null;
|
|
628
|
+
if (nodeConflicts > 0 || edgeConflicts > 0) {
|
|
629
|
+
const what = [nodeConflicts === 1 ? tr(`${KEY}.conflicts.nodes.one`, "1 node") : nodeConflicts > 1 ? tr(`${KEY}.conflicts.nodes.other`, "{{count}} nodes", { count: nodeConflicts }) : null, edgeConflicts === 1 ? tr(`${KEY}.conflicts.edges.one`, "1 connection") : edgeConflicts > 1 ? tr(`${KEY}.conflicts.edges.other`, "{{count}} connections", { count: edgeConflicts }) : null].filter((item) => item !== null).join(tr(`${KEY}.and`, " and "));
|
|
630
|
+
conflicts = tr(`${KEY}.conflicts.summary`, "Kept your edits on {{what}} the assistant also changed", { what });
|
|
631
|
+
}
|
|
632
|
+
return {
|
|
633
|
+
title: tr(`${KEY}.title`, "Assistant updated this workflow"),
|
|
634
|
+
summary: changes.length > 0 ? changes.join(", ") : null,
|
|
635
|
+
conflicts
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
function describeNewVersion(tr, version) {
|
|
639
|
+
if (!version) return {
|
|
640
|
+
title: tr(`${KEY}.newVersion.unknown`, "The assistant saved a new version of this workflow"),
|
|
641
|
+
action: null
|
|
642
|
+
};
|
|
643
|
+
return {
|
|
644
|
+
title: tr(`${KEY}.newVersion.title`, "The assistant saved version {{version}} of this workflow", { version }),
|
|
645
|
+
action: tr(`${KEY}.newVersion.open`, "Open {{version}}", { version })
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
function describeFailedSync(tr) {
|
|
649
|
+
return tr(`${KEY}.failed`, "The assistant changed this workflow, but the canvas could not be refreshed. Reopen the workflow to see the change.");
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
// src/builder/live/assistant-live-canvas-host.tsx
|
|
653
|
+
/**
|
|
654
|
+
* Mounted by the builder page while a workflow is open (BOFF-9806): receives
|
|
655
|
+
* the assistant's approved writes from the host's live-canvas controller
|
|
656
|
+
* (`@fluidgrids/fe-sdk/assistant`) and brings them onto the canvas.
|
|
657
|
+
* Renders nothing; its notices are toasts.
|
|
658
|
+
*/
|
|
659
|
+
async function fetchDefinition(dbId) {
|
|
660
|
+
const { data } = throwIfResultError(await getFluidGridsClient().query({
|
|
661
|
+
query: WorkflowDefinitionDocument,
|
|
662
|
+
variables: { id: dbId },
|
|
663
|
+
fetchPolicy: "network-only"
|
|
664
|
+
}));
|
|
665
|
+
return data?.workflowDefinition ?? null;
|
|
666
|
+
}
|
|
667
|
+
function AssistantLiveCanvasHost() {
|
|
668
|
+
const tr = useTr();
|
|
669
|
+
const navigate = useNavigate();
|
|
670
|
+
const latest = useRef({
|
|
671
|
+
tr,
|
|
672
|
+
navigate
|
|
673
|
+
});
|
|
674
|
+
useEffect(() => {
|
|
675
|
+
latest.current = {
|
|
676
|
+
tr,
|
|
677
|
+
navigate
|
|
678
|
+
};
|
|
679
|
+
});
|
|
680
|
+
useEffect(() => {
|
|
681
|
+
const notify = (notice) => {
|
|
682
|
+
const { tr: t, navigate: go } = latest.current;
|
|
683
|
+
if (notice.kind === "failed") {
|
|
684
|
+
toast.error(describeFailedSync(t));
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
if (notice.kind === "new-version") {
|
|
688
|
+
const text = describeNewVersion(t, notice.version);
|
|
689
|
+
const { workflowKey, version } = notice;
|
|
690
|
+
toast.info(text.title, {
|
|
691
|
+
dismissible: true,
|
|
692
|
+
duration: 1e4,
|
|
693
|
+
...text.action && version ? { action: {
|
|
694
|
+
label: text.action,
|
|
695
|
+
onClick: () => go(`../workflow/${workflowKey}/${version}`)
|
|
696
|
+
} } : {}
|
|
697
|
+
});
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
const text = describeAppliedSync(t, notice.merge, notice.renamed);
|
|
701
|
+
const description = [text.summary, text.conflicts].filter((line) => line !== null).join(". ");
|
|
702
|
+
(text.conflicts ? toast.warning : toast.success)(text.title, {
|
|
703
|
+
dismissible: true,
|
|
704
|
+
...description ? { description } : {}
|
|
705
|
+
});
|
|
706
|
+
};
|
|
707
|
+
const sync = createLiveCanvasSync({
|
|
708
|
+
fetchDefinition,
|
|
709
|
+
registerNodeTypes: registerWorkflowNodeTypes,
|
|
710
|
+
notify,
|
|
711
|
+
workspaceId: () => getFluidGridsConfig().workspaceId || null,
|
|
712
|
+
onSynced: (remote) => rememberRevision(remote.id, remote.revision)
|
|
713
|
+
});
|
|
714
|
+
const stopWatching = watchCanvasBase();
|
|
715
|
+
const unregister = registerLiveCanvasHandler(sync.handle);
|
|
716
|
+
return () => {
|
|
717
|
+
unregister();
|
|
718
|
+
stopWatching();
|
|
719
|
+
};
|
|
720
|
+
}, []);
|
|
721
|
+
return null;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// src/builder/app/workflow/_components/load-problem.tsx
|
|
725
|
+
function LoadProblem({ kind, title, description, retryLabel, onRetry, backLabel, onBack, testId }) {
|
|
726
|
+
return /* @__PURE__ */ jsx("div", {
|
|
727
|
+
role: "alert",
|
|
728
|
+
"data-testid": testId,
|
|
729
|
+
className: "flex h-full min-h-[60vh] w-full flex-col items-center justify-center p-6",
|
|
730
|
+
children: /* @__PURE__ */ jsx(EmptyState, {
|
|
731
|
+
kind,
|
|
732
|
+
size: "page",
|
|
733
|
+
icon: null,
|
|
734
|
+
title,
|
|
735
|
+
description,
|
|
736
|
+
action: /* @__PURE__ */ jsx("button", {
|
|
737
|
+
type: "button",
|
|
738
|
+
className: "rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",
|
|
739
|
+
onClick: onRetry,
|
|
740
|
+
children: retryLabel
|
|
741
|
+
}),
|
|
742
|
+
secondaryAction: /* @__PURE__ */ jsx("button", {
|
|
743
|
+
type: "button",
|
|
744
|
+
className: "rounded-md border px-4 py-2 text-sm font-medium text-foreground",
|
|
745
|
+
onClick: onBack,
|
|
746
|
+
children: backLabel
|
|
747
|
+
})
|
|
748
|
+
})
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
// src/builder/lib/start-node-link.ts
|
|
753
|
+
/** Query parameter naming the node type to start the workflow with. */
|
|
754
|
+
const START_NODE_PARAM = "startNode";
|
|
755
|
+
/** Query parameter naming the operation, for a node with several. */
|
|
756
|
+
const START_OPERATION_PARAM = "startOperation";
|
|
757
|
+
/** Query parameter with the new workflow's name. */
|
|
758
|
+
const START_NAME_PARAM = "name";
|
|
759
|
+
/** Prefix of the query parameters that fill the start node's fields. */
|
|
760
|
+
const START_FIELD_PREFIX = "set.";
|
|
761
|
+
/** Longest workflow name a link may set. */
|
|
762
|
+
const MAX_START_NAME_LENGTH = 120;
|
|
763
|
+
/** Longest field value a link may set. */
|
|
764
|
+
const MAX_START_VALUE_LENGTH = 1e3;
|
|
765
|
+
/** Most fields one link may fill. */
|
|
766
|
+
const MAX_START_FIELDS = 20;
|
|
767
|
+
const NODE_TYPE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9:._/@-]{0,159}$/;
|
|
768
|
+
const FIELD_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
|
|
769
|
+
const OPERATION_PATTERN = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
|
|
770
|
+
const EXPRESSION_MARKERS = /\$\{|\{\{|^=/;
|
|
771
|
+
/** Field types a link may fill with plain text. */
|
|
772
|
+
const TEXT_FIELD_TYPES = /* @__PURE__ */ new Set([
|
|
773
|
+
"string",
|
|
774
|
+
"text",
|
|
775
|
+
"timezone",
|
|
776
|
+
"timecampus-time-trigger"
|
|
777
|
+
]);
|
|
778
|
+
const NUMBER_FIELD_TYPES = /* @__PURE__ */ new Set(["number", "integer"]);
|
|
779
|
+
const CHOICE_FIELD_TYPES = /* @__PURE__ */ new Set([
|
|
780
|
+
"string",
|
|
781
|
+
"enum",
|
|
782
|
+
"options",
|
|
783
|
+
"select",
|
|
784
|
+
"multiOptions"
|
|
785
|
+
]);
|
|
786
|
+
/** True when the text holds a C0 control character or DEL. */
|
|
787
|
+
function hasControlCharacter(value) {
|
|
788
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
789
|
+
const code = value.charCodeAt(index);
|
|
790
|
+
if (code < 32 || code === 127) return true;
|
|
791
|
+
}
|
|
792
|
+
return false;
|
|
793
|
+
}
|
|
794
|
+
function isPlainText(value, maxLength) {
|
|
795
|
+
return value.length > 0 && value.length <= maxLength && !hasControlCharacter(value) && !EXPRESSION_MARKERS.test(value);
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Read a start-node request from a URL query string. Returns null when the
|
|
799
|
+
* URL does not ask for one (or names a node type that cannot be valid).
|
|
800
|
+
*/
|
|
801
|
+
function readStartNodeRequest(search) {
|
|
802
|
+
const params = new URLSearchParams(search);
|
|
803
|
+
const nodeType = params.get("startNode")?.trim() ?? "";
|
|
804
|
+
if (!NODE_TYPE_PATTERN.test(nodeType)) return null;
|
|
805
|
+
const rejected = [];
|
|
806
|
+
const fields = Object.create(null);
|
|
807
|
+
let count = 0;
|
|
808
|
+
for (const [key, raw] of params) {
|
|
809
|
+
if (!key.startsWith("set.")) continue;
|
|
810
|
+
const field = key.slice(4);
|
|
811
|
+
if (!FIELD_NAME_PATTERN.test(field) || Object.hasOwn(fields, field)) {
|
|
812
|
+
rejected.push({
|
|
813
|
+
field: field.slice(0, 64),
|
|
814
|
+
reason: "unknown-field"
|
|
815
|
+
});
|
|
816
|
+
continue;
|
|
817
|
+
}
|
|
818
|
+
if (count >= 20) {
|
|
819
|
+
rejected.push({
|
|
820
|
+
field,
|
|
821
|
+
reason: "too-many"
|
|
822
|
+
});
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
fields[field] = raw.trim();
|
|
826
|
+
count += 1;
|
|
827
|
+
}
|
|
828
|
+
const operationRaw = params.get(START_OPERATION_PARAM)?.trim();
|
|
829
|
+
const operation = operationRaw && OPERATION_PATTERN.test(operationRaw) ? operationRaw : void 0;
|
|
830
|
+
const nameRaw = params.get(START_NAME_PARAM)?.trim();
|
|
831
|
+
let name;
|
|
832
|
+
if (nameRaw) {
|
|
833
|
+
if (isPlainText(nameRaw, 120)) name = nameRaw;
|
|
834
|
+
else rejected.push({
|
|
835
|
+
field: START_NAME_PARAM,
|
|
836
|
+
reason: "invalid-name"
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
return {
|
|
840
|
+
nodeType,
|
|
841
|
+
...operation ? { operation } : {},
|
|
842
|
+
...name ? { name } : {},
|
|
843
|
+
fields,
|
|
844
|
+
rejected
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Check one requested value against the manifest field it targets. Returns the
|
|
849
|
+
* value to store in the node's state, or the reason it was refused.
|
|
850
|
+
*/
|
|
851
|
+
function validateStartField(param, raw) {
|
|
852
|
+
if (!param) return {
|
|
853
|
+
ok: false,
|
|
854
|
+
reason: "unknown-field"
|
|
855
|
+
};
|
|
856
|
+
if (param.secret) return {
|
|
857
|
+
ok: false,
|
|
858
|
+
reason: "secret"
|
|
859
|
+
};
|
|
860
|
+
const options = param.options ?? [];
|
|
861
|
+
if (param.type === "multiOptions") {
|
|
862
|
+
if (options.length === 0) return {
|
|
863
|
+
ok: false,
|
|
864
|
+
reason: "unsupported-type"
|
|
865
|
+
};
|
|
866
|
+
const picked = raw.split(",").map((part) => part.trim()).filter((part) => part.length > 0);
|
|
867
|
+
if (picked.length === 0) return {
|
|
868
|
+
ok: false,
|
|
869
|
+
reason: "invalid-value"
|
|
870
|
+
};
|
|
871
|
+
const allowed = new Set(options);
|
|
872
|
+
if (picked.some((part) => !allowed.has(part))) return {
|
|
873
|
+
ok: false,
|
|
874
|
+
reason: "not-an-option"
|
|
875
|
+
};
|
|
876
|
+
const chosen = new Set(picked);
|
|
877
|
+
return {
|
|
878
|
+
ok: true,
|
|
879
|
+
value: options.filter((option) => chosen.has(option))
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
if (options.length > 0 && CHOICE_FIELD_TYPES.has(param.type)) return options.includes(raw) ? {
|
|
883
|
+
ok: true,
|
|
884
|
+
value: raw
|
|
885
|
+
} : {
|
|
886
|
+
ok: false,
|
|
887
|
+
reason: "not-an-option"
|
|
888
|
+
};
|
|
889
|
+
if (NUMBER_FIELD_TYPES.has(param.type)) {
|
|
890
|
+
if (!/^-?\d+(\.\d+)?$/.test(raw)) return {
|
|
891
|
+
ok: false,
|
|
892
|
+
reason: "invalid-value"
|
|
893
|
+
};
|
|
894
|
+
const value = Number(raw);
|
|
895
|
+
if (!Number.isFinite(value) || param.type === "integer" && !Number.isInteger(value)) return {
|
|
896
|
+
ok: false,
|
|
897
|
+
reason: "invalid-value"
|
|
898
|
+
};
|
|
899
|
+
return {
|
|
900
|
+
ok: true,
|
|
901
|
+
value
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
if (param.type === "boolean") {
|
|
905
|
+
if (raw === "true") return {
|
|
906
|
+
ok: true,
|
|
907
|
+
value: true
|
|
908
|
+
};
|
|
909
|
+
if (raw === "false") return {
|
|
910
|
+
ok: true,
|
|
911
|
+
value: false
|
|
912
|
+
};
|
|
913
|
+
return {
|
|
914
|
+
ok: false,
|
|
915
|
+
reason: "invalid-value"
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
if (TEXT_FIELD_TYPES.has(param.type)) return isPlainText(raw, 1e3) ? {
|
|
919
|
+
ok: true,
|
|
920
|
+
value: raw
|
|
921
|
+
} : {
|
|
922
|
+
ok: false,
|
|
923
|
+
reason: "invalid-value"
|
|
924
|
+
};
|
|
925
|
+
return {
|
|
926
|
+
ok: false,
|
|
927
|
+
reason: "unsupported-type"
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* Validate every requested field against the operation's parameters. Accepted
|
|
932
|
+
* values go into `state`; the rest are listed in `rejected`.
|
|
933
|
+
*/
|
|
934
|
+
function validateStartFields(params, fields) {
|
|
935
|
+
const byName = new Map(params.map((param) => [param.name, param]));
|
|
936
|
+
const state = {};
|
|
937
|
+
const rejected = [];
|
|
938
|
+
for (const [field, raw] of Object.entries(fields)) {
|
|
939
|
+
const result = validateStartField(byName.get(field), raw);
|
|
940
|
+
if (result.ok) state[field] = result.value;
|
|
941
|
+
else rejected.push({
|
|
942
|
+
field,
|
|
943
|
+
reason: result.reason
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
return {
|
|
947
|
+
state,
|
|
948
|
+
rejected
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
/** True for a query parameter that belongs to a start-node link. */
|
|
952
|
+
function isStartNodeParam(key) {
|
|
953
|
+
return key === "startNode" || key === "startOperation" || key === "name" || key.startsWith("set.");
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* A stable key for the start-node parameters of a query string ("" when it
|
|
957
|
+
* has none). The builder re-reads the link when this key changes, so a host
|
|
958
|
+
* that navigates from one start-node link to another without reloading the
|
|
959
|
+
* page still gets the new node, while unrelated query changes do not reset
|
|
960
|
+
* the canvas.
|
|
961
|
+
*/
|
|
962
|
+
function startNodeKey(search) {
|
|
963
|
+
const params = new URLSearchParams(search);
|
|
964
|
+
const kept = new URLSearchParams();
|
|
965
|
+
for (const [key, value] of params) if (isStartNodeParam(key)) kept.append(key, value);
|
|
966
|
+
return kept.toString();
|
|
967
|
+
}
|
|
968
|
+
/** The query string with every start-node parameter removed. */
|
|
969
|
+
function withoutStartNodeParams(search) {
|
|
970
|
+
const params = new URLSearchParams(search);
|
|
971
|
+
for (const key of [...params.keys()]) if (isStartNodeParam(key)) params.delete(key);
|
|
972
|
+
const rest = params.toString();
|
|
973
|
+
return rest ? `?${rest}` : "";
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* Build a start-node link. `basePath` is where the host mounts the workflows
|
|
977
|
+
* module (for example "/workflows").
|
|
978
|
+
*/
|
|
979
|
+
function startNodeLink(basePath, request) {
|
|
980
|
+
const params = new URLSearchParams();
|
|
981
|
+
params.set(START_NODE_PARAM, request.nodeType);
|
|
982
|
+
if (request.operation) params.set(START_OPERATION_PARAM, request.operation);
|
|
983
|
+
if (request.name) params.set(START_NAME_PARAM, request.name);
|
|
984
|
+
for (const [field, value] of Object.entries(request.fields ?? {})) params.set(`${START_FIELD_PREFIX}${field}`, value);
|
|
985
|
+
return `${basePath.endsWith("/") ? basePath.slice(0, -1) : basePath}/new?${params.toString()}`;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
// src/builder/app/workflow/work/start-node.ts
|
|
989
|
+
/** Where the start node lands on the empty canvas. */
|
|
990
|
+
const START_POSITION = {
|
|
991
|
+
x: 0,
|
|
992
|
+
y: 0
|
|
993
|
+
};
|
|
994
|
+
/** The value when it is a plain object, otherwise an empty one. */
|
|
995
|
+
function recordOf(value) {
|
|
996
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? { ...value } : {};
|
|
997
|
+
}
|
|
998
|
+
function buildStartNode(request) {
|
|
999
|
+
const config = getNodeConfig(request.nodeType);
|
|
1000
|
+
if (!config) return {
|
|
1001
|
+
ok: false,
|
|
1002
|
+
reason: "unknown-node"
|
|
1003
|
+
};
|
|
1004
|
+
if (request.operation) {
|
|
1005
|
+
if (!resolveNodeOperation(void 0, config.operations).operations.some((op) => op.name === request.operation)) return {
|
|
1006
|
+
ok: false,
|
|
1007
|
+
reason: "unknown-operation"
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
const node = createConfiguredNode(request.nodeType, START_POSITION, request.operation);
|
|
1011
|
+
const data = recordOf(node.data);
|
|
1012
|
+
const pinned = typeof data.operation_name === "string" && data.operation_name;
|
|
1013
|
+
const rejected = [...request.rejected];
|
|
1014
|
+
if (!pinned) for (const field of Object.keys(request.fields)) rejected.push({
|
|
1015
|
+
field,
|
|
1016
|
+
reason: "unknown-field"
|
|
1017
|
+
});
|
|
1018
|
+
else {
|
|
1019
|
+
const { selected } = resolveNodeOperation(data, config.operations);
|
|
1020
|
+
const { state, rejected: refused } = validateStartFields(paramsFromOperation(selected), request.fields);
|
|
1021
|
+
rejected.push(...refused);
|
|
1022
|
+
const args = recordOf(data.args);
|
|
1023
|
+
const current = recordOf(args.state);
|
|
1024
|
+
node.data = {
|
|
1025
|
+
...data,
|
|
1026
|
+
args: {
|
|
1027
|
+
...args,
|
|
1028
|
+
state: {
|
|
1029
|
+
...current,
|
|
1030
|
+
...state
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
return {
|
|
1036
|
+
ok: true,
|
|
1037
|
+
node,
|
|
1038
|
+
...request.name ? { name: request.name } : {},
|
|
1039
|
+
rejected
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
// src/onboarding/GuidedTourStarter.tsx
|
|
1044
|
+
/** Let the canvas and its toolbar settle before the first step spotlights. */
|
|
1045
|
+
const START_DELAY_MS = 800;
|
|
1046
|
+
function StartGuidedTour() {
|
|
1047
|
+
const location = useLocation();
|
|
1048
|
+
const navigate = useNavigate();
|
|
1049
|
+
const { pageTours, pageId, loading } = useSafeToursContext();
|
|
1050
|
+
const playTour = usePlayTour();
|
|
1051
|
+
const startedForKey = useRef(null);
|
|
1052
|
+
const tour = loading ? null : pickGuidedTour(pageTours, pageId);
|
|
1053
|
+
useEffect(() => {
|
|
1054
|
+
if (!tour || startedForKey.current === location.key) return void 0;
|
|
1055
|
+
const timer = setTimeout(() => {
|
|
1056
|
+
startedForKey.current = location.key;
|
|
1057
|
+
playTour(tour);
|
|
1058
|
+
navigate({
|
|
1059
|
+
pathname: location.pathname,
|
|
1060
|
+
search: location.search,
|
|
1061
|
+
hash: location.hash
|
|
1062
|
+
}, {
|
|
1063
|
+
replace: true,
|
|
1064
|
+
state: withoutGuidedTourIntent(location.state)
|
|
1065
|
+
});
|
|
1066
|
+
}, START_DELAY_MS);
|
|
1067
|
+
return () => clearTimeout(timer);
|
|
1068
|
+
}, [
|
|
1069
|
+
tour,
|
|
1070
|
+
playTour,
|
|
1071
|
+
navigate,
|
|
1072
|
+
location.key,
|
|
1073
|
+
location.pathname,
|
|
1074
|
+
location.search,
|
|
1075
|
+
location.hash,
|
|
1076
|
+
location.state
|
|
1077
|
+
]);
|
|
1078
|
+
return null;
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* Starts the builder's product tour when the builder was opened by the guided
|
|
1082
|
+
* "build your first workflow" step (router state `guidedTour: true`), once the
|
|
1083
|
+
* canvas is `ready`. Renders nothing otherwise: hosts without a tours runtime,
|
|
1084
|
+
* or without a tour for this page, open the builder exactly as before.
|
|
1085
|
+
*/
|
|
1086
|
+
function GuidedTourStarter({ ready }) {
|
|
1087
|
+
const location = useLocation();
|
|
1088
|
+
const { productId } = useSafeToursContext();
|
|
1089
|
+
if (!ready || !productId || !isGuidedTourIntent(location.state)) return null;
|
|
1090
|
+
return /* @__PURE__ */ jsx(StartGuidedTour, {});
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
// src/builder/app/workflow/work/page.tsx
|
|
1094
|
+
const LazyMissingNodesInstallModal = lazy(() => import("./MissingNodesInstallModal-rO_SEDrC.js").then((m) => ({ default: m.MissingNodesInstallModal })));
|
|
1095
|
+
function WorkflowItem({ readonly = false }) {
|
|
1096
|
+
if (readonly) {
|
|
1097
|
+
const queryParams = new URLSearchParams(window.location.search);
|
|
1098
|
+
queryParams.set("readonly", "true");
|
|
1099
|
+
const newUrl = `${window.location.pathname}?${queryParams.toString()}`;
|
|
1100
|
+
window.history.replaceState(null, "", newUrl);
|
|
1101
|
+
}
|
|
1102
|
+
const { id, version } = useParams();
|
|
1103
|
+
const navigate = useNavigate();
|
|
1104
|
+
const tr = useTr();
|
|
1105
|
+
const location = useLocation();
|
|
1106
|
+
const requestedStartLink = startNodeKey(location.search);
|
|
1107
|
+
const [startLink, setStartLink] = useState({
|
|
1108
|
+
navigation: location.key,
|
|
1109
|
+
link: requestedStartLink
|
|
1110
|
+
});
|
|
1111
|
+
if (requestedStartLink && (requestedStartLink !== startLink.link || location.key !== startLink.navigation)) setStartLink({
|
|
1112
|
+
navigation: location.key,
|
|
1113
|
+
link: requestedStartLink
|
|
1114
|
+
});
|
|
1115
|
+
const consumedStartLinkRef = useRef(null);
|
|
1116
|
+
const createIntentRef = useRef(isCreateIntent(location.state));
|
|
1117
|
+
useEffect(() => {
|
|
1118
|
+
createIntentRef.current = isCreateIntent(location.state);
|
|
1119
|
+
}, [location.state]);
|
|
1120
|
+
const [notFound, setNotFound] = useState(false);
|
|
1121
|
+
const [retryNonce, setRetryNonce] = useState(0);
|
|
1122
|
+
const loadRunId = new URLSearchParams(window.location.search).get("loadRun");
|
|
1123
|
+
const [workflow, setWorkflow] = useState(null);
|
|
1124
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
1125
|
+
const [loadError, setLoadError] = useState(null);
|
|
1126
|
+
const [createRefusal, setCreateRefusal] = useState(null);
|
|
1127
|
+
const upgradingRef = useRef(false);
|
|
1128
|
+
const resetWorkflow = useFlowStore((s) => s.actions.resetWorkflow);
|
|
1129
|
+
const reloadNonce = useWorkflowReloadStore((s) => s.nonce);
|
|
1130
|
+
useEffect(() => () => releaseLeaseKeptForReload(), [id, version]);
|
|
1131
|
+
useEffect(() => cancelPendingBuilderLoad, []);
|
|
1132
|
+
const seenReloadNonceRef = useRef(reloadNonce);
|
|
1133
|
+
const pendingReloadRef = useRef(null);
|
|
1134
|
+
const [reloadFailed, setReloadFailed] = useState(false);
|
|
1135
|
+
const { getWorkflow } = useLazyWorkflowDefinition({
|
|
1136
|
+
withNodeManifests: true,
|
|
1137
|
+
routeCritical: true
|
|
1138
|
+
});
|
|
1139
|
+
const { createWorkflow } = useCreateWorkflow();
|
|
1140
|
+
const creatingRef = useRef(false);
|
|
1141
|
+
const fromSharedLoadedRef = useRef(false);
|
|
1142
|
+
const fetchedWorkflowRef = useRef(null);
|
|
1143
|
+
const loadSeqRef = useRef(0);
|
|
1144
|
+
const { installedAppIds, installationsMap } = useInstalledNodes();
|
|
1145
|
+
const [nodeCheck, setNodeCheck] = useState(null);
|
|
1146
|
+
const [configModalOpen, setConfigModalOpen] = useState(false);
|
|
1147
|
+
const [installing, setInstalling] = useState(false);
|
|
1148
|
+
const [installProgress, setInstallProgress] = useState(null);
|
|
1149
|
+
const [installErrors, setInstallErrors] = useState([]);
|
|
1150
|
+
const doNodeCheck = useCallback((requiredNodeTypes) => buildNodeCheck(requiredNodeTypes, installedAppIds, installationsMap), [installedAppIds, installationsMap]);
|
|
1151
|
+
const doNodeCheckRef = useRef(doNodeCheck);
|
|
1152
|
+
useEffect(() => {
|
|
1153
|
+
doNodeCheckRef.current = doNodeCheck;
|
|
1154
|
+
});
|
|
1155
|
+
const trRef = useRef(tr);
|
|
1156
|
+
useEffect(() => {
|
|
1157
|
+
trRef.current = tr;
|
|
1158
|
+
});
|
|
1159
|
+
const handleInstallConfirm = useCallback(async () => {
|
|
1160
|
+
const nodesToInstall = [...nodeCheck?.missing ?? [], ...nodeCheck?.needsUpdate ?? []].filter((n) => !!n.storeProductId);
|
|
1161
|
+
const failed = [];
|
|
1162
|
+
if (nodesToInstall.length > 0) {
|
|
1163
|
+
setInstalling(true);
|
|
1164
|
+
setInstallErrors([]);
|
|
1165
|
+
try {
|
|
1166
|
+
const { getGlobalStoreClient } = await import("./global-client-BQPuFrFa.js").then((n) => n.r);
|
|
1167
|
+
const { InstallWorkflowNodeDocument } = await import("./global-operations-BG6YgxrM.js").then((n) => n.t);
|
|
1168
|
+
const { getFluidGridsConfig } = await import("./config-DO68jw5k.js").then((n) => n.n);
|
|
1169
|
+
const storeClient = getGlobalStoreClient();
|
|
1170
|
+
const cfg = getFluidGridsConfig();
|
|
1171
|
+
for (let i = 0; i < nodesToInstall.length; i++) {
|
|
1172
|
+
const node = nodesToInstall[i];
|
|
1173
|
+
setInstallProgress({
|
|
1174
|
+
current: i + 1,
|
|
1175
|
+
total: nodesToInstall.length,
|
|
1176
|
+
nodeName: node.displayName || node.nodeType
|
|
1177
|
+
});
|
|
1178
|
+
try {
|
|
1179
|
+
if (storeClient) await storeClient.mutate({
|
|
1180
|
+
mutation: InstallWorkflowNodeDocument,
|
|
1181
|
+
variables: { input: {
|
|
1182
|
+
productId: node.storeProductId,
|
|
1183
|
+
workspaceId: cfg.workspaceId,
|
|
1184
|
+
organizationId: cfg.tenantId,
|
|
1185
|
+
version: node.nodeVersion,
|
|
1186
|
+
manifest: null
|
|
1187
|
+
} }
|
|
1188
|
+
});
|
|
1189
|
+
} catch {
|
|
1190
|
+
failed.push(node.displayName || node.nodeType);
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
await refetchStoreNodes();
|
|
1194
|
+
await ensureNodeTypesLoaded(nodesToInstall.map((n) => n.nodeType));
|
|
1195
|
+
} finally {
|
|
1196
|
+
setInstalling(false);
|
|
1197
|
+
setInstallProgress(null);
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
if (failed.length > 0) {
|
|
1201
|
+
setInstallErrors(failed);
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
setInstallErrors([]);
|
|
1205
|
+
setConfigModalOpen(false);
|
|
1206
|
+
setNodeCheck(null);
|
|
1207
|
+
}, [nodeCheck]);
|
|
1208
|
+
const handleSkipInstall = useCallback(() => {
|
|
1209
|
+
setConfigModalOpen(false);
|
|
1210
|
+
setNodeCheck(null);
|
|
1211
|
+
}, []);
|
|
1212
|
+
const newWorkflow = useMemo(() => ({
|
|
1213
|
+
id: id ?? "",
|
|
1214
|
+
workflowKey: id ?? "",
|
|
1215
|
+
version: version ?? "",
|
|
1216
|
+
name: "Untitled Workflow",
|
|
1217
|
+
edges: [],
|
|
1218
|
+
nodes: [],
|
|
1219
|
+
sidebar: {
|
|
1220
|
+
active: "store-browse",
|
|
1221
|
+
panels: { nodeProperties: { selectedNode: null } }
|
|
1222
|
+
}
|
|
1223
|
+
}), [id, version]);
|
|
1224
|
+
useEffect(() => {
|
|
1225
|
+
let mounted = true;
|
|
1226
|
+
const target = `${id ?? ""}@${version ?? ""}`;
|
|
1227
|
+
loadSeqRef.current += 1;
|
|
1228
|
+
const loadSeq = loadSeqRef.current;
|
|
1229
|
+
if (reloadNonce !== seenReloadNonceRef.current) {
|
|
1230
|
+
seenReloadNonceRef.current = reloadNonce;
|
|
1231
|
+
pendingReloadRef.current = target;
|
|
1232
|
+
}
|
|
1233
|
+
const reloadPending = () => pendingReloadRef.current === target;
|
|
1234
|
+
const timedLoad = !reloadPending();
|
|
1235
|
+
const fetchedCopy = () => fetchedWorkflowRef.current?.target === target ? fetchedWorkflowRef.current.workflow : null;
|
|
1236
|
+
const recordFetched = (workflow) => {
|
|
1237
|
+
if (loadSeqRef.current !== loadSeq) return false;
|
|
1238
|
+
fetchedWorkflowRef.current = {
|
|
1239
|
+
target,
|
|
1240
|
+
workflow
|
|
1241
|
+
};
|
|
1242
|
+
if (pendingReloadRef.current === target) pendingReloadRef.current = null;
|
|
1243
|
+
return true;
|
|
1244
|
+
};
|
|
1245
|
+
const offerMissingNodes = (nodes) => {
|
|
1246
|
+
buildRequiredNodeTypes(nodes).then((requiredNodeTypes) => {
|
|
1247
|
+
if (!mounted || requiredNodeTypes.length === 0) return;
|
|
1248
|
+
const check = doNodeCheckRef.current(requiredNodeTypes);
|
|
1249
|
+
if (check.missing.length > 0 || check.missingPaid.length > 0 || (check.needsUpdate?.length ?? 0) > 0) {
|
|
1250
|
+
setNodeCheck(check);
|
|
1251
|
+
setConfigModalOpen(true);
|
|
1252
|
+
}
|
|
1253
|
+
}).catch((error) => {
|
|
1254
|
+
console.warn("[WorkflowItem] Missing-nodes check failed:", error);
|
|
1255
|
+
});
|
|
1256
|
+
};
|
|
1257
|
+
const loadWorkflow = async () => {
|
|
1258
|
+
try {
|
|
1259
|
+
resetWorkflow();
|
|
1260
|
+
if (mounted) setNotFound(false);
|
|
1261
|
+
if (mounted) setConfigModalOpen(false);
|
|
1262
|
+
if (mounted) setNodeCheck(null);
|
|
1263
|
+
if (mounted) setLoadError(null);
|
|
1264
|
+
if (mounted) setReloadFailed(false);
|
|
1265
|
+
if (version && mounted) setIsLoading(true);
|
|
1266
|
+
if (!version) {
|
|
1267
|
+
const fromSharedId = typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("fromShared") : null;
|
|
1268
|
+
const pendingManifestJson = fromSharedId && typeof localStorage !== "undefined" ? localStorage.getItem("pendingSharedWorkflow") : null;
|
|
1269
|
+
if (fromSharedId && pendingManifestJson) try {
|
|
1270
|
+
const manifest = JSON.parse(pendingManifestJson);
|
|
1271
|
+
const sharedWorkflow = {
|
|
1272
|
+
...newWorkflow,
|
|
1273
|
+
name: manifest.name ?? "Copied Workflow",
|
|
1274
|
+
nodes: manifest.nodes ?? [],
|
|
1275
|
+
edges: manifest.edges ?? []
|
|
1276
|
+
};
|
|
1277
|
+
if (mounted) {
|
|
1278
|
+
localStorage.removeItem("pendingSharedWorkflow");
|
|
1279
|
+
setWorkflow(sharedWorkflow);
|
|
1280
|
+
setIsLoading(false);
|
|
1281
|
+
fromSharedLoadedRef.current = true;
|
|
1282
|
+
offerMissingNodes(sharedWorkflow.nodes);
|
|
1283
|
+
}
|
|
1284
|
+
return;
|
|
1285
|
+
} catch (e) {
|
|
1286
|
+
console.error("[WorkflowItem] parse error:", e);
|
|
1287
|
+
if (mounted) localStorage.removeItem("pendingSharedWorkflow");
|
|
1288
|
+
}
|
|
1289
|
+
if (fromSharedId && fromSharedLoadedRef.current) {
|
|
1290
|
+
if (mounted) setIsLoading(false);
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
const startRequest = startLink.link && startLink !== consumedStartLinkRef.current ? readStartNodeRequest(startLink.link) : null;
|
|
1294
|
+
if (startRequest) {
|
|
1295
|
+
await ensureNodeTypesLoaded([startRequest.nodeType]);
|
|
1296
|
+
if (!mounted) return;
|
|
1297
|
+
consumedStartLinkRef.current = startLink;
|
|
1298
|
+
const started = buildStartNode(startRequest);
|
|
1299
|
+
window.history.replaceState(window.history.state, "", `${window.location.pathname}${withoutStartNodeParams(window.location.search)}${window.location.hash}`);
|
|
1300
|
+
if (started.ok) {
|
|
1301
|
+
const nodeType = started.node.type ?? startRequest.nodeType;
|
|
1302
|
+
setWorkflow({
|
|
1303
|
+
...newWorkflow,
|
|
1304
|
+
name: started.name ?? newWorkflow.name,
|
|
1305
|
+
nodes: [started.node],
|
|
1306
|
+
sidebar: {
|
|
1307
|
+
active: "node-properties",
|
|
1308
|
+
panels: { nodeProperties: { selectedNode: {
|
|
1309
|
+
id: started.node.id,
|
|
1310
|
+
type: nodeType
|
|
1311
|
+
} } }
|
|
1312
|
+
}
|
|
1313
|
+
});
|
|
1314
|
+
if (started.rejected.length > 0) toast.warning(trRef.current("fluidgrids.builder.startNode.partial", "Some settings from the link were not applied"), { description: started.rejected.map((entry) => entry.field).join(", ") });
|
|
1315
|
+
return;
|
|
1316
|
+
}
|
|
1317
|
+
toast.error(trRef.current("fluidgrids.builder.startNode.unavailable", "The node this link starts with is not available in this workspace"));
|
|
1318
|
+
}
|
|
1319
|
+
if (mounted) setWorkflow(newWorkflow);
|
|
1320
|
+
return;
|
|
1321
|
+
}
|
|
1322
|
+
const freshCreate = createIntentRef.current && !creatingRef.current && !fetchedCopy() && !loadRunId;
|
|
1323
|
+
const result = freshCreate ? null : await getWorkflow(id, void 0, version, { reusePrefetched: !reloadPending() });
|
|
1324
|
+
const definitionJson = result?.definitionJson;
|
|
1325
|
+
const defData = definitionJson?.data ?? (definitionJson?.nodes ? definitionJson : void 0);
|
|
1326
|
+
if (defData) {
|
|
1327
|
+
const workflowState = {
|
|
1328
|
+
...defData,
|
|
1329
|
+
nodes: mergeStickyNotes(defData),
|
|
1330
|
+
id: result?.workflowKey ?? "",
|
|
1331
|
+
workflowKey: result?.workflowKey ?? "",
|
|
1332
|
+
version: result?.version ?? "",
|
|
1333
|
+
name: result?.name ?? "",
|
|
1334
|
+
alias: result?.alias ?? "",
|
|
1335
|
+
description: result?.description ?? "",
|
|
1336
|
+
dbId: result?.id ?? "",
|
|
1337
|
+
status: result?.status ?? "DRAFT",
|
|
1338
|
+
codeBuildId: codeBuildIdOf(result?.definitionJson)
|
|
1339
|
+
};
|
|
1340
|
+
if (recordFetched(workflowState)) rememberRevision(result?.id, result?.revision);
|
|
1341
|
+
if (Array.isArray(result?.nodeManifests)) registerNodeManifests(result.nodeManifests, getWorkflowNodeTypes(workflowState.nodes));
|
|
1342
|
+
if (mounted) {
|
|
1343
|
+
setWorkflow(workflowState);
|
|
1344
|
+
if (timedLoad) noteWorkflowApplied(`${target}#${loadSeq}`);
|
|
1345
|
+
offerMissingNodes(workflowState.nodes);
|
|
1346
|
+
}
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
if (mounted) {
|
|
1350
|
+
if (reloadPending()) {
|
|
1351
|
+
setReloadFailed(true);
|
|
1352
|
+
releaseLeaseKeptForReload();
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
const earlier = fetchedCopy();
|
|
1356
|
+
if (earlier) {
|
|
1357
|
+
setWorkflow(earlier);
|
|
1358
|
+
return;
|
|
1359
|
+
}
|
|
1360
|
+
if (loadRunId) {
|
|
1361
|
+
setLoadError("The workflow version for this TEST run is no longer available.");
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1364
|
+
const anyVersion = freshCreate ? null : await getWorkflow(id, void 0, void 0);
|
|
1365
|
+
const missing = decideMissingWorkflow({
|
|
1366
|
+
createIntent: createIntentRef.current,
|
|
1367
|
+
otherVersionExists: !!anyVersion?.workflowKey
|
|
1368
|
+
});
|
|
1369
|
+
if (missing === "open-newest" && anyVersion) {
|
|
1370
|
+
toast.info(`Version ${version} not found`, {
|
|
1371
|
+
description: `Opening ${anyVersion.version} instead.`,
|
|
1372
|
+
dismissible: true
|
|
1373
|
+
});
|
|
1374
|
+
navigate(`../workflow/${id}/${anyVersion.version}`, { replace: true });
|
|
1375
|
+
return;
|
|
1376
|
+
}
|
|
1377
|
+
if (missing === "not-found") {
|
|
1378
|
+
if (mounted) {
|
|
1379
|
+
setNotFound(true);
|
|
1380
|
+
noteBuilderLoadAbandoned();
|
|
1381
|
+
}
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
if (!creatingRef.current) {
|
|
1385
|
+
creatingRef.current = true;
|
|
1386
|
+
let reported = null;
|
|
1387
|
+
let created = null;
|
|
1388
|
+
try {
|
|
1389
|
+
created = await createWorkflow(blankWorkflowCreateInput(id, version), { onError: (createError) => {
|
|
1390
|
+
reported = createError;
|
|
1391
|
+
} });
|
|
1392
|
+
} catch (createError) {
|
|
1393
|
+
reported = createError;
|
|
1394
|
+
created = null;
|
|
1395
|
+
}
|
|
1396
|
+
if (!created) {
|
|
1397
|
+
if (mounted) setCreateRefusal(classifyCreateRefusal(reported));
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
const createdWorkflow = {
|
|
1401
|
+
...newWorkflow,
|
|
1402
|
+
id: created.workflowKey,
|
|
1403
|
+
workflowKey: created.workflowKey,
|
|
1404
|
+
version: created.version,
|
|
1405
|
+
dbId: created.id,
|
|
1406
|
+
status: created.status ?? "DRAFT"
|
|
1407
|
+
};
|
|
1408
|
+
if (recordFetched(createdWorkflow)) rememberRevision(created.id, created.revision);
|
|
1409
|
+
if (mounted) setWorkflow(createdWorkflow);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
} catch (error) {
|
|
1413
|
+
console.error("[WorkflowItem] Error loading workflow:", error);
|
|
1414
|
+
if (mounted) {
|
|
1415
|
+
noteBuilderLoadAbandoned();
|
|
1416
|
+
if (loadRunId) setLoadError("The workflow version for this TEST run could not be loaded.");
|
|
1417
|
+
else if (reloadPending()) {
|
|
1418
|
+
setReloadFailed(true);
|
|
1419
|
+
releaseLeaseKeptForReload();
|
|
1420
|
+
} else setWorkflow(fetchedCopy() ?? newWorkflow);
|
|
1421
|
+
}
|
|
1422
|
+
} finally {
|
|
1423
|
+
if (mounted) {
|
|
1424
|
+
setIsLoading(false);
|
|
1425
|
+
creatingRef.current = false;
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
};
|
|
1429
|
+
loadWorkflow();
|
|
1430
|
+
return () => {
|
|
1431
|
+
mounted = false;
|
|
1432
|
+
};
|
|
1433
|
+
}, [
|
|
1434
|
+
id,
|
|
1435
|
+
version,
|
|
1436
|
+
createWorkflow,
|
|
1437
|
+
getWorkflow,
|
|
1438
|
+
newWorkflow,
|
|
1439
|
+
resetWorkflow,
|
|
1440
|
+
navigate,
|
|
1441
|
+
loadRunId,
|
|
1442
|
+
retryNonce,
|
|
1443
|
+
reloadNonce,
|
|
1444
|
+
startLink
|
|
1445
|
+
]);
|
|
1446
|
+
if (loadError) return /* @__PURE__ */ jsx("div", {
|
|
1447
|
+
className: "flex h-full min-h-[60vh] w-full items-center justify-center p-6",
|
|
1448
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1449
|
+
className: "max-w-md rounded-lg border border-[var(--color-status-error-border)] bg-[var(--color-status-error-bg-subtle)] p-6 text-center",
|
|
1450
|
+
children: [
|
|
1451
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
1452
|
+
icon: "mdi:alert-circle-outline",
|
|
1453
|
+
className: "mx-auto mb-3 size-8 text-[var(--color-status-error-text)]"
|
|
1454
|
+
}),
|
|
1455
|
+
/* @__PURE__ */ jsx("h2", {
|
|
1456
|
+
className: "text-lg font-semibold text-[var(--color-status-error-text)]",
|
|
1457
|
+
children: "Unable to load run"
|
|
1458
|
+
}),
|
|
1459
|
+
/* @__PURE__ */ jsx("p", {
|
|
1460
|
+
className: "mt-2 text-sm text-[var(--color-status-error-text)]",
|
|
1461
|
+
children: loadError
|
|
1462
|
+
}),
|
|
1463
|
+
/* @__PURE__ */ jsx("button", {
|
|
1464
|
+
type: "button",
|
|
1465
|
+
className: "mt-4 rounded-md border border-border px-3 py-2 text-sm text-foreground hover:bg-muted",
|
|
1466
|
+
onClick: () => navigate("../runs"),
|
|
1467
|
+
children: "Back to executions"
|
|
1468
|
+
})
|
|
1469
|
+
]
|
|
1470
|
+
})
|
|
1471
|
+
});
|
|
1472
|
+
if (isLoading) return /* @__PURE__ */ jsx("div", {
|
|
1473
|
+
className: "flex h-full min-h-[60vh] w-full items-center justify-center",
|
|
1474
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1475
|
+
className: "flex flex-col items-center gap-2",
|
|
1476
|
+
children: [/* @__PURE__ */ jsx(CompactMarkOr, {
|
|
1477
|
+
today: /* @__PURE__ */ jsx(Icon, {
|
|
1478
|
+
icon: "mynaui:spinner",
|
|
1479
|
+
className: "size-6 animate-spin text-primary"
|
|
1480
|
+
}),
|
|
1481
|
+
className: "size-6"
|
|
1482
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
1483
|
+
className: "text-sm text-foreground/60",
|
|
1484
|
+
children: "Loading workflow..."
|
|
1485
|
+
})]
|
|
1486
|
+
})
|
|
1487
|
+
});
|
|
1488
|
+
const retryLabel = tr("fluidgrids.builder.workflowNotFound.retry", "Try again");
|
|
1489
|
+
const backLabel = tr("fluidgrids.builder.workflowNotFound.back", "Back to Workflows");
|
|
1490
|
+
if (createRefusal?.kind === "failed") return /* @__PURE__ */ jsx(LoadProblem, {
|
|
1491
|
+
kind: "error",
|
|
1492
|
+
title: tr("fluidgrids.builder.workflowNotCreated.title", "Workflow not created"),
|
|
1493
|
+
description: tr("fluidgrids.builder.workflowNotCreated.description", "The new workflow could not be created, so there is nothing to edit yet."),
|
|
1494
|
+
retryLabel,
|
|
1495
|
+
onRetry: () => {
|
|
1496
|
+
setCreateRefusal(null);
|
|
1497
|
+
setRetryNonce((n) => n + 1);
|
|
1498
|
+
},
|
|
1499
|
+
backLabel,
|
|
1500
|
+
onBack: () => navigate("../list", { replace: true })
|
|
1501
|
+
});
|
|
1502
|
+
if (notFound) return /* @__PURE__ */ jsx(LoadProblem, {
|
|
1503
|
+
kind: "not-found",
|
|
1504
|
+
title: tr("fluidgrids.builder.workflowNotFound.title", "Workflow not found"),
|
|
1505
|
+
description: tr("fluidgrids.builder.workflowNotFound.description", "No workflow with this key exists in this workspace, or it could not be loaded. Nothing was created."),
|
|
1506
|
+
retryLabel,
|
|
1507
|
+
onRetry: () => setRetryNonce((n) => n + 1),
|
|
1508
|
+
backLabel,
|
|
1509
|
+
onBack: () => navigate("../list")
|
|
1510
|
+
});
|
|
1511
|
+
if (reloadFailed) return /* @__PURE__ */ jsx(LoadProblem, {
|
|
1512
|
+
kind: "error",
|
|
1513
|
+
testId: "fluidgrids-builder-reload-failed",
|
|
1514
|
+
title: tr("fluidgrids.builder.reloadFailed.title", "The latest version did not load"),
|
|
1515
|
+
description: tr("fluidgrids.builder.reloadFailed.description", "The latest saved version of this workflow could not be loaded, so nothing older is shown in its place. Check your connection and try again."),
|
|
1516
|
+
retryLabel,
|
|
1517
|
+
onRetry: () => setRetryNonce((n) => n + 1),
|
|
1518
|
+
backLabel,
|
|
1519
|
+
onBack: () => navigate("../list")
|
|
1520
|
+
});
|
|
1521
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1522
|
+
configModalOpen && workflow && /* @__PURE__ */ jsx(Suspense, {
|
|
1523
|
+
fallback: null,
|
|
1524
|
+
children: /* @__PURE__ */ jsx(LazyMissingNodesInstallModal, {
|
|
1525
|
+
open: configModalOpen,
|
|
1526
|
+
onOpenChange: (open) => {
|
|
1527
|
+
if (!open) handleSkipInstall();
|
|
1528
|
+
},
|
|
1529
|
+
workflowName: workflow.name,
|
|
1530
|
+
nodeCheckResult: nodeCheck,
|
|
1531
|
+
onConfirm: handleInstallConfirm,
|
|
1532
|
+
onSkip: handleSkipInstall,
|
|
1533
|
+
installing,
|
|
1534
|
+
installProgress,
|
|
1535
|
+
installErrors
|
|
1536
|
+
})
|
|
1537
|
+
}),
|
|
1538
|
+
/* @__PURE__ */ jsx(CreateWorkflowRefusalDialog, {
|
|
1539
|
+
surface: "builder-create",
|
|
1540
|
+
refusal: createRefusal,
|
|
1541
|
+
onClose: () => {
|
|
1542
|
+
setCreateRefusal(null);
|
|
1543
|
+
if (upgradingRef.current) return;
|
|
1544
|
+
navigate("../list", { replace: true });
|
|
1545
|
+
},
|
|
1546
|
+
onUpgrade: () => {
|
|
1547
|
+
upgradingRef.current = true;
|
|
1548
|
+
navigate(BILLING_PLANS_PATH);
|
|
1549
|
+
}
|
|
1550
|
+
}),
|
|
1551
|
+
workflow && !isLoading && /* @__PURE__ */ jsx(FlowBuilderPage, { workflow }),
|
|
1552
|
+
workflow && !isLoading && /* @__PURE__ */ jsx(AssistantLiveCanvasHost, {}),
|
|
1553
|
+
/* @__PURE__ */ jsx(GuidedTourStarter, { ready: Boolean(workflow && !isLoading && !configModalOpen) })
|
|
1554
|
+
] });
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
// src/pages/WorkflowBuilder.tsx
|
|
1558
|
+
var WorkflowBuilder_exports = /* @__PURE__ */ __exportAll({ WorkflowBuilder: () => WorkflowBuilder });
|
|
1559
|
+
/**
|
|
1560
|
+
* WorkflowBuilder page with ErrorBoundary for graceful crash recovery.
|
|
1561
|
+
* If the builder throws (React Flow error, node rendering crash, etc.),
|
|
1562
|
+
* the user sees a recovery UI instead of a blank screen.
|
|
1563
|
+
*/
|
|
1564
|
+
function WorkflowBuilder() {
|
|
1565
|
+
const navigate = useNavigate();
|
|
1566
|
+
return /* @__PURE__ */ jsx(ErrorBoundary, {
|
|
1567
|
+
fallback: (error) => /* @__PURE__ */ jsx("div", {
|
|
1568
|
+
className: "flex flex-col items-center justify-center min-h-[60vh] gap-4 p-8",
|
|
1569
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
1570
|
+
className: "rounded-lg border border-[var(--color-status-error-border)] bg-[var(--color-status-error-bg-subtle)] p-6 max-w-lg w-full text-center",
|
|
1571
|
+
children: [
|
|
1572
|
+
/* @__PURE__ */ jsx("h2", {
|
|
1573
|
+
className: "text-lg font-semibold text-[var(--color-status-error-text)] mb-2",
|
|
1574
|
+
children: "Workflow Builder Error"
|
|
1575
|
+
}),
|
|
1576
|
+
/* @__PURE__ */ jsx("p", {
|
|
1577
|
+
className: "text-sm text-[var(--color-text-secondary)] mb-4",
|
|
1578
|
+
children: "Something went wrong while loading the workflow builder. This may be caused by invalid workflow data or a rendering issue."
|
|
1579
|
+
}),
|
|
1580
|
+
error && /* @__PURE__ */ jsxs("details", {
|
|
1581
|
+
className: "text-left mb-4",
|
|
1582
|
+
children: [/* @__PURE__ */ jsx("summary", {
|
|
1583
|
+
className: "text-xs text-[var(--color-text-tertiary)] cursor-pointer hover:text-[var(--color-text-secondary)]",
|
|
1584
|
+
children: "Error details"
|
|
1585
|
+
}), /* @__PURE__ */ jsx("pre", {
|
|
1586
|
+
className: "mt-2 p-2 bg-[var(--color-bg-canvas)] rounded text-xs overflow-auto max-h-32 text-[var(--color-text-tertiary)]",
|
|
1587
|
+
children: error.message
|
|
1588
|
+
})]
|
|
1589
|
+
}),
|
|
1590
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1591
|
+
className: "flex gap-3 justify-center",
|
|
1592
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
1593
|
+
type: "button",
|
|
1594
|
+
onClick: () => window.location.reload(),
|
|
1595
|
+
className: "px-4 py-2 text-sm font-medium rounded-md bg-[var(--color-bg-accent)] text-[var(--color-text-on-accent)] hover:opacity-90 transition-opacity",
|
|
1596
|
+
children: "Reload Page"
|
|
1597
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
1598
|
+
type: "button",
|
|
1599
|
+
onClick: () => navigate("../list"),
|
|
1600
|
+
className: "px-4 py-2 text-sm font-medium rounded-md border border-border-default text-[var(--color-text-secondary)] hover:bg-[var(--color-bg-elevated)] transition-colors",
|
|
1601
|
+
children: "Back to Workflows"
|
|
1602
|
+
})]
|
|
1603
|
+
})
|
|
1604
|
+
]
|
|
1605
|
+
})
|
|
1606
|
+
}),
|
|
1607
|
+
children: /* @__PURE__ */ jsx(WorkflowItem, {})
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
export { START_NAME_PARAM as a, readStartNodeRequest as c, START_FIELD_PREFIX as i, startNodeLink as l, WorkflowBuilder_exports as n, START_NODE_PARAM as o, GuidedTourStarter as r, START_OPERATION_PARAM as s, WorkflowBuilder as t };
|