@burdenoff/fluidgrids-fe-sdk 2026.1026.5 → 2026.1027.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/{ExecutionDetailPage-QWMR2CST.js → ExecutionDetailPage-CRGWMW6J.js} +7 -7
  2. package/dist/{ExecutionsListPage-TYYC3WT7.js → ExecutionsListPage-P4I6FJX3.js} +7 -7
  3. package/dist/{WorkflowBuilder-U636SQC4.js → WorkflowBuilder-D4FMZ6NM.js} +9 -9
  4. package/dist/{WorkflowsList-XPARJ4SL.js → WorkflowsList-ZO7KPIG7.js} +7 -7
  5. package/dist/{chunk-NLK5WXH5.js → chunk-2PQZZ6Y4.js} +2 -2
  6. package/dist/{chunk-IQLMFGAQ.js → chunk-3UA5H5CT.js} +1 -1
  7. package/dist/{chunk-W57KG66V.js → chunk-5BF6XLMJ.js} +1 -1
  8. package/dist/{chunk-WU3ZNMXL.js → chunk-5TSO3MJL.js} +4 -4
  9. package/dist/{chunk-FJMKFZ6L.js → chunk-BK4OICYX.js} +5 -5
  10. package/dist/{chunk-U5HHDK3P.js → chunk-BQWEOKPY.js} +2 -2
  11. package/dist/{chunk-3ZGCACWA.js → chunk-IKGKMOBR.js} +1 -1
  12. package/dist/{chunk-KVVM3C2R.js → chunk-JQ66KPU6.js} +2 -2
  13. package/dist/{chunk-BTVYWLPL.js → chunk-JVBJKIV2.js} +1 -1
  14. package/dist/{chunk-JOE4LAR4.js → chunk-KEURSYHK.js} +1 -1
  15. package/dist/{chunk-4QV27HMI.js → chunk-KQ76OJWI.js} +3 -3
  16. package/dist/{chunk-IGBCNXSB.js → chunk-L7ZCMJ7H.js} +3 -3
  17. package/dist/{chunk-DIZ7NKG2.js → chunk-LR46LFJH.js} +113 -5
  18. package/dist/{chunk-PKE3R6N3.js → chunk-LXQXMWJ6.js} +1 -1
  19. package/dist/{chunk-NHGKPOJZ.js → chunk-MRL6QLBD.js} +1 -1
  20. package/dist/{chunk-6HMCSUQM.js → chunk-NVXDNFVB.js} +1006 -27
  21. package/dist/{chunk-KQWIQJ7E.js → chunk-PGEG5FCW.js} +2 -2
  22. package/dist/{chunk-L2S5V4YS.js → chunk-QRJ7SYR2.js} +11 -3
  23. package/dist/{chunk-SO7UZG76.js → chunk-RBAYIRXR.js} +5 -5
  24. package/dist/{chunk-4JR52R3N.js → chunk-WYTARFHH.js} +3 -3
  25. package/dist/{chunk-IOAU6GYE.js → chunk-X7IMNKTG.js} +1 -1
  26. package/dist/executions.js +9 -9
  27. package/dist/history.js +4 -4
  28. package/dist/index.d.ts +1127 -8
  29. package/dist/index.js +31 -31
  30. package/dist/nodes.js +2 -2
  31. package/dist/observability.js +4 -4
  32. package/dist/settings.js +4 -4
  33. package/dist/templates.js +8 -8
  34. package/dist/workflow-builder.js +10 -10
  35. package/dist/workflows-list.js +7 -7
  36. package/package.json +1 -1
@@ -2,16 +2,16 @@ import { deepClone, applyTemplateInputs } from './chunk-GEMNVFPK.js';
2
2
  import { Input as Input$1 } from './chunk-IEVSFCFS.js';
3
3
  import { Dialog as Dialog$1, DialogContent as DialogContent$1, DialogHeader as DialogHeader$1, DialogTitle as DialogTitle$1, DialogDescription as DialogDescription$1, DialogFooter } from './chunk-YXMFRQYV.js';
4
4
  import { Badge as Badge$1, Button } from './chunk-BQXVT32O.js';
5
- import { QuotaExhaustedDialog } from './chunk-3ZGCACWA.js';
6
- import { EntityTagPicker } from './chunk-IQLMFGAQ.js';
7
- import { useWorkflowVersions, useRestoreWorkflowVersion, useActivateWorkflow, useDeleteWorkflow, useLazyWorkflowDefinition, useDeactivateWorkflow } from './chunk-NLK5WXH5.js';
5
+ import { QuotaExhaustedDialog } from './chunk-IKGKMOBR.js';
6
+ import { EntityTagPicker } from './chunk-3UA5H5CT.js';
7
+ import { useWorkflowVersions, useRestoreWorkflowVersion, useActivateWorkflow, useDeleteWorkflow, useLazyWorkflowDefinition, useDeactivateWorkflow } from './chunk-2PQZZ6Y4.js';
8
8
  import { FluidGridsDocsLink } from './chunk-4VJ3MDOV.js';
9
- import { RUNS_QUOTA_NAME, throwIfResultError, useFlowStore, BILLING_PLANS_PATH, emitUpgradeClicked, FluidGridsContext, emitWorkflowCreated, emitTemplateUsed, ensureNodeConfigsLoaded, NODE_CONFIGS, registerWorkflowNodeTypes, emitNodeInstalled, useNodeExecution, onNodeTypesUpdate, NODE_TYPES, getNodeMetadata, useIsValidConnection, refetchStoreNodes, AVAILABLE_NODES, useInsertNode, NODE_TYPE_DRAG_DATA_FORMAT, NODE_OPERATION_DRAG_DATA_FORMAT, useSaveWorkflow, SdkPermissionButton, FLUIDGRIDS_PERMISSIONS, STICKY_NOTE_TYPE, fieldsFromValue, getNodeDetail, useFluidGridsAnalytics, buildOperationSeed, isNodeTrigger, buildStickyNode, fieldsFromIO, ConnectionSelector, structuredParameterType, nodeAccent, NodeTypeIcon, NODES_METADATA, resolveNodeOperation, declaredOutputFields, subscribeWorkflowSaved, pathToExpression, ExpressionEditor, formatParameterValue, parseParameterValue, isNodeConfigsInitialized, resolveUiSpec, isImageIcon, NODES, synchronizeOperationUpdate, NodePropertyPanel, openRunQuotaUpgradePrompt, describeOperationError, isTriggerOperation, canRenderOperationPanel, resolveOperationName, resolveInputHandles } from './chunk-BTVYWLPL.js';
9
+ import { RUNS_QUOTA_NAME, throwIfResultError, useFlowStore, BILLING_PLANS_PATH, emitUpgradeClicked, FluidGridsContext, emitWorkflowCreated, emitTemplateUsed, ensureNodeConfigsLoaded, NODE_CONFIGS, registerWorkflowNodeTypes, emitNodeInstalled, useNodeExecution, onNodeTypesUpdate, NODE_TYPES, getNodeMetadata, useIsValidConnection, refetchStoreNodes, AVAILABLE_NODES, useInsertNode, NODE_TYPE_DRAG_DATA_FORMAT, NODE_OPERATION_DRAG_DATA_FORMAT, useConnections, ConnectionFormDialog, useSaveWorkflow, SdkPermissionButton, FLUIDGRIDS_PERMISSIONS, STICKY_NOTE_TYPE, fieldsFromValue, getNodeDetail, useFluidGridsAnalytics, buildOperationSeed, isNodeTrigger, buildStickyNode, fieldsFromIO, ConnectionSelector, structuredParameterType, nodeAccent, NodeTypeIcon, NODES_METADATA, resolveNodeOperation, declaredOutputFields, subscribeWorkflowSaved, pathToExpression, ExpressionEditor, formatParameterValue, parseParameterValue, isNodeConfigsInitialized, resolveUiSpec, isImageIcon, NODES, synchronizeOperationUpdate, NodePropertyPanel, openRunQuotaUpgradePrompt, describeOperationError, isTriggerOperation, canRenderOperationPanel, resolveOperationName, resolveInputHandles } from './chunk-JVBJKIV2.js';
10
10
  import { cn } from './chunk-JL7CASN5.js';
11
11
  import { getGlobalStoreClient } from './chunk-PXIFUMLA.js';
12
12
  import { getFluidGridsConfig } from './chunk-CY6KX4RG.js';
