@open-mercato/core 0.6.3-develop.3894.1.352abf4240 → 0.6.3
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/.turbo/turbo-build.log +1 -1
- package/dist/global.d.js +1 -0
- package/dist/global.d.js.map +7 -0
- package/dist/modules/catalog/commands/variants.js +11 -5
- package/dist/modules/catalog/commands/variants.js.map +2 -2
- package/dist/modules/customers/backend/customers/deals/create/page.js +3 -61
- package/dist/modules/customers/backend/customers/deals/create/page.js.map +2 -2
- package/dist/modules/customers/components/detail/DealForm.js +2 -0
- package/dist/modules/customers/components/detail/DealForm.js.map +2 -2
- package/dist/modules/customers/components/detail/create/CreateDealForm.js +233 -0
- package/dist/modules/customers/components/detail/create/CreateDealForm.js.map +7 -0
- package/dist/modules/customers/components/detail/create/DealAssociationsField.js +209 -0
- package/dist/modules/customers/components/detail/create/DealAssociationsField.js.map +7 -0
- package/dist/modules/customers/components/detail/create/DealAssociationsSection.js +67 -0
- package/dist/modules/customers/components/detail/create/DealAssociationsSection.js.map +7 -0
- package/dist/modules/customers/components/detail/create/DealCreateSidebar.js +73 -0
- package/dist/modules/customers/components/detail/create/DealCreateSidebar.js.map +7 -0
- package/dist/modules/customers/components/detail/create/DealCurrencyField.js +92 -0
- package/dist/modules/customers/components/detail/create/DealCurrencyField.js.map +7 -0
- package/dist/modules/customers/components/detail/create/DealCustomAttributes.js +81 -0
- package/dist/modules/customers/components/detail/create/DealCustomAttributes.js.map +7 -0
- package/dist/modules/customers/components/detail/create/DealDetailsFields.js +171 -0
- package/dist/modules/customers/components/detail/create/DealDetailsFields.js.map +7 -0
- package/dist/modules/customers/components/detail/create/DealFormField.js +24 -0
- package/dist/modules/customers/components/detail/create/DealFormField.js.map +7 -0
- package/dist/modules/customers/components/detail/create/DealSectionCard.js +29 -0
- package/dist/modules/customers/components/detail/create/DealSectionCard.js.map +7 -0
- package/dist/modules/customers/components/detail/create/DealTipsCard.js +19 -0
- package/dist/modules/customers/components/detail/create/DealTipsCard.js.map +7 -0
- package/dist/modules/customers/components/detail/create/PipelineSelect.js +41 -0
- package/dist/modules/customers/components/detail/create/PipelineSelect.js.map +7 -0
- package/dist/modules/customers/components/detail/create/PipelineStageSelect.js +49 -0
- package/dist/modules/customers/components/detail/create/PipelineStageSelect.js.map +7 -0
- package/dist/modules/customers/components/detail/create/SuffixInput.js +21 -0
- package/dist/modules/customers/components/detail/create/SuffixInput.js.map +7 -0
- package/dist/modules/customers/components/detail/create/dealCustomFieldControl.js +270 -0
- package/dist/modules/customers/components/detail/create/dealCustomFieldControl.js.map +7 -0
- package/dist/modules/customers/components/detail/create/dealFormTypes.js +17 -0
- package/dist/modules/customers/components/detail/create/dealFormTypes.js.map +7 -0
- package/dist/modules/customers/components/detail/create/dealNumericInput.js +16 -0
- package/dist/modules/customers/components/detail/create/dealNumericInput.js.map +7 -0
- package/dist/modules/customers/components/detail/create/useDealCustomFields.js +93 -0
- package/dist/modules/customers/components/detail/create/useDealCustomFields.js.map +7 -0
- package/dist/modules/customers/components/detail/create/useDealPipelines.js +59 -0
- package/dist/modules/customers/components/detail/create/useDealPipelines.js.map +7 -0
- package/dist/modules/customers/components/formConfig.js +4 -2
- package/dist/modules/customers/components/formConfig.js.map +2 -2
- package/dist/modules/dictionaries/components/DictionaryEntrySelect.js +5 -2
- package/dist/modules/dictionaries/components/DictionaryEntrySelect.js.map +2 -2
- package/dist/modules/feature_toggles/lib/feature-flag-check.js +13 -5
- package/dist/modules/feature_toggles/lib/feature-flag-check.js.map +2 -2
- package/dist/modules/query_index/subscribers/coverage_refresh.js +6 -1
- package/dist/modules/query_index/subscribers/coverage_refresh.js.map +2 -2
- package/dist/modules/sync_excel/widgets/injection/upload-config/target-options.js +33 -5
- package/dist/modules/sync_excel/widgets/injection/upload-config/target-options.js.map +2 -2
- package/dist/modules/workflows/components/WorkflowGraph.js +29 -186
- package/dist/modules/workflows/components/WorkflowGraph.js.map +2 -2
- package/dist/modules/workflows/components/WorkflowGraphImpl.js +196 -0
- package/dist/modules/workflows/components/WorkflowGraphImpl.js.map +7 -0
- package/package.json +8 -9
- package/src/global.d.ts +9 -0
- package/src/modules/catalog/commands/variants.ts +14 -5
- package/src/modules/customers/backend/customers/deals/create/page.tsx +3 -64
- package/src/modules/customers/components/detail/DealForm.tsx +2 -0
- package/src/modules/customers/components/detail/create/CreateDealForm.tsx +254 -0
- package/src/modules/customers/components/detail/create/DealAssociationsField.tsx +253 -0
- package/src/modules/customers/components/detail/create/DealAssociationsSection.tsx +72 -0
- package/src/modules/customers/components/detail/create/DealCreateSidebar.tsx +79 -0
- package/src/modules/customers/components/detail/create/DealCurrencyField.tsx +108 -0
- package/src/modules/customers/components/detail/create/DealCustomAttributes.tsx +118 -0
- package/src/modules/customers/components/detail/create/DealDetailsFields.tsx +171 -0
- package/src/modules/customers/components/detail/create/DealFormField.tsx +39 -0
- package/src/modules/customers/components/detail/create/DealSectionCard.tsx +40 -0
- package/src/modules/customers/components/detail/create/DealTipsCard.tsx +26 -0
- package/src/modules/customers/components/detail/create/PipelineSelect.tsx +55 -0
- package/src/modules/customers/components/detail/create/PipelineStageSelect.tsx +70 -0
- package/src/modules/customers/components/detail/create/SuffixInput.tsx +20 -0
- package/src/modules/customers/components/detail/create/dealCustomFieldControl.tsx +310 -0
- package/src/modules/customers/components/detail/create/dealFormTypes.ts +29 -0
- package/src/modules/customers/components/detail/create/dealNumericInput.ts +20 -0
- package/src/modules/customers/components/detail/create/useDealCustomFields.ts +118 -0
- package/src/modules/customers/components/detail/create/useDealPipelines.ts +80 -0
- package/src/modules/customers/components/formConfig.tsx +3 -0
- package/src/modules/customers/i18n/de.json +26 -0
- package/src/modules/customers/i18n/en.json +26 -0
- package/src/modules/customers/i18n/es.json +26 -0
- package/src/modules/customers/i18n/pl.json +26 -0
- package/src/modules/dictionaries/components/DictionaryEntrySelect.tsx +12 -1
- package/src/modules/feature_toggles/lib/feature-flag-check.ts +14 -4
- package/src/modules/query_index/subscribers/coverage_refresh.ts +7 -1
- package/src/modules/resources/i18n/de.json +1 -0
- package/src/modules/resources/i18n/en.json +1 -0
- package/src/modules/resources/i18n/es.json +1 -0
- package/src/modules/resources/i18n/pl.json +1 -0
- package/src/modules/sales/i18n/de.json +2 -0
- package/src/modules/sales/i18n/en.json +2 -0
- package/src/modules/sales/i18n/es.json +2 -0
- package/src/modules/sales/i18n/pl.json +2 -0
- package/src/modules/sync_excel/widgets/injection/upload-config/target-options.ts +40 -5
- package/src/modules/workflows/components/WorkflowGraph.tsx +39 -235
- package/src/modules/workflows/components/WorkflowGraphImpl.tsx +233 -0
|
@@ -1,193 +1,36 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
onEdgesChange: onEdgesChangeProp,
|
|
29
|
-
onNodeClick: onNodeClickProp,
|
|
30
|
-
onEdgeClick: onEdgeClickProp,
|
|
31
|
-
onConnect: onConnectProp,
|
|
32
|
-
editable = false,
|
|
33
|
-
className = "",
|
|
34
|
-
height = "600px"
|
|
35
|
-
}) {
|
|
36
|
-
const t = useT();
|
|
37
|
-
const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);
|
|
38
|
-
const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);
|
|
39
|
-
const { resolvedTheme } = useTheme();
|
|
40
|
-
const isDark = resolvedTheme === "dark";
|
|
41
|
-
const backgroundDotColor = isDark ? "#374151" : "#e5e7eb";
|
|
42
|
-
const [isCompactViewport, setIsCompactViewport] = useState(false);
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (typeof window === "undefined") return;
|
|
45
|
-
const mediaQuery = window.matchMedia("(max-width: 1279px)");
|
|
46
|
-
const updateViewportMode = () => setIsCompactViewport(mediaQuery.matches);
|
|
47
|
-
updateViewportMode();
|
|
48
|
-
mediaQuery.addEventListener("change", updateViewportMode);
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import dynamic from "next/dynamic";
|
|
5
|
+
import { Spinner } from "@open-mercato/ui/primitives/spinner";
|
|
6
|
+
const WorkflowGraphImpl = dynamic(() => import("./WorkflowGraphImpl.js"), {
|
|
7
|
+
ssr: false,
|
|
8
|
+
loading: () => null
|
|
9
|
+
});
|
|
10
|
+
function WorkflowGraphPlaceholder({ height }) {
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"div",
|
|
13
|
+
{
|
|
14
|
+
className: "workflow-graph-container flex items-center justify-center rounded-lg border border-border bg-muted/30",
|
|
15
|
+
style: { height },
|
|
16
|
+
children: /* @__PURE__ */ jsx(Spinner, { className: "h-6 w-6 text-muted-foreground" })
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
function WorkflowGraph(props) {
|
|
21
|
+
const { height = "600px" } = props;
|
|
22
|
+
const [isImplReady, setIsImplReady] = React.useState(false);
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
let cancelled = false;
|
|
25
|
+
void import("./WorkflowGraphImpl.js").then(() => {
|
|
26
|
+
if (!cancelled) setIsImplReady(true);
|
|
27
|
+
});
|
|
49
28
|
return () => {
|
|
50
|
-
|
|
29
|
+
cancelled = true;
|
|
51
30
|
};
|
|
52
31
|
}, []);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}, [initialNodes, setNodes]);
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
setEdges(initialEdges);
|
|
58
|
-
}, [initialEdges, setEdges]);
|
|
59
|
-
const onConnect = useCallback(
|
|
60
|
-
(connection) => {
|
|
61
|
-
if (onConnectProp) {
|
|
62
|
-
onConnectProp(connection);
|
|
63
|
-
} else {
|
|
64
|
-
const newEdge = {
|
|
65
|
-
...connection,
|
|
66
|
-
type: "workflowTransition",
|
|
67
|
-
animated: false,
|
|
68
|
-
markerEnd: {
|
|
69
|
-
type: MarkerType.ArrowClosed,
|
|
70
|
-
width: 16,
|
|
71
|
-
height: 16,
|
|
72
|
-
color: "#9ca3af"
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
setEdges((eds) => addEdge(newEdge, eds));
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
[setEdges, onConnectProp]
|
|
79
|
-
);
|
|
80
|
-
const handleNodesChange = useCallback(
|
|
81
|
-
(changes) => {
|
|
82
|
-
onNodesChange(changes);
|
|
83
|
-
if (onNodesChangeProp) {
|
|
84
|
-
onNodesChangeProp(changes);
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
[onNodesChange, onNodesChangeProp]
|
|
88
|
-
);
|
|
89
|
-
const handleEdgesChange = useCallback(
|
|
90
|
-
(changes) => {
|
|
91
|
-
onEdgesChange(changes);
|
|
92
|
-
if (onEdgesChangeProp) {
|
|
93
|
-
onEdgesChangeProp(changes);
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
[onEdgesChange, onEdgesChangeProp]
|
|
97
|
-
);
|
|
98
|
-
const nodeTypes = useMemo(
|
|
99
|
-
() => ({
|
|
100
|
-
start: StartNode,
|
|
101
|
-
end: EndNode,
|
|
102
|
-
userTask: UserTaskNode,
|
|
103
|
-
automated: AutomatedNode,
|
|
104
|
-
subWorkflow: SubWorkflowNode,
|
|
105
|
-
waitForSignal: WaitForSignalNode,
|
|
106
|
-
waitForTimer: WaitForTimerNode
|
|
107
|
-
}),
|
|
108
|
-
[]
|
|
109
|
-
);
|
|
110
|
-
const edgeTypes = useMemo(
|
|
111
|
-
() => ({
|
|
112
|
-
workflowTransition: WorkflowTransitionEdge
|
|
113
|
-
}),
|
|
114
|
-
[]
|
|
115
|
-
);
|
|
116
|
-
return /* @__PURE__ */ jsx("div", { className: `workflow-graph-container ${className}`, style: { height }, children: /* @__PURE__ */ jsxs(
|
|
117
|
-
ReactFlow,
|
|
118
|
-
{
|
|
119
|
-
nodes,
|
|
120
|
-
edges,
|
|
121
|
-
nodeTypes,
|
|
122
|
-
edgeTypes,
|
|
123
|
-
onNodesChange: handleNodesChange,
|
|
124
|
-
onEdgesChange: handleEdgesChange,
|
|
125
|
-
onConnect: editable ? onConnect : void 0,
|
|
126
|
-
onNodeClick: onNodeClickProp,
|
|
127
|
-
onEdgeClick: onEdgeClickProp,
|
|
128
|
-
connectionMode: ConnectionMode.Loose,
|
|
129
|
-
fitView: true,
|
|
130
|
-
fitViewOptions: {
|
|
131
|
-
padding: 0.2,
|
|
132
|
-
maxZoom: isCompactViewport ? 0.9 : 1
|
|
133
|
-
},
|
|
134
|
-
minZoom: 0.1,
|
|
135
|
-
maxZoom: 2,
|
|
136
|
-
defaultEdgeOptions: {
|
|
137
|
-
type: "workflowTransition",
|
|
138
|
-
animated: false,
|
|
139
|
-
markerEnd: {
|
|
140
|
-
type: MarkerType.ArrowClosed,
|
|
141
|
-
width: 16,
|
|
142
|
-
height: 16,
|
|
143
|
-
color: "#9ca3af"
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
nodesDraggable: editable,
|
|
147
|
-
nodesConnectable: editable,
|
|
148
|
-
elementsSelectable: editable,
|
|
149
|
-
proOptions: { hideAttribution: true },
|
|
150
|
-
children: [
|
|
151
|
-
/* @__PURE__ */ jsx(
|
|
152
|
-
Background,
|
|
153
|
-
{
|
|
154
|
-
variant: BackgroundVariant.Dots,
|
|
155
|
-
gap: 16,
|
|
156
|
-
size: 1,
|
|
157
|
-
color: backgroundDotColor
|
|
158
|
-
}
|
|
159
|
-
),
|
|
160
|
-
/* @__PURE__ */ jsx(
|
|
161
|
-
Controls,
|
|
162
|
-
{
|
|
163
|
-
showZoom: true,
|
|
164
|
-
showFitView: true,
|
|
165
|
-
showInteractive: false,
|
|
166
|
-
position: isCompactViewport ? "bottom-right" : "top-right",
|
|
167
|
-
className: `!bg-card !border-border !shadow-md [&>button]:!bg-card [&>button]:!border-border [&>button]:!fill-foreground [&>button:hover]:!bg-muted ${isCompactViewport ? "scale-90 origin-bottom-right" : ""}`
|
|
168
|
-
}
|
|
169
|
-
),
|
|
170
|
-
!isCompactViewport && /* @__PURE__ */ jsx(
|
|
171
|
-
MiniMap,
|
|
172
|
-
{
|
|
173
|
-
nodeStrokeWidth: 3,
|
|
174
|
-
nodeColor: (node) => {
|
|
175
|
-
const status = node.data?.status || "not_started";
|
|
176
|
-
return STATUS_COLORS[status]?.hex || STATUS_COLORS.not_started.hex;
|
|
177
|
-
},
|
|
178
|
-
maskColor: "rgba(0, 0, 0, 0.1)",
|
|
179
|
-
position: "bottom-left",
|
|
180
|
-
className: "!bg-card !border !border-border !rounded-lg"
|
|
181
|
-
}
|
|
182
|
-
),
|
|
183
|
-
!editable && !isCompactViewport && /* @__PURE__ */ jsx(Panel, { position: "top-left", style: { margin: 10 }, children: /* @__PURE__ */ jsx("div", { className: "bg-card rounded-lg shadow-sm border border-border px-4 py-2", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground font-medium", children: t("workflows.graph.visualization") }) }) }),
|
|
184
|
-
editable && !isCompactViewport && /* @__PURE__ */ jsx(Panel, { position: "top-left", style: { margin: 10 }, children: /* @__PURE__ */ jsxs(Alert, { variant: "info", className: "max-w-sm", children: [
|
|
185
|
-
/* @__PURE__ */ jsx(Edit3, { className: "size-4" }),
|
|
186
|
-
/* @__PURE__ */ jsx(AlertDescription, { className: "font-medium", children: t("workflows.graph.editModeInfo") })
|
|
187
|
-
] }) })
|
|
188
|
-
]
|
|
189
|
-
}
|
|
190
|
-
) });
|
|
32
|
+
if (!isImplReady) return /* @__PURE__ */ jsx(WorkflowGraphPlaceholder, { height });
|
|
33
|
+
return /* @__PURE__ */ jsx(WorkflowGraphImpl, { ...props });
|
|
191
34
|
}
|
|
192
35
|
function WorkflowGraphReadOnly({
|
|
193
36
|
nodes,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/workflows/components/WorkflowGraph.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport dynamic from 'next/dynamic'\nimport type { Node, Edge, Connection } from '@xyflow/react'\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\n\nexport interface WorkflowGraphProps {\n initialNodes?: Node[]\n initialEdges?: Edge[]\n onNodesChange?: (changes: any[]) => void\n onEdgesChange?: (changes: any[]) => void\n onNodeClick?: (event: React.MouseEvent, node: Node) => void\n onEdgeClick?: (event: React.MouseEvent, edge: Edge) => void\n onConnect?: (connection: Connection) => void\n editable?: boolean\n className?: string\n height?: string\n}\n\nconst WorkflowGraphImpl = dynamic(() => import('./WorkflowGraphImpl'), {\n ssr: false,\n loading: () => null,\n})\n\nfunction WorkflowGraphPlaceholder({ height }: { height: string }) {\n return (\n <div\n className=\"workflow-graph-container flex items-center justify-center rounded-lg border border-border bg-muted/30\"\n style={{ height }}\n >\n <Spinner className=\"h-6 w-6 text-muted-foreground\" />\n </div>\n )\n}\n\n/**\n * WorkflowGraph \u2014 lazy-loaded ReactFlow wrapper.\n *\n * @xyflow/react is loaded via next/dynamic({ ssr: false }) so the ~12 MB\n * package only enters the Turbopack module graph when this component\n * actually renders.\n */\nexport function WorkflowGraph(props: WorkflowGraphProps) {\n const { height = '600px' } = props\n // Track impl-chunk readiness so the loading placeholder respects the\n // caller's `height` prop (next/dynamic's `loading` cannot access props).\n // The browser caches the module, so the duplicate `import()` is free.\n const [isImplReady, setIsImplReady] = React.useState(false)\n React.useEffect(() => {\n let cancelled = false\n void import('./WorkflowGraphImpl').then(() => {\n if (!cancelled) setIsImplReady(true)\n })\n return () => {\n cancelled = true\n }\n }, [])\n\n if (!isImplReady) return <WorkflowGraphPlaceholder height={height} />\n return <WorkflowGraphImpl {...props} />\n}\n\n/**\n * WorkflowGraphReadOnly \u2014 read-only viewer that reuses WorkflowGraph.\n */\nexport function WorkflowGraphReadOnly({\n nodes,\n edges,\n className = '',\n height = '500px',\n}: {\n nodes: Node[]\n edges: Edge[]\n className?: string\n height?: string\n}) {\n return (\n <WorkflowGraph\n initialNodes={nodes}\n initialEdges={edges}\n editable={false}\n className={className}\n height={height}\n />\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA+BM;AA7BN,YAAY,WAAW;AACvB,OAAO,aAAa;AAEpB,SAAS,eAAe;AAexB,MAAM,oBAAoB,QAAQ,MAAM,OAAO,qBAAqB,GAAG;AAAA,EACrE,KAAK;AAAA,EACL,SAAS,MAAM;AACjB,CAAC;AAED,SAAS,yBAAyB,EAAE,OAAO,GAAuB;AAChE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,OAAO;AAAA,MAEhB,8BAAC,WAAQ,WAAU,iCAAgC;AAAA;AAAA,EACrD;AAEJ;AASO,SAAS,cAAc,OAA2B;AACvD,QAAM,EAAE,SAAS,QAAQ,IAAI;AAI7B,QAAM,CAAC,aAAa,cAAc,IAAI,MAAM,SAAS,KAAK;AAC1D,QAAM,UAAU,MAAM;AACpB,QAAI,YAAY;AAChB,SAAK,OAAO,qBAAqB,EAAE,KAAK,MAAM;AAC5C,UAAI,CAAC,UAAW,gBAAe,IAAI;AAAA,IACrC,CAAC;AACD,WAAO,MAAM;AACX,kBAAY;AAAA,IACd;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,MAAI,CAAC,YAAa,QAAO,oBAAC,4BAAyB,QAAgB;AACnE,SAAO,oBAAC,qBAAmB,GAAG,OAAO;AACvC;AAKO,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,SAAS;AACX,GAKG;AACD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,cAAc;AAAA,MACd,cAAc;AAAA,MACd,UAAU;AAAA,MACV;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import "@xyflow/react/dist/style.css";
|
|
4
|
+
import { useCallback, useMemo, useEffect, useState } from "react";
|
|
5
|
+
import {
|
|
6
|
+
ReactFlow,
|
|
7
|
+
Controls,
|
|
8
|
+
Background,
|
|
9
|
+
BackgroundVariant,
|
|
10
|
+
MiniMap,
|
|
11
|
+
Panel,
|
|
12
|
+
useNodesState,
|
|
13
|
+
useEdgesState,
|
|
14
|
+
addEdge,
|
|
15
|
+
ConnectionMode,
|
|
16
|
+
MarkerType
|
|
17
|
+
} from "@xyflow/react";
|
|
18
|
+
import { StartNode, EndNode, UserTaskNode, AutomatedNode, SubWorkflowNode, WaitForSignalNode, WaitForTimerNode } from "./nodes/index.js";
|
|
19
|
+
import { WorkflowTransitionEdge } from "./WorkflowTransitionEdge.js";
|
|
20
|
+
import { STATUS_COLORS } from "../lib/status-colors.js";
|
|
21
|
+
import { Alert, AlertDescription } from "@open-mercato/ui/primitives/alert";
|
|
22
|
+
import { Edit3 } from "lucide-react";
|
|
23
|
+
import { useTheme } from "@open-mercato/ui/theme";
|
|
24
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
25
|
+
function WorkflowGraphImpl({
|
|
26
|
+
initialNodes = [],
|
|
27
|
+
initialEdges = [],
|
|
28
|
+
onNodesChange: onNodesChangeProp,
|
|
29
|
+
onEdgesChange: onEdgesChangeProp,
|
|
30
|
+
onNodeClick: onNodeClickProp,
|
|
31
|
+
onEdgeClick: onEdgeClickProp,
|
|
32
|
+
onConnect: onConnectProp,
|
|
33
|
+
editable = false,
|
|
34
|
+
className = "",
|
|
35
|
+
height = "600px"
|
|
36
|
+
}) {
|
|
37
|
+
const t = useT();
|
|
38
|
+
const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);
|
|
39
|
+
const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);
|
|
40
|
+
const { resolvedTheme } = useTheme();
|
|
41
|
+
const isDark = resolvedTheme === "dark";
|
|
42
|
+
const backgroundDotColor = isDark ? "#374151" : "#e5e7eb";
|
|
43
|
+
const [isCompactViewport, setIsCompactViewport] = useState(false);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (typeof window === "undefined") return;
|
|
46
|
+
const mediaQuery = window.matchMedia("(max-width: 1279px)");
|
|
47
|
+
const updateViewportMode = () => setIsCompactViewport(mediaQuery.matches);
|
|
48
|
+
updateViewportMode();
|
|
49
|
+
mediaQuery.addEventListener("change", updateViewportMode);
|
|
50
|
+
return () => {
|
|
51
|
+
mediaQuery.removeEventListener("change", updateViewportMode);
|
|
52
|
+
};
|
|
53
|
+
}, []);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
setNodes(initialNodes);
|
|
56
|
+
}, [initialNodes, setNodes]);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
setEdges(initialEdges);
|
|
59
|
+
}, [initialEdges, setEdges]);
|
|
60
|
+
const onConnect = useCallback(
|
|
61
|
+
(connection) => {
|
|
62
|
+
if (onConnectProp) {
|
|
63
|
+
onConnectProp(connection);
|
|
64
|
+
} else {
|
|
65
|
+
const newEdge = {
|
|
66
|
+
...connection,
|
|
67
|
+
type: "workflowTransition",
|
|
68
|
+
animated: false,
|
|
69
|
+
markerEnd: {
|
|
70
|
+
type: MarkerType.ArrowClosed,
|
|
71
|
+
width: 16,
|
|
72
|
+
height: 16,
|
|
73
|
+
color: "#9ca3af"
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
setEdges((eds) => addEdge(newEdge, eds));
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
[setEdges, onConnectProp]
|
|
80
|
+
);
|
|
81
|
+
const handleNodesChange = useCallback(
|
|
82
|
+
(changes) => {
|
|
83
|
+
onNodesChange(changes);
|
|
84
|
+
if (onNodesChangeProp) {
|
|
85
|
+
onNodesChangeProp(changes);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
[onNodesChange, onNodesChangeProp]
|
|
89
|
+
);
|
|
90
|
+
const handleEdgesChange = useCallback(
|
|
91
|
+
(changes) => {
|
|
92
|
+
onEdgesChange(changes);
|
|
93
|
+
if (onEdgesChangeProp) {
|
|
94
|
+
onEdgesChangeProp(changes);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
[onEdgesChange, onEdgesChangeProp]
|
|
98
|
+
);
|
|
99
|
+
const nodeTypes = useMemo(
|
|
100
|
+
() => ({
|
|
101
|
+
start: StartNode,
|
|
102
|
+
end: EndNode,
|
|
103
|
+
userTask: UserTaskNode,
|
|
104
|
+
automated: AutomatedNode,
|
|
105
|
+
subWorkflow: SubWorkflowNode,
|
|
106
|
+
waitForSignal: WaitForSignalNode,
|
|
107
|
+
waitForTimer: WaitForTimerNode
|
|
108
|
+
}),
|
|
109
|
+
[]
|
|
110
|
+
);
|
|
111
|
+
const edgeTypes = useMemo(
|
|
112
|
+
() => ({
|
|
113
|
+
workflowTransition: WorkflowTransitionEdge
|
|
114
|
+
}),
|
|
115
|
+
[]
|
|
116
|
+
);
|
|
117
|
+
return /* @__PURE__ */ jsx("div", { className: `workflow-graph-container ${className}`, style: { height }, children: /* @__PURE__ */ jsxs(
|
|
118
|
+
ReactFlow,
|
|
119
|
+
{
|
|
120
|
+
nodes,
|
|
121
|
+
edges,
|
|
122
|
+
nodeTypes,
|
|
123
|
+
edgeTypes,
|
|
124
|
+
onNodesChange: handleNodesChange,
|
|
125
|
+
onEdgesChange: handleEdgesChange,
|
|
126
|
+
onConnect: editable ? onConnect : void 0,
|
|
127
|
+
onNodeClick: onNodeClickProp,
|
|
128
|
+
onEdgeClick: onEdgeClickProp,
|
|
129
|
+
connectionMode: ConnectionMode.Loose,
|
|
130
|
+
fitView: true,
|
|
131
|
+
fitViewOptions: {
|
|
132
|
+
padding: 0.2,
|
|
133
|
+
maxZoom: isCompactViewport ? 0.9 : 1
|
|
134
|
+
},
|
|
135
|
+
minZoom: 0.1,
|
|
136
|
+
maxZoom: 2,
|
|
137
|
+
defaultEdgeOptions: {
|
|
138
|
+
type: "workflowTransition",
|
|
139
|
+
animated: false,
|
|
140
|
+
markerEnd: {
|
|
141
|
+
type: MarkerType.ArrowClosed,
|
|
142
|
+
width: 16,
|
|
143
|
+
height: 16,
|
|
144
|
+
color: "#9ca3af"
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
nodesDraggable: editable,
|
|
148
|
+
nodesConnectable: editable,
|
|
149
|
+
elementsSelectable: editable,
|
|
150
|
+
proOptions: { hideAttribution: true },
|
|
151
|
+
children: [
|
|
152
|
+
/* @__PURE__ */ jsx(
|
|
153
|
+
Background,
|
|
154
|
+
{
|
|
155
|
+
variant: BackgroundVariant.Dots,
|
|
156
|
+
gap: 16,
|
|
157
|
+
size: 1,
|
|
158
|
+
color: backgroundDotColor
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
/* @__PURE__ */ jsx(
|
|
162
|
+
Controls,
|
|
163
|
+
{
|
|
164
|
+
showZoom: true,
|
|
165
|
+
showFitView: true,
|
|
166
|
+
showInteractive: false,
|
|
167
|
+
position: isCompactViewport ? "bottom-right" : "top-right",
|
|
168
|
+
className: `!bg-card !border-border !shadow-md [&>button]:!bg-card [&>button]:!border-border [&>button]:!fill-foreground [&>button:hover]:!bg-muted ${isCompactViewport ? "scale-90 origin-bottom-right" : ""}`
|
|
169
|
+
}
|
|
170
|
+
),
|
|
171
|
+
!isCompactViewport && /* @__PURE__ */ jsx(
|
|
172
|
+
MiniMap,
|
|
173
|
+
{
|
|
174
|
+
nodeStrokeWidth: 3,
|
|
175
|
+
nodeColor: (node) => {
|
|
176
|
+
const status = node.data?.status || "not_started";
|
|
177
|
+
return STATUS_COLORS[status]?.hex || STATUS_COLORS.not_started.hex;
|
|
178
|
+
},
|
|
179
|
+
maskColor: "rgba(0, 0, 0, 0.1)",
|
|
180
|
+
position: "bottom-left",
|
|
181
|
+
className: "!bg-card !border !border-border !rounded-lg"
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
!editable && !isCompactViewport && /* @__PURE__ */ jsx(Panel, { position: "top-left", style: { margin: 10 }, children: /* @__PURE__ */ jsx("div", { className: "bg-card rounded-lg shadow-sm border border-border px-4 py-2", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground font-medium", children: t("workflows.graph.visualization") }) }) }),
|
|
185
|
+
editable && !isCompactViewport && /* @__PURE__ */ jsx(Panel, { position: "top-left", style: { margin: 10 }, children: /* @__PURE__ */ jsxs(Alert, { variant: "info", className: "max-w-sm", children: [
|
|
186
|
+
/* @__PURE__ */ jsx(Edit3, { className: "size-4" }),
|
|
187
|
+
/* @__PURE__ */ jsx(AlertDescription, { className: "font-medium", children: t("workflows.graph.editModeInfo") })
|
|
188
|
+
] }) })
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
) });
|
|
192
|
+
}
|
|
193
|
+
export {
|
|
194
|
+
WorkflowGraphImpl as default
|
|
195
|
+
};
|
|
196
|
+
//# sourceMappingURL=WorkflowGraphImpl.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/workflows/components/WorkflowGraphImpl.tsx"],
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport '@xyflow/react/dist/style.css'\n\nimport { useCallback, useMemo, useEffect, useState } from 'react'\nimport {\n ReactFlow,\n Node,\n Edge,\n Controls,\n Background,\n BackgroundVariant,\n MiniMap,\n Panel,\n useNodesState,\n useEdgesState,\n addEdge,\n Connection,\n ConnectionMode,\n MarkerType,\n} from '@xyflow/react'\nimport {StartNode, EndNode, UserTaskNode, AutomatedNode, SubWorkflowNode, WaitForSignalNode, WaitForTimerNode} from './nodes'\nimport { WorkflowTransitionEdge } from './WorkflowTransitionEdge'\nimport { STATUS_COLORS } from '../lib/status-colors'\nimport { Alert, AlertDescription } from '@open-mercato/ui/primitives/alert'\nimport { Edit3 } from 'lucide-react'\nimport { useTheme } from '@open-mercato/ui/theme'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\n\nexport interface WorkflowGraphImplProps {\n initialNodes?: Node[]\n initialEdges?: Edge[]\n onNodesChange?: (changes: any[]) => void\n onEdgesChange?: (changes: any[]) => void\n onNodeClick?: (event: React.MouseEvent, node: Node) => void\n onEdgeClick?: (event: React.MouseEvent, edge: Edge) => void\n onConnect?: (connection: Connection) => void\n editable?: boolean\n className?: string\n height?: string\n}\n\nexport default function WorkflowGraphImpl({\n initialNodes = [],\n initialEdges = [],\n onNodesChange: onNodesChangeProp,\n onEdgesChange: onEdgesChangeProp,\n onNodeClick: onNodeClickProp,\n onEdgeClick: onEdgeClickProp,\n onConnect: onConnectProp,\n editable = false,\n className = '',\n height = '600px',\n}: WorkflowGraphImplProps) {\n const t = useT()\n const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes)\n const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges)\n\n const { resolvedTheme } = useTheme()\n const isDark = resolvedTheme === 'dark'\n const backgroundDotColor = isDark ? '#374151' : '#e5e7eb'\n const [isCompactViewport, setIsCompactViewport] = useState(false)\n\n useEffect(() => {\n if (typeof window === 'undefined') return\n const mediaQuery = window.matchMedia('(max-width: 1279px)')\n const updateViewportMode = () => setIsCompactViewport(mediaQuery.matches)\n\n updateViewportMode()\n mediaQuery.addEventListener('change', updateViewportMode)\n\n return () => {\n mediaQuery.removeEventListener('change', updateViewportMode)\n }\n }, [])\n\n useEffect(() => {\n setNodes(initialNodes)\n }, [initialNodes, setNodes])\n\n useEffect(() => {\n setEdges(initialEdges)\n }, [initialEdges, setEdges])\n\n const onConnect = useCallback(\n (connection: Connection) => {\n if (onConnectProp) {\n onConnectProp(connection)\n } else {\n const newEdge = {\n ...connection,\n type: 'workflowTransition',\n animated: false,\n markerEnd: {\n type: MarkerType.ArrowClosed,\n width: 16,\n height: 16,\n color: '#9ca3af',\n },\n }\n setEdges((eds) => addEdge(newEdge, eds))\n }\n },\n [setEdges, onConnectProp]\n )\n\n const handleNodesChange = useCallback(\n (changes: any) => {\n onNodesChange(changes)\n if (onNodesChangeProp) {\n onNodesChangeProp(changes)\n }\n },\n [onNodesChange, onNodesChangeProp]\n )\n\n const handleEdgesChange = useCallback(\n (changes: any) => {\n onEdgesChange(changes)\n if (onEdgesChangeProp) {\n onEdgesChangeProp(changes)\n }\n },\n [onEdgesChange, onEdgesChangeProp]\n )\n\n const nodeTypes = useMemo(\n () => ({\n start: StartNode,\n end: EndNode,\n userTask: UserTaskNode,\n automated: AutomatedNode,\n subWorkflow: SubWorkflowNode,\n waitForSignal: WaitForSignalNode,\n waitForTimer: WaitForTimerNode,\n }),\n []\n )\n\n const edgeTypes = useMemo(\n () => ({\n workflowTransition: WorkflowTransitionEdge,\n }),\n []\n )\n\n return (\n <div className={`workflow-graph-container ${className}`} style={{ height }}>\n <ReactFlow\n nodes={nodes}\n edges={edges}\n nodeTypes={nodeTypes}\n edgeTypes={edgeTypes}\n onNodesChange={handleNodesChange}\n onEdgesChange={handleEdgesChange}\n onConnect={editable ? onConnect : undefined}\n onNodeClick={onNodeClickProp}\n onEdgeClick={onEdgeClickProp}\n connectionMode={ConnectionMode.Loose}\n fitView\n fitViewOptions={{\n padding: 0.2,\n maxZoom: isCompactViewport ? 0.9 : 1,\n }}\n minZoom={0.1}\n maxZoom={2}\n defaultEdgeOptions={{\n type: 'workflowTransition',\n animated: false,\n markerEnd: {\n type: MarkerType.ArrowClosed,\n width: 16,\n height: 16,\n color: '#9ca3af',\n },\n }}\n nodesDraggable={editable}\n nodesConnectable={editable}\n elementsSelectable={editable}\n proOptions={{ hideAttribution: true }}\n >\n <Background\n variant={BackgroundVariant.Dots}\n gap={16}\n size={1}\n color={backgroundDotColor}\n />\n\n <Controls\n showZoom={true}\n showFitView={true}\n showInteractive={false}\n position={isCompactViewport ? 'bottom-right' : 'top-right'}\n className={`!bg-card !border-border !shadow-md [&>button]:!bg-card [&>button]:!border-border [&>button]:!fill-foreground [&>button:hover]:!bg-muted ${isCompactViewport ? 'scale-90 origin-bottom-right' : ''}`}\n />\n\n {!isCompactViewport && (\n <MiniMap\n nodeStrokeWidth={3}\n nodeColor={(node) => {\n const status = (node.data?.status || 'not_started') as keyof typeof STATUS_COLORS\n return STATUS_COLORS[status]?.hex || STATUS_COLORS.not_started.hex\n }}\n maskColor=\"rgba(0, 0, 0, 0.1)\"\n position=\"bottom-left\"\n className=\"!bg-card !border !border-border !rounded-lg\"\n />\n )}\n\n {!editable && !isCompactViewport && (\n <Panel position=\"top-left\" style={{ margin: 10 }}>\n <div className=\"bg-card rounded-lg shadow-sm border border-border px-4 py-2\">\n <p className=\"text-sm text-muted-foreground font-medium\">\n {t('workflows.graph.visualization')}\n </p>\n </div>\n </Panel>\n )}\n\n {editable && !isCompactViewport && (\n <Panel position=\"top-left\" style={{ margin: 10 }}>\n <Alert variant=\"info\" className=\"max-w-sm\">\n <Edit3 className=\"size-4\" />\n <AlertDescription className=\"font-medium\">\n {t('workflows.graph.editModeInfo')}\n </AlertDescription>\n </Alert>\n </Panel>\n )}\n </ReactFlow>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAqLQ,cAwCI,YAxCJ;AAnLR,OAAO;AAEP,SAAS,aAAa,SAAS,WAAW,gBAAgB;AAC1D;AAAA,EACE;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAQ,WAAW,SAAS,cAAc,eAAe,iBAAiB,mBAAmB,wBAAuB;AACpH,SAAS,8BAA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8BAA8B,GACnC;AAAA,WACF,GACF;AAAA;AAAA;AAAA,EAEJ,GACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/core",
|
|
3
|
-
"version": "0.6.3
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -243,16 +243,16 @@
|
|
|
243
243
|
"zod": "^4.4.3"
|
|
244
244
|
},
|
|
245
245
|
"peerDependencies": {
|
|
246
|
-
"@open-mercato/ai-assistant": "0.6.3
|
|
247
|
-
"@open-mercato/shared": "0.6.3
|
|
248
|
-
"@open-mercato/ui": "0.6.3
|
|
246
|
+
"@open-mercato/ai-assistant": "0.6.3",
|
|
247
|
+
"@open-mercato/shared": "0.6.3",
|
|
248
|
+
"@open-mercato/ui": "0.6.3",
|
|
249
249
|
"react": "^19.0.0",
|
|
250
250
|
"react-dom": "^19.0.0"
|
|
251
251
|
},
|
|
252
252
|
"devDependencies": {
|
|
253
|
-
"@open-mercato/ai-assistant": "0.6.3
|
|
254
|
-
"@open-mercato/shared": "0.6.3
|
|
255
|
-
"@open-mercato/ui": "0.6.3
|
|
253
|
+
"@open-mercato/ai-assistant": "0.6.3",
|
|
254
|
+
"@open-mercato/shared": "0.6.3",
|
|
255
|
+
"@open-mercato/ui": "0.6.3",
|
|
256
256
|
"@testing-library/dom": "^10.4.1",
|
|
257
257
|
"@testing-library/jest-dom": "^6.9.1",
|
|
258
258
|
"@testing-library/react": "^16.3.1",
|
|
@@ -276,6 +276,5 @@
|
|
|
276
276
|
"type": "git",
|
|
277
277
|
"url": "https://github.com/open-mercato/open-mercato",
|
|
278
278
|
"directory": "packages/core"
|
|
279
|
-
}
|
|
280
|
-
"stableVersion": "0.6.2"
|
|
279
|
+
}
|
|
281
280
|
}
|
package/src/global.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Ambient module declarations for the @open-mercato/core TypeScript context.
|
|
2
|
+
//
|
|
3
|
+
// Next.js apps get these declarations via `next-env.d.ts`, but workspace
|
|
4
|
+
// packages need them locally because they may import CSS side-effects from
|
|
5
|
+
// .tsx files (e.g. `import 'pkg/dist/style.css'` inside a lazy-loaded
|
|
6
|
+
// client component).
|
|
7
|
+
|
|
8
|
+
declare module '*.css'
|
|
9
|
+
declare module '*.scss'
|
|
@@ -103,7 +103,12 @@ async function loadVariantSnapshot(
|
|
|
103
103
|
): Promise<VariantSnapshot | null> {
|
|
104
104
|
const record = await em.findOne(CatalogProductVariant, { id, deletedAt: null })
|
|
105
105
|
if (!record) return null
|
|
106
|
-
const prices = options.includePrices
|
|
106
|
+
const prices = options.includePrices
|
|
107
|
+
? await loadVariantPriceSnapshots(em, record.id, {
|
|
108
|
+
tenantId: record.tenantId,
|
|
109
|
+
organizationId: record.organizationId,
|
|
110
|
+
})
|
|
111
|
+
: null
|
|
107
112
|
const custom = await loadCustomFieldSnapshot(em, {
|
|
108
113
|
entityId: E.catalog.catalog_product_variant,
|
|
109
114
|
recordId: record.id,
|
|
@@ -223,14 +228,15 @@ type VariantPriceSnapshot = {
|
|
|
223
228
|
|
|
224
229
|
async function loadVariantPriceSnapshots(
|
|
225
230
|
em: EntityManager,
|
|
226
|
-
variantId: string
|
|
231
|
+
variantId: string,
|
|
232
|
+
scope: { tenantId: string; organizationId: string }
|
|
227
233
|
): Promise<VariantPriceSnapshot[]> {
|
|
228
234
|
const prices = await findWithDecryption(
|
|
229
235
|
em,
|
|
230
236
|
CatalogProductPrice,
|
|
231
|
-
{ variant: variantId },
|
|
237
|
+
{ variant: variantId, tenantId: scope.tenantId, organizationId: scope.organizationId },
|
|
232
238
|
{ populate: ['priceKind', 'product', 'offer'] },
|
|
233
|
-
{ tenantId:
|
|
239
|
+
{ tenantId: scope.tenantId, organizationId: scope.organizationId },
|
|
234
240
|
)
|
|
235
241
|
const snapshots: VariantPriceSnapshot[] = []
|
|
236
242
|
for (const price of prices) {
|
|
@@ -904,7 +910,10 @@ const deleteVariantCommand: CommandHandler<
|
|
|
904
910
|
const priceSnapshots =
|
|
905
911
|
snapshot?.prices && snapshot.prices.length
|
|
906
912
|
? snapshot.prices
|
|
907
|
-
: await loadVariantPriceSnapshots(baseEm, id
|
|
913
|
+
: await loadVariantPriceSnapshots(baseEm, id, {
|
|
914
|
+
tenantId: record.tenantId,
|
|
915
|
+
organizationId: record.organizationId,
|
|
916
|
+
})
|
|
908
917
|
|
|
909
918
|
if (priceSnapshots.length) {
|
|
910
919
|
await em.nativeDelete(CatalogProductPrice, { id: { $in: priceSnapshots.map((price) => price.id) } })
|