@mastra/react 1.12.0 → 1.13.0-alpha.0
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/{accumulator-CgLQ_3q3.cjs → accumulator-BmD8-x9I.cjs} +52 -3
- package/dist/accumulator-BmD8-x9I.cjs.map +1 -0
- package/dist/{accumulator-BfvVnXJr.js → accumulator-D9jAph99.js} +52 -3
- package/dist/accumulator-D9jAph99.js.map +1 -0
- package/dist/chat/index.cjs +1 -1
- package/dist/chat/index.js +1 -1
- package/dist/hooks/capabilities/index.cjs +42 -0
- package/dist/hooks/capabilities/index.cjs.map +1 -1
- package/dist/hooks/capabilities/index.d.ts +3 -0
- package/dist/hooks/capabilities/index.d.ts.map +1 -1
- package/dist/hooks/capabilities/index.js +40 -1
- package/dist/hooks/capabilities/index.js.map +1 -1
- package/dist/hooks/capabilities/use-span-aggregate-available.d.ts +9 -0
- package/dist/hooks/capabilities/use-span-aggregate-available.d.ts.map +1 -0
- package/dist/hooks/capabilities/use-span-query-available.d.ts +9 -0
- package/dist/hooks/capabilities/use-span-query-available.d.ts.map +1 -0
- package/dist/hooks/capabilities/use-thread-query-available.d.ts +9 -0
- package/dist/hooks/capabilities/use-thread-query-available.d.ts.map +1 -0
- package/dist/hooks/templates/index.cjs.map +1 -1
- package/dist/hooks/templates/index.js.map +1 -1
- package/dist/hooks/templates/use-templates.d.ts.map +1 -1
- package/dist/hooks/traces/index.cjs +109 -1
- package/dist/hooks/traces/index.cjs.map +1 -1
- package/dist/hooks/traces/index.d.ts +2 -0
- package/dist/hooks/traces/index.d.ts.map +1 -1
- package/dist/hooks/traces/index.js +106 -2
- package/dist/hooks/traces/index.js.map +1 -1
- package/dist/hooks/traces/use-query-spans.d.ts +27 -0
- package/dist/hooks/traces/use-query-spans.d.ts.map +1 -0
- package/dist/hooks/traces/use-query-threads.d.ts +30 -0
- package/dist/hooks/traces/use-query-threads.d.ts.map +1 -0
- package/dist/hooks/traces/use-traces.d.ts +37 -37
- package/dist/hooks/workflows/index.cjs +1 -1
- package/dist/hooks/workflows/index.js +1 -1
- package/dist/{hooks-B1i-oHae.cjs → hooks-C6CJtoOR.cjs} +2 -2
- package/dist/{hooks-B1i-oHae.cjs.map → hooks-C6CJtoOR.cjs.map} +1 -1
- package/dist/{hooks-NaZLZreZ.js → hooks-DG-Y1KFe.js} +2 -2
- package/dist/{hooks-NaZLZreZ.js.map → hooks-DG-Y1KFe.js.map} +1 -1
- package/dist/{hooks-CLfMO5cH.js → hooks-DvLSZtUd.js} +2 -2
- package/dist/{hooks-CLfMO5cH.js.map → hooks-DvLSZtUd.js.map} +1 -1
- package/dist/{hooks-D8nOYPUd.cjs → hooks-XYsmqFCz.cjs} +2 -2
- package/dist/{hooks-D8nOYPUd.cjs.map → hooks-XYsmqFCz.cjs.map} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/dist/lib/mastra-db/accumulator.d.ts +0 -6
- package/dist/lib/mastra-db/accumulator.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/accumulator-BfvVnXJr.js.map +0 -1
- package/dist/accumulator-CgLQ_3q3.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as useMastraClient } from "../../mastra-client-context-Bx_g84YB.js";
|
|
2
2
|
import { t as useInView } from "../../use-in-view-C9sYPGRm.js";
|
|
3
|
+
import { t as getOrCreate } from "../../map-CDv4fbu4.js";
|
|
3
4
|
import { n as is403ForbiddenError } from "../../query-utils-D1NgFnWU.js";
|
|
4
5
|
import { t as getFeedbackRefetchInterval } from "../../feedback-refetch-interval-DLHzQoVV.js";
|
|
5
|
-
import { t as getOrCreate } from "../../map-CDv4fbu4.js";
|
|
6
6
|
import { MastraClient, MastraClientError } from "@mastra/client-js";
|
|
7
7
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
8
8
|
import { keepPreviousData, queryOptions, skipToken, useInfiniteQuery, useMutation, useQueries, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
@@ -627,6 +627,110 @@ function useTraceQueryLatest({ query, limit = 25, enabled = true, refetchInterva
|
|
|
627
627
|
});
|
|
628
628
|
}
|
|
629
629
|
//#endregion
|
|
630
|
+
//#region src/hooks/traces/use-query-spans.ts
|
|
631
|
+
const SPAN_QUERY_PER_PAGE = 25;
|
|
632
|
+
const selectSpans = (data) => data.pages.flatMap((page) => page.spans);
|
|
633
|
+
/** Queries completed spans with cursor pagination and viewport-driven loading. */
|
|
634
|
+
function useQuerySpans({ query, limit = 25, enabled = true, queryOptions }) {
|
|
635
|
+
const client = useMastraClient();
|
|
636
|
+
const { inView, setRef: setEndOfListElement } = useInView();
|
|
637
|
+
const { data, hasNextPage, isFetchingNextPage, fetchNextPage, isLoading, isFetching, isError, error, refetch, isFetchNextPageError } = useInfiniteQuery({
|
|
638
|
+
queryKey: [
|
|
639
|
+
"span-query",
|
|
640
|
+
query,
|
|
641
|
+
limit
|
|
642
|
+
],
|
|
643
|
+
queryFn: query ? ({ pageParam }) => client.querySpans({
|
|
644
|
+
...query,
|
|
645
|
+
page: pageParam ? {
|
|
646
|
+
limit,
|
|
647
|
+
after: pageParam
|
|
648
|
+
} : { limit }
|
|
649
|
+
}) : skipToken,
|
|
650
|
+
initialPageParam: void 0,
|
|
651
|
+
getNextPageParam: (lastPage) => lastPage.page.next ?? void 0,
|
|
652
|
+
select: selectSpans,
|
|
653
|
+
retry: false,
|
|
654
|
+
placeholderData: keepPreviousData,
|
|
655
|
+
enabled,
|
|
656
|
+
...queryOptions
|
|
657
|
+
});
|
|
658
|
+
useEffect(() => {
|
|
659
|
+
if (enabled && inView && hasNextPage && !isFetching && !isFetchNextPageError) fetchNextPage();
|
|
660
|
+
}, [
|
|
661
|
+
enabled,
|
|
662
|
+
inView,
|
|
663
|
+
hasNextPage,
|
|
664
|
+
isFetching,
|
|
665
|
+
isFetchNextPageError,
|
|
666
|
+
fetchNextPage
|
|
667
|
+
]);
|
|
668
|
+
return {
|
|
669
|
+
spans: data,
|
|
670
|
+
hasNextPage,
|
|
671
|
+
isFetchingNextPage,
|
|
672
|
+
fetchNextPage: () => void fetchNextPage(),
|
|
673
|
+
setEndOfListElement,
|
|
674
|
+
isLoading,
|
|
675
|
+
isFetching,
|
|
676
|
+
isError,
|
|
677
|
+
error,
|
|
678
|
+
refetch: () => void refetch()
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
//#endregion
|
|
682
|
+
//#region src/hooks/traces/use-query-threads.ts
|
|
683
|
+
const THREAD_QUERY_PER_PAGE = 25;
|
|
684
|
+
const selectThreads = (data) => data.pages.flatMap((page) => page.threads);
|
|
685
|
+
/** Queries thread rows with cursor pagination and viewport-driven loading. */
|
|
686
|
+
function useQueryThreads({ query, limit = 25, enabled = true, queryOptions }) {
|
|
687
|
+
const client = useMastraClient();
|
|
688
|
+
const { inView, setRef: setEndOfListElement } = useInView();
|
|
689
|
+
const { data, hasNextPage, isFetchingNextPage, fetchNextPage, isLoading, isFetching, isError, error, refetch, isFetchNextPageError } = useInfiniteQuery({
|
|
690
|
+
queryKey: [
|
|
691
|
+
"thread-query",
|
|
692
|
+
query,
|
|
693
|
+
limit
|
|
694
|
+
],
|
|
695
|
+
queryFn: query ? ({ pageParam }) => client.queryTraceThreads({
|
|
696
|
+
...query,
|
|
697
|
+
page: pageParam ? {
|
|
698
|
+
limit,
|
|
699
|
+
after: pageParam
|
|
700
|
+
} : { limit }
|
|
701
|
+
}) : skipToken,
|
|
702
|
+
initialPageParam: void 0,
|
|
703
|
+
getNextPageParam: (lastPage) => lastPage.page.next ?? void 0,
|
|
704
|
+
select: selectThreads,
|
|
705
|
+
retry: false,
|
|
706
|
+
placeholderData: keepPreviousData,
|
|
707
|
+
enabled,
|
|
708
|
+
...queryOptions
|
|
709
|
+
});
|
|
710
|
+
useEffect(() => {
|
|
711
|
+
if (enabled && inView && hasNextPage && !isFetching && !isFetchNextPageError) fetchNextPage();
|
|
712
|
+
}, [
|
|
713
|
+
enabled,
|
|
714
|
+
inView,
|
|
715
|
+
hasNextPage,
|
|
716
|
+
isFetching,
|
|
717
|
+
isFetchNextPageError,
|
|
718
|
+
fetchNextPage
|
|
719
|
+
]);
|
|
720
|
+
return {
|
|
721
|
+
threads: data,
|
|
722
|
+
hasNextPage,
|
|
723
|
+
isFetchingNextPage,
|
|
724
|
+
fetchNextPage: () => void fetchNextPage(),
|
|
725
|
+
setEndOfListElement,
|
|
726
|
+
isLoading,
|
|
727
|
+
isFetching,
|
|
728
|
+
isError,
|
|
729
|
+
error,
|
|
730
|
+
refetch: () => void refetch()
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
//#endregion
|
|
630
734
|
//#region src/hooks/traces/use-trace-usage.ts
|
|
631
735
|
const INPUT_TOKEN_METRIC = "mastra_model_total_input_tokens";
|
|
632
736
|
const OUTPUT_TOKEN_METRIC = "mastra_model_total_output_tokens";
|
|
@@ -1300,6 +1404,6 @@ function useTraceColumnPreferencesStorageKey() {
|
|
|
1300
1404
|
return `mastra:traces:columns:${client.options.baseUrl || (typeof window === "undefined" ? "local" : window.location.origin || "local")}:${client.options.apiPrefix ?? "/api"}`;
|
|
1301
1405
|
}
|
|
1302
1406
|
//#endregion
|
|
1303
|
-
export { DISCOVERY_STALE_TIME, ROOT_ENTITY_TYPES, TRACES_PER_PAGE, TRACE_QUERY_DELTA_LIMIT, TRACE_QUERY_PER_PAGE, createTraceQueryValuesResolver, getLegacyTraceQueryNextPageParam, getTraceQueryNextPageParam, getTracesNextPageParam, lightSpanToTraceQueryTrace, mergeDeltaIntoPage0, mergeTraceQueryDelta, refreshPage0Rows, selectLegacyTraceQueryTraces, selectTraceQueryTraces, selectUniqueTraces, shouldPinLightList, shouldResetAfterIdle, traceQueryFieldsQueryKey, traceQueryKey, traceSpansQueryOptions, useBranch, useCreateFeedback, useDeleteFeedback, useEntityNames, useEnvironments, useFetchTraceSpans, useServiceNames, useSpanDetail, useSpanFeedback, useTags, useThreadHasOtherTraces, useTraceColumnPreferencesStorageKey, useTraceFeedback, useTraceLightSpans, useTraceMetadataFilterFields, useTraceOrBranchSpans, useTraceQuery, useTraceQueryLatest, useTraceSpans, useTraceSpansQueries, useTraceUsage, useTraces };
|
|
1407
|
+
export { DISCOVERY_STALE_TIME, ROOT_ENTITY_TYPES, SPAN_QUERY_PER_PAGE, THREAD_QUERY_PER_PAGE, TRACES_PER_PAGE, TRACE_QUERY_DELTA_LIMIT, TRACE_QUERY_PER_PAGE, createTraceQueryValuesResolver, getLegacyTraceQueryNextPageParam, getTraceQueryNextPageParam, getTracesNextPageParam, lightSpanToTraceQueryTrace, mergeDeltaIntoPage0, mergeTraceQueryDelta, refreshPage0Rows, selectLegacyTraceQueryTraces, selectTraceQueryTraces, selectUniqueTraces, shouldPinLightList, shouldResetAfterIdle, traceQueryFieldsQueryKey, traceQueryKey, traceSpansQueryOptions, useBranch, useCreateFeedback, useDeleteFeedback, useEntityNames, useEnvironments, useFetchTraceSpans, useQuerySpans, useQueryThreads, useServiceNames, useSpanDetail, useSpanFeedback, useTags, useThreadHasOtherTraces, useTraceColumnPreferencesStorageKey, useTraceFeedback, useTraceLightSpans, useTraceMetadataFilterFields, useTraceOrBranchSpans, useTraceQuery, useTraceQueryLatest, useTraceSpans, useTraceSpansQueries, useTraceUsage, useTraces };
|
|
1304
1408
|
|
|
1305
1409
|
//# sourceMappingURL=index.js.map
|