13
13
  import { GetMyNodeInstallationsDocument, BrowseWorkflowTemplatesDocument, InstallWorkflowNodeDocument, InstallPurchasedNodeDocument, BrowseWorkflowNodesDocument, UninstallWorkflowNodeDocument, CreateStoreOrderDocument, GetNodeInstallableVersionsDocument } from './chunk-WBH2XEWO.js';
14
- import { WorkspaceRunsQuotaDocument, NodeSchemaIntrospectionDocument, useWorkflowPinnedDataQuery, usePinNodeDataMutation, useUnpinNodeDataMutation, WorkflowGenerationTemplatesDocument, WorkflowGenerationDocument, GenerateWorkflowFromPromptDocument, WorkflowEnvironmentsDocument, WorkflowPromotionRequestsDocument, DeployWorkflowVersionToDevDocument, RequestWorkflowPromotionDocument, ApproveWorkflowPromotionDocument, RejectWorkflowPromotionDocument, CancelWorkflowPromotionDocument, UpdateWorkflowEnvironmentPolicyDocument, useRunFromNodeEligibilityQuery, EventRegistrationsDocument, WebhookTestListenerDocument, StopWebhookTestListenerDocument, ListenForWebhookTestEventDocument, NodeUsageStatusDocument, RemoveNodeFromWorkflowsDocument } from './chunk-L2S5V4YS.js';
14
+ import { WorkspaceRunsQuotaDocument, NodeSchemaIntrospectionDocument, useWorkflowPinnedDataQuery, usePinNodeDataMutation, useUnpinNodeDataMutation, WorkflowGenerationTemplatesDocument, WorkflowGenerationDocument, GenerateWorkflowFromPromptDocument, WorkflowEnvironmentsDocument, WorkflowPromotionRequestsDocument, DeployWorkflowVersionToDevDocument, RequestWorkflowPromotionDocument, ApproveWorkflowPromotionDocument, RejectWorkflowPromotionDocument, CancelWorkflowPromotionDocument, UpdateWorkflowEnvironmentPolicyDocument, WorkflowGitRepositoryDocument, WorkflowGitPushesDocument, WorkflowGitCommitsDocument, LinkWorkflowGitRepositoryDocument, UnlinkWorkflowGitRepositoryDocument, PushWorkflowToGitDocument, WorkflowGitDiffDocument, RestoreWorkflowFromGitDocument, useRunFromNodeEligibilityQuery, EventRegistrationsDocument, WebhookTestListenerDocument, StopWebhookTestListenerDocument, ListenForWebhookTestEventDocument, NodeUsageStatusDocument, RemoveNodeFromWorkflowsDocument } from './chunk-QRJ7SYR2.js';
15
15
  import { useTr } from './chunk-UULVIT25.js';
16
16
  import { getFluidGridsClient, waitForFluidGridsClient, getFluidGridsClientSafe } from './chunk-NTWG3CJX.js';
17
17
  import * as React3 from 'react';
@@ -25,7 +25,7 @@ import { useEventBus } from '@burdenoff/fe-libs/shared/events';
25
25
  import { useQuery, useMutation } from '@apollo/client/react';
26
26
  import { gql as gql$1 } from '@apollo/client/core';
27
27
  import 'jszip';
28
- import { Sparkles, Star, Download, Eye, Loader2, History, GitCompareArrows, Play, RotateCcw, Trash2, Layers, Upload, Rocket, ArrowRight, Check, X, Undo2, Maximize2, Redo2, LayoutGrid, Keyboard, Plus, GitBranch, AlertCircle, Search, RefreshCw, CheckCircle2, Package, Info, Copy, BadgeCheck, DollarSign, Type, Code, Hash, List, Braces, Workflow, PlusCircle, ChevronDown, ChevronRight, AlertTriangle } from 'lucide-react';
28
+ import { Sparkles, Star, Download, Eye, Loader2, History, GitCompareArrows, Play, RotateCcw, Trash2, Layers, Upload, Rocket, ArrowRight, Check, X, Undo2, Plus, Link2, GitBranch, Unlink, GitCompare, ExternalLink, GitCommitHorizontal, Maximize2, Redo2, LayoutGrid, Keyboard, AlertCircle, Search, RefreshCw, CheckCircle2, Package, Info, Copy, BadgeCheck, DollarSign, Type, Code, Hash, List, Braces, Workflow, PlusCircle, ChevronDown, ChevronRight, AlertTriangle } from 'lucide-react';
29
29
  import { Icon } from '@iconify/react';
30
30
  import { toast } from 'sonner';
31
31
  import { useShallow, shallow } from 'zustand/shallow';
