@streamoid/catalogix-chat 0.2.11 → 0.2.13
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/dist/index.d.ts +2 -1
- package/dist/index.js +45 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -141,11 +141,12 @@ interface MapAttributesChatProps {
|
|
|
141
141
|
uniqueValues: Record<string, string[]>;
|
|
142
142
|
lovOptions?: Record<string, string[]>;
|
|
143
143
|
storeId: string;
|
|
144
|
+
marketplace?: string;
|
|
144
145
|
submitted?: boolean;
|
|
145
146
|
submittedValues?: Record<string, unknown>;
|
|
146
147
|
onSubmit: (values: Record<string, unknown>) => void;
|
|
147
148
|
}
|
|
148
|
-
declare function MapAttributesChat({ mappingData: initialData, mpAttributes, valuesOntologyAttributes, uniqueValues, lovOptions, submitted, onSubmit, }: MapAttributesChatProps): react_jsx_runtime.JSX.Element;
|
|
149
|
+
declare function MapAttributesChat({ mappingData: initialData, mpAttributes, valuesOntologyAttributes, uniqueValues, lovOptions, storeId, marketplace, submitted, onSubmit, }: MapAttributesChatProps): react_jsx_runtime.JSX.Element;
|
|
149
150
|
|
|
150
151
|
interface ProductAutomationProps {
|
|
151
152
|
storeId: string;
|
package/dist/index.js
CHANGED
|
@@ -2450,6 +2450,19 @@ import {
|
|
|
2450
2450
|
Loader2 as Loader25
|
|
2451
2451
|
} from "lucide-react";
|
|
2452
2452
|
import { Fragment as Fragment4, jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2453
|
+
async function fetchLovValues(storeId, marketplace, feedCol, smpAttr) {
|
|
2454
|
+
const { catalogixBaseUrl } = getApiConfig();
|
|
2455
|
+
const params = new URLSearchParams({
|
|
2456
|
+
vendor_attribute: feedCol,
|
|
2457
|
+
mp_attribute: smpAttr
|
|
2458
|
+
});
|
|
2459
|
+
const res = await fetchJson(
|
|
2460
|
+
`${catalogixBaseUrl}/api/v1/store/${storeId}/product/${marketplace}/metavalue/unique_attributes/get?${params}`
|
|
2461
|
+
);
|
|
2462
|
+
return (res.data?.ontology_values ?? []).map(
|
|
2463
|
+
(v) => typeof v === "string" ? v : v.value
|
|
2464
|
+
);
|
|
2465
|
+
}
|
|
2453
2466
|
function getAllAttributes(mpAttributes) {
|
|
2454
2467
|
return Object.values(mpAttributes).flat();
|
|
2455
2468
|
}
|
|
@@ -2634,9 +2647,13 @@ function ValueMappingPanel({
|
|
|
2634
2647
|
valuesOntologyAttributes,
|
|
2635
2648
|
uniqueValues,
|
|
2636
2649
|
lovOptions,
|
|
2650
|
+
storeId,
|
|
2651
|
+
marketplace,
|
|
2637
2652
|
onValueChange
|
|
2638
2653
|
}) {
|
|
2639
2654
|
const [expandedIndex, setExpandedIndex] = useState7(null);
|
|
2655
|
+
const [lovCache, setLovCache] = useState7({});
|
|
2656
|
+
const [loadingLov, setLoadingLov] = useState7(false);
|
|
2640
2657
|
const lovItems = useMemo5(() => {
|
|
2641
2658
|
const items = [];
|
|
2642
2659
|
data.forEach((item, itemIndex) => {
|
|
@@ -2672,13 +2689,31 @@ function ValueMappingPanel({
|
|
|
2672
2689
|
const first = lovItems.findIndex((i) => i.mappedCount < i.totalCount);
|
|
2673
2690
|
setExpandedIndex(first >= 0 ? first : 0);
|
|
2674
2691
|
}, [lovItems.length]);
|
|
2692
|
+
useEffect5(() => {
|
|
2693
|
+
if (expandedIndex == null) return;
|
|
2694
|
+
const item = lovItems[expandedIndex];
|
|
2695
|
+
if (!item || lovCache[item.attribute]) return;
|
|
2696
|
+
if (!storeId || !marketplace) return;
|
|
2697
|
+
let cancelled = false;
|
|
2698
|
+
setLoadingLov(true);
|
|
2699
|
+
fetchLovValues(storeId, marketplace, item.feedCol, item.attribute).then((values) => {
|
|
2700
|
+
if (!cancelled && values.length > 0) {
|
|
2701
|
+
setLovCache((prev) => ({ ...prev, [item.attribute]: values }));
|
|
2702
|
+
}
|
|
2703
|
+
}).catch((err) => console.warn("LOV fetch failed:", err)).finally(() => {
|
|
2704
|
+
if (!cancelled) setLoadingLov(false);
|
|
2705
|
+
});
|
|
2706
|
+
return () => {
|
|
2707
|
+
cancelled = true;
|
|
2708
|
+
};
|
|
2709
|
+
}, [expandedIndex, storeId, marketplace]);
|
|
2675
2710
|
if (lovItems.length === 0) {
|
|
2676
2711
|
return /* @__PURE__ */ jsx21("div", { className: "flex items-center justify-center py-6 text-xs text-muted-foreground", children: "No value mapping required." });
|
|
2677
2712
|
}
|
|
2678
2713
|
return /* @__PURE__ */ jsx21("div", { className: "divide-y divide-border/50", children: lovItems.map((item, idx) => {
|
|
2679
2714
|
const isExpanded = expandedIndex === idx;
|
|
2680
2715
|
const isComplete = item.mappedCount >= item.totalCount;
|
|
2681
|
-
const options = lovOptions[item.attribute] ?? [...new Set(
|
|
2716
|
+
const options = lovCache[item.attribute] ?? lovOptions[item.attribute] ?? [...new Set(
|
|
2682
2717
|
Object.values(item.mappedValues).filter(Boolean)
|
|
2683
2718
|
)];
|
|
2684
2719
|
return /* @__PURE__ */ jsxs10("div", { className: "py-1", children: [
|
|
@@ -2710,7 +2745,10 @@ function ValueMappingPanel({
|
|
|
2710
2745
|
]
|
|
2711
2746
|
}
|
|
2712
2747
|
),
|
|
2713
|
-
isExpanded && /* @__PURE__ */ jsx21("div", { className: "space-y-1 pl-4 pb-1.5 pt-1", children: item.
|
|
2748
|
+
isExpanded && /* @__PURE__ */ jsx21("div", { className: "space-y-1 pl-4 pb-1.5 pt-1", children: loadingLov && !lovCache[item.attribute] ? /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2 py-2 text-xs text-muted-foreground", children: [
|
|
2749
|
+
/* @__PURE__ */ jsx21(Loader25, { className: "size-3 animate-spin" }),
|
|
2750
|
+
"Loading values..."
|
|
2751
|
+
] }) : item.rawValues.map((raw) => /* @__PURE__ */ jsx21(
|
|
2714
2752
|
ValueRow,
|
|
2715
2753
|
{
|
|
2716
2754
|
raw,
|
|
@@ -2731,6 +2769,8 @@ function MapAttributesChat({
|
|
|
2731
2769
|
valuesOntologyAttributes,
|
|
2732
2770
|
uniqueValues,
|
|
2733
2771
|
lovOptions = {},
|
|
2772
|
+
storeId,
|
|
2773
|
+
marketplace = "SMP",
|
|
2734
2774
|
submitted,
|
|
2735
2775
|
onSubmit
|
|
2736
2776
|
}) {
|
|
@@ -2943,6 +2983,8 @@ function MapAttributesChat({
|
|
|
2943
2983
|
valuesOntologyAttributes,
|
|
2944
2984
|
uniqueValues,
|
|
2945
2985
|
lovOptions,
|
|
2986
|
+
storeId,
|
|
2987
|
+
marketplace,
|
|
2946
2988
|
onValueChange: handleValueChange
|
|
2947
2989
|
}
|
|
2948
2990
|
)
|
|
@@ -4121,6 +4163,7 @@ function CatalogixChat(props) {
|
|
|
4121
4163
|
uniqueValues: uiProps.uniqueValues ?? {},
|
|
4122
4164
|
lovOptions: uiProps.lovOptions ?? {},
|
|
4123
4165
|
storeId,
|
|
4166
|
+
marketplace: uiProps.marketplace ?? "SMP",
|
|
4124
4167
|
submitted: props.submitted,
|
|
4125
4168
|
submittedValues: props.submittedValues,
|
|
4126
4169
|
onSubmit: (mapping) => onSubmit(mapping, "Attribute mapping confirmed.")
|
package/package.json
CHANGED