@malloy-publisher/sdk 0.0.140 → 0.0.142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1350 -17
- package/dist/index.cjs.js +27 -27
- package/dist/index.es.js +914 -920
- package/package.json +1 -1
- package/src/components/Notebook/Notebook.tsx +2 -2
- package/src/components/RenderedResult/ResultContainer.tsx +1 -1
- package/src/components/filter/DimensionFilter.tsx +33 -28
package/package.json
CHANGED
|
@@ -179,7 +179,7 @@ export default function Notebook({
|
|
|
179
179
|
/^\s*(run|query)\s*:/m.test(cellText);
|
|
180
180
|
|
|
181
181
|
try {
|
|
182
|
-
if (hasQuery && modelPath) {
|
|
182
|
+
if (hasQuery && modelPath && filtersToApply.length > 0) {
|
|
183
183
|
// Query cell - use models API with optional filters
|
|
184
184
|
let queryToExecute = cellText;
|
|
185
185
|
|
|
@@ -241,7 +241,7 @@ export default function Notebook({
|
|
|
241
241
|
result: response.data.result,
|
|
242
242
|
});
|
|
243
243
|
} else {
|
|
244
|
-
// Non-query code cell - use notebook cell execution API
|
|
244
|
+
// Non-query code cell (or no filters applied) - use notebook cell execution API
|
|
245
245
|
const response =
|
|
246
246
|
await apiClients.notebooks.executeNotebookCell(
|
|
247
247
|
projectName,
|
|
@@ -160,7 +160,7 @@ export default function ResultContainer({
|
|
|
160
160
|
ref={contentRef}
|
|
161
161
|
sx={{
|
|
162
162
|
flex: 1,
|
|
163
|
-
overflow: "
|
|
163
|
+
overflow: "hidden",
|
|
164
164
|
p: 0,
|
|
165
165
|
// Adjust bottom padding when toggle is shown to prevent content overlap
|
|
166
166
|
pb: shouldShowToggle ? "40px" : 1,
|
|
@@ -138,13 +138,13 @@ export function DimensionFilter({
|
|
|
138
138
|
const [retrievalInputValue, setRetrievalInputValue] = useState("");
|
|
139
139
|
const [retrievalSearched, setRetrievalSearched] = useState(false);
|
|
140
140
|
const [retrievalFocused, setRetrievalFocused] = useState(false);
|
|
141
|
-
const
|
|
142
|
-
const
|
|
141
|
+
const retrievalTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
142
|
+
const latestRequestIdRef = useRef(0);
|
|
143
143
|
|
|
144
144
|
// MinMax focus state for showing helper text
|
|
145
145
|
const [showMinMaxHelper, setShowMinMaxHelper] = useState(false);
|
|
146
146
|
|
|
147
|
-
// Effect to trigger retrieval
|
|
147
|
+
// Effect to trigger retrieval with debounce
|
|
148
148
|
useEffect(() => {
|
|
149
149
|
if (spec.filterType !== "Retrieval" || !retrievalFn) return;
|
|
150
150
|
|
|
@@ -155,41 +155,46 @@ export function DimensionFilter({
|
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
158
|
+
// Cancel any existing timer
|
|
159
|
+
if (retrievalTimerRef.current) {
|
|
160
|
+
clearTimeout(retrievalTimerRef.current);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Set a new 300ms timer
|
|
164
|
+
retrievalTimerRef.current = setTimeout(async () => {
|
|
165
|
+
// Increment and capture request ID to track this request
|
|
166
|
+
latestRequestIdRef.current += 1;
|
|
167
|
+
const thisRequestId = latestRequestIdRef.current;
|
|
163
168
|
|
|
164
|
-
isRequestInFlightRef.current = true;
|
|
165
169
|
setRetrievalLoading(true);
|
|
166
170
|
|
|
167
171
|
try {
|
|
168
|
-
const results = await retrievalFn(
|
|
169
|
-
|
|
172
|
+
const results = await retrievalFn(query, spec);
|
|
173
|
+
// Only update state if this is still the latest request
|
|
174
|
+
if (thisRequestId === latestRequestIdRef.current) {
|
|
175
|
+
setRetrievalOptions(results);
|
|
176
|
+
}
|
|
170
177
|
} catch (e) {
|
|
171
|
-
|
|
172
|
-
|
|
178
|
+
// Only update state if this is still the latest request
|
|
179
|
+
if (thisRequestId === latestRequestIdRef.current) {
|
|
180
|
+
console.error("Retrieval failed", e);
|
|
181
|
+
setRetrievalOptions([]);
|
|
182
|
+
}
|
|
173
183
|
} finally {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
// Check pending
|
|
179
|
-
if (pendingRequestRef.current) {
|
|
180
|
-
const nextQuery = pendingRequestRef.current;
|
|
181
|
-
pendingRequestRef.current = null;
|
|
182
|
-
setTimeout(() => performRetrieval(nextQuery), 0);
|
|
184
|
+
// Only update loading/searched state if this is still the latest request
|
|
185
|
+
if (thisRequestId === latestRequestIdRef.current) {
|
|
186
|
+
setRetrievalLoading(false);
|
|
187
|
+
setRetrievalSearched(true);
|
|
183
188
|
}
|
|
184
189
|
}
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
// Debounce
|
|
188
|
-
const timeoutId = setTimeout(() => {
|
|
189
|
-
performRetrieval(query);
|
|
190
190
|
}, 300);
|
|
191
191
|
|
|
192
|
-
|
|
192
|
+
// Cleanup: cancel timer on unmount or when dependencies change
|
|
193
|
+
return () => {
|
|
194
|
+
if (retrievalTimerRef.current) {
|
|
195
|
+
clearTimeout(retrievalTimerRef.current);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
193
198
|
}, [retrievalInputValue, spec, retrievalFn]);
|
|
194
199
|
|
|
195
200
|
// Sync internal state with selection prop changes (e.g., when filter is cleared externally)
|