@upstash/react-redis-browser 0.2.14-rc.10 → 0.2.14-rc.11
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.css +241 -54
- package/dist/index.d.mts +48 -2
- package/dist/index.d.ts +48 -2
- package/dist/index.js +1616 -954
- package/dist/index.mjs +2258 -1596
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2665,6 +2665,12 @@ function formatTime(seconds) {
|
|
|
2665
2665
|
return parts.slice(0, 1).join(" ");
|
|
2666
2666
|
}
|
|
2667
2667
|
var isTest = typeof window !== "undefined" && window.__PLAYWRIGHT__ === true;
|
|
2668
|
+
var jsonToJsLiteral = (json) => {
|
|
2669
|
+
return json.replaceAll(/"([$A-Z_a-z][\w$]*)"\s*:/g, "$1:");
|
|
2670
|
+
};
|
|
2671
|
+
var toJsLiteral = (obj) => {
|
|
2672
|
+
return jsonToJsLiteral(JSON.stringify(obj, null, 2));
|
|
2673
|
+
};
|
|
2668
2674
|
var formatUpstashErrorMessage = (error) => {
|
|
2669
2675
|
if (error.name !== "UpstashError") return error.message;
|
|
2670
2676
|
let message = error.message;
|
|
@@ -2795,7 +2801,7 @@ var DatabrowserProvider = ({
|
|
|
2795
2801
|
removeItem: () => {
|
|
2796
2802
|
}
|
|
2797
2803
|
},
|
|
2798
|
-
version:
|
|
2804
|
+
version: 8,
|
|
2799
2805
|
migrate: (originalState, version) => {
|
|
2800
2806
|
const state = originalState;
|
|
2801
2807
|
if (version <= 1) {
|
|
@@ -2827,9 +2833,12 @@ var DatabrowserProvider = ({
|
|
|
2827
2833
|
if (version <= 6) {
|
|
2828
2834
|
state.tabs = state.tabs.map(([id, data]) => [
|
|
2829
2835
|
id,
|
|
2830
|
-
{ ...data, valuesSearch: { index: "", queries: {} } }
|
|
2836
|
+
{ ...data, valuesSearch: { index: "", queries: {}, queryBuilderMode: "ui" } }
|
|
2831
2837
|
]);
|
|
2832
2838
|
}
|
|
2839
|
+
if (version <= 7) {
|
|
2840
|
+
state.aiDataSharingConsent = _nullishCoalesce(state.aiDataSharingConsent, () => ( false));
|
|
2841
|
+
}
|
|
2833
2842
|
return state;
|
|
2834
2843
|
}
|
|
2835
2844
|
})
|
|
@@ -2861,7 +2870,7 @@ var storeCreator = (set, get) => ({
|
|
|
2861
2870
|
id,
|
|
2862
2871
|
selectedKeys: [],
|
|
2863
2872
|
search: { key: "", type: void 0 },
|
|
2864
|
-
valuesSearch: { index: "", queries: {} },
|
|
2873
|
+
valuesSearch: { index: "", queries: {}, queryBuilderMode: "ui" },
|
|
2865
2874
|
isValuesSearchSelected: false,
|
|
2866
2875
|
pinned: false
|
|
2867
2876
|
};
|
|
@@ -3078,9 +3087,29 @@ var storeCreator = (set, get) => ({
|
|
|
3078
3087
|
return { ...old, tabs: newTabs };
|
|
3079
3088
|
});
|
|
3080
3089
|
},
|
|
3090
|
+
setQueryBuilderMode: (tabId, mode) => {
|
|
3091
|
+
set((old) => {
|
|
3092
|
+
const tabIndex = old.tabs.findIndex(([id]) => id === tabId);
|
|
3093
|
+
if (tabIndex === -1) return old;
|
|
3094
|
+
const newTabs = [...old.tabs];
|
|
3095
|
+
const [, tabData] = newTabs[tabIndex];
|
|
3096
|
+
newTabs[tabIndex] = [
|
|
3097
|
+
tabId,
|
|
3098
|
+
{
|
|
3099
|
+
...tabData,
|
|
3100
|
+
valuesSearch: { ...tabData.valuesSearch, queryBuilderMode: mode }
|
|
3101
|
+
}
|
|
3102
|
+
];
|
|
3103
|
+
return { ...old, tabs: newTabs };
|
|
3104
|
+
});
|
|
3105
|
+
},
|
|
3081
3106
|
searchHistory: [],
|
|
3082
3107
|
addSearchHistory: (key) => {
|
|
3083
3108
|
set((old) => ({ ...old, searchHistory: [key, ...old.searchHistory] }));
|
|
3109
|
+
},
|
|
3110
|
+
aiDataSharingConsent: false,
|
|
3111
|
+
setAiDataSharingConsent: (consent) => {
|
|
3112
|
+
set({ aiDataSharingConsent: consent });
|
|
3084
3113
|
}
|
|
3085
3114
|
});
|
|
3086
3115
|
|
|
@@ -3111,7 +3140,8 @@ var useTab = () => {
|
|
|
3111
3140
|
setValuesSearch,
|
|
3112
3141
|
setValuesSearchIndex,
|
|
3113
3142
|
setValuesSearchQuery,
|
|
3114
|
-
setIsValuesSearchSelected
|
|
3143
|
+
setIsValuesSearchSelected,
|
|
3144
|
+
setQueryBuilderMode
|
|
3115
3145
|
} = useDatabrowserStore();
|
|
3116
3146
|
const tabId = useTabId();
|
|
3117
3147
|
const tabData = _react.useMemo.call(void 0, () => _optionalChain([tabs, 'access', _20 => _20.find, 'call', _21 => _21(([id]) => id === tabId), 'optionalAccess', _22 => _22[1]]), [tabs, tabId]);
|
|
@@ -3130,6 +3160,7 @@ var useTab = () => {
|
|
|
3130
3160
|
query: _nullishCoalesce(tabData.valuesSearch.queries[tabData.valuesSearch.index], () => ( ""))
|
|
3131
3161
|
},
|
|
3132
3162
|
isValuesSearchSelected: tabData.isValuesSearchSelected,
|
|
3163
|
+
queryBuilderMode: _nullishCoalesce(tabData.valuesSearch.queryBuilderMode, () => ( "ui")),
|
|
3133
3164
|
pinned: tabData.pinned,
|
|
3134
3165
|
setSelectedKey: (key) => setSelectedKey(tabId, key),
|
|
3135
3166
|
setSelectedKeys: (keys) => setSelectedKeys(tabId, keys),
|
|
@@ -3140,7 +3171,8 @@ var useTab = () => {
|
|
|
3140
3171
|
setValuesSearch: (search) => setValuesSearch(tabId, search),
|
|
3141
3172
|
setValuesSearchIndex: (index) => setValuesSearchIndex(tabId, index),
|
|
3142
3173
|
setValuesSearchQuery: (query) => setValuesSearchQuery(tabId, query),
|
|
3143
|
-
setIsValuesSearchSelected: (isSelected) => setIsValuesSearchSelected(tabId, isSelected)
|
|
3174
|
+
setIsValuesSearchSelected: (isSelected) => setIsValuesSearchSelected(tabId, isSelected),
|
|
3175
|
+
setQueryBuilderMode: (mode) => setQueryBuilderMode(tabId, mode)
|
|
3144
3176
|
}),
|
|
3145
3177
|
[selectedTab, tabs, tabId]
|
|
3146
3178
|
);
|
|
@@ -3170,6 +3202,29 @@ var portalWrapper = wrapper;
|
|
|
3170
3202
|
|
|
3171
3203
|
var _reactresizablepanels = require('react-resizable-panels');
|
|
3172
3204
|
|
|
3205
|
+
// src/components/ui/resize-handle.tsx
|
|
3206
|
+
|
|
3207
|
+
|
|
3208
|
+
var ResizeHandle = ({
|
|
3209
|
+
direction = "horizontal"
|
|
3210
|
+
}) => {
|
|
3211
|
+
const isHorizontal = direction === "horizontal";
|
|
3212
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3213
|
+
_reactresizablepanels.PanelResizeHandle,
|
|
3214
|
+
{
|
|
3215
|
+
className: cn(
|
|
3216
|
+
"group flex items-center justify-center gap-1 rounded-md transition-colors hover:bg-zinc-300/10",
|
|
3217
|
+
isHorizontal ? "mx-[2px] h-full flex-col px-[8px]" : "my-[2px] w-full flex-row py-[8px]"
|
|
3218
|
+
),
|
|
3219
|
+
children: [
|
|
3220
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-[3px] w-[3px] rounded-full bg-zinc-300" }),
|
|
3221
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-[3px] w-[3px] rounded-full bg-zinc-300" }),
|
|
3222
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-[3px] w-[3px] rounded-full bg-zinc-300" })
|
|
3223
|
+
]
|
|
3224
|
+
}
|
|
3225
|
+
);
|
|
3226
|
+
};
|
|
3227
|
+
|
|
3173
3228
|
// src/components/ui/segmented.tsx
|
|
3174
3229
|
|
|
3175
3230
|
var Segmented = ({
|
|
@@ -3181,21 +3236,30 @@ var Segmented = ({
|
|
|
3181
3236
|
selectedClassName,
|
|
3182
3237
|
unselectedClassName
|
|
3183
3238
|
}) => {
|
|
3184
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3185
|
-
"
|
|
3239
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3240
|
+
"div",
|
|
3186
3241
|
{
|
|
3187
3242
|
className: cn(
|
|
3188
|
-
"
|
|
3189
|
-
|
|
3190
|
-
buttonClassName
|
|
3243
|
+
"flex w-fit select-none gap-[2px] rounded-lg bg-zinc-200 p-[2px] text-sm",
|
|
3244
|
+
className
|
|
3191
3245
|
),
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3246
|
+
children: options.map((option) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3247
|
+
"button",
|
|
3248
|
+
{
|
|
3249
|
+
className: cn(
|
|
3250
|
+
"h-7 rounded-md px-3 transition-all",
|
|
3251
|
+
value === option.key ? _nullishCoalesce(selectedClassName, () => ( "bg-white text-zinc-950")) : _nullishCoalesce(unselectedClassName, () => ( "text-zinc-700")),
|
|
3252
|
+
buttonClassName
|
|
3253
|
+
),
|
|
3254
|
+
onClick: () => {
|
|
3255
|
+
_optionalChain([onChange, 'optionalCall', _25 => _25(option.key)]);
|
|
3256
|
+
},
|
|
3257
|
+
children: option.label
|
|
3258
|
+
},
|
|
3259
|
+
option.key
|
|
3260
|
+
))
|
|
3261
|
+
}
|
|
3262
|
+
);
|
|
3199
3263
|
};
|
|
3200
3264
|
|
|
3201
3265
|
// src/components/ui/toaster.tsx
|
|
@@ -3367,6 +3431,33 @@ function Toaster() {
|
|
|
3367
3431
|
|
|
3368
3432
|
// src/components/databrowser/hooks/use-fetch-search-indexes.tsx
|
|
3369
3433
|
|
|
3434
|
+
|
|
3435
|
+
// src/lib/scan-keys.ts
|
|
3436
|
+
async function scanKeys(redis, {
|
|
3437
|
+
match,
|
|
3438
|
+
type,
|
|
3439
|
+
count: count2 = 100,
|
|
3440
|
+
limit
|
|
3441
|
+
} = {}) {
|
|
3442
|
+
let cursor = "0";
|
|
3443
|
+
const result = [];
|
|
3444
|
+
while (true) {
|
|
3445
|
+
const [newCursor, keys] = await redis.scan(cursor, {
|
|
3446
|
+
count: count2,
|
|
3447
|
+
type,
|
|
3448
|
+
match
|
|
3449
|
+
});
|
|
3450
|
+
result.push(...keys);
|
|
3451
|
+
if (limit && result.length >= limit) {
|
|
3452
|
+
return result.slice(0, limit);
|
|
3453
|
+
}
|
|
3454
|
+
if (newCursor === "0") break;
|
|
3455
|
+
cursor = newCursor;
|
|
3456
|
+
}
|
|
3457
|
+
return result;
|
|
3458
|
+
}
|
|
3459
|
+
|
|
3460
|
+
// src/components/databrowser/hooks/use-fetch-search-indexes.tsx
|
|
3370
3461
|
var FETCH_SEARCH_INDEXES_QUERY_KEY = "fetch-search-indexes";
|
|
3371
3462
|
var useFetchSearchIndexes = ({
|
|
3372
3463
|
match,
|
|
@@ -3376,21 +3467,7 @@ var useFetchSearchIndexes = ({
|
|
|
3376
3467
|
return _reactquery.useQuery.call(void 0, {
|
|
3377
3468
|
queryKey: [FETCH_SEARCH_INDEXES_QUERY_KEY],
|
|
3378
3469
|
enabled: _nullishCoalesce(enabled, () => ( true)),
|
|
3379
|
-
queryFn:
|
|
3380
|
-
let cursor = "0";
|
|
3381
|
-
const finalResult = [];
|
|
3382
|
-
while (true) {
|
|
3383
|
-
const [newCursor, results] = await redis.scan(cursor, {
|
|
3384
|
-
count: 100,
|
|
3385
|
-
type: "search",
|
|
3386
|
-
match
|
|
3387
|
-
});
|
|
3388
|
-
finalResult.push(...results);
|
|
3389
|
-
if (newCursor === "0") break;
|
|
3390
|
-
cursor = newCursor;
|
|
3391
|
-
}
|
|
3392
|
-
return finalResult;
|
|
3393
|
-
}
|
|
3470
|
+
queryFn: () => scanKeys(redis, { match, type: "search" })
|
|
3394
3471
|
});
|
|
3395
3472
|
};
|
|
3396
3473
|
|
|
@@ -3677,6 +3754,7 @@ Label.displayName = LabelPrimitive.Root.displayName;
|
|
|
3677
3754
|
// src/components/ui/select.tsx
|
|
3678
3755
|
|
|
3679
3756
|
var _reactselect = require('@radix-ui/react-select'); var SelectPrimitive = _interopRequireWildcard(_reactselect);
|
|
3757
|
+
var _reactdom = require('react-dom'); var ReactDOM = _interopRequireWildcard(_reactdom);
|
|
3680
3758
|
|
|
3681
3759
|
var Select = SelectPrimitive.Root;
|
|
3682
3760
|
var SelectGroup = SelectPrimitive.Group;
|
|
@@ -3732,7 +3810,7 @@ var SelectContent = React6.forwardRef(({ className, children, position = "popper
|
|
|
3732
3810
|
SelectPrimitive.Viewport,
|
|
3733
3811
|
{
|
|
3734
3812
|
className: cn(
|
|
3735
|
-
"p-1",
|
|
3813
|
+
"max-h-[min(var(--radix-select-content-available-height),20rem)] overflow-y-auto p-1",
|
|
3736
3814
|
position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
|
|
3737
3815
|
),
|
|
3738
3816
|
children
|
|
@@ -3750,40 +3828,76 @@ var SelectLabel = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE
|
|
|
3750
3828
|
}
|
|
3751
3829
|
));
|
|
3752
3830
|
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
3753
|
-
var
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3831
|
+
var SelectItemTooltip = ({
|
|
3832
|
+
description,
|
|
3833
|
+
itemRef
|
|
3834
|
+
}) => {
|
|
3835
|
+
const [pos, setPos] = React6.useState();
|
|
3836
|
+
React6.useEffect(() => {
|
|
3837
|
+
const el = itemRef.current;
|
|
3838
|
+
if (!el) return;
|
|
3839
|
+
const rect = el.getBoundingClientRect();
|
|
3840
|
+
setPos({ top: rect.top + rect.height / 2, left: rect.right + 8 });
|
|
3841
|
+
}, [itemRef]);
|
|
3842
|
+
if (!pos) return;
|
|
3843
|
+
return ReactDOM.createPortal(
|
|
3844
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3845
|
+
"div",
|
|
3846
|
+
{
|
|
3847
|
+
className: "pointer-events-none fixed z-[100] -translate-y-1/2 whitespace-nowrap rounded-md bg-zinc-900 px-3 py-1.5 text-xs text-zinc-50 shadow-md animate-in fade-in-0",
|
|
3848
|
+
style: { top: pos.top, left: pos.left },
|
|
3849
|
+
children: description
|
|
3850
|
+
}
|
|
3760
3851
|
),
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3852
|
+
_nullishCoalesce(portalRoot, () => ( document.body))
|
|
3853
|
+
);
|
|
3854
|
+
};
|
|
3855
|
+
var SelectItem = React6.forwardRef(({ className, children, description, ...props }, ref) => {
|
|
3856
|
+
const [isHovered, setIsHovered] = React6.useState(false);
|
|
3857
|
+
const itemRef = React6.useRef(null);
|
|
3858
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3859
|
+
SelectPrimitive.Item,
|
|
3860
|
+
{
|
|
3861
|
+
ref: (node) => {
|
|
3862
|
+
;
|
|
3863
|
+
itemRef.current = node;
|
|
3864
|
+
if (typeof ref === "function") ref(node);
|
|
3865
|
+
else if (ref) ref.current = node;
|
|
3866
|
+
},
|
|
3867
|
+
className: cn(
|
|
3868
|
+
"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none hover:bg-zinc-100 focus:bg-zinc-100 focus:text-zinc-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
3869
|
+
className
|
|
3870
|
+
),
|
|
3871
|
+
onMouseEnter: () => setIsHovered(true),
|
|
3872
|
+
onMouseLeave: () => setIsHovered(false),
|
|
3873
|
+
...props,
|
|
3874
|
+
children: [
|
|
3875
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3876
|
+
"svg",
|
|
3877
|
+
{
|
|
3878
|
+
width: "15",
|
|
3879
|
+
height: "15",
|
|
3880
|
+
viewBox: "0 0 15 15",
|
|
3881
|
+
fill: "none",
|
|
3882
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3883
|
+
className: "h-4 w-4",
|
|
3884
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3885
|
+
"path",
|
|
3886
|
+
{
|
|
3887
|
+
d: "M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z",
|
|
3888
|
+
fill: "currentColor",
|
|
3889
|
+
fillRule: "evenodd",
|
|
3890
|
+
clipRule: "evenodd"
|
|
3891
|
+
}
|
|
3892
|
+
)
|
|
3893
|
+
}
|
|
3894
|
+
) }) }),
|
|
3895
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectPrimitive.ItemText, { children }),
|
|
3896
|
+
description && isHovered && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectItemTooltip, { description, itemRef })
|
|
3897
|
+
]
|
|
3898
|
+
}
|
|
3899
|
+
);
|
|
3900
|
+
});
|
|
3787
3901
|
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
3788
3902
|
var SelectSeparator = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3789
3903
|
SelectPrimitive.Separator,
|
|
@@ -4466,7 +4580,6 @@ function transformArray(inputArray) {
|
|
|
4466
4580
|
var FETCH_SIMPLE_KEY_QUERY_KEY = "fetch-simple-key";
|
|
4467
4581
|
var useFetchSimpleKey = (dataKey, type) => {
|
|
4468
4582
|
const { redisNoPipeline: redis } = useRedis();
|
|
4469
|
-
const { deleteKeyCache } = useDeleteKeyCache();
|
|
4470
4583
|
return _reactquery.useQuery.call(void 0, {
|
|
4471
4584
|
queryKey: [FETCH_SIMPLE_KEY_QUERY_KEY, dataKey],
|
|
4472
4585
|
queryFn: async () => {
|
|
@@ -4476,7 +4589,6 @@ var useFetchSimpleKey = (dataKey, type) => {
|
|
|
4476
4589
|
else throw new Error(`Invalid type when fetching simple key: ${type}`);
|
|
4477
4590
|
if (type === "json" && result !== null)
|
|
4478
4591
|
result = JSON.stringify(sortObject(JSON.parse(result)));
|
|
4479
|
-
if (result === null) deleteKeyCache(dataKey);
|
|
4480
4592
|
return result;
|
|
4481
4593
|
}
|
|
4482
4594
|
});
|
|
@@ -4492,10 +4604,9 @@ var sortObject = (obj) => {
|
|
|
4492
4604
|
|
|
4493
4605
|
// src/components/databrowser/hooks/use-delete-key-cache.ts
|
|
4494
4606
|
var useDeleteKeyCache = () => {
|
|
4495
|
-
const {
|
|
4607
|
+
const { isValuesSearchSelected, valuesSearch } = useTab();
|
|
4496
4608
|
const deleteKeyCache = _react.useCallback.call(void 0,
|
|
4497
4609
|
(key) => {
|
|
4498
|
-
setSelectedKey(void 0);
|
|
4499
4610
|
queryClient.invalidateQueries({
|
|
4500
4611
|
queryKey: [FETCH_KEYS_QUERY_KEY]
|
|
4501
4612
|
});
|
|
@@ -4508,22 +4619,36 @@ var useDeleteKeyCache = () => {
|
|
|
4508
4619
|
queryClient.invalidateQueries({
|
|
4509
4620
|
queryKey: [FETCH_KEY_TYPE_QUERY_KEY, key]
|
|
4510
4621
|
});
|
|
4622
|
+
queryClient.invalidateQueries({
|
|
4623
|
+
queryKey: [FETCH_SEARCH_INDEX_QUERY_KEY, key]
|
|
4624
|
+
});
|
|
4625
|
+
if (isValuesSearchSelected && valuesSearch.index) {
|
|
4626
|
+
queryClient.invalidateQueries({
|
|
4627
|
+
queryKey: [FETCH_SEARCH_INDEX_QUERY_KEY, valuesSearch.index]
|
|
4628
|
+
});
|
|
4629
|
+
}
|
|
4511
4630
|
},
|
|
4512
|
-
[
|
|
4631
|
+
[isValuesSearchSelected, valuesSearch.index]
|
|
4513
4632
|
);
|
|
4514
4633
|
return { deleteKeyCache };
|
|
4515
4634
|
};
|
|
4516
4635
|
|
|
4517
4636
|
// src/components/databrowser/hooks/use-delete-key.ts
|
|
4518
4637
|
var useDeleteKey = () => {
|
|
4519
|
-
const { redis } = useRedis();
|
|
4638
|
+
const { redis, redisNoPipeline } = useRedis();
|
|
4520
4639
|
const { deleteKeyCache } = useDeleteKeyCache();
|
|
4640
|
+
const { isValuesSearchSelected, valuesSearch } = useTab();
|
|
4521
4641
|
const deleteKey = _reactquery.useMutation.call(void 0, {
|
|
4522
|
-
mutationFn: async (
|
|
4523
|
-
|
|
4642
|
+
mutationFn: async ({ keys, reindex }) => {
|
|
4643
|
+
await Promise.all(keys.map((key) => redis.del(key)));
|
|
4644
|
+
if (reindex && isValuesSearchSelected && valuesSearch.index) {
|
|
4645
|
+
await redisNoPipeline.search.index({ name: valuesSearch.index }).waitIndexing();
|
|
4646
|
+
}
|
|
4524
4647
|
},
|
|
4525
|
-
onSuccess: (_,
|
|
4526
|
-
|
|
4648
|
+
onSuccess: (_, { keys }) => {
|
|
4649
|
+
for (const key of keys) {
|
|
4650
|
+
deleteKeyCache(key);
|
|
4651
|
+
}
|
|
4527
4652
|
}
|
|
4528
4653
|
});
|
|
4529
4654
|
return deleteKey;
|
|
@@ -5045,80 +5170,134 @@ var DropdownMenuShortcut = ({ className, ...props }) => {
|
|
|
5045
5170
|
};
|
|
5046
5171
|
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
|
5047
5172
|
|
|
5048
|
-
// src/components/
|
|
5173
|
+
// src/components/databrowser/components/delete-key-modal.tsx
|
|
5174
|
+
|
|
5175
|
+
|
|
5176
|
+
// src/components/ui/dialog.tsx
|
|
5049
5177
|
|
|
5050
|
-
var
|
|
5178
|
+
var _reactdialog = require('@radix-ui/react-dialog'); var DialogPrimitive = _interopRequireWildcard(_reactdialog);
|
|
5051
5179
|
|
|
5052
|
-
var
|
|
5053
|
-
var
|
|
5054
|
-
var
|
|
5055
|
-
|
|
5056
|
-
var
|
|
5057
|
-
|
|
5180
|
+
var Dialog = DialogPrimitive.Root;
|
|
5181
|
+
var DialogTrigger = DialogPrimitive.Trigger;
|
|
5182
|
+
var DialogPortal = (props) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogPrimitive.Portal, { container: portalRoot, ...props });
|
|
5183
|
+
DialogPortal.displayName = DialogPrimitive.Portal.displayName;
|
|
5184
|
+
var DialogOverlay = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5185
|
+
DialogPrimitive.Overlay,
|
|
5058
5186
|
{
|
|
5187
|
+
ref,
|
|
5059
5188
|
className: cn(
|
|
5060
|
-
"
|
|
5189
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out",
|
|
5190
|
+
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
5191
|
+
"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",
|
|
5061
5192
|
className
|
|
5062
5193
|
),
|
|
5063
|
-
...props
|
|
5064
|
-
ref
|
|
5194
|
+
...props
|
|
5065
5195
|
}
|
|
5066
5196
|
));
|
|
5067
|
-
|
|
5068
|
-
var
|
|
5069
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5070
|
-
/* @__PURE__ */ _jsxruntime.
|
|
5071
|
-
|
|
5197
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
5198
|
+
var DialogContent = React10.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DialogPortal, { children: [
|
|
5199
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogOverlay, {}),
|
|
5200
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
5201
|
+
DialogPrimitive.Content,
|
|
5072
5202
|
{
|
|
5073
5203
|
ref,
|
|
5074
5204
|
className: cn(
|
|
5075
|
-
"antialiased
|
|
5205
|
+
"antialiased",
|
|
5206
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out ",
|
|
5207
|
+
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 ",
|
|
5208
|
+
"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 ",
|
|
5209
|
+
"data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]",
|
|
5210
|
+
"data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",
|
|
5211
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg ",
|
|
5212
|
+
"translate-x-[-50%] translate-y-[-50%] gap-4",
|
|
5213
|
+
"bg-white p-8 shadow-lg duration-200 ",
|
|
5214
|
+
"rounded-2xl md:w-full",
|
|
5076
5215
|
className
|
|
5077
5216
|
),
|
|
5078
|
-
...props
|
|
5217
|
+
...props,
|
|
5218
|
+
children: [
|
|
5219
|
+
children,
|
|
5220
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DialogPrimitive.Close, { className: "absolute right-4 top-4 text-zinc-400 transition-colors hover:text-zinc-600 focus:outline-none disabled:pointer-events-none", children: [
|
|
5221
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5222
|
+
"svg",
|
|
5223
|
+
{
|
|
5224
|
+
width: "20",
|
|
5225
|
+
height: "20",
|
|
5226
|
+
viewBox: "0 0 15 15",
|
|
5227
|
+
fill: "none",
|
|
5228
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5229
|
+
className: "size-5",
|
|
5230
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5231
|
+
"path",
|
|
5232
|
+
{
|
|
5233
|
+
d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",
|
|
5234
|
+
fill: "currentColor",
|
|
5235
|
+
fillRule: "evenodd",
|
|
5236
|
+
clipRule: "evenodd"
|
|
5237
|
+
}
|
|
5238
|
+
)
|
|
5239
|
+
}
|
|
5240
|
+
),
|
|
5241
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "sr-only", children: "Close" })
|
|
5242
|
+
] })
|
|
5243
|
+
]
|
|
5079
5244
|
}
|
|
5080
5245
|
)
|
|
5081
5246
|
] }));
|
|
5082
|
-
|
|
5083
|
-
var
|
|
5084
|
-
|
|
5085
|
-
var
|
|
5247
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
5248
|
+
var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className), ...props });
|
|
5249
|
+
DialogHeader.displayName = "DialogHeader";
|
|
5250
|
+
var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5086
5251
|
"div",
|
|
5087
5252
|
{
|
|
5088
5253
|
className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className),
|
|
5089
5254
|
...props
|
|
5090
5255
|
}
|
|
5091
5256
|
);
|
|
5092
|
-
|
|
5093
|
-
var
|
|
5094
|
-
|
|
5257
|
+
DialogFooter.displayName = "DialogFooter";
|
|
5258
|
+
var DialogTitle = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5259
|
+
DialogPrimitive.Title,
|
|
5095
5260
|
{
|
|
5096
5261
|
ref,
|
|
5097
|
-
className: cn("text-
|
|
5262
|
+
className: cn("text-base font-semibold text-zinc-950", className),
|
|
5098
5263
|
...props
|
|
5099
5264
|
}
|
|
5100
5265
|
));
|
|
5101
|
-
|
|
5102
|
-
var
|
|
5103
|
-
|
|
5266
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
5267
|
+
var DialogDescription = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5268
|
+
DialogPrimitive.Description,
|
|
5104
5269
|
{
|
|
5105
5270
|
ref,
|
|
5106
5271
|
className: cn("text-sm text-zinc-500", className),
|
|
5107
5272
|
...props
|
|
5108
5273
|
}
|
|
5109
5274
|
));
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5275
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
5276
|
+
|
|
5277
|
+
// src/components/ui/switch.tsx
|
|
5278
|
+
|
|
5279
|
+
var _reactswitch = require('@radix-ui/react-switch'); var SwitchPrimitives = _interopRequireWildcard(_reactswitch);
|
|
5280
|
+
|
|
5281
|
+
var Switch = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5282
|
+
SwitchPrimitives.Root,
|
|
5115
5283
|
{
|
|
5284
|
+
className: cn(
|
|
5285
|
+
"peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-950 focus-visible:ring-offset-2 focus-visible:ring-offset-white disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-neutral-900 data-[state=unchecked]:bg-neutral-200 dark:focus-visible:ring-neutral-300 dark:focus-visible:ring-offset-neutral-950 dark:data-[state=checked]:bg-neutral-50 dark:data-[state=unchecked]:bg-neutral-800",
|
|
5286
|
+
className
|
|
5287
|
+
),
|
|
5288
|
+
...props,
|
|
5116
5289
|
ref,
|
|
5117
|
-
|
|
5118
|
-
|
|
5290
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5291
|
+
SwitchPrimitives.Thumb,
|
|
5292
|
+
{
|
|
5293
|
+
className: cn(
|
|
5294
|
+
"pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0 dark:bg-neutral-950"
|
|
5295
|
+
)
|
|
5296
|
+
}
|
|
5297
|
+
)
|
|
5119
5298
|
}
|
|
5120
5299
|
));
|
|
5121
|
-
|
|
5300
|
+
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
5122
5301
|
|
|
5123
5302
|
// src/components/databrowser/components/delete-key-modal.tsx
|
|
5124
5303
|
|
|
@@ -5128,17 +5307,20 @@ function DeleteKeyModal({
|
|
|
5128
5307
|
open,
|
|
5129
5308
|
onOpenChange,
|
|
5130
5309
|
deletionType,
|
|
5131
|
-
count: count2 = 1
|
|
5310
|
+
count: count2 = 1,
|
|
5311
|
+
showReindex
|
|
5132
5312
|
}) {
|
|
5133
5313
|
const isPlural = count2 > 1;
|
|
5134
5314
|
const itemLabel = deletionType === "item" ? "Item" : "Key";
|
|
5135
5315
|
const itemsLabel = deletionType === "item" ? "Items" : "Keys";
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5316
|
+
const [reindex, setReindex] = _react.useState.call(void 0, true);
|
|
5317
|
+
const [isPending, setIsPending] = _react.useState.call(void 0, false);
|
|
5318
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Dialog, { open, onOpenChange, children: [
|
|
5319
|
+
children && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogTrigger, { asChild: true, children }),
|
|
5320
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DialogContent, { children: [
|
|
5321
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DialogHeader, { children: [
|
|
5322
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogTitle, { children: isPlural ? `Delete ${count2} ${itemsLabel}` : `Delete ${itemLabel}` }),
|
|
5323
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DialogDescription, { className: "mt-5", children: [
|
|
5142
5324
|
"Are you sure you want to delete",
|
|
5143
5325
|
" ",
|
|
5144
5326
|
isPlural ? `these ${count2} ${deletionType}s` : `this ${deletionType}`,
|
|
@@ -5147,14 +5329,44 @@ function DeleteKeyModal({
|
|
|
5147
5329
|
"This action cannot be undone."
|
|
5148
5330
|
] })
|
|
5149
5331
|
] }),
|
|
5150
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
5151
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5332
|
+
showReindex && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
5333
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5334
|
+
Switch,
|
|
5335
|
+
{
|
|
5336
|
+
id: "reindex",
|
|
5337
|
+
checked: reindex,
|
|
5338
|
+
onCheckedChange: setReindex,
|
|
5339
|
+
disabled: isPending
|
|
5340
|
+
}
|
|
5341
|
+
),
|
|
5342
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Label, { htmlFor: "reindex", className: "cursor-pointer text-sm text-zinc-700", children: "Reindex after deletion" })
|
|
5343
|
+
] }),
|
|
5344
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DialogFooter, { children: [
|
|
5345
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5346
|
+
Button,
|
|
5347
|
+
{
|
|
5348
|
+
type: "button",
|
|
5349
|
+
variant: "outline",
|
|
5350
|
+
disabled: isPending,
|
|
5351
|
+
onClick: () => _optionalChain([onOpenChange, 'optionalCall', _38 => _38(false)]),
|
|
5352
|
+
children: "Cancel"
|
|
5353
|
+
}
|
|
5354
|
+
),
|
|
5152
5355
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5153
|
-
|
|
5356
|
+
Button,
|
|
5154
5357
|
{
|
|
5358
|
+
variant: "primary",
|
|
5155
5359
|
className: "bg-red-500 text-zinc-50 hover:bg-red-600",
|
|
5156
|
-
|
|
5157
|
-
|
|
5360
|
+
disabled: isPending,
|
|
5361
|
+
onClick: async (e) => {
|
|
5362
|
+
setIsPending(true);
|
|
5363
|
+
try {
|
|
5364
|
+
await onDeleteConfirm(e, { reindex });
|
|
5365
|
+
} finally {
|
|
5366
|
+
setIsPending(false);
|
|
5367
|
+
}
|
|
5368
|
+
},
|
|
5369
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spinner, { isLoading: isPending, isLoadingText: "Deleting", children: "Yes, Delete" })
|
|
5158
5370
|
}
|
|
5159
5371
|
)
|
|
5160
5372
|
] })
|
|
@@ -5164,8 +5376,13 @@ function DeleteKeyModal({
|
|
|
5164
5376
|
|
|
5165
5377
|
// src/components/databrowser/components/display/key-actions.tsx
|
|
5166
5378
|
|
|
5167
|
-
function KeyActions({
|
|
5379
|
+
function KeyActions({
|
|
5380
|
+
dataKey,
|
|
5381
|
+
content,
|
|
5382
|
+
type
|
|
5383
|
+
}) {
|
|
5168
5384
|
const { mutateAsync: deleteKey } = useDeleteKey();
|
|
5385
|
+
const { isValuesSearchSelected } = useTab();
|
|
5169
5386
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DropdownMenu, { modal: false, children: [
|
|
5170
5387
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { size: "icon-sm", "aria-label": "Key actions", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5171
5388
|
_iconsreact.IconDotsVertical,
|
|
@@ -5196,14 +5413,24 @@ function KeyActions({ dataKey, content }) {
|
|
|
5196
5413
|
children: "Copy key"
|
|
5197
5414
|
}
|
|
5198
5415
|
),
|
|
5199
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5200
|
-
|
|
5416
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5417
|
+
DeleteKeyModal,
|
|
5201
5418
|
{
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5419
|
+
deletionType: "key",
|
|
5420
|
+
showReindex: isValuesSearchSelected && type !== "search",
|
|
5421
|
+
onDeleteConfirm: async (_e, options) => {
|
|
5422
|
+
await deleteKey({ keys: [dataKey], reindex: _optionalChain([options, 'optionalAccess', _39 => _39.reindex]) });
|
|
5423
|
+
},
|
|
5424
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5425
|
+
DropdownMenuItem,
|
|
5426
|
+
{
|
|
5427
|
+
className: "text-red-500 focus:bg-red-500 focus:text-white",
|
|
5428
|
+
onSelect: (e) => e.preventDefault(),
|
|
5429
|
+
children: "Delete key"
|
|
5430
|
+
}
|
|
5431
|
+
)
|
|
5205
5432
|
}
|
|
5206
|
-
)
|
|
5433
|
+
)
|
|
5207
5434
|
] })
|
|
5208
5435
|
] });
|
|
5209
5436
|
}
|
|
@@ -5225,10 +5452,10 @@ var DisplayHeader = ({
|
|
|
5225
5452
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "grow truncate text-sm", children: dataKey.trim() === "" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "ml-1 text-zinc-500", children: "(Empty Key)" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "font-medium text-zinc-950", children: dataKey }) }),
|
|
5226
5453
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-1", children: [
|
|
5227
5454
|
type !== "string" && type !== "json" && type !== "search" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SimpleTooltip, { content: "Add item", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { onClick: handleAddItem, size: "icon-sm", "aria-label": "Add item", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconPlus, { className: "size-4 text-zinc-500 dark:text-zinc-600" }) }) }),
|
|
5228
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, KeyActions, { dataKey, content })
|
|
5455
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, KeyActions, { dataKey, content, type })
|
|
5229
5456
|
] })
|
|
5230
5457
|
] }),
|
|
5231
|
-
type === "search" && hideTypeTag ? void 0 : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex h-10 items-center gap-1.5 overflow-scroll", children: [
|
|
5458
|
+
type === "search" && hideTypeTag ? void 0 : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex h-10 items-center gap-1.5 overflow-x-scroll", children: [
|
|
5232
5459
|
!hideTypeTag && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TypeTag, { variant: type, type: "badge" }),
|
|
5233
5460
|
type !== "search" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SizeBadge, { dataKey }),
|
|
5234
5461
|
type !== "search" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LengthBadge, { dataKey, type, content }),
|
|
@@ -5237,116 +5464,43 @@ var DisplayHeader = ({
|
|
|
5237
5464
|
] });
|
|
5238
5465
|
};
|
|
5239
5466
|
|
|
5467
|
+
// src/components/databrowser/components/display/key-deleted.tsx
|
|
5468
|
+
|
|
5469
|
+
var KeyDeleted = () => {
|
|
5470
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex h-full items-center justify-center rounded-md border border-dashed border-zinc-300", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-zinc-500", children: "This key has been deleted" }) });
|
|
5471
|
+
};
|
|
5472
|
+
|
|
5473
|
+
// src/components/databrowser/components/docs-link.tsx
|
|
5474
|
+
|
|
5475
|
+
|
|
5476
|
+
var DocsLink = ({ href, className }) => {
|
|
5477
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
5478
|
+
"a",
|
|
5479
|
+
{
|
|
5480
|
+
href,
|
|
5481
|
+
target: "_blank",
|
|
5482
|
+
rel: "noopener noreferrer",
|
|
5483
|
+
className: cn(
|
|
5484
|
+
"inline-flex items-center gap-1 px-1 text-xs text-zinc-400 transition-colors hover:text-zinc-600",
|
|
5485
|
+
className
|
|
5486
|
+
),
|
|
5487
|
+
children: [
|
|
5488
|
+
"Docs",
|
|
5489
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconExternalLink, { size: 12 })
|
|
5490
|
+
]
|
|
5491
|
+
}
|
|
5492
|
+
);
|
|
5493
|
+
};
|
|
5494
|
+
|
|
5240
5495
|
// src/components/databrowser/components/search/save-schema-modal.tsx
|
|
5241
5496
|
|
|
5242
5497
|
|
|
5243
|
-
// src/components/ui/
|
|
5498
|
+
// src/components/ui/progress.tsx
|
|
5244
5499
|
|
|
5245
|
-
var
|
|
5500
|
+
var _reactprogress = require('@radix-ui/react-progress'); var ProgressPrimitive = _interopRequireWildcard(_reactprogress);
|
|
5246
5501
|
|
|
5247
|
-
var
|
|
5248
|
-
|
|
5249
|
-
var DialogPortal = (props) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogPrimitive.Portal, { container: portalRoot, ...props });
|
|
5250
|
-
DialogPortal.displayName = DialogPrimitive.Portal.displayName;
|
|
5251
|
-
var DialogOverlay = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5252
|
-
DialogPrimitive.Overlay,
|
|
5253
|
-
{
|
|
5254
|
-
ref,
|
|
5255
|
-
className: cn(
|
|
5256
|
-
"data-[state=open]:animate-in data-[state=closed]:animate-out",
|
|
5257
|
-
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
5258
|
-
"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",
|
|
5259
|
-
className
|
|
5260
|
-
),
|
|
5261
|
-
...props
|
|
5262
|
-
}
|
|
5263
|
-
));
|
|
5264
|
-
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
5265
|
-
var DialogContent = React11.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DialogPortal, { children: [
|
|
5266
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogOverlay, {}),
|
|
5267
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
5268
|
-
DialogPrimitive.Content,
|
|
5269
|
-
{
|
|
5270
|
-
ref,
|
|
5271
|
-
className: cn(
|
|
5272
|
-
"antialiased",
|
|
5273
|
-
"data-[state=open]:animate-in data-[state=closed]:animate-out ",
|
|
5274
|
-
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 ",
|
|
5275
|
-
"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 ",
|
|
5276
|
-
"data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]",
|
|
5277
|
-
"data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",
|
|
5278
|
-
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg ",
|
|
5279
|
-
"translate-x-[-50%] translate-y-[-50%] gap-4",
|
|
5280
|
-
"bg-white p-6 shadow-lg duration-200 ",
|
|
5281
|
-
"sm:rounded-lg md:w-full",
|
|
5282
|
-
className
|
|
5283
|
-
),
|
|
5284
|
-
...props,
|
|
5285
|
-
children: [
|
|
5286
|
-
children,
|
|
5287
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-zinc-950 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-zinc-100 data-[state=open]:text-zinc-500", children: [
|
|
5288
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5289
|
-
"svg",
|
|
5290
|
-
{
|
|
5291
|
-
width: "15",
|
|
5292
|
-
height: "15",
|
|
5293
|
-
viewBox: "0 0 15 15",
|
|
5294
|
-
fill: "none",
|
|
5295
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
5296
|
-
className: "h-4 w-4",
|
|
5297
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5298
|
-
"path",
|
|
5299
|
-
{
|
|
5300
|
-
d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z",
|
|
5301
|
-
fill: "currentColor",
|
|
5302
|
-
fillRule: "evenodd",
|
|
5303
|
-
clipRule: "evenodd"
|
|
5304
|
-
}
|
|
5305
|
-
)
|
|
5306
|
-
}
|
|
5307
|
-
),
|
|
5308
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "sr-only", children: "Close" })
|
|
5309
|
-
] })
|
|
5310
|
-
]
|
|
5311
|
-
}
|
|
5312
|
-
)
|
|
5313
|
-
] }));
|
|
5314
|
-
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
5315
|
-
var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className), ...props });
|
|
5316
|
-
DialogHeader.displayName = "DialogHeader";
|
|
5317
|
-
var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5318
|
-
"div",
|
|
5319
|
-
{
|
|
5320
|
-
className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className),
|
|
5321
|
-
...props
|
|
5322
|
-
}
|
|
5323
|
-
);
|
|
5324
|
-
DialogFooter.displayName = "DialogFooter";
|
|
5325
|
-
var DialogTitle = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5326
|
-
DialogPrimitive.Title,
|
|
5327
|
-
{
|
|
5328
|
-
ref,
|
|
5329
|
-
className: cn("text-lg font-semibold leading-none tracking-tight", className),
|
|
5330
|
-
...props
|
|
5331
|
-
}
|
|
5332
|
-
));
|
|
5333
|
-
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
5334
|
-
var DialogDescription = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5335
|
-
DialogPrimitive.Description,
|
|
5336
|
-
{
|
|
5337
|
-
ref,
|
|
5338
|
-
className: cn("text-sm text-zinc-500", className),
|
|
5339
|
-
...props
|
|
5340
|
-
}
|
|
5341
|
-
));
|
|
5342
|
-
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
5343
|
-
|
|
5344
|
-
// src/components/ui/progress.tsx
|
|
5345
|
-
|
|
5346
|
-
var _reactprogress = require('@radix-ui/react-progress'); var ProgressPrimitive = _interopRequireWildcard(_reactprogress);
|
|
5347
|
-
|
|
5348
|
-
var Progress = React12.forwardRef(({ className, value, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5349
|
-
ProgressPrimitive.Root,
|
|
5502
|
+
var Progress = React12.forwardRef(({ className, value, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5503
|
+
ProgressPrimitive.Root,
|
|
5350
5504
|
{
|
|
5351
5505
|
ref,
|
|
5352
5506
|
className: cn(
|
|
@@ -5491,16 +5645,18 @@ var MonacoEditorWithTypes = ({
|
|
|
5491
5645
|
const monaco = _react2.useMonaco.call(void 0, );
|
|
5492
5646
|
const editorRef = _react.useRef.call(void 0, null);
|
|
5493
5647
|
const extraLibRef = _react.useRef.call(void 0, null);
|
|
5648
|
+
const valueRef = _react.useRef.call(void 0, value);
|
|
5649
|
+
valueRef.current = value;
|
|
5494
5650
|
const theme = useTheme();
|
|
5495
5651
|
_react.useEffect.call(void 0, () => {
|
|
5496
5652
|
if (!monaco) return;
|
|
5497
|
-
_optionalChain([extraLibRef, 'access',
|
|
5653
|
+
_optionalChain([extraLibRef, 'access', _40 => _40.current, 'optionalAccess', _41 => _41.dispose, 'call', _42 => _42()]);
|
|
5498
5654
|
extraLibRef.current = monaco.languages.typescript.typescriptDefaults.addExtraLib(
|
|
5499
5655
|
typeDefinitions,
|
|
5500
5656
|
`file:///${filePath.replace(".ts", "-types.d.ts")}`
|
|
5501
5657
|
);
|
|
5502
5658
|
requestAnimationFrame(() => {
|
|
5503
|
-
const model = _optionalChain([editorRef, 'access',
|
|
5659
|
+
const model = _optionalChain([editorRef, 'access', _43 => _43.current, 'optionalAccess', _44 => _44.getModel, 'optionalCall', _45 => _45()]);
|
|
5504
5660
|
if (model) {
|
|
5505
5661
|
const currentValue = model.getValue();
|
|
5506
5662
|
model.setValue(currentValue);
|
|
@@ -5509,10 +5665,10 @@ var MonacoEditorWithTypes = ({
|
|
|
5509
5665
|
}, [monaco, typeDefinitions, filePath]);
|
|
5510
5666
|
_react.useEffect.call(void 0, () => {
|
|
5511
5667
|
return () => {
|
|
5512
|
-
_optionalChain([extraLibRef, 'access',
|
|
5668
|
+
_optionalChain([extraLibRef, 'access', _46 => _46.current, 'optionalAccess', _47 => _47.dispose, 'call', _48 => _48()]);
|
|
5513
5669
|
if (monaco) {
|
|
5514
5670
|
const model = monaco.editor.getModel(monaco.Uri.parse(filePath));
|
|
5515
|
-
_optionalChain([model, 'optionalAccess',
|
|
5671
|
+
_optionalChain([model, 'optionalAccess', _49 => _49.dispose, 'call', _50 => _50()]);
|
|
5516
5672
|
}
|
|
5517
5673
|
};
|
|
5518
5674
|
}, [monaco, filePath]);
|
|
@@ -5522,12 +5678,12 @@ var MonacoEditorWithTypes = ({
|
|
|
5522
5678
|
} else if (newValue.trim() === "") {
|
|
5523
5679
|
onChange(defaultValue);
|
|
5524
5680
|
} else {
|
|
5525
|
-
_optionalChain([editorRef, 'access',
|
|
5681
|
+
_optionalChain([editorRef, 'access', _51 => _51.current, 'optionalAccess', _52 => _52.setValue, 'optionalCall', _53 => _53(valueRef.current)]);
|
|
5526
5682
|
}
|
|
5527
5683
|
};
|
|
5528
5684
|
_react.useEffect.call(void 0, () => {
|
|
5529
5685
|
if (!validateValue(value)) onChange(defaultValue);
|
|
5530
|
-
}, [value,
|
|
5686
|
+
}, [value, onChange, validateValue, defaultValue]);
|
|
5531
5687
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5532
5688
|
"div",
|
|
5533
5689
|
{
|
|
@@ -5804,7 +5960,7 @@ type Schema = NestedIndexSchema | FlatIndexSchema;
|
|
|
5804
5960
|
|
|
5805
5961
|
var SCHEMA_PREFIX = "const schema: Schema = s.object({";
|
|
5806
5962
|
var SCHEMA_SUFFIX = "})";
|
|
5807
|
-
var SCHEMA_DEFAULT = "const schema: Schema = s.object({\n
|
|
5963
|
+
var SCHEMA_DEFAULT = "const schema: Schema = s.object({\n name: s.string(),\n})";
|
|
5808
5964
|
var isSchemaStringValid = (value) => {
|
|
5809
5965
|
return value.startsWith(SCHEMA_PREFIX) && value.endsWith(SCHEMA_SUFFIX);
|
|
5810
5966
|
};
|
|
@@ -5863,7 +6019,7 @@ var SearchDisplay = ({
|
|
|
5863
6019
|
indexName: _nullishCoalesce(indexName, () => ( "")),
|
|
5864
6020
|
editorValue: data.schema ? schemaToEditorValue(data.schema) : SCHEMA_DEFAULT,
|
|
5865
6021
|
dataType: data.dataType || "string",
|
|
5866
|
-
prefixes: _optionalChain([data, 'access',
|
|
6022
|
+
prefixes: _optionalChain([data, 'access', _54 => _54.prefixes, 'optionalAccess', _55 => _55.join, 'call', _56 => _56(", ")]) || "",
|
|
5867
6023
|
language: data.language || "english"
|
|
5868
6024
|
});
|
|
5869
6025
|
}, [data, reset, indexName]);
|
|
@@ -5889,9 +6045,12 @@ var SearchDisplay = ({
|
|
|
5889
6045
|
createSchema.reset();
|
|
5890
6046
|
reset();
|
|
5891
6047
|
};
|
|
5892
|
-
|
|
6048
|
+
if (!isCreateModal && !isLoading && (data === null || data === void 0)) {
|
|
6049
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, KeyDeleted, {});
|
|
6050
|
+
}
|
|
6051
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex h-full min-h-0 w-full min-w-0 flex-col gap-2", children: [
|
|
5893
6052
|
!isCreateModal && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DisplayHeader, { dataKey: effectiveIndexName, type: "search", hideTypeTag: isEditModal }),
|
|
5894
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex h-
|
|
6053
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex min-h-0 min-w-0 grow flex-col gap-2 rounded-md", children: !isCreateModal && isLoading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spinner, { isLoadingText: "", isLoading: true }) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex min-h-0 w-full flex-1 flex-col gap-3", children: [
|
|
5895
6054
|
isCreateModal && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-1.5", children: [
|
|
5896
6055
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Label, { htmlFor: "index-name", children: "Key" }),
|
|
5897
6056
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -5904,9 +6063,9 @@ var SearchDisplay = ({
|
|
|
5904
6063
|
),
|
|
5905
6064
|
errors.indexName && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-red-500", children: errors.indexName.message })
|
|
5906
6065
|
] }),
|
|
5907
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "rounded-md border border-zinc-300 bg-white p-3", children: [
|
|
6066
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "shrink-0 rounded-md border border-zinc-300 bg-white p-3", children: [
|
|
5908
6067
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex items-center justify-between", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-medium text-zinc-700", children: "Config" }) }),
|
|
5909
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mt-2 grid grid-cols-
|
|
6068
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mt-2 grid grid-cols-2 gap-4 text-sm lg:grid-cols-4", children: [
|
|
5910
6069
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
|
|
5911
6070
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "mb-1.5 block text-xs font-medium text-zinc-500", children: "Data Type" }),
|
|
5912
6071
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -5930,7 +6089,7 @@ var SearchDisplay = ({
|
|
|
5930
6089
|
control,
|
|
5931
6090
|
render: ({ field }) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Select, { value: field.value, onValueChange: field.onChange, children: [
|
|
5932
6091
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectTrigger, { className: "h-8", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectValue, { placeholder: "Select language" }) }),
|
|
5933
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectContent, { children: LANGUAGES.map((lang) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectItem, { value: lang, children: lang }, lang)) })
|
|
6092
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectContent, { children: LANGUAGES.map((lang) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectItem, { value: lang, children: lang.charAt(0).toUpperCase() + lang.slice(1) }, lang)) })
|
|
5934
6093
|
] })
|
|
5935
6094
|
}
|
|
5936
6095
|
)
|
|
@@ -5949,7 +6108,7 @@ var SearchDisplay = ({
|
|
|
5949
6108
|
] })
|
|
5950
6109
|
] })
|
|
5951
6110
|
] }),
|
|
5952
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex min-h-0 flex-1 flex-col rounded-md border border-zinc-300 bg-white", children: [
|
|
6111
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "relative flex min-h-0 flex-1 flex-col rounded-md border border-zinc-300 bg-white", children: [
|
|
5953
6112
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex items-center justify-between border-b border-zinc-200 px-3 py-2", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-sm font-medium text-zinc-700", children: "Schema" }) }),
|
|
5954
6113
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-full px-1", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
5955
6114
|
_reacthookform.Controller,
|
|
@@ -5965,7 +6124,14 @@ var SearchDisplay = ({
|
|
|
5965
6124
|
}
|
|
5966
6125
|
)
|
|
5967
6126
|
}
|
|
5968
|
-
) }) })
|
|
6127
|
+
) }) }),
|
|
6128
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
6129
|
+
DocsLink,
|
|
6130
|
+
{
|
|
6131
|
+
className: "absolute bottom-2 right-2 text-sm",
|
|
6132
|
+
href: "https://upstash-search.mintlify.app/redis/search/schema-definition"
|
|
6133
|
+
}
|
|
6134
|
+
)
|
|
5969
6135
|
] }),
|
|
5970
6136
|
isCreateModal && createSchema.error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-full break-words text-xs text-red-500", children: createSchema.error.message.startsWith("ERR syntax error") ? "Invalid schema" : formatUpstashErrorMessage(createSchema.error) }),
|
|
5971
6137
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex shrink-0 items-center gap-2", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "ml-auto flex gap-2", children: [
|
|
@@ -6277,7 +6443,7 @@ var ItemContextMenu = ({
|
|
|
6277
6443
|
editItem({
|
|
6278
6444
|
type,
|
|
6279
6445
|
dataKey,
|
|
6280
|
-
itemKey: _optionalChain([data, 'optionalAccess',
|
|
6446
|
+
itemKey: _optionalChain([data, 'optionalAccess', _57 => _57.key]),
|
|
6281
6447
|
// For deletion
|
|
6282
6448
|
newKey: void 0
|
|
6283
6449
|
});
|
|
@@ -6312,7 +6478,7 @@ var ItemContextMenu = ({
|
|
|
6312
6478
|
{
|
|
6313
6479
|
onClick: () => {
|
|
6314
6480
|
if (!data) return;
|
|
6315
|
-
navigator.clipboard.writeText(_optionalChain([data, 'optionalAccess',
|
|
6481
|
+
navigator.clipboard.writeText(_optionalChain([data, 'optionalAccess', _58 => _58.key]));
|
|
6316
6482
|
toast({
|
|
6317
6483
|
description: "Key copied to clipboard"
|
|
6318
6484
|
});
|
|
@@ -6324,11 +6490,11 @@ var ItemContextMenu = ({
|
|
|
6324
6490
|
]
|
|
6325
6491
|
}
|
|
6326
6492
|
),
|
|
6327
|
-
_optionalChain([data, 'optionalAccess',
|
|
6493
|
+
_optionalChain([data, 'optionalAccess', _59 => _59.value]) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
6328
6494
|
ContextMenuItem,
|
|
6329
6495
|
{
|
|
6330
6496
|
onClick: () => {
|
|
6331
|
-
navigator.clipboard.writeText(_nullishCoalesce(_optionalChain([data, 'optionalAccess',
|
|
6497
|
+
navigator.clipboard.writeText(_nullishCoalesce(_optionalChain([data, 'optionalAccess', _60 => _60.value]), () => ( "")));
|
|
6332
6498
|
toast({
|
|
6333
6499
|
description: "Value copied to clipboard"
|
|
6334
6500
|
});
|
|
@@ -6440,7 +6606,7 @@ var useSetHashTTL = () => {
|
|
|
6440
6606
|
var HashFieldTTLBadge = ({ dataKey, field }) => {
|
|
6441
6607
|
const { data } = useFetchHashFieldExpires({ dataKey, fields: [field] });
|
|
6442
6608
|
const { mutate: setTTL, isPending } = useSetHashTTL();
|
|
6443
|
-
const expireAt = _optionalChain([data, 'optionalAccess',
|
|
6609
|
+
const expireAt = _optionalChain([data, 'optionalAccess', _61 => _61[field]]);
|
|
6444
6610
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
6445
6611
|
TTLBadge,
|
|
6446
6612
|
{
|
|
@@ -6537,7 +6703,7 @@ var MonacoEditor = ({
|
|
|
6537
6703
|
if (!active || !monaco || !editorRef.current) {
|
|
6538
6704
|
return;
|
|
6539
6705
|
}
|
|
6540
|
-
_optionalChain([monaco, 'optionalAccess',
|
|
6706
|
+
_optionalChain([monaco, 'optionalAccess', _62 => _62.editor, 'access', _63 => _63.setModelLanguage, 'call', _64 => _64(editorRef.current.getModel(), language)]);
|
|
6541
6707
|
}, [monaco, language, active]);
|
|
6542
6708
|
const editor = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
6543
6709
|
_react2.Editor,
|
|
@@ -6662,6 +6828,13 @@ var useField = ({
|
|
|
6662
6828
|
}
|
|
6663
6829
|
}
|
|
6664
6830
|
};
|
|
6831
|
+
_react.useLayoutEffect.call(void 0, () => {
|
|
6832
|
+
if (!fieldState.isDirty && contentType === "JSON" && checkIsValidJSON(data)) {
|
|
6833
|
+
form.setValue(name, formatJSON(data), {
|
|
6834
|
+
shouldDirty: false
|
|
6835
|
+
});
|
|
6836
|
+
}
|
|
6837
|
+
}, [data, fieldState.isDirty]);
|
|
6665
6838
|
return {
|
|
6666
6839
|
selector: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentTypeSelect, { value: contentType, onChange: handleTypeChange, data: field.value }),
|
|
6667
6840
|
editor: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -6694,7 +6867,7 @@ var ListEditDisplay = ({
|
|
|
6694
6867
|
type,
|
|
6695
6868
|
item
|
|
6696
6869
|
}) => {
|
|
6697
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "grow rounded-md", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ListEditForm, { item, type, dataKey }, item.key) });
|
|
6870
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "min-h-0 grow rounded-md", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ListEditForm, { item, type, dataKey }, item.key) });
|
|
6698
6871
|
};
|
|
6699
6872
|
var ListEditForm = ({
|
|
6700
6873
|
type,
|
|
@@ -6706,7 +6879,7 @@ var ListEditForm = ({
|
|
|
6706
6879
|
dataKey
|
|
6707
6880
|
});
|
|
6708
6881
|
const findValue = () => {
|
|
6709
|
-
for (const page of _nullishCoalesce(_optionalChain([query, 'access',
|
|
6882
|
+
for (const page of _nullishCoalesce(_optionalChain([query, 'access', _65 => _65.data, 'optionalAccess', _66 => _66.pages]), () => ( []))) {
|
|
6710
6883
|
const item = page.keys.find((item2) => item2.key === itemKey);
|
|
6711
6884
|
if (item && "value" in item) return item.value;
|
|
6712
6885
|
}
|
|
@@ -6733,8 +6906,8 @@ var ListEditForm = ({
|
|
|
6733
6906
|
});
|
|
6734
6907
|
setSelectedListItem(void 0);
|
|
6735
6908
|
});
|
|
6736
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacthookform.FormProvider, { ...form, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit, className: "flex h-full flex-col gap-2", children: [
|
|
6737
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex grow flex-col gap-2", children: [
|
|
6909
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacthookform.FormProvider, { ...form, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "form", { onSubmit, className: "flex h-full min-h-0 flex-col gap-2", children: [
|
|
6910
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex min-h-0 grow flex-col gap-2", children: [
|
|
6738
6911
|
type === "zset" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NumberFormItem, { name: "value", label: valueLabel }),
|
|
6739
6912
|
type !== "list" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FormItem, { readOnly: type === "stream", name: "key", label: keyLabel, data: itemKey }),
|
|
6740
6913
|
type !== "set" && type !== "zset" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -6823,7 +6996,7 @@ var FormItem = ({
|
|
|
6823
6996
|
readOnly,
|
|
6824
6997
|
data
|
|
6825
6998
|
});
|
|
6826
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cn("flex flex-col gap-1", !height && "h-full"), children: [
|
|
6999
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cn("flex flex-col gap-1", !height && "h-full min-h-0"), children: [
|
|
6827
7000
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-1 text-xs", children: [
|
|
6828
7001
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "font-medium text-zinc-700", children: label }),
|
|
6829
7002
|
" ",
|
|
@@ -6835,7 +7008,7 @@ var FormItem = ({
|
|
|
6835
7008
|
{
|
|
6836
7009
|
className: cn(
|
|
6837
7010
|
"overflow-hidden rounded-md border border-zinc-300 bg-white p-2 shadow-sm",
|
|
6838
|
-
!height && "h-full"
|
|
7011
|
+
!height && "h-full min-h-0"
|
|
6839
7012
|
),
|
|
6840
7013
|
children: editor
|
|
6841
7014
|
}
|
|
@@ -6852,7 +7025,7 @@ var HashFieldTTLInfo = ({
|
|
|
6852
7025
|
fields
|
|
6853
7026
|
}) => {
|
|
6854
7027
|
const { data } = useFetchHashFieldExpires({ dataKey, fields });
|
|
6855
|
-
const expireAt = _optionalChain([data, 'optionalAccess',
|
|
7028
|
+
const expireAt = _optionalChain([data, 'optionalAccess', _67 => _67[field]]);
|
|
6856
7029
|
const [ttl, setTTL] = _react.useState.call(void 0, () => calculateTTL(expireAt));
|
|
6857
7030
|
_react.useEffect.call(void 0, () => {
|
|
6858
7031
|
setTTL(calculateTTL(expireAt));
|
|
@@ -6877,7 +7050,11 @@ var headerLabels = {
|
|
|
6877
7050
|
var ListDisplay = ({ dataKey, type }) => {
|
|
6878
7051
|
const { selectedListItem } = useTab();
|
|
6879
7052
|
const query = useFetchListItems({ dataKey, type });
|
|
6880
|
-
|
|
7053
|
+
const isEmpty = query.isFetched && _optionalChain([query, 'access', _68 => _68.data, 'optionalAccess', _69 => _69.pages, 'access', _70 => _70.every, 'call', _71 => _71((page) => page.keys.length === 0)]);
|
|
7054
|
+
if (isEmpty) {
|
|
7055
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, KeyDeleted, {});
|
|
7056
|
+
}
|
|
7057
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex h-full min-h-0 flex-col gap-2 overflow-hidden", children: [
|
|
6881
7058
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DisplayHeader, { dataKey, type }),
|
|
6882
7059
|
selectedListItem && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ListEditDisplay, { dataKey, type, item: selectedListItem }),
|
|
6883
7060
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cn("min-h-0 grow", selectedListItem && "hidden"), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfiniteScroll, { query, className: "rounded-lg border border-zinc-200 bg-white", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "table", { className: "w-full", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ItemContextMenu, { dataKey, type, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "tbody", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ListItems, { dataKey, type, query }) }) }) }) }) })
|
|
@@ -6889,7 +7066,7 @@ var ListItems = ({
|
|
|
6889
7066
|
dataKey
|
|
6890
7067
|
}) => {
|
|
6891
7068
|
const { setSelectedListItem } = useTab();
|
|
6892
|
-
const keys = _react.useMemo.call(void 0, () => _nullishCoalesce(_optionalChain([query, 'access',
|
|
7069
|
+
const keys = _react.useMemo.call(void 0, () => _nullishCoalesce(_optionalChain([query, 'access', _72 => _72.data, 'optionalAccess', _73 => _73.pages, 'access', _74 => _74.flatMap, 'call', _75 => _75((page) => page.keys)]), () => ( [])), [query.data]);
|
|
6893
7070
|
const fields = _react.useMemo.call(void 0, () => keys.map((key) => key.key), [keys]);
|
|
6894
7071
|
const { mutate: editItem } = useEditListItem();
|
|
6895
7072
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: keys.map(({ key, value }, i) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
@@ -6971,9 +7148,12 @@ var ListItems = ({
|
|
|
6971
7148
|
|
|
6972
7149
|
var EditorDisplay = ({ dataKey, type }) => {
|
|
6973
7150
|
const { data } = useFetchSimpleKey(dataKey, type);
|
|
6974
|
-
|
|
7151
|
+
if (data === null) {
|
|
7152
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, KeyDeleted, {});
|
|
7153
|
+
}
|
|
7154
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex h-full min-h-0 w-full flex-col gap-2 overflow-hidden", children: [
|
|
6975
7155
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DisplayHeader, { dataKey, type, content: _nullishCoalesce(data, () => ( void 0)) }),
|
|
6976
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex h-
|
|
7156
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex min-h-0 grow flex-col gap-2 rounded-md", children: data === void 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spinner, { isLoadingText: "", isLoading: true }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EditorDisplayForm, { dataKey, type, data }, dataKey) })
|
|
6977
7157
|
] });
|
|
6978
7158
|
};
|
|
6979
7159
|
var EditorDisplayForm = ({
|
|
@@ -6990,12 +7170,12 @@ var EditorDisplayForm = ({
|
|
|
6990
7170
|
const { editor, selector } = useField({ name: "value", form, data });
|
|
6991
7171
|
const { mutateAsync: setKey, isPending: isSettingKey } = useSetSimpleKey(dataKey, type);
|
|
6992
7172
|
const handleCancel = () => {
|
|
6993
|
-
form.reset(
|
|
7173
|
+
form.reset();
|
|
6994
7174
|
};
|
|
6995
7175
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
6996
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex grow flex-col gap-1", children: [
|
|
7176
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex min-h-0 grow flex-col gap-1", children: [
|
|
6997
7177
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex shrink-0 items-center gap-2", children: type === "json" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", {}) : selector }),
|
|
6998
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "grow rounded-md border border-zinc-300 bg-white p-2", children: editor })
|
|
7178
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "min-h-0 grow rounded-md border border-zinc-300 bg-white p-2", children: editor })
|
|
6999
7179
|
] }),
|
|
7000
7180
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex shrink-0 items-center gap-2", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "ml-auto flex gap-2", children: [
|
|
7001
7181
|
form.formState.isDirty && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { onClick: handleCancel, children: "Cancel" }),
|
|
@@ -7036,33 +7216,6 @@ var DataDisplay = () => {
|
|
|
7036
7216
|
|
|
7037
7217
|
|
|
7038
7218
|
|
|
7039
|
-
// src/components/common/reload-button.tsx
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
var ReloadButton = ({
|
|
7044
|
-
onClick,
|
|
7045
|
-
isLoading: isLoadingProp
|
|
7046
|
-
}) => {
|
|
7047
|
-
const [isLoading, setIsLoading] = _react.useState.call(void 0, false);
|
|
7048
|
-
const handleClick = () => {
|
|
7049
|
-
setIsLoading(true);
|
|
7050
|
-
onClick();
|
|
7051
|
-
setTimeout(() => {
|
|
7052
|
-
setIsLoading(false);
|
|
7053
|
-
}, 350);
|
|
7054
|
-
};
|
|
7055
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SimpleTooltip, { content: "Refresh", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
7056
|
-
Button,
|
|
7057
|
-
{
|
|
7058
|
-
variant: "outline",
|
|
7059
|
-
size: "icon",
|
|
7060
|
-
onClick: handleClick,
|
|
7061
|
-
disabled: isLoading || isLoadingProp,
|
|
7062
|
-
children: isLoading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconLoader2, { className: "size-5 animate-spin text-zinc-500" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconRefresh, { className: "size-5 text-zinc-500 dark:text-zinc-600" })
|
|
7063
|
-
}
|
|
7064
|
-
) }) });
|
|
7065
|
-
};
|
|
7066
7219
|
|
|
7067
7220
|
// src/components/databrowser/components/add-key-modal.tsx
|
|
7068
7221
|
|
|
@@ -7085,7 +7238,7 @@ function AddKeyModal() {
|
|
|
7085
7238
|
setSelectedKey(key);
|
|
7086
7239
|
setOpen(false);
|
|
7087
7240
|
setTimeout(() => {
|
|
7088
|
-
_optionalChain([window, 'access',
|
|
7241
|
+
_optionalChain([window, 'access', _76 => _76.document, 'access', _77 => _77.querySelector, 'call', _78 => _78(`[data-key="${key}"]`), 'optionalAccess', _79 => _79.scrollIntoView, 'call', _80 => _80({
|
|
7089
7242
|
behavior: "smooth",
|
|
7090
7243
|
block: "start",
|
|
7091
7244
|
inline: "nearest"
|
|
@@ -7106,7 +7259,7 @@ function AddKeyModal() {
|
|
|
7106
7259
|
{
|
|
7107
7260
|
variant: "primary",
|
|
7108
7261
|
"data-testid": "add-key-button",
|
|
7109
|
-
className: "flex h-8 items-center gap-1 rounded-lg pl-2 pr-3 text-sm font-medium",
|
|
7262
|
+
className: "flex h-8 select-none items-center gap-1 rounded-lg pl-2 pr-3 text-sm font-medium",
|
|
7110
7263
|
children: [
|
|
7111
7264
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconPlus, { className: "size-5" }),
|
|
7112
7265
|
"Key"
|
|
@@ -7141,7 +7294,7 @@ function AddKeyModal() {
|
|
|
7141
7294
|
}
|
|
7142
7295
|
)
|
|
7143
7296
|
] }),
|
|
7144
|
-
formState.errors.key && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-3 mt-2 text-xs text-red-500", children: _optionalChain([formState, 'access',
|
|
7297
|
+
formState.errors.key && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mb-3 mt-2 text-xs text-red-500", children: _optionalChain([formState, 'access', _81 => _81.errors, 'access', _82 => _82.key, 'optionalAccess', _83 => _83.message]) }),
|
|
7145
7298
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mt-2 text-xs text-zinc-500", children: "After creating the key, you can edit the value" }),
|
|
7146
7299
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mt-6 flex justify-end gap-2", children: [
|
|
7147
7300
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -7164,414 +7317,62 @@ function AddKeyModal() {
|
|
|
7164
7317
|
);
|
|
7165
7318
|
}
|
|
7166
7319
|
|
|
7167
|
-
// src/components/databrowser/components/
|
|
7168
|
-
|
|
7169
|
-
var CreateIndexModal = ({
|
|
7170
|
-
open,
|
|
7171
|
-
onOpenChange
|
|
7172
|
-
}) => {
|
|
7173
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DialogContent, { className: "max-w-2xl", children: [
|
|
7174
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogTitle, { children: "Create new Index" }) }),
|
|
7175
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "sr-only", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogDescription, { children: "Create new search index" }) }),
|
|
7176
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SearchDisplay, { isCreateModal: true, onClose: () => onOpenChange(false) })
|
|
7177
|
-
] }) });
|
|
7178
|
-
};
|
|
7179
|
-
|
|
7180
|
-
// src/components/databrowser/components/search/edit-index-modal.tsx
|
|
7320
|
+
// src/components/databrowser/components/query-wizard/query-wizard-popover.tsx
|
|
7181
7321
|
|
|
7182
|
-
var EditIndexModal = ({
|
|
7183
|
-
open,
|
|
7184
|
-
onOpenChange,
|
|
7185
|
-
indexName
|
|
7186
|
-
}) => {
|
|
7187
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DialogContent, { className: "max-w-2xl", children: [
|
|
7188
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogTitle, { children: "Edit Index" }) }),
|
|
7189
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "sr-only", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogDescription, { children: "Edit search index schema" }) }),
|
|
7190
|
-
indexName && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SearchDisplay, { indexName, isEditModal: true, onClose: () => onOpenChange(false) })
|
|
7191
|
-
] }) });
|
|
7192
|
-
};
|
|
7193
7322
|
|
|
7194
|
-
// src/components/databrowser/components/header/search-input.tsx
|
|
7195
7323
|
|
|
7324
|
+
// src/components/databrowser/components/query-wizard/consent-prompt.tsx
|
|
7196
7325
|
|
|
7197
7326
|
|
|
7198
|
-
var
|
|
7199
|
-
const
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
seen.add(item);
|
|
7203
|
-
return true;
|
|
7204
|
-
});
|
|
7205
|
-
};
|
|
7206
|
-
var SearchInput = () => {
|
|
7207
|
-
const { setSearchKey, search } = useTab();
|
|
7208
|
-
const { searchHistory, addSearchHistory } = useDatabrowserStore();
|
|
7209
|
-
const [state, setState] = _react.useState.call(void 0, search.key);
|
|
7210
|
-
const [isFocus, setIsFocus] = _react.useState.call(void 0, false);
|
|
7211
|
-
const [focusedIndex, setFocusedIndex] = _react.useState.call(void 0, -1);
|
|
7212
|
-
const inputRef = _react.useRef.call(void 0, null);
|
|
7213
|
-
const historyItemRefs = _react.useRef.call(void 0, []);
|
|
7214
|
-
const handleSubmit = (value) => {
|
|
7215
|
-
if (value.trim() !== "" && !value.includes("*")) value = `${value}*`;
|
|
7216
|
-
addSearchHistory(value);
|
|
7217
|
-
setSearchKey(value);
|
|
7218
|
-
setState(value);
|
|
7219
|
-
};
|
|
7220
|
-
const filteredHistory = dedupeSearchHistory(
|
|
7221
|
-
searchHistory.filter((item) => item.trim() !== "" && item.trim() !== "*").filter((item) => item.includes(state) && item !== state)
|
|
7222
|
-
).slice(0, 5).map((item) => item.endsWith("*") ? item.slice(0, -1) : item);
|
|
7223
|
-
_react.useEffect.call(void 0, () => {
|
|
7224
|
-
setFocusedIndex(-1);
|
|
7225
|
-
}, [filteredHistory.length]);
|
|
7226
|
-
const handleKeyDown = (e) => {
|
|
7227
|
-
if (e.key === "Enter") {
|
|
7228
|
-
const text = focusedIndex >= 0 && focusedIndex < filteredHistory.length ? filteredHistory[focusedIndex] : e.currentTarget.value;
|
|
7229
|
-
handleSubmit(text);
|
|
7230
|
-
} else if (e.key === "Escape") {
|
|
7231
|
-
setState("");
|
|
7232
|
-
setFocusedIndex(-1);
|
|
7233
|
-
_optionalChain([inputRef, 'access', _78 => _78.current, 'optionalAccess', _79 => _79.blur, 'call', _80 => _80()]);
|
|
7234
|
-
} else if (e.key === "ArrowDown" || e.key === "Tab" && !e.shiftKey) {
|
|
7235
|
-
e.preventDefault();
|
|
7236
|
-
if (focusedIndex < filteredHistory.length - 1) {
|
|
7237
|
-
setFocusedIndex(focusedIndex + 1);
|
|
7238
|
-
} else if (filteredHistory.length > 0) {
|
|
7239
|
-
setFocusedIndex(0);
|
|
7240
|
-
}
|
|
7241
|
-
} else if (e.key === "ArrowUp" || e.key === "Tab" && e.shiftKey) {
|
|
7242
|
-
e.preventDefault();
|
|
7243
|
-
if (focusedIndex > 0) {
|
|
7244
|
-
setFocusedIndex(focusedIndex - 1);
|
|
7245
|
-
} else if (filteredHistory.length > 0 && focusedIndex === 0) {
|
|
7246
|
-
setFocusedIndex(-1);
|
|
7247
|
-
_optionalChain([inputRef, 'access', _81 => _81.current, 'optionalAccess', _82 => _82.focus, 'call', _83 => _83()]);
|
|
7248
|
-
} else if (filteredHistory.length > 0) {
|
|
7249
|
-
setFocusedIndex(filteredHistory.length - 1);
|
|
7250
|
-
}
|
|
7251
|
-
}
|
|
7327
|
+
var ConsentPrompt = ({ onClose }) => {
|
|
7328
|
+
const store = useDatabrowserStore();
|
|
7329
|
+
const handleContinue = () => {
|
|
7330
|
+
store.setAiDataSharingConsent(true);
|
|
7252
7331
|
};
|
|
7253
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "
|
|
7254
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
7255
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
7256
|
-
|
|
7332
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex max-w-[500px] flex-col gap-6 rounded-2xl p-6 shadow-lg", children: [
|
|
7333
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
7334
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-base font-semibold text-zinc-950", children: "AI Query Builder" }),
|
|
7335
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex items-center justify-center rounded-md bg-purple-100 px-1.5 py-0.5", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium text-purple-700", children: "BETA" }) })
|
|
7336
|
+
] }),
|
|
7337
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex gap-3 rounded-xl border border-yellow-300 bg-yellow-50 p-5", children: [
|
|
7338
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconAlertCircleFilled, { className: "size-5 shrink-0 text-yellow-800" }),
|
|
7339
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-1.5", children: [
|
|
7340
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm font-semibold text-yellow-800", children: "AI Query Builder requires data sharing" }),
|
|
7341
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "text-sm text-yellow-800", children: [
|
|
7342
|
+
"To generate accurate queries, we'll send your",
|
|
7343
|
+
" ",
|
|
7344
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "font-semibold", children: "index schema" }),
|
|
7345
|
+
" and a",
|
|
7346
|
+
" ",
|
|
7347
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "font-semibold", children: "small sample of your data" }),
|
|
7348
|
+
" to AI models. This may include field names and example values."
|
|
7349
|
+
] }),
|
|
7350
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-yellow-800", children: "Only used to generate the query you request." })
|
|
7351
|
+
] })
|
|
7352
|
+
] }),
|
|
7353
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-end gap-2", children: [
|
|
7354
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
7355
|
+
"button",
|
|
7257
7356
|
{
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
onKeyDown: handleKeyDown,
|
|
7262
|
-
onChange: (e) => {
|
|
7263
|
-
setState(e.currentTarget.value);
|
|
7264
|
-
if (e.currentTarget.value.trim() === "") handleSubmit("");
|
|
7265
|
-
},
|
|
7266
|
-
value: state,
|
|
7267
|
-
onFocus: () => {
|
|
7268
|
-
setIsFocus(true);
|
|
7269
|
-
setFocusedIndex(-1);
|
|
7270
|
-
},
|
|
7271
|
-
onBlur: () => setIsFocus(false)
|
|
7357
|
+
onClick: onClose,
|
|
7358
|
+
className: "flex h-8 items-center justify-center rounded-md border border-zinc-300 bg-white px-4 text-sm text-zinc-950 hover:bg-zinc-50",
|
|
7359
|
+
children: "Cancel"
|
|
7272
7360
|
}
|
|
7273
|
-
)
|
|
7361
|
+
),
|
|
7274
7362
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
7275
|
-
|
|
7363
|
+
"button",
|
|
7276
7364
|
{
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
e.preventDefault();
|
|
7281
|
-
e.stopPropagation();
|
|
7282
|
-
},
|
|
7283
|
-
children: filteredHistory.map((item, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-full py-[3px]", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
7284
|
-
"button",
|
|
7285
|
-
{
|
|
7286
|
-
ref: (el) => {
|
|
7287
|
-
historyItemRefs.current[index] = el;
|
|
7288
|
-
},
|
|
7289
|
-
onClick: () => handleSubmit(item),
|
|
7290
|
-
onMouseEnter: () => setFocusedIndex(index),
|
|
7291
|
-
className: `block w-full truncate rounded-sm p-1 text-left transition-colors ${focusedIndex === index ? "bg-zinc-100" : "hover:bg-zinc-100"}`,
|
|
7292
|
-
children: item
|
|
7293
|
-
}
|
|
7294
|
-
) }, item))
|
|
7365
|
+
onClick: handleContinue,
|
|
7366
|
+
className: "flex h-8 items-center justify-center rounded-md bg-purple-500 px-4 text-sm text-white hover:bg-purple-600",
|
|
7367
|
+
children: "I agree & Continue"
|
|
7295
7368
|
}
|
|
7296
7369
|
)
|
|
7297
|
-
] }),
|
|
7298
|
-
state && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
7299
|
-
Button,
|
|
7300
|
-
{
|
|
7301
|
-
type: "button",
|
|
7302
|
-
variant: "link",
|
|
7303
|
-
size: "icon",
|
|
7304
|
-
className: "absolute right-1 top-1/2 h-5 w-5 -translate-y-1/2 text-zinc-500 hover:text-zinc-900",
|
|
7305
|
-
onClick: () => {
|
|
7306
|
-
setSearchKey("");
|
|
7307
|
-
setState("");
|
|
7308
|
-
},
|
|
7309
|
-
children: [
|
|
7310
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconX, { size: 16 }),
|
|
7311
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "sr-only", children: "Clear" })
|
|
7312
|
-
]
|
|
7313
|
-
}
|
|
7314
|
-
),
|
|
7315
|
-
" "
|
|
7316
|
-
] });
|
|
7317
|
-
};
|
|
7318
|
-
|
|
7319
|
-
// src/components/databrowser/components/header/type-selector.tsx
|
|
7320
|
-
|
|
7321
|
-
var ALL_TYPES_KEY = "all";
|
|
7322
|
-
function DataTypeSelector({ allowSearch }) {
|
|
7323
|
-
const { search, setSearchType } = useTab();
|
|
7324
|
-
const entries = [
|
|
7325
|
-
[ALL_TYPES_KEY, "All Types"],
|
|
7326
|
-
...Object.entries(DATA_TYPE_NAMES).filter(([key]) => allowSearch || key !== "search")
|
|
7327
|
-
];
|
|
7328
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
7329
|
-
Select,
|
|
7330
|
-
{
|
|
7331
|
-
onValueChange: (type) => {
|
|
7332
|
-
if (type === ALL_TYPES_KEY) {
|
|
7333
|
-
setSearchType(void 0);
|
|
7334
|
-
} else {
|
|
7335
|
-
setSearchType(type);
|
|
7336
|
-
}
|
|
7337
|
-
},
|
|
7338
|
-
value: search.type === void 0 ? ALL_TYPES_KEY : search.type,
|
|
7339
|
-
children: [
|
|
7340
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectTrigger, { className: "!w-auto shrink-0 select-none whitespace-nowrap border-zinc-300 pr-8", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectValue, {}) }),
|
|
7341
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectGroup, { children: entries.map(([key, value]) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectItem, { value: key, children: value }, key)) }) })
|
|
7342
|
-
]
|
|
7343
|
-
}
|
|
7344
|
-
);
|
|
7345
|
-
}
|
|
7346
|
-
|
|
7347
|
-
// src/components/databrowser/components/header/index.tsx
|
|
7348
|
-
|
|
7349
|
-
var Header = ({ tabType, allowSearch }) => {
|
|
7350
|
-
const { isValuesSearchSelected, setIsValuesSearchSelected } = useTab();
|
|
7351
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between gap-1.5", children: [
|
|
7352
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex grow items-center gap-1.5", children: [
|
|
7353
|
-
tabType === "all" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
7354
|
-
Segmented,
|
|
7355
|
-
{
|
|
7356
|
-
options: [
|
|
7357
|
-
{
|
|
7358
|
-
key: "keys",
|
|
7359
|
-
label: "Keys"
|
|
7360
|
-
},
|
|
7361
|
-
{
|
|
7362
|
-
key: "values",
|
|
7363
|
-
label: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-1", children: [
|
|
7364
|
-
"Search",
|
|
7365
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex h-[18px] items-center rounded-md bg-emerald-100 px-[5px] text-[11px] text-emerald-700", children: "NEW" })
|
|
7366
|
-
] })
|
|
7367
|
-
}
|
|
7368
|
-
],
|
|
7369
|
-
value: isValuesSearchSelected ? "values" : "keys",
|
|
7370
|
-
onChange: (value) => {
|
|
7371
|
-
setIsValuesSearchSelected(value === "values");
|
|
7372
|
-
},
|
|
7373
|
-
className: "bg-emerald-800",
|
|
7374
|
-
unselectedClassName: "text-emerald-100",
|
|
7375
|
-
selectedClassName: "bg-emerald-50 text-emerald-800"
|
|
7376
|
-
}
|
|
7377
|
-
),
|
|
7378
|
-
isValuesSearchSelected ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, IndexSelector, {}) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
7379
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DataTypeSelector, { allowSearch }),
|
|
7380
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SearchInput, {})
|
|
7381
|
-
] })
|
|
7382
|
-
] }),
|
|
7383
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-1.5", children: [
|
|
7384
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, RefreshButton, {}),
|
|
7385
|
-
isValuesSearchSelected ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AddIndexButton, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AddKeyModal, {})
|
|
7386
7370
|
] })
|
|
7387
7371
|
] });
|
|
7388
7372
|
};
|
|
7389
|
-
var IndexSelector = () => {
|
|
7390
|
-
const {
|
|
7391
|
-
valuesSearch: { index },
|
|
7392
|
-
setValuesSearchIndex
|
|
7393
|
-
} = useTab();
|
|
7394
|
-
const { data: indexes, isLoading } = useFetchSearchIndexes();
|
|
7395
|
-
const [open, setOpen] = _react.useState.call(void 0, false);
|
|
7396
|
-
_react.useEffect.call(void 0, () => {
|
|
7397
|
-
if (!indexes || isLoading) return;
|
|
7398
|
-
if (index && !indexes.includes(index)) {
|
|
7399
|
-
setValuesSearchIndex("");
|
|
7400
|
-
}
|
|
7401
|
-
}, [indexes, index, isLoading, setValuesSearchIndex]);
|
|
7402
|
-
const [search, setSearch] = _react.useState.call(void 0, "");
|
|
7403
|
-
const [editingIndex, setEditingIndex] = _react.useState.call(void 0, null);
|
|
7404
|
-
const filteredIndexes = _optionalChain([indexes, 'optionalAccess', _84 => _84.filter, 'call', _85 => _85((idx) => idx.toLowerCase().includes(search.toLowerCase()))]);
|
|
7405
|
-
const handleEditIndex = (indexName) => {
|
|
7406
|
-
setOpen(false);
|
|
7407
|
-
setEditingIndex(indexName);
|
|
7408
|
-
};
|
|
7409
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex", children: [
|
|
7410
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex items-center rounded-l-lg border border-r-0 border-zinc-300 bg-white px-3 text-sm text-zinc-700", children: "Index" }),
|
|
7411
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
7412
|
-
Popover,
|
|
7413
|
-
{
|
|
7414
|
-
open,
|
|
7415
|
-
onOpenChange: (isOpen) => {
|
|
7416
|
-
setOpen(isOpen);
|
|
7417
|
-
if (!isOpen) setSearch("");
|
|
7418
|
-
},
|
|
7419
|
-
modal: false,
|
|
7420
|
-
children: [
|
|
7421
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, PopoverTrigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "button", { className: "flex min-w-[140px] items-center justify-between gap-2 rounded-r-lg border border-zinc-300 bg-emerald-50 px-3 py-[5px] text-sm font-medium text-emerald-800 transition-colors hover:bg-emerald-100", children: [
|
|
7422
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "truncate", children: index || "Select an index" }),
|
|
7423
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconChevronDown, { className: "size-4 shrink-0 opacity-50" })
|
|
7424
|
-
] }) }),
|
|
7425
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, PopoverContent, { className: "p-2", align: "center", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-2", children: [
|
|
7426
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CreateIndexButton, {}),
|
|
7427
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-px bg-zinc-100" }),
|
|
7428
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex h-9 items-center rounded-md border border-zinc-300 px-2", children: [
|
|
7429
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconSearch, { className: "size-5 text-zinc-400" }),
|
|
7430
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
7431
|
-
"input",
|
|
7432
|
-
{
|
|
7433
|
-
value: search,
|
|
7434
|
-
onChange: (e) => setSearch(e.target.value),
|
|
7435
|
-
placeholder: "Search Index",
|
|
7436
|
-
className: "flex h-full w-full bg-transparent px-2 py-3 text-sm outline-none placeholder:text-zinc-400"
|
|
7437
|
-
}
|
|
7438
|
-
)
|
|
7439
|
-
] }),
|
|
7440
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "max-h-[200px] overflow-y-auto", children: [
|
|
7441
|
-
_optionalChain([filteredIndexes, 'optionalAccess', _86 => _86.length]) === 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "py-4 text-center text-sm text-zinc-500", children: "No indexes found" }),
|
|
7442
|
-
_optionalChain([filteredIndexes, 'optionalAccess', _87 => _87.map, 'call', _88 => _88((idx) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
7443
|
-
"div",
|
|
7444
|
-
{
|
|
7445
|
-
className: "flex h-9 items-center rounded-md px-2 transition-colors hover:bg-zinc-100",
|
|
7446
|
-
children: [
|
|
7447
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
7448
|
-
"button",
|
|
7449
|
-
{
|
|
7450
|
-
onClick: () => {
|
|
7451
|
-
setValuesSearchIndex(idx);
|
|
7452
|
-
setOpen(false);
|
|
7453
|
-
},
|
|
7454
|
-
className: "flex flex-1 items-center gap-2 text-left text-sm",
|
|
7455
|
-
children: [
|
|
7456
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
7457
|
-
"span",
|
|
7458
|
-
{
|
|
7459
|
-
className: cn(
|
|
7460
|
-
"flex size-5 items-center justify-center",
|
|
7461
|
-
idx === index ? "text-emerald-600" : "text-transparent"
|
|
7462
|
-
),
|
|
7463
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconCircleCheck, { className: "size-5" })
|
|
7464
|
-
}
|
|
7465
|
-
),
|
|
7466
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "truncate", children: idx })
|
|
7467
|
-
]
|
|
7468
|
-
}
|
|
7469
|
-
),
|
|
7470
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
7471
|
-
"button",
|
|
7472
|
-
{
|
|
7473
|
-
onClick: (event) => {
|
|
7474
|
-
event.stopPropagation();
|
|
7475
|
-
event.preventDefault();
|
|
7476
|
-
handleEditIndex(idx);
|
|
7477
|
-
},
|
|
7478
|
-
className: "ml-2 text-sm text-zinc-500 underline hover:text-zinc-700",
|
|
7479
|
-
children: "Edit"
|
|
7480
|
-
}
|
|
7481
|
-
)
|
|
7482
|
-
]
|
|
7483
|
-
},
|
|
7484
|
-
idx
|
|
7485
|
-
))])
|
|
7486
|
-
] })
|
|
7487
|
-
] }) })
|
|
7488
|
-
]
|
|
7489
|
-
}
|
|
7490
|
-
),
|
|
7491
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
7492
|
-
EditIndexModal,
|
|
7493
|
-
{
|
|
7494
|
-
open: Boolean(editingIndex),
|
|
7495
|
-
onOpenChange: (isOpen) => !isOpen && setEditingIndex(null),
|
|
7496
|
-
indexName: editingIndex
|
|
7497
|
-
}
|
|
7498
|
-
)
|
|
7499
|
-
] });
|
|
7500
|
-
};
|
|
7501
|
-
var CreateIndexButton = () => {
|
|
7502
|
-
const [open, setOpen] = _react.useState.call(void 0, false);
|
|
7503
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
7504
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
7505
|
-
"button",
|
|
7506
|
-
{
|
|
7507
|
-
onClick: (e) => {
|
|
7508
|
-
e.stopPropagation();
|
|
7509
|
-
setOpen(true);
|
|
7510
|
-
},
|
|
7511
|
-
className: "flex h-9 w-full items-center gap-2 rounded-md px-2 text-sm text-emerald-600 transition-colors hover:bg-zinc-50",
|
|
7512
|
-
children: [
|
|
7513
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconCirclePlus, { className: "size-5" }),
|
|
7514
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "underline", children: "Create a new Index" })
|
|
7515
|
-
]
|
|
7516
|
-
}
|
|
7517
|
-
),
|
|
7518
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CreateIndexModal, { open, onOpenChange: setOpen })
|
|
7519
|
-
] });
|
|
7520
|
-
};
|
|
7521
|
-
var AddIndexButton = () => {
|
|
7522
|
-
const [open, setOpen] = _react.useState.call(void 0, false);
|
|
7523
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
7524
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SimpleTooltip, { content: "Add index", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
7525
|
-
Button,
|
|
7526
|
-
{
|
|
7527
|
-
variant: "primary",
|
|
7528
|
-
onClick: () => setOpen(true),
|
|
7529
|
-
className: "flex h-8 items-center gap-1 rounded-lg pl-2 pr-3 text-sm font-medium",
|
|
7530
|
-
children: [
|
|
7531
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconPlus, { className: "size-5" }),
|
|
7532
|
-
"Index"
|
|
7533
|
-
]
|
|
7534
|
-
}
|
|
7535
|
-
) }),
|
|
7536
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CreateIndexModal, { open, onOpenChange: setOpen })
|
|
7537
|
-
] });
|
|
7538
|
-
};
|
|
7539
|
-
var RefreshButton = () => {
|
|
7540
|
-
const { query } = useKeys();
|
|
7541
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
7542
|
-
ReloadButton,
|
|
7543
|
-
{
|
|
7544
|
-
onClick: () => {
|
|
7545
|
-
queryClient.invalidateQueries({
|
|
7546
|
-
queryKey: [FETCH_KEYS_QUERY_KEY]
|
|
7547
|
-
});
|
|
7548
|
-
queryClient.invalidateQueries({
|
|
7549
|
-
queryKey: [FETCH_LIST_ITEMS_QUERY_KEY]
|
|
7550
|
-
});
|
|
7551
|
-
queryClient.invalidateQueries({
|
|
7552
|
-
queryKey: [FETCH_SIMPLE_KEY_QUERY_KEY]
|
|
7553
|
-
});
|
|
7554
|
-
queryClient.invalidateQueries({
|
|
7555
|
-
queryKey: [FETCH_KEY_TYPE_QUERY_KEY]
|
|
7556
|
-
});
|
|
7557
|
-
},
|
|
7558
|
-
isLoading: query.isFetching
|
|
7559
|
-
}
|
|
7560
|
-
);
|
|
7561
|
-
};
|
|
7562
|
-
|
|
7563
|
-
// src/components/databrowser/components/header-error.tsx
|
|
7564
|
-
|
|
7565
|
-
var HeaderError = () => {
|
|
7566
|
-
const { query } = useKeys();
|
|
7567
|
-
if (!query.error) return null;
|
|
7568
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-red-600 dark:text-red-400", children: formatUpstashErrorMessage(query.error) });
|
|
7569
|
-
};
|
|
7570
|
-
|
|
7571
|
-
// src/components/databrowser/components/query-builder.tsx
|
|
7572
7373
|
|
|
7374
|
+
// src/components/databrowser/components/query-wizard/use-query-wizard.tsx
|
|
7573
7375
|
|
|
7574
|
-
// src/components/databrowser/components/search/query-editor.tsx
|
|
7575
7376
|
|
|
7576
7377
|
|
|
7577
7378
|
// src/components/databrowser/components/search/search-types-file.ts
|
|
@@ -8040,82 +7841,765 @@ type BoolNode<TSchema extends NestedIndexSchema | FlatIndexSchema> = BoolBase<TS
|
|
|
8040
7841
|
$and?: never;
|
|
8041
7842
|
$or?: never;
|
|
8042
7843
|
};
|
|
8043
|
-
|
|
8044
|
-
// Create a type for a query filter
|
|
8045
|
-
export type QueryFilter<TSchema extends NestedIndexSchema | FlatIndexSchema> =
|
|
8046
|
-
| QueryLeaf<TSchema>
|
|
8047
|
-
| AndNode<TSchema>
|
|
8048
|
-
| OrNode<TSchema>
|
|
8049
|
-
| MustNode<TSchema>
|
|
8050
|
-
| ShouldNode<TSchema>
|
|
8051
|
-
| MustShouldNode<TSchema>
|
|
8052
|
-
| NotNode<TSchema>
|
|
8053
|
-
| AndNotNode<TSchema>
|
|
8054
|
-
| OrNotNode<TSchema>
|
|
8055
|
-
| ShouldNotNode<TSchema>
|
|
8056
|
-
| MustNotNode<TSchema>
|
|
8057
|
-
| BoolNode<TSchema>;
|
|
8058
|
-
|
|
8059
|
-
// Create a type for root-level queries (restricts $or from mixing with fields)
|
|
8060
|
-
export type RootQueryFilter<TSchema extends NestedIndexSchema | FlatIndexSchema> =
|
|
8061
|
-
| QueryLeaf<TSchema>
|
|
8062
|
-
| AndNode<TSchema>
|
|
8063
|
-
| RootOrNode<TSchema>
|
|
8064
|
-
| MustNode<TSchema>
|
|
8065
|
-
| ShouldNode<TSchema>
|
|
8066
|
-
| MustShouldNode<TSchema>
|
|
8067
|
-
| AndNotNode<TSchema>
|
|
8068
|
-
| ShouldNotNode<TSchema>
|
|
8069
|
-
| BoolNode<TSchema>;
|
|
8070
|
-
|
|
8071
|
-
// Restricted version of OrNode that doesn't allow field operations at root level
|
|
8072
|
-
type RootOrNode<TSchema extends NestedIndexSchema | FlatIndexSchema> = {
|
|
8073
|
-
[P in SchemaPaths<TSchema>]?: never; // No field operations at root level with $or
|
|
8074
|
-
} & {
|
|
8075
|
-
$or: QueryFilter<TSchema> | QueryFilter<TSchema>[];
|
|
8076
|
-
$boost?: number;
|
|
8077
|
-
$and?: never;
|
|
8078
|
-
$must?: never;
|
|
8079
|
-
$should?: never;
|
|
8080
|
-
$mustNot?: never;
|
|
7844
|
+
|
|
7845
|
+
// Create a type for a query filter
|
|
7846
|
+
export type QueryFilter<TSchema extends NestedIndexSchema | FlatIndexSchema> =
|
|
7847
|
+
| QueryLeaf<TSchema>
|
|
7848
|
+
| AndNode<TSchema>
|
|
7849
|
+
| OrNode<TSchema>
|
|
7850
|
+
| MustNode<TSchema>
|
|
7851
|
+
| ShouldNode<TSchema>
|
|
7852
|
+
| MustShouldNode<TSchema>
|
|
7853
|
+
| NotNode<TSchema>
|
|
7854
|
+
| AndNotNode<TSchema>
|
|
7855
|
+
| OrNotNode<TSchema>
|
|
7856
|
+
| ShouldNotNode<TSchema>
|
|
7857
|
+
| MustNotNode<TSchema>
|
|
7858
|
+
| BoolNode<TSchema>;
|
|
7859
|
+
|
|
7860
|
+
// Create a type for root-level queries (restricts $or from mixing with fields)
|
|
7861
|
+
export type RootQueryFilter<TSchema extends NestedIndexSchema | FlatIndexSchema> =
|
|
7862
|
+
| QueryLeaf<TSchema>
|
|
7863
|
+
| AndNode<TSchema>
|
|
7864
|
+
| RootOrNode<TSchema>
|
|
7865
|
+
| MustNode<TSchema>
|
|
7866
|
+
| ShouldNode<TSchema>
|
|
7867
|
+
| MustShouldNode<TSchema>
|
|
7868
|
+
| AndNotNode<TSchema>
|
|
7869
|
+
| ShouldNotNode<TSchema>
|
|
7870
|
+
| BoolNode<TSchema>;
|
|
7871
|
+
|
|
7872
|
+
// Restricted version of OrNode that doesn't allow field operations at root level
|
|
7873
|
+
type RootOrNode<TSchema extends NestedIndexSchema | FlatIndexSchema> = {
|
|
7874
|
+
[P in SchemaPaths<TSchema>]?: never; // No field operations at root level with $or
|
|
7875
|
+
} & {
|
|
7876
|
+
$or: QueryFilter<TSchema> | QueryFilter<TSchema>[];
|
|
7877
|
+
$boost?: number;
|
|
7878
|
+
$and?: never;
|
|
7879
|
+
$must?: never;
|
|
7880
|
+
$should?: never;
|
|
7881
|
+
$mustNot?: never;
|
|
7882
|
+
};
|
|
7883
|
+
|
|
7884
|
+
export type DescribeFieldInfo = {
|
|
7885
|
+
type: FieldType;
|
|
7886
|
+
noTokenize?: boolean;
|
|
7887
|
+
noStem?: boolean;
|
|
7888
|
+
fast?: boolean;
|
|
7889
|
+
};
|
|
7890
|
+
|
|
7891
|
+
export type IndexDescription<TSchema extends NestedIndexSchema | FlatIndexSchema> = {
|
|
7892
|
+
name: string;
|
|
7893
|
+
dataType: "hash" | "string" | "json";
|
|
7894
|
+
prefixes: string[];
|
|
7895
|
+
language?: Language;
|
|
7896
|
+
schema: Record<SchemaPaths<TSchema>, DescribeFieldInfo>;
|
|
7897
|
+
};
|
|
7898
|
+
|
|
7899
|
+
export type Language =
|
|
7900
|
+
| "english"
|
|
7901
|
+
| "arabic"
|
|
7902
|
+
| "danish"
|
|
7903
|
+
| "dutch"
|
|
7904
|
+
| "finnish"
|
|
7905
|
+
| "french"
|
|
7906
|
+
| "german"
|
|
7907
|
+
| "greek"
|
|
7908
|
+
| "hungarian"
|
|
7909
|
+
| "italian"
|
|
7910
|
+
| "norwegian"
|
|
7911
|
+
| "portuguese"
|
|
7912
|
+
| "romanian"
|
|
7913
|
+
| "russian"
|
|
7914
|
+
| "spanish"
|
|
7915
|
+
| "swedish"
|
|
7916
|
+
| "tamil"
|
|
7917
|
+
| "turkish";
|
|
7918
|
+
|
|
7919
|
+
`;
|
|
7920
|
+
|
|
7921
|
+
// src/components/databrowser/components/query-wizard/use-query-wizard.tsx
|
|
7922
|
+
var QueryWizardContext = _react.createContext.call(void 0, void 0);
|
|
7923
|
+
var QueryWizardProvider = QueryWizardContext.Provider;
|
|
7924
|
+
var useQueryWizardFn = () => {
|
|
7925
|
+
return _react.useContext.call(void 0, QueryWizardContext);
|
|
7926
|
+
};
|
|
7927
|
+
var useGenerateQuery = () => {
|
|
7928
|
+
const queryWizard = useQueryWizardFn();
|
|
7929
|
+
return _reactquery.useMutation.call(void 0, {
|
|
7930
|
+
mutationFn: async ({
|
|
7931
|
+
prompt,
|
|
7932
|
+
searchIndex,
|
|
7933
|
+
sampleData
|
|
7934
|
+
}) => {
|
|
7935
|
+
if (!queryWizard) {
|
|
7936
|
+
throw new Error(
|
|
7937
|
+
"Query Wizard is not configured. Please provide a useQueryWizard prop to RedisBrowser component."
|
|
7938
|
+
);
|
|
7939
|
+
}
|
|
7940
|
+
const result = await queryWizard({
|
|
7941
|
+
prompt,
|
|
7942
|
+
searchIndex,
|
|
7943
|
+
sampleData,
|
|
7944
|
+
searchTypes: SEARCH_TYPES
|
|
7945
|
+
});
|
|
7946
|
+
return result;
|
|
7947
|
+
}
|
|
7948
|
+
});
|
|
7949
|
+
};
|
|
7950
|
+
|
|
7951
|
+
// src/components/databrowser/components/query-wizard/query-wizard-popover.tsx
|
|
7952
|
+
|
|
7953
|
+
var QueryWizardPopover = ({ onClose }) => {
|
|
7954
|
+
const { valuesSearch, setValuesSearchQuery, setQueryBuilderMode } = useTab();
|
|
7955
|
+
const { redisNoPipeline: redis } = useRedis();
|
|
7956
|
+
const [input, setInput] = _react.useState.call(void 0, "");
|
|
7957
|
+
const [sampleData, setSampleData] = _react.useState.call(void 0, []);
|
|
7958
|
+
const [showIndexFields, setShowIndexFields] = _react.useState.call(void 0, false);
|
|
7959
|
+
const { aiDataSharingConsent } = useDatabrowserStore();
|
|
7960
|
+
const { data: indexData, isLoading: isLoadingIndex } = useFetchSearchIndex(valuesSearch.index);
|
|
7961
|
+
const generateQuery = useGenerateQuery();
|
|
7962
|
+
const handleGenerate = async () => {
|
|
7963
|
+
if (!input.trim() || !valuesSearch.index) return;
|
|
7964
|
+
try {
|
|
7965
|
+
let samples = sampleData;
|
|
7966
|
+
if (samples.length === 0 && _optionalChain([indexData, 'optionalAccess', _84 => _84.prefixes, 'optionalAccess', _85 => _85[0]])) {
|
|
7967
|
+
try {
|
|
7968
|
+
const firstTenKeys = await scanKeys(redis, {
|
|
7969
|
+
match: `${indexData.prefixes[0]}*`,
|
|
7970
|
+
type: indexData.dataType,
|
|
7971
|
+
limit: 10
|
|
7972
|
+
});
|
|
7973
|
+
const dataPromises = firstTenKeys.map(async (key) => {
|
|
7974
|
+
try {
|
|
7975
|
+
if (indexData.dataType === "json") {
|
|
7976
|
+
const data = await redis.json.get(key);
|
|
7977
|
+
return { key, data };
|
|
7978
|
+
} else if (indexData.dataType === "hash") {
|
|
7979
|
+
const data = await redis.hgetall(key);
|
|
7980
|
+
return { key, data };
|
|
7981
|
+
} else {
|
|
7982
|
+
const data = await redis.get(key);
|
|
7983
|
+
return { key, data };
|
|
7984
|
+
}
|
|
7985
|
+
} catch (e5) {
|
|
7986
|
+
return null;
|
|
7987
|
+
}
|
|
7988
|
+
});
|
|
7989
|
+
const results = await Promise.all(dataPromises);
|
|
7990
|
+
samples = results.filter(Boolean);
|
|
7991
|
+
setSampleData(samples);
|
|
7992
|
+
} catch (error) {
|
|
7993
|
+
console.error("Error fetching sample data:", error);
|
|
7994
|
+
}
|
|
7995
|
+
}
|
|
7996
|
+
const result = await generateQuery.mutateAsync({
|
|
7997
|
+
prompt: input,
|
|
7998
|
+
searchIndex: _nullishCoalesce(indexData, () => ( void 0)),
|
|
7999
|
+
sampleData: samples
|
|
8000
|
+
});
|
|
8001
|
+
const queryString = toJsLiteral(result.query);
|
|
8002
|
+
setValuesSearchQuery(queryString);
|
|
8003
|
+
setQueryBuilderMode("code");
|
|
8004
|
+
_optionalChain([onClose, 'optionalCall', _86 => _86()]);
|
|
8005
|
+
} catch (error) {
|
|
8006
|
+
console.error("Error generating query:", error);
|
|
8007
|
+
}
|
|
8008
|
+
};
|
|
8009
|
+
if (isLoadingIndex) {
|
|
8010
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex h-[100px] w-[340px] items-center justify-center rounded-2xl bg-white", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spinner, { isLoading: true, isLoadingText: "Loading index..." }) });
|
|
8011
|
+
}
|
|
8012
|
+
if (!valuesSearch.index) {
|
|
8013
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-[340px] flex-col items-center gap-2 rounded-2xl bg-white p-8", children: [
|
|
8014
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm font-medium text-zinc-700", children: "No index selected" }),
|
|
8015
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-center text-xs text-zinc-500", children: "Create a new index to use the Query Wizard." })
|
|
8016
|
+
] });
|
|
8017
|
+
}
|
|
8018
|
+
if (aiDataSharingConsent === false) {
|
|
8019
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ConsentPrompt, { onClose });
|
|
8020
|
+
}
|
|
8021
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex w-[500px] flex-col gap-6 rounded-2xl bg-white p-6", children: [
|
|
8022
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-2", children: [
|
|
8023
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "text-base font-semibold text-zinc-950", children: "AI Query Builder" }),
|
|
8024
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex items-center justify-center rounded-md bg-purple-100 px-1.5 py-0.5", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "!text-sm font-medium text-purple-700", children: "BETA" }) })
|
|
8025
|
+
] }),
|
|
8026
|
+
generateQuery.error && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mt-2 rounded-md border border-yellow-300 bg-yellow-50 p-4", children: [
|
|
8027
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "!text-sm font-medium !text-yellow-800", children: generateQuery.error.name }),
|
|
8028
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "mt-0.5 !text-sm !text-yellow-800 opacity-90", children: generateQuery.error.message })
|
|
8029
|
+
] }),
|
|
8030
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-5", children: [
|
|
8031
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
8032
|
+
"button",
|
|
8033
|
+
{
|
|
8034
|
+
onClick: () => setShowIndexFields(!showIndexFields),
|
|
8035
|
+
className: "flex h-8 items-center gap-1.5 rounded-md border border-zinc-300 bg-zinc-50 px-3 hover:bg-zinc-100",
|
|
8036
|
+
children: [
|
|
8037
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8038
|
+
_iconsreact.IconChevronRight,
|
|
8039
|
+
{
|
|
8040
|
+
className: `size-5 text-zinc-700 transition-transform ${showIndexFields ? "rotate-90" : ""}`
|
|
8041
|
+
}
|
|
8042
|
+
),
|
|
8043
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-sm font-medium text-zinc-700", children: "Show Index fields" })
|
|
8044
|
+
]
|
|
8045
|
+
}
|
|
8046
|
+
),
|
|
8047
|
+
showIndexFields && indexData && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "rounded-md border border-zinc-200 bg-zinc-50 p-3", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "pre", { className: "max-h-40 overflow-auto text-xs text-zinc-700", children: JSON.stringify(indexData.schema, null, 2) }) }),
|
|
8048
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-1", children: [
|
|
8049
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Label, { htmlFor: "query-input", className: "text-sm font-medium text-zinc-950", children: "Describe" }),
|
|
8050
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8051
|
+
"textarea",
|
|
8052
|
+
{
|
|
8053
|
+
id: "query-input",
|
|
8054
|
+
value: input,
|
|
8055
|
+
onChange: (e) => setInput(e.target.value),
|
|
8056
|
+
placeholder: "",
|
|
8057
|
+
className: "h-[58px] w-full resize-none rounded-md border border-zinc-300 bg-white px-3 py-3 text-sm text-zinc-950 shadow-sm focus:border-purple-500 focus:outline-none focus:ring-1 focus:ring-purple-500 disabled:cursor-not-allowed disabled:opacity-50",
|
|
8058
|
+
disabled: generateQuery.isPending,
|
|
8059
|
+
autoFocus: true
|
|
8060
|
+
}
|
|
8061
|
+
),
|
|
8062
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-0.5 pt-0.5", children: [
|
|
8063
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-zinc-500", children: "Example: Find sports cars and trucks, exclude age > 100, boost sports_car" }),
|
|
8064
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8065
|
+
"a",
|
|
8066
|
+
{
|
|
8067
|
+
href: "https://upstash.com/docs/redis",
|
|
8068
|
+
target: "_blank",
|
|
8069
|
+
rel: "noopener noreferrer",
|
|
8070
|
+
className: "text-xs text-zinc-500 underline hover:text-zinc-700",
|
|
8071
|
+
children: "View Docs \u2192"
|
|
8072
|
+
}
|
|
8073
|
+
)
|
|
8074
|
+
] })
|
|
8075
|
+
] })
|
|
8076
|
+
] }),
|
|
8077
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-end gap-2", children: [
|
|
8078
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8079
|
+
"button",
|
|
8080
|
+
{
|
|
8081
|
+
onClick: onClose,
|
|
8082
|
+
disabled: generateQuery.isPending,
|
|
8083
|
+
className: "flex h-8 items-center justify-center rounded-md border border-zinc-300 bg-white px-4 text-sm text-zinc-950 shadow-[0_1px_1px_rgba(0,0,0,0.05)] hover:bg-zinc-50 disabled:cursor-not-allowed disabled:opacity-50",
|
|
8084
|
+
children: "Cancel"
|
|
8085
|
+
}
|
|
8086
|
+
),
|
|
8087
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8088
|
+
"button",
|
|
8089
|
+
{
|
|
8090
|
+
onClick: handleGenerate,
|
|
8091
|
+
disabled: !input.trim() || generateQuery.isPending,
|
|
8092
|
+
className: "flex h-8 items-center justify-center gap-2 rounded-md bg-purple-500 px-4 text-sm text-white shadow-[0_1px_1px_rgba(0,0,0,0.05)] hover:bg-purple-600 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-purple-500",
|
|
8093
|
+
children: generateQuery.isPending ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
8094
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Spinner, { isLoading: true }),
|
|
8095
|
+
"Generating..."
|
|
8096
|
+
] }) : "Generate Query"
|
|
8097
|
+
}
|
|
8098
|
+
)
|
|
8099
|
+
] })
|
|
8100
|
+
] });
|
|
8101
|
+
};
|
|
8102
|
+
|
|
8103
|
+
// src/components/databrowser/components/search/create-index-modal.tsx
|
|
8104
|
+
|
|
8105
|
+
var CreateIndexModal = ({
|
|
8106
|
+
open,
|
|
8107
|
+
onOpenChange
|
|
8108
|
+
}) => {
|
|
8109
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
8110
|
+
DialogContent,
|
|
8111
|
+
{
|
|
8112
|
+
className: "max-w-2xl",
|
|
8113
|
+
onEscapeKeyDown: (e) => {
|
|
8114
|
+
const active = document.activeElement;
|
|
8115
|
+
if (_optionalChain([active, 'optionalAccess', _87 => _87.closest, 'call', _88 => _88(".monaco-editor")]) || _optionalChain([active, 'optionalAccess', _89 => _89.tagName]) === "TEXTAREA") {
|
|
8116
|
+
e.preventDefault();
|
|
8117
|
+
}
|
|
8118
|
+
},
|
|
8119
|
+
children: [
|
|
8120
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogTitle, { children: "Create new Index" }) }),
|
|
8121
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "sr-only", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogDescription, { children: "Create new search index" }) }),
|
|
8122
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SearchDisplay, { isCreateModal: true, onClose: () => onOpenChange(false) })
|
|
8123
|
+
]
|
|
8124
|
+
}
|
|
8125
|
+
) });
|
|
8126
|
+
};
|
|
8127
|
+
|
|
8128
|
+
// src/components/databrowser/components/search/edit-index-modal.tsx
|
|
8129
|
+
|
|
8130
|
+
|
|
8131
|
+
var EditIndexModal = ({
|
|
8132
|
+
open,
|
|
8133
|
+
onOpenChange,
|
|
8134
|
+
indexName
|
|
8135
|
+
}) => {
|
|
8136
|
+
const { data: indexData, isLoading: isIndexLoading } = useFetchSearchIndex(indexName, {
|
|
8137
|
+
enabled: open
|
|
8138
|
+
});
|
|
8139
|
+
_react.useEffect.call(void 0, () => {
|
|
8140
|
+
if (open && !isIndexLoading && indexData === null) {
|
|
8141
|
+
onOpenChange(false);
|
|
8142
|
+
}
|
|
8143
|
+
}, [indexData, onOpenChange, isIndexLoading, open]);
|
|
8144
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Dialog, { open, onOpenChange, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
8145
|
+
DialogContent,
|
|
8146
|
+
{
|
|
8147
|
+
className: "min-h-[500px] max-w-2xl",
|
|
8148
|
+
onEscapeKeyDown: (e) => {
|
|
8149
|
+
const active = document.activeElement;
|
|
8150
|
+
if (_optionalChain([active, 'optionalAccess', _90 => _90.closest, 'call', _91 => _91(".monaco-editor")]) || _optionalChain([active, 'optionalAccess', _92 => _92.tagName]) === "TEXTAREA") {
|
|
8151
|
+
e.preventDefault();
|
|
8152
|
+
}
|
|
8153
|
+
},
|
|
8154
|
+
children: [
|
|
8155
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogHeader, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogTitle, { children: "Edit Index" }) }),
|
|
8156
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "sr-only", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogDescription, { children: "Edit search index schema" }) }),
|
|
8157
|
+
indexName && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SearchDisplay, { indexName, isEditModal: true, onClose: () => onOpenChange(false) })
|
|
8158
|
+
]
|
|
8159
|
+
}
|
|
8160
|
+
) });
|
|
8161
|
+
};
|
|
8162
|
+
|
|
8163
|
+
// src/components/databrowser/components/header/refresh-button.tsx
|
|
8164
|
+
|
|
8165
|
+
|
|
8166
|
+
// src/components/common/reload-button.tsx
|
|
8167
|
+
|
|
8168
|
+
|
|
8169
|
+
|
|
8170
|
+
var ReloadButton = ({
|
|
8171
|
+
onClick,
|
|
8172
|
+
isLoading: isLoadingProp,
|
|
8173
|
+
tooltip = "Refresh"
|
|
8174
|
+
}) => {
|
|
8175
|
+
const [isLoading, setIsLoading] = _react.useState.call(void 0, false);
|
|
8176
|
+
const handleClick = () => {
|
|
8177
|
+
setIsLoading(true);
|
|
8178
|
+
onClick();
|
|
8179
|
+
setTimeout(() => {
|
|
8180
|
+
setIsLoading(false);
|
|
8181
|
+
}, 350);
|
|
8182
|
+
};
|
|
8183
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SimpleTooltip, { content: tooltip, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8184
|
+
Button,
|
|
8185
|
+
{
|
|
8186
|
+
variant: "outline",
|
|
8187
|
+
size: "icon",
|
|
8188
|
+
onClick: handleClick,
|
|
8189
|
+
disabled: isLoading || isLoadingProp,
|
|
8190
|
+
children: isLoading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconLoader2, { className: "size-5 animate-spin text-zinc-500" }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconRefresh, { className: "size-5 text-zinc-500 dark:text-zinc-600" })
|
|
8191
|
+
}
|
|
8192
|
+
) }) });
|
|
8193
|
+
};
|
|
8194
|
+
|
|
8195
|
+
// src/components/databrowser/components/header/refresh-button.tsx
|
|
8196
|
+
|
|
8197
|
+
var invalidateAll = () => {
|
|
8198
|
+
queryClient.invalidateQueries({ queryKey: [FETCH_KEYS_QUERY_KEY] });
|
|
8199
|
+
queryClient.invalidateQueries({ queryKey: [FETCH_LIST_ITEMS_QUERY_KEY] });
|
|
8200
|
+
queryClient.invalidateQueries({ queryKey: [FETCH_SIMPLE_KEY_QUERY_KEY] });
|
|
8201
|
+
queryClient.invalidateQueries({ queryKey: [FETCH_KEY_TYPE_QUERY_KEY] });
|
|
8202
|
+
};
|
|
8203
|
+
var RefreshButton = () => {
|
|
8204
|
+
const { query } = useKeys();
|
|
8205
|
+
const { isValuesSearchSelected, valuesSearch } = useTab();
|
|
8206
|
+
const { redisNoPipeline: redis } = useRedis();
|
|
8207
|
+
const reindex = _reactquery.useMutation.call(void 0, {
|
|
8208
|
+
mutationFn: async () => {
|
|
8209
|
+
if (isValuesSearchSelected && valuesSearch.index) {
|
|
8210
|
+
await redis.search.index({ name: valuesSearch.index }).waitIndexing();
|
|
8211
|
+
}
|
|
8212
|
+
},
|
|
8213
|
+
onSettled: invalidateAll
|
|
8214
|
+
});
|
|
8215
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8216
|
+
ReloadButton,
|
|
8217
|
+
{
|
|
8218
|
+
onClick: () => reindex.mutate(),
|
|
8219
|
+
isLoading: query.isFetching || reindex.isPending,
|
|
8220
|
+
tooltip: isValuesSearchSelected ? "Reindex & Refresh Query" : "Refresh Scan"
|
|
8221
|
+
}
|
|
8222
|
+
);
|
|
8223
|
+
};
|
|
8224
|
+
|
|
8225
|
+
// src/components/databrowser/components/header/search-input.tsx
|
|
8226
|
+
|
|
8227
|
+
|
|
8228
|
+
|
|
8229
|
+
var dedupeSearchHistory = (history) => {
|
|
8230
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8231
|
+
return history.filter((item) => {
|
|
8232
|
+
if (!item || seen.has(item)) return false;
|
|
8233
|
+
seen.add(item);
|
|
8234
|
+
return true;
|
|
8235
|
+
});
|
|
8236
|
+
};
|
|
8237
|
+
var SearchInput = () => {
|
|
8238
|
+
const { setSearchKey, search } = useTab();
|
|
8239
|
+
const { searchHistory, addSearchHistory } = useDatabrowserStore();
|
|
8240
|
+
const [state, setState] = _react.useState.call(void 0, search.key);
|
|
8241
|
+
const [isFocus, setIsFocus] = _react.useState.call(void 0, false);
|
|
8242
|
+
const [focusedIndex, setFocusedIndex] = _react.useState.call(void 0, -1);
|
|
8243
|
+
const inputRef = _react.useRef.call(void 0, null);
|
|
8244
|
+
const historyItemRefs = _react.useRef.call(void 0, []);
|
|
8245
|
+
const handleSubmit = (value) => {
|
|
8246
|
+
if (value.trim() !== "" && !value.includes("*")) value = `${value}*`;
|
|
8247
|
+
addSearchHistory(value);
|
|
8248
|
+
setSearchKey(value);
|
|
8249
|
+
setState(value);
|
|
8250
|
+
};
|
|
8251
|
+
const filteredHistory = dedupeSearchHistory(
|
|
8252
|
+
searchHistory.filter((item) => item.trim() !== "" && item.trim() !== "*").filter((item) => item.includes(state) && item !== state)
|
|
8253
|
+
).slice(0, 5).map((item) => item.endsWith("*") ? item.slice(0, -1) : item);
|
|
8254
|
+
_react.useEffect.call(void 0, () => {
|
|
8255
|
+
setFocusedIndex(-1);
|
|
8256
|
+
}, [filteredHistory.length]);
|
|
8257
|
+
const handleKeyDown = (e) => {
|
|
8258
|
+
if (e.key === "Enter") {
|
|
8259
|
+
const text = focusedIndex >= 0 && focusedIndex < filteredHistory.length ? filteredHistory[focusedIndex] : e.currentTarget.value;
|
|
8260
|
+
handleSubmit(text);
|
|
8261
|
+
} else if (e.key === "Escape") {
|
|
8262
|
+
setState("");
|
|
8263
|
+
setFocusedIndex(-1);
|
|
8264
|
+
_optionalChain([inputRef, 'access', _93 => _93.current, 'optionalAccess', _94 => _94.blur, 'call', _95 => _95()]);
|
|
8265
|
+
} else if (e.key === "ArrowDown" || e.key === "Tab" && !e.shiftKey) {
|
|
8266
|
+
e.preventDefault();
|
|
8267
|
+
if (focusedIndex < filteredHistory.length - 1) {
|
|
8268
|
+
setFocusedIndex(focusedIndex + 1);
|
|
8269
|
+
} else if (filteredHistory.length > 0) {
|
|
8270
|
+
setFocusedIndex(0);
|
|
8271
|
+
}
|
|
8272
|
+
} else if (e.key === "ArrowUp" || e.key === "Tab" && e.shiftKey) {
|
|
8273
|
+
e.preventDefault();
|
|
8274
|
+
if (focusedIndex > 0) {
|
|
8275
|
+
setFocusedIndex(focusedIndex - 1);
|
|
8276
|
+
} else if (filteredHistory.length > 0 && focusedIndex === 0) {
|
|
8277
|
+
setFocusedIndex(-1);
|
|
8278
|
+
_optionalChain([inputRef, 'access', _96 => _96.current, 'optionalAccess', _97 => _97.focus, 'call', _98 => _98()]);
|
|
8279
|
+
} else if (filteredHistory.length > 0) {
|
|
8280
|
+
setFocusedIndex(filteredHistory.length - 1);
|
|
8281
|
+
}
|
|
8282
|
+
}
|
|
8283
|
+
};
|
|
8284
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "relative grow", children: [
|
|
8285
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Popover, { open: isFocus && filteredHistory.length > 0, children: [
|
|
8286
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, PopoverTrigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-8 rounded-md border border-zinc-300 font-normal", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8287
|
+
Input,
|
|
8288
|
+
{
|
|
8289
|
+
ref: inputRef,
|
|
8290
|
+
placeholder: "Search",
|
|
8291
|
+
className: "h-full border-none pr-6",
|
|
8292
|
+
onKeyDown: handleKeyDown,
|
|
8293
|
+
onChange: (e) => {
|
|
8294
|
+
setState(e.currentTarget.value);
|
|
8295
|
+
if (e.currentTarget.value.trim() === "") handleSubmit("");
|
|
8296
|
+
},
|
|
8297
|
+
value: state,
|
|
8298
|
+
onFocus: () => {
|
|
8299
|
+
setIsFocus(true);
|
|
8300
|
+
setFocusedIndex(-1);
|
|
8301
|
+
},
|
|
8302
|
+
onBlur: () => setIsFocus(false)
|
|
8303
|
+
}
|
|
8304
|
+
) }) }),
|
|
8305
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8306
|
+
PopoverContent,
|
|
8307
|
+
{
|
|
8308
|
+
className: "w-[--radix-popover-trigger-width] divide-y px-3 py-2 text-[13px] text-zinc-900",
|
|
8309
|
+
autoFocus: false,
|
|
8310
|
+
onOpenAutoFocus: (e) => {
|
|
8311
|
+
e.preventDefault();
|
|
8312
|
+
e.stopPropagation();
|
|
8313
|
+
},
|
|
8314
|
+
children: filteredHistory.map((item, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "w-full py-[3px]", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8315
|
+
"button",
|
|
8316
|
+
{
|
|
8317
|
+
ref: (el) => {
|
|
8318
|
+
historyItemRefs.current[index] = el;
|
|
8319
|
+
},
|
|
8320
|
+
onClick: () => handleSubmit(item),
|
|
8321
|
+
onMouseEnter: () => setFocusedIndex(index),
|
|
8322
|
+
className: `block w-full truncate rounded-sm p-1 text-left transition-colors ${focusedIndex === index ? "bg-zinc-100" : "hover:bg-zinc-100"}`,
|
|
8323
|
+
children: item
|
|
8324
|
+
}
|
|
8325
|
+
) }, item))
|
|
8326
|
+
}
|
|
8327
|
+
)
|
|
8328
|
+
] }),
|
|
8329
|
+
state && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
8330
|
+
Button,
|
|
8331
|
+
{
|
|
8332
|
+
type: "button",
|
|
8333
|
+
variant: "link",
|
|
8334
|
+
size: "icon",
|
|
8335
|
+
className: "absolute right-1 top-1/2 h-5 w-5 -translate-y-1/2 text-zinc-500 hover:text-zinc-900",
|
|
8336
|
+
onClick: () => {
|
|
8337
|
+
setSearchKey("");
|
|
8338
|
+
setState("");
|
|
8339
|
+
},
|
|
8340
|
+
children: [
|
|
8341
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconX, { size: 16 }),
|
|
8342
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "sr-only", children: "Clear" })
|
|
8343
|
+
]
|
|
8344
|
+
}
|
|
8345
|
+
),
|
|
8346
|
+
" "
|
|
8347
|
+
] });
|
|
8348
|
+
};
|
|
8349
|
+
|
|
8350
|
+
// src/components/databrowser/components/header/type-selector.tsx
|
|
8351
|
+
|
|
8352
|
+
var ALL_TYPES_KEY = "all";
|
|
8353
|
+
function DataTypeSelector({ allowSearch }) {
|
|
8354
|
+
const { search, setSearchType } = useTab();
|
|
8355
|
+
const entries = [
|
|
8356
|
+
[ALL_TYPES_KEY, "All Types"],
|
|
8357
|
+
...Object.entries(DATA_TYPE_NAMES).filter(([key]) => allowSearch || key !== "search")
|
|
8358
|
+
];
|
|
8359
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
8360
|
+
Select,
|
|
8361
|
+
{
|
|
8362
|
+
onValueChange: (type) => {
|
|
8363
|
+
if (type === ALL_TYPES_KEY) {
|
|
8364
|
+
setSearchType(void 0);
|
|
8365
|
+
} else {
|
|
8366
|
+
setSearchType(type);
|
|
8367
|
+
}
|
|
8368
|
+
},
|
|
8369
|
+
value: search.type === void 0 ? ALL_TYPES_KEY : search.type,
|
|
8370
|
+
children: [
|
|
8371
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectTrigger, { className: "!w-auto shrink-0 select-none whitespace-nowrap border-zinc-300 pr-8", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectValue, {}) }),
|
|
8372
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectGroup, { children: entries.map(([key, value]) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectItem, { value: key, children: value }, key)) }) })
|
|
8373
|
+
]
|
|
8374
|
+
}
|
|
8375
|
+
);
|
|
8376
|
+
}
|
|
8377
|
+
|
|
8378
|
+
// src/components/databrowser/components/header/index.tsx
|
|
8379
|
+
|
|
8380
|
+
var Header = ({ tabType, allowSearch }) => {
|
|
8381
|
+
const { isValuesSearchSelected, setIsValuesSearchSelected } = useTab();
|
|
8382
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center justify-between gap-1.5", children: [
|
|
8383
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex grow items-center gap-1.5", children: [
|
|
8384
|
+
tabType === "all" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8385
|
+
Segmented,
|
|
8386
|
+
{
|
|
8387
|
+
options: [
|
|
8388
|
+
{
|
|
8389
|
+
key: "keys",
|
|
8390
|
+
label: "Keys"
|
|
8391
|
+
},
|
|
8392
|
+
{
|
|
8393
|
+
key: "values",
|
|
8394
|
+
label: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-1", children: [
|
|
8395
|
+
"Search",
|
|
8396
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex h-[18px] items-center rounded-md bg-emerald-100 px-[5px] text-[11px] text-emerald-700", children: "NEW" })
|
|
8397
|
+
] })
|
|
8398
|
+
}
|
|
8399
|
+
],
|
|
8400
|
+
value: isValuesSearchSelected ? "values" : "keys",
|
|
8401
|
+
onChange: (value) => {
|
|
8402
|
+
setIsValuesSearchSelected(value === "values");
|
|
8403
|
+
},
|
|
8404
|
+
className: "bg-emerald-800",
|
|
8405
|
+
unselectedClassName: "text-emerald-100",
|
|
8406
|
+
selectedClassName: "bg-emerald-50 text-emerald-800"
|
|
8407
|
+
}
|
|
8408
|
+
),
|
|
8409
|
+
isValuesSearchSelected ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, IndexSelector, {}) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
8410
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DataTypeSelector, { allowSearch }),
|
|
8411
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SearchInput, {})
|
|
8412
|
+
] })
|
|
8413
|
+
] }),
|
|
8414
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-1.5", children: [
|
|
8415
|
+
isValuesSearchSelected && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WizardButton, {}),
|
|
8416
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, RefreshButton, {}),
|
|
8417
|
+
isValuesSearchSelected ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AddIndexButton, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AddKeyModal, {})
|
|
8418
|
+
] })
|
|
8419
|
+
] });
|
|
8420
|
+
};
|
|
8421
|
+
var IndexSelector = () => {
|
|
8422
|
+
const {
|
|
8423
|
+
valuesSearch: { index },
|
|
8424
|
+
setValuesSearchIndex
|
|
8425
|
+
} = useTab();
|
|
8426
|
+
const { data: indexes, isLoading } = useFetchSearchIndexes();
|
|
8427
|
+
const [open, setOpen] = _react.useState.call(void 0, false);
|
|
8428
|
+
_react.useEffect.call(void 0, () => {
|
|
8429
|
+
if (!indexes || isLoading) return;
|
|
8430
|
+
if (index && !indexes.includes(index)) {
|
|
8431
|
+
setValuesSearchIndex("");
|
|
8432
|
+
} else if (!index && indexes.length > 0) {
|
|
8433
|
+
setValuesSearchIndex(indexes[0]);
|
|
8434
|
+
}
|
|
8435
|
+
}, [indexes, index, isLoading, setValuesSearchIndex]);
|
|
8436
|
+
const [search, setSearch] = _react.useState.call(void 0, "");
|
|
8437
|
+
const [editingIndex, setEditingIndex] = _react.useState.call(void 0, );
|
|
8438
|
+
const filteredIndexes = _optionalChain([indexes, 'optionalAccess', _99 => _99.filter, 'call', _100 => _100((idx) => idx.toLowerCase().includes(search.toLowerCase()))]);
|
|
8439
|
+
const handleEditIndex = (indexName) => {
|
|
8440
|
+
setOpen(false);
|
|
8441
|
+
setEditingIndex(indexName);
|
|
8442
|
+
};
|
|
8443
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex", children: [
|
|
8444
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex items-center rounded-l-lg border border-r-0 border-zinc-300 bg-white px-3 text-sm text-zinc-700", children: "Index" }),
|
|
8445
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
8446
|
+
Popover,
|
|
8447
|
+
{
|
|
8448
|
+
open,
|
|
8449
|
+
onOpenChange: (isOpen) => {
|
|
8450
|
+
setOpen(isOpen);
|
|
8451
|
+
if (!isOpen) setSearch("");
|
|
8452
|
+
},
|
|
8453
|
+
modal: false,
|
|
8454
|
+
children: [
|
|
8455
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, PopoverTrigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "button", { className: "flex min-w-[140px] items-center justify-between gap-2 rounded-r-lg border border-zinc-300 bg-emerald-50 px-3 py-[5px] text-sm font-medium text-emerald-800 transition-colors hover:bg-emerald-100", children: [
|
|
8456
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "truncate", children: index || "Select an index" }),
|
|
8457
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconChevronDown, { className: "size-4 shrink-0 opacity-50" })
|
|
8458
|
+
] }) }),
|
|
8459
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, PopoverContent, { className: "p-2", align: "center", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex flex-col gap-2", children: [
|
|
8460
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CreateIndexButton, {}),
|
|
8461
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-px bg-zinc-100" }),
|
|
8462
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex h-9 items-center rounded-md border border-zinc-300 px-2", children: [
|
|
8463
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconSearch, { className: "size-5 text-zinc-400" }),
|
|
8464
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8465
|
+
"input",
|
|
8466
|
+
{
|
|
8467
|
+
value: search,
|
|
8468
|
+
onChange: (e) => setSearch(e.target.value),
|
|
8469
|
+
placeholder: "Search Index",
|
|
8470
|
+
className: "flex h-full w-full bg-transparent px-2 py-3 text-sm outline-none placeholder:text-zinc-400"
|
|
8471
|
+
}
|
|
8472
|
+
)
|
|
8473
|
+
] }),
|
|
8474
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "max-h-[200px] overflow-y-auto", children: [
|
|
8475
|
+
_optionalChain([filteredIndexes, 'optionalAccess', _101 => _101.length]) === 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "py-4 text-center text-sm text-zinc-500", children: "No indexes found" }),
|
|
8476
|
+
_optionalChain([filteredIndexes, 'optionalAccess', _102 => _102.map, 'call', _103 => _103((idx) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
8477
|
+
"div",
|
|
8478
|
+
{
|
|
8479
|
+
className: "flex h-9 items-center rounded-md px-2 transition-colors hover:bg-zinc-100 dark:hover:bg-zinc-200",
|
|
8480
|
+
children: [
|
|
8481
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
8482
|
+
"button",
|
|
8483
|
+
{
|
|
8484
|
+
onClick: () => {
|
|
8485
|
+
setValuesSearchIndex(idx);
|
|
8486
|
+
setOpen(false);
|
|
8487
|
+
},
|
|
8488
|
+
className: "flex flex-1 items-center gap-2 text-left text-sm",
|
|
8489
|
+
children: [
|
|
8490
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8491
|
+
"span",
|
|
8492
|
+
{
|
|
8493
|
+
className: cn(
|
|
8494
|
+
"flex size-5 items-center justify-center",
|
|
8495
|
+
idx === index ? "text-emerald-600" : "text-transparent"
|
|
8496
|
+
),
|
|
8497
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconCircleCheck, { className: "size-5" })
|
|
8498
|
+
}
|
|
8499
|
+
),
|
|
8500
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "truncate", children: idx })
|
|
8501
|
+
]
|
|
8502
|
+
}
|
|
8503
|
+
),
|
|
8504
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8505
|
+
"button",
|
|
8506
|
+
{
|
|
8507
|
+
onClick: (event) => {
|
|
8508
|
+
event.stopPropagation();
|
|
8509
|
+
event.preventDefault();
|
|
8510
|
+
handleEditIndex(idx);
|
|
8511
|
+
},
|
|
8512
|
+
className: "ml-2 text-sm text-zinc-500 underline hover:text-zinc-700",
|
|
8513
|
+
children: "Edit"
|
|
8514
|
+
}
|
|
8515
|
+
)
|
|
8516
|
+
]
|
|
8517
|
+
},
|
|
8518
|
+
idx
|
|
8519
|
+
))])
|
|
8520
|
+
] })
|
|
8521
|
+
] }) })
|
|
8522
|
+
]
|
|
8523
|
+
}
|
|
8524
|
+
),
|
|
8525
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8526
|
+
EditIndexModal,
|
|
8527
|
+
{
|
|
8528
|
+
open: Boolean(editingIndex),
|
|
8529
|
+
onOpenChange: (isOpen) => !isOpen && setEditingIndex(void 0),
|
|
8530
|
+
indexName: editingIndex
|
|
8531
|
+
}
|
|
8532
|
+
)
|
|
8533
|
+
] });
|
|
8534
|
+
};
|
|
8535
|
+
var CreateIndexButton = () => {
|
|
8536
|
+
const [open, setOpen] = _react.useState.call(void 0, false);
|
|
8537
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
8538
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
8539
|
+
"button",
|
|
8540
|
+
{
|
|
8541
|
+
onClick: (e) => {
|
|
8542
|
+
e.stopPropagation();
|
|
8543
|
+
setOpen(true);
|
|
8544
|
+
},
|
|
8545
|
+
className: "flex h-9 w-full items-center gap-2 rounded-md px-2 text-sm text-emerald-600 transition-colors hover:bg-zinc-100 dark:hover:bg-zinc-200",
|
|
8546
|
+
children: [
|
|
8547
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconCirclePlus, { className: "size-5" }),
|
|
8548
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "underline", children: "Create a new Index" })
|
|
8549
|
+
]
|
|
8550
|
+
}
|
|
8551
|
+
),
|
|
8552
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CreateIndexModal, { open, onOpenChange: setOpen })
|
|
8553
|
+
] });
|
|
8554
|
+
};
|
|
8555
|
+
var AddIndexButton = () => {
|
|
8556
|
+
const [open, setOpen] = _react.useState.call(void 0, false);
|
|
8557
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
8558
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SimpleTooltip, { content: "Create new Index", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
8559
|
+
Button,
|
|
8560
|
+
{
|
|
8561
|
+
variant: "primary",
|
|
8562
|
+
onClick: () => setOpen(true),
|
|
8563
|
+
className: "flex h-8 select-none items-center gap-1 rounded-lg pl-2 pr-3 text-sm font-medium",
|
|
8564
|
+
children: [
|
|
8565
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconPlus, { className: "size-5" }),
|
|
8566
|
+
"Index"
|
|
8567
|
+
]
|
|
8568
|
+
}
|
|
8569
|
+
) }),
|
|
8570
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, CreateIndexModal, { open, onOpenChange: setOpen })
|
|
8571
|
+
] });
|
|
8572
|
+
};
|
|
8573
|
+
var WizardButton = () => {
|
|
8574
|
+
const queryWizard = useQueryWizardFn();
|
|
8575
|
+
const [open, setOpen] = _react.useState.call(void 0, false);
|
|
8576
|
+
if (!queryWizard) return null;
|
|
8577
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Popover, { open, onOpenChange: setOpen, modal: false, children: [
|
|
8578
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SimpleTooltip, { content: "Query Wizard", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PopoverTrigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { size: "icon", "aria-label": "Query Wizard", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconSparkles, { className: "size-4 text-zinc-500" }) }) }) }),
|
|
8579
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8580
|
+
PopoverContent,
|
|
8581
|
+
{
|
|
8582
|
+
side: "bottom",
|
|
8583
|
+
align: "end",
|
|
8584
|
+
alignOffset: -124,
|
|
8585
|
+
avoidCollisions: false,
|
|
8586
|
+
className: "w-auto p-0",
|
|
8587
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, QueryWizardPopover, { onClose: () => setOpen(false) })
|
|
8588
|
+
}
|
|
8589
|
+
)
|
|
8590
|
+
] });
|
|
8081
8591
|
};
|
|
8082
8592
|
|
|
8083
|
-
|
|
8084
|
-
type: FieldType;
|
|
8085
|
-
noTokenize?: boolean;
|
|
8086
|
-
noStem?: boolean;
|
|
8087
|
-
fast?: boolean;
|
|
8088
|
-
};
|
|
8593
|
+
// src/components/databrowser/components/header-error.tsx
|
|
8089
8594
|
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
language?: Language;
|
|
8095
|
-
schema: Record<SchemaPaths<TSchema>, DescribeFieldInfo>;
|
|
8595
|
+
var HeaderError = () => {
|
|
8596
|
+
const { query } = useKeys();
|
|
8597
|
+
if (!query.error) return null;
|
|
8598
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-sm text-red-600 dark:text-red-400", children: formatUpstashErrorMessage(query.error) });
|
|
8096
8599
|
};
|
|
8097
8600
|
|
|
8098
|
-
|
|
8099
|
-
| "english"
|
|
8100
|
-
| "arabic"
|
|
8101
|
-
| "danish"
|
|
8102
|
-
| "dutch"
|
|
8103
|
-
| "finnish"
|
|
8104
|
-
| "french"
|
|
8105
|
-
| "german"
|
|
8106
|
-
| "greek"
|
|
8107
|
-
| "hungarian"
|
|
8108
|
-
| "italian"
|
|
8109
|
-
| "norwegian"
|
|
8110
|
-
| "portuguese"
|
|
8111
|
-
| "romanian"
|
|
8112
|
-
| "russian"
|
|
8113
|
-
| "spanish"
|
|
8114
|
-
| "swedish"
|
|
8115
|
-
| "tamil"
|
|
8116
|
-
| "turkish";
|
|
8601
|
+
// src/components/databrowser/components/search/query-editor.tsx
|
|
8117
8602
|
|
|
8118
|
-
`;
|
|
8119
8603
|
|
|
8120
8604
|
// src/components/databrowser/components/search/generate-query-type-definitions.tsx
|
|
8121
8605
|
var buildNestedSchema = (flatSchema) => {
|
|
@@ -8148,7 +8632,7 @@ var generateNestedInterface = (obj, indent = " ") => {
|
|
|
8148
8632
|
var toAmbientTypes = (types) => types.replaceAll(/export const (\w+) = (\[.*?]) as const;/g, "declare const $1: readonly $2;").replaceAll("export ", "");
|
|
8149
8633
|
var generateTypeDefinitions = (schema) => {
|
|
8150
8634
|
let schemaFieldsInterface = "";
|
|
8151
|
-
const schemaFields = _optionalChain([schema, 'optionalAccess',
|
|
8635
|
+
const schemaFields = _optionalChain([schema, 'optionalAccess', _104 => _104.schema]);
|
|
8152
8636
|
if (schemaFields && Object.keys(schemaFields).length > 0) {
|
|
8153
8637
|
const nested = buildNestedSchema(schemaFields);
|
|
8154
8638
|
const fieldLines = generateNestedInterface(nested);
|
|
@@ -8203,32 +8687,57 @@ var QueryBuilder = () => {
|
|
|
8203
8687
|
const { valuesSearch, setValuesSearchQuery } = useTab();
|
|
8204
8688
|
const { data: indexDetails } = useFetchSearchIndex(valuesSearch.index);
|
|
8205
8689
|
const editorValue = PREFIX + (valuesSearch.query || "{}");
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
|
|
8690
|
+
if (!indexDetails) return;
|
|
8691
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex h-full flex-col rounded-lg border border-zinc-300 bg-white px-[6px]", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8692
|
+
QueryEditor,
|
|
8693
|
+
{
|
|
8694
|
+
value: editorValue,
|
|
8695
|
+
onChange: (value) => {
|
|
8696
|
+
const queryPart = value.slice(PREFIX.length);
|
|
8697
|
+
setValuesSearchQuery(queryPart);
|
|
8698
|
+
},
|
|
8699
|
+
schema: indexDetails
|
|
8700
|
+
}
|
|
8701
|
+
) }) });
|
|
8702
|
+
};
|
|
8703
|
+
|
|
8704
|
+
// src/components/databrowser/components/query-builder-error.tsx
|
|
8705
|
+
|
|
8706
|
+
|
|
8707
|
+
var ERROR_TIMEOUT = 5e3;
|
|
8708
|
+
var QueryBuilderError = ({
|
|
8709
|
+
error,
|
|
8710
|
+
autoHide
|
|
8711
|
+
}) => {
|
|
8712
|
+
const [visible, setVisible] = _react.useState.call(void 0, false);
|
|
8713
|
+
const [displayedError, setDisplayedError] = _react.useState.call(void 0, );
|
|
8714
|
+
_react.useEffect.call(void 0, () => {
|
|
8715
|
+
let timeout;
|
|
8716
|
+
if (error) {
|
|
8717
|
+
setDisplayedError(error);
|
|
8718
|
+
setVisible(true);
|
|
8719
|
+
if (autoHide) {
|
|
8720
|
+
timeout = setTimeout(() => setVisible(false), ERROR_TIMEOUT);
|
|
8229
8721
|
}
|
|
8230
|
-
|
|
8231
|
-
|
|
8722
|
+
} else {
|
|
8723
|
+
setVisible(false);
|
|
8724
|
+
}
|
|
8725
|
+
return () => clearTimeout(timeout);
|
|
8726
|
+
}, [error, autoHide]);
|
|
8727
|
+
if (!displayedError) return;
|
|
8728
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8729
|
+
"p",
|
|
8730
|
+
{
|
|
8731
|
+
className: cn(
|
|
8732
|
+
"absolute bottom-2 left-2 z-[2] max-w-[70%] rounded-md bg-red-50 px-3 py-1.5 text-sm text-red-600 shadow-sm",
|
|
8733
|
+
visible ? "duration-200 animate-in fade-in slide-in-from-bottom-1" : "duration-200 animate-out fade-out slide-out-to-bottom-1 fill-mode-forwards"
|
|
8734
|
+
),
|
|
8735
|
+
onAnimationEnd: () => {
|
|
8736
|
+
if (!visible) setDisplayedError(void 0);
|
|
8737
|
+
},
|
|
8738
|
+
children: displayedError
|
|
8739
|
+
}
|
|
8740
|
+
);
|
|
8232
8741
|
};
|
|
8233
8742
|
|
|
8234
8743
|
// src/components/databrowser/components/search-empty-state.tsx
|
|
@@ -8389,7 +8898,7 @@ var ImportSampleDatasetModal = ({
|
|
|
8389
8898
|
if (await index.describe()) {
|
|
8390
8899
|
await index.drop();
|
|
8391
8900
|
}
|
|
8392
|
-
} catch (
|
|
8901
|
+
} catch (e6) {
|
|
8393
8902
|
}
|
|
8394
8903
|
await redis.search.createIndex({
|
|
8395
8904
|
dataType: "string",
|
|
@@ -8483,7 +8992,7 @@ var ImportSampleDatasetModal = ({
|
|
|
8483
8992
|
|
|
8484
8993
|
var SearchEmptyState = () => {
|
|
8485
8994
|
const [importModalOpen, setImportModalOpen] = _react.useState.call(void 0, false);
|
|
8486
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mx-auto flex h-full
|
|
8995
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "mx-auto flex h-full gap-8 rounded-xl border border-zinc-200 bg-gradient-to-b from-zinc-50 to-white p-8", children: [
|
|
8487
8996
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ImportSampleDatasetModal, { open: importModalOpen, onOpenChange: setImportModalOpen }),
|
|
8488
8997
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex-1", children: [
|
|
8489
8998
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { className: "mb-2 text-lg font-semibold text-zinc-900", children: "Redis Search" }),
|
|
@@ -8560,7 +9069,7 @@ var Empty = () => {
|
|
|
8560
9069
|
|
|
8561
9070
|
|
|
8562
9071
|
var SidebarContextMenu = ({ children }) => {
|
|
8563
|
-
const {
|
|
9072
|
+
const { mutateAsync: deleteKey } = useDeleteKey();
|
|
8564
9073
|
const [isAlertOpen, setAlertOpen] = _react.useState.call(void 0, false);
|
|
8565
9074
|
const [contextKeys, setContextKeys] = _react.useState.call(void 0, []);
|
|
8566
9075
|
const {
|
|
@@ -8569,7 +9078,7 @@ var SidebarContextMenu = ({ children }) => {
|
|
|
8569
9078
|
selectTab,
|
|
8570
9079
|
setSearch
|
|
8571
9080
|
} = useDatabrowserStore();
|
|
8572
|
-
const { search: currentSearch, selectedKeys } = useTab();
|
|
9081
|
+
const { search: currentSearch, selectedKeys, isValuesSearchSelected } = useTab();
|
|
8573
9082
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
8574
9083
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8575
9084
|
DeleteKeyModal,
|
|
@@ -8578,11 +9087,10 @@ var SidebarContextMenu = ({ children }) => {
|
|
|
8578
9087
|
count: contextKeys.length,
|
|
8579
9088
|
open: isAlertOpen,
|
|
8580
9089
|
onOpenChange: setAlertOpen,
|
|
8581
|
-
|
|
9090
|
+
showReindex: isValuesSearchSelected,
|
|
9091
|
+
onDeleteConfirm: async (e, options) => {
|
|
8582
9092
|
e.stopPropagation();
|
|
8583
|
-
|
|
8584
|
-
deleteKey(key);
|
|
8585
|
-
}
|
|
9093
|
+
await deleteKey({ keys: contextKeys, reindex: _optionalChain([options, 'optionalAccess', _105 => _105.reindex]) });
|
|
8586
9094
|
setAlertOpen(false);
|
|
8587
9095
|
}
|
|
8588
9096
|
}
|
|
@@ -8745,7 +9253,7 @@ var LoadingSkeleton = () => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div",
|
|
|
8745
9253
|
|
|
8746
9254
|
function Sidebar() {
|
|
8747
9255
|
const { keys, query } = useKeys();
|
|
8748
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "flex h-full flex-col gap-2", children: query.isLoading && keys.length === 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LoadingSkeleton, {}) : keys.length > 0 ? (
|
|
9256
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "relative flex h-full flex-col gap-2", children: query.isLoading && keys.length === 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LoadingSkeleton, {}) : keys.length > 0 ? (
|
|
8749
9257
|
// Infinite scroll already has a loader at the bottom
|
|
8750
9258
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
8751
9259
|
InfiniteScroll,
|
|
@@ -8768,18 +9276,19 @@ function Sidebar() {
|
|
|
8768
9276
|
|
|
8769
9277
|
// src/components/databrowser/components/ui-query-builder/types.ts
|
|
8770
9278
|
var STRING_OPERATORS = [
|
|
9279
|
+
"smart",
|
|
8771
9280
|
"eq",
|
|
8772
9281
|
"ne",
|
|
8773
9282
|
"in",
|
|
8774
9283
|
"phrase",
|
|
8775
9284
|
"regex",
|
|
8776
|
-
"fuzzy"
|
|
8777
|
-
"smart"
|
|
9285
|
+
"fuzzy"
|
|
8778
9286
|
];
|
|
8779
|
-
var NUMBER_OPERATORS = ["eq", "ne", "gt", "gte", "lt", "lte"
|
|
8780
|
-
var BOOLEAN_OPERATORS = ["eq", "ne"
|
|
8781
|
-
var DATE_OPERATORS =
|
|
9287
|
+
var NUMBER_OPERATORS = ["eq", "ne", "gt", "gte", "lt", "lte"];
|
|
9288
|
+
var BOOLEAN_OPERATORS = ["eq", "ne"];
|
|
9289
|
+
var DATE_OPERATORS = NUMBER_OPERATORS;
|
|
8782
9290
|
var ALL_OPERATORS = [
|
|
9291
|
+
"smart",
|
|
8783
9292
|
"eq",
|
|
8784
9293
|
"ne",
|
|
8785
9294
|
"gt",
|
|
@@ -8789,10 +9298,23 @@ var ALL_OPERATORS = [
|
|
|
8789
9298
|
"in",
|
|
8790
9299
|
"phrase",
|
|
8791
9300
|
"regex",
|
|
8792
|
-
"fuzzy"
|
|
8793
|
-
"smart"
|
|
9301
|
+
"fuzzy"
|
|
8794
9302
|
];
|
|
9303
|
+
var OPERATOR_DESCRIPTIONS = {
|
|
9304
|
+
eq: "Equals",
|
|
9305
|
+
ne: "Not equals",
|
|
9306
|
+
gt: "Greater than",
|
|
9307
|
+
gte: "Greater than or equal",
|
|
9308
|
+
lt: "Less than",
|
|
9309
|
+
lte: "Less than or equal",
|
|
9310
|
+
in: "Matches any of the given values, comma separated",
|
|
9311
|
+
phrase: "Matches an exact phrase",
|
|
9312
|
+
regex: "Matches a regular expression pattern",
|
|
9313
|
+
fuzzy: "Approximate match with custom edit distance",
|
|
9314
|
+
smart: "Default opinionated matching algorithm"
|
|
9315
|
+
};
|
|
8795
9316
|
var OPERATOR_OPTIONS = [
|
|
9317
|
+
{ value: "smart", label: "smart" },
|
|
8796
9318
|
{ value: "eq", label: "eq" },
|
|
8797
9319
|
{ value: "ne", label: "ne" },
|
|
8798
9320
|
{ value: "gt", label: "gt" },
|
|
@@ -8802,8 +9324,7 @@ var OPERATOR_OPTIONS = [
|
|
|
8802
9324
|
{ value: "in", label: "in" },
|
|
8803
9325
|
{ value: "phrase", label: "phrase" },
|
|
8804
9326
|
{ value: "regex", label: "regex" },
|
|
8805
|
-
{ value: "fuzzy", label: "fuzzy" }
|
|
8806
|
-
{ value: "smart", label: "smart" }
|
|
9327
|
+
{ value: "fuzzy", label: "fuzzy" }
|
|
8807
9328
|
];
|
|
8808
9329
|
var getOperatorsForFieldType = (fieldType) => {
|
|
8809
9330
|
switch (fieldType) {
|
|
@@ -8845,7 +9366,7 @@ var hasMustShouldCombination = (queryString) => {
|
|
|
8845
9366
|
const obj = parseJSObjectLiteral(queryString);
|
|
8846
9367
|
if (!obj) return false;
|
|
8847
9368
|
return hasMustShouldCombinationInObject(obj);
|
|
8848
|
-
} catch (
|
|
9369
|
+
} catch (e7) {
|
|
8849
9370
|
return false;
|
|
8850
9371
|
}
|
|
8851
9372
|
};
|
|
@@ -8871,12 +9392,13 @@ var isFieldConditionObject = (obj) => {
|
|
|
8871
9392
|
};
|
|
8872
9393
|
var parseFieldCondition = (field, fieldValue) => {
|
|
8873
9394
|
if (!isFieldConditionObject(fieldValue)) {
|
|
9395
|
+
const operator2 = typeof fieldValue === "boolean" || typeof fieldValue === "number" ? "eq" : "smart";
|
|
8874
9396
|
return {
|
|
8875
9397
|
id: generateId(),
|
|
8876
9398
|
type: "condition",
|
|
8877
9399
|
condition: {
|
|
8878
9400
|
field,
|
|
8879
|
-
operator:
|
|
9401
|
+
operator: operator2,
|
|
8880
9402
|
value: fieldValue
|
|
8881
9403
|
}
|
|
8882
9404
|
};
|
|
@@ -8907,20 +9429,23 @@ var parseFieldCondition = (field, fieldValue) => {
|
|
|
8907
9429
|
break;
|
|
8908
9430
|
}
|
|
8909
9431
|
}
|
|
9432
|
+
if (operator === "smart" && (typeof value === "boolean" || typeof value === "number")) {
|
|
9433
|
+
operator = "eq";
|
|
9434
|
+
}
|
|
8910
9435
|
if ("$boost" in fieldObj) {
|
|
8911
9436
|
boost = fieldObj.$boost;
|
|
8912
9437
|
}
|
|
8913
9438
|
return {
|
|
8914
9439
|
id: generateId(),
|
|
8915
9440
|
type: "condition",
|
|
9441
|
+
boost,
|
|
8916
9442
|
condition: {
|
|
8917
9443
|
field,
|
|
8918
9444
|
operator,
|
|
8919
9445
|
value,
|
|
8920
9446
|
fuzzyDistance,
|
|
8921
9447
|
phraseSlop,
|
|
8922
|
-
phrasePrefix
|
|
8923
|
-
boost
|
|
9448
|
+
phrasePrefix
|
|
8924
9449
|
}
|
|
8925
9450
|
};
|
|
8926
9451
|
};
|
|
@@ -8930,6 +9455,10 @@ var parseMultiFieldObject = (obj, operator) => {
|
|
|
8930
9455
|
for (const [key, value] of Object.entries(obj)) {
|
|
8931
9456
|
if (key === "$boost") {
|
|
8932
9457
|
boost = value;
|
|
9458
|
+
} else if (key === "$and" || key === "$or") {
|
|
9459
|
+
const nestedOp = key === "$and" ? "and" : "or";
|
|
9460
|
+
const nestedGroup = parseGroup(value, nestedOp);
|
|
9461
|
+
if (nestedGroup) children.push(nestedGroup);
|
|
8933
9462
|
} else if (!isOperatorKey(key)) {
|
|
8934
9463
|
children.push(parseFieldCondition(key, value));
|
|
8935
9464
|
}
|
|
@@ -9000,11 +9529,29 @@ var objectToQueryNode = (obj) => {
|
|
|
9000
9529
|
const operator = "$and" in obj ? "and" : "or";
|
|
9001
9530
|
const groupValue = _nullishCoalesce(obj["$and"], () => ( obj["$or"]));
|
|
9002
9531
|
const boost = "$boost" in obj ? obj.$boost : void 0;
|
|
9003
|
-
const groupNode = parseGroup(
|
|
9532
|
+
const groupNode = parseGroup(
|
|
9533
|
+
groupValue,
|
|
9534
|
+
operator,
|
|
9535
|
+
nonOperatorKeys.length === 0 ? boost : void 0
|
|
9536
|
+
);
|
|
9004
9537
|
if (groupNode && groupNode.type === "group" && hasMustNot) {
|
|
9005
9538
|
addMustNotChildren(groupNode, obj.$mustNot);
|
|
9006
9539
|
}
|
|
9007
|
-
|
|
9540
|
+
if (!groupNode || nonOperatorKeys.length === 0) {
|
|
9541
|
+
return groupNode;
|
|
9542
|
+
}
|
|
9543
|
+
const fieldChildren = nonOperatorKeys.map((key) => parseFieldCondition(key, obj[key]));
|
|
9544
|
+
const group = {
|
|
9545
|
+
id: generateId(),
|
|
9546
|
+
type: "group",
|
|
9547
|
+
groupOperator: "and",
|
|
9548
|
+
children: [...fieldChildren, groupNode],
|
|
9549
|
+
boost
|
|
9550
|
+
};
|
|
9551
|
+
if (hasMustNot) {
|
|
9552
|
+
addMustNotChildren(group, obj.$mustNot);
|
|
9553
|
+
}
|
|
9554
|
+
return group;
|
|
9008
9555
|
}
|
|
9009
9556
|
if (hasMustNot) {
|
|
9010
9557
|
if (nonOperatorKeys.length > 0) {
|
|
@@ -9053,7 +9600,7 @@ var parseQueryStringWithError = (queryString) => {
|
|
|
9053
9600
|
}
|
|
9054
9601
|
return { success: true, state: { root: root2 } };
|
|
9055
9602
|
}
|
|
9056
|
-
} catch (
|
|
9603
|
+
} catch (e8) {
|
|
9057
9604
|
}
|
|
9058
9605
|
return { success: false, error: "Failed to parse query" };
|
|
9059
9606
|
};
|
|
@@ -9240,8 +9787,7 @@ var moveNodeInTree = (root2, nodeId, newParentId, newIndex) => {
|
|
|
9240
9787
|
|
|
9241
9788
|
|
|
9242
9789
|
|
|
9243
|
-
// src/components/databrowser/components/ui-query-builder/
|
|
9244
|
-
|
|
9790
|
+
// src/components/databrowser/components/ui-query-builder/boost-badge.tsx
|
|
9245
9791
|
|
|
9246
9792
|
|
|
9247
9793
|
// src/components/databrowser/components/ui-query-builder/dynamic-width-input.tsx
|
|
@@ -9294,7 +9840,7 @@ var DynamicWidthInput = ({
|
|
|
9294
9840
|
);
|
|
9295
9841
|
};
|
|
9296
9842
|
|
|
9297
|
-
// src/components/databrowser/components/ui-query-builder/
|
|
9843
|
+
// src/components/databrowser/components/ui-query-builder/boost-badge.tsx
|
|
9298
9844
|
|
|
9299
9845
|
var BoostBadge = ({
|
|
9300
9846
|
node,
|
|
@@ -9325,7 +9871,13 @@ var BoostBadge = ({
|
|
|
9325
9871
|
const labelBg = isNegative ? "bg-red-50" : "bg-purple-50";
|
|
9326
9872
|
const textColor = isNegative ? "text-red-800" : "text-purple-800";
|
|
9327
9873
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "relative flex h-[26px] items-center overflow-hidden rounded-md border border-zinc-300 text-sm font-medium", children: [
|
|
9328
|
-
/* @__PURE__ */ _jsxruntime.
|
|
9874
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Tooltip, { delayDuration: 200, children: [
|
|
9875
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipTrigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: `flex h-full cursor-default items-center px-2 ${labelBg} ${textColor}`, children: isNegative ? "Demote" : "Boost" }) }),
|
|
9876
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, TooltipContent, { side: "bottom", className: "max-w-xs", children: [
|
|
9877
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: isNegative ? `Multiplies this condition's score by ${_nullishCoalesce(node.boost, () => ( 0))}, subtracting from the total.` : `Multiplies this condition's score by ${_nullishCoalesce(node.boost, () => ( 0))}.` }),
|
|
9878
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DocsLink, { href: "https://upstash-search.mintlify.app/redis/search/query-operators/boolean-operators/boost" })
|
|
9879
|
+
] })
|
|
9880
|
+
] }),
|
|
9329
9881
|
isStatic ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: `px-2 ${textColor}`, children: node.boost }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "flex h-full items-center bg-white px-2", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
9330
9882
|
DynamicWidthInput,
|
|
9331
9883
|
{
|
|
@@ -9339,7 +9891,33 @@ var BoostBadge = ({
|
|
|
9339
9891
|
) })
|
|
9340
9892
|
] });
|
|
9341
9893
|
};
|
|
9894
|
+
|
|
9895
|
+
// src/components/databrowser/components/ui-query-builder/dnd-context.tsx
|
|
9896
|
+
|
|
9897
|
+
|
|
9898
|
+
|
|
9899
|
+
|
|
9900
|
+
|
|
9901
|
+
|
|
9902
|
+
|
|
9903
|
+
var _core = require('@dnd-kit/core');
|
|
9904
|
+
|
|
9905
|
+
// src/components/databrowser/components/ui-query-builder/drag-overlay.tsx
|
|
9906
|
+
|
|
9907
|
+
|
|
9908
|
+
|
|
9909
|
+
// src/components/databrowser/components/ui-query-builder/not-badge.tsx
|
|
9910
|
+
|
|
9342
9911
|
var NotBadge = () => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "flex h-[26px] items-center rounded-md border border-zinc-300 bg-amber-50 px-2 text-sm font-medium text-amber-800", children: "Not" });
|
|
9912
|
+
|
|
9913
|
+
// src/components/databrowser/components/ui-query-builder/query-condition.tsx
|
|
9914
|
+
|
|
9915
|
+
|
|
9916
|
+
|
|
9917
|
+
// src/components/databrowser/components/ui-query-builder/node-actions-menu.tsx
|
|
9918
|
+
|
|
9919
|
+
|
|
9920
|
+
|
|
9343
9921
|
var NodeActionsMenu = ({ node }) => {
|
|
9344
9922
|
const { updateNode } = useQueryBuilderUI();
|
|
9345
9923
|
const [open, setOpen] = _react.useState.call(void 0, false);
|
|
@@ -9393,24 +9971,8 @@ var NodeActionsMenu = ({ node }) => {
|
|
|
9393
9971
|
] });
|
|
9394
9972
|
};
|
|
9395
9973
|
|
|
9396
|
-
// src/components/databrowser/components/ui-query-builder/dnd-context.tsx
|
|
9397
|
-
|
|
9398
|
-
|
|
9399
|
-
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
var _core = require('@dnd-kit/core');
|
|
9405
|
-
|
|
9406
|
-
// src/components/databrowser/components/ui-query-builder/drag-overlay.tsx
|
|
9407
|
-
|
|
9408
|
-
|
|
9409
|
-
|
|
9410
9974
|
// src/components/databrowser/components/ui-query-builder/query-condition.tsx
|
|
9411
9975
|
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
9976
|
var formatValueForDisplay = (value) => {
|
|
9415
9977
|
if (Array.isArray(value)) {
|
|
9416
9978
|
return value.join(", ");
|
|
@@ -9435,7 +9997,7 @@ var QueryCondition = ({
|
|
|
9435
9997
|
setLocalValue(formattedConditionValue);
|
|
9436
9998
|
}
|
|
9437
9999
|
const currentFieldInfo = fieldInfos.find((f) => f.name === condition.field);
|
|
9438
|
-
const currentFieldType = _nullishCoalesce(_optionalChain([currentFieldInfo, 'optionalAccess',
|
|
10000
|
+
const currentFieldType = _nullishCoalesce(_optionalChain([currentFieldInfo, 'optionalAccess', _106 => _106.type]), () => ( "unknown"));
|
|
9439
10001
|
const isUnknownField = condition.field && !fieldNames.includes(condition.field);
|
|
9440
10002
|
const getValueTypeError = () => {
|
|
9441
10003
|
if (isUnknownField || currentFieldType === "unknown" || currentFieldType === "string") {
|
|
@@ -9493,8 +10055,8 @@ var QueryCondition = ({
|
|
|
9493
10055
|
}
|
|
9494
10056
|
}, [currentFieldType, condition.value]);
|
|
9495
10057
|
const handleFieldChange = (value) => {
|
|
9496
|
-
const newFieldInfo = _optionalChain([fieldInfos, 'optionalAccess',
|
|
9497
|
-
const newFieldType = _nullishCoalesce(_optionalChain([newFieldInfo, 'optionalAccess',
|
|
10058
|
+
const newFieldInfo = _optionalChain([fieldInfos, 'optionalAccess', _107 => _107.find, 'call', _108 => _108((f) => f.name === value)]);
|
|
10059
|
+
const newFieldType = _nullishCoalesce(_optionalChain([newFieldInfo, 'optionalAccess', _109 => _109.type]), () => ( "unknown"));
|
|
9498
10060
|
const validOperators = getOperatorsForFieldType(newFieldType);
|
|
9499
10061
|
const isOperatorValid = validOperators.includes(condition.operator);
|
|
9500
10062
|
let newValue = condition.value;
|
|
@@ -9635,10 +10197,10 @@ var QueryCondition = ({
|
|
|
9635
10197
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
9636
10198
|
"div",
|
|
9637
10199
|
{
|
|
9638
|
-
ref: _optionalChain([dragHandleProps, 'optionalAccess',
|
|
10200
|
+
ref: _optionalChain([dragHandleProps, 'optionalAccess', _110 => _110.ref]),
|
|
9639
10201
|
className: "flex cursor-grab items-center px-1 text-zinc-400 hover:text-zinc-600",
|
|
9640
|
-
..._optionalChain([dragHandleProps, 'optionalAccess',
|
|
9641
|
-
..._optionalChain([dragHandleProps, 'optionalAccess',
|
|
10202
|
+
..._optionalChain([dragHandleProps, 'optionalAccess', _111 => _111.attributes]),
|
|
10203
|
+
..._optionalChain([dragHandleProps, 'optionalAccess', _112 => _112.listeners]),
|
|
9642
10204
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconGripVertical, { size: 16 })
|
|
9643
10205
|
}
|
|
9644
10206
|
),
|
|
@@ -9681,7 +10243,15 @@ var QueryCondition = ({
|
|
|
9681
10243
|
},
|
|
9682
10244
|
condition.operator
|
|
9683
10245
|
),
|
|
9684
|
-
filteredOperators.map((op) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
10246
|
+
filteredOperators.map((op) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
10247
|
+
SelectItem,
|
|
10248
|
+
{
|
|
10249
|
+
value: op.value,
|
|
10250
|
+
description: OPERATOR_DESCRIPTIONS[op.value],
|
|
10251
|
+
children: op.label
|
|
10252
|
+
},
|
|
10253
|
+
op.value
|
|
10254
|
+
))
|
|
9685
10255
|
] })
|
|
9686
10256
|
] }),
|
|
9687
10257
|
currentFieldType === "boolean" && condition.operator === "in" ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex h-[26px] items-center gap-2 rounded-none rounded-r-md border border-zinc-200 bg-white px-2 text-sm", children: [
|
|
@@ -9763,8 +10333,15 @@ var QueryCondition = ({
|
|
|
9763
10333
|
children: [
|
|
9764
10334
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectTrigger, { className: "h-[26px] w-16 gap-3 border-zinc-200 bg-white px-2 text-sm", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectValue, {}) }),
|
|
9765
10335
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, SelectContent, { children: [
|
|
9766
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
9767
|
-
|
|
10336
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
10337
|
+
SelectItem,
|
|
10338
|
+
{
|
|
10339
|
+
value: "1",
|
|
10340
|
+
description: "Matches words with 1 character edit (e.g. 'teh' \u2192 'the')",
|
|
10341
|
+
children: "1"
|
|
10342
|
+
}
|
|
10343
|
+
),
|
|
10344
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectItem, { value: "2", description: "Matches words with up to 2 character edits", children: "2" })
|
|
9768
10345
|
] })
|
|
9769
10346
|
]
|
|
9770
10347
|
}
|
|
@@ -9773,9 +10350,23 @@ var QueryCondition = ({
|
|
|
9773
10350
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Select, { value: phraseMode, onValueChange: handlePhraseModeChange, children: [
|
|
9774
10351
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectTrigger, { className: "h-[26px] w-20 gap-3 border-zinc-200 bg-white px-2 text-sm font-normal", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectValue, {}) }),
|
|
9775
10352
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, SelectContent, { children: [
|
|
9776
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectItem, { value: "exact", children: "exact" }),
|
|
9777
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
9778
|
-
|
|
10353
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SelectItem, { value: "exact", description: "Terms must appear adjacent to each other", children: "exact" }),
|
|
10354
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
10355
|
+
SelectItem,
|
|
10356
|
+
{
|
|
10357
|
+
value: "slop",
|
|
10358
|
+
description: "Allow custom number of intervening words between terms",
|
|
10359
|
+
children: "slop"
|
|
10360
|
+
}
|
|
10361
|
+
),
|
|
10362
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
10363
|
+
SelectItem,
|
|
10364
|
+
{
|
|
10365
|
+
value: "prefix",
|
|
10366
|
+
description: "Last term matches as a prefix (e.g. 'wireless head' \u2192 'headphones')",
|
|
10367
|
+
children: "prefix"
|
|
10368
|
+
}
|
|
10369
|
+
)
|
|
9779
10370
|
] })
|
|
9780
10371
|
] }),
|
|
9781
10372
|
phraseMode === "slop" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -9791,6 +10382,7 @@ var QueryCondition = ({
|
|
|
9791
10382
|
}
|
|
9792
10383
|
)
|
|
9793
10384
|
] }),
|
|
10385
|
+
node.not && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NotBadge, {}),
|
|
9794
10386
|
node.boost !== void 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BoostBadge, { node }),
|
|
9795
10387
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
9796
10388
|
"div",
|
|
@@ -10027,6 +10619,7 @@ var DraggableItem = ({
|
|
|
10027
10619
|
// src/components/databrowser/components/ui-query-builder/drop-zone.tsx
|
|
10028
10620
|
|
|
10029
10621
|
|
|
10622
|
+
|
|
10030
10623
|
var DropIndicator = ({ id, isOver }) => {
|
|
10031
10624
|
const { setNodeRef } = _core.useDroppable.call(void 0, { id });
|
|
10032
10625
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref: setNodeRef, className: `relative flex h-2 items-center`, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -10039,14 +10632,26 @@ var DropIndicator = ({ id, isOver }) => {
|
|
|
10039
10632
|
}
|
|
10040
10633
|
) });
|
|
10041
10634
|
};
|
|
10042
|
-
var EmptyGroupDropZone = ({
|
|
10635
|
+
var EmptyGroupDropZone = ({
|
|
10636
|
+
groupId,
|
|
10637
|
+
isOver,
|
|
10638
|
+
onAddCondition
|
|
10639
|
+
}) => {
|
|
10043
10640
|
const { setNodeRef } = _core.useDroppable.call(void 0, { id: `drop-${groupId}-end` });
|
|
10044
|
-
return /* @__PURE__ */ _jsxruntime.
|
|
10045
|
-
"
|
|
10641
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
10642
|
+
"button",
|
|
10046
10643
|
{
|
|
10644
|
+
type: "button",
|
|
10047
10645
|
ref: setNodeRef,
|
|
10048
|
-
|
|
10049
|
-
|
|
10646
|
+
onClick: onAddCondition,
|
|
10647
|
+
className: cn(
|
|
10648
|
+
"mt-2 flex h-8 w-full items-center justify-center gap-1.5 rounded-md border border-dashed text-sm transition-all",
|
|
10649
|
+
isOver ? "border-blue-500 bg-blue-50 text-blue-600" : "border-zinc-300 text-zinc-400 hover:border-zinc-400 hover:bg-zinc-50 hover:text-zinc-500"
|
|
10650
|
+
),
|
|
10651
|
+
children: [
|
|
10652
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconPlus, { size: 14 }),
|
|
10653
|
+
"Add a condition"
|
|
10654
|
+
]
|
|
10050
10655
|
}
|
|
10051
10656
|
);
|
|
10052
10657
|
};
|
|
@@ -10093,9 +10698,7 @@ var InnerGroup = ({
|
|
|
10093
10698
|
addChildToGroup(node.id, createEmptyCondition(fieldInfos));
|
|
10094
10699
|
};
|
|
10095
10700
|
const handleAddGroup = () => {
|
|
10096
|
-
|
|
10097
|
-
newGroup.children = [createEmptyCondition(fieldInfos)];
|
|
10098
|
-
addChildToGroup(node.id, newGroup);
|
|
10701
|
+
addChildToGroup(node.id, createEmptyGroup("and"));
|
|
10099
10702
|
};
|
|
10100
10703
|
const handleDeleteGroup = () => {
|
|
10101
10704
|
deleteNode(node.id);
|
|
@@ -10105,10 +10708,10 @@ var InnerGroup = ({
|
|
|
10105
10708
|
!isRoot && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
10106
10709
|
"div",
|
|
10107
10710
|
{
|
|
10108
|
-
ref: _optionalChain([dragHandleProps, 'optionalAccess',
|
|
10711
|
+
ref: _optionalChain([dragHandleProps, 'optionalAccess', _113 => _113.ref]),
|
|
10109
10712
|
className: "flex cursor-grab items-center px-1 text-zinc-400",
|
|
10110
|
-
..._optionalChain([dragHandleProps, 'optionalAccess',
|
|
10111
|
-
..._optionalChain([dragHandleProps, 'optionalAccess',
|
|
10713
|
+
..._optionalChain([dragHandleProps, 'optionalAccess', _114 => _114.attributes]),
|
|
10714
|
+
..._optionalChain([dragHandleProps, 'optionalAccess', _115 => _115.listeners]),
|
|
10112
10715
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconGripVertical, { size: 16 })
|
|
10113
10716
|
}
|
|
10114
10717
|
),
|
|
@@ -10134,6 +10737,7 @@ var InnerGroup = ({
|
|
|
10134
10737
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DropdownMenuItem, { onClick: handleAddGroup, children: "Add Group" })
|
|
10135
10738
|
] })
|
|
10136
10739
|
] }),
|
|
10740
|
+
node.not && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NotBadge, {}),
|
|
10137
10741
|
node.boost !== void 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BoostBadge, { node }),
|
|
10138
10742
|
!isRoot && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
10139
10743
|
"div",
|
|
@@ -10154,7 +10758,14 @@ var InnerGroup = ({
|
|
|
10154
10758
|
}
|
|
10155
10759
|
)
|
|
10156
10760
|
] }),
|
|
10157
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: `min-h-[20px] ${isRoot ? "" : "ml-[15px] border-l-2 border-zinc-200 pl-3"}`, children: node.children.length === 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
10761
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: `min-h-[20px] ${isRoot ? "" : "ml-[15px] border-l-2 border-zinc-200 pl-3"}`, children: node.children.length === 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
10762
|
+
EmptyGroupDropZone,
|
|
10763
|
+
{
|
|
10764
|
+
groupId: node.id,
|
|
10765
|
+
isOver: activeOverId === `drop-${node.id}-end`,
|
|
10766
|
+
onAddCondition: fieldInfos.length > 0 ? handleAddCondition : void 0
|
|
10767
|
+
}
|
|
10768
|
+
) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
10158
10769
|
node.children.map(
|
|
10159
10770
|
(child) => !child.not && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
10160
10771
|
ChildRow,
|
|
@@ -10170,20 +10781,10 @@ var InnerGroup = ({
|
|
|
10170
10781
|
),
|
|
10171
10782
|
node.children.some((child) => child.not) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Tooltip, { delayDuration: 200, children: [
|
|
10172
10783
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipTrigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "ml-2 mt-2 flex h-[26px] w-fit cursor-default select-none items-center rounded-md border border-zinc-300 bg-amber-50 px-2 text-sm font-medium capitalize text-amber-800", children: "Must Not" }) }),
|
|
10173
|
-
/* @__PURE__ */ _jsxruntime.
|
|
10174
|
-
"Keys matching any of the conditions below are excluded from the results.",
|
|
10175
|
-
"
|
|
10176
|
-
|
|
10177
|
-
"a",
|
|
10178
|
-
{
|
|
10179
|
-
href: "https://upstash-search.mintlify.app/redis/search/query-operators/boolean-operators/must-not",
|
|
10180
|
-
target: "_blank",
|
|
10181
|
-
rel: "noopener noreferrer",
|
|
10182
|
-
className: "underline",
|
|
10183
|
-
children: "Learn more"
|
|
10184
|
-
}
|
|
10185
|
-
)
|
|
10186
|
-
] }) })
|
|
10784
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, TooltipContent, { side: "right", className: "max-w-xs", children: [
|
|
10785
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "Keys matching any of the conditions below are excluded from the results." }),
|
|
10786
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DocsLink, { href: "https://upstash-search.mintlify.app/redis/search/query-operators/boolean-operators/must-not" })
|
|
10787
|
+
] })
|
|
10187
10788
|
] }),
|
|
10188
10789
|
node.children.map(
|
|
10189
10790
|
(child) => child.not && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -10248,12 +10849,6 @@ var QueryGroup = ({ node, isRoot = false, depth }) => {
|
|
|
10248
10849
|
|
|
10249
10850
|
|
|
10250
10851
|
// src/components/databrowser/components/ui-query-builder/query-stringify.ts
|
|
10251
|
-
var jsonToJsLiteral = (json) => {
|
|
10252
|
-
return json.replaceAll(/"([$A-Z_a-z][\w$]*)"\s*:/g, "$1:");
|
|
10253
|
-
};
|
|
10254
|
-
var toJsLiteral = (obj) => {
|
|
10255
|
-
return jsonToJsLiteral(JSON.stringify(obj, null, 2));
|
|
10256
|
-
};
|
|
10257
10852
|
var buildOperatorValue = (operator, value, fuzzyDistance, phraseSlop, phrasePrefix) => {
|
|
10258
10853
|
if (operator === "fuzzy" && fuzzyDistance) {
|
|
10259
10854
|
return { value, distance: fuzzyDistance };
|
|
@@ -10279,7 +10874,8 @@ var conditionToObject = (node) => {
|
|
|
10279
10874
|
phrasePrefix
|
|
10280
10875
|
} = node.condition;
|
|
10281
10876
|
const effectiveBoost = _nullishCoalesce(node.boost, () => ( conditionBoost));
|
|
10282
|
-
|
|
10877
|
+
const isCollapsibleEq = operator === "eq" && (typeof value === "boolean" || typeof value === "number");
|
|
10878
|
+
if ((operator === "smart" || isCollapsibleEq) && !effectiveBoost) {
|
|
10283
10879
|
return { [field]: value };
|
|
10284
10880
|
}
|
|
10285
10881
|
const fieldCondition = {
|
|
@@ -10292,15 +10888,15 @@ var conditionToObject = (node) => {
|
|
|
10292
10888
|
return { [field]: fieldCondition };
|
|
10293
10889
|
};
|
|
10294
10890
|
var canMergeChildren = (children) => {
|
|
10295
|
-
|
|
10296
|
-
|
|
10297
|
-
);
|
|
10891
|
+
if (!children.every((child) => child.type === "condition" && !child.not)) return false;
|
|
10892
|
+
const fields = children.map((c) => c.condition.field);
|
|
10893
|
+
return new Set(fields).size === fields.length;
|
|
10298
10894
|
};
|
|
10299
10895
|
var mergeConditions = (children, boost) => {
|
|
10300
10896
|
const merged = {};
|
|
10301
10897
|
for (const child of children) {
|
|
10302
10898
|
if (child.type === "condition") {
|
|
10303
|
-
merged
|
|
10899
|
+
Object.assign(merged, conditionToObject(child));
|
|
10304
10900
|
}
|
|
10305
10901
|
}
|
|
10306
10902
|
if (boost && boost !== 1) {
|
|
@@ -10308,7 +10904,14 @@ var mergeConditions = (children, boost) => {
|
|
|
10308
10904
|
}
|
|
10309
10905
|
return merged;
|
|
10310
10906
|
};
|
|
10311
|
-
var
|
|
10907
|
+
var buildMustNot = (negatedChildren) => {
|
|
10908
|
+
const negatedObjects = negatedChildren.map((child) => {
|
|
10909
|
+
const withoutNot = { ...child, not: void 0 };
|
|
10910
|
+
return queryNodeToObject(withoutNot, false);
|
|
10911
|
+
});
|
|
10912
|
+
return negatedObjects.length === 1 ? negatedObjects[0] : negatedObjects;
|
|
10913
|
+
};
|
|
10914
|
+
var groupToObject = (node, isRoot, forArray = false) => {
|
|
10312
10915
|
const { groupOperator, children, boost, not } = node;
|
|
10313
10916
|
const normalChildren = children.filter((c) => !c.not);
|
|
10314
10917
|
const negatedChildren = children.filter((c) => c.not);
|
|
@@ -10324,41 +10927,84 @@ var groupToObject = (node, isRoot) => {
|
|
|
10324
10927
|
}
|
|
10325
10928
|
return { $mustNot: [inner] };
|
|
10326
10929
|
}
|
|
10327
|
-
if (isRoot && groupOperator === "and" &&
|
|
10328
|
-
|
|
10930
|
+
if (isRoot && groupOperator === "and" && negatedChildren.length === 0) {
|
|
10931
|
+
if (normalChildren.length === 1) {
|
|
10932
|
+
const result2 = queryNodeToObject(normalChildren[0], false);
|
|
10933
|
+
if (boost && boost !== 1) result2.$boost = boost;
|
|
10934
|
+
return result2;
|
|
10935
|
+
}
|
|
10936
|
+
const conditionChildren = normalChildren.filter((c) => c.type === "condition");
|
|
10937
|
+
const groupChildren = normalChildren.filter((c) => c.type === "group");
|
|
10938
|
+
const hasConflictingGroupChild = groupChildren.some(
|
|
10939
|
+
(c) => c.groupOperator === groupOperator && c.children.length > 1 && c.boost
|
|
10940
|
+
);
|
|
10941
|
+
if (!hasConflictingGroupChild) {
|
|
10942
|
+
const fields = conditionChildren.map(
|
|
10943
|
+
(c) => c.condition.field
|
|
10944
|
+
);
|
|
10945
|
+
const groupOps = groupChildren.map((c) => `$${c.groupOperator}`);
|
|
10946
|
+
const allKeys = [...fields, ...groupOps];
|
|
10947
|
+
const hasConflicts = new Set(allKeys).size !== allKeys.length;
|
|
10948
|
+
if (!hasConflicts) {
|
|
10949
|
+
const result2 = {};
|
|
10950
|
+
for (const child of conditionChildren) {
|
|
10951
|
+
Object.assign(result2, conditionToObject(child));
|
|
10952
|
+
}
|
|
10953
|
+
for (const child of groupChildren) {
|
|
10954
|
+
Object.assign(result2, groupToObject(child, false));
|
|
10955
|
+
}
|
|
10956
|
+
if (boost && boost !== 1) result2.$boost = boost;
|
|
10957
|
+
return result2;
|
|
10958
|
+
}
|
|
10959
|
+
}
|
|
10329
10960
|
}
|
|
10330
|
-
if (normalChildren.length > 0 &&
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
|
|
10961
|
+
if (normalChildren.length > 0 && canMergeChildren(normalChildren)) {
|
|
10962
|
+
if (isRoot && groupOperator === "and" && negatedChildren.length === 0) {
|
|
10963
|
+
return mergeConditions(normalChildren, boost);
|
|
10964
|
+
}
|
|
10965
|
+
const result2 = {};
|
|
10966
|
+
if (forArray) {
|
|
10967
|
+
result2[`$${groupOperator}`] = mergeConditions(normalChildren);
|
|
10968
|
+
if (boost && boost !== 1) result2.$boost = boost;
|
|
10969
|
+
} else {
|
|
10970
|
+
result2[`$${groupOperator}`] = mergeConditions(normalChildren, boost);
|
|
10334
10971
|
}
|
|
10335
|
-
|
|
10336
|
-
|
|
10337
|
-
result2.$boost = boost;
|
|
10972
|
+
if (negatedChildren.length > 0) {
|
|
10973
|
+
result2.$mustNot = buildMustNot(negatedChildren);
|
|
10338
10974
|
}
|
|
10339
10975
|
return result2;
|
|
10340
10976
|
}
|
|
10341
10977
|
const result = {};
|
|
10342
10978
|
if (normalChildren.length > 0) {
|
|
10343
|
-
result[`$${groupOperator}`] = normalChildren.map((child) =>
|
|
10979
|
+
result[`$${groupOperator}`] = normalChildren.map((child) => {
|
|
10980
|
+
if (child.type === "group") {
|
|
10981
|
+
const groupChild = child;
|
|
10982
|
+
const gc = groupChild.children;
|
|
10983
|
+
const gcNormal = gc.filter((c) => !c.not);
|
|
10984
|
+
const gcNegated = gc.filter((c) => c.not);
|
|
10985
|
+
if (groupChild.groupOperator === groupOperator && gc.length > 1 && gcNegated.length === 0 && canMergeChildren(gcNormal)) {
|
|
10986
|
+
return mergeConditions(gcNormal, groupChild.boost);
|
|
10987
|
+
}
|
|
10988
|
+
}
|
|
10989
|
+
return queryNodeToObject(child, false, true);
|
|
10990
|
+
});
|
|
10991
|
+
} else if (negatedChildren.length > 0) {
|
|
10992
|
+
result[`$${groupOperator}`] = {};
|
|
10344
10993
|
}
|
|
10345
10994
|
if (negatedChildren.length > 0) {
|
|
10346
|
-
result.$mustNot = negatedChildren
|
|
10347
|
-
const withoutNot = { ...child, not: void 0 };
|
|
10348
|
-
return queryNodeToObject(withoutNot, false);
|
|
10349
|
-
});
|
|
10995
|
+
result.$mustNot = buildMustNot(negatedChildren);
|
|
10350
10996
|
}
|
|
10351
10997
|
if (boost && boost !== 1) {
|
|
10352
10998
|
result.$boost = boost;
|
|
10353
10999
|
}
|
|
10354
11000
|
return result;
|
|
10355
11001
|
};
|
|
10356
|
-
var queryNodeToObject = (node, isRoot = false) => {
|
|
11002
|
+
var queryNodeToObject = (node, isRoot = false, forArray = false) => {
|
|
10357
11003
|
if (node.type === "condition") {
|
|
10358
11004
|
return conditionToObject(node);
|
|
10359
11005
|
}
|
|
10360
11006
|
if (node.type === "group") {
|
|
10361
|
-
return groupToObject(node, isRoot);
|
|
11007
|
+
return groupToObject(node, isRoot, forArray);
|
|
10362
11008
|
}
|
|
10363
11009
|
return {};
|
|
10364
11010
|
};
|
|
@@ -10414,7 +11060,7 @@ var UIQueryBuilder = () => {
|
|
|
10414
11060
|
const { valuesSearch } = useTab();
|
|
10415
11061
|
const { data: indexDetails } = useFetchSearchIndex(valuesSearch.index);
|
|
10416
11062
|
const { queryState, setQueryState } = useQueryStateSync();
|
|
10417
|
-
const fieldInfos = _optionalChain([indexDetails, 'optionalAccess',
|
|
11063
|
+
const fieldInfos = _optionalChain([indexDetails, 'optionalAccess', _116 => _116.schema]) ? extractFieldInfo(indexDetails.schema) : [];
|
|
10418
11064
|
const hasNormalized = _react.useRef.call(void 0, false);
|
|
10419
11065
|
_react.useEffect.call(void 0, () => {
|
|
10420
11066
|
if (hasNormalized.current || fieldInfos.length === 0) return;
|
|
@@ -10433,7 +11079,7 @@ var UIQueryBuilder = () => {
|
|
|
10433
11079
|
setHasBottomShadow(scrollTop + clientHeight < scrollHeight - 1);
|
|
10434
11080
|
}, []);
|
|
10435
11081
|
_react.useEffect.call(void 0, () => {
|
|
10436
|
-
viewportRef.current = _optionalChain([scrollAreaRef, 'access',
|
|
11082
|
+
viewportRef.current = _optionalChain([scrollAreaRef, 'access', _117 => _117.current, 'optionalAccess', _118 => _118.querySelector, 'call', _119 => _119(
|
|
10437
11083
|
"[data-radix-scroll-area-viewport]"
|
|
10438
11084
|
)]);
|
|
10439
11085
|
recomputeShadows();
|
|
@@ -10443,7 +11089,7 @@ var UIQueryBuilder = () => {
|
|
|
10443
11089
|
obs.observe(el);
|
|
10444
11090
|
return () => obs.disconnect();
|
|
10445
11091
|
}, [recomputeShadows]);
|
|
10446
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, QueryBuilderUIProvider, { fieldInfos, setQueryState, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "relative h-full rounded-lg bg-zinc-50", children: [
|
|
11092
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, QueryBuilderUIProvider, { fieldInfos, setQueryState, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "relative h-full rounded-lg bg-zinc-50 dark:bg-zinc-50/40", children: [
|
|
10447
11093
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
10448
11094
|
"div",
|
|
10449
11095
|
{
|
|
@@ -10539,41 +11185,47 @@ var extractFieldInfo = (schema) => {
|
|
|
10539
11185
|
|
|
10540
11186
|
var PREFIX = "const query: Query = ";
|
|
10541
11187
|
var QueryBuilderContent = () => {
|
|
10542
|
-
const { valuesSearch } = useTab();
|
|
10543
|
-
const
|
|
10544
|
-
const [switchError, setSwitchError] = _react.useState.call(void 0,
|
|
11188
|
+
const { valuesSearch, queryBuilderMode, setQueryBuilderMode } = useTab();
|
|
11189
|
+
const { query } = useKeys();
|
|
11190
|
+
const [switchError, setSwitchError] = _react.useState.call(void 0, );
|
|
10545
11191
|
const handleModeChange = (value) => {
|
|
10546
11192
|
const newMode = value;
|
|
10547
|
-
if (newMode === "
|
|
11193
|
+
if (newMode === "ui") {
|
|
10548
11194
|
if (hasMustShouldCombination(valuesSearch.query)) {
|
|
10549
11195
|
setSwitchError(
|
|
10550
11196
|
"Queries using both $must and $should are not supported in the UI query builder"
|
|
10551
11197
|
);
|
|
10552
11198
|
return;
|
|
10553
11199
|
}
|
|
10554
|
-
setSwitchError(
|
|
11200
|
+
setSwitchError(void 0);
|
|
10555
11201
|
} else {
|
|
10556
|
-
setSwitchError(
|
|
11202
|
+
setSwitchError(void 0);
|
|
10557
11203
|
}
|
|
10558
|
-
|
|
11204
|
+
setQueryBuilderMode(newMode);
|
|
10559
11205
|
};
|
|
10560
|
-
|
|
10561
|
-
|
|
10562
|
-
|
|
10563
|
-
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
|
|
10573
|
-
|
|
10574
|
-
|
|
10575
|
-
|
|
10576
|
-
|
|
11206
|
+
const errorMessage = _nullishCoalesce(switchError, () => ( (query.error ? formatUpstashErrorMessage(query.error) : void 0)));
|
|
11207
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "relative h-full", children: [
|
|
11208
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "absolute right-4 top-4 z-[2]", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
11209
|
+
Segmented,
|
|
11210
|
+
{
|
|
11211
|
+
options: [
|
|
11212
|
+
{ key: "ui", label: "Query Builder" },
|
|
11213
|
+
{ key: "code", label: "Code Editor" }
|
|
11214
|
+
],
|
|
11215
|
+
value: queryBuilderMode,
|
|
11216
|
+
onChange: handleModeChange,
|
|
11217
|
+
buttonClassName: "h-6"
|
|
11218
|
+
}
|
|
11219
|
+
) }),
|
|
11220
|
+
queryBuilderMode === "ui" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UIQueryBuilder, {}) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, QueryBuilder, {}),
|
|
11221
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, QueryBuilderError, { error: errorMessage, autoHide: Boolean(switchError) }),
|
|
11222
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
11223
|
+
DocsLink,
|
|
11224
|
+
{
|
|
11225
|
+
className: "absolute bottom-2 right-2 text-sm",
|
|
11226
|
+
href: "https://upstash-search.mintlify.app/redis/search/query-operators/boolean-operators/overview"
|
|
11227
|
+
}
|
|
11228
|
+
)
|
|
10577
11229
|
] });
|
|
10578
11230
|
};
|
|
10579
11231
|
var SearchContent = () => {
|
|
@@ -10606,16 +11258,31 @@ var DatabrowserInstance = ({
|
|
|
10606
11258
|
"div",
|
|
10607
11259
|
{
|
|
10608
11260
|
className: cn(
|
|
10609
|
-
"flex min-h-0 grow flex-col rounded-
|
|
11261
|
+
"flex min-h-0 grow flex-col rounded-[10px] bg-white px-5 pb-5",
|
|
10610
11262
|
hidden && "hidden"
|
|
10611
11263
|
),
|
|
10612
11264
|
children: [
|
|
10613
11265
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-3 py-5", children: [
|
|
10614
11266
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Header, { tabType, allowSearch }),
|
|
10615
|
-
isValuesSearchSelected &&
|
|
10616
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, HeaderError, {})
|
|
11267
|
+
!isValuesSearchSelected && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, HeaderError, {})
|
|
10617
11268
|
] }),
|
|
10618
|
-
showEmptyState ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SearchEmptyState, {}) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
11269
|
+
showEmptyState ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SearchEmptyState, {}) : isValuesSearchSelected ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
11270
|
+
_reactresizablepanels.PanelGroup,
|
|
11271
|
+
{
|
|
11272
|
+
autoSaveId: "search-layout",
|
|
11273
|
+
direction: "vertical",
|
|
11274
|
+
className: "h-full w-full text-sm antialiased",
|
|
11275
|
+
children: [
|
|
11276
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactresizablepanels.Panel, { defaultSize: 30, minSize: 15, maxSize: 60, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SearchContent, {}) }),
|
|
11277
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ResizeHandle, { direction: "vertical" }),
|
|
11278
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactresizablepanels.Panel, { minSize: 30, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactresizablepanels.PanelGroup, { autoSaveId: "persistence", direction: "horizontal", className: "h-full w-full", children: [
|
|
11279
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactresizablepanels.Panel, { defaultSize: 30, minSize: 30, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Sidebar, {}) }),
|
|
11280
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ResizeHandle, {}),
|
|
11281
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactresizablepanels.Panel, { minSize: 40, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DataDisplay, {}) })
|
|
11282
|
+
] }) })
|
|
11283
|
+
]
|
|
11284
|
+
}
|
|
11285
|
+
) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
10619
11286
|
_reactresizablepanels.PanelGroup,
|
|
10620
11287
|
{
|
|
10621
11288
|
autoSaveId: "persistence",
|
|
@@ -10623,11 +11290,7 @@ var DatabrowserInstance = ({
|
|
|
10623
11290
|
className: "h-full w-full text-sm antialiased",
|
|
10624
11291
|
children: [
|
|
10625
11292
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactresizablepanels.Panel, { defaultSize: 30, minSize: 30, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Sidebar, {}) }),
|
|
10626
|
-
/* @__PURE__ */ _jsxruntime.
|
|
10627
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-[3px] w-[3px] rounded-full bg-zinc-300" }),
|
|
10628
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-[3px] w-[3px] rounded-full bg-zinc-300" }),
|
|
10629
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-[3px] w-[3px] rounded-full bg-zinc-300" })
|
|
10630
|
-
] }),
|
|
11293
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ResizeHandle, {}),
|
|
10631
11294
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactresizablepanels.Panel, { minSize: 40, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DataDisplay, {}) })
|
|
10632
11295
|
]
|
|
10633
11296
|
}
|
|
@@ -10756,7 +11419,7 @@ var useOverflow = () => {
|
|
|
10756
11419
|
}
|
|
10757
11420
|
if (!node) return;
|
|
10758
11421
|
observerRef.current = new ResizeObserver((entries) => {
|
|
10759
|
-
const el = _optionalChain([entries, 'access',
|
|
11422
|
+
const el = _optionalChain([entries, 'access', _120 => _120.at, 'call', _121 => _121(0), 'optionalAccess', _122 => _122.target]);
|
|
10760
11423
|
if (!el) return;
|
|
10761
11424
|
setIsOverflow(el.scrollWidth > el.clientWidth);
|
|
10762
11425
|
});
|
|
@@ -10764,7 +11427,7 @@ var useOverflow = () => {
|
|
|
10764
11427
|
}, []);
|
|
10765
11428
|
_react.useEffect.call(void 0, () => {
|
|
10766
11429
|
return () => {
|
|
10767
|
-
_optionalChain([observerRef, 'access',
|
|
11430
|
+
_optionalChain([observerRef, 'access', _123 => _123.current, 'optionalAccess', _124 => _124.disconnect, 'call', _125 => _125()]);
|
|
10768
11431
|
};
|
|
10769
11432
|
}, []);
|
|
10770
11433
|
return { ref, isOverflow };
|
|
@@ -10882,8 +11545,8 @@ var SortableTab = ({ id }) => {
|
|
|
10882
11545
|
const [originalWidth, setOriginalWidth] = _react.useState.call(void 0, null);
|
|
10883
11546
|
const textRef = _react.useRef.call(void 0, null);
|
|
10884
11547
|
const { tabs } = useDatabrowserStore();
|
|
10885
|
-
const tabData = _optionalChain([tabs, 'access',
|
|
10886
|
-
const isPinned = _optionalChain([tabData, 'optionalAccess',
|
|
11548
|
+
const tabData = _optionalChain([tabs, 'access', _126 => _126.find, 'call', _127 => _127(([tabId]) => tabId === id), 'optionalAccess', _128 => _128[1]]);
|
|
11549
|
+
const isPinned = _optionalChain([tabData, 'optionalAccess', _129 => _129.pinned]);
|
|
10887
11550
|
const { attributes, listeners: listeners2, setNodeRef, transform, transition, isDragging } = _sortable.useSortable.call(void 0, {
|
|
10888
11551
|
id,
|
|
10889
11552
|
disabled: isPinned,
|
|
@@ -11028,7 +11691,7 @@ var DatabrowserTabs = ({ onFullScreenClick }) => {
|
|
|
11028
11691
|
reorderTabs(oldIndex, newIndex);
|
|
11029
11692
|
}
|
|
11030
11693
|
};
|
|
11031
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "relative shrink-0 overflow-hidden rounded-t-
|
|
11694
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "relative shrink-0 overflow-hidden rounded-t-[10px] bg-zinc-300", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-1", children: [
|
|
11032
11695
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "relative min-w-0 flex-1", children: [
|
|
11033
11696
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
11034
11697
|
"div",
|
|
@@ -11076,7 +11739,7 @@ var DatabrowserTabs = ({ onFullScreenClick }) => {
|
|
|
11076
11739
|
}
|
|
11077
11740
|
)
|
|
11078
11741
|
] }),
|
|
11079
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-1
|
|
11742
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-center gap-1 px-1", children: [
|
|
11080
11743
|
isOverflow && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AddTabButton, {}),
|
|
11081
11744
|
tabs.length > 1 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TabsListButton, { tabs, onSelectTab: selectTab }),
|
|
11082
11745
|
onFullScreenClick && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
@@ -11084,9 +11747,8 @@ var DatabrowserTabs = ({ onFullScreenClick }) => {
|
|
|
11084
11747
|
{
|
|
11085
11748
|
"aria-label": "Toggle fullscreen",
|
|
11086
11749
|
variant: "secondary",
|
|
11087
|
-
size: "icon-sm",
|
|
11088
11750
|
onClick: onFullScreenClick,
|
|
11089
|
-
className: "flex-shrink-0 bg-white text-zinc-500 dark:bg-zinc-100",
|
|
11751
|
+
className: "h-[34px] w-[34px] flex-shrink-0 rounded-lg bg-white text-zinc-500 dark:bg-zinc-100",
|
|
11090
11752
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _iconsreact.IconWindowMaximize, { size: 16 })
|
|
11091
11753
|
}
|
|
11092
11754
|
)
|
|
@@ -11100,7 +11762,7 @@ function AddTabButton() {
|
|
|
11100
11762
|
const tabsId = addTab();
|
|
11101
11763
|
selectTab(tabsId);
|
|
11102
11764
|
setTimeout(() => {
|
|
11103
|
-
const tab = _optionalChain([rootRef, 'optionalAccess',
|
|
11765
|
+
const tab = _optionalChain([rootRef, 'optionalAccess', _130 => _130.current, 'optionalAccess', _131 => _131.querySelector, 'call', _132 => _132(`#tab-${tabsId}`)]);
|
|
11104
11766
|
if (!tab) return;
|
|
11105
11767
|
tab.scrollIntoView({ behavior: "smooth" });
|
|
11106
11768
|
}, 20);
|
|
@@ -11134,7 +11796,7 @@ function TabsListButton({
|
|
|
11134
11796
|
onSelectTab(id);
|
|
11135
11797
|
setOpen(false);
|
|
11136
11798
|
setTimeout(() => {
|
|
11137
|
-
const tab = _optionalChain([rootRef, 'optionalAccess',
|
|
11799
|
+
const tab = _optionalChain([rootRef, 'optionalAccess', _133 => _133.current, 'optionalAccess', _134 => _134.querySelector, 'call', _135 => _135(`#tab-${id}`)]);
|
|
11138
11800
|
if (!tab) return;
|
|
11139
11801
|
tab.scrollIntoView({ behavior: "smooth" });
|
|
11140
11802
|
}, 20);
|
|
@@ -11144,8 +11806,7 @@ function TabsListButton({
|
|
|
11144
11806
|
Button,
|
|
11145
11807
|
{
|
|
11146
11808
|
variant: "secondary",
|
|
11147
|
-
|
|
11148
|
-
className: "gap-1 bg-white px-2",
|
|
11809
|
+
className: "h-[34px] gap-1 rounded-lg bg-white px-2",
|
|
11149
11810
|
"aria-label": "Search in tabs",
|
|
11150
11811
|
children: [
|
|
11151
11812
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "text-xs text-zinc-600", children: tabs.length }),
|
|
@@ -11184,14 +11845,15 @@ var RedisBrowser = ({
|
|
|
11184
11845
|
disableTelemetry,
|
|
11185
11846
|
onFullScreenClick,
|
|
11186
11847
|
theme = "light",
|
|
11187
|
-
allowSearch = false
|
|
11848
|
+
allowSearch = false,
|
|
11849
|
+
useQueryWizard
|
|
11188
11850
|
}) => {
|
|
11189
11851
|
const credentials = _react.useMemo.call(void 0, () => ({ token, url }), [token, url]);
|
|
11190
11852
|
const rootRef = _react.useRef.call(void 0, null);
|
|
11191
11853
|
_react.useEffect.call(void 0, () => {
|
|
11192
11854
|
queryClient.resetQueries();
|
|
11193
11855
|
}, [credentials.url]);
|
|
11194
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RedisProvider, { redisCredentials: credentials, telemetry: !disableTelemetry, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DarkModeProvider, { theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DatabrowserProvider, { storage, rootRef, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttooltip.TooltipProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
11856
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactquery.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RedisProvider, { redisCredentials: credentials, telemetry: !disableTelemetry, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DarkModeProvider, { theme, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DatabrowserProvider, { storage, rootRef, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, QueryWizardProvider, { value: useQueryWizard, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttooltip.TooltipProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
11195
11857
|
RedisBrowserRoot,
|
|
11196
11858
|
{
|
|
11197
11859
|
allowSearch,
|
|
@@ -11200,7 +11862,7 @@ var RedisBrowser = ({
|
|
|
11200
11862
|
rootRef,
|
|
11201
11863
|
onFullScreenClick
|
|
11202
11864
|
}
|
|
11203
|
-
) }) }) }) }) });
|
|
11865
|
+
) }) }) }) }) }) });
|
|
11204
11866
|
};
|
|
11205
11867
|
var RedisBrowserRoot = ({
|
|
11206
11868
|
hideTabs,
|
|
@@ -11222,7 +11884,7 @@ var RedisBrowserRoot = ({
|
|
|
11222
11884
|
className: `ups-db ${theme === "dark" ? "dark" : ""}`,
|
|
11223
11885
|
style: { height: "100%" },
|
|
11224
11886
|
ref: rootRef,
|
|
11225
|
-
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex h-full flex-col
|
|
11887
|
+
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex h-full flex-col rounded-[14px] border-[4px] border-zinc-300 text-zinc-700", children: [
|
|
11226
11888
|
!hideTabs && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DatabrowserTabs, { onFullScreenClick }),
|
|
11227
11889
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DatabrowserInstances, { tabType, allowSearch })
|
|
11228
11890
|
] })
|