@@ -6456,8 +6456,8 @@ var reducer = (state, action) => {
6456
6456
  if (toastId) {
6457
6457
  addToRemoveQueue(toastId);
6458
6458
  } else {
6459
- state.toasts.forEach((toast12) => {
6460
- addToRemoveQueue(toast12.id);
6459
+ state.toasts.forEach((toast13) => {
6460
+ addToRemoveQueue(toast13.id);
6461
6461
  });
6462
6462
  }
6463
6463
  return {
@@ -7833,7 +7833,7 @@ function VisualMapperContent({
7833
7833
  mapping,
7834
7834
  onMappingChange
7835
7835
  }) {
7836
- const { toast: toast12 } = useToast();
7836
+ const { toast: toast13 } = useToast();
7837
7837
  const tr = useTr();
7838
7838
  const reactFlowWrapper = useRef(null);
7839
7839
  const [selectedSourceNode, setSelectedSourceNode] = useState(null);
@@ -7853,7 +7853,7 @@ function VisualMapperContent({
7853
7853
  targetOperation
7854
7854
  );
7855
7855
  if (generatedNodes.length === 0) {
7856
- toast12({
7856
+ toast13({
7857
7857
  title: tr(
7858
7858
  "fluidgrids.builder.visualMapper.noFieldsFoundTitle",
7859
7859
  "No fields found"
@@ -7879,7 +7879,7 @@ function VisualMapperContent({
7879
7879
  targetNode,
7880
7880
  targetOperation,
7881
7881
  setNodes,
7882
- toast12,
7882
+ toast13,
7883
7883
  tr
7884
7884
  ]);
7885
7885
  useEffect(() => {
@@ -7986,7 +7986,7 @@ function VisualMapperContent({
7986
7986
  }
7987
7987
  onMappingChange(updatedMapping);
7988
7988
  if (isCompatible) {
7989
- toast12({
7989
+ toast13({
7990
7990
  title: tr(
7991
7991
  "fluidgrids.builder.visualMapper.mappingCreatedTitle",
7992
7992
  "Mapping created"
@@ -7994,7 +7994,7 @@ function VisualMapperContent({
7994
7994
  description: `Mapped ${sourcePath} (${sourceType}) to ${targetPath} (${targetType})`
7995
7995
  });
7996
7996
  } else {
7997
- toast12({
7997
+ toast13({
7998
7998
  title: tr(
7999
7999
  "fluidgrids.builder.visualMapper.typeMismatchTitle",
8000
8000
  "Type mismatch warning"
@@ -8004,7 +8004,7 @@ function VisualMapperContent({
8004
8004
  });
8005
8005
  }
8006
8006
  } else {
8007
- toast12({
8007
+ toast13({
8008
8008
  title: tr(
8009
8009
  "fluidgrids.builder.visualMapper.invalidMappingTitle",
8010
8010
  "Invalid mapping"
@@ -8017,7 +8017,7 @@ function VisualMapperContent({
8017
8017
  });
8018
8018
  }
8019
8019
  },
8020
- [nodes, mapping, onMappingChange, toast12, tr, setEdges]
8020
+ [nodes, mapping, onMappingChange, toast13, tr, setEdges]
8021
8021
  );
8022
8022
  const onEdgeDelete = useCallback(
8023
8023
  (edge) => {
@@ -8074,7 +8074,7 @@ function VisualMapperContent({
8074
8074
  const handleSaveMappingDialog = (expression, targetFieldName) => {
8075
8075
  const targetPath = targetFieldName || selectedTargetNode?.data?.path;
8076
8076
  if (!targetPath) {
8077
- toast12({
8077
+ toast13({
8078
8078
  title: tr(
8079
8079
  "fluidgrids.builder.visualMapper.noTargetFieldTitle",
8080
8080
  "No target field specified"
@@ -8106,7 +8106,7 @@ function VisualMapperContent({
8106
8106
  }
8107
8107
  onMappingChange(updatedMapping);
8108
8108
  const mappingType = detectMappingType(expression);
8109
- toast12({
8109
+ toast13({
8110
8110
  title: `${mappingType.charAt(0).toUpperCase() + mappingType.slice(1)} mapping created`,
8111
8111
  description: `${tr("fluidgrids.builder.visualMapper.appliedMappingTo", "Applied mapping to")} ${targetPath}`
8112
8112
  });
@@ -8405,7 +8405,7 @@ function MappingEditor({
8405
8405
  setEdges,
8406
8406
  edgeId
8407
8407
  }) {
8408
- const { toast: toast12 } = useToast();
8408
+ const { toast: toast13 } = useToast();
8409
8409
  const tr = useTr();
8410
8410
  const [mappingJson, setMappingJson] = useState({});
8411
8411
  const [jsonDataString, setJsonDataString] = useState(
@@ -8529,7 +8529,7 @@ function MappingEditor({
8529
8529
  const handleSaveMapping = () => {
8530
8530
  try {
8531
8531
  checkJsonValidity();
8532
- toast12({
8532
+ toast13({
8533
8533
  title: tr(
8534
8534
  "fluidgrids.builder.mappingEditor.mappingSavedTitle",
8535
8535
  "Mapping saved"
@@ -8540,7 +8540,7 @@ function MappingEditor({
8540
8540
  )
8541
8541
  });
8542
8542
  } catch (error) {
8543
- toast12({
8543
+ toast13({
8544
8544
  title: tr(
8545
8545
  "fluidgrids.builder.mappingEditor.errorSavingTitle",
8546
8546
  "Error saving mapping"
@@ -8559,7 +8559,7 @@ function MappingEditor({
8559
8559
  const parsedData = checkJsonValidity();
8560
8560
  const result = await applyMapping(parsedData, sampleInput);
8561
8561
  setPreviewOutput(result);
8562
- toast12({
8562
+ toast13({
8563
8563
  title: tr(
8564
8564
  "fluidgrids.builder.mappingEditor.mappingTestedTitle",
8565
8565
  "Mapping tested"
@@ -8571,7 +8571,7 @@ function MappingEditor({
8571
8571
  });
8572
8572
  } catch (error) {
8573
8573
  console.error("Test mapping error:", error);
8574
- toast12({
8574
+ toast13({
8575
8575
  title: tr(
8576
8576
  "fluidgrids.builder.mappingEditor.mappingTestFailedTitle",
8577
8577
  "Mapping test failed"
@@ -20410,7 +20410,8 @@ function EnvironmentsPanel({
20410
20410
  ) : [
20411
20411
  state.promotedFrom ? `${tr("fluidgrids.builder.environments.from", "From")} ${envLabel(state.promotedFrom)}` : null,
20412
20412
  deployer,
20413
- relativeTime(state.deployedAt)
20413
+ relativeTime(state.deployedAt),
20414
+ state.gitCommitSha ? `Git ${state.gitCommitSha.slice(0, 7)}` : null
20414
20415
  ].filter(Boolean).join(" \xB7 ") }),
20415
20416
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex flex-wrap gap-2", children: [
20416
20417
  state.environment === "DEV" && currentVersion && /* @__PURE__ */ jsxs(
@@ -20684,7 +20685,8 @@ function EnvironmentsPanel({
20684
20685
  /* @__PURE__ */ jsx("p", { className: "truncate text-muted-foreground", children: [
20685
20686
  nameOf(item.requestedById),
20686
20687
  item.reviewedById && item.reviewedById !== item.requestedById ? `${tr("fluidgrids.builder.environments.reviewedBy", "reviewed by")} ${nameOf(item.reviewedById)}` : null,
20687
- relativeTime(item.requestedAt)
20688
+ relativeTime(item.requestedAt),
20689
+ item.gitCommitSha ? `Git ${item.gitCommitSha.slice(0, 7)}` : null
20688
20690
  ].filter(Boolean).join(" \xB7 ") })
20689
20691
  ] }),
20690
20692
  /* @__PURE__ */ jsx(
@@ -20754,6 +20756,981 @@ function EnvironmentsPanel({
20754
20756
  )
20755
20757
  ] });
20756
20758
  }
20759
+ var LIST_LIMIT = 20;
20760
+ function messageOf2(error) {
20761
+ return error instanceof Error ? error.message : String(error);
20762
+ }
20763
+ function useWorkflowGitSync(workflowKey) {
20764
+ const [repository, setRepository] = useState(null);
20765
+ const [commits, setCommits] = useState([]);
20766
+ const [pushes, setPushes] = useState([]);
20767
+ const [loading, setLoading] = useState(false);
20768
+ const [error, setError] = useState(null);
20769
+ const [historyError, setHistoryError] = useState(null);
20770
+ const keyRef = useRef(workflowKey);
20771
+ keyRef.current = workflowKey;
20772
+ const refetch = useCallback(async () => {
20773
+ if (!workflowKey) return;
20774
+ setLoading(true);
20775
+ setError(null);
20776
+ setHistoryError(null);
20777
+ try {
20778
+ const client = getFluidGridsClient();
20779
+ const [linked, pushed] = await Promise.all([
20780
+ client.query({
20781
+ query: WorkflowGitRepositoryDocument,
20782
+ fetchPolicy: "network-only"
20783
+ }),
20784
+ client.query({
20785
+ query: WorkflowGitPushesDocument,
20786
+ variables: { workflowKey, limit: LIST_LIMIT },
20787
+ fetchPolicy: "network-only"
20788
+ })
20789
+ ]);
20790
+ throwIfResultError(linked);
20791
+ throwIfResultError(pushed);
20792
+ if (keyRef.current !== workflowKey) return;
20793
+ const link2 = linked.data?.workflowGitRepository ?? null;
20794
+ setRepository(link2);
20795
+ setPushes(pushed.data?.workflowGitPushes ?? []);
20796
+ if (!link2) {
20797
+ setCommits([]);
20798
+ return;
20799
+ }
20800
+ try {
20801
+ const history = await client.query({
20802
+ query: WorkflowGitCommitsDocument,
20803
+ variables: { workflowKey, limit: LIST_LIMIT },
20804
+ fetchPolicy: "network-only"
20805
+ });
20806
+ throwIfResultError(history);
20807
+ if (keyRef.current === workflowKey) {
20808
+ setCommits(history.data?.workflowGitCommits ?? []);
20809
+ }
20810
+ } catch (err) {
20811
+ if (keyRef.current === workflowKey) {
20812
+ setCommits([]);
20813
+ setHistoryError(messageOf2(err));
20814
+ }
20815
+ }
20816
+ } catch (err) {
20817
+ if (keyRef.current === workflowKey) setError(messageOf2(err));
20818
+ } finally {
20819
+ if (keyRef.current === workflowKey) setLoading(false);
20820
+ }
20821
+ }, [workflowKey]);
20822
+ useEffect(() => {
20823
+ setRepository(null);
20824
+ setCommits([]);
20825
+ setPushes([]);
20826
+ }, [workflowKey]);
20827
+ const link = useCallback(
20828
+ async (values) => {
20829
+ const result = await getFluidGridsClient().mutate({
20830
+ mutation: LinkWorkflowGitRepositoryDocument,
20831
+ variables: {
20832
+ input: {
20833
+ provider: "GITHUB",
20834
+ connectionId: values.connectionId,
20835
+ repository: values.repository.trim(),
20836
+ branch: values.branch.trim(),
20837
+ pathPrefix: values.pathPrefix.trim(),
20838
+ pushOnActivation: values.pushOnActivation,
20839
+ pushOnPromotion: values.pushOnPromotion
20840
+ }
20841
+ }
20842
+ });
20843
+ throwIfResultError(result);
20844
+ await refetch();
20845
+ },
20846
+ [refetch]
20847
+ );
20848
+ const unlink = useCallback(async () => {
20849
+ const result = await getFluidGridsClient().mutate({ mutation: UnlinkWorkflowGitRepositoryDocument });
20850
+ throwIfResultError(result);
20851
+ await refetch();
20852
+ }, [refetch]);
20853
+ const push = useCallback(
20854
+ async (version) => {
20855
+ const result = await getFluidGridsClient().mutate({
20856
+ mutation: PushWorkflowToGitDocument,
20857
+ variables: { workflowKey, version }
20858
+ });
20859
+ throwIfResultError(result);
20860
+ const pushed = result.data?.pushWorkflowToGit;
20861
+ if (!pushed) throw new Error("The push returned no result");
20862
+ await refetch();
20863
+ return pushed;
20864
+ },
20865
+ [workflowKey, refetch]
20866
+ );
20867
+ const diff = useCallback(
20868
+ async (commitSha, version) => {
20869
+ const result = await getFluidGridsClient().query({
20870
+ query: WorkflowGitDiffDocument,
20871
+ variables: { workflowKey, commitSha, version },
20872
+ fetchPolicy: "network-only"
20873
+ });
20874
+ throwIfResultError(result);
20875
+ const view = result.data?.workflowGitDiff;
20876
+ if (!view) throw new Error("The diff returned no result");
20877
+ return view;
20878
+ },
20879
+ [workflowKey]
20880
+ );
20881
+ const restore = useCallback(
20882
+ async (commitSha) => {
20883
+ const result = await getFluidGridsClient().mutate({
20884
+ mutation: RestoreWorkflowFromGitDocument,
20885
+ variables: { input: { workflowKey, commitSha } }
20886
+ });
20887
+ throwIfResultError(result);
20888
+ const restored = result.data?.restoreWorkflowFromGit;
20889
+ if (!restored) throw new Error("The restore returned no result");
20890
+ return restored;
20891
+ },
20892
+ [workflowKey]
20893
+ );
20894
+ return {
20895
+ repository,
20896
+ commits,
20897
+ pushes,
20898
+ loading,
20899
+ error,
20900
+ historyError,
20901
+ refetch,
20902
+ link,
20903
+ unlink,
20904
+ push,
20905
+ diff,
20906
+ restore
20907
+ };
20908
+ }
20909
+
20910
+ // src/builder/lib/workflow-git-sync.ts
20911
+ var GITHUB_PROVIDER_KEY = "github";
20912
+ var DEFAULT_GIT_BRANCH = "main";
20913
+ var DEFAULT_GIT_FOLDER = "fluidgrids/workflows";
20914
+ function githubConnections(connections) {
20915
+ return connections.filter(
20916
+ (connection) => connection.provider?.key?.toLowerCase() === GITHUB_PROVIDER_KEY
20917
+ ).sort((a, b) => {
20918
+ const activeA = a.status === "ACTIVE" ? 0 : 1;
20919
+ const activeB = b.status === "ACTIVE" ? 0 : 1;
20920
+ return activeA - activeB || a.name.localeCompare(b.name);
20921
+ });
20922
+ }
20923
+ function normalizeRepositoryInput(value) {
20924
+ return value.trim().replace(/^https?:\/\/github\.com\//i, "").replace(/\.git$/i, "").replace(/\/+$/, "");
20925
+ }
20926
+ function gitLinkFormProblem(form) {
20927
+ if (!form.connectionId.trim()) return "connection";
20928
+ if (!/^[A-Za-z0-9][A-Za-z0-9-]*\/[A-Za-z0-9._-]+$/.test(
20929
+ normalizeRepositoryInput(form.repository)
20930
+ ))
20931
+ return "repository";
20932
+ const branch = form.branch.trim();
20933
+ if (!branch || /\s|\.\.|^\/|\/$/.test(branch)) return "branch";
20934
+ const folder = form.pathPrefix.trim().replace(/^\/+|\/+$/g, "");
20935
+ if (folder.split("/").some((segment) => segment === ".." || segment === "."))
20936
+ return "pathPrefix";
20937
+ return null;
20938
+ }
20939
+ function gitFilePath(pathPrefix, workflowKey) {
20940
+ return pathPrefix ? `${pathPrefix}/${workflowKey}.json` : `${workflowKey}.json`;
20941
+ }
20942
+ function shortSha(sha) {
20943
+ return sha ? sha.slice(0, 7) : "";
20944
+ }
20945
+ function commitTitle(message) {
20946
+ const first = message.split("\n", 1)[0] ?? "";
20947
+ return first.trim() || "(no message)";
20948
+ }
20949
+ var EMPTY_FORM = {
20950
+ connectionId: "",
20951
+ repository: "",
20952
+ branch: DEFAULT_GIT_BRANCH,
20953
+ pathPrefix: DEFAULT_GIT_FOLDER,
20954
+ pushOnActivation: true,
20955
+ pushOnPromotion: true
20956
+ };
20957
+ function formatDiffValue2(value) {
20958
+ if (value === void 0 || value === null) return "\u2014";
20959
+ try {
20960
+ return JSON.stringify(value);
20961
+ } catch {
20962
+ return String(value);
20963
+ }
20964
+ }
20965
+ function GitSyncPanel({
20966
+ className,
20967
+ compact = false
20968
+ }) {
20969
+ const tr = useTr();
20970
+ const navigate = useNavigate();
20971
+ const params = useParams();
20972
+ const workflowKey = params?.id ?? "";
20973
+ const currentVersion = params?.version ?? "";
20974
+ const {
20975
+ repository,
20976
+ commits,
20977
+ pushes,
20978
+ loading,
20979
+ error,
20980
+ historyError,
20981
+ refetch,
20982
+ link,
20983
+ unlink,
20984
+ push,
20985
+ diff,
20986
+ restore
20987
+ } = useWorkflowGitSync(workflowKey);
20988
+ const {
20989
+ connections,
20990
+ loading: connectionsLoading,
20991
+ refetch: refetchConnections
20992
+ } = useConnections();
20993
+ const gitConnections = useMemo(
20994
+ () => githubConnections(connections),
20995
+ [connections]
20996
+ );
20997
+ const [busy, setBusy] = useState(null);
20998
+ const [editing, setEditing] = useState(false);
20999
+ const [form, setForm] = useState(EMPTY_FORM);
21000
+ const [showProblem, setShowProblem] = useState(false);
21001
+ const [newConnectionOpen, setNewConnectionOpen] = useState(false);
21002
+ const [comparison, setComparison] = useState(
21003
+ null
21004
+ );
21005
+ const [confirm, setConfirm] = useState(null);
21006
+ const config = getFluidGridsConfig();
21007
+ const actorInputs = useMemo(() => {
21008
+ const ids = /* @__PURE__ */ new Set();
21009
+ for (const item of pushes) ids.add(item.pushedById);
21010
+ if (repository) ids.add(repository.linkedById);
21011
+ return [...ids].map((actorId) => ({ actorId, actorType: "user" }));
21012
+ }, [pushes, repository]);
21013
+ const actorProfiles = useActorProfiles(actorInputs, {
21014
+ workspaceId: config.workspaceId || void 0,
21015
+ orgId: config.organizationId,
21016
+ authToken: config.authToken
21017
+ });
21018
+ const nameOf = (actorId) => {
21019
+ if (!actorId) return null;
21020
+ return actorProfiles[actorId]?.displayName ?? buildActorFallback({ actorId, actorType: "user" }).displayName;
21021
+ };
21022
+ const problem = gitLinkFormProblem(form);
21023
+ const problemText = (value) => {
21024
+ switch (value) {
21025
+ case "connection":
21026
+ return tr(
21027
+ "fluidgrids.builder.git.problemConnection",
21028
+ "Choose a GitHub connection"
21029
+ );
21030
+ case "repository":
21031
+ return tr(
21032
+ "fluidgrids.builder.git.problemRepository",
21033
+ "Enter the repository as owner/name"
21034
+ );
21035
+ case "branch":
21036
+ return tr(
21037
+ "fluidgrids.builder.git.problemBranch",
21038
+ "Enter a valid branch name"
21039
+ );
21040
+ default:
21041
+ return tr(
21042
+ "fluidgrids.builder.git.problemFolder",
21043
+ "The folder cannot contain . or .. segments"
21044
+ );
21045
+ }
21046
+ };
21047
+ const run = async (key, action, errorTitle) => {
21048
+ setBusy(key);
21049
+ try {
21050
+ await action();
21051
+ } catch (err) {
21052
+ toast.error(errorTitle, {
21053
+ description: err instanceof Error ? err.message : String(err)
21054
+ });
21055
+ } finally {
21056
+ setBusy(null);
21057
+ }
21058
+ };
21059
+ const startEditing = () => {
21060
+ setForm(
21061
+ repository ? {
21062
+ connectionId: repository.connectionId,
21063
+ repository: repository.repository,
21064
+ branch: repository.branch,
21065
+ pathPrefix: repository.pathPrefix,
21066
+ pushOnActivation: repository.pushOnActivation,
21067
+ pushOnPromotion: repository.pushOnPromotion
21068
+ } : {
21069
+ ...EMPTY_FORM,
21070
+ connectionId: gitConnections[0]?.id ?? ""
21071
+ }
21072
+ );
21073
+ setShowProblem(false);
21074
+ setEditing(true);
21075
+ };
21076
+ const handleLink = () => {
21077
+ if (problem) {
21078
+ setShowProblem(true);
21079
+ return;
21080
+ }
21081
+ void run(
21082
+ "link",
21083
+ async () => {
21084
+ await link(form);
21085
+ setEditing(false);
21086
+ toast.success(
21087
+ tr("fluidgrids.builder.git.linked", "Repository linked"),
21088
+ {
21089
+ description: `${form.repository.trim()} @ ${form.branch.trim()}`,
21090
+ dismissible: true
21091
+ }
21092
+ );
21093
+ },
21094
+ tr("fluidgrids.builder.git.linkError", "Could not link the repository")
21095
+ );
21096
+ };
21097
+ const handlePush = () => run(
21098
+ "push",
21099
+ async () => {
21100
+ const pushed = await push(currentVersion);
21101
+ toast.success(
21102
+ pushed.status === "UNCHANGED" ? tr(
21103
+ "fluidgrids.builder.git.unchanged",
21104
+ "Already up to date in Git"
21105
+ ) : `${pushed.version} ${tr("fluidgrids.builder.git.pushed", "pushed to Git")}`,
21106
+ {
21107
+ description: pushed.commitSha ? `${pushed.filePath} \xB7 ${shortSha(pushed.commitSha)}` : pushed.filePath,
21108
+ dismissible: true
21109
+ }
21110
+ );
21111
+ },
21112
+ tr("fluidgrids.builder.git.pushError", "Push to Git failed")
21113
+ );
21114
+ const handleCompare = (sha) => run(
21115
+ `diff:${sha}`,
21116
+ async () => {
21117
+ setComparison(await diff(sha, currentVersion));
21118
+ },
21119
+ tr("fluidgrids.builder.git.diffError", "Could not compare")
21120
+ );
21121
+ const handleConfirm = async () => {
21122
+ if (!confirm) return;
21123
+ const current = confirm;
21124
+ setConfirm(null);
21125
+ if (current.kind === "unlink") {
21126
+ await run(
21127
+ "unlink",
21128
+ async () => {
21129
+ await unlink();
21130
+ setComparison(null);
21131
+ toast.success(
21132
+ tr("fluidgrids.builder.git.unlinked", "Repository unlinked"),
21133
+ { dismissible: true }
21134
+ );
21135
+ },
21136
+ tr(
21137
+ "fluidgrids.builder.git.unlinkError",
21138
+ "Could not unlink the repository"
21139
+ )
21140
+ );
21141
+ return;
21142
+ }
21143
+ await run(
21144
+ `restore:${current.sha}`,
21145
+ async () => {
21146
+ const result = await restore(current.sha);
21147
+ if (!result.success || !result.workflow) {
21148
+ const reasons = [
21149
+ ...result.validation?.errors ?? [],
21150
+ result.message ?? ""
21151
+ ].filter(Boolean);
21152
+ throw new Error(reasons.join(" "));
21153
+ }
21154
+ toast.success(
21155
+ tr("fluidgrids.builder.git.restored", "Restored from Git"),
21156
+ {
21157
+ description: `${shortSha(current.sha)} \u2192 ${result.workflow.version}`,
21158
+ dismissible: true
21159
+ }
21160
+ );
21161
+ navigate(
21162
+ `../workflow/${result.workflow.workflowKey}/${result.workflow.version}`
21163
+ );
21164
+ },
21165
+ tr("fluidgrids.builder.git.restoreError", "Restore from Git failed")
21166
+ );
21167
+ };
21168
+ const pushStatusVariant = (status) => {
21169
+ if (status === "PUSHED") return "default";
21170
+ if (status === "FAILED") return "destructive";
21171
+ return "outline";
21172
+ };
21173
+ const triggerLabel = (trigger) => {
21174
+ if (trigger === "PROMOTION")
21175
+ return tr("fluidgrids.builder.git.triggerPromotion", "Promotion");
21176
+ if (trigger === "ACTIVATION")
21177
+ return tr("fluidgrids.builder.git.triggerActivation", "Publish");
21178
+ return tr("fluidgrids.builder.git.triggerManual", "Manual");
21179
+ };
21180
+ const linkForm = /* @__PURE__ */ jsxs(
21181
+ "div",
21182
+ {
21183
+ className: "space-y-3 rounded-lg border border-border p-3",
21184
+ "data-testid": "fluidgrids-git-link-form",
21185
+ children: [
21186
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
21187
+ /* @__PURE__ */ jsx(Label, { htmlFor: "fg-git-connection", className: "text-xs", children: tr("fluidgrids.builder.git.connection", "GitHub connection") }),
21188
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
21189
+ /* @__PURE__ */ jsxs(
21190
+ Select,
21191
+ {
21192
+ value: form.connectionId,
21193
+ onValueChange: (value) => setForm((prev) => ({ ...prev, connectionId: value })),
21194
+ children: [
21195
+ /* @__PURE__ */ jsx(SelectTrigger, { id: "fg-git-connection", className: "h-8 flex-1", children: /* @__PURE__ */ jsx(
21196
+ SelectValue,
21197
+ {
21198
+ placeholder: connectionsLoading ? tr("fluidgrids.builder.git.loading", "Loading...") : tr(
21199
+ "fluidgrids.builder.git.chooseConnection",
21200
+ "Choose a connection"
21201
+ )
21202
+ }
21203
+ ) }),
21204
+ /* @__PURE__ */ jsx(SelectContent, { className: "z-[120]", children: gitConnections.map((connection) => /* @__PURE__ */ jsxs(SelectItem, { value: connection.id, children: [
21205
+ connection.name,
21206
+ connection.status !== "ACTIVE" ? ` (${connection.status.toLowerCase()})` : ""
21207
+ ] }, connection.id)) })
21208
+ ]
21209
+ }
21210
+ ),
21211
+ /* @__PURE__ */ jsxs(
21212
+ Button$1,
21213
+ {
21214
+ variant: "outline",
21215
+ size: "sm",
21216
+ className: "h-8 gap-1 text-xs",
21217
+ onClick: () => setNewConnectionOpen(true),
21218
+ children: [
21219
+ /* @__PURE__ */ jsx(Plus, { className: "size-3.5" }),
21220
+ tr("fluidgrids.builder.git.newConnection", "New")
21221
+ ]
21222
+ }
21223
+ )
21224
+ ] }),
21225
+ !connectionsLoading && gitConnections.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-[11px] text-muted-foreground", children: tr(
21226
+ "fluidgrids.builder.git.noConnections",
21227
+ "No GitHub connection yet. Create one; it needs access to the repository's contents (the repo scope)."
21228
+ ) })
21229
+ ] }),
21230
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
21231
+ /* @__PURE__ */ jsx(Label, { htmlFor: "fg-git-repository", className: "text-xs", children: tr("fluidgrids.builder.git.repository", "Repository") }),
21232
+ /* @__PURE__ */ jsx(
21233
+ Input,
21234
+ {
21235
+ id: "fg-git-repository",
21236
+ className: "h-8 font-mono text-xs",
21237
+ placeholder: "owner/name",
21238
+ value: form.repository,
21239
+ onChange: (event) => setForm((prev) => ({ ...prev, repository: event.target.value }))
21240
+ }
21241
+ )
21242
+ ] }),
21243
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
21244
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
21245
+ /* @__PURE__ */ jsx(Label, { htmlFor: "fg-git-branch", className: "text-xs", children: tr("fluidgrids.builder.git.branch", "Branch") }),
21246
+ /* @__PURE__ */ jsx(
21247
+ Input,
21248
+ {
21249
+ id: "fg-git-branch",
21250
+ className: "h-8 font-mono text-xs",
21251
+ value: form.branch,
21252
+ onChange: (event) => setForm((prev) => ({ ...prev, branch: event.target.value }))
21253
+ }
21254
+ )
21255
+ ] }),
21256
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
21257
+ /* @__PURE__ */ jsx(Label, { htmlFor: "fg-git-folder", className: "text-xs", children: tr("fluidgrids.builder.git.folder", "Folder") }),
21258
+ /* @__PURE__ */ jsx(
21259
+ Input,
21260
+ {
21261
+ id: "fg-git-folder",
21262
+ className: "h-8 font-mono text-xs",
21263
+ value: form.pathPrefix,
21264
+ onChange: (event) => setForm((prev) => ({ ...prev, pathPrefix: event.target.value }))
21265
+ }
21266
+ )
21267
+ ] })
21268
+ ] }),
21269
+ [
21270
+ [
21271
+ "pushOnActivation",
21272
+ tr(
21273
+ "fluidgrids.builder.git.pushOnActivation",
21274
+ "Commit when a version is published"
21275
+ )
21276
+ ],
21277
+ [
21278
+ "pushOnPromotion",
21279
+ tr(
21280
+ "fluidgrids.builder.git.pushOnPromotion",
21281
+ "Commit when a promotion applies"
21282
+ )
21283
+ ]
21284
+ ].map(([field, label]) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
21285
+ /* @__PURE__ */ jsx(Label, { htmlFor: `fg-git-${field}`, className: "text-xs font-normal", children: label }),
21286
+ /* @__PURE__ */ jsx(
21287
+ Switch,
21288
+ {
21289
+ id: `fg-git-${field}`,
21290
+ checked: form[field],
21291
+ onCheckedChange: (checked) => setForm((prev) => ({ ...prev, [field]: checked }))
21292
+ }
21293
+ )
21294
+ ] }, field)),
21295
+ showProblem && problem && /* @__PURE__ */ jsx("p", { className: "text-xs text-[var(--color-status-error-text)]", children: problemText(problem) }),
21296
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
21297
+ /* @__PURE__ */ jsxs(
21298
+ Button$1,
21299
+ {
21300
+ size: "sm",
21301
+ className: "h-7 gap-1 text-xs",
21302
+ disabled: busy !== null,
21303
+ onClick: handleLink,
21304
+ children: [
21305
+ busy === "link" ? /* @__PURE__ */ jsx(Loader2, { className: "size-3.5 animate-spin" }) : /* @__PURE__ */ jsx(Link2, { className: "size-3.5" }),
21306
+ repository ? tr("fluidgrids.builder.git.saveLink", "Save") : tr("fluidgrids.builder.git.link", "Link repository")
21307
+ ]
21308
+ }
21309
+ ),
21310
+ repository && /* @__PURE__ */ jsx(
21311
+ Button$1,
21312
+ {
21313
+ size: "sm",
21314
+ variant: "ghost",
21315
+ className: "h-7 text-xs",
21316
+ disabled: busy !== null,
21317
+ onClick: () => setEditing(false),
21318
+ children: tr("fluidgrids.builder.git.cancel", "Cancel")
21319
+ }
21320
+ )
21321
+ ] }),
21322
+ /* @__PURE__ */ jsx("p", { className: "text-[11px] text-muted-foreground", children: tr(
21323
+ "fluidgrids.builder.git.linkHint",
21324
+ "The link applies to every workflow in this workspace. Linking checks that the connection can read the branch. Only members with publish rights can change it."
21325
+ ) })
21326
+ ]
21327
+ }
21328
+ );
21329
+ return /* @__PURE__ */ jsxs(
21330
+ Sheet,
21331
+ {
21332
+ onOpenChange: (open) => {
21333
+ if (!open) return;
21334
+ setComparison(null);
21335
+ void refetch();
21336
+ void refetchConnections();
21337
+ },
21338
+ children: [
21339
+ /* @__PURE__ */ jsx(SheetTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
21340
+ Button$1,
21341
+ {
21342
+ "data-tour": "fluidgrids-builder-git",
21343
+ variant: "outline",
21344
+ size: compact ? "icon" : "sm",
21345
+ className: cn$1(!compact && "flex gap-1", className),
21346
+ "aria-label": tr("fluidgrids.builder.git.triggerButton", "Git"),
21347
+ disabled: !workflowKey,
21348
+ children: [
21349
+ /* @__PURE__ */ jsx(GitBranch, { className: "size-4" }),
21350
+ !compact && tr("fluidgrids.builder.git.triggerButton", "Git")
21351
+ ]
21352
+ }
21353
+ ) }),
21354
+ /* @__PURE__ */ jsxs(
21355
+ SheetContent,
21356
+ {
21357
+ side: "right",
21358
+ className: "w-[380px] sm:w-[460px] overflow-y-auto",
21359
+ "data-testid": "fluidgrids-git-panel",
21360
+ children: [
21361
+ /* @__PURE__ */ jsxs(SheetHeader, { children: [
21362
+ /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
21363
+ /* @__PURE__ */ jsx(GitBranch, { className: "size-5" }),
21364
+ tr("fluidgrids.builder.git.title", "Git sync")
21365
+ ] }),
21366
+ /* @__PURE__ */ jsx(SheetDescription, { children: tr(
21367
+ "fluidgrids.builder.git.description",
21368
+ "Keep this workflow in a GitHub repository: commit versions, read the file's history, compare a commit with this version or restore it as a new draft."
21369
+ ) })
21370
+ ] }),
21371
+ loading && !repository && pushes.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-8 text-sm text-muted-foreground", children: [
21372
+ /* @__PURE__ */ jsx(Loader2, { className: "mr-2 size-4 animate-spin" }),
21373
+ tr("fluidgrids.builder.git.loading", "Loading...")
21374
+ ] }) : error ? /* @__PURE__ */ jsxs("div", { className: "py-6 text-sm", children: [
21375
+ /* @__PURE__ */ jsx("p", { className: "text-[var(--color-status-error-text)]", children: error }),
21376
+ /* @__PURE__ */ jsx(
21377
+ Button$1,
21378
+ {
21379
+ variant: "outline",
21380
+ size: "sm",
21381
+ className: "mt-3",
21382
+ onClick: () => void refetch(),
21383
+ children: tr("fluidgrids.builder.git.retry", "Retry")
21384
+ }
21385
+ )
21386
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-5 pb-6", children: [
21387
+ /* @__PURE__ */ jsxs("section", { "aria-labelledby": "fg-git-repo", children: [
21388
+ /* @__PURE__ */ jsx(
21389
+ "h3",
21390
+ {
21391
+ id: "fg-git-repo",
21392
+ className: "mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",
21393
+ children: tr("fluidgrids.builder.git.repositoryTitle", "Repository")
21394
+ }
21395
+ ),
21396
+ !repository && !editing ? /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-dashed border-border p-3", children: [
21397
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: tr(
21398
+ "fluidgrids.builder.git.notLinked",
21399
+ "No repository is linked to this workspace yet."
21400
+ ) }),
21401
+ /* @__PURE__ */ jsxs(
21402
+ Button$1,
21403
+ {
21404
+ size: "sm",
21405
+ className: "mt-2 h-7 gap-1 text-xs",
21406
+ onClick: startEditing,
21407
+ children: [
21408
+ /* @__PURE__ */ jsx(Link2, { className: "size-3.5" }),
21409
+ tr("fluidgrids.builder.git.link", "Link repository")
21410
+ ]
21411
+ }
21412
+ )
21413
+ ] }) : editing ? linkForm : repository ? /* @__PURE__ */ jsxs(
21414
+ "div",
21415
+ {
21416
+ className: "rounded-lg border border-border p-3",
21417
+ "data-testid": "fluidgrids-git-linked",
21418
+ children: [
21419
+ /* @__PURE__ */ jsx("p", { className: "font-mono text-sm text-foreground", children: repository.repository }),
21420
+ /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-muted-foreground", children: [
21421
+ `${tr("fluidgrids.builder.git.branch", "Branch")} ${repository.branch}`,
21422
+ gitFilePath(repository.pathPrefix, workflowKey)
21423
+ ].join(" \xB7 ") }),
21424
+ /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-muted-foreground", children: [
21425
+ repository.pushOnActivation ? tr(
21426
+ "fluidgrids.builder.git.onPublish",
21427
+ "Commits on publish"
21428
+ ) : null,
21429
+ repository.pushOnPromotion ? tr(
21430
+ "fluidgrids.builder.git.onPromotion",
21431
+ "Commits on promotion"
21432
+ ) : null,
21433
+ nameOf(repository.linkedById)
21434
+ ].filter(Boolean).join(" \xB7 ") }),
21435
+ /* @__PURE__ */ jsxs("div", { className: "mt-2 flex flex-wrap gap-2", children: [
21436
+ currentVersion && /* @__PURE__ */ jsxs(
21437
+ Button$1,
21438
+ {
21439
+ size: "sm",
21440
+ className: "h-7 gap-1 text-xs",
21441
+ disabled: busy !== null,
21442
+ onClick: () => void handlePush(),
21443
+ children: [
21444
+ busy === "push" ? /* @__PURE__ */ jsx(Loader2, { className: "size-3.5 animate-spin" }) : /* @__PURE__ */ jsx(Upload, { className: "size-3.5" }),
21445
+ tr("fluidgrids.builder.git.push", "Push"),
21446
+ " ",
21447
+ currentVersion
21448
+ ]
21449
+ }
21450
+ ),
21451
+ /* @__PURE__ */ jsx(
21452
+ Button$1,
21453
+ {
21454
+ size: "sm",
21455
+ variant: "outline",
21456
+ className: "h-7 text-xs",
21457
+ disabled: busy !== null,
21458
+ onClick: startEditing,
21459
+ children: tr("fluidgrids.builder.git.edit", "Edit link")
21460
+ }
21461
+ ),
21462
+ /* @__PURE__ */ jsxs(
21463
+ Button$1,
21464
+ {
21465
+ size: "sm",
21466
+ variant: "ghost",
21467
+ className: "h-7 gap-1 text-xs",
21468
+ disabled: busy !== null,
21469
+ onClick: () => setConfirm({ kind: "unlink" }),
21470
+ children: [
21471
+ /* @__PURE__ */ jsx(Unlink, { className: "size-3.5" }),
21472
+ tr("fluidgrids.builder.git.unlink", "Unlink")
21473
+ ]
21474
+ }
21475
+ )
21476
+ ] })
21477
+ ]
21478
+ }
21479
+ ) : null
21480
+ ] }),
21481
+ repository && /* @__PURE__ */ jsxs("section", { "aria-labelledby": "fg-git-commits", children: [
21482
+ /* @__PURE__ */ jsx(
21483
+ "h3",
21484
+ {
21485
+ id: "fg-git-commits",
21486
+ className: "mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",
21487
+ children: tr("fluidgrids.builder.git.commitsTitle", "Git history")
21488
+ }
21489
+ ),
21490
+ historyError ? /* @__PURE__ */ jsx("p", { className: "text-xs text-[var(--color-status-error-text)]", children: historyError }) : commits.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: tr(
21491
+ "fluidgrids.builder.git.commitsEmpty",
21492
+ "This workflow has no commits in the repository yet."
21493
+ ) }) : /* @__PURE__ */ jsx("ul", { className: "space-y-2", children: commits.map((commit) => /* @__PURE__ */ jsxs(
21494
+ "li",
21495
+ {
21496
+ className: "rounded-lg border border-border p-2.5",
21497
+ "data-testid": "fluidgrids-git-commit",
21498
+ children: [
21499
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
21500
+ /* @__PURE__ */ jsx("p", { className: "min-w-0 truncate text-xs font-medium text-foreground", children: commitTitle(commit.message) }),
21501
+ commit.version && /* @__PURE__ */ jsx(
21502
+ Badge,
21503
+ {
21504
+ variant: "outline",
21505
+ className: "h-5 shrink-0 px-1.5 py-0 font-mono text-[10px]",
21506
+ children: commit.version
21507
+ }
21508
+ )
21509
+ ] }),
21510
+ /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-[11px] text-muted-foreground", children: [
21511
+ shortSha(commit.sha),
21512
+ commit.authorName,
21513
+ relativeTime(commit.authoredAt)
21514
+ ].filter(Boolean).join(" \xB7 ") }),
21515
+ /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex flex-wrap gap-1.5", children: [
21516
+ currentVersion && /* @__PURE__ */ jsxs(
21517
+ Button$1,
21518
+ {
21519
+ size: "sm",
21520
+ variant: "outline",
21521
+ className: "h-6 gap-1 px-2 text-[11px]",
21522
+ disabled: busy !== null,
21523
+ onClick: () => void handleCompare(commit.sha),
21524
+ children: [
21525
+ busy === `diff:${commit.sha}` ? /* @__PURE__ */ jsx(Loader2, { className: "size-3 animate-spin" }) : /* @__PURE__ */ jsx(GitCompare, { className: "size-3" }),
21526
+ tr(
21527
+ "fluidgrids.builder.git.compare",
21528
+ "Compare with"
21529
+ ),
21530
+ " ",
21531
+ currentVersion
21532
+ ]
21533
+ }
21534
+ ),
21535
+ /* @__PURE__ */ jsxs(
21536
+ Button$1,
21537
+ {
21538
+ size: "sm",
21539
+ variant: "outline",
21540
+ className: "h-6 gap-1 px-2 text-[11px]",
21541
+ disabled: busy !== null,
21542
+ onClick: () => setConfirm({ kind: "restore", sha: commit.sha }),
21543
+ children: [
21544
+ busy === `restore:${commit.sha}` ? /* @__PURE__ */ jsx(Loader2, { className: "size-3 animate-spin" }) : /* @__PURE__ */ jsx(RotateCcw, { className: "size-3" }),
21545
+ tr(
21546
+ "fluidgrids.builder.git.restore",
21547
+ "Restore as draft"
21548
+ )
21549
+ ]
21550
+ }
21551
+ ),
21552
+ commit.url && /* @__PURE__ */ jsx(
21553
+ Button$1,
21554
+ {
21555
+ asChild: true,
21556
+ size: "sm",
21557
+ variant: "ghost",
21558
+ className: "h-6 gap-1 px-2 text-[11px]",
21559
+ children: /* @__PURE__ */ jsxs(
21560
+ "a",
21561
+ {
21562
+ href: commit.url,
21563
+ target: "_blank",
21564
+ rel: "noopener noreferrer",
21565
+ children: [
21566
+ /* @__PURE__ */ jsx(ExternalLink, { className: "size-3" }),
21567
+ tr(
21568
+ "fluidgrids.builder.git.openCommit",
21569
+ "Open"
21570
+ )
21571
+ ]
21572
+ }
21573
+ )
21574
+ }
21575
+ )
21576
+ ] })
21577
+ ]
21578
+ },
21579
+ commit.sha
21580
+ )) }),
21581
+ comparison && /* @__PURE__ */ jsxs(
21582
+ "div",
21583
+ {
21584
+ className: "mt-3 space-y-2 border-t border-border pt-3",
21585
+ "data-testid": "fluidgrids-git-diff",
21586
+ children: [
21587
+ /* @__PURE__ */ jsxs("p", { className: "text-xs text-muted-foreground", children: [
21588
+ shortSha(comparison.commitSha),
21589
+ " \u2192 ",
21590
+ comparison.version,
21591
+ ":",
21592
+ " ",
21593
+ comparison.entries.length,
21594
+ " ",
21595
+ tr("fluidgrids.builder.git.changes", "changes"),
21596
+ comparison.truncated ? "+" : ""
21597
+ ] }),
21598
+ comparison.entries.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: tr(
21599
+ "fluidgrids.builder.git.noChanges",
21600
+ "The commit matches this version"
21601
+ ) }) : /* @__PURE__ */ jsx("ul", { className: "max-h-64 space-y-1 overflow-y-auto", children: comparison.entries.map((entry) => /* @__PURE__ */ jsxs(
21602
+ "li",
21603
+ {
21604
+ className: "rounded border border-border p-2 text-xs",
21605
+ children: [
21606
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
21607
+ /* @__PURE__ */ jsx(
21608
+ Badge,
21609
+ {
21610
+ variant: entry.kind === "CHANGED" ? "secondary" : entry.kind === "ADDED" ? "default" : "destructive",
21611
+ className: "text-[10px]",
21612
+ children: entry.kind
21613
+ }
21614
+ ),
21615
+ /* @__PURE__ */ jsx("code", { className: "min-w-0 truncate font-mono", children: entry.path })
21616
+ ] }),
21617
+ entry.kind === "CHANGED" && /* @__PURE__ */ jsxs("div", { className: "mt-1 grid gap-1 text-[11px] text-muted-foreground", children: [
21618
+ /* @__PURE__ */ jsxs("span", { className: "truncate", children: [
21619
+ "\u2212 ",
21620
+ formatDiffValue2(entry.before)
21621
+ ] }),
21622
+ /* @__PURE__ */ jsxs("span", { className: "truncate", children: [
21623
+ "+ ",
21624
+ formatDiffValue2(entry.after)
21625
+ ] })
21626
+ ] })
21627
+ ]
21628
+ },
21629
+ `${entry.kind}-${entry.path}`
21630
+ )) })
21631
+ ]
21632
+ }
21633
+ )
21634
+ ] }),
21635
+ /* @__PURE__ */ jsxs("section", { "aria-labelledby": "fg-git-pushes", children: [
21636
+ /* @__PURE__ */ jsx(
21637
+ "h3",
21638
+ {
21639
+ id: "fg-git-pushes",
21640
+ className: "mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",
21641
+ children: tr("fluidgrids.builder.git.pushesTitle", "Pushes")
21642
+ }
21643
+ ),
21644
+ pushes.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: tr(
21645
+ "fluidgrids.builder.git.pushesEmpty",
21646
+ "Nothing was pushed from FluidGrids yet."
21647
+ ) }) : /* @__PURE__ */ jsx("ul", { className: "space-y-1.5", children: pushes.map((item) => /* @__PURE__ */ jsxs(
21648
+ "li",
21649
+ {
21650
+ className: "flex items-start justify-between gap-2 text-xs",
21651
+ "data-testid": "fluidgrids-git-push",
21652
+ children: [
21653
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
21654
+ /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-1 text-foreground", children: [
21655
+ /* @__PURE__ */ jsx(GitCommitHorizontal, { className: "size-3.5 shrink-0 text-muted-foreground" }),
21656
+ /* @__PURE__ */ jsx("span", { className: "font-mono", children: item.version }),
21657
+ item.environment ? ` \u2192 ${item.environment}` : "",
21658
+ /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
21659
+ "\xB7 ",
21660
+ triggerLabel(item.trigger)
21661
+ ] })
21662
+ ] }),
21663
+ /* @__PURE__ */ jsx("p", { className: "truncate text-muted-foreground", children: [
21664
+ shortSha(item.commitSha),
21665
+ nameOf(item.pushedById),
21666
+ relativeTime(item.pushedAt)
21667
+ ].filter(Boolean).join(" \xB7 ") }),
21668
+ item.errorMessage && /* @__PURE__ */ jsx("p", { className: "text-[11px] text-[var(--color-status-error-text)]", children: item.errorMessage })
21669
+ ] }),
21670
+ /* @__PURE__ */ jsx(
21671
+ Badge,
21672
+ {
21673
+ variant: pushStatusVariant(item.status),
21674
+ className: "h-5 shrink-0 px-1.5 py-0 text-[10px]",
21675
+ children: item.status === "PUSHED" ? tr("fluidgrids.builder.git.statusPushed", "Pushed") : item.status === "UNCHANGED" ? tr(
21676
+ "fluidgrids.builder.git.statusUnchanged",
21677
+ "Up to date"
21678
+ ) : tr(
21679
+ "fluidgrids.builder.git.statusFailed",
21680
+ "Failed"
21681
+ )
21682
+ }
21683
+ )
21684
+ ]
21685
+ },
21686
+ item.id
21687
+ )) })
21688
+ ] })
21689
+ ] })
21690
+ ]
21691
+ }
21692
+ ),
21693
+ /* @__PURE__ */ jsx(
21694
+ ConnectionFormDialog,
21695
+ {
21696
+ open: newConnectionOpen,
21697
+ onClose: () => setNewConnectionOpen(false),
21698
+ providerKey: GITHUB_PROVIDER_KEY,
21699
+ defaultName: "GitHub",
21700
+ onConnectionCreated: (created) => {
21701
+ setNewConnectionOpen(false);
21702
+ setForm((prev) => ({ ...prev, connectionId: created.id }));
21703
+ void refetchConnections();
21704
+ }
21705
+ }
21706
+ ),
21707
+ /* @__PURE__ */ jsx(
21708
+ AlertDialog,
21709
+ {
21710
+ open: confirm !== null,
21711
+ onOpenChange: (open) => !open && setConfirm(null),
21712
+ children: /* @__PURE__ */ jsxs(AlertDialogContent, { className: "z-[120]", children: [
21713
+ /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
21714
+ /* @__PURE__ */ jsx(AlertDialogTitle, { children: confirm?.kind === "unlink" ? tr("fluidgrids.builder.git.unlinkTitle", "Unlink repository?") : `${tr("fluidgrids.builder.git.restoreTitle", "Restore commit")} ${confirm?.kind === "restore" ? shortSha(confirm.sha) : ""}` }),
21715
+ /* @__PURE__ */ jsx(AlertDialogDescription, { children: confirm?.kind === "unlink" ? tr(
21716
+ "fluidgrids.builder.git.unlinkBody",
21717
+ "Publishing and promotions stop committing to Git for every workflow in this workspace. Commits already made stay in the repository."
21718
+ ) : tr(
21719
+ "fluidgrids.builder.git.restoreBody",
21720
+ "The workflow file at this commit becomes a new draft version. No existing version changes and nothing is activated."
21721
+ ) })
21722
+ ] }),
21723
+ /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
21724
+ /* @__PURE__ */ jsx(AlertDialogCancel, { children: tr("fluidgrids.builder.git.cancel", "Cancel") }),
21725
+ /* @__PURE__ */ jsx(AlertDialogAction, { onClick: () => void handleConfirm(), children: confirm?.kind === "unlink" ? tr("fluidgrids.builder.git.unlink", "Unlink") : tr("fluidgrids.builder.git.restore", "Restore as draft") })
21726
+ ] })
21727
+ ] })
21728
+ }
21729
+ )
21730
+ ]
21731
+ }
21732
+ );
21733
+ }
20757
21734
 
