@mastra/react 1.7.3-alpha.3 → 1.8.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-B1MuNX3j.js +1668 -0
- package/dist/accumulator-B1MuNX3j.js.map +1 -0
- package/dist/accumulator-CsUGDUHk.cjs +1709 -0
- package/dist/accumulator-CsUGDUHk.cjs.map +1 -0
- package/dist/agent/hooks.d.ts.map +1 -1
- package/dist/agent/user-message.d.ts +4 -0
- package/dist/agent/user-message.d.ts.map +1 -0
- package/dist/chat/index.cjs +3 -0
- package/dist/chat/index.d.ts +3 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/index.js +2 -0
- package/dist/feedback-refetch-interval-DLHzQoVV.js +12 -0
- package/dist/feedback-refetch-interval-DLHzQoVV.js.map +1 -0
- package/dist/feedback-refetch-interval-XD5FVc2k.cjs +17 -0
- package/dist/feedback-refetch-interval-XD5FVc2k.cjs.map +1 -0
- package/dist/hooks/agents/index.cjs +988 -0
- package/dist/hooks/agents/index.cjs.map +1 -0
- package/dist/hooks/agents/index.d.ts +19 -0
- package/dist/hooks/agents/index.d.ts.map +1 -0
- package/dist/hooks/agents/index.js +952 -0
- package/dist/hooks/agents/index.js.map +1 -0
- package/dist/hooks/agents/is-model-not-allowed.d.ts +15 -0
- package/dist/hooks/agents/is-model-not-allowed.d.ts.map +1 -0
- package/dist/hooks/agents/use-agent-messages.d.ts +18 -0
- package/dist/hooks/agents/use-agent-messages.d.ts.map +1 -0
- package/dist/hooks/agents/use-agent-plan.d.ts +14 -0
- package/dist/hooks/agents/use-agent-plan.d.ts.map +1 -0
- package/dist/hooks/agents/use-agent-skills.d.ts +2021 -0
- package/dist/hooks/agents/use-agent-skills.d.ts.map +1 -0
- package/dist/hooks/agents/use-agent-versions.d.ts +72 -0
- package/dist/hooks/agents/use-agent-versions.d.ts.map +1 -0
- package/dist/hooks/agents/use-agent-working-memory.d.ts +11 -0
- package/dist/hooks/agents/use-agent-working-memory.d.ts.map +1 -0
- package/dist/hooks/agents/use-agent-workspace.d.ts +2022 -0
- package/dist/hooks/agents/use-agent-workspace.d.ts.map +1 -0
- package/dist/hooks/agents/use-agent.d.ts +12 -0
- package/dist/hooks/agents/use-agent.d.ts.map +1 -0
- package/dist/hooks/agents/use-agents-model-providers.d.ts +9 -0
- package/dist/hooks/agents/use-agents-model-providers.d.ts.map +1 -0
- package/dist/hooks/agents/use-agents.d.ts +28 -0
- package/dist/hooks/agents/use-agents.d.ts.map +1 -0
- package/dist/hooks/agents/use-background-tasks.d.ts +51 -0
- package/dist/hooks/agents/use-background-tasks.d.ts.map +1 -0
- package/dist/hooks/agents/use-browser-session-probe.d.ts +34 -0
- package/dist/hooks/agents/use-browser-session-probe.d.ts.map +1 -0
- package/dist/hooks/agents/use-channels.d.ts +34 -0
- package/dist/hooks/agents/use-channels.d.ts.map +1 -0
- package/dist/hooks/agents/use-close-browser.d.ts +17 -0
- package/dist/hooks/agents/use-close-browser.d.ts.map +1 -0
- package/dist/hooks/agents/use-execute-agent-tool.d.ts +14 -0
- package/dist/hooks/agents/use-execute-agent-tool.d.ts.map +1 -0
- package/dist/hooks/agents/use-preview-instructions.d.ts +20 -0
- package/dist/hooks/agents/use-preview-instructions.d.ts.map +1 -0
- package/dist/hooks/agents/use-stored-agents.d.ts +8023 -0
- package/dist/hooks/agents/use-stored-agents.d.ts.map +1 -0
- package/dist/hooks/agents/use-stored-skills.d.ts +8 -0
- package/dist/hooks/agents/use-stored-skills.d.ts.map +1 -0
- package/dist/hooks/auth/fetch-with-refresh.d.ts +28 -0
- package/dist/hooks/auth/fetch-with-refresh.d.ts.map +1 -0
- package/dist/hooks/auth/get-client-query-key.d.ts +7 -0
- package/dist/hooks/auth/get-client-query-key.d.ts.map +1 -0
- package/dist/hooks/auth/index.cjs +492 -0
- package/dist/hooks/auth/index.cjs.map +1 -0
- package/dist/hooks/auth/index.d.ts +11 -0
- package/dist/hooks/auth/index.d.ts.map +1 -0
- package/dist/hooks/auth/index.js +474 -0
- package/dist/hooks/auth/index.js.map +1 -0
- package/dist/hooks/auth/sso-login.d.ts +8 -0
- package/dist/hooks/auth/sso-login.d.ts.map +1 -0
- package/dist/hooks/auth/types.d.ts +107 -0
- package/dist/hooks/auth/types.d.ts.map +1 -0
- package/dist/hooks/auth/use-auth-actions.d.ts +99 -0
- package/dist/hooks/auth/use-auth-actions.d.ts.map +1 -0
- package/dist/hooks/auth/use-auth-capabilities.d.ts +43 -0
- package/dist/hooks/auth/use-auth-capabilities.d.ts.map +1 -0
- package/dist/hooks/auth/use-credentials-login.d.ts +63 -0
- package/dist/hooks/auth/use-credentials-login.d.ts.map +1 -0
- package/dist/hooks/auth/use-credentials-signup.d.ts +66 -0
- package/dist/hooks/auth/use-credentials-signup.d.ts.map +1 -0
- package/dist/hooks/auth/use-current-user.d.ts +40 -0
- package/dist/hooks/auth/use-current-user.d.ts.map +1 -0
- package/dist/hooks/auth/use-permission-patterns.d.ts +24 -0
- package/dist/hooks/auth/use-permission-patterns.d.ts.map +1 -0
- package/dist/hooks/capabilities/index.cjs +47 -0
- package/dist/hooks/capabilities/index.cjs.map +1 -0
- package/dist/hooks/capabilities/index.d.ts +4 -0
- package/dist/hooks/capabilities/index.d.ts.map +1 -0
- package/dist/hooks/capabilities/index.js +44 -0
- package/dist/hooks/capabilities/index.js.map +1 -0
- package/dist/hooks/capabilities/use-feedback-available.d.ts +9 -0
- package/dist/hooks/capabilities/use-feedback-available.d.ts.map +1 -0
- package/dist/hooks/capabilities/use-observability-capabilities.d.ts +9 -0
- package/dist/hooks/capabilities/use-observability-capabilities.d.ts.map +1 -0
- package/dist/hooks/capabilities/use-trace-query-available.d.ts +9 -0
- package/dist/hooks/capabilities/use-trace-query-available.d.ts.map +1 -0
- package/dist/hooks/configuration/index.cjs +18 -0
- package/dist/hooks/configuration/index.cjs.map +1 -0
- package/dist/hooks/configuration/index.d.ts +2 -0
- package/dist/hooks/configuration/index.d.ts.map +1 -0
- package/dist/hooks/configuration/index.js +17 -0
- package/dist/hooks/configuration/index.js.map +1 -0
- package/dist/hooks/configuration/use-mastra-packages.d.ts +9 -0
- package/dist/hooks/configuration/use-mastra-packages.d.ts.map +1 -0
- package/dist/hooks/datasets/index.cjs +615 -0
- package/dist/hooks/datasets/index.cjs.map +1 -0
- package/dist/hooks/datasets/index.d.ts +10 -0
- package/dist/hooks/datasets/index.d.ts.map +1 -0
- package/dist/hooks/datasets/index.js +600 -0
- package/dist/hooks/datasets/index.js.map +1 -0
- package/dist/hooks/datasets/use-compare-experiments.d.ts +23 -0
- package/dist/hooks/datasets/use-compare-experiments.d.ts.map +1 -0
- package/dist/hooks/datasets/use-dataset-experiments.d.ts +49 -0
- package/dist/hooks/datasets/use-dataset-experiments.d.ts.map +1 -0
- package/dist/hooks/datasets/use-dataset-item-versions.d.ts +31 -0
- package/dist/hooks/datasets/use-dataset-item-versions.d.ts.map +1 -0
- package/dist/hooks/datasets/use-dataset-items.d.ts +38 -0
- package/dist/hooks/datasets/use-dataset-items.d.ts.map +1 -0
- package/dist/hooks/datasets/use-dataset-mutations.d.ts +362 -0
- package/dist/hooks/datasets/use-dataset-mutations.d.ts.map +1 -0
- package/dist/hooks/datasets/use-dataset-versions.d.ts +23 -0
- package/dist/hooks/datasets/use-dataset-versions.d.ts.map +1 -0
- package/dist/hooks/datasets/use-datasets.d.ts +44 -0
- package/dist/hooks/datasets/use-datasets.d.ts.map +1 -0
- package/dist/hooks/datasets/use-experiments.d.ts +16 -0
- package/dist/hooks/datasets/use-experiments.d.ts.map +1 -0
- package/dist/hooks/datasets/use-workflow-schema.d.ts +16 -0
- package/dist/hooks/datasets/use-workflow-schema.d.ts.map +1 -0
- package/dist/hooks/embedders/index.cjs +19 -0
- package/dist/hooks/embedders/index.cjs.map +1 -0
- package/dist/hooks/embedders/index.d.ts +2 -0
- package/dist/hooks/embedders/index.d.ts.map +1 -0
- package/dist/hooks/embedders/index.js +18 -0
- package/dist/hooks/embedders/index.js.map +1 -0
- package/dist/hooks/embedders/use-embedders.d.ts +17 -0
- package/dist/hooks/embedders/use-embedders.d.ts.map +1 -0
- package/dist/hooks/experiments/index.cjs +152 -0
- package/dist/hooks/experiments/index.cjs.map +1 -0
- package/dist/hooks/experiments/index.d.ts +5 -0
- package/dist/hooks/experiments/index.d.ts.map +1 -0
- package/dist/hooks/experiments/index.js +146 -0
- package/dist/hooks/experiments/index.js.map +1 -0
- package/dist/hooks/experiments/use-experiment-metrics.d.ts +30 -0
- package/dist/hooks/experiments/use-experiment-metrics.d.ts.map +1 -0
- package/dist/hooks/experiments/use-experiment-trace.d.ts +13 -0
- package/dist/hooks/experiments/use-experiment-trace.d.ts.map +1 -0
- package/dist/hooks/experiments/use-experiments-for-dataset-filter.d.ts +22 -0
- package/dist/hooks/experiments/use-experiments-for-dataset-filter.d.ts.map +1 -0
- package/dist/hooks/experiments/use-infinite-experiments.d.ts +22 -0
- package/dist/hooks/experiments/use-infinite-experiments.d.ts.map +1 -0
- package/dist/hooks/feedback/feedback-refetch-interval.d.ts +7 -0
- package/dist/hooks/feedback/feedback-refetch-interval.d.ts.map +1 -0
- package/dist/hooks/feedback/index.cjs +22 -0
- package/dist/hooks/feedback/index.cjs.map +1 -0
- package/dist/hooks/feedback/index.d.ts +3 -0
- package/dist/hooks/feedback/index.d.ts.map +1 -0
- package/dist/hooks/feedback/index.js +20 -0
- package/dist/hooks/feedback/index.js.map +1 -0
- package/dist/hooks/feedback/use-feedback.d.ts +56 -0
- package/dist/hooks/feedback/use-feedback.d.ts.map +1 -0
- package/dist/hooks/llm/index.cjs +17 -0
- package/dist/hooks/llm/index.cjs.map +1 -0
- package/dist/hooks/llm/index.d.ts +2 -0
- package/dist/hooks/llm/index.d.ts.map +1 -0
- package/dist/hooks/llm/index.js +16 -0
- package/dist/hooks/llm/index.js.map +1 -0
- package/dist/hooks/llm/use-llm-providers.d.ts +7 -0
- package/dist/hooks/llm/use-llm-providers.d.ts.map +1 -0
- package/dist/hooks/logs/index.cjs +84 -0
- package/dist/hooks/logs/index.cjs.map +1 -0
- package/dist/hooks/logs/index.d.ts +4 -0
- package/dist/hooks/logs/index.d.ts.map +1 -0
- package/dist/hooks/logs/index.js +82 -0
- package/dist/hooks/logs/index.js.map +1 -0
- package/dist/hooks/logs/types.d.ts +36 -0
- package/dist/hooks/logs/types.d.ts.map +1 -0
- package/dist/hooks/logs/use-logs.d.ts +79 -0
- package/dist/hooks/logs/use-logs.d.ts.map +1 -0
- package/dist/hooks/mcps/index.cjs +215 -0
- package/dist/hooks/mcps/index.cjs.map +1 -0
- package/dist/hooks/mcps/index.d.ts +7 -0
- package/dist/hooks/mcps/index.d.ts.map +1 -0
- package/dist/hooks/mcps/index.js +208 -0
- package/dist/hooks/mcps/index.js.map +1 -0
- package/dist/hooks/mcps/use-mcp-app-tools.d.ts +21 -0
- package/dist/hooks/mcps/use-mcp-app-tools.d.ts.map +1 -0
- package/dist/hooks/mcps/use-mcp-server-tool.d.ts +25 -0
- package/dist/hooks/mcps/use-mcp-server-tool.d.ts.map +1 -0
- package/dist/hooks/mcps/use-mcp-server-tools-by-id.d.ts +13 -0
- package/dist/hooks/mcps/use-mcp-server-tools-by-id.d.ts.map +1 -0
- package/dist/hooks/mcps/use-mcp-server-tools.d.ts +9 -0
- package/dist/hooks/mcps/use-mcp-server-tools.d.ts.map +1 -0
- package/dist/hooks/mcps/use-mcp-servers.d.ts +8 -0
- package/dist/hooks/mcps/use-mcp-servers.d.ts.map +1 -0
- package/dist/hooks/mcps/use-try-connect-mcp.d.ts +15 -0
- package/dist/hooks/mcps/use-try-connect-mcp.d.ts.map +1 -0
- package/dist/hooks/memory/index.cjs +328 -0
- package/dist/hooks/memory/index.cjs.map +1 -0
- package/dist/hooks/memory/index.d.ts +5 -0
- package/dist/hooks/memory/index.d.ts.map +1 -0
- package/dist/hooks/memory/index.js +312 -0
- package/dist/hooks/memory/index.js.map +1 -0
- package/dist/hooks/memory/use-memory-status.d.ts +12 -0
- package/dist/hooks/memory/use-memory-status.d.ts.map +1 -0
- package/dist/hooks/memory/use-memory-thread-messages.d.ts +13 -0
- package/dist/hooks/memory/use-memory-thread-messages.d.ts.map +1 -0
- package/dist/hooks/memory/use-memory.d.ts +159 -0
- package/dist/hooks/memory/use-memory.d.ts.map +1 -0
- package/dist/hooks/memory/use-observational-memory.d.ts +13 -0
- package/dist/hooks/memory/use-observational-memory.d.ts.map +1 -0
- package/dist/hooks/metrics/index.cjs +997 -0
- package/dist/hooks/metrics/index.cjs.map +1 -0
- package/dist/hooks/metrics/index.d.ts +16 -0
- package/dist/hooks/metrics/index.d.ts.map +1 -0
- package/dist/hooks/metrics/index.js +981 -0
- package/dist/hooks/metrics/index.js.map +1 -0
- package/dist/hooks/metrics/metrics-interval.d.ts +8 -0
- package/dist/hooks/metrics/metrics-interval.d.ts.map +1 -0
- package/dist/hooks/metrics/metrics-query-filters.d.ts +62 -0
- package/dist/hooks/metrics/metrics-query-filters.d.ts.map +1 -0
- package/dist/hooks/metrics/use-active-resources-kpi-metrics.d.ts +12 -0
- package/dist/hooks/metrics/use-active-resources-kpi-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-active-threads-kpi-metrics.d.ts +12 -0
- package/dist/hooks/metrics/use-active-threads-kpi-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-agent-runs-kpi-metrics.d.ts +9 -0
- package/dist/hooks/metrics/use-agent-runs-kpi-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-latency-metrics.d.ts +23 -0
- package/dist/hooks/metrics/use-latency-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-model-cost-kpi-metrics.d.ts +14 -0
- package/dist/hooks/metrics/use-model-cost-kpi-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-model-usage-cost-metrics.d.ts +16 -0
- package/dist/hooks/metrics/use-model-usage-cost-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-scores-metrics.d.ts +24 -0
- package/dist/hooks/metrics/use-scores-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-token-usage-by-agent-metrics.d.ts +15 -0
- package/dist/hooks/metrics/use-token-usage-by-agent-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-token-usage-timeseries.d.ts +22 -0
- package/dist/hooks/metrics/use-token-usage-timeseries.d.ts.map +1 -0
- package/dist/hooks/metrics/use-top-active-threads-metrics.d.ts +21 -0
- package/dist/hooks/metrics/use-top-active-threads-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-top-resources-by-threads-metrics.d.ts +20 -0
- package/dist/hooks/metrics/use-top-resources-by-threads-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-total-tokens-kpi-metrics.d.ts +13 -0
- package/dist/hooks/metrics/use-total-tokens-kpi-metrics.d.ts.map +1 -0
- package/dist/hooks/metrics/use-trace-volume-metrics.d.ts +17 -0
- package/dist/hooks/metrics/use-trace-volume-metrics.d.ts.map +1 -0
- package/dist/hooks/processors/index.cjs +43 -0
- package/dist/hooks/processors/index.cjs.map +1 -0
- package/dist/hooks/processors/index.d.ts +2 -0
- package/dist/hooks/processors/index.d.ts.map +1 -0
- package/dist/hooks/processors/index.js +40 -0
- package/dist/hooks/processors/index.js.map +1 -0
- package/dist/hooks/processors/use-processors.d.ts +64 -0
- package/dist/hooks/processors/use-processors.d.ts.map +1 -0
- package/dist/hooks/prompt-blocks/index.cjs +181 -0
- package/dist/hooks/prompt-blocks/index.cjs.map +1 -0
- package/dist/hooks/prompt-blocks/index.d.ts +3 -0
- package/dist/hooks/prompt-blocks/index.d.ts.map +1 -0
- package/dist/hooks/prompt-blocks/index.js +172 -0
- package/dist/hooks/prompt-blocks/index.js.map +1 -0
- package/dist/hooks/prompt-blocks/use-prompt-block-versions.d.ts +59 -0
- package/dist/hooks/prompt-blocks/use-prompt-block-versions.d.ts.map +1 -0
- package/dist/hooks/prompt-blocks/use-stored-prompt-blocks.d.ts +180 -0
- package/dist/hooks/prompt-blocks/use-stored-prompt-blocks.d.ts.map +1 -0
- package/dist/hooks/query/index.cjs +34 -0
- package/dist/hooks/query/index.cjs.map +1 -0
- package/dist/hooks/query/index.d.ts +4 -0
- package/dist/hooks/query/index.d.ts.map +1 -0
- package/dist/hooks/query/index.js +25 -0
- package/dist/hooks/query/index.js.map +1 -0
- package/dist/hooks/query/query-client-provider.d.ts +8 -0
- package/dist/hooks/query/query-client-provider.d.ts.map +1 -0
- package/dist/hooks/query/query-utils.d.ts +48 -0
- package/dist/hooks/query/query-utils.d.ts.map +1 -0
- package/dist/hooks/review/index.cjs +89 -0
- package/dist/hooks/review/index.cjs.map +1 -0
- package/dist/hooks/review/index.d.ts +4 -0
- package/dist/hooks/review/index.d.ts.map +1 -0
- package/dist/hooks/review/index.js +86 -0
- package/dist/hooks/review/index.js.map +1 -0
- package/dist/hooks/review/types.d.ts +21 -0
- package/dist/hooks/review/types.d.ts.map +1 -0
- package/dist/hooks/review/use-dataset-review-items.d.ts +19 -0
- package/dist/hooks/review/use-dataset-review-items.d.ts.map +1 -0
- package/dist/hooks/review/use-review-summary.d.ts +9 -0
- package/dist/hooks/review/use-review-summary.d.ts.map +1 -0
- package/dist/hooks/schedules/index.cjs +110 -0
- package/dist/hooks/schedules/index.cjs.map +1 -0
- package/dist/hooks/schedules/index.d.ts +5 -0
- package/dist/hooks/schedules/index.d.ts.map +1 -0
- package/dist/hooks/schedules/index.js +106 -0
- package/dist/hooks/schedules/index.js.map +1 -0
- package/dist/hooks/schedules/use-schedule-triggers.d.ts +18 -0
- package/dist/hooks/schedules/use-schedule-triggers.d.ts.map +1 -0
- package/dist/hooks/schedules/use-schedule.d.ts +11 -0
- package/dist/hooks/schedules/use-schedule.d.ts.map +1 -0
- package/dist/hooks/schedules/use-schedules.d.ts +7 -0
- package/dist/hooks/schedules/use-schedules.d.ts.map +1 -0
- package/dist/hooks/schedules/use-toggle-schedule.d.ts +13 -0
- package/dist/hooks/schedules/use-toggle-schedule.d.ts.map +1 -0
- package/dist/hooks/scores/index.cjs +339 -0
- package/dist/hooks/scores/index.cjs.map +1 -0
- package/dist/hooks/scores/index.d.ts +6 -0
- package/dist/hooks/scores/index.d.ts.map +1 -0
- package/dist/hooks/scores/index.js +323 -0
- package/dist/hooks/scores/index.js.map +1 -0
- package/dist/hooks/scores/use-scorer-versions.d.ts +71 -0
- package/dist/hooks/scores/use-scorer-versions.d.ts.map +1 -0
- package/dist/hooks/scores/use-scorers.d.ts +34 -0
- package/dist/hooks/scores/use-scorers.d.ts.map +1 -0
- package/dist/hooks/scores/use-stored-scorers.d.ts +151 -0
- package/dist/hooks/scores/use-stored-scorers.d.ts.map +1 -0
- package/dist/hooks/scores/use-trace-span-scores.d.ts +20 -0
- package/dist/hooks/scores/use-trace-span-scores.d.ts.map +1 -0
- package/dist/hooks/scores/use-trigger-scorer.d.ts +17 -0
- package/dist/hooks/scores/use-trigger-scorer.d.ts.map +1 -0
- package/dist/hooks/shared/cost.d.ts +7 -0
- package/dist/hooks/shared/cost.d.ts.map +1 -0
- package/dist/hooks/shared/date-format.d.ts +30 -0
- package/dist/hooks/shared/date-format.d.ts.map +1 -0
- package/dist/hooks/shared/map.d.ts +2 -0
- package/dist/hooks/shared/map.d.ts.map +1 -0
- package/dist/hooks/shared/query-options.d.ts +19 -0
- package/dist/hooks/shared/query-options.d.ts.map +1 -0
- package/dist/hooks/shared/use-in-view.d.ts +23 -0
- package/dist/hooks/shared/use-in-view.d.ts.map +1 -0
- package/dist/hooks/templates/index.cjs +464 -0
- package/dist/hooks/templates/index.cjs.map +1 -0
- package/dist/hooks/templates/index.d.ts +2 -0
- package/dist/hooks/templates/index.d.ts.map +1 -0
- package/dist/hooks/templates/index.js +456 -0
- package/dist/hooks/templates/index.js.map +1 -0
- package/dist/hooks/templates/use-templates.d.ts +139 -0
- package/dist/hooks/templates/use-templates.d.ts.map +1 -0
- package/dist/hooks/tool-providers/index.cjs +342 -0
- package/dist/hooks/tool-providers/index.cjs.map +1 -0
- package/dist/hooks/tool-providers/index.d.ts +10 -0
- package/dist/hooks/tool-providers/index.d.ts.map +1 -0
- package/dist/hooks/tool-providers/index.js +332 -0
- package/dist/hooks/tool-providers/index.js.map +1 -0
- package/dist/hooks/tool-providers/use-all-connections.d.ts +41 -0
- package/dist/hooks/tool-providers/use-all-connections.d.ts.map +1 -0
- package/dist/hooks/tool-providers/use-all-provider-tools.d.ts +25 -0
- package/dist/hooks/tool-providers/use-all-provider-tools.d.ts.map +1 -0
- package/dist/hooks/tool-providers/use-authorize.d.ts +45 -0
- package/dist/hooks/tool-providers/use-authorize.d.ts.map +1 -0
- package/dist/hooks/tool-providers/use-disconnect-connection.d.ts +24 -0
- package/dist/hooks/tool-providers/use-disconnect-connection.d.ts.map +1 -0
- package/dist/hooks/tool-providers/use-existing-connections.d.ts +33 -0
- package/dist/hooks/tool-providers/use-existing-connections.d.ts.map +1 -0
- package/dist/hooks/tool-providers/use-provider-tools.d.ts +17 -0
- package/dist/hooks/tool-providers/use-provider-tools.d.ts.map +1 -0
- package/dist/hooks/tool-providers/use-tool-providers.d.ts +23 -0
- package/dist/hooks/tool-providers/use-tool-providers.d.ts.map +1 -0
- package/dist/hooks/tool-providers/use-toolkits.d.ts +13 -0
- package/dist/hooks/tool-providers/use-toolkits.d.ts.map +1 -0
- package/dist/hooks/tool-providers/use-update-connection.d.ts +24 -0
- package/dist/hooks/tool-providers/use-update-connection.d.ts.map +1 -0
- package/dist/hooks/tools/index.cjs +49 -0
- package/dist/hooks/tools/index.cjs.map +1 -0
- package/dist/hooks/tools/index.d.ts +3 -0
- package/dist/hooks/tools/index.d.ts.map +1 -0
- package/dist/hooks/tools/index.js +46 -0
- package/dist/hooks/tools/index.js.map +1 -0
- package/dist/hooks/tools/use-all-tools.d.ts +16 -0
- package/dist/hooks/tools/use-all-tools.d.ts.map +1 -0
- package/dist/hooks/tools/use-execute-tool.d.ts +13 -0
- package/dist/hooks/tools/use-execute-tool.d.ts.map +1 -0
- package/dist/hooks/traces/discovery-cache.d.ts +12 -0
- package/dist/hooks/traces/discovery-cache.d.ts.map +1 -0
- package/dist/hooks/traces/index.cjs +1168 -0
- package/dist/hooks/traces/index.cjs.map +1 -0
- package/dist/hooks/traces/index.d.ts +22 -0
- package/dist/hooks/traces/index.d.ts.map +1 -0
- package/dist/hooks/traces/index.js +1129 -0
- package/dist/hooks/traces/index.js.map +1 -0
- package/dist/hooks/traces/types.d.ts +20 -0
- package/dist/hooks/traces/types.d.ts.map +1 -0
- package/dist/hooks/traces/use-branch.d.ts +18 -0
- package/dist/hooks/traces/use-branch.d.ts.map +1 -0
- package/dist/hooks/traces/use-create-feedback.d.ts +21 -0
- package/dist/hooks/traces/use-create-feedback.d.ts.map +1 -0
- package/dist/hooks/traces/use-delete-feedback.d.ts +21 -0
- package/dist/hooks/traces/use-delete-feedback.d.ts.map +1 -0
- package/dist/hooks/traces/use-entity-names.d.ts +14 -0
- package/dist/hooks/traces/use-entity-names.d.ts.map +1 -0
- package/dist/hooks/traces/use-environments.d.ts +10 -0
- package/dist/hooks/traces/use-environments.d.ts.map +1 -0
- package/dist/hooks/traces/use-service-names.d.ts +10 -0
- package/dist/hooks/traces/use-service-names.d.ts.map +1 -0
- package/dist/hooks/traces/use-span-detail.d.ts +14 -0
- package/dist/hooks/traces/use-span-detail.d.ts.map +1 -0
- package/dist/hooks/traces/use-span-feedback.d.ts +19 -0
- package/dist/hooks/traces/use-span-feedback.d.ts.map +1 -0
- package/dist/hooks/traces/use-tags.d.ts +10 -0
- package/dist/hooks/traces/use-tags.d.ts.map +1 -0
- package/dist/hooks/traces/use-thread-has-other-traces.d.ts +17 -0
- package/dist/hooks/traces/use-thread-has-other-traces.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-column-preferences-storage-key.d.ts +6 -0
- package/dist/hooks/traces/use-trace-column-preferences-storage-key.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-feedback.d.ts +16 -0
- package/dist/hooks/traces/use-trace-feedback.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-light-spans.d.ts +16 -0
- package/dist/hooks/traces/use-trace-light-spans.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-metadata-filter-fields.d.ts +36 -0
- package/dist/hooks/traces/use-trace-metadata-filter-fields.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-or-branch-spans.d.ts +39 -0
- package/dist/hooks/traces/use-trace-or-branch-spans.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-query.d.ts +57 -0
- package/dist/hooks/traces/use-trace-query.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-spans.d.ts +46 -0
- package/dist/hooks/traces/use-trace-spans.d.ts.map +1 -0
- package/dist/hooks/traces/use-trace-usage.d.ts +10 -0
- package/dist/hooks/traces/use-trace-usage.d.ts.map +1 -0
- package/dist/hooks/traces/use-traces.d.ts +292 -0
- package/dist/hooks/traces/use-traces.d.ts.map +1 -0
- package/dist/hooks/vectors/index.cjs +19 -0
- package/dist/hooks/vectors/index.cjs.map +1 -0
- package/dist/hooks/vectors/index.d.ts +2 -0
- package/dist/hooks/vectors/index.d.ts.map +1 -0
- package/dist/hooks/vectors/index.js +18 -0
- package/dist/hooks/vectors/index.js.map +1 -0
- package/dist/hooks/vectors/use-vectors.d.ts +14 -0
- package/dist/hooks/vectors/use-vectors.d.ts.map +1 -0
- package/dist/hooks/voice/index.cjs +87 -0
- package/dist/hooks/voice/index.cjs.map +1 -0
- package/dist/hooks/voice/index.d.ts +2 -0
- package/dist/hooks/voice/index.d.ts.map +1 -0
- package/dist/hooks/voice/index.js +86 -0
- package/dist/hooks/voice/index.js.map +1 -0
- package/dist/hooks/voice/use-read-aloud.d.ts +20 -0
- package/dist/hooks/voice/use-read-aloud.d.ts.map +1 -0
- package/dist/hooks/workflows/index.cjs +173 -0
- package/dist/hooks/workflows/index.cjs.map +1 -0
- package/dist/hooks/workflows/index.d.ts +7 -0
- package/dist/hooks/workflows/index.d.ts.map +1 -0
- package/dist/hooks/workflows/index.js +157 -0
- package/dist/hooks/workflows/index.js.map +1 -0
- package/dist/hooks/workflows/use-workflow-runs.d.ts +51 -0
- package/dist/hooks/workflows/use-workflow-runs.d.ts.map +1 -0
- package/dist/hooks/workflows/use-workflow.d.ts +14 -0
- package/dist/hooks/workflows/use-workflow.d.ts.map +1 -0
- package/dist/hooks/workflows/use-workflows-run-counts.d.ts +25 -0
- package/dist/hooks/workflows/use-workflows-run-counts.d.ts.map +1 -0
- package/dist/hooks/workflows/use-workflows.d.ts +10 -0
- package/dist/hooks/workflows/use-workflows.d.ts.map +1 -0
- package/dist/hooks/workspace/client-utils.d.ts +5 -0
- package/dist/hooks/workspace/client-utils.d.ts.map +1 -0
- package/dist/hooks/workspace/compatibility.d.ts +22 -0
- package/dist/hooks/workspace/compatibility.d.ts.map +1 -0
- package/dist/hooks/workspace/file-type.d.ts +7 -0
- package/dist/hooks/workspace/file-type.d.ts.map +1 -0
- package/dist/hooks/workspace/index.cjs +624 -0
- package/dist/hooks/workspace/index.cjs.map +1 -0
- package/dist/hooks/workspace/index.d.ts +11 -0
- package/dist/hooks/workspace/index.d.ts.map +1 -0
- package/dist/hooks/workspace/index.js +594 -0
- package/dist/hooks/workspace/index.js.map +1 -0
- package/dist/hooks/workspace/types.d.ts +199 -0
- package/dist/hooks/workspace/types.d.ts.map +1 -0
- package/dist/hooks/workspace/use-skills-sh.d.ts +104 -0
- package/dist/hooks/workspace/use-skills-sh.d.ts.map +1 -0
- package/dist/hooks/workspace/use-stored-workspaces.d.ts +12 -0
- package/dist/hooks/workspace/use-stored-workspaces.d.ts.map +1 -0
- package/dist/hooks/workspace/use-workspace-directory.d.ts +13 -0
- package/dist/hooks/workspace/use-workspace-directory.d.ts.map +1 -0
- package/dist/hooks/workspace/use-workspace-file-content.d.ts +15 -0
- package/dist/hooks/workspace/use-workspace-file-content.d.ts.map +1 -0
- package/dist/hooks/workspace/use-workspace-search.d.ts +20 -0
- package/dist/hooks/workspace/use-workspace-search.d.ts.map +1 -0
- package/dist/hooks/workspace/use-workspace-skills.d.ts +23 -0
- package/dist/hooks/workspace/use-workspace-skills.d.ts.map +1 -0
- package/dist/hooks/workspace/use-workspace.d.ts +56 -0
- package/dist/hooks/workspace/use-workspace.d.ts.map +1 -0
- package/dist/hooks-BFQK_s4g.js +1231 -0
- package/dist/hooks-BFQK_s4g.js.map +1 -0
- package/dist/hooks-CMjizg6y.cjs +1248 -0
- package/dist/hooks-CMjizg6y.cjs.map +1 -0
- package/dist/hooks-CjULNHpJ.js +252 -0
- package/dist/hooks-CjULNHpJ.js.map +1 -0
- package/dist/hooks-DsDYaJ3T.cjs +269 -0
- package/dist/hooks-DsDYaJ3T.cjs.map +1 -0
- package/dist/index.cjs +21 -3434
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3419
- package/dist/index.js.map +1 -1
- package/dist/lib/mastra-db/fromCoreUserMessage.d.ts +3 -4
- package/dist/lib/mastra-db/fromCoreUserMessage.d.ts.map +1 -1
- package/dist/map-CDv4fbu4.js +12 -0
- package/dist/map-CDv4fbu4.js.map +1 -0
- package/dist/map-wjmL1y5O.cjs +17 -0
- package/dist/map-wjmL1y5O.cjs.map +1 -0
- package/dist/mastra-client-context-Bx_g84YB.js +50 -0
- package/dist/mastra-client-context-Bx_g84YB.js.map +1 -0
- package/dist/mastra-client-context-DzX3f0RF.cjs +61 -0
- package/dist/mastra-client-context-DzX3f0RF.cjs.map +1 -0
- package/dist/query-utils-CcrChYgz.cjs +174 -0
- package/dist/query-utils-CcrChYgz.cjs.map +1 -0
- package/dist/query-utils-D1NgFnWU.js +127 -0
- package/dist/query-utils-D1NgFnWU.js.map +1 -0
- package/dist/use-in-view-B6eJO9Zi.cjs +37 -0
- package/dist/use-in-view-B6eJO9Zi.cjs.map +1 -0
- package/dist/use-in-view-C9sYPGRm.js +32 -0
- package/dist/use-in-view-C9sYPGRm.js.map +1 -0
- package/dist/voice-BOtUdMi8.cjs +281 -0
- package/dist/voice-BOtUdMi8.cjs.map +1 -0
- package/dist/voice-DgirjEyH.js +264 -0
- package/dist/voice-DgirjEyH.js.map +1 -0
- package/package.json +32 -3
|
@@ -5,10 +5,9 @@ export declare const fromCoreUserMessageToMastraDBMessage: (coreUserMessage: Cor
|
|
|
5
5
|
* Merge multiple `CoreUserMessage`s into a single canonical `MastraDBMessage`.
|
|
6
6
|
*
|
|
7
7
|
* A user turn that carries attachments arrives as several `CoreUserMessage`s
|
|
8
|
-
* (one for the text, one per attachment).
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* `parts` array — to render identically (one bubble, not one per message).
|
|
8
|
+
* (one for the text, one per attachment). Flatten their parts for the optimistic
|
|
9
|
+
* display. The send path must also submit a single multipart message: this
|
|
10
|
+
* display conversion alone cannot combine separately persisted messages.
|
|
12
11
|
*/
|
|
13
12
|
export declare const fromCoreUserMessagesToMastraDBMessage: (coreUserMessages: CoreUserMessage[]) => MastraDBMessage;
|
|
14
13
|
//# sourceMappingURL=fromCoreUserMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromCoreUserMessage.d.ts","sourceRoot":"","sources":["../../../src/lib/mastra-db/fromCoreUserMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,iCAAiC,CAAC;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAuDxD,eAAO,MAAM,oCAAoC,oBAAqB,eAAe,KAAG,eAC/B,CAAC;AAE1D
|
|
1
|
+
{"version":3,"file":"fromCoreUserMessage.d.ts","sourceRoot":"","sources":["../../../src/lib/mastra-db/fromCoreUserMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,iCAAiC,CAAC;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAuDxD,eAAO,MAAM,oCAAoC,oBAAqB,eAAe,KAAG,eAC/B,CAAC;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,qCAAqC,qBAAsB,eAAe,EAAE,KAAG,eAC1B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/hooks/shared/map.ts
|
|
2
|
+
function getOrCreate(map, key, create) {
|
|
3
|
+
const existing = map.get(key);
|
|
4
|
+
if (existing !== void 0) return existing;
|
|
5
|
+
const value = create();
|
|
6
|
+
map.set(key, value);
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { getOrCreate as t };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=map-CDv4fbu4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-CDv4fbu4.js","names":[],"sources":["../src/hooks/shared/map.ts"],"sourcesContent":["export function getOrCreate<K, V>(map: Map<K, V>, key: K, create: () => V): V {\n const existing = map.get(key);\n if (existing !== undefined) return existing;\n const value = create();\n map.set(key, value);\n return value;\n}\n"],"mappings":";AAAA,SAAgB,YAAkB,KAAgB,KAAQ,QAAoB;CAC5E,MAAM,WAAW,IAAI,IAAI,GAAG;CAC5B,IAAI,aAAa,KAAA,GAAW,OAAO;CACnC,MAAM,QAAQ,OAAO;CACrB,IAAI,IAAI,KAAK,KAAK;CAClB,OAAO;AACT"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/hooks/shared/map.ts
|
|
2
|
+
function getOrCreate(map, key, create) {
|
|
3
|
+
const existing = map.get(key);
|
|
4
|
+
if (existing !== void 0) return existing;
|
|
5
|
+
const value = create();
|
|
6
|
+
map.set(key, value);
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
Object.defineProperty(exports, "getOrCreate", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return getOrCreate;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=map-wjmL1y5O.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-wjmL1y5O.cjs","names":[],"sources":["../src/hooks/shared/map.ts"],"sourcesContent":["export function getOrCreate<K, V>(map: Map<K, V>, key: K, create: () => V): V {\n const existing = map.get(key);\n if (existing !== undefined) return existing;\n const value = create();\n map.set(key, value);\n return value;\n}\n"],"mappings":";AAAA,SAAgB,YAAkB,KAAgB,KAAQ,QAAoB;CAC5E,MAAM,WAAW,IAAI,IAAI,GAAG;CAC5B,IAAI,aAAa,KAAA,GAAW,OAAO;CACnC,MAAM,QAAQ,OAAO;CACrB,IAAI,IAAI,KAAK,KAAK;CAClB,OAAO;AACT"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { MastraClient } from "@mastra/client-js";
|
|
2
|
+
import { createContext, useContext, useMemo } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/mastra-client-context.tsx
|
|
5
|
+
const MastraClientContext = createContext({});
|
|
6
|
+
const MastraClientProvider = ({ children, baseUrl, headers, apiPrefix, credentials = "include", customFetch }) => {
|
|
7
|
+
const client = useMemo(() => createMastraClient(baseUrl, headers, apiPrefix, credentials, customFetch), [
|
|
8
|
+
baseUrl,
|
|
9
|
+
headers,
|
|
10
|
+
apiPrefix,
|
|
11
|
+
credentials,
|
|
12
|
+
customFetch
|
|
13
|
+
]);
|
|
14
|
+
return /* @__PURE__ */ jsx(MastraClientContext.Provider, {
|
|
15
|
+
value: client,
|
|
16
|
+
children
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
const useMastraClient = () => useContext(MastraClientContext);
|
|
20
|
+
const IPV4_LOOPBACK_RE = /^127\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
|
|
21
|
+
const isIPv4Loopback = (hostname) => {
|
|
22
|
+
const m = IPV4_LOOPBACK_RE.exec(hostname);
|
|
23
|
+
if (!m) return false;
|
|
24
|
+
return +m[1] <= 255 && +m[2] <= 255 && +m[3] <= 255;
|
|
25
|
+
};
|
|
26
|
+
const isLocalUrl = (url) => {
|
|
27
|
+
if (!url) return true;
|
|
28
|
+
try {
|
|
29
|
+
const { hostname } = new URL(url);
|
|
30
|
+
return hostname === "localhost" || hostname.endsWith(".localhost") || isIPv4Loopback(hostname) || hostname === "::1" || hostname === "[::1]";
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const createMastraClient = (baseUrl, mastraClientHeaders = {}, apiPrefix, credentials = "include", customFetch) => {
|
|
36
|
+
return new MastraClient({
|
|
37
|
+
baseUrl: baseUrl || "",
|
|
38
|
+
headers: isLocalUrl(baseUrl) ? {
|
|
39
|
+
...mastraClientHeaders,
|
|
40
|
+
"x-mastra-dev-playground": "true"
|
|
41
|
+
} : mastraClientHeaders,
|
|
42
|
+
apiPrefix,
|
|
43
|
+
credentials,
|
|
44
|
+
fetch: customFetch
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { useMastraClient as n, MastraClientProvider as t };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=mastra-client-context-Bx_g84YB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mastra-client-context-Bx_g84YB.js","names":[],"sources":["../src/mastra-client-context.tsx"],"sourcesContent":["import { MastraClient } from '@mastra/client-js';\nimport type { ReactNode } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\n\nexport type MastraClientContextType = MastraClient;\n\nconst MastraClientContext = createContext<MastraClientContextType>({} as MastraClientContextType);\n\n/** Passed through to `fetch` / `MastraClient`. Default `include` sends cookies on cross-origin Studio → API requests. */\nexport type MastraClientCredentials = 'omit' | 'same-origin' | 'include';\n\nexport interface MastraClientProviderProps {\n children: ReactNode;\n baseUrl?: string;\n headers?: Record<string, string>;\n /** API route prefix. Defaults to '/api'. Set this to match your server's apiPrefix configuration. */\n apiPrefix?: string;\n /**\n * Credentials mode for API requests. Defaults to `include` so session cookies reach a custom server when Studio and API differ by origin/port.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials\n */\n credentials?: MastraClientCredentials;\n /**\n * Custom fetch function for HTTP requests. Useful for adding middleware like auth refresh.\n * When provided, this overrides the default fetch behavior.\n */\n customFetch?: typeof fetch;\n}\n\nexport const MastraClientProvider = ({\n children,\n baseUrl,\n headers,\n apiPrefix,\n credentials = 'include',\n customFetch,\n}: MastraClientProviderProps) => {\n // Consumers key per-client caches (endpoint support, capability probes) on this instance,\n // so a fresh client each render silently resets them.\n const client = useMemo(\n () => createMastraClient(baseUrl, headers, apiPrefix, credentials, customFetch),\n [baseUrl, headers, apiPrefix, credentials, customFetch],\n );\n\n return <MastraClientContext.Provider value={client}>{children}</MastraClientContext.Provider>;\n};\n\nexport const useMastraClient = () => useContext(MastraClientContext);\n\nconst IPV4_LOOPBACK_RE = /^127\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/;\n\nconst isIPv4Loopback = (hostname: string): boolean => {\n const m = IPV4_LOOPBACK_RE.exec(hostname);\n if (!m) return false;\n return +m[1]! <= 255 && +m[2]! <= 255 && +m[3]! <= 255;\n};\n\nexport const isLocalUrl = (url?: string): boolean => {\n if (!url) return true;\n try {\n const { hostname } = new URL(url);\n return (\n hostname === 'localhost' ||\n hostname.endsWith('.localhost') ||\n isIPv4Loopback(hostname) ||\n hostname === '::1' ||\n hostname === '[::1]'\n );\n } catch {\n return false;\n }\n};\n\nconst createMastraClient = (\n baseUrl?: string,\n mastraClientHeaders: Record<string, string> = {},\n apiPrefix?: string,\n credentials: MastraClientCredentials = 'include',\n customFetch?: typeof fetch,\n) => {\n return new MastraClient({\n baseUrl: baseUrl || '',\n headers: isLocalUrl(baseUrl) ? { ...mastraClientHeaders, 'x-mastra-dev-playground': 'true' } : mastraClientHeaders,\n apiPrefix,\n credentials,\n fetch: customFetch,\n });\n};\n"],"mappings":";;;;AAMA,MAAM,sBAAsB,cAAuC,CAAC,CAA4B;AAuBhG,MAAa,wBAAwB,EACnC,UACA,SACA,SACA,WACA,cAAc,WACd,kBAC+B;CAG/B,MAAM,SAAS,cACP,mBAAmB,SAAS,SAAS,WAAW,aAAa,WAAW,GAC9E;EAAC;EAAS;EAAS;EAAW;EAAa;CAAW,CACxD;CAEA,OAAO,oBAAC,oBAAoB,UAArB;EAA8B,OAAO;EAAS;CAAuC,CAAA;AAC9F;AAEA,MAAa,wBAAwB,WAAW,mBAAmB;AAEnE,MAAM,mBAAmB;AAEzB,MAAM,kBAAkB,aAA8B;CACpD,MAAM,IAAI,iBAAiB,KAAK,QAAQ;CACxC,IAAI,CAAC,GAAG,OAAO;CACf,OAAO,CAAC,EAAE,MAAO,OAAO,CAAC,EAAE,MAAO,OAAO,CAAC,EAAE,MAAO;AACrD;AAEA,MAAa,cAAc,QAA0B;CACnD,IAAI,CAAC,KAAK,OAAO;CACjB,IAAI;EACF,MAAM,EAAE,aAAa,IAAI,IAAI,GAAG;EAChC,OACE,aAAa,eACb,SAAS,SAAS,YAAY,KAC9B,eAAe,QAAQ,KACvB,aAAa,SACb,aAAa;CAEjB,QAAQ;EACN,OAAO;CACT;AACF;AAEA,MAAM,sBACJ,SACA,sBAA8C,CAAC,GAC/C,WACA,cAAuC,WACvC,gBACG;CACH,OAAO,IAAI,aAAa;EACtB,SAAS,WAAW;EACpB,SAAS,WAAW,OAAO,IAAI;GAAE,GAAG;GAAqB,2BAA2B;EAAO,IAAI;EAC/F;EACA;EACA,OAAO;CACT,CAAC;AACH"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
let _mastra_client_js = require("@mastra/client-js");
|
|
2
|
+
let react = require("react");
|
|
3
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
|
+
//#region src/mastra-client-context.tsx
|
|
5
|
+
const MastraClientContext = (0, react.createContext)({});
|
|
6
|
+
const MastraClientProvider = ({ children, baseUrl, headers, apiPrefix, credentials = "include", customFetch }) => {
|
|
7
|
+
const client = (0, react.useMemo)(() => createMastraClient(baseUrl, headers, apiPrefix, credentials, customFetch), [
|
|
8
|
+
baseUrl,
|
|
9
|
+
headers,
|
|
10
|
+
apiPrefix,
|
|
11
|
+
credentials,
|
|
12
|
+
customFetch
|
|
13
|
+
]);
|
|
14
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MastraClientContext.Provider, {
|
|
15
|
+
value: client,
|
|
16
|
+
children
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
const useMastraClient = () => (0, react.useContext)(MastraClientContext);
|
|
20
|
+
const IPV4_LOOPBACK_RE = /^127\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
|
|
21
|
+
const isIPv4Loopback = (hostname) => {
|
|
22
|
+
const m = IPV4_LOOPBACK_RE.exec(hostname);
|
|
23
|
+
if (!m) return false;
|
|
24
|
+
return +m[1] <= 255 && +m[2] <= 255 && +m[3] <= 255;
|
|
25
|
+
};
|
|
26
|
+
const isLocalUrl = (url) => {
|
|
27
|
+
if (!url) return true;
|
|
28
|
+
try {
|
|
29
|
+
const { hostname } = new URL(url);
|
|
30
|
+
return hostname === "localhost" || hostname.endsWith(".localhost") || isIPv4Loopback(hostname) || hostname === "::1" || hostname === "[::1]";
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const createMastraClient = (baseUrl, mastraClientHeaders = {}, apiPrefix, credentials = "include", customFetch) => {
|
|
36
|
+
return new _mastra_client_js.MastraClient({
|
|
37
|
+
baseUrl: baseUrl || "",
|
|
38
|
+
headers: isLocalUrl(baseUrl) ? {
|
|
39
|
+
...mastraClientHeaders,
|
|
40
|
+
"x-mastra-dev-playground": "true"
|
|
41
|
+
} : mastraClientHeaders,
|
|
42
|
+
apiPrefix,
|
|
43
|
+
credentials,
|
|
44
|
+
fetch: customFetch
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
Object.defineProperty(exports, "MastraClientProvider", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function() {
|
|
51
|
+
return MastraClientProvider;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "useMastraClient", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function() {
|
|
57
|
+
return useMastraClient;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=mastra-client-context-DzX3f0RF.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mastra-client-context-DzX3f0RF.cjs","names":["MastraClient"],"sources":["../src/mastra-client-context.tsx"],"sourcesContent":["import { MastraClient } from '@mastra/client-js';\nimport type { ReactNode } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\n\nexport type MastraClientContextType = MastraClient;\n\nconst MastraClientContext = createContext<MastraClientContextType>({} as MastraClientContextType);\n\n/** Passed through to `fetch` / `MastraClient`. Default `include` sends cookies on cross-origin Studio → API requests. */\nexport type MastraClientCredentials = 'omit' | 'same-origin' | 'include';\n\nexport interface MastraClientProviderProps {\n children: ReactNode;\n baseUrl?: string;\n headers?: Record<string, string>;\n /** API route prefix. Defaults to '/api'. Set this to match your server's apiPrefix configuration. */\n apiPrefix?: string;\n /**\n * Credentials mode for API requests. Defaults to `include` so session cookies reach a custom server when Studio and API differ by origin/port.\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials\n */\n credentials?: MastraClientCredentials;\n /**\n * Custom fetch function for HTTP requests. Useful for adding middleware like auth refresh.\n * When provided, this overrides the default fetch behavior.\n */\n customFetch?: typeof fetch;\n}\n\nexport const MastraClientProvider = ({\n children,\n baseUrl,\n headers,\n apiPrefix,\n credentials = 'include',\n customFetch,\n}: MastraClientProviderProps) => {\n // Consumers key per-client caches (endpoint support, capability probes) on this instance,\n // so a fresh client each render silently resets them.\n const client = useMemo(\n () => createMastraClient(baseUrl, headers, apiPrefix, credentials, customFetch),\n [baseUrl, headers, apiPrefix, credentials, customFetch],\n );\n\n return <MastraClientContext.Provider value={client}>{children}</MastraClientContext.Provider>;\n};\n\nexport const useMastraClient = () => useContext(MastraClientContext);\n\nconst IPV4_LOOPBACK_RE = /^127\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/;\n\nconst isIPv4Loopback = (hostname: string): boolean => {\n const m = IPV4_LOOPBACK_RE.exec(hostname);\n if (!m) return false;\n return +m[1]! <= 255 && +m[2]! <= 255 && +m[3]! <= 255;\n};\n\nexport const isLocalUrl = (url?: string): boolean => {\n if (!url) return true;\n try {\n const { hostname } = new URL(url);\n return (\n hostname === 'localhost' ||\n hostname.endsWith('.localhost') ||\n isIPv4Loopback(hostname) ||\n hostname === '::1' ||\n hostname === '[::1]'\n );\n } catch {\n return false;\n }\n};\n\nconst createMastraClient = (\n baseUrl?: string,\n mastraClientHeaders: Record<string, string> = {},\n apiPrefix?: string,\n credentials: MastraClientCredentials = 'include',\n customFetch?: typeof fetch,\n) => {\n return new MastraClient({\n baseUrl: baseUrl || '',\n headers: isLocalUrl(baseUrl) ? { ...mastraClientHeaders, 'x-mastra-dev-playground': 'true' } : mastraClientHeaders,\n apiPrefix,\n credentials,\n fetch: customFetch,\n });\n};\n"],"mappings":";;;;AAMA,MAAM,uBAAA,GAAA,MAAA,cAAA,CAA6D,CAAC,CAA4B;AAuBhG,MAAa,wBAAwB,EACnC,UACA,SACA,SACA,WACA,cAAc,WACd,kBAC+B;CAG/B,MAAM,UAAA,GAAA,MAAA,QAAA,OACE,mBAAmB,SAAS,SAAS,WAAW,aAAa,WAAW,GAC9E;EAAC;EAAS;EAAS;EAAW;EAAa;CAAW,CACxD;CAEA,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,oBAAoB,UAArB;EAA8B,OAAO;EAAS;CAAuC,CAAA;AAC9F;AAEA,MAAa,yBAAA,GAAA,MAAA,WAAA,CAAmC,mBAAmB;AAEnE,MAAM,mBAAmB;AAEzB,MAAM,kBAAkB,aAA8B;CACpD,MAAM,IAAI,iBAAiB,KAAK,QAAQ;CACxC,IAAI,CAAC,GAAG,OAAO;CACf,OAAO,CAAC,EAAE,MAAO,OAAO,CAAC,EAAE,MAAO,OAAO,CAAC,EAAE,MAAO;AACrD;AAEA,MAAa,cAAc,QAA0B;CACnD,IAAI,CAAC,KAAK,OAAO;CACjB,IAAI;EACF,MAAM,EAAE,aAAa,IAAI,IAAI,GAAG;EAChC,OACE,aAAa,eACb,SAAS,SAAS,YAAY,KAC9B,eAAe,QAAQ,KACvB,aAAa,SACb,aAAa;CAEjB,QAAQ;EACN,OAAO;CACT;AACF;AAEA,MAAM,sBACJ,SACA,sBAA8C,CAAC,GAC/C,WACA,cAAuC,WACvC,gBACG;CACH,OAAO,IAAIA,kBAAAA,aAAa;EACtB,SAAS,WAAW;EACpB,SAAS,WAAW,OAAO,IAAI;GAAE,GAAG;GAAqB,2BAA2B;EAAO,IAAI;EAC/F;EACA;EACA,OAAO;CACT,CAAC;AACH"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
//#region src/hooks/query/query-utils.ts
|
|
2
|
+
/**
|
|
3
|
+
* HTTP status codes that should not be retried.
|
|
4
|
+
* - 400: Bad Request (client error, won't change)
|
|
5
|
+
* - 401: Unauthorized (needs re-auth, not retry)
|
|
6
|
+
* - 403: Forbidden (RBAC permission denied)
|
|
7
|
+
* - 404: Not Found (resource doesn't exist)
|
|
8
|
+
* - 501: Not Implemented (capability gap, e.g. disabled storage domain, won't change)
|
|
9
|
+
*/
|
|
10
|
+
const HTTP_NO_RETRY_STATUSES = [
|
|
11
|
+
400,
|
|
12
|
+
401,
|
|
13
|
+
403,
|
|
14
|
+
404,
|
|
15
|
+
501
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* Check if error is a 401 Unauthorized response.
|
|
19
|
+
* Indicates the user's session has expired or token is invalid.
|
|
20
|
+
* Handles both direct status property and client-js error message format.
|
|
21
|
+
*/
|
|
22
|
+
function is401UnauthorizedError(error) {
|
|
23
|
+
if (!error || typeof error !== "object") return false;
|
|
24
|
+
if ("status" in error && error.status === 401) return true;
|
|
25
|
+
if ("statusCode" in error && error.statusCode === 401) return true;
|
|
26
|
+
if ("message" in error) {
|
|
27
|
+
const message = error.message;
|
|
28
|
+
if (typeof message === "string") return /\bstatus:\s*401\b/.test(message);
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Check if error is a 403 Forbidden response.
|
|
34
|
+
* Handles both direct status property and client-js error message format.
|
|
35
|
+
*/
|
|
36
|
+
function is403ForbiddenError(error) {
|
|
37
|
+
if (!error || typeof error !== "object") return false;
|
|
38
|
+
if ("status" in error && error.status === 403) return true;
|
|
39
|
+
if ("statusCode" in error && error.statusCode === 403) return true;
|
|
40
|
+
if ("message" in error) {
|
|
41
|
+
const message = error.message;
|
|
42
|
+
if (typeof message === "string") return /\bstatus:\s*403\b/.test(message);
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Check if error is a 404 Not Found response.
|
|
48
|
+
* Handles both direct status property and client-js error message format.
|
|
49
|
+
*/
|
|
50
|
+
function is404NotFoundError(error) {
|
|
51
|
+
if (!error || typeof error !== "object") return false;
|
|
52
|
+
if ("status" in error && error.status === 404) return true;
|
|
53
|
+
if ("statusCode" in error && error.statusCode === 404) return true;
|
|
54
|
+
if ("message" in error) {
|
|
55
|
+
const message = error.message;
|
|
56
|
+
if (typeof message === "string") return /\bstatus:\s*404\b/.test(message);
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Check if an error came from a storage provider that does not implement `listBranches`.
|
|
62
|
+
*
|
|
63
|
+
* The server's `handleError` strips the original MastraError's `code`/`id` before serializing,
|
|
64
|
+
* so we can't match on the ID `OBSERVABILITY_STORAGE_LIST_BRANCHES_NOT_IMPLEMENTED` directly —
|
|
65
|
+
* we match on the message text from `core/.../observability/base.ts` instead.
|
|
66
|
+
*/
|
|
67
|
+
function isBranchesNotSupportedError(error) {
|
|
68
|
+
if (!error || typeof error !== "object" || !("message" in error)) return false;
|
|
69
|
+
const message = error.message;
|
|
70
|
+
if (typeof message !== "string") return false;
|
|
71
|
+
return message.includes("does not support listing trace branches");
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check if an error came from an observability storage provider that does not
|
|
75
|
+
* implement a list operation. These are capability gaps, not transient failures.
|
|
76
|
+
*
|
|
77
|
+
* The server serializes these as plain HTTP errors, so the original MastraError
|
|
78
|
+
* ID is not available in the browser. Match the stable base-storage message text
|
|
79
|
+
* instead, like the trace branch support check above.
|
|
80
|
+
*/
|
|
81
|
+
function isUnsupportedObservabilityOperationError(error, operation) {
|
|
82
|
+
if (!error || typeof error !== "object" || !("message" in error)) return false;
|
|
83
|
+
const message = error.message;
|
|
84
|
+
if (typeof message !== "string") return false;
|
|
85
|
+
return message.includes(`does not support listing ${operation}`);
|
|
86
|
+
}
|
|
87
|
+
const OBSERVABILITY_UNAVAILABLE_MESSAGES = ["Observability storage domain is not available", "Scores storage domain is not available"];
|
|
88
|
+
/** Check if an error came from a server whose observability storage domain is disabled. */
|
|
89
|
+
function isObservabilityUnavailableError(error) {
|
|
90
|
+
if (!error || typeof error !== "object" || !("message" in error)) return false;
|
|
91
|
+
const message = error.message;
|
|
92
|
+
if (typeof message !== "string") return false;
|
|
93
|
+
return OBSERVABILITY_UNAVAILABLE_MESSAGES.some((m) => message.includes(m));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Check if error has a status code that shouldn't be retried.
|
|
97
|
+
* Used to prevent retrying client errors that won't resolve.
|
|
98
|
+
*/
|
|
99
|
+
function isNonRetryableError(error) {
|
|
100
|
+
if (!error || typeof error !== "object") return false;
|
|
101
|
+
if ("status" in error) {
|
|
102
|
+
const status = error.status;
|
|
103
|
+
return HTTP_NO_RETRY_STATUSES.includes(status);
|
|
104
|
+
}
|
|
105
|
+
if ("statusCode" in error) {
|
|
106
|
+
const statusCode = error.statusCode;
|
|
107
|
+
return HTTP_NO_RETRY_STATUSES.includes(statusCode);
|
|
108
|
+
}
|
|
109
|
+
if ("message" in error) {
|
|
110
|
+
const message = error.message;
|
|
111
|
+
if (typeof message === "string") return HTTP_NO_RETRY_STATUSES.some((code) => new RegExp(`\\bstatus:\\s*${code}\\b`).test(message));
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Default retry function for TanStack Query.
|
|
117
|
+
* Does not retry 4xx client errors (400, 401, 403, 404) or 501 capability gaps.
|
|
118
|
+
* Retries other errors up to 3 times.
|
|
119
|
+
*/
|
|
120
|
+
function shouldRetryQuery(failureCount, error) {
|
|
121
|
+
if (isNonRetryableError(error)) return false;
|
|
122
|
+
return failureCount < 3;
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
Object.defineProperty(exports, "is401UnauthorizedError", {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
get: function() {
|
|
128
|
+
return is401UnauthorizedError;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
Object.defineProperty(exports, "is403ForbiddenError", {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function() {
|
|
134
|
+
return is403ForbiddenError;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
Object.defineProperty(exports, "is404NotFoundError", {
|
|
138
|
+
enumerable: true,
|
|
139
|
+
get: function() {
|
|
140
|
+
return is404NotFoundError;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
Object.defineProperty(exports, "isBranchesNotSupportedError", {
|
|
144
|
+
enumerable: true,
|
|
145
|
+
get: function() {
|
|
146
|
+
return isBranchesNotSupportedError;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
Object.defineProperty(exports, "isNonRetryableError", {
|
|
150
|
+
enumerable: true,
|
|
151
|
+
get: function() {
|
|
152
|
+
return isNonRetryableError;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
Object.defineProperty(exports, "isObservabilityUnavailableError", {
|
|
156
|
+
enumerable: true,
|
|
157
|
+
get: function() {
|
|
158
|
+
return isObservabilityUnavailableError;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
Object.defineProperty(exports, "isUnsupportedObservabilityOperationError", {
|
|
162
|
+
enumerable: true,
|
|
163
|
+
get: function() {
|
|
164
|
+
return isUnsupportedObservabilityOperationError;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
Object.defineProperty(exports, "shouldRetryQuery", {
|
|
168
|
+
enumerable: true,
|
|
169
|
+
get: function() {
|
|
170
|
+
return shouldRetryQuery;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
//# sourceMappingURL=query-utils-CcrChYgz.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-utils-CcrChYgz.cjs","names":[],"sources":["../src/hooks/query/query-utils.ts"],"sourcesContent":["/**\n * HTTP status codes that should not be retried.\n * - 400: Bad Request (client error, won't change)\n * - 401: Unauthorized (needs re-auth, not retry)\n * - 403: Forbidden (RBAC permission denied)\n * - 404: Not Found (resource doesn't exist)\n * - 501: Not Implemented (capability gap, e.g. disabled storage domain, won't change)\n */\nconst HTTP_NO_RETRY_STATUSES = [400, 401, 403, 404, 501];\n\n/**\n * Check if error is a 401 Unauthorized response.\n * Indicates the user's session has expired or token is invalid.\n * Handles both direct status property and client-js error message format.\n */\nexport function is401UnauthorizedError(error: unknown): boolean {\n if (!error || typeof error !== 'object') return false;\n\n // Check for status property (direct response or wrapped)\n if ('status' in error && (error as { status: number }).status === 401) {\n return true;\n }\n\n // Check for statusCode property (some HTTP clients)\n if ('statusCode' in error && (error as { statusCode: number }).statusCode === 401) {\n return true;\n }\n\n // Check error message for client-js pattern: \"HTTP error! status: 401\"\n if ('message' in error) {\n const message = (error as { message: unknown }).message;\n if (typeof message === 'string') {\n return /\\bstatus:\\s*401\\b/.test(message);\n }\n }\n\n return false;\n}\n\n/**\n * Check if error is a 403 Forbidden response.\n * Handles both direct status property and client-js error message format.\n */\nexport function is403ForbiddenError(error: unknown): boolean {\n if (!error || typeof error !== 'object') return false;\n\n // Check for status property (direct response or wrapped)\n if ('status' in error && (error as { status: number }).status === 403) {\n return true;\n }\n\n // Check for statusCode property (some HTTP clients)\n if ('statusCode' in error && (error as { statusCode: number }).statusCode === 403) {\n return true;\n }\n\n // Check error message for client-js pattern: \"HTTP error! status: 403\"\n if ('message' in error) {\n const message = (error as { message: unknown }).message;\n if (typeof message === 'string') {\n return /\\bstatus:\\s*403\\b/.test(message);\n }\n }\n\n return false;\n}\n\n/**\n * Check if error is a 404 Not Found response.\n * Handles both direct status property and client-js error message format.\n */\nexport function is404NotFoundError(error: unknown): boolean {\n if (!error || typeof error !== 'object') return false;\n\n if ('status' in error && (error as { status: number }).status === 404) {\n return true;\n }\n\n if ('statusCode' in error && (error as { statusCode: number }).statusCode === 404) {\n return true;\n }\n\n if ('message' in error) {\n const message = (error as { message: unknown }).message;\n if (typeof message === 'string') {\n return /\\bstatus:\\s*404\\b/.test(message);\n }\n }\n\n return false;\n}\n\n/**\n * Check if an error came from a storage provider that does not implement `listBranches`.\n *\n * The server's `handleError` strips the original MastraError's `code`/`id` before serializing,\n * so we can't match on the ID `OBSERVABILITY_STORAGE_LIST_BRANCHES_NOT_IMPLEMENTED` directly —\n * we match on the message text from `core/.../observability/base.ts` instead.\n */\nexport function isBranchesNotSupportedError(error: unknown): boolean {\n if (!error || typeof error !== 'object' || !('message' in error)) return false;\n const message = (error as { message: unknown }).message;\n if (typeof message !== 'string') return false;\n return message.includes('does not support listing trace branches');\n}\n\nexport type UnsupportedObservabilityOperation = 'logs' | 'metrics' | 'scores' | 'feedback';\n\n/**\n * Check if an error came from an observability storage provider that does not\n * implement a list operation. These are capability gaps, not transient failures.\n *\n * The server serializes these as plain HTTP errors, so the original MastraError\n * ID is not available in the browser. Match the stable base-storage message text\n * instead, like the trace branch support check above.\n */\nexport function isUnsupportedObservabilityOperationError(\n error: unknown,\n operation: UnsupportedObservabilityOperation,\n): boolean {\n if (!error || typeof error !== 'object' || !('message' in error)) return false;\n const message = (error as { message: unknown }).message;\n if (typeof message !== 'string') return false;\n return message.includes(`does not support listing ${operation}`);\n}\n\n// Span scores are backed by the separate `scores` domain. Explicit list: many\n// unrelated server domains share the \"storage domain is not available\" suffix.\nconst OBSERVABILITY_UNAVAILABLE_MESSAGES = [\n 'Observability storage domain is not available',\n 'Scores storage domain is not available',\n];\n\n/** Check if an error came from a server whose observability storage domain is disabled. */\nexport function isObservabilityUnavailableError(error: unknown): boolean {\n if (!error || typeof error !== 'object' || !('message' in error)) return false;\n const message = (error as { message: unknown }).message;\n if (typeof message !== 'string') return false;\n return OBSERVABILITY_UNAVAILABLE_MESSAGES.some(m => message.includes(m));\n}\n\n/**\n * Check if error has a status code that shouldn't be retried.\n * Used to prevent retrying client errors that won't resolve.\n */\nexport function isNonRetryableError(error: unknown): boolean {\n if (!error || typeof error !== 'object') return false;\n\n // Check for status property\n if ('status' in error) {\n const status = (error as { status: number }).status;\n return HTTP_NO_RETRY_STATUSES.includes(status);\n }\n\n // Check for statusCode property\n if ('statusCode' in error) {\n const statusCode = (error as { statusCode: number }).statusCode;\n return HTTP_NO_RETRY_STATUSES.includes(statusCode);\n }\n\n // Check error message for client-js pattern\n if ('message' in error) {\n const message = (error as { message: unknown }).message;\n if (typeof message === 'string') {\n return HTTP_NO_RETRY_STATUSES.some(code => new RegExp(`\\\\bstatus:\\\\s*${code}\\\\b`).test(message));\n }\n }\n\n return false;\n}\n\n/**\n * Default retry function for TanStack Query.\n * Does not retry 4xx client errors (400, 401, 403, 404) or 501 capability gaps.\n * Retries other errors up to 3 times.\n */\nexport function shouldRetryQuery(failureCount: number, error: unknown): boolean {\n // Don't retry client errors - they won't resolve with retries\n if (isNonRetryableError(error)) {\n return false;\n }\n // Default: retry up to 3 times for transient errors\n return failureCount < 3;\n}\n"],"mappings":";;;;;;;;;AAQA,MAAM,yBAAyB;CAAC;CAAK;CAAK;CAAK;CAAK;AAAG;;;;;;AAOvD,SAAgB,uBAAuB,OAAyB;CAC9D,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAGhD,IAAI,YAAY,SAAU,MAA6B,WAAW,KAChE,OAAO;CAIT,IAAI,gBAAgB,SAAU,MAAiC,eAAe,KAC5E,OAAO;CAIT,IAAI,aAAa,OAAO;EACtB,MAAM,UAAW,MAA+B;EAChD,IAAI,OAAO,YAAY,UACrB,OAAO,oBAAoB,KAAK,OAAO;CAE3C;CAEA,OAAO;AACT;;;;;AAMA,SAAgB,oBAAoB,OAAyB;CAC3D,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAGhD,IAAI,YAAY,SAAU,MAA6B,WAAW,KAChE,OAAO;CAIT,IAAI,gBAAgB,SAAU,MAAiC,eAAe,KAC5E,OAAO;CAIT,IAAI,aAAa,OAAO;EACtB,MAAM,UAAW,MAA+B;EAChD,IAAI,OAAO,YAAY,UACrB,OAAO,oBAAoB,KAAK,OAAO;CAE3C;CAEA,OAAO;AACT;;;;;AAMA,SAAgB,mBAAmB,OAAyB;CAC1D,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAEhD,IAAI,YAAY,SAAU,MAA6B,WAAW,KAChE,OAAO;CAGT,IAAI,gBAAgB,SAAU,MAAiC,eAAe,KAC5E,OAAO;CAGT,IAAI,aAAa,OAAO;EACtB,MAAM,UAAW,MAA+B;EAChD,IAAI,OAAO,YAAY,UACrB,OAAO,oBAAoB,KAAK,OAAO;CAE3C;CAEA,OAAO;AACT;;;;;;;;AASA,SAAgB,4BAA4B,OAAyB;CACnE,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QAAQ,OAAO;CACzE,MAAM,UAAW,MAA+B;CAChD,IAAI,OAAO,YAAY,UAAU,OAAO;CACxC,OAAO,QAAQ,SAAS,yCAAyC;AACnE;;;;;;;;;AAYA,SAAgB,yCACd,OACA,WACS;CACT,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QAAQ,OAAO;CACzE,MAAM,UAAW,MAA+B;CAChD,IAAI,OAAO,YAAY,UAAU,OAAO;CACxC,OAAO,QAAQ,SAAS,4BAA4B,WAAW;AACjE;AAIA,MAAM,qCAAqC,CACzC,iDACA,wCACF;;AAGA,SAAgB,gCAAgC,OAAyB;CACvE,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QAAQ,OAAO;CACzE,MAAM,UAAW,MAA+B;CAChD,IAAI,OAAO,YAAY,UAAU,OAAO;CACxC,OAAO,mCAAmC,MAAK,MAAK,QAAQ,SAAS,CAAC,CAAC;AACzE;;;;;AAMA,SAAgB,oBAAoB,OAAyB;CAC3D,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAGhD,IAAI,YAAY,OAAO;EACrB,MAAM,SAAU,MAA6B;EAC7C,OAAO,uBAAuB,SAAS,MAAM;CAC/C;CAGA,IAAI,gBAAgB,OAAO;EACzB,MAAM,aAAc,MAAiC;EACrD,OAAO,uBAAuB,SAAS,UAAU;CACnD;CAGA,IAAI,aAAa,OAAO;EACtB,MAAM,UAAW,MAA+B;EAChD,IAAI,OAAO,YAAY,UACrB,OAAO,uBAAuB,MAAK,SAAQ,IAAI,OAAO,iBAAiB,KAAK,IAAI,CAAC,CAAC,KAAK,OAAO,CAAC;CAEnG;CAEA,OAAO;AACT;;;;;;AAOA,SAAgB,iBAAiB,cAAsB,OAAyB;CAE9E,IAAI,oBAAoB,KAAK,GAC3B,OAAO;CAGT,OAAO,eAAe;AACxB"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
//#region src/hooks/query/query-utils.ts
|
|
2
|
+
/**
|
|
3
|
+
* HTTP status codes that should not be retried.
|
|
4
|
+
* - 400: Bad Request (client error, won't change)
|
|
5
|
+
* - 401: Unauthorized (needs re-auth, not retry)
|
|
6
|
+
* - 403: Forbidden (RBAC permission denied)
|
|
7
|
+
* - 404: Not Found (resource doesn't exist)
|
|
8
|
+
* - 501: Not Implemented (capability gap, e.g. disabled storage domain, won't change)
|
|
9
|
+
*/
|
|
10
|
+
const HTTP_NO_RETRY_STATUSES = [
|
|
11
|
+
400,
|
|
12
|
+
401,
|
|
13
|
+
403,
|
|
14
|
+
404,
|
|
15
|
+
501
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* Check if error is a 401 Unauthorized response.
|
|
19
|
+
* Indicates the user's session has expired or token is invalid.
|
|
20
|
+
* Handles both direct status property and client-js error message format.
|
|
21
|
+
*/
|
|
22
|
+
function is401UnauthorizedError(error) {
|
|
23
|
+
if (!error || typeof error !== "object") return false;
|
|
24
|
+
if ("status" in error && error.status === 401) return true;
|
|
25
|
+
if ("statusCode" in error && error.statusCode === 401) return true;
|
|
26
|
+
if ("message" in error) {
|
|
27
|
+
const message = error.message;
|
|
28
|
+
if (typeof message === "string") return /\bstatus:\s*401\b/.test(message);
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Check if error is a 403 Forbidden response.
|
|
34
|
+
* Handles both direct status property and client-js error message format.
|
|
35
|
+
*/
|
|
36
|
+
function is403ForbiddenError(error) {
|
|
37
|
+
if (!error || typeof error !== "object") return false;
|
|
38
|
+
if ("status" in error && error.status === 403) return true;
|
|
39
|
+
if ("statusCode" in error && error.statusCode === 403) return true;
|
|
40
|
+
if ("message" in error) {
|
|
41
|
+
const message = error.message;
|
|
42
|
+
if (typeof message === "string") return /\bstatus:\s*403\b/.test(message);
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Check if error is a 404 Not Found response.
|
|
48
|
+
* Handles both direct status property and client-js error message format.
|
|
49
|
+
*/
|
|
50
|
+
function is404NotFoundError(error) {
|
|
51
|
+
if (!error || typeof error !== "object") return false;
|
|
52
|
+
if ("status" in error && error.status === 404) return true;
|
|
53
|
+
if ("statusCode" in error && error.statusCode === 404) return true;
|
|
54
|
+
if ("message" in error) {
|
|
55
|
+
const message = error.message;
|
|
56
|
+
if (typeof message === "string") return /\bstatus:\s*404\b/.test(message);
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Check if an error came from a storage provider that does not implement `listBranches`.
|
|
62
|
+
*
|
|
63
|
+
* The server's `handleError` strips the original MastraError's `code`/`id` before serializing,
|
|
64
|
+
* so we can't match on the ID `OBSERVABILITY_STORAGE_LIST_BRANCHES_NOT_IMPLEMENTED` directly —
|
|
65
|
+
* we match on the message text from `core/.../observability/base.ts` instead.
|
|
66
|
+
*/
|
|
67
|
+
function isBranchesNotSupportedError(error) {
|
|
68
|
+
if (!error || typeof error !== "object" || !("message" in error)) return false;
|
|
69
|
+
const message = error.message;
|
|
70
|
+
if (typeof message !== "string") return false;
|
|
71
|
+
return message.includes("does not support listing trace branches");
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check if an error came from an observability storage provider that does not
|
|
75
|
+
* implement a list operation. These are capability gaps, not transient failures.
|
|
76
|
+
*
|
|
77
|
+
* The server serializes these as plain HTTP errors, so the original MastraError
|
|
78
|
+
* ID is not available in the browser. Match the stable base-storage message text
|
|
79
|
+
* instead, like the trace branch support check above.
|
|
80
|
+
*/
|
|
81
|
+
function isUnsupportedObservabilityOperationError(error, operation) {
|
|
82
|
+
if (!error || typeof error !== "object" || !("message" in error)) return false;
|
|
83
|
+
const message = error.message;
|
|
84
|
+
if (typeof message !== "string") return false;
|
|
85
|
+
return message.includes(`does not support listing ${operation}`);
|
|
86
|
+
}
|
|
87
|
+
const OBSERVABILITY_UNAVAILABLE_MESSAGES = ["Observability storage domain is not available", "Scores storage domain is not available"];
|
|
88
|
+
/** Check if an error came from a server whose observability storage domain is disabled. */
|
|
89
|
+
function isObservabilityUnavailableError(error) {
|
|
90
|
+
if (!error || typeof error !== "object" || !("message" in error)) return false;
|
|
91
|
+
const message = error.message;
|
|
92
|
+
if (typeof message !== "string") return false;
|
|
93
|
+
return OBSERVABILITY_UNAVAILABLE_MESSAGES.some((m) => message.includes(m));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Check if error has a status code that shouldn't be retried.
|
|
97
|
+
* Used to prevent retrying client errors that won't resolve.
|
|
98
|
+
*/
|
|
99
|
+
function isNonRetryableError(error) {
|
|
100
|
+
if (!error || typeof error !== "object") return false;
|
|
101
|
+
if ("status" in error) {
|
|
102
|
+
const status = error.status;
|
|
103
|
+
return HTTP_NO_RETRY_STATUSES.includes(status);
|
|
104
|
+
}
|
|
105
|
+
if ("statusCode" in error) {
|
|
106
|
+
const statusCode = error.statusCode;
|
|
107
|
+
return HTTP_NO_RETRY_STATUSES.includes(statusCode);
|
|
108
|
+
}
|
|
109
|
+
if ("message" in error) {
|
|
110
|
+
const message = error.message;
|
|
111
|
+
if (typeof message === "string") return HTTP_NO_RETRY_STATUSES.some((code) => new RegExp(`\\bstatus:\\s*${code}\\b`).test(message));
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Default retry function for TanStack Query.
|
|
117
|
+
* Does not retry 4xx client errors (400, 401, 403, 404) or 501 capability gaps.
|
|
118
|
+
* Retries other errors up to 3 times.
|
|
119
|
+
*/
|
|
120
|
+
function shouldRetryQuery(failureCount, error) {
|
|
121
|
+
if (isNonRetryableError(error)) return false;
|
|
122
|
+
return failureCount < 3;
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { isNonRetryableError as a, shouldRetryQuery as c, isBranchesNotSupportedError as i, is403ForbiddenError as n, isObservabilityUnavailableError as o, is404NotFoundError as r, isUnsupportedObservabilityOperationError as s, is401UnauthorizedError as t };
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=query-utils-D1NgFnWU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-utils-D1NgFnWU.js","names":[],"sources":["../src/hooks/query/query-utils.ts"],"sourcesContent":["/**\n * HTTP status codes that should not be retried.\n * - 400: Bad Request (client error, won't change)\n * - 401: Unauthorized (needs re-auth, not retry)\n * - 403: Forbidden (RBAC permission denied)\n * - 404: Not Found (resource doesn't exist)\n * - 501: Not Implemented (capability gap, e.g. disabled storage domain, won't change)\n */\nconst HTTP_NO_RETRY_STATUSES = [400, 401, 403, 404, 501];\n\n/**\n * Check if error is a 401 Unauthorized response.\n * Indicates the user's session has expired or token is invalid.\n * Handles both direct status property and client-js error message format.\n */\nexport function is401UnauthorizedError(error: unknown): boolean {\n if (!error || typeof error !== 'object') return false;\n\n // Check for status property (direct response or wrapped)\n if ('status' in error && (error as { status: number }).status === 401) {\n return true;\n }\n\n // Check for statusCode property (some HTTP clients)\n if ('statusCode' in error && (error as { statusCode: number }).statusCode === 401) {\n return true;\n }\n\n // Check error message for client-js pattern: \"HTTP error! status: 401\"\n if ('message' in error) {\n const message = (error as { message: unknown }).message;\n if (typeof message === 'string') {\n return /\\bstatus:\\s*401\\b/.test(message);\n }\n }\n\n return false;\n}\n\n/**\n * Check if error is a 403 Forbidden response.\n * Handles both direct status property and client-js error message format.\n */\nexport function is403ForbiddenError(error: unknown): boolean {\n if (!error || typeof error !== 'object') return false;\n\n // Check for status property (direct response or wrapped)\n if ('status' in error && (error as { status: number }).status === 403) {\n return true;\n }\n\n // Check for statusCode property (some HTTP clients)\n if ('statusCode' in error && (error as { statusCode: number }).statusCode === 403) {\n return true;\n }\n\n // Check error message for client-js pattern: \"HTTP error! status: 403\"\n if ('message' in error) {\n const message = (error as { message: unknown }).message;\n if (typeof message === 'string') {\n return /\\bstatus:\\s*403\\b/.test(message);\n }\n }\n\n return false;\n}\n\n/**\n * Check if error is a 404 Not Found response.\n * Handles both direct status property and client-js error message format.\n */\nexport function is404NotFoundError(error: unknown): boolean {\n if (!error || typeof error !== 'object') return false;\n\n if ('status' in error && (error as { status: number }).status === 404) {\n return true;\n }\n\n if ('statusCode' in error && (error as { statusCode: number }).statusCode === 404) {\n return true;\n }\n\n if ('message' in error) {\n const message = (error as { message: unknown }).message;\n if (typeof message === 'string') {\n return /\\bstatus:\\s*404\\b/.test(message);\n }\n }\n\n return false;\n}\n\n/**\n * Check if an error came from a storage provider that does not implement `listBranches`.\n *\n * The server's `handleError` strips the original MastraError's `code`/`id` before serializing,\n * so we can't match on the ID `OBSERVABILITY_STORAGE_LIST_BRANCHES_NOT_IMPLEMENTED` directly —\n * we match on the message text from `core/.../observability/base.ts` instead.\n */\nexport function isBranchesNotSupportedError(error: unknown): boolean {\n if (!error || typeof error !== 'object' || !('message' in error)) return false;\n const message = (error as { message: unknown }).message;\n if (typeof message !== 'string') return false;\n return message.includes('does not support listing trace branches');\n}\n\nexport type UnsupportedObservabilityOperation = 'logs' | 'metrics' | 'scores' | 'feedback';\n\n/**\n * Check if an error came from an observability storage provider that does not\n * implement a list operation. These are capability gaps, not transient failures.\n *\n * The server serializes these as plain HTTP errors, so the original MastraError\n * ID is not available in the browser. Match the stable base-storage message text\n * instead, like the trace branch support check above.\n */\nexport function isUnsupportedObservabilityOperationError(\n error: unknown,\n operation: UnsupportedObservabilityOperation,\n): boolean {\n if (!error || typeof error !== 'object' || !('message' in error)) return false;\n const message = (error as { message: unknown }).message;\n if (typeof message !== 'string') return false;\n return message.includes(`does not support listing ${operation}`);\n}\n\n// Span scores are backed by the separate `scores` domain. Explicit list: many\n// unrelated server domains share the \"storage domain is not available\" suffix.\nconst OBSERVABILITY_UNAVAILABLE_MESSAGES = [\n 'Observability storage domain is not available',\n 'Scores storage domain is not available',\n];\n\n/** Check if an error came from a server whose observability storage domain is disabled. */\nexport function isObservabilityUnavailableError(error: unknown): boolean {\n if (!error || typeof error !== 'object' || !('message' in error)) return false;\n const message = (error as { message: unknown }).message;\n if (typeof message !== 'string') return false;\n return OBSERVABILITY_UNAVAILABLE_MESSAGES.some(m => message.includes(m));\n}\n\n/**\n * Check if error has a status code that shouldn't be retried.\n * Used to prevent retrying client errors that won't resolve.\n */\nexport function isNonRetryableError(error: unknown): boolean {\n if (!error || typeof error !== 'object') return false;\n\n // Check for status property\n if ('status' in error) {\n const status = (error as { status: number }).status;\n return HTTP_NO_RETRY_STATUSES.includes(status);\n }\n\n // Check for statusCode property\n if ('statusCode' in error) {\n const statusCode = (error as { statusCode: number }).statusCode;\n return HTTP_NO_RETRY_STATUSES.includes(statusCode);\n }\n\n // Check error message for client-js pattern\n if ('message' in error) {\n const message = (error as { message: unknown }).message;\n if (typeof message === 'string') {\n return HTTP_NO_RETRY_STATUSES.some(code => new RegExp(`\\\\bstatus:\\\\s*${code}\\\\b`).test(message));\n }\n }\n\n return false;\n}\n\n/**\n * Default retry function for TanStack Query.\n * Does not retry 4xx client errors (400, 401, 403, 404) or 501 capability gaps.\n * Retries other errors up to 3 times.\n */\nexport function shouldRetryQuery(failureCount: number, error: unknown): boolean {\n // Don't retry client errors - they won't resolve with retries\n if (isNonRetryableError(error)) {\n return false;\n }\n // Default: retry up to 3 times for transient errors\n return failureCount < 3;\n}\n"],"mappings":";;;;;;;;;AAQA,MAAM,yBAAyB;CAAC;CAAK;CAAK;CAAK;CAAK;AAAG;;;;;;AAOvD,SAAgB,uBAAuB,OAAyB;CAC9D,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAGhD,IAAI,YAAY,SAAU,MAA6B,WAAW,KAChE,OAAO;CAIT,IAAI,gBAAgB,SAAU,MAAiC,eAAe,KAC5E,OAAO;CAIT,IAAI,aAAa,OAAO;EACtB,MAAM,UAAW,MAA+B;EAChD,IAAI,OAAO,YAAY,UACrB,OAAO,oBAAoB,KAAK,OAAO;CAE3C;CAEA,OAAO;AACT;;;;;AAMA,SAAgB,oBAAoB,OAAyB;CAC3D,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAGhD,IAAI,YAAY,SAAU,MAA6B,WAAW,KAChE,OAAO;CAIT,IAAI,gBAAgB,SAAU,MAAiC,eAAe,KAC5E,OAAO;CAIT,IAAI,aAAa,OAAO;EACtB,MAAM,UAAW,MAA+B;EAChD,IAAI,OAAO,YAAY,UACrB,OAAO,oBAAoB,KAAK,OAAO;CAE3C;CAEA,OAAO;AACT;;;;;AAMA,SAAgB,mBAAmB,OAAyB;CAC1D,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAEhD,IAAI,YAAY,SAAU,MAA6B,WAAW,KAChE,OAAO;CAGT,IAAI,gBAAgB,SAAU,MAAiC,eAAe,KAC5E,OAAO;CAGT,IAAI,aAAa,OAAO;EACtB,MAAM,UAAW,MAA+B;EAChD,IAAI,OAAO,YAAY,UACrB,OAAO,oBAAoB,KAAK,OAAO;CAE3C;CAEA,OAAO;AACT;;;;;;;;AASA,SAAgB,4BAA4B,OAAyB;CACnE,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QAAQ,OAAO;CACzE,MAAM,UAAW,MAA+B;CAChD,IAAI,OAAO,YAAY,UAAU,OAAO;CACxC,OAAO,QAAQ,SAAS,yCAAyC;AACnE;;;;;;;;;AAYA,SAAgB,yCACd,OACA,WACS;CACT,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QAAQ,OAAO;CACzE,MAAM,UAAW,MAA+B;CAChD,IAAI,OAAO,YAAY,UAAU,OAAO;CACxC,OAAO,QAAQ,SAAS,4BAA4B,WAAW;AACjE;AAIA,MAAM,qCAAqC,CACzC,iDACA,wCACF;;AAGA,SAAgB,gCAAgC,OAAyB;CACvE,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,EAAE,aAAa,QAAQ,OAAO;CACzE,MAAM,UAAW,MAA+B;CAChD,IAAI,OAAO,YAAY,UAAU,OAAO;CACxC,OAAO,mCAAmC,MAAK,MAAK,QAAQ,SAAS,CAAC,CAAC;AACzE;;;;;AAMA,SAAgB,oBAAoB,OAAyB;CAC3D,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAGhD,IAAI,YAAY,OAAO;EACrB,MAAM,SAAU,MAA6B;EAC7C,OAAO,uBAAuB,SAAS,MAAM;CAC/C;CAGA,IAAI,gBAAgB,OAAO;EACzB,MAAM,aAAc,MAAiC;EACrD,OAAO,uBAAuB,SAAS,UAAU;CACnD;CAGA,IAAI,aAAa,OAAO;EACtB,MAAM,UAAW,MAA+B;EAChD,IAAI,OAAO,YAAY,UACrB,OAAO,uBAAuB,MAAK,SAAQ,IAAI,OAAO,iBAAiB,KAAK,IAAI,CAAC,CAAC,KAAK,OAAO,CAAC;CAEnG;CAEA,OAAO;AACT;;;;;;AAOA,SAAgB,iBAAiB,cAAsB,OAAyB;CAE9E,IAAI,oBAAoB,KAAK,GAC3B,OAAO;CAGT,OAAO,eAAe;AACxB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
let react = require("react");
|
|
2
|
+
//#region src/hooks/shared/use-in-view.ts
|
|
3
|
+
/**
|
|
4
|
+
* Tracks whether or not the given element is currently in view.
|
|
5
|
+
* This is to replace framer-motion's `useInView` which has issues
|
|
6
|
+
* tracking a ref that is set at a time other than mount.
|
|
7
|
+
*
|
|
8
|
+
* The observer is created in an effect (not in the callback ref) so that an
|
|
9
|
+
* ancestor `root` ref, which React assigns after descendant refs, is already
|
|
10
|
+
* populated when the observer is constructed.
|
|
11
|
+
*/
|
|
12
|
+
const useInView = ({ root } = {}) => {
|
|
13
|
+
const [inView, setInView] = (0, react.useState)(false);
|
|
14
|
+
const [node, setRef] = (0, react.useState)(null);
|
|
15
|
+
(0, react.useEffect)(() => {
|
|
16
|
+
if (!node) return;
|
|
17
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
18
|
+
if (!entry) return;
|
|
19
|
+
setInView(entry.isIntersecting);
|
|
20
|
+
}, { root: root?.current ?? null });
|
|
21
|
+
observer.observe(node);
|
|
22
|
+
return () => observer.disconnect();
|
|
23
|
+
}, [node, root]);
|
|
24
|
+
return {
|
|
25
|
+
inView,
|
|
26
|
+
setRef
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
Object.defineProperty(exports, "useInView", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function() {
|
|
33
|
+
return useInView;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=use-in-view-B6eJO9Zi.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-in-view-B6eJO9Zi.cjs","names":[],"sources":["../src/hooks/shared/use-in-view.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport { useEffect, useState } from 'react';\n\nexport type UseInViewOptions = {\n /**\n * Scroll container to observe against. When omitted, the browser viewport is used.\n * Pass the list's own scroll viewport so the sentinel only fires when scrolled\n * into view inside that container.\n */\n root?: RefObject<HTMLElement | null>;\n};\n\n/**\n * Tracks whether or not the given element is currently in view.\n * This is to replace framer-motion's `useInView` which has issues\n * tracking a ref that is set at a time other than mount.\n *\n * The observer is created in an effect (not in the callback ref) so that an\n * ancestor `root` ref, which React assigns after descendant refs, is already\n * populated when the observer is constructed.\n */\nexport const useInView = ({ root }: UseInViewOptions = {}) => {\n const [inView, setInView] = useState(false);\n const [node, setRef] = useState<HTMLDivElement | null>(null);\n\n useEffect(() => {\n if (!node) return;\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (!entry) return;\n setInView(entry.isIntersecting);\n },\n { root: root?.current ?? null },\n );\n observer.observe(node);\n return () => observer.disconnect();\n }, [node, root]);\n\n return { inView, setRef };\n};\n"],"mappings":";;;;;;;;;;;AAqBA,MAAa,aAAa,EAAE,SAA2B,CAAC,MAAM;CAC5D,MAAM,CAAC,QAAQ,cAAA,GAAA,MAAA,SAAA,CAAsB,KAAK;CAC1C,MAAM,CAAC,MAAM,WAAA,GAAA,MAAA,SAAA,CAA0C,IAAI;CAE3D,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,CAAC,MAAM;EAEX,MAAM,WAAW,IAAI,sBAClB,CAAC,WAAW;GACX,IAAI,CAAC,OAAO;GACZ,UAAU,MAAM,cAAc;EAChC,GACA,EAAE,MAAM,MAAM,WAAW,KAAK,CAChC;EACA,SAAS,QAAQ,IAAI;EACrB,aAAa,SAAS,WAAW;CACnC,GAAG,CAAC,MAAM,IAAI,CAAC;CAEf,OAAO;EAAE;EAAQ;CAAO;AAC1B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
//#region src/hooks/shared/use-in-view.ts
|
|
3
|
+
/**
|
|
4
|
+
* Tracks whether or not the given element is currently in view.
|
|
5
|
+
* This is to replace framer-motion's `useInView` which has issues
|
|
6
|
+
* tracking a ref that is set at a time other than mount.
|
|
7
|
+
*
|
|
8
|
+
* The observer is created in an effect (not in the callback ref) so that an
|
|
9
|
+
* ancestor `root` ref, which React assigns after descendant refs, is already
|
|
10
|
+
* populated when the observer is constructed.
|
|
11
|
+
*/
|
|
12
|
+
const useInView = ({ root } = {}) => {
|
|
13
|
+
const [inView, setInView] = useState(false);
|
|
14
|
+
const [node, setRef] = useState(null);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!node) return;
|
|
17
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
18
|
+
if (!entry) return;
|
|
19
|
+
setInView(entry.isIntersecting);
|
|
20
|
+
}, { root: root?.current ?? null });
|
|
21
|
+
observer.observe(node);
|
|
22
|
+
return () => observer.disconnect();
|
|
23
|
+
}, [node, root]);
|
|
24
|
+
return {
|
|
25
|
+
inView,
|
|
26
|
+
setRef
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { useInView as t };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=use-in-view-C9sYPGRm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-in-view-C9sYPGRm.js","names":[],"sources":["../src/hooks/shared/use-in-view.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport { useEffect, useState } from 'react';\n\nexport type UseInViewOptions = {\n /**\n * Scroll container to observe against. When omitted, the browser viewport is used.\n * Pass the list's own scroll viewport so the sentinel only fires when scrolled\n * into view inside that container.\n */\n root?: RefObject<HTMLElement | null>;\n};\n\n/**\n * Tracks whether or not the given element is currently in view.\n * This is to replace framer-motion's `useInView` which has issues\n * tracking a ref that is set at a time other than mount.\n *\n * The observer is created in an effect (not in the callback ref) so that an\n * ancestor `root` ref, which React assigns after descendant refs, is already\n * populated when the observer is constructed.\n */\nexport const useInView = ({ root }: UseInViewOptions = {}) => {\n const [inView, setInView] = useState(false);\n const [node, setRef] = useState<HTMLDivElement | null>(null);\n\n useEffect(() => {\n if (!node) return;\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (!entry) return;\n setInView(entry.isIntersecting);\n },\n { root: root?.current ?? null },\n );\n observer.observe(node);\n return () => observer.disconnect();\n }, [node, root]);\n\n return { inView, setRef };\n};\n"],"mappings":";;;;;;;;;;;AAqBA,MAAa,aAAa,EAAE,SAA2B,CAAC,MAAM;CAC5D,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAC1C,MAAM,CAAC,MAAM,UAAU,SAAgC,IAAI;CAE3D,gBAAgB;EACd,IAAI,CAAC,MAAM;EAEX,MAAM,WAAW,IAAI,sBAClB,CAAC,WAAW;GACX,IAAI,CAAC,OAAO;GACZ,UAAU,MAAM,cAAc;EAChC,GACA,EAAE,MAAM,MAAM,WAAW,KAAK,CAChC;EACA,SAAS,QAAQ,IAAI;EACrB,aAAa,SAAS,WAAW;CACnC,GAAG,CAAC,MAAM,IAAI,CAAC;CAEf,OAAO;EAAE;EAAQ;CAAO;AAC1B"}
|