@mastra/react 1.13.0-alpha.3 → 1.13.0-alpha.4
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 +28 -51
- package/dist/hooks/traces/index.cjs.map +1 -1
- package/dist/hooks/traces/index.js +28 -51
- package/dist/hooks/traces/index.js.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 +18 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useMastraClient","useQuery","useQueryClient","useMutation","useMastraClient","useQuery","useQueryClient","useMutation"],"sources":["../../../src/hooks/prompt-blocks/use-prompt-block-versions.ts","../../../src/hooks/prompt-blocks/use-stored-prompt-blocks.ts"],"sourcesContent":["import type {\n ListPromptBlockVersionsParams,\n CreatePromptBlockVersionParams,\n ListPromptBlockVersionsResponse,\n PromptBlockVersionResponse,\n ActivatePromptBlockVersionResponse,\n DeletePromptBlockVersionResponse,\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 { ListPromptBlockVersionsParams, CreatePromptBlockVersionParams };\n\n/**\n * Hook to list versions of a stored prompt block\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const usePromptBlockVersions = <TData = ListPromptBlockVersionsResponse>({\n blockId,\n params,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n params?: ListPromptBlockVersionsParams;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListPromptBlockVersionsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListPromptBlockVersionsResponse, Error, TData>({\n queryKey: ['prompt-block-versions', blockId, params, requestContext],\n queryFn: () => client.getStoredPromptBlock(blockId).listVersions(params, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to get a single version of a stored prompt block\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const usePromptBlockVersion = <TData = PromptBlockVersionResponse>({\n blockId,\n versionId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n versionId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<PromptBlockVersionResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<PromptBlockVersionResponse, Error, TData>({\n queryKey: ['prompt-block-version', blockId, versionId, requestContext],\n queryFn: () => client.getStoredPromptBlock(blockId).getVersion(versionId, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to create a new version of a stored prompt block\n */\nexport const useCreatePromptBlockVersion = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<PromptBlockVersionResponse, CreatePromptBlockVersionParams | undefined>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<PromptBlockVersionResponse, Error, CreatePromptBlockVersionParams | undefined>({\n mutationFn: (params?: CreatePromptBlockVersionParams) =>\n client.getStoredPromptBlock(blockId).createVersion(params, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to activate a specific version of a stored prompt block\n */\nexport const useActivatePromptBlockVersion = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ActivatePromptBlockVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ActivatePromptBlockVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredPromptBlock(blockId).activateVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to restore a specific version of a stored prompt block (creates a new version from an old one)\n */\nexport const useRestorePromptBlockVersion = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<PromptBlockVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<PromptBlockVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredPromptBlock(blockId).restoreVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to delete a specific version of a stored prompt block\n */\nexport const useDeletePromptBlockVersion = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<DeletePromptBlockVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<DeletePromptBlockVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredPromptBlock(blockId).deleteVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n },\n ...queryOptions,\n });\n};\n","import type {\n MastraClient,\n ListStoredPromptBlocksParams,\n ListStoredPromptBlocksResponse,\n StoredPromptBlockResponse,\n CreateStoredPromptBlockParams,\n UpdateStoredPromptBlockParams,\n} 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\nexport const useStoredPromptBlocks = <TData = ListStoredPromptBlocksResponse>({\n requestContext,\n queryOptions,\n ...params\n}: ListStoredPromptBlocksParams & {\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListStoredPromptBlocksResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListStoredPromptBlocksResponse, Error, TData>({\n queryKey: ['stored-prompt-blocks', params, requestContext],\n queryFn: () => client.listStoredPromptBlocks(params),\n placeholderData: (previousData: ListStoredPromptBlocksResponse | undefined) => previousData,\n ...queryOptions,\n });\n};\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useStoredPromptBlock = <TData = StoredPromptBlockResponse | null>({\n blockId,\n status,\n requestContext,\n queryOptions,\n}: {\n blockId?: string;\n status?: 'draft' | 'published';\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<StoredPromptBlockResponse | null, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<StoredPromptBlockResponse | null, Error, TData>({\n queryKey: ['stored-prompt-block', blockId, status, requestContext],\n queryFn: () => (blockId ? client.getStoredPromptBlock(blockId).details(requestContext, { status }) : null),\n ...queryOptions,\n });\n};\n\ntype DeleteStoredPromptBlockResponse = Awaited<ReturnType<ReturnType<MastraClient['getStoredPromptBlock']>['delete']>>;\n\nexport const useStoredPromptBlockMutations = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: {\n createStoredPromptBlock?: MastraMutationOptions<StoredPromptBlockResponse, CreateStoredPromptBlockParams>;\n updateStoredPromptBlock?: MastraMutationOptions<StoredPromptBlockResponse, UpdateStoredPromptBlockParams>;\n deleteStoredPromptBlock?: MastraMutationOptions<DeleteStoredPromptBlockResponse, void>;\n };\n} = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n const createMutation = useMutation({\n mutationFn: (params: CreateStoredPromptBlockParams) => client.createStoredPromptBlock(params),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-blocks'] });\n },\n ...queryOptions?.createStoredPromptBlock,\n });\n\n const updateMutation = useMutation({\n mutationFn: (params: UpdateStoredPromptBlockParams) => {\n if (!blockId) throw new Error('blockId is required for update');\n return client.getStoredPromptBlock(blockId).update(params, requestContext);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-blocks'] });\n if (blockId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n }\n },\n ...queryOptions?.updateStoredPromptBlock,\n });\n\n const deleteMutation = useMutation({\n mutationFn: () => {\n if (!blockId) throw new Error('blockId is required for delete');\n return client.getStoredPromptBlock(blockId).delete(requestContext);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-blocks'] });\n if (blockId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n }\n },\n ...queryOptions?.deleteStoredPromptBlock,\n });\n\n return {\n createStoredPromptBlock: createMutation,\n updateStoredPromptBlock: updateMutation,\n deleteStoredPromptBlock: deleteMutation,\n };\n};\n"],"mappings":";;;;;;;;;AAoBA,MAAa,0BAAmE,EAC9E,SACA,QACA,gBACA,mBAMkC;CAClC,MAAM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,CAAC,OAAO,cAAc;GACnE;GACA,iBAAiB;IACf,YAAiB,kBAAkB,EAAE,UAAU,CAAC,sBAAsB,EAAE,CAAC;IACzE,IAAI,SACF,YAAiB,kBAAkB,EAAE,UAAU,CAAC,uBAAuB,OAAO,EAAE,CAAC;GAErF;GACA,GAAG,cAAc;EACnB,CAKwC;CACxC;AACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useMastraClient","useQuery","useQueryClient","useMutation","useMastraClient","useQuery","useQueryClient","useMutation"],"sources":["../../../src/hooks/prompt-blocks/use-prompt-block-versions.ts","../../../src/hooks/prompt-blocks/use-stored-prompt-blocks.ts"],"sourcesContent":["import type {\n ListPromptBlockVersionsParams,\n CreatePromptBlockVersionParams,\n ListPromptBlockVersionsResponse,\n PromptBlockVersionResponse,\n ActivatePromptBlockVersionResponse,\n DeletePromptBlockVersionResponse,\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 { ListPromptBlockVersionsParams, CreatePromptBlockVersionParams };\n\n/**\n * Hook to list versions of a stored prompt block\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const usePromptBlockVersions = <TData = ListPromptBlockVersionsResponse>({\n blockId,\n params,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n params?: ListPromptBlockVersionsParams;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListPromptBlockVersionsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListPromptBlockVersionsResponse, Error, TData>({\n queryKey: ['prompt-block-versions', blockId, params, requestContext],\n queryFn: () => client.getStoredPromptBlock(blockId).listVersions(params, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to get a single version of a stored prompt block\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const usePromptBlockVersion = <TData = PromptBlockVersionResponse>({\n blockId,\n versionId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n versionId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<PromptBlockVersionResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<PromptBlockVersionResponse, Error, TData>({\n queryKey: ['prompt-block-version', blockId, versionId, requestContext],\n queryFn: () => client.getStoredPromptBlock(blockId).getVersion(versionId, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to create a new version of a stored prompt block\n */\nexport const useCreatePromptBlockVersion = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<PromptBlockVersionResponse, CreatePromptBlockVersionParams | undefined>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<PromptBlockVersionResponse, Error, CreatePromptBlockVersionParams | undefined>({\n mutationFn: (params?: CreatePromptBlockVersionParams) =>\n client.getStoredPromptBlock(blockId).createVersion(params, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to activate a specific version of a stored prompt block\n */\nexport const useActivatePromptBlockVersion = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ActivatePromptBlockVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ActivatePromptBlockVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredPromptBlock(blockId).activateVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to restore a specific version of a stored prompt block (creates a new version from an old one)\n */\nexport const useRestorePromptBlockVersion = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<PromptBlockVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<PromptBlockVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredPromptBlock(blockId).restoreVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to delete a specific version of a stored prompt block\n */\nexport const useDeletePromptBlockVersion = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<DeletePromptBlockVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<DeletePromptBlockVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredPromptBlock(blockId).deleteVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n },\n ...queryOptions,\n });\n};\n","import type {\n MastraClient,\n ListStoredPromptBlocksParams,\n ListStoredPromptBlocksResponse,\n StoredPromptBlockResponse,\n CreateStoredPromptBlockParams,\n UpdateStoredPromptBlockParams,\n} 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\nexport const useStoredPromptBlocks = <TData = ListStoredPromptBlocksResponse>({\n requestContext,\n queryOptions,\n ...params\n}: ListStoredPromptBlocksParams & {\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListStoredPromptBlocksResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListStoredPromptBlocksResponse, Error, TData>({\n queryKey: ['stored-prompt-blocks', params, requestContext],\n queryFn: () => client.listStoredPromptBlocks(params),\n placeholderData: (previousData: ListStoredPromptBlocksResponse | undefined) => previousData,\n ...queryOptions,\n });\n};\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useStoredPromptBlock = <TData = StoredPromptBlockResponse | null>({\n blockId,\n status,\n requestContext,\n queryOptions,\n}: {\n blockId?: string;\n status?: 'draft' | 'published';\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<StoredPromptBlockResponse | null, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<StoredPromptBlockResponse | null, Error, TData>({\n queryKey: ['stored-prompt-block', blockId, status, requestContext],\n queryFn: () => (blockId ? client.getStoredPromptBlock(blockId).details(requestContext, { status }) : null),\n ...queryOptions,\n });\n};\n\ntype DeleteStoredPromptBlockResponse = Awaited<ReturnType<ReturnType<MastraClient['getStoredPromptBlock']>['delete']>>;\n\nexport const useStoredPromptBlockMutations = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: {\n createStoredPromptBlock?: MastraMutationOptions<StoredPromptBlockResponse, CreateStoredPromptBlockParams>;\n updateStoredPromptBlock?: MastraMutationOptions<StoredPromptBlockResponse, UpdateStoredPromptBlockParams>;\n deleteStoredPromptBlock?: MastraMutationOptions<DeleteStoredPromptBlockResponse, void>;\n };\n} = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n const createMutation = useMutation({\n mutationFn: (params: CreateStoredPromptBlockParams) => client.createStoredPromptBlock(params),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-blocks'] });\n },\n ...queryOptions?.createStoredPromptBlock,\n });\n\n const updateMutation = useMutation({\n mutationFn: (params: UpdateStoredPromptBlockParams) => {\n if (!blockId) throw new Error('blockId is required for update');\n return client.getStoredPromptBlock(blockId).update(params, requestContext);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-blocks'] });\n if (blockId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n }\n },\n ...queryOptions?.updateStoredPromptBlock,\n });\n\n const deleteMutation = useMutation({\n mutationFn: () => {\n if (!blockId) throw new Error('blockId is required for delete');\n return client.getStoredPromptBlock(blockId).delete(requestContext);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-blocks'] });\n if (blockId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n }\n },\n ...queryOptions?.deleteStoredPromptBlock,\n });\n\n return {\n createStoredPromptBlock: createMutation,\n updateStoredPromptBlock: updateMutation,\n deleteStoredPromptBlock: deleteMutation,\n };\n};\n"],"mappings":";;;;;;;;;AAoBA,MAAa,0BAAmE,EAC9E,SACA,QACA,gBACA,mBAMkC;CAClC,MAAM,SAASA,8BAAAA,gBAAgB;CAE/B,QAAA,GAAOC,sBAAAA,SAAAA,CAAwD;EAC7D,UAAU;GAAC;GAAyB;GAAS;GAAQ;EAAc;EACnE,eAAe,OAAO,qBAAqB,OAAO,CAAC,CAAC,aAAa,QAAQ,cAAc;EACvF,GAAG;CACL,CAAC;AACH;;;;;;AAOA,MAAa,yBAA6D,EACxE,SACA,WACA,gBACA,mBAMkC;CAClC,MAAM,SAASD,8BAAAA,gBAAgB;CAE/B,QAAA,GAAOC,sBAAAA,SAAAA,CAAmD;EACxD,UAAU;GAAC;GAAwB;GAAS;GAAW;EAAc;EAC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M,eAAA,GAAcE,sBAAAA,eAAAA,CAAe;CAuCnC,OAAO;EACL,0BAAA,GAtCqBC,sBAAAA,YAAAA,CAAY;GACjC,aAAa,WAA0C,OAAO,wBAAwB,MAAM;GAC5F,iBAAiB;IACf,YAAiB,kBAAkB,EAAE,UAAU,CAAC,sBAAsB,EAAE,CAAC;GAC3E;GACA,GAAG,cAAc;EACnB,CAgCwC;EACtC,0BAAA,GA/BqBA,sBAAAA,YAAAA,CAAY;GACjC,aAAa,WAA0C;IACrD,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,gCAAgC;IAC9D,OAAO,OAAO,qBAAqB,OAAO,CAAC,CAAC,OAAO,QAAQ,cAAc;GAC3E;GACA,iBAAiB;IACf,YAAiB,kBAAkB,EAAE,UAAU,CAAC,sBAAsB,EAAE,CAAC;IACzE,IAAI,SAAS;KACX,YAAiB,kBAAkB,EAAE,UAAU,CAAC,uBAAuB,OAAO,EAAE,CAAC;KACjF,YAAiB,kBAAkB,EAAE,UAAU,CAAC,yBAAyB,OAAO,EAAE,CAAC;IACrF;GACF;GACA,GAAG,cAAc;EACnB,CAkBwC;EACtC,0BAAA,GAjBqBA,sBAAAA,YAAAA,CAAY;GACjC,kBAAkB;IAChB,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,gCAAgC;IAC9D,OAAO,OAAO,qBAAqB,OAAO,CAAC,CAAC,OAAO,cAAc;GACnE;GACA,iBAAiB;IACf,YAAiB,kBAAkB,EAAE,UAAU,CAAC,sBAAsB,EAAE,CAAC;IACzE,IAAI,SACF,YAAiB,kBAAkB,EAAE,UAAU,CAAC,uBAAuB,OAAO,EAAE,CAAC;GAErF;GACA,GAAG,cAAc;EACnB,CAKwC;CACxC;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as useMastraClient } from "../../mastra-client-context-
|
|
1
|
+
import { n as useMastraClient } from "../../mastra-client-context-DQ5z_ze9.js";
|
|
2
2
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
-
|
|
3
|
+
// src/hooks/prompt-blocks/use-prompt-block-versions.ts
|
|
4
4
|
/**
|
|
5
5
|
* Hook to list versions of a stored prompt block
|
|
6
6
|
*
|
|
@@ -97,8 +97,7 @@ const useDeletePromptBlockVersion = ({ blockId, requestContext, queryOptions })
|
|
|
97
97
|
...queryOptions
|
|
98
98
|
});
|
|
99
99
|
};
|
|
100
|
-
|
|
101
|
-
//#region src/hooks/prompt-blocks/use-stored-prompt-blocks.ts
|
|
100
|
+
// src/hooks/prompt-blocks/use-stored-prompt-blocks.ts
|
|
102
101
|
const useStoredPromptBlocks = ({ requestContext, queryOptions, ...params } = {}) => {
|
|
103
102
|
const client = useMastraClient();
|
|
104
103
|
return useQuery({
|
|
@@ -166,7 +165,6 @@ const useStoredPromptBlockMutations = ({ blockId, requestContext, queryOptions }
|
|
|
166
165
|
})
|
|
167
166
|
};
|
|
168
167
|
};
|
|
169
|
-
//#endregion
|
|
170
168
|
export { useActivatePromptBlockVersion, useCreatePromptBlockVersion, useDeletePromptBlockVersion, usePromptBlockVersion, usePromptBlockVersions, useRestorePromptBlockVersion, useStoredPromptBlock, useStoredPromptBlockMutations, useStoredPromptBlocks };
|
|
171
169
|
|
|
172
170
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/prompt-blocks/use-prompt-block-versions.ts","../../../src/hooks/prompt-blocks/use-stored-prompt-blocks.ts"],"sourcesContent":["import type {\n ListPromptBlockVersionsParams,\n CreatePromptBlockVersionParams,\n ListPromptBlockVersionsResponse,\n PromptBlockVersionResponse,\n ActivatePromptBlockVersionResponse,\n DeletePromptBlockVersionResponse,\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 { ListPromptBlockVersionsParams, CreatePromptBlockVersionParams };\n\n/**\n * Hook to list versions of a stored prompt block\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const usePromptBlockVersions = <TData = ListPromptBlockVersionsResponse>({\n blockId,\n params,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n params?: ListPromptBlockVersionsParams;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListPromptBlockVersionsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListPromptBlockVersionsResponse, Error, TData>({\n queryKey: ['prompt-block-versions', blockId, params, requestContext],\n queryFn: () => client.getStoredPromptBlock(blockId).listVersions(params, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to get a single version of a stored prompt block\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const usePromptBlockVersion = <TData = PromptBlockVersionResponse>({\n blockId,\n versionId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n versionId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<PromptBlockVersionResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<PromptBlockVersionResponse, Error, TData>({\n queryKey: ['prompt-block-version', blockId, versionId, requestContext],\n queryFn: () => client.getStoredPromptBlock(blockId).getVersion(versionId, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to create a new version of a stored prompt block\n */\nexport const useCreatePromptBlockVersion = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<PromptBlockVersionResponse, CreatePromptBlockVersionParams | undefined>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<PromptBlockVersionResponse, Error, CreatePromptBlockVersionParams | undefined>({\n mutationFn: (params?: CreatePromptBlockVersionParams) =>\n client.getStoredPromptBlock(blockId).createVersion(params, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to activate a specific version of a stored prompt block\n */\nexport const useActivatePromptBlockVersion = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ActivatePromptBlockVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ActivatePromptBlockVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredPromptBlock(blockId).activateVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to restore a specific version of a stored prompt block (creates a new version from an old one)\n */\nexport const useRestorePromptBlockVersion = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<PromptBlockVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<PromptBlockVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredPromptBlock(blockId).restoreVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to delete a specific version of a stored prompt block\n */\nexport const useDeletePromptBlockVersion = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<DeletePromptBlockVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<DeletePromptBlockVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredPromptBlock(blockId).deleteVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n },\n ...queryOptions,\n });\n};\n","import type {\n MastraClient,\n ListStoredPromptBlocksParams,\n ListStoredPromptBlocksResponse,\n StoredPromptBlockResponse,\n CreateStoredPromptBlockParams,\n UpdateStoredPromptBlockParams,\n} 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\nexport const useStoredPromptBlocks = <TData = ListStoredPromptBlocksResponse>({\n requestContext,\n queryOptions,\n ...params\n}: ListStoredPromptBlocksParams & {\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListStoredPromptBlocksResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListStoredPromptBlocksResponse, Error, TData>({\n queryKey: ['stored-prompt-blocks', params, requestContext],\n queryFn: () => client.listStoredPromptBlocks(params),\n placeholderData: (previousData: ListStoredPromptBlocksResponse | undefined) => previousData,\n ...queryOptions,\n });\n};\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useStoredPromptBlock = <TData = StoredPromptBlockResponse | null>({\n blockId,\n status,\n requestContext,\n queryOptions,\n}: {\n blockId?: string;\n status?: 'draft' | 'published';\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<StoredPromptBlockResponse | null, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<StoredPromptBlockResponse | null, Error, TData>({\n queryKey: ['stored-prompt-block', blockId, status, requestContext],\n queryFn: () => (blockId ? client.getStoredPromptBlock(blockId).details(requestContext, { status }) : null),\n ...queryOptions,\n });\n};\n\ntype DeleteStoredPromptBlockResponse = Awaited<ReturnType<ReturnType<MastraClient['getStoredPromptBlock']>['delete']>>;\n\nexport const useStoredPromptBlockMutations = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: {\n createStoredPromptBlock?: MastraMutationOptions<StoredPromptBlockResponse, CreateStoredPromptBlockParams>;\n updateStoredPromptBlock?: MastraMutationOptions<StoredPromptBlockResponse, UpdateStoredPromptBlockParams>;\n deleteStoredPromptBlock?: MastraMutationOptions<DeleteStoredPromptBlockResponse, void>;\n };\n} = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n const createMutation = useMutation({\n mutationFn: (params: CreateStoredPromptBlockParams) => client.createStoredPromptBlock(params),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-blocks'] });\n },\n ...queryOptions?.createStoredPromptBlock,\n });\n\n const updateMutation = useMutation({\n mutationFn: (params: UpdateStoredPromptBlockParams) => {\n if (!blockId) throw new Error('blockId is required for update');\n return client.getStoredPromptBlock(blockId).update(params, requestContext);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-blocks'] });\n if (blockId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n }\n },\n ...queryOptions?.updateStoredPromptBlock,\n });\n\n const deleteMutation = useMutation({\n mutationFn: () => {\n if (!blockId) throw new Error('blockId is required for delete');\n return client.getStoredPromptBlock(blockId).delete(requestContext);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-blocks'] });\n if (blockId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n }\n },\n ...queryOptions?.deleteStoredPromptBlock,\n });\n\n return {\n createStoredPromptBlock: createM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.ts","../../../src/hooks/prompt-blocks/use-stored-prompt-blocks.ts"],"sourcesContent":["import type {\n ListPromptBlockVersionsParams,\n CreatePromptBlockVersionParams,\n ListPromptBlockVersionsResponse,\n PromptBlockVersionResponse,\n ActivatePromptBlockVersionResponse,\n DeletePromptBlockVersionResponse,\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 { ListPromptBlockVersionsParams, CreatePromptBlockVersionParams };\n\n/**\n * Hook to list versions of a stored prompt block\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const usePromptBlockVersions = <TData = ListPromptBlockVersionsResponse>({\n blockId,\n params,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n params?: ListPromptBlockVersionsParams;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListPromptBlockVersionsResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListPromptBlockVersionsResponse, Error, TData>({\n queryKey: ['prompt-block-versions', blockId, params, requestContext],\n queryFn: () => client.getStoredPromptBlock(blockId).listVersions(params, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to get a single version of a stored prompt block\n *\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const usePromptBlockVersion = <TData = PromptBlockVersionResponse>({\n blockId,\n versionId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n versionId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<PromptBlockVersionResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<PromptBlockVersionResponse, Error, TData>({\n queryKey: ['prompt-block-version', blockId, versionId, requestContext],\n queryFn: () => client.getStoredPromptBlock(blockId).getVersion(versionId, requestContext),\n ...queryOptions,\n });\n};\n\n/**\n * Hook to create a new version of a stored prompt block\n */\nexport const useCreatePromptBlockVersion = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<PromptBlockVersionResponse, CreatePromptBlockVersionParams | undefined>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<PromptBlockVersionResponse, Error, CreatePromptBlockVersionParams | undefined>({\n mutationFn: (params?: CreatePromptBlockVersionParams) =>\n client.getStoredPromptBlock(blockId).createVersion(params, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to activate a specific version of a stored prompt block\n */\nexport const useActivatePromptBlockVersion = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<ActivatePromptBlockVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ActivatePromptBlockVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredPromptBlock(blockId).activateVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to restore a specific version of a stored prompt block (creates a new version from an old one)\n */\nexport const useRestorePromptBlockVersion = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<PromptBlockVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<PromptBlockVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredPromptBlock(blockId).restoreVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n },\n ...queryOptions,\n });\n};\n\n/**\n * Hook to delete a specific version of a stored prompt block\n */\nexport const useDeletePromptBlockVersion = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId: string;\n requestContext?: Record<string, any>;\n queryOptions?: MastraMutationOptions<DeletePromptBlockVersionResponse, string>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<DeletePromptBlockVersionResponse, Error, string>({\n mutationFn: (versionId: string) => client.getStoredPromptBlock(blockId).deleteVersion(versionId, requestContext),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n },\n ...queryOptions,\n });\n};\n","import type {\n MastraClient,\n ListStoredPromptBlocksParams,\n ListStoredPromptBlocksResponse,\n StoredPromptBlockResponse,\n CreateStoredPromptBlockParams,\n UpdateStoredPromptBlockParams,\n} 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\nexport const useStoredPromptBlocks = <TData = ListStoredPromptBlocksResponse>({\n requestContext,\n queryOptions,\n ...params\n}: ListStoredPromptBlocksParams & {\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<ListStoredPromptBlocksResponse, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ListStoredPromptBlocksResponse, Error, TData>({\n queryKey: ['stored-prompt-blocks', params, requestContext],\n queryFn: () => client.listStoredPromptBlocks(params),\n placeholderData: (previousData: ListStoredPromptBlocksResponse | undefined) => previousData,\n ...queryOptions,\n });\n};\n\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useStoredPromptBlock = <TData = StoredPromptBlockResponse | null>({\n blockId,\n status,\n requestContext,\n queryOptions,\n}: {\n blockId?: string;\n status?: 'draft' | 'published';\n requestContext?: Record<string, any>;\n queryOptions?: MastraQueryOptions<StoredPromptBlockResponse | null, TData>;\n} = {}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<StoredPromptBlockResponse | null, Error, TData>({\n queryKey: ['stored-prompt-block', blockId, status, requestContext],\n queryFn: () => (blockId ? client.getStoredPromptBlock(blockId).details(requestContext, { status }) : null),\n ...queryOptions,\n });\n};\n\ntype DeleteStoredPromptBlockResponse = Awaited<ReturnType<ReturnType<MastraClient['getStoredPromptBlock']>['delete']>>;\n\nexport const useStoredPromptBlockMutations = ({\n blockId,\n requestContext,\n queryOptions,\n}: {\n blockId?: string;\n requestContext?: Record<string, any>;\n queryOptions?: {\n createStoredPromptBlock?: MastraMutationOptions<StoredPromptBlockResponse, CreateStoredPromptBlockParams>;\n updateStoredPromptBlock?: MastraMutationOptions<StoredPromptBlockResponse, UpdateStoredPromptBlockParams>;\n deleteStoredPromptBlock?: MastraMutationOptions<DeleteStoredPromptBlockResponse, void>;\n };\n} = {}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n const createMutation = useMutation({\n mutationFn: (params: CreateStoredPromptBlockParams) => client.createStoredPromptBlock(params),\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-blocks'] });\n },\n ...queryOptions?.createStoredPromptBlock,\n });\n\n const updateMutation = useMutation({\n mutationFn: (params: UpdateStoredPromptBlockParams) => {\n if (!blockId) throw new Error('blockId is required for update');\n return client.getStoredPromptBlock(blockId).update(params, requestContext);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-blocks'] });\n if (blockId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n void queryClient.invalidateQueries({ queryKey: ['prompt-block-versions', blockId] });\n }\n },\n ...queryOptions?.updateStoredPromptBlock,\n });\n\n const deleteMutation = useMutation({\n mutationFn: () => {\n if (!blockId) throw new Error('blockId is required for delete');\n return client.getStoredPromptBlock(blockId).delete(requestContext);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-blocks'] });\n if (blockId) {\n void queryClient.invalidateQueries({ queryKey: ['stored-prompt-block', blockId] });\n }\n },\n ...queryOptions?.deleteStoredPromptBlock,\n });\n\n return {\n createStoredPromptBlock: createMutation,\n updateStoredPromptBlock: updateMutation,\n deleteStoredPromptBlock: deleteMutation,\n };\n};\n"],"mappings":";;;;;;;;AAoBA,MAAa,0BAAmE,EAC9E,SACA,QACA,gBACA,mBAMkC;CAClC,MAAM,SAAS,gBAAgB;CAE/B,OAAO,SAAwD;EAC7D,UAAU;GAAC;GAAyB;GAAS;GAAQ;EAAc;EACnE,eAAe,OAAO,qBAAqB,OAAO,CAAC,CAAC,aAAa,QAAQ,cAAc;EACvF,GAAG;CACL,CAAC;AACH;;;;;;AAOA,MAAa,yBAA6D,EACxE,SACA,WACA,gBACA,mBAMkC;CAClC,MAAM,SAAS,gBAAgB;CAE/B,OAAO,SAAmD;EACxD,UAAU;GAAC;GAAwB;GAAS;GAAW;EAAc;EACrE,eAAe,OAAO,qBAAqB,OAAO,CAAC,CAAC,WAAW,WAAW,cAAc;EACxF,GAAG;CACL,CAAC;AACH;;;;AAKA,MAAa,+BAA+B,EAC1C,SACA,gBACA,mBAKI;CACJ,MAAM,SAAS,gBAAgB;CAC/B,MAAM,cAAc,eAAe;CAEnC,OAAO,YAA2F;EAChG,aAAa,WACX,OAAO,qBAAqB,OAAO,CAAC,CAAC,cAAc,QAAQ,cAAc;EAC3E,iBAAiB;GACf,YAAiB,kBAAkB,EAAE,UAAU,CAAC,yBAAyB,OAAO,EAAE,CAAC;GACnF,YAAiB,kBAAkB,EAAE,UAAU,CAAC,uBAAuB,OAAO,EAAE,C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gCAAgC;IAC9D,OAAO,OAAO,qBAAqB,OAAO,CAAC,CAAC,OAAO,cAAc;GACnE;GACA,iBAAiB;IACf,YAAiB,kBAAkB,EAAE,UAAU,CAAC,sBAAsB,EAAE,CAAC;IACzE,IAAI,SACF,YAAiB,kBAAkB,EAAE,UAAU,CAAC,uBAAuB,OAAO,EAAE,CAAC;GAErF;GACA,GAAG,cAAc;EACnB,CAKwC;CACxC;AACF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_query_utils = require("../../query-utils-
|
|
2
|
+
const require_query_utils = require("../../query-utils-BVgE_xxj.cjs");
|
|
3
3
|
let react = require("react");
|
|
4
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
5
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
6
|
-
|
|
6
|
+
// src/hooks/query/query-client-provider.tsx
|
|
7
7
|
const MastraQueryClientProvider = ({ children, options }) => {
|
|
8
8
|
const [queryClient] = (0, react.useState)(() => new _tanstack_react_query.QueryClient({
|
|
9
9
|
...options,
|
|
@@ -20,7 +20,6 @@ const MastraQueryClientProvider = ({ children, options }) => {
|
|
|
20
20
|
children
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
|
-
//#endregion
|
|
24
23
|
exports.MastraQueryClientProvider = MastraQueryClientProvider;
|
|
25
24
|
exports.is401UnauthorizedError = require_query_utils.is401UnauthorizedError;
|
|
26
25
|
exports.is403ForbiddenError = require_query_utils.is403ForbiddenError;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as isNonRetryableError, c as shouldRetryQuery, i as isBranchesNotSupportedError, n as is403ForbiddenError, o as isObservabilityUnavailableError, r as is404NotFoundError, s as isUnsupportedObservabilityOperationError, t as is401UnauthorizedError } from "../../query-utils-
|
|
1
|
+
import { a as isNonRetryableError, c as shouldRetryQuery, i as isBranchesNotSupportedError, n as is403ForbiddenError, o as isObservabilityUnavailableError, r as is404NotFoundError, s as isUnsupportedObservabilityOperationError, t as is401UnauthorizedError } from "../../query-utils-DvMERIwf.js";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
5
|
-
|
|
5
|
+
// src/hooks/query/query-client-provider.tsx
|
|
6
6
|
const MastraQueryClientProvider = ({ children, options }) => {
|
|
7
7
|
const [queryClient] = useState(() => new QueryClient({
|
|
8
8
|
...options,
|
|
@@ -19,7 +19,6 @@ const MastraQueryClientProvider = ({ children, options }) => {
|
|
|
19
19
|
children
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
|
-
//#endregion
|
|
23
22
|
export { MastraQueryClientProvider, is401UnauthorizedError, is403ForbiddenError, is404NotFoundError, isBranchesNotSupportedError, isNonRetryableError, isObservabilityUnavailableError, isUnsupportedObservabilityOperationError, shouldRetryQuery };
|
|
24
23
|
|
|
25
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_mastra_client_context = require("../../mastra-client-context-
|
|
3
|
-
const require_experiments = require("../../experiments-
|
|
2
|
+
const require_mastra_client_context = require("../../mastra-client-context-DX8wJM9p.cjs");
|
|
3
|
+
const require_experiments = require("../../experiments-Duv0RgkM.cjs");
|
|
4
4
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
5
|
-
|
|
5
|
+
// src/hooks/review/use-dataset-review-items.ts
|
|
6
6
|
/**
|
|
7
7
|
* Loads experiment results with the given review status, across the project, scoped to a target,
|
|
8
8
|
* or scoped to one experiment.
|
|
@@ -74,8 +74,7 @@ const useReviewItemsByStatus = (status, { experimentId, targetType, targetId, ex
|
|
|
74
74
|
const useReviewItems = (options = {}) => useReviewItemsByStatus("needs-review", options);
|
|
75
75
|
/** Loads completed review items (status='complete'), project-wide, per target or for one experiment. */
|
|
76
76
|
const useCompletedItems = (options = {}) => useReviewItemsByStatus("complete", options);
|
|
77
|
-
|
|
78
|
-
//#region src/hooks/review/use-review-summary.ts
|
|
77
|
+
// src/hooks/review/use-review-summary.ts
|
|
79
78
|
function useReviewSummary({ queryOptions } = {}) {
|
|
80
79
|
const client = require_mastra_client_context.useMastraClient();
|
|
81
80
|
return (0, _tanstack_react_query.useQuery)({
|
|
@@ -84,7 +83,6 @@ function useReviewSummary({ queryOptions } = {}) {
|
|
|
84
83
|
...queryOptions
|
|
85
84
|
});
|
|
86
85
|
}
|
|
87
|
-
//#endregion
|
|
88
86
|
exports.useCompletedItems = useCompletedItems;
|
|
89
87
|
exports.useReviewItems = useReviewItems;
|
|
90
88
|
exports.useReviewSummary = useReviewSummary;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useMastraClient","useExperimentsForDatasetFilter","useQuery","useMastraClient","useQuery"],"sources":["../../../src/hooks/review/use-dataset-review-items.ts","../../../src/hooks/review/use-review-summary.ts"],"sourcesContent":["import type { DatasetExperiment } from '@mastra/client-js';\nimport { useQuery } from '@tanstack/react-query';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { useExperimentsForDatasetFilter } from '../experiments';\nimport type { ExperimentTargetFilter } from '../experiments';\nimport type { MastraQueryOptions } from '../shared/query-options';\nimport type { ReviewItem } from './types';\n\ntype ReviewStatus = 'needs-review' | 'complete';\n\nexport interface ReviewItemsOptions extends ExperimentTargetFilter {\n /** When set, only this experiment's results are loaded; otherwise every experiment in the project. */\n experimentId?: string;\n /** Explicit source owned by the caller; an empty list disables discovery too. */\n experiments?: DatasetExperiment[];\n isLoadingExperiments?: boolean;\n /** TanStack overrides spread last into the review-items query. */\n queryOptions?: MastraQueryOptions<ReviewItem[]>;\n}\n\n/**\n * Loads experiment results with the given review status, across the project, scoped to a target,\n * or scoped to one experiment.\n */\nconst useReviewItemsByStatus = (\n status: ReviewStatus,\n {\n experimentId,\n targetType,\n targetId,\n experiments: suppliedExperiments,\n isLoadingExperiments = false,\n queryOptions,\n }: ReviewItemsOptions,\n): UseQueryResult<ReviewItem[], Error> => {\n const client = useMastraClient();\n const hasSuppliedExperiments = suppliedExperiments !== undefined;\n const { data: experimentsData, isLoading: isDiscoveringExperiments } = useExperimentsForDatasetFilter({\n datasetId: undefined,\n target: { targetType, targetId },\n queryOptions: { enabled: !hasSuppliedExperiments },\n });\n const experiments = hasSuppliedExperiments ? suppliedExperiments : experimentsData?.experiments;\n const isLoadingSource = hasSuppliedExperiments ? isLoadingExperiments : isDiscoveringExperiments;\n const scopedExperiments = experimentId ? experiments?.filter(exp => exp.id === experimentId) : experiments;\n\n const query = useQuery({\n queryKey: [\n 'review-items',\n status,\n experimentId ?? 'all',\n hasSuppliedExperiments ? 'supplied' : 'discovered',\n hasSuppliedExperiments ? undefined : targetType || 'all',\n hasSuppliedExperiments ? undefined : targetId || 'all',\n scopedExperiments?.map(e => [e.datasetId, e.id]),\n ],\n queryFn: async () => {\n if (!scopedExperiments || scopedExperiments.length === 0) return [] as ReviewItem[];\n\n const allResults = await Promise.all(\n scopedExperiments.map(async exp => {\n if (!exp.datasetId) return [];\n try {\n const { results } = await client.listDatasetExperimentResults(exp.datasetId, exp.id);\n return results\n .filter(r => r.status === status)\n .map(r => ({\n id: r.id,\n input: r.input,\n output: r.output,\n error: r.error,\n itemId: r.itemId,\n experimentId: r.experimentId,\n datasetId: exp.datasetId ?? undefined,\n traceId: r.traceId ?? undefined,\n scores: r.scores ? Object.fromEntries(r.scores.map(s => [s.scorerId, s.score ?? 0])) : {},\n tags: r.tags ?? [],\n targetType: r.targetType,\n createdAt: r.createdAt,\n startedAt: r.startedAt,\n completedAt: r.completedAt,\n status: r.status,\n groundTruth: r.groundTruth,\n toolMockReport: r.toolMockReport,\n }));\n } catch {\n return [];\n }\n }),\n );\n\n return allResults.flat() as ReviewItem[];\n },\n enabled: Boolean(experiments),\n refetchOnWindowFocus: false,\n ...queryOptions,\n });\n\n // The results query is disabled until experiments arrive, so its own `isLoading`\n // is false during that window; surface the upstream load to avoid an empty flash.\n return { ...query, isLoading: query.isLoading || isLoadingSource } as UseQueryResult<ReviewItem[], Error>;\n};\n\n/** Loads persisted review items (status='needs-review'), project-wide, per target or for one experiment. */\nexport const useReviewItems = (options: ReviewItemsOptions = {}) => useReviewItemsByStatus('needs-review', options);\n\n/** Loads completed review items (status='complete'), project-wide, per target or for one experiment. */\nexport const useCompletedItems = (options: ReviewItemsOptions = {}) => useReviewItemsByStatus('complete', options);\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 ReviewSummaryResponse = Awaited<ReturnType<MastraClient['getExperimentReviewSummary']>>;\n\nexport function useReviewSummary<TData = ReviewSummaryResponse>({\n queryOptions,\n}: {\n queryOptions?: MastraQueryOptions<ReviewSummaryResponse, TData>;\n} = {}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['experiment-review-summary'],\n queryFn: () => client.getExperimentReviewSummary(),\n ...queryOptions,\n });\n}\n"],"mappings":";;;;;;;;;AAyBA,MAAM,0BACJ,QACA,EACE,cACA,YACA,UACA,aAAa,qBACb,uBAAuB,OACvB,mBAEsC;CACxC,MAAM,SAASA,8BAAAA,gBAAgB;CAC/B,MAAM,yBAAyB,wBAAwB,KAAA;CACvD,MAAM,EAAE,MAAM,iBAAiB,WAAW,6BAA6BC,oBAAAA,+BAA+B;EACpG,WAAW,KAAA;EACX,QAAQ;GAAE;GAAY;EAAS;EAC/B,cAAc,EAAE,SAAS,CAAC,uBAAuB;CACnD,CAAC;CACD,MAAM,cAAc,yBAAyB,sBAAsB,iBAAiB;CACpF,MAAM,kBAAkB,yBAAyB,uBAAuB;CACxE,MAAM,oBAAoB,eAAe,aAAa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MAAM,aAAa;CAAgB;AACnE;;AAGA,MAAa,kBAAkB,UAA8B,CAAC,MAAM,uBAAuB,gBAAgB,OAAO;;AAGlH,MAAa,qBAAqB,UAA8B,CAAC,MAAM,uBAAuB,YAAY,OAAO
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useMastraClient","useExperimentsForDatasetFilter","useQuery","useMastraClient","useQuery"],"sources":["../../../src/hooks/review/use-dataset-review-items.ts","../../../src/hooks/review/use-review-summary.ts"],"sourcesContent":["import type { DatasetExperiment } from '@mastra/client-js';\nimport { useQuery } from '@tanstack/react-query';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { useExperimentsForDatasetFilter } from '../experiments';\nimport type { ExperimentTargetFilter } from '../experiments';\nimport type { MastraQueryOptions } from '../shared/query-options';\nimport type { ReviewItem } from './types';\n\ntype ReviewStatus = 'needs-review' | 'complete';\n\nexport interface ReviewItemsOptions extends ExperimentTargetFilter {\n /** When set, only this experiment's results are loaded; otherwise every experiment in the project. */\n experimentId?: string;\n /** Explicit source owned by the caller; an empty list disables discovery too. */\n experiments?: DatasetExperiment[];\n isLoadingExperiments?: boolean;\n /** TanStack overrides spread last into the review-items query. */\n queryOptions?: MastraQueryOptions<ReviewItem[]>;\n}\n\n/**\n * Loads experiment results with the given review status, across the project, scoped to a target,\n * or scoped to one experiment.\n */\nconst useReviewItemsByStatus = (\n status: ReviewStatus,\n {\n experimentId,\n targetType,\n targetId,\n experiments: suppliedExperiments,\n isLoadingExperiments = false,\n queryOptions,\n }: ReviewItemsOptions,\n): UseQueryResult<ReviewItem[], Error> => {\n const client = useMastraClient();\n const hasSuppliedExperiments = suppliedExperiments !== undefined;\n const { data: experimentsData, isLoading: isDiscoveringExperiments } = useExperimentsForDatasetFilter({\n datasetId: undefined,\n target: { targetType, targetId },\n queryOptions: { enabled: !hasSuppliedExperiments },\n });\n const experiments = hasSuppliedExperiments ? suppliedExperiments : experimentsData?.experiments;\n const isLoadingSource = hasSuppliedExperiments ? isLoadingExperiments : isDiscoveringExperiments;\n const scopedExperiments = experimentId ? experiments?.filter(exp => exp.id === experimentId) : experiments;\n\n const query = useQuery({\n queryKey: [\n 'review-items',\n status,\n experimentId ?? 'all',\n hasSuppliedExperiments ? 'supplied' : 'discovered',\n hasSuppliedExperiments ? undefined : targetType || 'all',\n hasSuppliedExperiments ? undefined : targetId || 'all',\n scopedExperiments?.map(e => [e.datasetId, e.id]),\n ],\n queryFn: async () => {\n if (!scopedExperiments || scopedExperiments.length === 0) return [] as ReviewItem[];\n\n const allResults = await Promise.all(\n scopedExperiments.map(async exp => {\n if (!exp.datasetId) return [];\n try {\n const { results } = await client.listDatasetExperimentResults(exp.datasetId, exp.id);\n return results\n .filter(r => r.status === status)\n .map(r => ({\n id: r.id,\n input: r.input,\n output: r.output,\n error: r.error,\n itemId: r.itemId,\n experimentId: r.experimentId,\n datasetId: exp.datasetId ?? undefined,\n traceId: r.traceId ?? undefined,\n scores: r.scores ? Object.fromEntries(r.scores.map(s => [s.scorerId, s.score ?? 0])) : {},\n tags: r.tags ?? [],\n targetType: r.targetType,\n createdAt: r.createdAt,\n startedAt: r.startedAt,\n completedAt: r.completedAt,\n status: r.status,\n groundTruth: r.groundTruth,\n toolMockReport: r.toolMockReport,\n }));\n } catch {\n return [];\n }\n }),\n );\n\n return allResults.flat() as ReviewItem[];\n },\n enabled: Boolean(experiments),\n refetchOnWindowFocus: false,\n ...queryOptions,\n });\n\n // The results query is disabled until experiments arrive, so its own `isLoading`\n // is false during that window; surface the upstream load to avoid an empty flash.\n return { ...query, isLoading: query.isLoading || isLoadingSource } as UseQueryResult<ReviewItem[], Error>;\n};\n\n/** Loads persisted review items (status='needs-review'), project-wide, per target or for one experiment. */\nexport const useReviewItems = (options: ReviewItemsOptions = {}) => useReviewItemsByStatus('needs-review', options);\n\n/** Loads completed review items (status='complete'), project-wide, per target or for one experiment. */\nexport const useCompletedItems = (options: ReviewItemsOptions = {}) => useReviewItemsByStatus('complete', options);\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 ReviewSummaryResponse = Awaited<ReturnType<MastraClient['getExperimentReviewSummary']>>;\n\nexport function useReviewSummary<TData = ReviewSummaryResponse>({\n queryOptions,\n}: {\n queryOptions?: MastraQueryOptions<ReviewSummaryResponse, TData>;\n} = {}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['experiment-review-summary'],\n queryFn: () => client.getExperimentReviewSummary(),\n ...queryOptions,\n });\n}\n"],"mappings":";;;;;;;;;AAyBA,MAAM,0BACJ,QACA,EACE,cACA,YACA,UACA,aAAa,qBACb,uBAAuB,OACvB,mBAEsC;CACxC,MAAM,SAASA,8BAAAA,gBAAgB;CAC/B,MAAM,yBAAyB,wBAAwB,KAAA;CACvD,MAAM,EAAE,MAAM,iBAAiB,WAAW,6BAA6BC,oBAAAA,+BAA+B;EACpG,WAAW,KAAA;EACX,QAAQ;GAAE;GAAY;EAAS;EAC/B,cAAc,EAAE,SAAS,CAAC,uBAAuB;CACnD,CAAC;CACD,MAAM,cAAc,yBAAyB,sBAAsB,iBAAiB;CACpF,MAAM,kBAAkB,yBAAyB,uBAAuB;CACxE,MAAM,oBAAoB,eAAe,aAAa,QAAO,QAAO,IAAI,OAAO,YAAY,IAAI;CAE/F,MAAM,SAAA,GAAQC,sBAAAA,SAAAA,CAAS;EACrB,UAAU;GACR;GACA;GACA,gBAAgB;GAChB,yBAAyB,aAAa;GACtC,yBAAyB,KAAA,IAAY,cAAc;GACnD,yBAAyB,KAAA,IAAY,YAAY;GACjD,mBAAmB,KAAI,MAAK,CAAC,EAAE,WAAW,EAAE,EAAE,CAAC;EACjD;EACA,SAAS,YAAY;GACnB,IAAI,CAAC,qBAAqB,kBAAkB,WAAW,GAAG,OAAO,CAAC;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CAAC;AACH"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as useMastraClient } from "../../mastra-client-context-
|
|
2
|
-
import { a as useExperimentsForDatasetFilter } from "../../experiments-
|
|
1
|
+
import { n as useMastraClient } from "../../mastra-client-context-DQ5z_ze9.js";
|
|
2
|
+
import { a as useExperimentsForDatasetFilter } from "../../experiments-DyecjEut.js";
|
|
3
3
|
import { useQuery } from "@tanstack/react-query";
|
|
4
|
-
|
|
4
|
+
// src/hooks/review/use-dataset-review-items.ts
|
|
5
5
|
/**
|
|
6
6
|
* Loads experiment results with the given review status, across the project, scoped to a target,
|
|
7
7
|
* or scoped to one experiment.
|
|
@@ -73,8 +73,7 @@ const useReviewItemsByStatus = (status, { experimentId, targetType, targetId, ex
|
|
|
73
73
|
const useReviewItems = (options = {}) => useReviewItemsByStatus("needs-review", options);
|
|
74
74
|
/** Loads completed review items (status='complete'), project-wide, per target or for one experiment. */
|
|
75
75
|
const useCompletedItems = (options = {}) => useReviewItemsByStatus("complete", options);
|
|
76
|
-
|
|
77
|
-
//#region src/hooks/review/use-review-summary.ts
|
|
76
|
+
// src/hooks/review/use-review-summary.ts
|
|
78
77
|
function useReviewSummary({ queryOptions } = {}) {
|
|
79
78
|
const client = useMastraClient();
|
|
80
79
|
return useQuery({
|
|
@@ -83,7 +82,6 @@ function useReviewSummary({ queryOptions } = {}) {
|
|
|
83
82
|
...queryOptions
|
|
84
83
|
});
|
|
85
84
|
}
|
|
86
|
-
//#endregion
|
|
87
85
|
export { useCompletedItems, useReviewItems, useReviewSummary };
|
|
88
86
|
|
|
89
87
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/review/use-dataset-review-items.ts","../../../src/hooks/review/use-review-summary.ts"],"sourcesContent":["import type { DatasetExperiment } from '@mastra/client-js';\nimport { useQuery } from '@tanstack/react-query';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { useExperimentsForDatasetFilter } from '../experiments';\nimport type { ExperimentTargetFilter } from '../experiments';\nimport type { MastraQueryOptions } from '../shared/query-options';\nimport type { ReviewItem } from './types';\n\ntype ReviewStatus = 'needs-review' | 'complete';\n\nexport interface ReviewItemsOptions extends ExperimentTargetFilter {\n /** When set, only this experiment's results are loaded; otherwise every experiment in the project. */\n experimentId?: string;\n /** Explicit source owned by the caller; an empty list disables discovery too. */\n experiments?: DatasetExperiment[];\n isLoadingExperiments?: boolean;\n /** TanStack overrides spread last into the review-items query. */\n queryOptions?: MastraQueryOptions<ReviewItem[]>;\n}\n\n/**\n * Loads experiment results with the given review status, across the project, scoped to a target,\n * or scoped to one experiment.\n */\nconst useReviewItemsByStatus = (\n status: ReviewStatus,\n {\n experimentId,\n targetType,\n targetId,\n experiments: suppliedExperiments,\n isLoadingExperiments = false,\n queryOptions,\n }: ReviewItemsOptions,\n): UseQueryResult<ReviewItem[], Error> => {\n const client = useMastraClient();\n const hasSuppliedExperiments = suppliedExperiments !== undefined;\n const { data: experimentsData, isLoading: isDiscoveringExperiments } = useExperimentsForDatasetFilter({\n datasetId: undefined,\n target: { targetType, targetId },\n queryOptions: { enabled: !hasSuppliedExperiments },\n });\n const experiments = hasSuppliedExperiments ? suppliedExperiments : experimentsData?.experiments;\n const isLoadingSource = hasSuppliedExperiments ? isLoadingExperiments : isDiscoveringExperiments;\n const scopedExperiments = experimentId ? experiments?.filter(exp => exp.id === experimentId) : experiments;\n\n const query = useQuery({\n queryKey: [\n 'review-items',\n status,\n experimentId ?? 'all',\n hasSuppliedExperiments ? 'supplied' : 'discovered',\n hasSuppliedExperiments ? undefined : targetType || 'all',\n hasSuppliedExperiments ? undefined : targetId || 'all',\n scopedExperiments?.map(e => [e.datasetId, e.id]),\n ],\n queryFn: async () => {\n if (!scopedExperiments || scopedExperiments.length === 0) return [] as ReviewItem[];\n\n const allResults = await Promise.all(\n scopedExperiments.map(async exp => {\n if (!exp.datasetId) return [];\n try {\n const { results } = await client.listDatasetExperimentResults(exp.datasetId, exp.id);\n return results\n .filter(r => r.status === status)\n .map(r => ({\n id: r.id,\n input: r.input,\n output: r.output,\n error: r.error,\n itemId: r.itemId,\n experimentId: r.experimentId,\n datasetId: exp.datasetId ?? undefined,\n traceId: r.traceId ?? undefined,\n scores: r.scores ? Object.fromEntries(r.scores.map(s => [s.scorerId, s.score ?? 0])) : {},\n tags: r.tags ?? [],\n targetType: r.targetType,\n createdAt: r.createdAt,\n startedAt: r.startedAt,\n completedAt: r.completedAt,\n status: r.status,\n groundTruth: r.groundTruth,\n toolMockReport: r.toolMockReport,\n }));\n } catch {\n return [];\n }\n }),\n );\n\n return allResults.flat() as ReviewItem[];\n },\n enabled: Boolean(experiments),\n refetchOnWindowFocus: false,\n ...queryOptions,\n });\n\n // The results query is disabled until experiments arrive, so its own `isLoading`\n // is false during that window; surface the upstream load to avoid an empty flash.\n return { ...query, isLoading: query.isLoading || isLoadingSource } as UseQueryResult<ReviewItem[], Error>;\n};\n\n/** Loads persisted review items (status='needs-review'), project-wide, per target or for one experiment. */\nexport const useReviewItems = (options: ReviewItemsOptions = {}) => useReviewItemsByStatus('needs-review', options);\n\n/** Loads completed review items (status='complete'), project-wide, per target or for one experiment. */\nexport const useCompletedItems = (options: ReviewItemsOptions = {}) => useReviewItemsByStatus('complete', options);\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 ReviewSummaryResponse = Awaited<ReturnType<MastraClient['getExperimentReviewSummary']>>;\n\nexport function useReviewSummary<TData = ReviewSummaryResponse>({\n queryOptions,\n}: {\n queryOptions?: MastraQueryOptions<ReviewSummaryResponse, TData>;\n} = {}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['experiment-review-summary'],\n queryFn: () => client.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,SAAS,OAAO,YAAY,EAAE,OAAO,KAAI,MAAK,CAAC,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;MACxF,MAAM,EAAE,QAAQ,CAAC;MACjB,YAAY,EAAE;MACd,WAAW,EAAE;MACb,WAAW,EAAE;MACb,aAAa,EAAE;MACf,QAAQ,EAAE;MACV,aAAa,EAAE;MACf,gBAAgB,EAAE;KACpB,EAAE;IACN,QAAQ;KACN,OAAO,CAAC;IACV;GACF,CAAC,CACH,EAAA,CAEkB,KAAK;EACzB;EACA,SAAS,QAAQ,WAAW;EAC5B,sBAAsB;EACtB,GAAG;CACL,CAAC;CAID,OAAO;EAAE,GAAG;EAAO,WAAW,MAAM,aAAa;CAAgB;AACnE;;AAGA,MAAa,kBAAkB,UAA8B,CAAC,MAAM,uBAAuB,gBAAgB,OAAO;;AAGlH,MAAa,qBAAqB,UAA8B,CAAC,MAAM,uBAAuB,YAAY,OAAO
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/review/use-dataset-review-items.ts","../../../src/hooks/review/use-review-summary.ts"],"sourcesContent":["import type { DatasetExperiment } from '@mastra/client-js';\nimport { useQuery } from '@tanstack/react-query';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { useMastraClient } from '../../mastra-client-context';\nimport { useExperimentsForDatasetFilter } from '../experiments';\nimport type { ExperimentTargetFilter } from '../experiments';\nimport type { MastraQueryOptions } from '../shared/query-options';\nimport type { ReviewItem } from './types';\n\ntype ReviewStatus = 'needs-review' | 'complete';\n\nexport interface ReviewItemsOptions extends ExperimentTargetFilter {\n /** When set, only this experiment's results are loaded; otherwise every experiment in the project. */\n experimentId?: string;\n /** Explicit source owned by the caller; an empty list disables discovery too. */\n experiments?: DatasetExperiment[];\n isLoadingExperiments?: boolean;\n /** TanStack overrides spread last into the review-items query. */\n queryOptions?: MastraQueryOptions<ReviewItem[]>;\n}\n\n/**\n * Loads experiment results with the given review status, across the project, scoped to a target,\n * or scoped to one experiment.\n */\nconst useReviewItemsByStatus = (\n status: ReviewStatus,\n {\n experimentId,\n targetType,\n targetId,\n experiments: suppliedExperiments,\n isLoadingExperiments = false,\n queryOptions,\n }: ReviewItemsOptions,\n): UseQueryResult<ReviewItem[], Error> => {\n const client = useMastraClient();\n const hasSuppliedExperiments = suppliedExperiments !== undefined;\n const { data: experimentsData, isLoading: isDiscoveringExperiments } = useExperimentsForDatasetFilter({\n datasetId: undefined,\n target: { targetType, targetId },\n queryOptions: { enabled: !hasSuppliedExperiments },\n });\n const experiments = hasSuppliedExperiments ? suppliedExperiments : experimentsData?.experiments;\n const isLoadingSource = hasSuppliedExperiments ? isLoadingExperiments : isDiscoveringExperiments;\n const scopedExperiments = experimentId ? experiments?.filter(exp => exp.id === experimentId) : experiments;\n\n const query = useQuery({\n queryKey: [\n 'review-items',\n status,\n experimentId ?? 'all',\n hasSuppliedExperiments ? 'supplied' : 'discovered',\n hasSuppliedExperiments ? undefined : targetType || 'all',\n hasSuppliedExperiments ? undefined : targetId || 'all',\n scopedExperiments?.map(e => [e.datasetId, e.id]),\n ],\n queryFn: async () => {\n if (!scopedExperiments || scopedExperiments.length === 0) return [] as ReviewItem[];\n\n const allResults = await Promise.all(\n scopedExperiments.map(async exp => {\n if (!exp.datasetId) return [];\n try {\n const { results } = await client.listDatasetExperimentResults(exp.datasetId, exp.id);\n return results\n .filter(r => r.status === status)\n .map(r => ({\n id: r.id,\n input: r.input,\n output: r.output,\n error: r.error,\n itemId: r.itemId,\n experimentId: r.experimentId,\n datasetId: exp.datasetId ?? undefined,\n traceId: r.traceId ?? undefined,\n scores: r.scores ? Object.fromEntries(r.scores.map(s => [s.scorerId, s.score ?? 0])) : {},\n tags: r.tags ?? [],\n targetType: r.targetType,\n createdAt: r.createdAt,\n startedAt: r.startedAt,\n completedAt: r.completedAt,\n status: r.status,\n groundTruth: r.groundTruth,\n toolMockReport: r.toolMockReport,\n }));\n } catch {\n return [];\n }\n }),\n );\n\n return allResults.flat() as ReviewItem[];\n },\n enabled: Boolean(experiments),\n refetchOnWindowFocus: false,\n ...queryOptions,\n });\n\n // The results query is disabled until experiments arrive, so its own `isLoading`\n // is false during that window; surface the upstream load to avoid an empty flash.\n return { ...query, isLoading: query.isLoading || isLoadingSource } as UseQueryResult<ReviewItem[], Error>;\n};\n\n/** Loads persisted review items (status='needs-review'), project-wide, per target or for one experiment. */\nexport const useReviewItems = (options: ReviewItemsOptions = {}) => useReviewItemsByStatus('needs-review', options);\n\n/** Loads completed review items (status='complete'), project-wide, per target or for one experiment. */\nexport const useCompletedItems = (options: ReviewItemsOptions = {}) => useReviewItemsByStatus('complete', options);\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 ReviewSummaryResponse = Awaited<ReturnType<MastraClient['getExperimentReviewSummary']>>;\n\nexport function useReviewSummary<TData = ReviewSummaryResponse>({\n queryOptions,\n}: {\n queryOptions?: MastraQueryOptions<ReviewSummaryResponse, TData>;\n} = {}): UseQueryResult<TData, Error> {\n const client = useMastraClient();\n\n return useQuery({\n queryKey: ['experiment-review-summary'],\n queryFn: () => client.getExperimentReviewSummary(),\n ...queryOptions,\n });\n}\n"],"mappings":";;;;;;;;AAyBA,MAAM,0BACJ,QACA,EACE,cACA,YACA,UACA,aAAa,qBACb,uBAAuB,OACvB,mBAEsC;CACxC,MAAM,SAAS,gBAAgB;CAC/B,MAAM,yBAAyB,wBAAwB,KAAA;CACvD,MAAM,EAAE,MAAM,iBAAiB,WAAW,6BAA6B,+BAA+B;EACpG,WAAW,KAAA;EACX,QAAQ;GAAE;GAAY;EAAS;EAC/B,cAAc,EAAE,SAAS,CAAC,uBAAuB;CACnD,CAAC;CACD,MAAM,cAAc,yBAAyB,sBAAsB,iBAAiB;CACpF,MAAM,kBAAkB,yBAAyB,uBAAuB;CACxE,MA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,MAAM,aAAa;CAAgB;AACnE;;AAGA,MAAa,kBAAkB,UAA8B,CAAC,MAAM,uBAAuB,gBAAgB,OAAO;;AAGlH,MAAa,qBAAqB,UAA8B,CAAC,MAAM,uBAAuB,YAAY,OAAO;;ACpGjH,SAAgB,iBAAgD,EAC9D,iBAGE,CAAC,GAAiC;CACpC,MAAM,SAAS,gBAAgB;CAE/B,OAAO,SAAS;EACd,UAAU,CAAC,2BAA2B;EACtC,eAAe,OAAO,2BAA2B;EACjD,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-
|
|
3
|
-
const require_use_in_view = require("../../use-in-view-
|
|
2
|
+
const require_mastra_client_context = require("../../mastra-client-context-DX8wJM9p.cjs");
|
|
3
|
+
const require_use_in_view = require("../../use-in-view-BxdrrnCw.cjs");
|
|
4
4
|
let react = require("react");
|
|
5
5
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
6
|
-
|
|
6
|
+
// src/hooks/schedules/use-schedule.ts
|
|
7
7
|
/**
|
|
8
8
|
* Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
|
|
9
9
|
*/
|
|
@@ -18,8 +18,7 @@ const useSchedule = ({ scheduleId, queryOptions }) => {
|
|
|
18
18
|
...queryOptions
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
|
-
|
|
22
|
-
//#region src/hooks/schedules/use-schedules.ts
|
|
21
|
+
// src/hooks/schedules/use-schedules.ts
|
|
23
22
|
const useSchedules = ({ queryOptions, ...params } = {}) => {
|
|
24
23
|
const client = require_mastra_client_context.useMastraClient();
|
|
25
24
|
return (0, _tanstack_react_query.useQuery)({
|
|
@@ -30,8 +29,7 @@ const useSchedules = ({ queryOptions, ...params } = {}) => {
|
|
|
30
29
|
...queryOptions
|
|
31
30
|
});
|
|
32
31
|
};
|
|
33
|
-
|
|
34
|
-
//#region src/hooks/schedules/use-schedule-triggers.ts
|
|
32
|
+
// src/hooks/schedules/use-schedule-triggers.ts
|
|
35
33
|
const PER_PAGE = 25;
|
|
36
34
|
/** `queryOptions` spread last; the hook flattens pages itself, so `select` is not applied to `data`. */
|
|
37
35
|
/**
|
|
@@ -78,8 +76,7 @@ const useScheduleTriggers = ({ scheduleId, queryOptions }) => {
|
|
|
78
76
|
setEndOfListElement
|
|
79
77
|
};
|
|
80
78
|
};
|
|
81
|
-
|
|
82
|
-
//#region src/hooks/schedules/use-toggle-schedule.ts
|
|
79
|
+
// src/hooks/schedules/use-toggle-schedule.ts
|
|
83
80
|
/**
|
|
84
81
|
* Pause/resume a schedule. Used by the schedule detail page button.
|
|
85
82
|
*
|
|
@@ -101,7 +98,6 @@ const useToggleSchedule = ({ scheduleId, queryOptions }) => {
|
|
|
101
98
|
...queryOptions
|
|
102
99
|
});
|
|
103
100
|
};
|
|
104
|
-
//#endregion
|
|
105
101
|
exports.useSchedule = useSchedule;
|
|
106
102
|
exports.useScheduleTriggers = useScheduleTriggers;
|
|
107
103
|
exports.useSchedules = useSchedules;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useMastraClient","useQuery","useMastraClient","useQuery","useMastraClient","useInView","useInfiniteQuery","useMastraClient","useQueryClient","useMutation"],"sources":["../../../src/hooks/schedules/use-schedule.ts","../../../src/hooks/schedules/use-schedules.ts","../../../src/hooks/schedules/use-schedule-triggers.ts","../../../src/hooks/schedules/use-toggle-schedule.ts"],"sourcesContent":["import type { ScheduleResponse } 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\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useSchedule = <TData = ScheduleResponse>({\n scheduleId,\n queryOptions,\n}: {\n scheduleId: string | undefined;\n queryOptions?: MastraQueryOptions<ScheduleResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ScheduleResponse, Error, TData>({\n queryKey: ['schedule', scheduleId],\n queryFn: async () => {\n if (!scheduleId) throw new Error('scheduleId is required');\n return client.getSchedule(scheduleId);\n },\n ...queryOptions,\n });\n};\n","import type { ListSchedulesParams, ScheduleResponse } 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\nexport const useSchedules = <TData = ScheduleResponse[]>({\n queryOptions,\n ...params\n}: ListSchedulesParams & { queryOptions?: MastraQueryOptions<ScheduleResponse[], TData> } = {}): UseQueryResult<\n TData,\n Error\n> => {\n const client = useMastraClient();\n\n return useQuery<ScheduleResponse[], Error, TData>({\n queryKey: ['schedules', params],\n queryFn: async () => {\n const result = await client.listSchedules(params);\n return result.schedules;\n },\n ...queryOptions,\n });\n};\n","import type { ScheduleTriggerResponse, MastraClient } from '@mastra/client-js';\nimport { useInfiniteQuery } from '@tanstack/react-query';\nimport type { InfiniteData, QueryKey, UseInfiniteQueryResult } from '@tanstack/react-query';\nimport { useEffect } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraInfiniteQueryOptions } from '../shared/query-options';\nimport { useInView } from '../shared/use-in-view';\n\nexport type UseScheduleTriggersResult = Omit<UseInfiniteQueryResult<unknown, Error>, 'data'> & {\n data: ScheduleTriggerResponse[];\n setEndOfListElement: (element: HTMLDivElement | null) => void;\n};\n\nconst PER_PAGE = 25;\n\ntype ListScheduleTriggersResponse = Awaited<ReturnType<MastraClient['listScheduleTriggers']>>;\n\n/** `queryOptions` spread last; the hook flattens pages itself, so `select` is not applied to `data`. */\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useScheduleTriggers = ({\n scheduleId,\n queryOptions,\n}: {\n scheduleId: string | undefined;\n queryOptions?: MastraInfiniteQueryOptions<\n ListScheduleTriggersResponse,\n InfiniteData<ListScheduleTriggersResponse, number | undefined>,\n QueryKey,\n number | undefined\n >;\n}): UseScheduleTriggersResult => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n\n const query = useInfiniteQuery({\n queryKey: ['schedule-triggers', scheduleId],\n initialPageParam: undefined as number | undefined,\n queryFn: async ({ pageParam }) => {\n if (!scheduleId) return { triggers: [] } as unknown as ListScheduleTriggersResponse;\n return client.listScheduleTriggers(scheduleId, {\n limit: PER_PAGE,\n toActualFireAt: pageParam,\n });\n },\n getNextPageParam: lastPage => {\n if (!lastPage?.triggers?.length || lastPage.triggers.length < PER_PAGE) {\n return undefined;\n }\n // triggers come back ordered by actualFireAt desc; cursor for next page\n // is the oldest timestamp on the current page (exclusive upper bound).\n return lastPage.triggers[lastPage.triggers.length - 1]!.actualFireAt;\n },\n refetchInterval: query => {\n const triggers = query.state.data?.pages.flatMap(p => p.triggers) ?? [];\n const hasActive = triggers.some(t => {\n if (!t.run) return t.outcome === 'published';\n return t.run.status === 'pending' || t.run.status === 'running' || t.run.status === 'waiting';\n });\n return hasActive ? 5_000 : false;\n },\n ...queryOptions,\n });\n\n const triggers = query.data?.pages.flatMap(page => page?.triggers ?? []) ?? [];\n\n const { hasNextPage, isFetchingNextPage, fetchNextPage } = query;\n useEffect(() => {\n if (isEndOfListInView && hasNextPage && !isFetchingNextPage) {\n void fetchNextPage();\n }\n }, [isEndOfListInView, hasNextPage, isFetchingNextPage, fetchNextPage]);\n\n return { ...query, data: triggers, setEndOfListElement };\n};\n","import type { ScheduleResponse } 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\n/**\n * Pause/resume a schedule. Used by the schedule detail page button.\n *\n * On success invalidates `['schedule', scheduleId]` and `['schedules']` so the\n * detail meta strip and the list view both refresh.\n */\nexport const useToggleSchedule = ({\n scheduleId,\n queryOptions,\n}: {\n scheduleId: string | undefined;\n queryOptions?: MastraMutationOptions<ScheduleResponse, 'pause' | 'resume'>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ScheduleResponse, Error, 'pause' | 'resume'>({\n mutationFn: async action => {\n if (!scheduleId) throw new Error('scheduleId is required');\n return action === 'pause' ? client.pauseSchedule(scheduleId) : client.resumeSchedule(scheduleId);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['schedule', scheduleId] });\n void queryClient.invalidateQueries({ queryKey: ['schedules'] });\n },\n ...queryOptions,\n });\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,eAAyC,EACpD,YACA,mBAIkC;CAClC,MAAM,SAASA,8BAAAA,gBAAgB;CAE/B,QAAA,GAAOC,sBAAAA,SAAAA,CAAyC;EAC9C,UAAU,CAAC,YAAY,UAAU;EACjC,SAAS,YAAY;GACnB,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,wBAAwB;GACzD,OAAO,OAAO,YAAY,UAAU;EACtC;EACA,GAAG;CACL,CAAC;AACH
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useMastraClient","useQuery","useMastraClient","useQuery","useMastraClient","useInView","useInfiniteQuery","useMastraClient","useQueryClient","useMutation"],"sources":["../../../src/hooks/schedules/use-schedule.ts","../../../src/hooks/schedules/use-schedules.ts","../../../src/hooks/schedules/use-schedule-triggers.ts","../../../src/hooks/schedules/use-toggle-schedule.ts"],"sourcesContent":["import type { ScheduleResponse } 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\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useSchedule = <TData = ScheduleResponse>({\n scheduleId,\n queryOptions,\n}: {\n scheduleId: string | undefined;\n queryOptions?: MastraQueryOptions<ScheduleResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ScheduleResponse, Error, TData>({\n queryKey: ['schedule', scheduleId],\n queryFn: async () => {\n if (!scheduleId) throw new Error('scheduleId is required');\n return client.getSchedule(scheduleId);\n },\n ...queryOptions,\n });\n};\n","import type { ListSchedulesParams, ScheduleResponse } 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\nexport const useSchedules = <TData = ScheduleResponse[]>({\n queryOptions,\n ...params\n}: ListSchedulesParams & { queryOptions?: MastraQueryOptions<ScheduleResponse[], TData> } = {}): UseQueryResult<\n TData,\n Error\n> => {\n const client = useMastraClient();\n\n return useQuery<ScheduleResponse[], Error, TData>({\n queryKey: ['schedules', params],\n queryFn: async () => {\n const result = await client.listSchedules(params);\n return result.schedules;\n },\n ...queryOptions,\n });\n};\n","import type { ScheduleTriggerResponse, MastraClient } from '@mastra/client-js';\nimport { useInfiniteQuery } from '@tanstack/react-query';\nimport type { InfiniteData, QueryKey, UseInfiniteQueryResult } from '@tanstack/react-query';\nimport { useEffect } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraInfiniteQueryOptions } from '../shared/query-options';\nimport { useInView } from '../shared/use-in-view';\n\nexport type UseScheduleTriggersResult = Omit<UseInfiniteQueryResult<unknown, Error>, 'data'> & {\n data: ScheduleTriggerResponse[];\n setEndOfListElement: (element: HTMLDivElement | null) => void;\n};\n\nconst PER_PAGE = 25;\n\ntype ListScheduleTriggersResponse = Awaited<ReturnType<MastraClient['listScheduleTriggers']>>;\n\n/** `queryOptions` spread last; the hook flattens pages itself, so `select` is not applied to `data`. */\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useScheduleTriggers = ({\n scheduleId,\n queryOptions,\n}: {\n scheduleId: string | undefined;\n queryOptions?: MastraInfiniteQueryOptions<\n ListScheduleTriggersResponse,\n InfiniteData<ListScheduleTriggersResponse, number | undefined>,\n QueryKey,\n number | undefined\n >;\n}): UseScheduleTriggersResult => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n\n const query = useInfiniteQuery({\n queryKey: ['schedule-triggers', scheduleId],\n initialPageParam: undefined as number | undefined,\n queryFn: async ({ pageParam }) => {\n if (!scheduleId) return { triggers: [] } as unknown as ListScheduleTriggersResponse;\n return client.listScheduleTriggers(scheduleId, {\n limit: PER_PAGE,\n toActualFireAt: pageParam,\n });\n },\n getNextPageParam: lastPage => {\n if (!lastPage?.triggers?.length || lastPage.triggers.length < PER_PAGE) {\n return undefined;\n }\n // triggers come back ordered by actualFireAt desc; cursor for next page\n // is the oldest timestamp on the current page (exclusive upper bound).\n return lastPage.triggers[lastPage.triggers.length - 1]!.actualFireAt;\n },\n refetchInterval: query => {\n const triggers = query.state.data?.pages.flatMap(p => p.triggers) ?? [];\n const hasActive = triggers.some(t => {\n if (!t.run) return t.outcome === 'published';\n return t.run.status === 'pending' || t.run.status === 'running' || t.run.status === 'waiting';\n });\n return hasActive ? 5_000 : false;\n },\n ...queryOptions,\n });\n\n const triggers = query.data?.pages.flatMap(page => page?.triggers ?? []) ?? [];\n\n const { hasNextPage, isFetchingNextPage, fetchNextPage } = query;\n useEffect(() => {\n if (isEndOfListInView && hasNextPage && !isFetchingNextPage) {\n void fetchNextPage();\n }\n }, [isEndOfListInView, hasNextPage, isFetchingNextPage, fetchNextPage]);\n\n return { ...query, data: triggers, setEndOfListElement };\n};\n","import type { ScheduleResponse } 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\n/**\n * Pause/resume a schedule. Used by the schedule detail page button.\n *\n * On success invalidates `['schedule', scheduleId]` and `['schedules']` so the\n * detail meta strip and the list view both refresh.\n */\nexport const useToggleSchedule = ({\n scheduleId,\n queryOptions,\n}: {\n scheduleId: string | undefined;\n queryOptions?: MastraMutationOptions<ScheduleResponse, 'pause' | 'resume'>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ScheduleResponse, Error, 'pause' | 'resume'>({\n mutationFn: async action => {\n if (!scheduleId) throw new Error('scheduleId is required');\n return action === 'pause' ? client.pauseSchedule(scheduleId) : client.resumeSchedule(scheduleId);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['schedule', scheduleId] });\n void queryClient.invalidateQueries({ queryKey: ['schedules'] });\n },\n ...queryOptions,\n });\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,eAAyC,EACpD,YACA,mBAIkC;CAClC,MAAM,SAASA,8BAAAA,gBAAgB;CAE/B,QAAA,GAAOC,sBAAAA,SAAAA,CAAyC;EAC9C,UAAU,CAAC,YAAY,UAAU;EACjC,SAAS,YAAY;GACnB,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,wBAAwB;GACzD,OAAO,OAAO,YAAY,UAAU;EACtC;EACA,GAAG;CACL,CAAC;AACH;;ACpBA,MAAa,gBAA4C,EACvD,cACA,GAAG,WACuF,CAAC,MAGxF;CACH,MAAM,SAASC,8BAAAA,gBAAgB;CAE/B,QAAA,GAAOC,sBAAAA,SAAAA,CAA2C;EAChD,UAAU,CAAC,aAAa,MAAM;EAC9B,SAAS,YAAY;GAEnB,QAAO,MADc,OAAO,cAAc,MAAM,EAAA,CAClC;EAChB;EACA,GAAG;CACL,CAAC;AACH;;ACVA,MAAM,WAAW;;;;;AAQjB,MAAa,uBAAuB,EAClC,YACA,mBAS+B;CAC/B,MAAM,SAASC,8BAAAA,gBAAgB;CAC/B,MAAM,EAAE,QAAQ,mBAAmB,QAAQ,wBAAwBC,oBAAAA,UAAU;CAE7E,MAAM,SAAA,GAAQC,sBA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AI,MAAM,wBAAwB;GACzD,OAAO,WAAW,UAAU,OAAO,cAAc,UAAU,IAAI,OAAO,eAAe,UAAU;EACjG;EACA,iBAAiB;GACf,YAAiB,kBAAkB,EAAE,UAAU,CAAC,YAAY,UAAU,EAAE,CAAC;GACzE,YAAiB,kBAAkB,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC;EAChE;EACA,GAAG;CACL,CAAC;AACH"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { n as useMastraClient } from "../../mastra-client-context-
|
|
2
|
-
import { t as useInView } from "../../use-in-view-
|
|
1
|
+
import { n as useMastraClient } from "../../mastra-client-context-DQ5z_ze9.js";
|
|
2
|
+
import { t as useInView } from "../../use-in-view-CyjKdplM.js";
|
|
3
3
|
import { useEffect } from "react";
|
|
4
4
|
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
5
|
-
|
|
5
|
+
// src/hooks/schedules/use-schedule.ts
|
|
6
6
|
/**
|
|
7
7
|
* Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
|
|
8
8
|
*/
|
|
@@ -17,8 +17,7 @@ const useSchedule = ({ scheduleId, queryOptions }) => {
|
|
|
17
17
|
...queryOptions
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
//#region src/hooks/schedules/use-schedules.ts
|
|
20
|
+
// src/hooks/schedules/use-schedules.ts
|
|
22
21
|
const useSchedules = ({ queryOptions, ...params } = {}) => {
|
|
23
22
|
const client = useMastraClient();
|
|
24
23
|
return useQuery({
|
|
@@ -29,8 +28,7 @@ const useSchedules = ({ queryOptions, ...params } = {}) => {
|
|
|
29
28
|
...queryOptions
|
|
30
29
|
});
|
|
31
30
|
};
|
|
32
|
-
|
|
33
|
-
//#region src/hooks/schedules/use-schedule-triggers.ts
|
|
31
|
+
// src/hooks/schedules/use-schedule-triggers.ts
|
|
34
32
|
const PER_PAGE = 25;
|
|
35
33
|
/** `queryOptions` spread last; the hook flattens pages itself, so `select` is not applied to `data`. */
|
|
36
34
|
/**
|
|
@@ -77,8 +75,7 @@ const useScheduleTriggers = ({ scheduleId, queryOptions }) => {
|
|
|
77
75
|
setEndOfListElement
|
|
78
76
|
};
|
|
79
77
|
};
|
|
80
|
-
|
|
81
|
-
//#region src/hooks/schedules/use-toggle-schedule.ts
|
|
78
|
+
// src/hooks/schedules/use-toggle-schedule.ts
|
|
82
79
|
/**
|
|
83
80
|
* Pause/resume a schedule. Used by the schedule detail page button.
|
|
84
81
|
*
|
|
@@ -100,7 +97,6 @@ const useToggleSchedule = ({ scheduleId, queryOptions }) => {
|
|
|
100
97
|
...queryOptions
|
|
101
98
|
});
|
|
102
99
|
};
|
|
103
|
-
//#endregion
|
|
104
100
|
export { useSchedule, useScheduleTriggers, useSchedules, useToggleSchedule };
|
|
105
101
|
|
|
106
102
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/schedules/use-schedule.ts","../../../src/hooks/schedules/use-schedules.ts","../../../src/hooks/schedules/use-schedule-triggers.ts","../../../src/hooks/schedules/use-toggle-schedule.ts"],"sourcesContent":["import type { ScheduleResponse } 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\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useSchedule = <TData = ScheduleResponse>({\n scheduleId,\n queryOptions,\n}: {\n scheduleId: string | undefined;\n queryOptions?: MastraQueryOptions<ScheduleResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ScheduleResponse, Error, TData>({\n queryKey: ['schedule', scheduleId],\n queryFn: async () => {\n if (!scheduleId) throw new Error('scheduleId is required');\n return client.getSchedule(scheduleId);\n },\n ...queryOptions,\n });\n};\n","import type { ListSchedulesParams, ScheduleResponse } 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\nexport const useSchedules = <TData = ScheduleResponse[]>({\n queryOptions,\n ...params\n}: ListSchedulesParams & { queryOptions?: MastraQueryOptions<ScheduleResponse[], TData> } = {}): UseQueryResult<\n TData,\n Error\n> => {\n const client = useMastraClient();\n\n return useQuery<ScheduleResponse[], Error, TData>({\n queryKey: ['schedules', params],\n queryFn: async () => {\n const result = await client.listSchedules(params);\n return result.schedules;\n },\n ...queryOptions,\n });\n};\n","import type { ScheduleTriggerResponse, MastraClient } from '@mastra/client-js';\nimport { useInfiniteQuery } from '@tanstack/react-query';\nimport type { InfiniteData, QueryKey, UseInfiniteQueryResult } from '@tanstack/react-query';\nimport { useEffect } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraInfiniteQueryOptions } from '../shared/query-options';\nimport { useInView } from '../shared/use-in-view';\n\nexport type UseScheduleTriggersResult = Omit<UseInfiniteQueryResult<unknown, Error>, 'data'> & {\n data: ScheduleTriggerResponse[];\n setEndOfListElement: (element: HTMLDivElement | null) => void;\n};\n\nconst PER_PAGE = 25;\n\ntype ListScheduleTriggersResponse = Awaited<ReturnType<MastraClient['listScheduleTriggers']>>;\n\n/** `queryOptions` spread last; the hook flattens pages itself, so `select` is not applied to `data`. */\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useScheduleTriggers = ({\n scheduleId,\n queryOptions,\n}: {\n scheduleId: string | undefined;\n queryOptions?: MastraInfiniteQueryOptions<\n ListScheduleTriggersResponse,\n InfiniteData<ListScheduleTriggersResponse, number | undefined>,\n QueryKey,\n number | undefined\n >;\n}): UseScheduleTriggersResult => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n\n const query = useInfiniteQuery({\n queryKey: ['schedule-triggers', scheduleId],\n initialPageParam: undefined as number | undefined,\n queryFn: async ({ pageParam }) => {\n if (!scheduleId) return { triggers: [] } as unknown as ListScheduleTriggersResponse;\n return client.listScheduleTriggers(scheduleId, {\n limit: PER_PAGE,\n toActualFireAt: pageParam,\n });\n },\n getNextPageParam: lastPage => {\n if (!lastPage?.triggers?.length || lastPage.triggers.length < PER_PAGE) {\n return undefined;\n }\n // triggers come back ordered by actualFireAt desc; cursor for next page\n // is the oldest timestamp on the current page (exclusive upper bound).\n return lastPage.triggers[lastPage.triggers.length - 1]!.actualFireAt;\n },\n refetchInterval: query => {\n const triggers = query.state.data?.pages.flatMap(p => p.triggers) ?? [];\n const hasActive = triggers.some(t => {\n if (!t.run) return t.outcome === 'published';\n return t.run.status === 'pending' || t.run.status === 'running' || t.run.status === 'waiting';\n });\n return hasActive ? 5_000 : false;\n },\n ...queryOptions,\n });\n\n const triggers = query.data?.pages.flatMap(page => page?.triggers ?? []) ?? [];\n\n const { hasNextPage, isFetchingNextPage, fetchNextPage } = query;\n useEffect(() => {\n if (isEndOfListInView && hasNextPage && !isFetchingNextPage) {\n void fetchNextPage();\n }\n }, [isEndOfListInView, hasNextPage, isFetchingNextPage, fetchNextPage]);\n\n return { ...query, data: triggers, setEndOfListElement };\n};\n","import type { ScheduleResponse } 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\n/**\n * Pause/resume a schedule. Used by the schedule detail page button.\n *\n * On success invalidates `['schedule', scheduleId]` and `['schedules']` so the\n * detail meta strip and the list view both refresh.\n */\nexport const useToggleSchedule = ({\n scheduleId,\n queryOptions,\n}: {\n scheduleId: string | undefined;\n queryOptions?: MastraMutationOptions<ScheduleResponse, 'pause' | 'resume'>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ScheduleResponse, Error, 'pause' | 'resume'>({\n mutationFn: async action => {\n if (!scheduleId) throw new Error('scheduleId is required');\n return action === 'pause' ? client.pauseSchedule(scheduleId) : client.resumeSchedule(scheduleId);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['schedule', scheduleId] });\n void queryClient.invalidateQueries({ queryKey: ['schedules'] });\n },\n ...queryOptions,\n });\n};\n"],"mappings":";;;;;;;;AASA,MAAa,eAAyC,EACpD,YACA,mBAIkC;CAClC,MAAM,SAAS,gBAAgB;CAE/B,OAAO,SAAyC;EAC9C,UAAU,CAAC,YAAY,UAAU;EACjC,SAAS,YAAY;GACnB,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,wBAAwB;GACzD,OAAO,OAAO,YAAY,UAAU;EACtC;EACA,GAAG;CACL,CAAC;AACH
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/hooks/schedules/use-schedule.ts","../../../src/hooks/schedules/use-schedules.ts","../../../src/hooks/schedules/use-schedule-triggers.ts","../../../src/hooks/schedules/use-toggle-schedule.ts"],"sourcesContent":["import type { ScheduleResponse } 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\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useSchedule = <TData = ScheduleResponse>({\n scheduleId,\n queryOptions,\n}: {\n scheduleId: string | undefined;\n queryOptions?: MastraQueryOptions<ScheduleResponse, TData>;\n}): UseQueryResult<TData, Error> => {\n const client = useMastraClient();\n\n return useQuery<ScheduleResponse, Error, TData>({\n queryKey: ['schedule', scheduleId],\n queryFn: async () => {\n if (!scheduleId) throw new Error('scheduleId is required');\n return client.getSchedule(scheduleId);\n },\n ...queryOptions,\n });\n};\n","import type { ListSchedulesParams, ScheduleResponse } 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\nexport const useSchedules = <TData = ScheduleResponse[]>({\n queryOptions,\n ...params\n}: ListSchedulesParams & { queryOptions?: MastraQueryOptions<ScheduleResponse[], TData> } = {}): UseQueryResult<\n TData,\n Error\n> => {\n const client = useMastraClient();\n\n return useQuery<ScheduleResponse[], Error, TData>({\n queryKey: ['schedules', params],\n queryFn: async () => {\n const result = await client.listSchedules(params);\n return result.schedules;\n },\n ...queryOptions,\n });\n};\n","import type { ScheduleTriggerResponse, MastraClient } from '@mastra/client-js';\nimport { useInfiniteQuery } from '@tanstack/react-query';\nimport type { InfiniteData, QueryKey, UseInfiniteQueryResult } from '@tanstack/react-query';\nimport { useEffect } from 'react';\nimport { useMastraClient } from '../../mastra-client-context';\nimport type { MastraInfiniteQueryOptions } from '../shared/query-options';\nimport { useInView } from '../shared/use-in-view';\n\nexport type UseScheduleTriggersResult = Omit<UseInfiniteQueryResult<unknown, Error>, 'data'> & {\n data: ScheduleTriggerResponse[];\n setEndOfListElement: (element: HTMLDivElement | null) => void;\n};\n\nconst PER_PAGE = 25;\n\ntype ListScheduleTriggersResponse = Awaited<ReturnType<MastraClient['listScheduleTriggers']>>;\n\n/** `queryOptions` spread last; the hook flattens pages itself, so `select` is not applied to `data`. */\n/**\n * Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.\n */\nexport const useScheduleTriggers = ({\n scheduleId,\n queryOptions,\n}: {\n scheduleId: string | undefined;\n queryOptions?: MastraInfiniteQueryOptions<\n ListScheduleTriggersResponse,\n InfiniteData<ListScheduleTriggersResponse, number | undefined>,\n QueryKey,\n number | undefined\n >;\n}): UseScheduleTriggersResult => {\n const client = useMastraClient();\n const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();\n\n const query = useInfiniteQuery({\n queryKey: ['schedule-triggers', scheduleId],\n initialPageParam: undefined as number | undefined,\n queryFn: async ({ pageParam }) => {\n if (!scheduleId) return { triggers: [] } as unknown as ListScheduleTriggersResponse;\n return client.listScheduleTriggers(scheduleId, {\n limit: PER_PAGE,\n toActualFireAt: pageParam,\n });\n },\n getNextPageParam: lastPage => {\n if (!lastPage?.triggers?.length || lastPage.triggers.length < PER_PAGE) {\n return undefined;\n }\n // triggers come back ordered by actualFireAt desc; cursor for next page\n // is the oldest timestamp on the current page (exclusive upper bound).\n return lastPage.triggers[lastPage.triggers.length - 1]!.actualFireAt;\n },\n refetchInterval: query => {\n const triggers = query.state.data?.pages.flatMap(p => p.triggers) ?? [];\n const hasActive = triggers.some(t => {\n if (!t.run) return t.outcome === 'published';\n return t.run.status === 'pending' || t.run.status === 'running' || t.run.status === 'waiting';\n });\n return hasActive ? 5_000 : false;\n },\n ...queryOptions,\n });\n\n const triggers = query.data?.pages.flatMap(page => page?.triggers ?? []) ?? [];\n\n const { hasNextPage, isFetchingNextPage, fetchNextPage } = query;\n useEffect(() => {\n if (isEndOfListInView && hasNextPage && !isFetchingNextPage) {\n void fetchNextPage();\n }\n }, [isEndOfListInView, hasNextPage, isFetchingNextPage, fetchNextPage]);\n\n return { ...query, data: triggers, setEndOfListElement };\n};\n","import type { ScheduleResponse } 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\n/**\n * Pause/resume a schedule. Used by the schedule detail page button.\n *\n * On success invalidates `['schedule', scheduleId]` and `['schedules']` so the\n * detail meta strip and the list view both refresh.\n */\nexport const useToggleSchedule = ({\n scheduleId,\n queryOptions,\n}: {\n scheduleId: string | undefined;\n queryOptions?: MastraMutationOptions<ScheduleResponse, 'pause' | 'resume'>;\n}) => {\n const client = useMastraClient();\n const queryClient = useQueryClient();\n\n return useMutation<ScheduleResponse, Error, 'pause' | 'resume'>({\n mutationFn: async action => {\n if (!scheduleId) throw new Error('scheduleId is required');\n return action === 'pause' ? client.pauseSchedule(scheduleId) : client.resumeSchedule(scheduleId);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: ['schedule', scheduleId] });\n void queryClient.invalidateQueries({ queryKey: ['schedules'] });\n },\n ...queryOptions,\n });\n};\n"],"mappings":";;;;;;;;AASA,MAAa,eAAyC,EACpD,YACA,mBAIkC;CAClC,MAAM,SAAS,gBAAgB;CAE/B,OAAO,SAAyC;EAC9C,UAAU,CAAC,YAAY,UAAU;EACjC,SAAS,YAAY;GACnB,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,wBAAwB;GACzD,OAAO,OAAO,YAAY,UAAU;EACtC;EACA,GAAG;CACL,CAAC;AACH;;ACpBA,MAAa,gBAA4C,EACvD,cACA,GAAG,WACuF,CAAC,MAGxF;CACH,MAAM,SAAS,gBAAgB;CAE/B,OAAO,SAA2C;EAChD,UAAU,CAAC,aAAa,MAAM;EAC9B,SAAS,YAAY;GAEnB,QAAO,MADc,OAAO,cAAc,MAAM,EAAA,CAClC;EAChB;EACA,GAAG;CACL,CAAC;AACH;;ACVA,MAAM,WAAW;;;;;AAQjB,MAAa,uBAAuB,EAClC,YACA,mBAS+B;CAC/B,MAAM,SAAS,gBAAgB;CAC/B,MAAM,EAAE,QAAQ,mBAAmB,QAAQ,wBAAwB,UAAU;CAE7E,MAAM,QAAQ,iBAAiB;EAC7B,UAAU,CAAC,qBAAqB,UAAU;EAC1C,kBAAkB,KAAA;EAClB,SAAS,OAAO,EAAE,gBAAgB;GAChC,IAAI,CAAC,YAAY,OAAO,EAAE,UAAU,CAAC,EAAE;GACvC,OAAO,OAAO,qBAAqB,YAAY;IAC7C,OAAO;IACP,gBAAgB;GAClB,CAAC;EACH;EACA,mBAAkB,aAAY;GAC5B,IAAI,CAAC,UAAU,UAAU,UAAU,SAAS,SAAS,SAAS,UAC5D;GAIF,OAAO,SAAS,SAAS,SAAS,SAAS,SAAS,EAAE,CAAE;EAC1D;EACA,kBAAiB,UAAS;GAMxB,QALiB,MAAM,MAAM,MAAM,MAAM,SAAQ,MAAK,EAAE,QAAQ,KAAK,CAAC,EAAA,CAC3C,MAAK,MAAK;IACnC,IAAI,CAAC,EAAE,KAAK,OAAO,EAAE,YAAY;IACjC,OAAO,EAAE,IAAI,WAAW,aAAa,EAAE,IAAI,WAAW,aAAa,EAAE,IAAI,WAAW;GACtF,CACe,IAAI,MAAQ;EAC7B;EACA,GAAG;CACL,CAAC;CAED,MAAM,WAAW,MAAM,MAAM,MAAM,SAAQ,SAAQ,MAAM,YAAY,CAAC,CAAC,KAAK,CAAC;CAE7E,MAAM,EAAE,aAAa,oBAAoB,kBAAkB;CAC3D,gBAAgB;EACd,IAAI,qBAAqB,eAAe,CAAC,oBACvC,cAAmB;CAEvB,GAAG;EAAC;EAAmB;EAAa;EAAoB;CAAa,CAAC;CAEtE,OAAO;EAAE,GAAG;EAAO,MAAM;EAAU;CAAoB;AACzD;;;;;;;;AChEA,MAAa,qBAAqB,EAChC,YACA,mBAII;CACJ,MAAM,SAAS,gBAAgB;CAC/B,MAAM,cAAc,eAAe;CAEnC,OAAO,YAAyD;EAC9D,YAAY,OAAM,WAAU;GAC1B,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,wBAAwB;GACzD,OAAO,WAAW,UAAU,OAAO,cAAc,UAAU,IAAI,OAAO,eAAe,UAAU;EACjG;EACA,iBAAiB;GACf,YAAiB,kBAAkB,EAAE,UAAU,CAAC,YAAY,UAAU,EAAE,CAAC;GACzE,YAAiB,kBAAkB,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC;EAChE;EACA,GAAG;CACL,CAAC;AACH"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_mastra_client_context = require("../../mastra-client-context-
|
|
3
|
-
const require_use_in_view = require("../../use-in-view-
|
|
4
|
-
const require_query_utils = require("../../query-utils-
|
|
2
|
+
const require_mastra_client_context = require("../../mastra-client-context-DX8wJM9p.cjs");
|
|
3
|
+
const require_use_in_view = require("../../use-in-view-BxdrrnCw.cjs");
|
|
4
|
+
const require_query_utils = require("../../query-utils-BVgE_xxj.cjs");
|
|
5
5
|
let react = require("react");
|
|
6
6
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
7
|
-
|
|
7
|
+
// src/hooks/scores/use-scorers.ts
|
|
8
8
|
const SCORES_PER_PAGE = 25;
|
|
9
9
|
const SCORES_REFETCH_INTERVAL_MS = 15e3;
|
|
10
10
|
function getScoresRefetchInterval(query) {
|
|
@@ -98,8 +98,7 @@ const useScorers = ({ requestContext, queryOptions } = {}) => {
|
|
|
98
98
|
...queryOptions
|
|
99
99
|
});
|
|
100
100
|
};
|
|
101
|
-
|
|
102
|
-
//#region src/hooks/scores/use-trace-span-scores.ts
|
|
101
|
+
// src/hooks/scores/use-trace-span-scores.ts
|
|
103
102
|
const TRACE_SPAN_SCORES_REFETCH_INTERVAL_MS = 15e3;
|
|
104
103
|
function getTraceSpanScoresRefetchInterval(query) {
|
|
105
104
|
if (require_query_utils.isUnsupportedObservabilityOperationError(query.state.error, "scores") || require_query_utils.isObservabilityUnavailableError(query.state.error)) return false;
|
|
@@ -129,8 +128,7 @@ const useTraceSpanScores = ({ traceId = "", spanId = "", page, queryOptions }) =
|
|
|
129
128
|
...queryOptions
|
|
130
129
|
});
|
|
131
130
|
};
|
|
132
|
-
|
|
133
|
-
//#region src/hooks/scores/use-trigger-scorer.ts
|
|
131
|
+
// src/hooks/scores/use-trigger-scorer.ts
|
|
134
132
|
const useTriggerScorer = ({ queryOptions } = {}) => {
|
|
135
133
|
const client = require_mastra_client_context.useMastraClient();
|
|
136
134
|
return (0, _tanstack_react_query.useMutation)({
|
|
@@ -146,8 +144,7 @@ const useTriggerScorer = ({ queryOptions } = {}) => {
|
|
|
146
144
|
...queryOptions
|
|
147
145
|
});
|
|
148
146
|
};
|
|
149
|
-
|
|
150
|
-
//#region src/hooks/scores/use-stored-scorers.ts
|
|
147
|
+
// src/hooks/scores/use-stored-scorers.ts
|
|
151
148
|
/**
|
|
152
149
|
* Does not guard on empty ids; pass `queryOptions: { enabled }` to skip the fetch.
|
|
153
150
|
*/
|
|
@@ -202,8 +199,7 @@ const useStoredScorerMutations = ({ scorerId, requestContext, queryOptions } = {
|
|
|
202
199
|
})
|
|
203
200
|
};
|
|
204
201
|
};
|
|
205
|
-
|
|
206
|
-
//#region src/hooks/scores/use-scorer-versions.ts
|
|
202
|
+
// src/hooks/scores/use-scorer-versions.ts
|
|
207
203
|
/**
|
|
208
204
|
* Hook to list versions of a stored scorer
|
|
209
205
|
*
|
|
@@ -318,7 +314,6 @@ const useCompareScorerVersions = ({ scorerId, fromVersionId, toVersionId, reques
|
|
|
318
314
|
...queryOptions
|
|
319
315
|
});
|
|
320
316
|
};
|
|
321
|
-
//#endregion
|
|
322
317
|
exports.getScoresRefetchInterval = getScoresRefetchInterval;
|
|
323
318
|
exports.getTraceSpanScoresRefetchInterval = getTraceSpanScoresRefetchInterval;
|
|
324
319
|
exports.useActivateScorerVersion = useActivateScorerVersion;
|