20758
21735
  // src/builder/lib/ai-draft.ts
20759
21736
  var AI_DRAFT_POLL_INTERVAL_MS = 2500;
@@ -20853,7 +21830,7 @@ function canvasHasWork(nodes) {
20853
21830
  }
20854
21831
 
20855
21832
  // src/builder/hooks/use-ai-workflow-draft.ts
20856
- function messageOf2(error) {
21833
+ function messageOf3(error) {
20857
21834
  return error instanceof Error ? error.message : String(error);
20858
21835
  }
20859
21836
  function useAiWorkflowDraft() {
@@ -20910,7 +21887,7 @@ function useAiWorkflowDraft() {
20910
21887
  setIsGenerating(false);
20911
21888
  } catch (pollError) {
20912
21889
  if (run !== runRef.current) return;
20913
- setError(messageOf2(pollError));
21890
+ setError(messageOf3(pollError));
20914
21891
  setIsGenerating(false);
20915
21892
  }
20916
21893
  },
@@ -20947,7 +21924,7 @@ function useAiWorkflowDraft() {
20947
21924
  );
20948
21925
  } catch (startError) {
20949
21926
  if (run !== runRef.current) return;
20950
- setError(messageOf2(startError));
21927
+ setError(messageOf3(startError));
20951
21928
  setIsGenerating(false);
20952
21929
  }
