@mastra/react 1.13.0-alpha.3 → 1.13.0-alpha.5
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-BmD8-x9I.cjs → accumulator-Bjfckb5t.cjs} +5 -9
- package/dist/{accumulator-BmD8-x9I.cjs.map → accumulator-Bjfckb5t.cjs.map} +1 -1
- package/dist/{accumulator-D9jAph99.js → accumulator-DysrPe6U.js} +5 -9
- package/dist/{accumulator-D9jAph99.js.map → accumulator-DysrPe6U.js.map} +1 -1
- package/dist/chat/index.cjs +1 -1
- package/dist/chat/index.js +1 -1
- package/dist/{combine-by-ids-CcaZKGT9.js → combine-by-ids-C-0oe4eH.js} +2 -3
- package/dist/{combine-by-ids-CcaZKGT9.js.map → combine-by-ids-C-0oe4eH.js.map} +1 -1
- package/dist/{combine-by-ids-D_lp6Dvq.cjs → combine-by-ids-ERVPXXBi.cjs} +2 -3
- package/dist/{combine-by-ids-D_lp6Dvq.cjs.map → combine-by-ids-ERVPXXBi.cjs.map} +1 -1
- package/dist/{experiments-CJw1N3FB.cjs → experiments-Duv0RgkM.cjs} +12 -19
- package/dist/{experiments-CJw1N3FB.cjs.map → experiments-Duv0RgkM.cjs.map} +1 -1
- package/dist/{experiments-B7vRMK5T.js → experiments-DyecjEut.js} +12 -19
- package/dist/{experiments-B7vRMK5T.js.map → experiments-DyecjEut.js.map} +1 -1
- package/dist/{feedback-refetch-interval-XD5FVc2k.cjs → feedback-refetch-interval-BBcT9r8s.cjs} +3 -4
- package/dist/{feedback-refetch-interval-XD5FVc2k.cjs.map → feedback-refetch-interval-BBcT9r8s.cjs.map} +1 -1
- package/dist/{feedback-refetch-interval-DLHzQoVV.js → feedback-refetch-interval-C12Nzb2r.js} +3 -4
- package/dist/{feedback-refetch-interval-DLHzQoVV.js.map → feedback-refetch-interval-C12Nzb2r.js.map} +1 -1
- package/dist/hooks/agents/index.cjs +19 -37
- package/dist/hooks/agents/index.cjs.map +1 -1
- package/dist/hooks/agents/index.js +19 -37
- package/dist/hooks/agents/index.js.map +1 -1
- package/dist/hooks/auth/index.cjs +11 -21
- package/dist/hooks/auth/index.cjs.map +1 -1
- package/dist/hooks/auth/index.js +11 -21
- package/dist/hooks/auth/index.js.map +1 -1
- package/dist/hooks/capabilities/index.cjs +11 -21
- package/dist/hooks/capabilities/index.cjs.map +1 -1
- package/dist/hooks/capabilities/index.js +11 -21
- package/dist/hooks/capabilities/index.js.map +1 -1
- package/dist/hooks/configuration/index.cjs +2 -3
- package/dist/hooks/configuration/index.js +2 -3
- package/dist/hooks/datasets/index.cjs +12 -21
- package/dist/hooks/datasets/index.cjs.map +1 -1
- package/dist/hooks/datasets/index.js +12 -21
- package/dist/hooks/datasets/index.js.map +1 -1
- package/dist/hooks/embedders/index.cjs +2 -3
- package/dist/hooks/embedders/index.js +2 -3
- package/dist/hooks/experiments/index.cjs +1 -1
- package/dist/hooks/experiments/index.js +1 -1
- package/dist/hooks/feedback/index.cjs +3 -4
- package/dist/hooks/feedback/index.js +3 -4
- package/dist/hooks/llm/index.cjs +2 -3
- package/dist/hooks/llm/index.js +2 -3
- package/dist/hooks/logs/index.cjs +4 -5
- package/dist/hooks/logs/index.js +4 -5
- package/dist/hooks/mcps/index.cjs +8 -15
- package/dist/hooks/mcps/index.cjs.map +1 -1
- package/dist/hooks/mcps/index.js +8 -15
- package/dist/hooks/mcps/index.js.map +1 -1
- package/dist/hooks/memory/index.cjs +5 -9
- package/dist/hooks/memory/index.cjs.map +1 -1
- package/dist/hooks/memory/index.js +5 -9
- package/dist/hooks/memory/index.js.map +1 -1
- package/dist/hooks/metrics/index.cjs +19 -36
- package/dist/hooks/metrics/index.cjs.map +1 -1
- package/dist/hooks/metrics/index.js +19 -36
- package/dist/hooks/metrics/index.js.map +1 -1
- package/dist/hooks/processors/index.cjs +2 -3
- package/dist/hooks/processors/index.js +2 -3
- package/dist/hooks/prompt-blocks/index.cjs +3 -5
- package/dist/hooks/prompt-blocks/index.cjs.map +1 -1
- package/dist/hooks/prompt-blocks/index.js +3 -5
- package/dist/hooks/prompt-blocks/index.js.map +1 -1
- package/dist/hooks/query/index.cjs +2 -3
- package/dist/hooks/query/index.js +2 -3
- package/dist/hooks/review/index.cjs +4 -6
- package/dist/hooks/review/index.cjs.map +1 -1
- package/dist/hooks/review/index.js +4 -6
- package/dist/hooks/review/index.js.map +1 -1
- package/dist/hooks/schedules/index.cjs +6 -10
- package/dist/hooks/schedules/index.cjs.map +1 -1
- package/dist/hooks/schedules/index.js +6 -10
- package/dist/hooks/schedules/index.js.map +1 -1
- package/dist/hooks/scores/index.cjs +8 -13
- package/dist/hooks/scores/index.cjs.map +1 -1
- package/dist/hooks/scores/index.js +8 -13
- package/dist/hooks/scores/index.js.map +1 -1
- package/dist/hooks/templates/index.cjs +2 -3
- package/dist/hooks/templates/index.js +2 -3
- package/dist/hooks/tool-providers/index.cjs +10 -19
- package/dist/hooks/tool-providers/index.cjs.map +1 -1
- package/dist/hooks/tool-providers/index.js +10 -19
- package/dist/hooks/tool-providers/index.js.map +1 -1
- package/dist/hooks/tools/index.cjs +3 -5
- package/dist/hooks/tools/index.cjs.map +1 -1
- package/dist/hooks/tools/index.js +3 -5
- package/dist/hooks/tools/index.js.map +1 -1
- package/dist/hooks/traces/index.cjs +71 -54
- 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 +70 -55
- package/dist/hooks/traces/index.js.map +1 -1
- package/dist/hooks/traces/use-span-aggregate.d.ts +16 -0
- package/dist/hooks/traces/use-span-aggregate.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-aggregate.d.ts +17 -0
- package/dist/hooks/traces/use-trace-aggregate.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-column-preferences-storage-key.d.ts +4 -2
- package/dist/hooks/traces/use-trace-column-preferences-storage-key.d.ts.map +1 -1
- package/dist/hooks/vectors/index.cjs +2 -3
- package/dist/hooks/vectors/index.js +2 -3
- package/dist/hooks/voice/index.cjs +3 -4
- package/dist/hooks/voice/index.js +3 -4
- package/dist/hooks/workflows/index.cjs +7 -11
- package/dist/hooks/workflows/index.cjs.map +1 -1
- package/dist/hooks/workflows/index.js +7 -11
- package/dist/hooks/workflows/index.js.map +1 -1
- package/dist/hooks/workspace/index.cjs +12 -22
- package/dist/hooks/workspace/index.cjs.map +1 -1
- package/dist/hooks/workspace/index.js +12 -22
- package/dist/hooks/workspace/index.js.map +1 -1
- package/dist/{hooks-XYsmqFCz.cjs → hooks-Bt15IwzP.cjs} +6 -9
- package/dist/{hooks-XYsmqFCz.cjs.map → hooks-Bt15IwzP.cjs.map} +1 -1
- package/dist/{hooks-DG-Y1KFe.js → hooks-Btt7PyI-.js} +6 -9
- package/dist/{hooks-DG-Y1KFe.js.map → hooks-Btt7PyI-.js.map} +1 -1
- package/dist/{hooks-BfysjY_K.js → hooks-CEikbhrN.js} +9 -15
- package/dist/{hooks-BfysjY_K.js.map → hooks-CEikbhrN.js.map} +1 -1
- package/dist/{hooks-BbUMSab8.cjs → hooks-D6LDSEcm.cjs} +9 -15
- package/dist/{hooks-BbUMSab8.cjs.map → hooks-D6LDSEcm.cjs.map} +1 -1
- package/dist/index.cjs +7 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -9
- package/dist/index.js.map +1 -1
- package/dist/{map-CDv4fbu4.js → map-5-4U5rwA.js} +2 -3
- package/dist/{map-CDv4fbu4.js.map → map-5-4U5rwA.js.map} +1 -1
- package/dist/{map-wjmL1y5O.cjs → map-BGoWBTGy.cjs} +2 -3
- package/dist/{map-wjmL1y5O.cjs.map → map-BGoWBTGy.cjs.map} +1 -1
- package/dist/{mastra-client-context-Bx_g84YB.js → mastra-client-context-DQ5z_ze9.js} +2 -3
- package/dist/{mastra-client-context-Bx_g84YB.js.map → mastra-client-context-DQ5z_ze9.js.map} +1 -1
- package/dist/{mastra-client-context-DzX3f0RF.cjs → mastra-client-context-DX8wJM9p.cjs} +2 -3
- package/dist/{mastra-client-context-DzX3f0RF.cjs.map → mastra-client-context-DX8wJM9p.cjs.map} +1 -1
- package/dist/{query-utils-CcrChYgz.cjs → query-utils-BVgE_xxj.cjs} +2 -3
- package/dist/{query-utils-CcrChYgz.cjs.map → query-utils-BVgE_xxj.cjs.map} +1 -1
- package/dist/{query-utils-D1NgFnWU.js → query-utils-DvMERIwf.js} +2 -3
- package/dist/{query-utils-D1NgFnWU.js.map → query-utils-DvMERIwf.js.map} +1 -1
- package/dist/ui/index.cjs +15 -30
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.js +14 -28
- package/dist/ui/index.js.map +1 -1
- package/dist/{use-in-view-B6eJO9Zi.cjs → use-in-view-BxdrrnCw.cjs} +2 -3
- package/dist/{use-in-view-B6eJO9Zi.cjs.map → use-in-view-BxdrrnCw.cjs.map} +1 -1
- package/dist/{use-in-view-C9sYPGRm.js → use-in-view-CyjKdplM.js} +2 -3
- package/dist/{use-in-view-C9sYPGRm.js.map → use-in-view-CyjKdplM.js.map} +1 -1
- package/dist/{voice-BOtUdMi8.cjs → voice-Didej2E1.cjs} +5 -8
- package/dist/{voice-BOtUdMi8.cjs.map → voice-Didej2E1.cjs.map} +1 -1
- package/dist/{voice-DgirjEyH.js → voice-ugGu7VyA.js} +5 -8
- package/dist/{voice-DgirjEyH.js.map → voice-ugGu7VyA.js.map} +1 -1
- package/package.json +19 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["isUnsupportedObservabilityOperationError","isObservabilityUnavailableError","useMastraClient","useInView","useInfiniteQuery","useState","useQuery","isUnsupportedObservabilityOperationError","isObservabilityUnavailableError","useMastraClient","useQuery","useMastraClient","useMutation","useMastraClient","useQuery","useQueryClient","useMutation","useMastraClient","useQuery","useQueryClient","useMutation"],"sources":["../../../src/hooks/scores/use-scorers.ts","../../../src/hooks/scores/use-trace-span-scores.ts","../../../src/hooks/scores/use-trigger-scorer.ts","../../../src/hooks/scores/use-stored-scorers.ts","../../../src/hooks/scores/use-scorer-versions.ts"],"sourcesContent":["import type { MastraClient, GetScorerResponse, ListScoresResponse } from '@mastra/client-js';\nimport type { UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';\nimport { useInfiniteQuery, useQuery } from '@tanstack/react-query';\nimport { useEffect, useState } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { isObservabilityUnavailableError, isUnsupportedObservabilityOperationError } from '../query/query-utils';\nimport type { MastraInfiniteQueryOptions, MastraQueryOptions } from '../shared/query-options';\nimport { useInView } from '../shared/use-in-view';\n\nconst SCORES_PER_PAGE = 25;\nconst SCORES_REFETCH_INTERVAL_MS = 15_000;\n\nexport function getScoresRefetchInterval(query: { state: { error: unknown } }) {\n if (\n isUnsupportedObservabilityOperationError(query.state.error, 'scores') ||\n isObservabilityUnavailableError(query.state.error)\n ) {\n return false;\n }\n return SCORES_REFETCH_INTERVAL_MS;\n}\n\ntype UseScoresByScorerIdProps<TData> = {\n scorerId: string;\n entityId?: string;\n entityType?: string;\n /** TanStack overrides spread last; `select` defaults to the flattened, de-duplicated score list. */\n queryOptions?: MastraInfiniteQueryOptions<ListScoresResponse, TData, readonly unknown[], number>;\n};\n\nfunction getScoresNextPageParam(lastPage: ListScoresResponse | undefined, _allPages: unknown, lastPageParam: number) {\n if (lastPage?.pagination?.hasMore) {\n return lastPageParam + 1;\n }\n return undefined;\n}\n\nfunction selectFlatScores(data: { pages: ListScoresResponse[] }) {\n const seen = new Set<string>();\n const scores = data.pages\n .flatMap(page => page.scores ?? [])\n .filter(score => {\n if (seen.has(score.id)) return false;\n seen.add(score.id);\n return true;\n });\n return scores;\n}\n\nexport const useScoresByScorerId = <TData = ReturnType<typeof selectFlatScores>>({\n scorerId,\n entityId,\n entityType,\n queryOptions,\n}: UseScoresByScorerIdProps<TData>): UseInfiniteQueryResult<TData, Error> & {\n setEndOfListElement: ReturnType<typeof useInView>['setRef'];\n} => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n\n const query = useInfiniteQuery<ListScoresResponse, Error, TData, readonly unknown[], number>({\n queryKey: ['scores', scorerId, entityId, entityType],\n queryFn: ({ pageParam }) =>\n client.listScoresByScorerId({ scorerId, page: pageParam, perPage: SCORES_PER_PAGE, entityId, entityType }),\n initialPageParam: 0,\n getNextPageParam: getScoresNextPageParam,\n select: data => selectFlatScores(data) as TData,\n refetchInterval: getScoresRefetchInterval,\n ...queryOptions,\n });\n\n const { hasNextPage, isFetchingNextPage, fetchNextPage } = query;\n\n useEffect(() => {\n if (isEndOfListInView && hasNextPage && !isFetchingNextPage) {\n void fetchNextPage();\n }\n }, [isEndOfListInView, hasNextPage, isFetchingNextPage, fetchNextPage]);\n\n return { ...query, setEndOfListElement };\n};\n\nexport const useScorer = (scorerId: string) => {\n const client = useMastraClient();\n const [scorer, setScorer] = useState<GetScorerResponse | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n const fetchScorer = async () => {\n setIsLoading(true);\n setError(null);\n try {\n const res = await client.getScorer(scorerId);\n setScorer(res);\n } catch (error) {\n setScorer(null);\n const errorObj = error instanceof Error ? error : new Error('Error fetching scorer');\n setError(errorObj);\n console.error('Error fetching scorer', error);\n } finally {\n setIsLoading(false);\n }\n };\n\n void fetchScorer();\n }, [scorerId, client]);\n\n return { scorer, isLoading, error };\n};\n\ntype ListScorersResponse = Awaited<ReturnType<MastraClient['listScorers']>>;\n\nexport const useScorers = <TData = ListScorersResponse>({\n requestContext,\n queryOptions,\n}: {\n requestContext?: Record<string, unknown>;\n queryOptions?: MastraQueryOptions<ListScorersResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListScorersResponse, Error, TData>({\n queryKey: ['scorers', requestContext],\n queryFn: () => client.listScorers(requestContext),\n staleTime: 0,\n gcTime: 0,\n ...queryOptions,\n });\n};\n","import type { ListScoresResponse } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { isObservabilityUnavailableError, isUnsupportedObservabilityOperationError } from '../query/query-utils';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nconst TRACE_SPAN_SCORES_REFETCH_INTERVAL_MS = 15_000;\n\nexport function getTraceSpanScoresRefetchInterval(query: { state: { error: unknown } }) {\n if (\n isUnsupportedObservabilityOperationError(query.state.error, 'scores') ||\n isObservabilityUnavailableError(query.state.error)\n ) {\n return false;\n }\n return TRACE_SPAN_SCORES_REFETCH_INTERVAL_MS;\n}\n\ntype useTraceSpanScoresProps<TData> = {\n traceId?: string;\n spanId?: string;\n page?: number;\n queryOptions?: MastraQueryOptions<ListScoresResponse, TData>;\n};\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useTraceSpanScores = <TData = ListScoresResponse>({\n traceId = '',\n spanId = '',\n page,\n queryOptions,\n}: useTraceSpanScoresProps<TData>): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery<ListScoresResponse, Error, TData>({\n queryKey: ['trace-span-scores', traceId, spanId, page],\n queryFn: () => client.listScoresBySpan({ traceId, spanId, page: page || 0, perPage: 10 }),\n refetchInterval: getTraceSpanScoresRefetchInterval,\n gcTime: 0,\n staleTime: 0,\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { useMutation } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\ninterface TriggerScoreArgs {\n scorerName: string;\n traceId: string;\n spanId?: string;\n}\n\ntype TriggerScorerResponse = Awaited<ReturnType<MastraClient['score']>>;\n\nexport const useTriggerScorer = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<TriggerScorerResponse, TriggerScoreArgs> } = {}) => {\n const client = useMastraClient();\n\n return useMutation({\n mutationFn: async ({ scorerName, traceId, spanId }: TriggerScoreArgs) => {\n const response = await client.score({\n scorerName,\n targets: [{ traceId, spanId }],\n });\n\n return response;\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient, CreateStoredScorerParams, UpdateStoredScorerParams } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\n\ntype StoredScorerResponse = Awaited<ReturnType<ReturnType<MastraClient['getStoredScorer']>['details']>>;\ntype DeleteStoredScorerResponse = Awaited<ReturnType<ReturnType<MastraClient['getStoredScorer']>['delete']>>;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useStoredScorer = <TData = StoredScorerResponse | null>({\n scorerId,\n status,\n requestContext,\n queryOptions,\n}: {\n scorerId?: string;\n status?: 'draft' | 'published';\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<StoredScorerResponse | null, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<StoredScorerResponse | null, Error, TData>({\n queryKey: ['stored-scorer', scorerId, status, requestContext],\n queryFn: () => (scorerId ? client.getStoredScorer(scorerId).details(requestContext, { status }) : null),\n ...queryOptions,\n });\n};\n\nexport const useStoredScorerMutations = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: {\n createStoredScorer?: MastraMutationOptions<StoredScorerResponse, CreateStoredScorerParams>;\n updateStoredScorer?: MastraMutationOptions<StoredScorerResponse, UpdateStoredScorerParams>;\n deleteStoredScorer?: MastraMutationOptions<DeleteStoredScorerResponse, void>;\n };\n} = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n const createMutation = useMutation({\n mutationFn: (params: CreateStoredScorerParams) => client.createStoredScorer(params),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorers'] });\n void queryClient.invalidateQueries({ queryKey: ['scorers'] });\n },\n ...queryOptions?.createStoredScorer,\n });\n\n const updateMutation = useMutation({\n mutationFn: (params: UpdateStoredScorerParams) => {\n if (!scorerId) throw new Error('scorerId is required for update');\n return client.getStoredScorer(scorerId).update(params, requestContext);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorers'] });\n void queryClient.invalidateQueries({ queryKey: ['scorers'] });\n if (scorerId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n }\n },\n ...queryOptions?.updateStoredScorer,\n });\n\n const deleteMutation = useMutation({\n mutationFn: () => {\n if (!scorerId) throw new Error('scorerId is required for delete');\n return client.getStoredScorer(scorerId).delete(requestContext);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorers'] });\n void queryClient.invalidateQueries({ queryKey: ['scorers'] });\n if (scorerId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n }\n },\n ...queryOptions?.deleteStoredScorer,\n });\n\n return {\n createStoredScorer: createMutation,\n updateStoredScorer: updateMutation,\n deleteStoredScorer: deleteMutation,\n };\n};\n","import type {\n ListScorerVersionsParams,\n CreateScorerVersionParams,\n ListScorerVersionsResponse,\n ScorerVersionResponse,\n CompareScorerVersionsResponse,\n ActivateScorerVersionResponse,\n DeleteScorerVersionResponse,\n} from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\n\nexport type { ListScorerVersionsParams, CreateScorerVersionParams };\n\n/**\n * Hook to list versions of a stored scorer\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useScorerVersions = <TData = ListScorerVersionsResponse>({\n scorerId,\n params,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n params?: ListScorerVersionsParams;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListScorerVersionsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListScorerVersionsResponse, Error, TData>({\n queryKey: ['scorer-versions', scorerId, params, requestContext],\n queryFn: () => client.getStoredScorer(scorerId).listVersions(params, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to get a single version of a stored scorer\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useScorerVersion = <TData = ScorerVersionResponse>({\n scorerId,\n versionId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n versionId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ScorerVersionResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ScorerVersionResponse, Error, TData>({\n queryKey: ['scorer-version', scorerId, versionId, requestContext],\n queryFn: () => client.getStoredScorer(scorerId).getVersion(versionId, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to create a new version of a stored scorer\n */\nexport const useCreateScorerVersion = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ScorerVersionResponse, CreateScorerVersionParams | undefined>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ScorerVersionResponse, Error, CreateScorerVersionParams | undefined>({\n mutationFn: (params?: CreateScorerVersionParams) =>\n client.getStoredScorer(scorerId).createVersion(params, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['scorer-versions', scorerId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to activate a specific version of a stored scorer\n */\nexport const useActivateScorerVersion = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ActivateScorerVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ActivateScorerVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredScorer(scorerId).activateVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['scorer-versions', scorerId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to restore a specific version of a stored scorer (creates a new version from an old one)\n */\nexport const useRestoreScorerVersion = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ScorerVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ScorerVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredScorer(scorerId).restoreVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['scorer-versions', scorerId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to delete a specific version of a stored scorer\n */\nexport const useDeleteScorerVersion = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<DeleteScorerVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<DeleteScorerVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredScorer(scorerId).deleteVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['scorer-versions', scorerId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to compare two versions of a stored scorer\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useCompareScorerVersions = <TData = CompareScorerVersionsResponse>({\n scorerId,\n fromVersionId,\n toVersionId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n fromVersionId: string;\n toVersionId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<CompareScorerVersionsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<CompareScorerVersionsResponse, Error, TData>({\n queryKey: ['scorer-versions-compare', scorerId, fromVersionId, toVersionId, requestContext],\n queryFn: () => client.getStoredScorer(scorerId).compareVersions(fromVersionId, toVersionId, requestContext),\n ...queryOptions,\n });\n};\n"],"mappings":";;;;;;;AASA,MAAM,kBAAkB;AACxB,MAAM,6BAA6B;AAEnC,SAAgB,yBAAyB,OAAsC;CAC7E,IACEA,oBAAAA,yCAAyC,MAAM,MAAM,OAAO,QAAQ,KACpEC,oBAAAA,gCAAgC,MAAM,MAAM,KAAK,GAEjD,OAAO;CAET,OAAO;AACT;AAUA,SAAS,uBAAuB,UAA0C,WAAoB,eAAuB;CACnH,IAAI,UAAU,YAAY,SACxB,OAAO,gBAAgB;AAG3B;AAEA,SAAS,iBAAiB,MAAuC;CAC/D,MAAM,uBAAO,IAAI,IAAY;CAQ7B,OAPe,KAAK,MACjB,SAAQ,SAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,CAClC,QAAO,UAAS;EACf,IAAI,KAAK,IAAI,MAAM,EAAE,GAAG,OAAO;EAC/B,KAAK,IAAI,MAAM,EAAE;EACjB,OAAO;CACT,CACU;AACd;AAEA,MAAa,uBAAoE,EAC/E,UACA,UACA,YACA,mBAGG;CACH,MAAM,SAASC,8BAAAA,gBAAgB;CAC/B,MAAM,EAAE,QAAQ,mBAAmB,QAAQ,wBAAwBC,oBAAAA,UAAU;CAE7E,MAAM,SAAA,GAAQC,sBAAAA,iBAAAA,CAA+E;EAC3F,UAAU;GAAC;GAAU;GAAU;GAAU;EAAU;EACnD,UAAU,EAAE,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,QAAQ,CAAC,CAAC,gBAAgB,eAAe,aAAa,cAAc;EAC1G,GAAG;CACL,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["isUnsupportedObservabilityOperationError","isObservabilityUnavailableError","useMastraClient","useInView","useInfiniteQuery","useState","useQuery","isUnsupportedObservabilityOperationError","isObservabilityUnavailableError","useMastraClient","useQuery","useMastraClient","useMutation","useMastraClient","useQuery","useQueryClient","useMutation","useMastraClient","useQuery","useQueryClient","useMutation"],"sources":["../../../src/hooks/scores/use-scorers.ts","../../../src/hooks/scores/use-trace-span-scores.ts","../../../src/hooks/scores/use-trigger-scorer.ts","../../../src/hooks/scores/use-stored-scorers.ts","../../../src/hooks/scores/use-scorer-versions.ts"],"sourcesContent":["import type { MastraClient, GetScorerResponse, ListScoresResponse } from '@mastra/client-js';\nimport type { UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';\nimport { useInfiniteQuery, useQuery } from '@tanstack/react-query';\nimport { useEffect, useState } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { isObservabilityUnavailableError, isUnsupportedObservabilityOperationError } from '../query/query-utils';\nimport type { MastraInfiniteQueryOptions, MastraQueryOptions } from '../shared/query-options';\nimport { useInView } from '../shared/use-in-view';\n\nconst SCORES_PER_PAGE = 25;\nconst SCORES_REFETCH_INTERVAL_MS = 15_000;\n\nexport function getScoresRefetchInterval(query: { state: { error: unknown } }) {\n if (\n isUnsupportedObservabilityOperationError(query.state.error, 'scores') ||\n isObservabilityUnavailableError(query.state.error)\n ) {\n return false;\n }\n return SCORES_REFETCH_INTERVAL_MS;\n}\n\ntype UseScoresByScorerIdProps<TData> = {\n scorerId: string;\n entityId?: string;\n entityType?: string;\n /** TanStack overrides spread last; `select` defaults to the flattened, de-duplicated score list. */\n queryOptions?: MastraInfiniteQueryOptions<ListScoresResponse, TData, readonly unknown[], number>;\n};\n\nfunction getScoresNextPageParam(lastPage: ListScoresResponse | undefined, _allPages: unknown, lastPageParam: number) {\n if (lastPage?.pagination?.hasMore) {\n return lastPageParam + 1;\n }\n return undefined;\n}\n\nfunction selectFlatScores(data: { pages: ListScoresResponse[] }) {\n const seen = new Set<string>();\n const scores = data.pages\n .flatMap(page => page.scores ?? [])\n .filter(score => {\n if (seen.has(score.id)) return false;\n seen.add(score.id);\n return true;\n });\n return scores;\n}\n\nexport const useScoresByScorerId = <TData = ReturnType<typeof selectFlatScores>>({\n scorerId,\n entityId,\n entityType,\n queryOptions,\n}: UseScoresByScorerIdProps<TData>): UseInfiniteQueryResult<TData, Error> & {\n setEndOfListElement: ReturnType<typeof useInView>['setRef'];\n} => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n\n const query = useInfiniteQuery<ListScoresResponse, Error, TData, readonly unknown[], number>({\n queryKey: ['scores', scorerId, entityId, entityType],\n queryFn: ({ pageParam }) =>\n client.listScoresByScorerId({ scorerId, page: pageParam, perPage: SCORES_PER_PAGE, entityId, entityType }),\n initialPageParam: 0,\n getNextPageParam: getScoresNextPageParam,\n select: data => selectFlatScores(data) as TData,\n refetchInterval: getScoresRefetchInterval,\n ...queryOptions,\n });\n\n const { hasNextPage, isFetchingNextPage, fetchNextPage } = query;\n\n useEffect(() => {\n if (isEndOfListInView && hasNextPage && !isFetchingNextPage) {\n void fetchNextPage();\n }\n }, [isEndOfListInView, hasNextPage, isFetchingNextPage, fetchNextPage]);\n\n return { ...query, setEndOfListElement };\n};\n\nexport const useScorer = (scorerId: string) => {\n const client = useMastraClient();\n const [scorer, setScorer] = useState<GetScorerResponse | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n const fetchScorer = async () => {\n setIsLoading(true);\n setError(null);\n try {\n const res = await client.getScorer(scorerId);\n setScorer(res);\n } catch (error) {\n setScorer(null);\n const errorObj = error instanceof Error ? error : new Error('Error fetching scorer');\n setError(errorObj);\n console.error('Error fetching scorer', error);\n } finally {\n setIsLoading(false);\n }\n };\n\n void fetchScorer();\n }, [scorerId, client]);\n\n return { scorer, isLoading, error };\n};\n\ntype ListScorersResponse = Awaited<ReturnType<MastraClient['listScorers']>>;\n\nexport const useScorers = <TData = ListScorersResponse>({\n requestContext,\n queryOptions,\n}: {\n requestContext?: Record<string, unknown>;\n queryOptions?: MastraQueryOptions<ListScorersResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListScorersResponse, Error, TData>({\n queryKey: ['scorers', requestContext],\n queryFn: () => client.listScorers(requestContext),\n staleTime: 0,\n gcTime: 0,\n ...queryOptions,\n });\n};\n","import type { ListScoresResponse } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { isObservabilityUnavailableError, isUnsupportedObservabilityOperationError } from '../query/query-utils';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nconst TRACE_SPAN_SCORES_REFETCH_INTERVAL_MS = 15_000;\n\nexport function getTraceSpanScoresRefetchInterval(query: { state: { error: unknown } }) {\n if (\n isUnsupportedObservabilityOperationError(query.state.error, 'scores') ||\n isObservabilityUnavailableError(query.state.error)\n ) {\n return false;\n }\n return TRACE_SPAN_SCORES_REFETCH_INTERVAL_MS;\n}\n\ntype useTraceSpanScoresProps<TData> = {\n traceId?: string;\n spanId?: string;\n page?: number;\n queryOptions?: MastraQueryOptions<ListScoresResponse, TData>;\n};\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useTraceSpanScores = <TData = ListScoresResponse>({\n traceId = '',\n spanId = '',\n page,\n queryOptions,\n}: useTraceSpanScoresProps<TData>): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery<ListScoresResponse, Error, TData>({\n queryKey: ['trace-span-scores', traceId, spanId, page],\n queryFn: () => client.listScoresBySpan({ traceId, spanId, page: page || 0, perPage: 10 }),\n refetchInterval: getTraceSpanScoresRefetchInterval,\n gcTime: 0,\n staleTime: 0,\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { useMutation } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\ninterface TriggerScoreArgs {\n scorerName: string;\n traceId: string;\n spanId?: string;\n}\n\ntype TriggerScorerResponse = Awaited<ReturnType<MastraClient['score']>>;\n\nexport const useTriggerScorer = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<TriggerScorerResponse, TriggerScoreArgs> } = {}) => {\n const client = useMastraClient();\n\n return useMutation({\n mutationFn: async ({ scorerName, traceId, spanId }: TriggerScoreArgs) => {\n const response = await client.score({\n scorerName,\n targets: [{ traceId, spanId }],\n });\n\n return response;\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient, CreateStoredScorerParams, UpdateStoredScorerParams } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\n\ntype StoredScorerResponse = Awaited<ReturnType<ReturnType<MastraClient['getStoredScorer']>['details']>>;\ntype DeleteStoredScorerResponse = Awaited<ReturnType<ReturnType<MastraClient['getStoredScorer']>['delete']>>;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useStoredScorer = <TData = StoredScorerResponse | null>({\n scorerId,\n status,\n requestContext,\n queryOptions,\n}: {\n scorerId?: string;\n status?: 'draft' | 'published';\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<StoredScorerResponse | null, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<StoredScorerResponse | null, Error, TData>({\n queryKey: ['stored-scorer', scorerId, status, requestContext],\n queryFn: () => (scorerId ? client.getStoredScorer(scorerId).details(requestContext, { status }) : null),\n ...queryOptions,\n });\n};\n\nexport const useStoredScorerMutations = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: {\n createStoredScorer?: MastraMutationOptions<StoredScorerResponse, CreateStoredScorerParams>;\n updateStoredScorer?: MastraMutationOptions<StoredScorerResponse, UpdateStoredScorerParams>;\n deleteStoredScorer?: MastraMutationOptions<DeleteStoredScorerResponse, void>;\n };\n} = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n const createMutation = useMutation({\n mutationFn: (params: CreateStoredScorerParams) => client.createStoredScorer(params),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorers'] });\n void queryClient.invalidateQueries({ queryKey: ['scorers'] });\n },\n ...queryOptions?.createStoredScorer,\n });\n\n const updateMutation = useMutation({\n mutationFn: (params: UpdateStoredScorerParams) => {\n if (!scorerId) throw new Error('scorerId is required for update');\n return client.getStoredScorer(scorerId).update(params, requestContext);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorers'] });\n void queryClient.invalidateQueries({ queryKey: ['scorers'] });\n if (scorerId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n }\n },\n ...queryOptions?.updateStoredScorer,\n });\n\n const deleteMutation = useMutation({\n mutationFn: () => {\n if (!scorerId) throw new Error('scorerId is required for delete');\n return client.getStoredScorer(scorerId).delete(requestContext);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorers'] });\n void queryClient.invalidateQueries({ queryKey: ['scorers'] });\n if (scorerId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n }\n },\n ...queryOptions?.deleteStoredScorer,\n });\n\n return {\n createStoredScorer: createMutation,\n updateStoredScorer: updateMutation,\n deleteStoredScorer: deleteMutation,\n };\n};\n","import type {\n ListScorerVersionsParams,\n CreateScorerVersionParams,\n ListScorerVersionsResponse,\n ScorerVersionResponse,\n CompareScorerVersionsResponse,\n ActivateScorerVersionResponse,\n DeleteScorerVersionResponse,\n} from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\n\nexport type { ListScorerVersionsParams, CreateScorerVersionParams };\n\n/**\n * Hook to list versions of a stored scorer\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useScorerVersions = <TData = ListScorerVersionsResponse>({\n scorerId,\n params,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n params?: ListScorerVersionsParams;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListScorerVersionsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListScorerVersionsResponse, Error, TData>({\n queryKey: ['scorer-versions', scorerId, params, requestContext],\n queryFn: () => client.getStoredScorer(scorerId).listVersions(params, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to get a single version of a stored scorer\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useScorerVersion = <TData = ScorerVersionResponse>({\n scorerId,\n versionId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n versionId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ScorerVersionResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ScorerVersionResponse, Error, TData>({\n queryKey: ['scorer-version', scorerId, versionId, requestContext],\n queryFn: () => client.getStoredScorer(scorerId).getVersion(versionId, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to create a new version of a stored scorer\n */\nexport const useCreateScorerVersion = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ScorerVersionResponse, CreateScorerVersionParams | undefined>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ScorerVersionResponse, Error, CreateScorerVersionParams | undefined>({\n mutationFn: (params?: CreateScorerVersionParams) =>\n client.getStoredScorer(scorerId).createVersion(params, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['scorer-versions', scorerId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to activate a specific version of a stored scorer\n */\nexport const useActivateScorerVersion = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ActivateScorerVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ActivateScorerVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredScorer(scorerId).activateVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['scorer-versions', scorerId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to restore a specific version of a stored scorer (creates a new version from an old one)\n */\nexport const useRestoreScorerVersion = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ScorerVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ScorerVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredScorer(scorerId).restoreVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['scorer-versions', scorerId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to delete a specific version of a stored scorer\n */\nexport const useDeleteScorerVersion = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<DeleteScorerVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<DeleteScorerVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredScorer(scorerId).deleteVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['scorer-versions', scorerId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to compare two versions of a stored scorer\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useCompareScorerVersions = <TData = CompareScorerVersionsResponse>({\n scorerId,\n fromVersionId,\n toVersionId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n fromVersionId: string;\n toVersionId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<CompareScorerVersionsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<CompareScorerVersionsResponse, Error, TData>({\n queryKey: ['scorer-versions-compare', scorerId, fromVersionId, toVersionId, requestContext],\n queryFn: () => client.getStoredScorer(scorerId).compareVersions(fromVersionId, toVersionId, requestContext),\n ...queryOptions,\n });\n};\n"],"mappings":";;;;;;;AASA,MAAM,kBAAkB;AACxB,MAAM,6BAA6B;AAEnC,SAAgB,yBAAyB,OAAsC;CAC7E,IACEA,oBAAAA,yCAAyC,MAAM,MAAM,OAAO,QAAQ,KACpEC,oBAAAA,gCAAgC,MAAM,MAAM,KAAK,GAEjD,OAAO;CAET,OAAO;AACT;AAUA,SAAS,uBAAuB,UAA0C,WAAoB,eAAuB;CACnH,IAAI,UAAU,YAAY,SACxB,OAAO,gBAAgB;AAG3B;AAEA,SAAS,iBAAiB,MAAuC;CAC/D,MAAM,uBAAO,IAAI,IAAY;CAQ7B,OAPe,KAAK,MACjB,SAAQ,SAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,CA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BAAgB,QAAQ,CAAC,CAAC,cAAc,WAAW,cAAc;EAC3G,iBAAiB;GACf,YAAiB,kBAAkB,EAAE,UAAU,CAAC,mBAAmB,QAAQ,EAAE,CAAC;EAChF;EACA,GAAG;CACL,CAAC;AACH;;;;;;AAOA,MAAa,4BAAmE,EAC9E,UACA,eACA,aACA,gBACA,mBAOkC;CAClC,MAAM,SAASH,8BAAAA,gBAAgB;CAE/B,QAAA,GAAOC,sBAAAA,SAAAA,CAAsD;EAC3D,UAAU;GAAC;GAA2B;GAAU;GAAe;GAAa;EAAc;EAC1F,eAAe,OAAO,gBAAgB,QAAQ,CAAC,CAAC,gBAAgB,eAAe,aAAa,cAAc;EAC1G,GAAG;CACL,CAAC;AACH"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { n as useMastraClient } from "../../mastra-client-context-
|
|
2
|
-
import { t as useInView } from "../../use-in-view-
|
|
3
|
-
import { o as isObservabilityUnavailableError, s as isUnsupportedObservabilityOperationError } from "../../query-utils-
|
|
1
|
+
import { n as useMastraClient } from "../../mastra-client-context-DQ5z_ze9.js";
|
|
2
|
+
import { t as useInView } from "../../use-in-view-CyjKdplM.js";
|
|
3
|
+
import { o as isObservabilityUnavailableError, s as isUnsupportedObservabilityOperationError } from "../../query-utils-DvMERIwf.js";
|
|
4
4
|
import { useEffect, useState } from "react";
|
|
5
5
|
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
6
|
-
|
|
6
|
+
// src/hooks/scores/use-scorers.ts
|
|
7
7
|
const SCORES_PER_PAGE = 25;
|
|
8
8
|
const SCORES_REFETCH_INTERVAL_MS = 15e3;
|
|
9
9
|
function getScoresRefetchInterval(query) {
|
|
@@ -97,8 +97,7 @@ const useScorers = ({ requestContext, queryOptions } = {}) => {
|
|
|
97
97
|
...queryOptions
|
|
98
98
|
});
|
|
99
99
|
};
|
|
100
|
-
|
|
101
|
-
//#region src/hooks/scores/use-trace-span-scores.ts
|
|
100
|
+
// src/hooks/scores/use-trace-span-scores.ts
|
|
102
101
|
const TRACE_SPAN_SCORES_REFETCH_INTERVAL_MS = 15e3;
|
|
103
102
|
function getTraceSpanScoresRefetchInterval(query) {
|
|
104
103
|
if (isUnsupportedObservabilityOperationError(query.state.error, "scores") || isObservabilityUnavailableError(query.state.error)) return false;
|
|
@@ -128,8 +127,7 @@ const useTraceSpanScores = ({ traceId = "", spanId = "", page, queryOptions }) =
|
|
|
128
127
|
...queryOptions
|
|
129
128
|
});
|
|
130
129
|
};
|
|
131
|
-
|
|
132
|
-
//#region src/hooks/scores/use-trigger-scorer.ts
|
|
130
|
+
// src/hooks/scores/use-trigger-scorer.ts
|
|
133
131
|
const useTriggerScorer = ({ queryOptions } = {}) => {
|
|
134
132
|
const client = useMastraClient();
|
|
135
133
|
return useMutation({
|
|
@@ -145,8 +143,7 @@ const useTriggerScorer = ({ queryOptions } = {}) => {
|
|
|
145
143
|
...queryOptions
|
|
146
144
|
});
|
|
147
145
|
};
|
|
148
|
-
|
|
149
|
-
//#region src/hooks/scores/use-stored-scorers.ts
|
|
146
|
+
// src/hooks/scores/use-stored-scorers.ts
|
|
150
147
|
/**
|
|
151
148
|
* Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
|
|
152
149
|
*/
|
|
@@ -201,8 +198,7 @@ const useStoredScorerMutations = ({ scorerId, requestContext, queryOptions } = {
|
|
|
201
198
|
})
|
|
202
199
|
};
|
|
203
200
|
};
|
|
204
|
-
|
|
205
|
-
//#region src/hooks/scores/use-scorer-versions.ts
|
|
201
|
+
// src/hooks/scores/use-scorer-versions.ts
|
|
206
202
|
/**
|
|
207
203
|
* Hook to list versions of a stored scorer
|
|
208
204
|
*
|
|
@@ -317,7 +313,6 @@ const useCompareScorerVersions = ({ scorerId, fromVersionId, toVersionId, reques
|
|
|
317
313
|
...queryOptions
|
|
318
314
|
});
|
|
319
315
|
};
|
|
320
|
-
//#endregion
|
|
321
316
|
export { getScoresRefetchInterval, getTraceSpanScoresRefetchInterval, useActivateScorerVersion, useCompareScorerVersions, useCreateScorerVersion, useDeleteScorerVersion, useRestoreScorerVersion, useScorer, useScorerVersion, useScorerVersions, useScorers, useScoresByScorerId, useStoredScorer, useStoredScorerMutations, useTraceSpanScores, useTriggerScorer };
|
|
322
317
|
|
|
323
318
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/scores/use-scorers.ts","../../../src/hooks/scores/use-trace-span-scores.ts","../../../src/hooks/scores/use-trigger-scorer.ts","../../../src/hooks/scores/use-stored-scorers.ts","../../../src/hooks/scores/use-scorer-versions.ts"],"sourcesContent":["import type { MastraClient, GetScorerResponse, ListScoresResponse } from '@mastra/client-js';\nimport type { UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';\nimport { useInfiniteQuery, useQuery } from '@tanstack/react-query';\nimport { useEffect, useState } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { isObservabilityUnavailableError, isUnsupportedObservabilityOperationError } from '../query/query-utils';\nimport type { MastraInfiniteQueryOptions, MastraQueryOptions } from '../shared/query-options';\nimport { useInView } from '../shared/use-in-view';\n\nconst SCORES_PER_PAGE = 25;\nconst SCORES_REFETCH_INTERVAL_MS = 15_000;\n\nexport function getScoresRefetchInterval(query: { state: { error: unknown } }) {\n if (\n isUnsupportedObservabilityOperationError(query.state.error, 'scores') ||\n isObservabilityUnavailableError(query.state.error)\n ) {\n return false;\n }\n return SCORES_REFETCH_INTERVAL_MS;\n}\n\ntype UseScoresByScorerIdProps<TData> = {\n scorerId: string;\n entityId?: string;\n entityType?: string;\n /** TanStack overrides spread last; `select` defaults to the flattened, de-duplicated score list. */\n queryOptions?: MastraInfiniteQueryOptions<ListScoresResponse, TData, readonly unknown[], number>;\n};\n\nfunction getScoresNextPageParam(lastPage: ListScoresResponse | undefined, _allPages: unknown, lastPageParam: number) {\n if (lastPage?.pagination?.hasMore) {\n return lastPageParam + 1;\n }\n return undefined;\n}\n\nfunction selectFlatScores(data: { pages: ListScoresResponse[] }) {\n const seen = new Set<string>();\n const scores = data.pages\n .flatMap(page => page.scores ?? [])\n .filter(score => {\n if (seen.has(score.id)) return false;\n seen.add(score.id);\n return true;\n });\n return scores;\n}\n\nexport const useScoresByScorerId = <TData = ReturnType<typeof selectFlatScores>>({\n scorerId,\n entityId,\n entityType,\n queryOptions,\n}: UseScoresByScorerIdProps<TData>): UseInfiniteQueryResult<TData, Error> & {\n setEndOfListElement: ReturnType<typeof useInView>['setRef'];\n} => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n\n const query = useInfiniteQuery<ListScoresResponse, Error, TData, readonly unknown[], number>({\n queryKey: ['scores', scorerId, entityId, entityType],\n queryFn: ({ pageParam }) =>\n client.listScoresByScorerId({ scorerId, page: pageParam, perPage: SCORES_PER_PAGE, entityId, entityType }),\n initialPageParam: 0,\n getNextPageParam: getScoresNextPageParam,\n select: data => selectFlatScores(data) as TData,\n refetchInterval: getScoresRefetchInterval,\n ...queryOptions,\n });\n\n const { hasNextPage, isFetchingNextPage, fetchNextPage } = query;\n\n useEffect(() => {\n if (isEndOfListInView && hasNextPage && !isFetchingNextPage) {\n void fetchNextPage();\n }\n }, [isEndOfListInView, hasNextPage, isFetchingNextPage, fetchNextPage]);\n\n return { ...query, setEndOfListElement };\n};\n\nexport const useScorer = (scorerId: string) => {\n const client = useMastraClient();\n const [scorer, setScorer] = useState<GetScorerResponse | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n const fetchScorer = async () => {\n setIsLoading(true);\n setError(null);\n try {\n const res = await client.getScorer(scorerId);\n setScorer(res);\n } catch (error) {\n setScorer(null);\n const errorObj = error instanceof Error ? error : new Error('Error fetching scorer');\n setError(errorObj);\n console.error('Error fetching scorer', error);\n } finally {\n setIsLoading(false);\n }\n };\n\n void fetchScorer();\n }, [scorerId, client]);\n\n return { scorer, isLoading, error };\n};\n\ntype ListScorersResponse = Awaited<ReturnType<MastraClient['listScorers']>>;\n\nexport const useScorers = <TData = ListScorersResponse>({\n requestContext,\n queryOptions,\n}: {\n requestContext?: Record<string, unknown>;\n queryOptions?: MastraQueryOptions<ListScorersResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListScorersResponse, Error, TData>({\n queryKey: ['scorers', requestContext],\n queryFn: () => client.listScorers(requestContext),\n staleTime: 0,\n gcTime: 0,\n ...queryOptions,\n });\n};\n","import type { ListScoresResponse } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { isObservabilityUnavailableError, isUnsupportedObservabilityOperationError } from '../query/query-utils';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nconst TRACE_SPAN_SCORES_REFETCH_INTERVAL_MS = 15_000;\n\nexport function getTraceSpanScoresRefetchInterval(query: { state: { error: unknown } }) {\n if (\n isUnsupportedObservabilityOperationError(query.state.error, 'scores') ||\n isObservabilityUnavailableError(query.state.error)\n ) {\n return false;\n }\n return TRACE_SPAN_SCORES_REFETCH_INTERVAL_MS;\n}\n\ntype useTraceSpanScoresProps<TData> = {\n traceId?: string;\n spanId?: string;\n page?: number;\n queryOptions?: MastraQueryOptions<ListScoresResponse, TData>;\n};\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useTraceSpanScores = <TData = ListScoresResponse>({\n traceId = '',\n spanId = '',\n page,\n queryOptions,\n}: useTraceSpanScoresProps<TData>): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery<ListScoresResponse, Error, TData>({\n queryKey: ['trace-span-scores', traceId, spanId, page],\n queryFn: () => client.listScoresBySpan({ traceId, spanId, page: page || 0, perPage: 10 }),\n refetchInterval: getTraceSpanScoresRefetchInterval,\n gcTime: 0,\n staleTime: 0,\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { useMutation } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\ninterface TriggerScoreArgs {\n scorerName: string;\n traceId: string;\n spanId?: string;\n}\n\ntype TriggerScorerResponse = Awaited<ReturnType<MastraClient['score']>>;\n\nexport const useTriggerScorer = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<TriggerScorerResponse, TriggerScoreArgs> } = {}) => {\n const client = useMastraClient();\n\n return useMutation({\n mutationFn: async ({ scorerName, traceId, spanId }: TriggerScoreArgs) => {\n const response = await client.score({\n scorerName,\n targets: [{ traceId, spanId }],\n });\n\n return response;\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient, CreateStoredScorerParams, UpdateStoredScorerParams } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\n\ntype StoredScorerResponse = Awaited<ReturnType<ReturnType<MastraClient['getStoredScorer']>['details']>>;\ntype DeleteStoredScorerResponse = Awaited<ReturnType<ReturnType<MastraClient['getStoredScorer']>['delete']>>;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useStoredScorer = <TData = StoredScorerResponse | null>({\n scorerId,\n status,\n requestContext,\n queryOptions,\n}: {\n scorerId?: string;\n status?: 'draft' | 'published';\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<StoredScorerResponse | null, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<StoredScorerResponse | null, Error, TData>({\n queryKey: ['stored-scorer', scorerId, status, requestContext],\n queryFn: () => (scorerId ? client.getStoredScorer(scorerId).details(requestContext, { status }) : null),\n ...queryOptions,\n });\n};\n\nexport const useStoredScorerMutations = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: {\n createStoredScorer?: MastraMutationOptions<StoredScorerResponse, CreateStoredScorerParams>;\n updateStoredScorer?: MastraMutationOptions<StoredScorerResponse, UpdateStoredScorerParams>;\n deleteStoredScorer?: MastraMutationOptions<DeleteStoredScorerResponse, void>;\n };\n} = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n const createMutation = useMutation({\n mutationFn: (params: CreateStoredScorerParams) => client.createStoredScorer(params),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorers'] });\n void queryClient.invalidateQueries({ queryKey: ['scorers'] });\n },\n ...queryOptions?.createStoredScorer,\n });\n\n const updateMutation = useMutation({\n mutationFn: (params: UpdateStoredScorerParams) => {\n if (!scorerId) throw new Error('scorerId is required for update');\n return client.getStoredScorer(scorerId).update(params, requestContext);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorers'] });\n void queryClient.invalidateQueries({ queryKey: ['scorers'] });\n if (scorerId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n }\n },\n ...queryOptions?.updateStoredScorer,\n });\n\n const deleteMutation = useMutation({\n mutationFn: () => {\n if (!scorerId) throw new Error('scorerId is required for delete');\n return client.getStoredScorer(scorerId).delete(requestContext);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorers'] });\n void queryClient.invalidateQueries({ queryKey: ['scorers'] });\n if (scorerId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n }\n },\n ...queryOptions?.deleteStoredScorer,\n });\n\n return {\n createStoredScorer: createMutation,\n updateStoredScorer: updateMutation,\n deleteStoredScorer: deleteMutation,\n };\n};\n","import type {\n ListScorerVersionsParams,\n CreateScorerVersionParams,\n ListScorerVersionsResponse,\n ScorerVersionResponse,\n CompareScorerVersionsResponse,\n ActivateScorerVersionResponse,\n DeleteScorerVersionResponse,\n} from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\n\nexport type { ListScorerVersionsParams, CreateScorerVersionParams };\n\n/**\n * Hook to list versions of a stored scorer\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useScorerVersions = <TData = ListScorerVersionsResponse>({\n scorerId,\n params,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n params?: ListScorerVersionsParams;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListScorerVersionsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListScorerVersionsResponse, Error, TData>({\n queryKey: ['scorer-versions', scorerId, params, requestContext],\n queryFn: () => client.getStoredScorer(scorerId).listVersions(params, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to get a single version of a stored scorer\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useScorerVersion = <TData = ScorerVersionResponse>({\n scorerId,\n versionId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n versionId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ScorerVersionResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ScorerVersionResponse, Error, TData>({\n queryKey: ['scorer-version', scorerId, versionId, requestContext],\n queryFn: () => client.getStoredScorer(scorerId).getVersion(versionId, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to create a new version of a stored scorer\n */\nexport const useCreateScorerVersion = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ScorerVersionResponse, CreateScorerVersionParams | undefined>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ScorerVersionResponse, Error, CreateScorerVersionParams | undefined>({\n mutationFn: (params?: CreateScorerVersionParams) =>\n client.getStoredScorer(scorerId).createVersion(params, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['scorer-versions', scorerId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to activate a specific version of a stored scorer\n */\nexport const useActivateScorerVersion = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ActivateScorerVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ActivateScorerVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredScorer(scorerId).activateVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['scorer-versions', scorerId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to restore a specific version of a stored scorer (creates a new version from an old one)\n */\nexport const useRestoreScorerVersion = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ScorerVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ScorerVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredScorer(scorerId).restoreVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['scorer-versions', scorerId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to delete a specific version of a stored scorer\n */\nexport const useDeleteScorerVersion = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<DeleteScorerVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<DeleteScorerVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredScorer(scorerId).deleteVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['scorer-versions', scorerId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to compare two versions of a stored scorer\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useCompareScorerVersions = <TData = CompareScorerVersionsResponse>({\n scorerId,\n fromVersionId,\n toVersionId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n fromVersionId: string;\n toVersionId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<CompareScorerVersionsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<CompareScorerVersionsResponse, Error, TData>({\n queryKey: ['scorer-versions-compare', scorerId, fromVersionId, toVersionId, requestContext],\n queryFn: () => client.getStoredScorer(scorerId).compareVersions(fromVersionId, toVersionId, requestContext),\n ...queryOptions,\n });\n};\n"],"mappings":";;;;;;AASA,MAAM,kBAAkB;AACxB,MAAM,6BAA6B;AAEnC,SAAgB,yBAAyB,OAAsC;CAC7E,IACE,yCAAyC,MAAM,MAAM,OAAO,QAAQ,KACpE,gCAAgC,MAAM,MAAM,KAAK,GAEjD,OAAO;CAET,OAAO;AACT;AAUA,SAAS,uBAAuB,UAA0C,WAAoB,eAAuB;CACnH,IAAI,UAAU,YAAY,SACxB,OAAO,gBAAgB;AAG3B;AAEA,SAAS,iBAAiB,MAAuC;CAC/D,MAAM,uBAAO,IAAI,IAAY;CAQ7B,OAPe,KAAK,MACjB,SAAQ,SAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,CAClC,QAAO,UAAS;EACf,IAAI,KAAK,IAAI,MAAM,EAAE,GAAG,OA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C,UACA,gBACA,mBAKI;CACJ,MAAM,SAAS,gBAAgB;CAC/B,MAAM,cAAc,eAAe;CAEnC,OAAO,YAAkD;EACvD,aAAa,cAAsB,OAAO,gBAAgB,QAAQ,CAAC,CAAC,eAAe,WAAW,cAAc;EAC5G,iBAAiB;GACf,YAAiB,kBAAkB,EAAE,UAAU,CAAC,mBAAmB,QAAQ,EAAE,CAAC;GAC9E,YAAiB,kBAAkB,EAAE,UAAU,CAAC,iBAAiB,QAAQ,EAAE,CAAC;EAC9E;EACA,GAAG;CACL,CAAC;AACH;;;;AAKA,MAAa,0BAA0B,EACrC,UACA,gBACA,mBAKI;CACJ,MAAM,SAAS,gBAAgB;CAC/B,MAAM,cAAc,eAAe;CAEnC,OAAO,YAAwD;EAC7D,aAAa,cAAsB,OAAO,gBAAgB,QAAQ,CAAC,CAAC,cAAc,WAAW,cAAc;EAC3G,iBAAiB;GACf,YAAiB,kBAAkB,EAAE,UAAU,CAAC,mBAAmB,QAAQ,EAAE,CAAC;EAChF;EACA,GAAG;CACL,CAAC;AACH;;;;;;AAOA,MAAa,4BAAmE,EAC9E,UACA,eACA,aACA,gBACA,mBAOkC;CAClC,MAAM,SAAS,gBAAgB;CAE/B,OAAO,SAAsD;EAC3D,UAAU;GAAC;GAA2B;GAAU;GAAe;GAAa;EAAc;EAC1F,eAAe,OAAO,gBAAgB,QAAQ,CAAC,CAAC,gBAAgB,eAAe,aAAa,cAAc;EAC1G,GAAG;CACL,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/scores/use-scorers.ts","../../../src/hooks/scores/use-trace-span-scores.ts","../../../src/hooks/scores/use-trigger-scorer.ts","../../../src/hooks/scores/use-stored-scorers.ts","../../../src/hooks/scores/use-scorer-versions.ts"],"sourcesContent":["import type { MastraClient, GetScorerResponse, ListScoresResponse } from '@mastra/client-js';\nimport type { UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';\nimport { useInfiniteQuery, useQuery } from '@tanstack/react-query';\nimport { useEffect, useState } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { isObservabilityUnavailableError, isUnsupportedObservabilityOperationError } from '../query/query-utils';\nimport type { MastraInfiniteQueryOptions, MastraQueryOptions } from '../shared/query-options';\nimport { useInView } from '../shared/use-in-view';\n\nconst SCORES_PER_PAGE = 25;\nconst SCORES_REFETCH_INTERVAL_MS = 15_000;\n\nexport function getScoresRefetchInterval(query: { state: { error: unknown } }) {\n if (\n isUnsupportedObservabilityOperationError(query.state.error, 'scores') ||\n isObservabilityUnavailableError(query.state.error)\n ) {\n return false;\n }\n return SCORES_REFETCH_INTERVAL_MS;\n}\n\ntype UseScoresByScorerIdProps<TData> = {\n scorerId: string;\n entityId?: string;\n entityType?: string;\n /** TanStack overrides spread last; `select` defaults to the flattened, de-duplicated score list. */\n queryOptions?: MastraInfiniteQueryOptions<ListScoresResponse, TData, readonly unknown[], number>;\n};\n\nfunction getScoresNextPageParam(lastPage: ListScoresResponse | undefined, _allPages: unknown, lastPageParam: number) {\n if (lastPage?.pagination?.hasMore) {\n return lastPageParam + 1;\n }\n return undefined;\n}\n\nfunction selectFlatScores(data: { pages: ListScoresResponse[] }) {\n const seen = new Set<string>();\n const scores = data.pages\n .flatMap(page => page.scores ?? [])\n .filter(score => {\n if (seen.has(score.id)) return false;\n seen.add(score.id);\n return true;\n });\n return scores;\n}\n\nexport const useScoresByScorerId = <TData = ReturnType<typeof selectFlatScores>>({\n scorerId,\n entityId,\n entityType,\n queryOptions,\n}: UseScoresByScorerIdProps<TData>): UseInfiniteQueryResult<TData, Error> & {\n setEndOfListElement: ReturnType<typeof useInView>['setRef'];\n} => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n\n const query = useInfiniteQuery<ListScoresResponse, Error, TData, readonly unknown[], number>({\n queryKey: ['scores', scorerId, entityId, entityType],\n queryFn: ({ pageParam }) =>\n client.listScoresByScorerId({ scorerId, page: pageParam, perPage: SCORES_PER_PAGE, entityId, entityType }),\n initialPageParam: 0,\n getNextPageParam: getScoresNextPageParam,\n select: data => selectFlatScores(data) as TData,\n refetchInterval: getScoresRefetchInterval,\n ...queryOptions,\n });\n\n const { hasNextPage, isFetchingNextPage, fetchNextPage } = query;\n\n useEffect(() => {\n if (isEndOfListInView && hasNextPage && !isFetchingNextPage) {\n void fetchNextPage();\n }\n }, [isEndOfListInView, hasNextPage, isFetchingNextPage, fetchNextPage]);\n\n return { ...query, setEndOfListElement };\n};\n\nexport const useScorer = (scorerId: string) => {\n const client = useMastraClient();\n const [scorer, setScorer] = useState<GetScorerResponse | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n const fetchScorer = async () => {\n setIsLoading(true);\n setError(null);\n try {\n const res = await client.getScorer(scorerId);\n setScorer(res);\n } catch (error) {\n setScorer(null);\n const errorObj = error instanceof Error ? error : new Error('Error fetching scorer');\n setError(errorObj);\n console.error('Error fetching scorer', error);\n } finally {\n setIsLoading(false);\n }\n };\n\n void fetchScorer();\n }, [scorerId, client]);\n\n return { scorer, isLoading, error };\n};\n\ntype ListScorersResponse = Awaited<ReturnType<MastraClient['listScorers']>>;\n\nexport const useScorers = <TData = ListScorersResponse>({\n requestContext,\n queryOptions,\n}: {\n requestContext?: Record<string, unknown>;\n queryOptions?: MastraQueryOptions<ListScorersResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListScorersResponse, Error, TData>({\n queryKey: ['scorers', requestContext],\n queryFn: () => client.listScorers(requestContext),\n staleTime: 0,\n gcTime: 0,\n ...queryOptions,\n });\n};\n","import type { ListScoresResponse } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { isObservabilityUnavailableError, isUnsupportedObservabilityOperationError } from '../query/query-utils';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nconst TRACE_SPAN_SCORES_REFETCH_INTERVAL_MS = 15_000;\n\nexport function getTraceSpanScoresRefetchInterval(query: { state: { error: unknown } }) {\n if (\n isUnsupportedObservabilityOperationError(query.state.error, 'scores') ||\n isObservabilityUnavailableError(query.state.error)\n ) {\n return false;\n }\n return TRACE_SPAN_SCORES_REFETCH_INTERVAL_MS;\n}\n\ntype useTraceSpanScoresProps<TData> = {\n traceId?: string;\n spanId?: string;\n page?: number;\n queryOptions?: MastraQueryOptions<ListScoresResponse, TData>;\n};\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useTraceSpanScores = <TData = ListScoresResponse>({\n traceId = '',\n spanId = '',\n page,\n queryOptions,\n}: useTraceSpanScoresProps<TData>): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n return useQuery<ListScoresResponse, Error, TData>({\n queryKey: ['trace-span-scores', traceId, spanId, page],\n queryFn: () => client.listScoresBySpan({ traceId, spanId, page: page || 0, perPage: 10 }),\n refetchInterval: getTraceSpanScoresRefetchInterval,\n gcTime: 0,\n staleTime: 0,\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { useMutation } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\ninterface TriggerScoreArgs {\n scorerName: string;\n traceId: string;\n spanId?: string;\n}\n\ntype TriggerScorerResponse = Awaited<ReturnType<MastraClient['score']>>;\n\nexport const useTriggerScorer = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<TriggerScorerResponse, TriggerScoreArgs> } = {}) => {\n const client = useMastraClient();\n\n return useMutation({\n mutationFn: async ({ scorerName, traceId, spanId }: TriggerScoreArgs) => {\n const response = await client.score({\n scorerName,\n targets: [{ traceId, spanId }],\n });\n\n return response;\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient, CreateStoredScorerParams, UpdateStoredScorerParams } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\n\ntype StoredScorerResponse = Awaited<ReturnType<ReturnType<MastraClient['getStoredScorer']>['details']>>;\ntype DeleteStoredScorerResponse = Awaited<ReturnType<ReturnType<MastraClient['getStoredScorer']>['delete']>>;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useStoredScorer = <TData = StoredScorerResponse | null>({\n scorerId,\n status,\n requestContext,\n queryOptions,\n}: {\n scorerId?: string;\n status?: 'draft' | 'published';\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<StoredScorerResponse | null, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<StoredScorerResponse | null, Error, TData>({\n queryKey: ['stored-scorer', scorerId, status, requestContext],\n queryFn: () => (scorerId ? client.getStoredScorer(scorerId).details(requestContext, { status }) : null),\n ...queryOptions,\n });\n};\n\nexport const useStoredScorerMutations = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: {\n createStoredScorer?: MastraMutationOptions<StoredScorerResponse, CreateStoredScorerParams>;\n updateStoredScorer?: MastraMutationOptions<StoredScorerResponse, UpdateStoredScorerParams>;\n deleteStoredScorer?: MastraMutationOptions<DeleteStoredScorerResponse, void>;\n };\n} = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n const createMutation = useMutation({\n mutationFn: (params: CreateStoredScorerParams) => client.createStoredScorer(params),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorers'] });\n void queryClient.invalidateQueries({ queryKey: ['scorers'] });\n },\n ...queryOptions?.createStoredScorer,\n });\n\n const updateMutation = useMutation({\n mutationFn: (params: UpdateStoredScorerParams) => {\n if (!scorerId) throw new Error('scorerId is required for update');\n return client.getStoredScorer(scorerId).update(params, requestContext);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorers'] });\n void queryClient.invalidateQueries({ queryKey: ['scorers'] });\n if (scorerId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n }\n },\n ...queryOptions?.updateStoredScorer,\n });\n\n const deleteMutation = useMutation({\n mutationFn: () => {\n if (!scorerId) throw new Error('scorerId is required for delete');\n return client.getStoredScorer(scorerId).delete(requestContext);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorers'] });\n void queryClient.invalidateQueries({ queryKey: ['scorers'] });\n if (scorerId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n }\n },\n ...queryOptions?.deleteStoredScorer,\n });\n\n return {\n createStoredScorer: createMutation,\n updateStoredScorer: updateMutation,\n deleteStoredScorer: deleteMutation,\n };\n};\n","import type {\n ListScorerVersionsParams,\n CreateScorerVersionParams,\n ListScorerVersionsResponse,\n ScorerVersionResponse,\n CompareScorerVersionsResponse,\n ActivateScorerVersionResponse,\n DeleteScorerVersionResponse,\n} from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions, MastraQueryOptions } from '../shared/query-options';\n\nexport type { ListScorerVersionsParams, CreateScorerVersionParams };\n\n/**\n * Hook to list versions of a stored scorer\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useScorerVersions = <TData = ListScorerVersionsResponse>({\n scorerId,\n params,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n params?: ListScorerVersionsParams;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListScorerVersionsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListScorerVersionsResponse, Error, TData>({\n queryKey: ['scorer-versions', scorerId, params, requestContext],\n queryFn: () => client.getStoredScorer(scorerId).listVersions(params, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to get a single version of a stored scorer\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useScorerVersion = <TData = ScorerVersionResponse>({\n scorerId,\n versionId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n versionId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ScorerVersionResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ScorerVersionResponse, Error, TData>({\n queryKey: ['scorer-version', scorerId, versionId, requestContext],\n queryFn: () => client.getStoredScorer(scorerId).getVersion(versionId, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to create a new version of a stored scorer\n */\nexport const useCreateScorerVersion = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ScorerVersionResponse, CreateScorerVersionParams | undefined>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ScorerVersionResponse, Error, CreateScorerVersionParams | undefined>({\n mutationFn: (params?: CreateScorerVersionParams) =>\n client.getStoredScorer(scorerId).createVersion(params, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['scorer-versions', scorerId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to activate a specific version of a stored scorer\n */\nexport const useActivateScorerVersion = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ActivateScorerVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ActivateScorerVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredScorer(scorerId).activateVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['scorer-versions', scorerId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to restore a specific version of a stored scorer (creates a new version from an old one)\n */\nexport const useRestoreScorerVersion = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ScorerVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ScorerVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredScorer(scorerId).restoreVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['scorer-versions', scorerId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-scorer', scorerId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to delete a specific version of a stored scorer\n */\nexport const useDeleteScorerVersion = ({\n scorerId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<DeleteScorerVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<DeleteScorerVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredScorer(scorerId).deleteVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['scorer-versions', scorerId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to compare two versions of a stored scorer\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useCompareScorerVersions = <TData = CompareScorerVersionsResponse>({\n scorerId,\n fromVersionId,\n toVersionId,\n requestContext,\n queryOptions,\n}: {\n scorerId: string;\n fromVersionId: string;\n toVersionId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<CompareScorerVersionsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<CompareScorerVersionsResponse, Error, TData>({\n queryKey: ['scorer-versions-compare', scorerId, fromVersionId, toVersionId, requestContext],\n queryFn: () => client.getStoredScorer(scorerId).compareVersions(fromVersionId, toVersionId, requestContext),\n ...queryOptions,\n });\n};\n"],"mappings":";;;;;;AASA,MAAM,kBAAkB;AACxB,MAAM,6BAA6B;AAEnC,SAAgB,yBAAyB,OAAsC;CAC7E,IACE,yCAAyC,MAAM,MAAM,OAAO,QAAQ,KACpE,gCAAgC,MAAM,MAAM,KAAK,GAEjD,OAAO;CAET,OAAO;AACT;AAUA,SAAS,uBAAuB,UAA0C,WAAoB,eAAuB;CACnH,IAAI,UAAU,YAAY,SACxB,OAAO,gBAAgB;AAG3B;AAEA,SAAS,iBAAiB,MAAuC;CAC/D,MAAM,uBAAO,IAAI,IAAY;CAQ7B,OAPe,KAAK,MACjB,SAAQ,SAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,CAClC,QAAO,UAAS;EACf,IAAI,KAAK,IAAI,MAAM,EAAE,GAAG,OAAO;EAC/B,KAAK,IAAI,MAAM,EAAE;EACjB,OAAO;CACT,CACU;AACd;AAEA,MAAa,uBAAoE,EAC/E,UACA,UACA,YACA,mBAGG;CACH,MAAM,SAAS,gBAAgB;CAC/B,MAAM,EAAE,QAAQ,mBAAmB,QAAQ,wBAAwB,UAAU;CAE7E,MAAM,QAAQ,iBAA+E;EAC3F,UAAU;GAAC;GAAU;GAAU;GAAU;EAAU;EACnD,UAAU,EAAE,gBACV,OAAO,qBAAqB;GAAE;GAAU,MAAM;GAAW,SAAS;GAAiB;GAAU;EAAW,CAAC;EAC3G,kBAAkB;EAClB,kBAAkB;EAClB,SAAQ,SAAQ,iBAAiB,IAAI;EACrC,iBAAiB;EACjB,GAAG;CACL,CAAC;CAED,MAAM,EAAE,aAAa,oBAAoB,kBAAkB;CAE3D,gBAAgB;EACd,IAAI,qBAAqB,eAAe,CAAC,o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B;GACf,YAAiB,kBAAkB,EAAE,UAAU,CAAC,mBAAmB,QAAQ,EAAE,CAAC;EAChF;EACA,GAAG;CACL,CAAC;AACH;;;;;;AAOA,MAAa,4BAAmE,EAC9E,UACA,eACA,aACA,gBACA,mBAOkC;CAClC,MAAM,SAAS,gBAAgB;CAE/B,OAAO,SAAsD;EAC3D,UAAU;GAAC;GAA2B;GAAU;GAAe;GAAa;EAAc;EAC1F,eAAe,OAAO,gBAAgB,QAAQ,CAAC,CAAC,gBAAgB,eAAe,aAAa,cAAc;EAC1G,GAAG;CACL,CAAC;AACH"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_mastra_client_context = require("../../mastra-client-context-
|
|
2
|
+
const require_mastra_client_context = require("../../mastra-client-context-DX8wJM9p.cjs");
|
|
3
3
|
let react = require("react");
|
|
4
4
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
5
5
|
let _mastra_core_request_context = require("@mastra/core/request-context");
|
|
6
|
-
|
|
6
|
+
// src/hooks/templates/use-templates.ts
|
|
7
7
|
async function getMastraTemplateRepos() {
|
|
8
8
|
const response = await fetch("https://mastra.ai/api/templates.json");
|
|
9
9
|
if (!response.ok) throw new Error(`Failed to fetch templates: ${response.statusText}`);
|
|
@@ -453,7 +453,6 @@ const useObserveStreamTemplateInstall = ({ workflowInfo, queryOptions } = {}) =>
|
|
|
453
453
|
isStreaming
|
|
454
454
|
};
|
|
455
455
|
};
|
|
456
|
-
//#endregion
|
|
457
456
|
exports.useAgentBuilderWorkflow = useAgentBuilderWorkflow;
|
|
458
457
|
exports.useCreateTemplateInstallRun = useCreateTemplateInstallRun;
|
|
459
458
|
exports.useGetTemplateInstallRun = useGetTemplateInstallRun;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as useMastraClient } from "../../mastra-client-context-
|
|
1
|
+
import { n as useMastraClient } from "../../mastra-client-context-DQ5z_ze9.js";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
4
4
|
import { RequestContext } from "@mastra/core/request-context";
|
|
5
|
-
|
|
5
|
+
// src/hooks/templates/use-templates.ts
|
|
6
6
|
async function getMastraTemplateRepos() {
|
|
7
7
|
const response = await fetch("https://mastra.ai/api/templates.json");
|
|
8
8
|
if (!response.ok) throw new Error(`Failed to fetch templates: ${response.statusText}`);
|
|
@@ -452,7 +452,6 @@ const useObserveStreamTemplateInstall = ({ workflowInfo, queryOptions } = {}) =>
|
|
|
452
452
|
isStreaming
|
|
453
453
|
};
|
|
454
454
|
};
|
|
455
|
-
//#endregion
|
|
456
455
|
export { useAgentBuilderWorkflow, useCreateTemplateInstallRun, useGetTemplateInstallRun, useMastraTemplates, useObserveStreamTemplateInstall, useStreamTemplateInstall, useTemplateRepo, useTemplateRepoEnvVars };
|
|
457
456
|
|
|
458
457
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_mastra_client_context = require("../../mastra-client-context-
|
|
2
|
+
const require_mastra_client_context = require("../../mastra-client-context-DX8wJM9p.cjs");
|
|
3
3
|
const require_hooks_auth_index = require("../auth/index.cjs");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
6
|
-
|
|
6
|
+
// src/hooks/tool-providers/use-tool-providers.ts
|
|
7
7
|
const useToolProviders = ({ queryOptions } = {}) => {
|
|
8
8
|
const client = require_mastra_client_context.useMastraClient();
|
|
9
9
|
return (0, _tanstack_react_query.useQuery)({
|
|
@@ -38,8 +38,7 @@ const useAllIntegrationTools = ({ queryOptions } = {}) => {
|
|
|
38
38
|
isLoading: isLoadingProviders || toolsQuery.isLoading
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
|
-
|
|
42
|
-
//#region src/hooks/tool-providers/use-all-connections.ts
|
|
41
|
+
// src/hooks/tool-providers/use-all-connections.ts
|
|
43
42
|
/**
|
|
44
43
|
* Stale time long enough to avoid refetching on every picker re-render but
|
|
45
44
|
* short enough that an OAuth completion in a sibling tab is reflected
|
|
@@ -115,8 +114,7 @@ const useAllConnections = ({ scopeToSelf = false, queryOptions } = {}) => {
|
|
|
115
114
|
isLoading
|
|
116
115
|
};
|
|
117
116
|
};
|
|
118
|
-
|
|
119
|
-
//#region src/hooks/tool-providers/use-all-provider-tools.ts
|
|
117
|
+
// src/hooks/tool-providers/use-all-provider-tools.ts
|
|
120
118
|
/**
|
|
121
119
|
* Upper bound for a single Composio-style `listTools` call. Composio's SDK has
|
|
122
120
|
* no cursor — only `limit` — so we ask for a large page and fan out per
|
|
@@ -182,8 +180,7 @@ const useAllProviderTools = ({ queryOptions } = {}) => {
|
|
|
182
180
|
isLoading
|
|
183
181
|
};
|
|
184
182
|
};
|
|
185
|
-
|
|
186
|
-
//#region src/hooks/tool-providers/use-authorize.ts
|
|
183
|
+
// src/hooks/tool-providers/use-authorize.ts
|
|
187
184
|
const DEFAULT_POLL_INTERVAL_MS = 2e3;
|
|
188
185
|
const DEFAULT_TIMEOUT_MS = 3e5;
|
|
189
186
|
/**
|
|
@@ -229,8 +226,7 @@ const useAuthorize = (options = {}) => {
|
|
|
229
226
|
...options.queryOptions
|
|
230
227
|
});
|
|
231
228
|
};
|
|
232
|
-
|
|
233
|
-
//#region src/hooks/tool-providers/use-disconnect-connection.ts
|
|
229
|
+
// src/hooks/tool-providers/use-disconnect-connection.ts
|
|
234
230
|
const useDisconnectConnection = ({ queryOptions } = {}) => {
|
|
235
231
|
const client = require_mastra_client_context.useMastraClient();
|
|
236
232
|
const qc = (0, _tanstack_react_query.useQueryClient)();
|
|
@@ -244,8 +240,7 @@ const useDisconnectConnection = ({ queryOptions } = {}) => {
|
|
|
244
240
|
...queryOptions
|
|
245
241
|
});
|
|
246
242
|
};
|
|
247
|
-
|
|
248
|
-
//#region src/hooks/tool-providers/use-existing-connections.ts
|
|
243
|
+
// src/hooks/tool-providers/use-existing-connections.ts
|
|
249
244
|
/**
|
|
250
245
|
* Lists existing provider connections for the caller, scoped to a tool
|
|
251
246
|
* service. Powers the "use existing connection" path in the picker so
|
|
@@ -280,8 +275,7 @@ const useExistingConnections = ({ providerId, toolkit, scopeToSelf = false, quer
|
|
|
280
275
|
...queryOptions
|
|
281
276
|
});
|
|
282
277
|
};
|
|
283
|
-
|
|
284
|
-
//#region src/hooks/tool-providers/use-provider-tools.ts
|
|
278
|
+
// src/hooks/tool-providers/use-provider-tools.ts
|
|
285
279
|
/**
|
|
286
280
|
* Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
|
|
287
281
|
*/
|
|
@@ -298,8 +292,7 @@ const useProviderTools = ({ providerId, params, queryOptions }) => {
|
|
|
298
292
|
...queryOptions
|
|
299
293
|
});
|
|
300
294
|
};
|
|
301
|
-
|
|
302
|
-
//#region src/hooks/tool-providers/use-toolkits.ts
|
|
295
|
+
// src/hooks/tool-providers/use-toolkits.ts
|
|
303
296
|
/**
|
|
304
297
|
* Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
|
|
305
298
|
*/
|
|
@@ -311,8 +304,7 @@ const useToolkits = ({ providerId, queryOptions }) => {
|
|
|
311
304
|
...queryOptions
|
|
312
305
|
});
|
|
313
306
|
};
|
|
314
|
-
|
|
315
|
-
//#region src/hooks/tool-providers/use-update-connection.ts
|
|
307
|
+
// src/hooks/tool-providers/use-update-connection.ts
|
|
316
308
|
const useUpdateConnection = ({ queryOptions } = {}) => {
|
|
317
309
|
const client = require_mastra_client_context.useMastraClient();
|
|
318
310
|
const qc = (0, _tanstack_react_query.useQueryClient)();
|
|
@@ -327,7 +319,6 @@ const useUpdateConnection = ({ queryOptions } = {}) => {
|
|
|
327
319
|
...queryOptions
|
|
328
320
|
});
|
|
329
321
|
};
|
|
330
|
-
//#endregion
|
|
331
322
|
exports.useAllConnections = useAllConnections;
|
|
332
323
|
exports.useAllIntegrationTools = useAllIntegrationTools;
|
|
333
324
|
exports.useAllProviderTools = useAllProviderTools;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useMastraClient","useQuery","useMastraClient","useMemo","useCurrentUser","isUnauthenticatedError","useQueries","useCallback","useMastraClient","useMemo","useQueries","useMastraClient","useMutation","useMastraClient","useQueryClient","useMutation","useMastraClient","useCurrentUser","isUnauthenticatedError","useQuery","useMastraClient","useQuery","useMastraClient","useQuery","useMastraClient","useQueryClient","useMutation"],"sources":["../../../src/hooks/tool-providers/use-tool-providers.ts","../../../src/hooks/tool-providers/use-all-connections.ts","../../../src/hooks/tool-providers/use-all-provider-tools.ts","../../../src/hooks/tool-providers/use-authorize.ts","../../../src/hooks/tool-providers/use-disconnect-connection.ts","../../../src/hooks/tool-providers/use-existing-connections.ts","../../../src/hooks/tool-providers/use-provider-tools.ts","../../../src/hooks/tool-providers/use-toolkits.ts","../../../src/hooks/tool-providers/use-update-connection.ts"],"sourcesContent":["import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype ToolProvidersResponse = Awaited<ReturnType<MastraClient['listToolProviders']>>;\n\nexport const useToolProviders = <TData = ToolProvidersResponse>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<ToolProvidersResponse, TData> } = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['tool-providers'],\n queryFn: () => client.listToolProviders(),\n ...queryOptions,\n });\n};\n\nexport interface IntegrationTool {\n slug: string;\n name: string;\n description?: string;\n toolkit?: string;\n providerId: string;\n providerName: string;\n}\n\nexport const useAllIntegrationTools = ({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<IntegrationTool[]> } = {}) => {\n const client = useMastraClient();\n const { data: providersData, isLoading: isLoadingProviders } = useToolProviders();\n const providers = providersData?.providers ?? [];\n\n const toolsQuery = useQuery({\n queryKey: ['integration-tools-all', providers.map(p => p.id)],\n queryFn: async () => {\n const results: IntegrationTool[] = [];\n\n for (const provider of providers) {\n const response = await client.getToolProvider(provider.id).listTools();\n for (const tool of response.data) {\n results.push({\n ...tool,\n providerId: provider.id,\n providerName: provider.name,\n });\n }\n }\n\n return results;\n },\n enabled: providers.length > 0,\n ...queryOptions,\n });\n\n return {\n data: toolsQuery.data ?? [],\n isLoading: isLoadingProviders || toolsQuery.isLoading,\n };\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { useQueries } from '@tanstack/react-query';\nimport { useCallback, useMemo } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { isUnauthenticatedError, useCurrentUser } from '../auth';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nimport { useToolProviders } from './use-tool-providers';\n\n/**\n * Stale time long enough to avoid refetching on every picker re-render but\n * short enough that an OAuth completion in a sibling tab is reflected\n * promptly (React Query also re-fetches on window focus by default).\n */\nconst STALE_TIME_MS = 30_000;\n\nexport interface UseAllConnectionsOptions {\n /**\n * When `true`, the hook forces the server-side `authorId` filter to the\n * caller's own userId. Builder edit view passes `scopeToSelf: true` so\n * admins see only their own connections, never other authors' rows.\n *\n * Non-admin callers see the same result either way — the server already\n * scopes to the caller's bucket — but the explicit filter keeps caches\n * consistent and prevents admin cross-author leakage.\n */\n scopeToSelf?: boolean;\n /** TanStack overrides applied to every fanned-out query, spread last. `select` must keep the default shape. */\n queryOptions?: {\n toolkits?: MastraQueryOptions<Awaited<ReturnType<ReturnType<MastraClient['getToolProvider']>['listToolkits']>>>;\n connections?: MastraQueryOptions<\n Awaited<ReturnType<ReturnType<MastraClient['getToolProvider']>['listConnections']>>\n >;\n };\n}\n\n/**\n * Fans out across every registered ToolProvider and every toolkit it\n * exposes to determine whether the caller has an existing connection for a\n * given `(providerId, toolkit)` pair.\n *\n * Used by the Builder tool picker to gate integration tool rows: if the\n * pair has no connection, the card cannot be selected and surfaces an\n * inline \"Connect\" button instead.\n *\n * Distinct from `useExistingConnections` (per-pair, used by `/integrations`)\n * to keep their query caches independent.\n */\nexport const useAllConnections = ({ scopeToSelf = false, queryOptions }: UseAllConnectionsOptions = {}) => {\n const client = useMastraClient();\n const providersQuery = useToolProviders();\n const providers = useMemo(() => providersQuery.data?.providers ?? [], [providersQuery.data?.providers]);\n\n const currentUserQuery = useCurrentUser();\n const callerAuthorId = currentUserQuery.data?.id;\n const callerReady = !scopeToSelf || currentUserQuery.isSuccess || isUnauthenticatedError(currentUserQuery.error);\n\n // 1. For every provider, list its toolkits.\n const toolkitsQueries = useQueries({\n queries: providers.map(provider => ({\n queryKey: ['tool-integration-services', provider.id],\n queryFn: () => client.getToolProvider(provider.id).listToolkits(),\n ...queryOptions?.toolkits,\n })),\n });\n\n // 2. Flatten to (providerId, toolkit) pairs.\n const pairs = useMemo(() => {\n const out: Array<{ providerId: string; toolkit: string }> = [];\n providers.forEach((provider, idx) => {\n const toolkits = toolkitsQueries[idx]?.data?.data ?? [];\n for (const toolkit of toolkits) {\n out.push({ providerId: provider.id, toolkit: toolkit.slug });\n }\n });\n return out;\n }, [providers, toolkitsQueries]);\n\n // 3. One listConnections call per pair. Include `authorId` in queryKey when\n // self-scoped so the cache is distinct from any unscoped admin reads.\n const connectionsQueries = useQueries({\n queries: pairs.map(pair => ({\n queryKey: scopeToSelf\n ? ['tool-integration-connections-all', pair.providerId, pair.toolkit, callerAuthorId]\n : ['tool-integration-connections-all', pair.providerId, pair.toolkit],\n queryFn: () =>\n client.getToolProvider(pair.providerId).listConnections({\n toolkit: pair.toolkit,\n ...(scopeToSelf && callerAuthorId ? { authorId: callerAuthorId } : {}),\n }),\n enabled: callerReady,\n staleTime: STALE_TIME_MS,\n ...queryOptions?.connections,\n })),\n });\n\n const isLoading =\n providersQuery.isLoading ||\n (scopeToSelf && currentUserQuery.isLoading) ||\n toolkitsQueries.some(q => q.isLoading) ||\n connectionsQueries.some(q => q.isLoading);\n\n // Build a per-pair list of connection summaries so callers can both gate\n // (\"does this row have any connection?\") and auto-pin (\"if exactly one\n // exists, write it into the form on toggle-on\").\n const connectionsByKey = useMemo(() => {\n const map = new Map<string, Array<{ connectionId: string; label?: string | null; status?: string }>>();\n pairs.forEach((pair, idx) => {\n const items = connectionsQueries[idx]?.data?.items ?? [];\n map.set(`${pair.providerId}:${pair.toolkit}`, items);\n });\n return map;\n }, [pairs, connectionsQueries]);\n\n // A toolkit \"has a connection\" only when at least one connection is active.\n // Pending/failed rows don't count — this keeps the card hint in sync with the\n // toolkit row control, which also treats only active connections as usable.\n const hasConnection = useCallback(\n (providerId: string, toolkit: string) =>\n (connectionsByKey.get(`${providerId}:${toolkit}`) ?? []).some(connection => connection.status === 'active'),\n [connectionsByKey],\n );\n\n const getConnections = useCallback(\n (providerId: string, toolkit: string) => connectionsByKey.get(`${providerId}:${toolkit}`) ?? [],\n [connectionsByKey],\n );\n\n return { hasConnection, getConnections, isLoading };\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { useQueries } from '@tanstack/react-query';\nimport { useMemo } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nimport { useToolProviders } from './use-tool-providers';\n\nexport interface AvailableIntegrationTool {\n providerId: string;\n slug: string;\n toolkit: string;\n name?: string;\n description?: string;\n}\n\n/**\n * Upper bound for a single Composio-style `listTools` call. Composio's SDK has\n * no cursor — only `limit` — so we ask for a large page and fan out per\n * `toolkit` to avoid being truncated when many toolkits are allowlisted.\n */\nconst PER_SERVICE_LIMIT = 500;\n\n/**\n * Returns every tool surfaced by every registered ToolProvider, scoped to\n * the provider's `allowedToolkits`/`allowedTools` filter (enforced\n * server-side). Used to render the full available-tools list inline.\n */\nexport const useAllProviderTools = ({\n queryOptions,\n}: {\n /** TanStack overrides applied to every fanned-out query, spread last. `select` must keep the default shape. */\n queryOptions?: {\n toolkits?: MastraQueryOptions<Awaited<ReturnType<ReturnType<MastraClient['getToolProvider']>['listToolkits']>>>;\n tools?: MastraQueryOptions<Awaited<ReturnType<ReturnType<MastraClient['getToolProvider']>['listTools']>>>;\n };\n} = {}) => {\n const client = useMastraClient();\n const integrationsQuery = useToolProviders();\n const integrations = useMemo(() => integrationsQuery.data?.providers ?? [], [integrationsQuery.data?.providers]);\n\n // 1. For every integration, fetch its tool services.\n const serviceQueries = useQueries({\n queries: integrations.map(integration => ({\n queryKey: ['tool-integration-services', integration.id],\n queryFn: () => client.getToolProvider(integration.id).listToolkits(),\n ...queryOptions?.toolkits,\n })),\n });\n\n // 2. Flatten to (providerId, serviceSlug) pairs.\n const servicePairs = useMemo(() => {\n const pairs: Array<{ providerId: string; toolkit: string }> = [];\n integrations.forEach((integration, idx) => {\n const services = serviceQueries[idx]?.data?.data ?? [];\n for (const service of services) {\n pairs.push({ providerId: integration.id, toolkit: service.slug });\n }\n });\n return pairs;\n }, [integrations, serviceQueries]);\n\n // 3. Fan out one tools query per (integration, service).\n const toolsQueries = useQueries({\n queries: servicePairs.map(pair => ({\n queryKey: ['tool-integration-tools-all', pair.providerId, pair.toolkit],\n queryFn: () =>\n client.getToolProvider(pair.providerId).listTools({ toolkit: pair.toolkit, perPage: PER_SERVICE_LIMIT }),\n ...queryOptions?.tools,\n })),\n });\n\n const isLoading =\n integrationsQuery.isLoading || serviceQueries.some(q => q.isLoading) || toolsQueries.some(q => q.isLoading);\n\n const tools = useMemo<AvailableIntegrationTool[]>(() => {\n const out: AvailableIntegrationTool[] = [];\n servicePairs.forEach((pair, idx) => {\n const items = toolsQueries[idx]?.data?.data ?? [];\n for (const item of items) {\n const toolkit = (item as { toolkit?: string }).toolkit ?? pair.toolkit;\n out.push({\n providerId: pair.providerId,\n slug: item.slug,\n toolkit,\n name: (item as { name?: string }).name,\n description: (item as { description?: string }).description,\n });\n }\n });\n return out;\n }, [servicePairs, toolsQueries]);\n\n return { tools, isLoading };\n};\n","import { useMutation } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\nexport interface AuthorizeArgs {\n providerId: string;\n toolkit: string;\n /**\n * Existing bucket id when re-authorizing; omit for a brand-new connection.\n * Semantics are provider-opaque; for Composio v1 this is the internal user\n * bucket the new connected account should be created under.\n */\n connectionId?: string;\n /**\n * Provider-specific connection fields collected from the picker (e.g.\n * Confluence subdomain). Forwarded to the server's `authorize` body.\n */\n config?: Record<string, unknown>;\n /**\n * Optional human label to persist on the resulting `tool_integration_connections` row.\n */\n label?: string | null;\n /**\n * Ownership scope of the OAuth bucket. `'per-author'` (default) buckets\n * under the caller's authorId.\n */\n scope?: 'per-author' | 'shared' | 'caller-supplied';\n}\n\nexport interface AuthorizeResult {\n status: 'completed' | 'failed';\n /**\n * The `authId` returned by `authorize`, exposed as `connectionId` because\n * for the v1 Composio adapter it is the `connected_account.id` that the\n * caller persists as `Connection.connectionId`.\n */\n connectionId: string;\n}\n\nconst DEFAULT_POLL_INTERVAL_MS = 2000;\nconst DEFAULT_TIMEOUT_MS = 5 * 60_000;\n\nexport interface UseAuthorizeOptions {\n pollIntervalMs?: number;\n timeoutMs?: number;\n openPopup?: (url: string) => Window | null;\n queryOptions?: MastraMutationOptions<AuthorizeResult, AuthorizeArgs>;\n}\n\n/**\n * Drives the OAuth popup + polling loop for a `ToolProvider` provider.\n */\nexport const useAuthorize = (options: UseAuthorizeOptions = {}) => {\n const client = useMastraClient();\n const pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const openPopup = options.openPopup ?? ((url: string) => window.open(url, '_blank', 'popup,width=600,height=700'));\n\n return useMutation<AuthorizeResult, Error, AuthorizeArgs>({\n mutationFn: async ({ providerId, toolkit, connectionId, config, label, scope }) => {\n const integration = client.getToolProvider(providerId);\n const normalizedConnectionId = connectionId?.trim();\n const { url, authId } = await integration.authorize({\n toolkit,\n ...(normalizedConnectionId ? { connectionId: normalizedConnectionId } : {}),\n ...(config ? { config } : {}),\n ...(label !== undefined ? { label } : {}),\n ...(scope ? { scope } : {}),\n });\n\n const popup = openPopup(url);\n if (!popup) {\n throw new Error('Popup blocked. Please allow popups for this site.');\n }\n\n const start = Date.now();\n while (Date.now() - start < timeoutMs) {\n await new Promise(resolve => setTimeout(resolve, pollIntervalMs));\n const { status } = await integration.getAuthStatus(authId);\n if (status === 'completed' || status === 'failed') {\n try {\n popup.close();\n } catch {\n // Cross-origin popups may refuse close(); ignore.\n }\n return { status, connectionId: authId };\n }\n }\n\n try {\n popup.close();\n } catch {\n // ignore\n }\n throw new Error('Authorization timed out');\n },\n ...options.queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\nexport interface DisconnectConnectionArgs {\n providerId: string;\n connectionId: string;\n /**\n * When `true`, the server skips the usage check and revokes the\n * connection at the provider before deleting the local row.\n */\n force?: boolean;\n}\n\n/**\n * Calls the provider-side revoke (best-effort) and drops the local\n * `tool_integration_connections` row. Server enforces the soft-vs-force rule.\n */\ntype DisconnectConnectionResponse = Awaited<\n ReturnType<ReturnType<MastraClient['getToolProvider']>['disconnectConnection']>\n>;\n\nexport const useDisconnectConnection = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<DisconnectConnectionResponse, DisconnectConnectionArgs> } = {}) => {\n const client = useMastraClient();\n const qc = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ providerId, connectionId, force }: DisconnectConnectionArgs) => {\n const integration = client.getToolProvider(providerId);\n return integration.disconnectConnection(connectionId, force ? { force } : undefined);\n },\n onSuccess: (_data, vars) => {\n void qc.invalidateQueries({ queryKey: ['tool-integration-connections', vars.providerId] });\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { isUnauthenticatedError, useCurrentUser } from '../auth';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nexport interface UseExistingConnectionsOptions {\n /**\n * When `true`, the hook forces the server-side `authorId` filter to the\n * caller's own userId. Builder edit view passes `scopeToSelf: true` so\n * admins see only their own connections, never other authors' rows.\n *\n * Non-admin callers see the same result either way — the server already\n * scopes to the caller's bucket — but the explicit filter keeps caches\n * consistent and prevents admin cross-author leakage in the picker.\n */\n scopeToSelf?: boolean;\n}\n\ntype ConnectionsResponse = Awaited<ReturnType<ReturnType<MastraClient['getToolProvider']>['listConnections']>>;\n\n/**\n * Lists existing provider connections for the caller, scoped to a tool\n * service. Powers the \"use existing connection\" path in the picker so\n * authors can pin previously-authorized accounts without re-running OAuth.\n *\n * The connection owner is resolved server-side from the request's auth\n * context. Admin callers receive cross-author rows by default; pass\n * `scopeToSelf: true` to narrow the response to the caller's own bucket\n * (used by the Builder edit view).\n */\nexport const useExistingConnections = <TData = ConnectionsResponse>({\n providerId,\n toolkit,\n scopeToSelf = false,\n queryOptions,\n}: UseExistingConnectionsOptions & {\n providerId: string | null | undefined;\n toolkit: string | null | undefined;\n queryOptions?: MastraQueryOptions<ConnectionsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n const currentUserQuery = useCurrentUser();\n const callerAuthorId = currentUserQuery.data?.id;\n\n const callerReady = !scopeToSelf || currentUserQuery.isSuccess || isUnauthenticatedError(currentUserQuery.error);\n\n const enabled = !!providerId && !!toolkit && callerReady;\n\n return useQuery({\n queryKey: scopeToSelf\n ? ['tool-integration-connections', providerId, toolkit, callerAuthorId]\n : ['tool-integration-connections', providerId, toolkit],\n queryFn: () =>\n client.getToolProvider(providerId!).listConnections({\n toolkit: toolkit!,\n ...(scopeToSelf && callerAuthorId ? { authorId: callerAuthorId } : {}),\n }),\n enabled,\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype ProviderToolsResponse = Awaited<ReturnType<ReturnType<MastraClient['getToolProvider']>['listTools']>>;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useProviderTools = <TData = ProviderToolsResponse>({\n providerId,\n params,\n queryOptions,\n}: {\n providerId: string | null;\n params?: { toolkit?: string; search?: string };\n queryOptions?: MastraQueryOptions<ProviderToolsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['tool-provider-tools', providerId, params?.toolkit, params?.search],\n queryFn: () => client.getToolProvider(providerId!).listTools(params),\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype ToolkitsResponse = Awaited<ReturnType<ReturnType<MastraClient['getToolProvider']>['listToolkits']>>;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useToolkits = <TData = ToolkitsResponse>({\n providerId,\n queryOptions,\n}: {\n providerId: string | null;\n queryOptions?: MastraQueryOptions<ToolkitsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['tool-provider-toolkits', providerId],\n queryFn: () => client.getToolProvider(providerId!).listToolkits(),\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\nexport interface UpdateConnectionArgs {\n providerId: string;\n connectionId: string;\n /**\n * New display label. Pass `null` (or an empty string) to clear the label.\n */\n label: string | null;\n}\n\n/**\n * Renames a `tool_provider_connections` row in place. Server enforces\n * ownership (owner / admin / shared scope). On success, invalidates both\n * the per-toolkit and the fan-out connection lists so the picker re-fetches.\n */\ntype UpdateConnectionResponse = Awaited<ReturnType<ReturnType<MastraClient['getToolProvider']>['updateConnection']>>;\n\nexport const useUpdateConnection = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<UpdateConnectionResponse, UpdateConnectionArgs> } = {}) => {\n const client = useMastraClient();\n const qc = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ providerId, connectionId, label }: UpdateConnectionArgs) => {\n const integration = client.getToolProvider(providerId);\n return integration.updateConnection(connectionId, { label });\n },\n onSuccess: (_data, vars) => {\n void qc.invalidateQueries({ queryKey: ['tool-integration-connections', vars.providerId] });\n void qc.invalidateQueries({ queryKey: ['tool-integration-connections-all', vars.providerId] });\n },\n ...queryOptions,\n });\n};\n"],"mappings":";;;;;;AAQA,MAAa,oBAAmD,EAC9D,iBACuE,CAAC,MAAoC;CAC5G,MAAM,SAASA,8BAAAA,gBAAgB;CAE/B,QAAA,GAAOC,sBAAAA,SAAAA,CAAS;EACd,UAAU,CAAC,gBAAgB;EAC3B,eAAe,OAAO,kBAAkB;EACxC,GAAG;CACL,CAAC;AACH;AAWA,MAAa,0BAA0B,EACrC,iBAC4D,CAAC,MAAM;CACnE,MAAM,SAASD,8BAAAA,gBAAgB;CAC/B,MAAM,EAAE,MAAM,eAAe,WAAW,uBAAuB,iBAAiB;CAChF,MAAM,YAAY,eAAe,aAAa,CAAC;CAE/C,MAAM,cAAA,GAAaC,sBAAAA,SAAAA,CAAS;EAC1B,UAAU,CAAC,yBAAyB,UAAU,KAAI,MAAK,EAAE,EAAE,CAAC;EAC5D,SAAS,YAAY;GACnB,MAAM,UAA6B,CAAC;GAEpC,KAAK,MAAM,YAAY,WAAW;IAChC,MAAM,WAAW,MAAM,OAAO,gBAAgB,SAAS,EAA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C,CAAC,WAAW;EAY3C,GAAG;CACL,CAAC;AACH;;;;;;ACnDA,MAAa,oBAAmD,EAC9D,YACA,QACA,mBAKkC;CAClC,MAAM,SAASC,8BAAAA,gBAAgB;CAE/B,QAAA,GAAOC,sBAAAA,SAAAA,CAAS;EACd,UAAU;GAAC;GAAuB;GAAY,QAAQ;GAAS,QAAQ;EAAM;EAC7E,eAAe,OAAO,gBAAgB,UAAW,CAAC,CAAC,UAAU,MAAM;EACnE,GAAG;CACL,CAAC;AACH;;;;;;AChBA,MAAa,eAAyC,EACpD,YACA,mBAIkC;CAClC,MAAM,SAASC,8BAAAA,gBAAgB;CAE/B,QAAA,GAAOC,sBAAAA,SAAAA,CAAS;EACd,UAAU,CAAC,0BAA0B,UAAU;EAC/C,eAAe,OAAO,gBAAgB,UAAW,CAAC,CAAC,aAAa;EAChE,GAAG;CACL,CAAC;AACH;;;ACJA,MAAa,uBAAuB,EAClC,iBAC4F,CAAC,MAAM;CACnG,MAAM,SAASC,8BAAAA,gBAAgB;CAC/B,MAAM,MAAA,GAAKC,sBAAAA,eAAAA,CAAe;CAE1B,QAAA,GAAOC,sBAAAA,YAAAA,CAAY;EACjB,YAAY,OAAO,EAAE,YAAY,cAAc,YAAkC;GAE/E,OADoB,OAAO,gBAAgB,UAC1B,CAAC,CAAC,iBAAiB,cAAc,EAAE,MAAM,CAAC;EAC7D;EACA,YAAY,OAAO,SAAS;GAC1B,GAAQ,kBAAkB,EAAE,UAAU,CAAC,gCAAgC,KAAK,UAAU,EAAE,CAAC;GACzF,GAAQ,kBAAkB,EAAE,UAAU,CAAC,oCAAoC,KAAK,UAAU,EAAE,CAAC;EAC/F;EACA,GAAG;CACL,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useMastraClient","useQuery","useMastraClient","useMemo","useCurrentUser","isUnauthenticatedError","useQueries","useCallback","useMastraClient","useMemo","useQueries","useMastraClient","useMutation","useMastraClient","useQueryClient","useMutation","useMastraClient","useCurrentUser","isUnauthenticatedError","useQuery","useMastraClient","useQuery","useMastraClient","useQuery","useMastraClient","useQueryClient","useMutation"],"sources":["../../../src/hooks/tool-providers/use-tool-providers.ts","../../../src/hooks/tool-providers/use-all-connections.ts","../../../src/hooks/tool-providers/use-all-provider-tools.ts","../../../src/hooks/tool-providers/use-authorize.ts","../../../src/hooks/tool-providers/use-disconnect-connection.ts","../../../src/hooks/tool-providers/use-existing-connections.ts","../../../src/hooks/tool-providers/use-provider-tools.ts","../../../src/hooks/tool-providers/use-toolkits.ts","../../../src/hooks/tool-providers/use-update-connection.ts"],"sourcesContent":["import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype ToolProvidersResponse = Awaited<ReturnType<MastraClient['listToolProviders']>>;\n\nexport const useToolProviders = <TData = ToolProvidersResponse>({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<ToolProvidersResponse, TData> } = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['tool-providers'],\n queryFn: () => client.listToolProviders(),\n ...queryOptions,\n });\n};\n\nexport interface IntegrationTool {\n slug: string;\n name: string;\n description?: string;\n toolkit?: string;\n providerId: string;\n providerName: string;\n}\n\nexport const useAllIntegrationTools = ({\n queryOptions,\n}: { queryOptions?: MastraQueryOptions<IntegrationTool[]> } = {}) => {\n const client = useMastraClient();\n const { data: providersData, isLoading: isLoadingProviders } = useToolProviders();\n const providers = providersData?.providers ?? [];\n\n const toolsQuery = useQuery({\n queryKey: ['integration-tools-all', providers.map(p => p.id)],\n queryFn: async () => {\n const results: IntegrationTool[] = [];\n\n for (const provider of providers) {\n const response = await client.getToolProvider(provider.id).listTools();\n for (const tool of response.data) {\n results.push({\n ...tool,\n providerId: provider.id,\n providerName: provider.name,\n });\n }\n }\n\n return results;\n },\n enabled: providers.length > 0,\n ...queryOptions,\n });\n\n return {\n data: toolsQuery.data ?? [],\n isLoading: isLoadingProviders || toolsQuery.isLoading,\n };\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { useQueries } from '@tanstack/react-query';\nimport { useCallback, useMemo } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { isUnauthenticatedError, useCurrentUser } from '../auth';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nimport { useToolProviders } from './use-tool-providers';\n\n/**\n * Stale time long enough to avoid refetching on every picker re-render but\n * short enough that an OAuth completion in a sibling tab is reflected\n * promptly (React Query also re-fetches on window focus by default).\n */\nconst STALE_TIME_MS = 30_000;\n\nexport interface UseAllConnectionsOptions {\n /**\n * When `true`, the hook forces the server-side `authorId` filter to the\n * caller's own userId. Builder edit view passes `scopeToSelf: true` so\n * admins see only their own connections, never other authors' rows.\n *\n * Non-admin callers see the same result either way — the server already\n * scopes to the caller's bucket — but the explicit filter keeps caches\n * consistent and prevents admin cross-author leakage.\n */\n scopeToSelf?: boolean;\n /** TanStack overrides applied to every fanned-out query, spread last. `select` must keep the default shape. */\n queryOptions?: {\n toolkits?: MastraQueryOptions<Awaited<ReturnType<ReturnType<MastraClient['getToolProvider']>['listToolkits']>>>;\n connections?: MastraQueryOptions<\n Awaited<ReturnType<ReturnType<MastraClient['getToolProvider']>['listConnections']>>\n >;\n };\n}\n\n/**\n * Fans out across every registered ToolProvider and every toolkit it\n * exposes to determine whether the caller has an existing connection for a\n * given `(providerId, toolkit)` pair.\n *\n * Used by the Builder tool picker to gate integration tool rows: if the\n * pair has no connection, the card cannot be selected and surfaces an\n * inline \"Connect\" button instead.\n *\n * Distinct from `useExistingConnections` (per-pair, used by `/integrations`)\n * to keep their query caches independent.\n */\nexport const useAllConnections = ({ scopeToSelf = false, queryOptions }: UseAllConnectionsOptions = {}) => {\n const client = useMastraClient();\n const providersQuery = useToolProviders();\n const providers = useMemo(() => providersQuery.data?.providers ?? [], [providersQuery.data?.providers]);\n\n const currentUserQuery = useCurrentUser();\n const callerAuthorId = currentUserQuery.data?.id;\n const callerReady = !scopeToSelf || currentUserQuery.isSuccess || isUnauthenticatedError(currentUserQuery.error);\n\n // 1. For every provider, list its toolkits.\n const toolkitsQueries = useQueries({\n queries: providers.map(provider => ({\n queryKey: ['tool-integration-services', provider.id],\n queryFn: () => client.getToolProvider(provider.id).listToolkits(),\n ...queryOptions?.toolkits,\n })),\n });\n\n // 2. Flatten to (providerId, toolkit) pairs.\n const pairs = useMemo(() => {\n const out: Array<{ providerId: string; toolkit: string }> = [];\n providers.forEach((provider, idx) => {\n const toolkits = toolkitsQueries[idx]?.data?.data ?? [];\n for (const toolkit of toolkits) {\n out.push({ providerId: provider.id, toolkit: toolkit.slug });\n }\n });\n return out;\n }, [providers, toolkitsQueries]);\n\n // 3. One listConnections call per pair. Include `authorId` in queryKey when\n // self-scoped so the cache is distinct from any unscoped admin reads.\n const connectionsQueries = useQueries({\n queries: pairs.map(pair => ({\n queryKey: scopeToSelf\n ? ['tool-integration-connections-all', pair.providerId, pair.toolkit, callerAuthorId]\n : ['tool-integration-connections-all', pair.providerId, pair.toolkit],\n queryFn: () =>\n client.getToolProvider(pair.providerId).listConnections({\n toolkit: pair.toolkit,\n ...(scopeToSelf && callerAuthorId ? { authorId: callerAuthorId } : {}),\n }),\n enabled: callerReady,\n staleTime: STALE_TIME_MS,\n ...queryOptions?.connections,\n })),\n });\n\n const isLoading =\n providersQuery.isLoading ||\n (scopeToSelf && currentUserQuery.isLoading) ||\n toolkitsQueries.some(q => q.isLoading) ||\n connectionsQueries.some(q => q.isLoading);\n\n // Build a per-pair list of connection summaries so callers can both gate\n // (\"does this row have any connection?\") and auto-pin (\"if exactly one\n // exists, write it into the form on toggle-on\").\n const connectionsByKey = useMemo(() => {\n const map = new Map<string, Array<{ connectionId: string; label?: string | null; status?: string }>>();\n pairs.forEach((pair, idx) => {\n const items = connectionsQueries[idx]?.data?.items ?? [];\n map.set(`${pair.providerId}:${pair.toolkit}`, items);\n });\n return map;\n }, [pairs, connectionsQueries]);\n\n // A toolkit \"has a connection\" only when at least one connection is active.\n // Pending/failed rows don't count — this keeps the card hint in sync with the\n // toolkit row control, which also treats only active connections as usable.\n const hasConnection = useCallback(\n (providerId: string, toolkit: string) =>\n (connectionsByKey.get(`${providerId}:${toolkit}`) ?? []).some(connection => connection.status === 'active'),\n [connectionsByKey],\n );\n\n const getConnections = useCallback(\n (providerId: string, toolkit: string) => connectionsByKey.get(`${providerId}:${toolkit}`) ?? [],\n [connectionsByKey],\n );\n\n return { hasConnection, getConnections, isLoading };\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { useQueries } from '@tanstack/react-query';\nimport { useMemo } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nimport { useToolProviders } from './use-tool-providers';\n\nexport interface AvailableIntegrationTool {\n providerId: string;\n slug: string;\n toolkit: string;\n name?: string;\n description?: string;\n}\n\n/**\n * Upper bound for a single Composio-style `listTools` call. Composio's SDK has\n * no cursor — only `limit` — so we ask for a large page and fan out per\n * `toolkit` to avoid being truncated when many toolkits are allowlisted.\n */\nconst PER_SERVICE_LIMIT = 500;\n\n/**\n * Returns every tool surfaced by every registered ToolProvider, scoped to\n * the provider's `allowedToolkits`/`allowedTools` filter (enforced\n * server-side). Used to render the full available-tools list inline.\n */\nexport const useAllProviderTools = ({\n queryOptions,\n}: {\n /** TanStack overrides applied to every fanned-out query, spread last. `select` must keep the default shape. */\n queryOptions?: {\n toolkits?: MastraQueryOptions<Awaited<ReturnType<ReturnType<MastraClient['getToolProvider']>['listToolkits']>>>;\n tools?: MastraQueryOptions<Awaited<ReturnType<ReturnType<MastraClient['getToolProvider']>['listTools']>>>;\n };\n} = {}) => {\n const client = useMastraClient();\n const integrationsQuery = useToolProviders();\n const integrations = useMemo(() => integrationsQuery.data?.providers ?? [], [integrationsQuery.data?.providers]);\n\n // 1. For every integration, fetch its tool services.\n const serviceQueries = useQueries({\n queries: integrations.map(integration => ({\n queryKey: ['tool-integration-services', integration.id],\n queryFn: () => client.getToolProvider(integration.id).listToolkits(),\n ...queryOptions?.toolkits,\n })),\n });\n\n // 2. Flatten to (providerId, serviceSlug) pairs.\n const servicePairs = useMemo(() => {\n const pairs: Array<{ providerId: string; toolkit: string }> = [];\n integrations.forEach((integration, idx) => {\n const services = serviceQueries[idx]?.data?.data ?? [];\n for (const service of services) {\n pairs.push({ providerId: integration.id, toolkit: service.slug });\n }\n });\n return pairs;\n }, [integrations, serviceQueries]);\n\n // 3. Fan out one tools query per (integration, service).\n const toolsQueries = useQueries({\n queries: servicePairs.map(pair => ({\n queryKey: ['tool-integration-tools-all', pair.providerId, pair.toolkit],\n queryFn: () =>\n client.getToolProvider(pair.providerId).listTools({ toolkit: pair.toolkit, perPage: PER_SERVICE_LIMIT }),\n ...queryOptions?.tools,\n })),\n });\n\n const isLoading =\n integrationsQuery.isLoading || serviceQueries.some(q => q.isLoading) || toolsQueries.some(q => q.isLoading);\n\n const tools = useMemo<AvailableIntegrationTool[]>(() => {\n const out: AvailableIntegrationTool[] = [];\n servicePairs.forEach((pair, idx) => {\n const items = toolsQueries[idx]?.data?.data ?? [];\n for (const item of items) {\n const toolkit = (item as { toolkit?: string }).toolkit ?? pair.toolkit;\n out.push({\n providerId: pair.providerId,\n slug: item.slug,\n toolkit,\n name: (item as { name?: string }).name,\n description: (item as { description?: string }).description,\n });\n }\n });\n return out;\n }, [servicePairs, toolsQueries]);\n\n return { tools, isLoading };\n};\n","import { useMutation } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\nexport interface AuthorizeArgs {\n providerId: string;\n toolkit: string;\n /**\n * Existing bucket id when re-authorizing; omit for a brand-new connection.\n * Semantics are provider-opaque; for Composio v1 this is the internal user\n * bucket the new connected account should be created under.\n */\n connectionId?: string;\n /**\n * Provider-specific connection fields collected from the picker (e.g.\n * Confluence subdomain). Forwarded to the server's `authorize` body.\n */\n config?: Record<string, unknown>;\n /**\n * Optional human label to persist on the resulting `tool_integration_connections` row.\n */\n label?: string | null;\n /**\n * Ownership scope of the OAuth bucket. `'per-author'` (default) buckets\n * under the caller's authorId.\n */\n scope?: 'per-author' | 'shared' | 'caller-supplied';\n}\n\nexport interface AuthorizeResult {\n status: 'completed' | 'failed';\n /**\n * The `authId` returned by `authorize`, exposed as `connectionId` because\n * for the v1 Composio adapter it is the `connected_account.id` that the\n * caller persists as `Connection.connectionId`.\n */\n connectionId: string;\n}\n\nconst DEFAULT_POLL_INTERVAL_MS = 2000;\nconst DEFAULT_TIMEOUT_MS = 5 * 60_000;\n\nexport interface UseAuthorizeOptions {\n pollIntervalMs?: number;\n timeoutMs?: number;\n openPopup?: (url: string) => Window | null;\n queryOptions?: MastraMutationOptions<AuthorizeResult, AuthorizeArgs>;\n}\n\n/**\n * Drives the OAuth popup + polling loop for a `ToolProvider` provider.\n */\nexport const useAuthorize = (options: UseAuthorizeOptions = {}) => {\n const client = useMastraClient();\n const pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const openPopup = options.openPopup ?? ((url: string) => window.open(url, '_blank', 'popup,width=600,height=700'));\n\n return useMutation<AuthorizeResult, Error, AuthorizeArgs>({\n mutationFn: async ({ providerId, toolkit, connectionId, config, label, scope }) => {\n const integration = client.getToolProvider(providerId);\n const normalizedConnectionId = connectionId?.trim();\n const { url, authId } = await integration.authorize({\n toolkit,\n ...(normalizedConnectionId ? { connectionId: normalizedConnectionId } : {}),\n ...(config ? { config } : {}),\n ...(label !== undefined ? { label } : {}),\n ...(scope ? { scope } : {}),\n });\n\n const popup = openPopup(url);\n if (!popup) {\n throw new Error('Popup blocked. Please allow popups for this site.');\n }\n\n const start = Date.now();\n while (Date.now() - start < timeoutMs) {\n await new Promise(resolve => setTimeout(resolve, pollIntervalMs));\n const { status } = await integration.getAuthStatus(authId);\n if (status === 'completed' || status === 'failed') {\n try {\n popup.close();\n } catch {\n // Cross-origin popups may refuse close(); ignore.\n }\n return { status, connectionId: authId };\n }\n }\n\n try {\n popup.close();\n } catch {\n // ignore\n }\n throw new Error('Authorization timed out');\n },\n ...options.queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\nexport interface DisconnectConnectionArgs {\n providerId: string;\n connectionId: string;\n /**\n * When `true`, the server skips the usage check and revokes the\n * connection at the provider before deleting the local row.\n */\n force?: boolean;\n}\n\n/**\n * Calls the provider-side revoke (best-effort) and drops the local\n * `tool_integration_connections` row. Server enforces the soft-vs-force rule.\n */\ntype DisconnectConnectionResponse = Awaited<\n ReturnType<ReturnType<MastraClient['getToolProvider']>['disconnectConnection']>\n>;\n\nexport const useDisconnectConnection = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<DisconnectConnectionResponse, DisconnectConnectionArgs> } = {}) => {\n const client = useMastraClient();\n const qc = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ providerId, connectionId, force }: DisconnectConnectionArgs) => {\n const integration = client.getToolProvider(providerId);\n return integration.disconnectConnection(connectionId, force ? { force } : undefined);\n },\n onSuccess: (_data, vars) => {\n void qc.invalidateQueries({ queryKey: ['tool-integration-connections', vars.providerId] });\n },\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { isUnauthenticatedError, useCurrentUser } from '../auth';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\nexport interface UseExistingConnectionsOptions {\n /**\n * When `true`, the hook forces the server-side `authorId` filter to the\n * caller's own userId. Builder edit view passes `scopeToSelf: true` so\n * admins see only their own connections, never other authors' rows.\n *\n * Non-admin callers see the same result either way — the server already\n * scopes to the caller's bucket — but the explicit filter keeps caches\n * consistent and prevents admin cross-author leakage in the picker.\n */\n scopeToSelf?: boolean;\n}\n\ntype ConnectionsResponse = Awaited<ReturnType<ReturnType<MastraClient['getToolProvider']>['listConnections']>>;\n\n/**\n * Lists existing provider connections for the caller, scoped to a tool\n * service. Powers the \"use existing connection\" path in the picker so\n * authors can pin previously-authorized accounts without re-running OAuth.\n *\n * The connection owner is resolved server-side from the request's auth\n * context. Admin callers receive cross-author rows by default; pass\n * `scopeToSelf: true` to narrow the response to the caller's own bucket\n * (used by the Builder edit view).\n */\nexport const useExistingConnections = <TData = ConnectionsResponse>({\n providerId,\n toolkit,\n scopeToSelf = false,\n queryOptions,\n}: UseExistingConnectionsOptions & {\n providerId: string | null | undefined;\n toolkit: string | null | undefined;\n queryOptions?: MastraQueryOptions<ConnectionsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n const currentUserQuery = useCurrentUser();\n const callerAuthorId = currentUserQuery.data?.id;\n\n const callerReady = !scopeToSelf || currentUserQuery.isSuccess || isUnauthenticatedError(currentUserQuery.error);\n\n const enabled = !!providerId && !!toolkit && callerReady;\n\n return useQuery({\n queryKey: scopeToSelf\n ? ['tool-integration-connections', providerId, toolkit, callerAuthorId]\n : ['tool-integration-connections', providerId, toolkit],\n queryFn: () =>\n client.getToolProvider(providerId!).listConnections({\n toolkit: toolkit!,\n ...(scopeToSelf && callerAuthorId ? { authorId: callerAuthorId } : {}),\n }),\n enabled,\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype ProviderToolsResponse = Awaited<ReturnType<ReturnType<MastraClient['getToolProvider']>['listTools']>>;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useProviderTools = <TData = ProviderToolsResponse>({\n providerId,\n params,\n queryOptions,\n}: {\n providerId: string | null;\n params?: { toolkit?: string; search?: string };\n queryOptions?: MastraQueryOptions<ProviderToolsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['tool-provider-tools', providerId, params?.toolkit, params?.search],\n queryFn: () => client.getToolProvider(providerId!).listTools(params),\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useQuery } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraQueryOptions } from '../shared/query-options';\n\ntype ToolkitsResponse = Awaited<ReturnType<ReturnType<MastraClient['getToolProvider']>['listToolkits']>>;\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useToolkits = <TData = ToolkitsResponse>({\n providerId,\n queryOptions,\n}: {\n providerId: string | null;\n queryOptions?: MastraQueryOptions<ToolkitsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['tool-provider-toolkits', providerId],\n queryFn: () => client.getToolProvider(providerId!).listToolkits(),\n ...queryOptions,\n });\n};\n","import type { MastraClient } from '@mastra/client-js';\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraMutationOptions } from '../shared/query-options';\n\nexport interface UpdateConnectionArgs {\n providerId: string;\n connectionId: string;\n /**\n * New display label. Pass `null` (or an empty string) to clear the label.\n */\n label: string | null;\n}\n\n/**\n * Renames a `tool_provider_connections` row in place. Server enforces\n * ownership (owner / admin / shared scope). On success, invalidates both\n * the per-toolkit and the fan-out connection lists so the picker re-fetches.\n */\ntype UpdateConnectionResponse = Awaited<ReturnType<ReturnType<MastraClient['getToolProvider']>['updateConnection']>>;\n\nexport const useUpdateConnection = ({\n queryOptions,\n}: { queryOptions?: MastraMutationOptions<UpdateConnectionResponse, UpdateConnectionArgs> } = {}) => {\n const client = useMastraClient();\n const qc = useQueryClient();\n\n return useMutation({\n mutationFn: async ({ providerId, connectionId, label }: UpdateConnectionArgs) => {\n const integration = client.getToolProvider(providerId);\n return integration.updateConnection(connectionId, { label });\n },\n onSuccess: (_data, vars) => {\n void qc.invalidateQueries({ queryKey: ['tool-integration-connections', vars.providerId] });\n void qc.invalidateQueries({ queryKey: ['tool-integration-connections-all', vars.providerId] });\n },\n ...queryOptions,\n });\n};\n"],"mappings":";;;;;;AAQA,MAAa,oBAAmD,EAC9D,iBACuE,CAAC,MAAoC;CAC5G,MAAM,SAASA,8BAAAA,gBAAgB;CAE/B,QAAA,GAAOC,sBAAAA,SAAAA,CAAS;EACd,UAAU,CAAC,gBAAgB;EAC3B,eAAe,OAAO,kBAAkB;EACxC,GAAG;CACL,CAAC;AACH;AAWA,MAAa,0BAA0B,EACrC,iBAC4D,CAAC,MAAM;CACnE,MAAM,SAASD,8BAAAA,gBAAgB;CAC/B,MAAM,EAAE,MAAM,eAAe,WAAW,uBAAuB,iBAAiB;CAChF,MAAM,YAAY,eAAe,aAAa,CAAC;CAE/C,MAAM,cAAA,GAAaC,sBAAAA,SAAAA,CAAS;EAC1B,UAAU,CAAC,yBAAyB,UAAU,KAAI,MAAK,EAAE,EAAE,CAAC;EAC5D,SAAS,YAAY;GACnB,MAAM,UAA6B,CAAC;GAEpC,KAAK,MAAM,YAAY,WAAW;IAChC,MAAM,WAAW,MAAM,OAAO,gBAAgB,SAAS,EAAE,CAAC,CAAC,UAAU;IACrE,KAAK,MAAM,QAAQ,SAAS,MAC1B,QAAQ,KAAK;KACX,GAAG;KACH,YAAY,SAAS;KACrB,cAAc,SAAS;IACzB,CAAC;GAEL;GAEA,OAAO;EACT;EACA,SAAS,UAAU,SAAS;EAC5B,GAAG;CACL,CAAC;CAED,OAAO;EACL,MAAM,WAAW,QAAQ,CAAC;EAC1B,WAAW,sBAAsB,WAAW;CA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