20953
21930
  },
@@ -21655,6 +22632,7 @@ var FlowBuilder = ({ readOnly = false }) => {
21655
22632
  !isReadOnly && /* @__PURE__ */ jsx(AiDraftPanel, {}),
21656
22633
  /* @__PURE__ */ jsx(VersionHistoryPanel, {}),
21657
22634
  /* @__PURE__ */ jsx(EnvironmentsPanel, {}),
22635
+ /* @__PURE__ */ jsx(GitSyncPanel, {}),
21658
22636
  /* @__PURE__ */ jsx(SaveFlowButton, {}),
21659
22637
  /* @__PURE__ */ jsx(ActivateWorkflowButton, {}),
21660
22638
  /* @__PURE__ */ jsx(
@@ -21677,6 +22655,7 @@ var FlowBuilder = ({ readOnly = false }) => {
21677
22655
  /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1 lg:hidden", children: [
21678
22656
  !isReadOnly && /* @__PURE__ */ jsx(AiDraftPanel, { compact: true }),
21679
22657
  /* @__PURE__ */ jsx(EnvironmentsPanel, { compact: true }),
22658
+ /* @__PURE__ */ jsx(GitSyncPanel, { compact: true }),
21680
22659
  /* @__PURE__ */ jsxs(DropdownMenu, { children: [
21681
22660
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
21682
22661
  Button$1,