@compose-market/theme 0.0.1 → 0.0.3
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/components/RFAComponent.d.ts +10 -0
- package/dist/components/RFAComponent.d.ts.map +1 -0
- package/dist/components/RFAComponent.js +288 -0
- package/dist/components/RFAComponent.js.map +1 -0
- package/dist/components/RFADetails.d.ts +9 -0
- package/dist/components/RFADetails.d.ts.map +1 -0
- package/dist/components/RFADetails.js +407 -0
- package/dist/components/RFADetails.js.map +1 -0
- package/dist/components/agent-card.d.ts +8 -0
- package/dist/components/agent-card.d.ts.map +1 -0
- package/dist/components/agent-card.js +216 -0
- package/dist/components/agent-card.js.map +1 -0
- package/dist/components/backpack.d.ts +21 -0
- package/dist/components/backpack.d.ts.map +1 -0
- package/dist/components/backpack.js +905 -0
- package/dist/components/backpack.js.map +1 -0
- package/dist/components/blur.d.ts +9 -0
- package/dist/components/blur.d.ts.map +1 -0
- package/dist/components/blur.js +60 -0
- package/dist/components/blur.js.map +1 -0
- package/dist/components/brand/Logo.d.ts +25 -0
- package/dist/components/brand/Logo.d.ts.map +1 -0
- package/dist/components/brand/Logo.js +53 -0
- package/dist/components/brand/Logo.js.map +1 -0
- package/dist/components/brand/index.d.ts +2 -0
- package/dist/components/brand/index.d.ts.map +1 -0
- package/dist/components/brand/index.js +2 -0
- package/dist/components/brand/index.js.map +1 -0
- package/dist/components/chat.d.ts +68 -0
- package/dist/components/chat.d.ts.map +1 -0
- package/dist/components/chat.js +618 -0
- package/dist/components/chat.js.map +1 -0
- package/dist/components/compose/index.d.ts +10 -0
- package/dist/components/compose/index.d.ts.map +1 -0
- package/dist/components/compose/index.js +13 -0
- package/dist/components/compose/index.js.map +1 -0
- package/dist/components/compose/nodes/agent-node.d.ts +11 -0
- package/dist/components/compose/nodes/agent-node.d.ts.map +1 -0
- package/dist/components/compose/nodes/agent-node.js +101 -0
- package/dist/components/compose/nodes/agent-node.js.map +1 -0
- package/dist/components/compose/nodes/hook-node.d.ts +11 -0
- package/dist/components/compose/nodes/hook-node.d.ts.map +1 -0
- package/dist/components/compose/nodes/hook-node.js +100 -0
- package/dist/components/compose/nodes/hook-node.js.map +1 -0
- package/dist/components/compose/nodes/index.d.ts +60 -0
- package/dist/components/compose/nodes/index.d.ts.map +1 -0
- package/dist/components/compose/nodes/index.js +22 -0
- package/dist/components/compose/nodes/index.js.map +1 -0
- package/dist/components/compose/nodes/step-node.d.ts +11 -0
- package/dist/components/compose/nodes/step-node.d.ts.map +1 -0
- package/dist/components/compose/nodes/step-node.js +88 -0
- package/dist/components/compose/nodes/step-node.js.map +1 -0
- package/dist/components/compose/nodes/trigger-node.d.ts +11 -0
- package/dist/components/compose/nodes/trigger-node.d.ts.map +1 -0
- package/dist/components/compose/nodes/trigger-node.js +92 -0
- package/dist/components/compose/nodes/trigger-node.js.map +1 -0
- package/dist/components/compose/overlay.d.ts +26 -0
- package/dist/components/compose/overlay.d.ts.map +1 -0
- package/dist/components/compose/overlay.js +48 -0
- package/dist/components/compose/overlay.js.map +1 -0
- package/dist/components/compose/pickers/agents-picker.d.ts +18 -0
- package/dist/components/compose/pickers/agents-picker.d.ts.map +1 -0
- package/dist/components/compose/pickers/agents-picker.js +180 -0
- package/dist/components/compose/pickers/agents-picker.js.map +1 -0
- package/dist/components/compose/pickers/connector-detail.d.ts +16 -0
- package/dist/components/compose/pickers/connector-detail.d.ts.map +1 -0
- package/dist/components/compose/pickers/connector-detail.js +236 -0
- package/dist/components/compose/pickers/connector-detail.js.map +1 -0
- package/dist/components/compose/pickers/connector-picker.d.ts +13 -0
- package/dist/components/compose/pickers/connector-picker.d.ts.map +1 -0
- package/dist/components/compose/pickers/connector-picker.js +101 -0
- package/dist/components/compose/pickers/connector-picker.js.map +1 -0
- package/dist/components/compose/pickers/index.d.ts +10 -0
- package/dist/components/compose/pickers/index.d.ts.map +1 -0
- package/dist/components/compose/pickers/index.js +10 -0
- package/dist/components/compose/pickers/index.js.map +1 -0
- package/dist/components/compose/pickers/trigger-picker.d.ts +13 -0
- package/dist/components/compose/pickers/trigger-picker.d.ts.map +1 -0
- package/dist/components/compose/pickers/trigger-picker.js +110 -0
- package/dist/components/compose/pickers/trigger-picker.js.map +1 -0
- package/dist/components/compose/toolbox.d.ts +24 -0
- package/dist/components/compose/toolbox.d.ts.map +1 -0
- package/dist/components/compose/toolbox.js +183 -0
- package/dist/components/compose/toolbox.js.map +1 -0
- package/dist/components/connector.d.ts +24 -0
- package/dist/components/connector.d.ts.map +1 -0
- package/dist/components/connector.js +263 -0
- package/dist/components/connector.js.map +1 -0
- package/dist/components/dispenser.d.ts +15 -0
- package/dist/components/dispenser.d.ts.map +1 -0
- package/dist/components/dispenser.js +323 -0
- package/dist/components/dispenser.js.map +1 -0
- package/dist/components/layout/AppLayout.d.ts +60 -0
- package/dist/components/layout/AppLayout.d.ts.map +1 -0
- package/dist/components/layout/AppLayout.js +265 -0
- package/dist/components/layout/AppLayout.js.map +1 -0
- package/dist/components/layout/Layout.d.ts +6 -0
- package/dist/components/layout/Layout.d.ts.map +1 -0
- package/dist/components/layout/Layout.js +186 -0
- package/dist/components/layout/Layout.js.map +1 -0
- package/dist/components/layout/Sidebar.d.ts +3 -0
- package/dist/components/layout/Sidebar.d.ts.map +1 -0
- package/dist/components/layout/Sidebar.js +160 -0
- package/dist/components/layout/Sidebar.js.map +1 -0
- package/dist/components/layout/TopBar.d.ts +6 -0
- package/dist/components/layout/TopBar.d.ts.map +1 -0
- package/dist/components/layout/TopBar.js +36 -0
- package/dist/components/layout/TopBar.js.map +1 -0
- package/dist/components/layout/index.d.ts +2 -0
- package/dist/components/layout/index.d.ts.map +1 -0
- package/dist/components/layout/index.js +2 -0
- package/dist/components/layout/index.js.map +1 -0
- package/dist/components/lyria-player.d.ts +23 -0
- package/dist/components/lyria-player.d.ts.map +1 -0
- package/dist/components/lyria-player.js +241 -0
- package/dist/components/lyria-player.js.map +1 -0
- package/dist/components/manowar-card.d.ts +8 -0
- package/dist/components/manowar-card.d.ts.map +1 -0
- package/dist/components/manowar-card.js +349 -0
- package/dist/components/manowar-card.js.map +1 -0
- package/dist/components/mirror-pane.d.ts +55 -0
- package/dist/components/mirror-pane.d.ts.map +1 -0
- package/dist/components/mirror-pane.js +330 -0
- package/dist/components/mirror-pane.js.map +1 -0
- package/dist/components/model-selector.d.ts +12 -0
- package/dist/components/model-selector.d.ts.map +1 -0
- package/dist/components/model-selector.js +148 -0
- package/dist/components/model-selector.js.map +1 -0
- package/dist/components/output.d.ts +26 -0
- package/dist/components/output.d.ts.map +1 -0
- package/dist/components/output.js +259 -0
- package/dist/components/output.js.map +1 -0
- package/dist/components/partners.d.ts +13 -0
- package/dist/components/partners.d.ts.map +1 -0
- package/dist/components/partners.js +210 -0
- package/dist/components/partners.js.map +1 -0
- package/dist/components/plugin-tester.d.ts +13 -0
- package/dist/components/plugin-tester.d.ts.map +1 -0
- package/dist/components/plugin-tester.js +907 -0
- package/dist/components/plugin-tester.js.map +1 -0
- package/dist/components/session/SessionComponents.d.ts +2 -0
- package/dist/components/session/SessionComponents.d.ts.map +1 -0
- package/dist/components/session/SessionComponents.js +2 -0
- package/dist/components/session/SessionComponents.js.map +1 -0
- package/dist/components/session/index.d.ts +2 -0
- package/dist/components/session/index.d.ts.map +1 -0
- package/dist/components/session/index.js +2 -0
- package/dist/components/session/index.js.map +1 -0
- package/dist/components/session.d.ts +58 -0
- package/dist/components/session.d.ts.map +1 -0
- package/dist/components/session.js +580 -0
- package/dist/components/session.js.map +1 -0
- package/dist/components/share-dialog.d.ts +9 -0
- package/dist/components/share-dialog.d.ts.map +1 -0
- package/dist/components/share-dialog.js +49 -0
- package/dist/components/share-dialog.js.map +1 -0
- package/dist/components/ui/accordion.d.ts +6 -0
- package/dist/components/ui/accordion.d.ts.map +1 -0
- package/dist/components/ui/accordion.js +20 -0
- package/dist/components/ui/accordion.js.map +1 -0
- package/dist/components/ui/alert-dialog.d.ts +20 -0
- package/dist/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/components/ui/alert-dialog.js +29 -0
- package/dist/components/ui/alert-dialog.js.map +1 -0
- package/dist/components/ui/alert.d.ts +5 -0
- package/dist/components/ui/alert.d.ts.map +1 -0
- package/dist/components/ui/alert.js +22 -0
- package/dist/components/ui/alert.js.map +1 -0
- package/dist/components/ui/aspect-ratio.d.ts +3 -0
- package/dist/components/ui/aspect-ratio.d.ts.map +1 -0
- package/dist/components/ui/aspect-ratio.js +4 -0
- package/dist/components/ui/aspect-ratio.js.map +1 -0
- package/dist/components/ui/avatar.d.ts +5 -0
- package/dist/components/ui/avatar.d.ts.map +1 -0
- package/dist/components/ui/avatar.js +12 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/badge.d.ts +8 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/badge.js +24 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/breadcrumb.d.ts +16 -0
- package/dist/components/ui/breadcrumb.d.ts.map +1 -0
- package/dist/components/ui/breadcrumb.js +28 -0
- package/dist/components/ui/breadcrumb.js.map +1 -0
- package/dist/components/ui/button-group.d.ts +10 -0
- package/dist/components/ui/button-group.d.ts.map +1 -0
- package/dist/components/ui/button-group.js +27 -0
- package/dist/components/ui/button-group.js.map +1 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +42 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/calendar.d.ts +9 -0
- package/dist/components/ui/calendar.d.ts.map +1 -0
- package/dist/components/ui/calendar.js +78 -0
- package/dist/components/ui/calendar.js.map +1 -0
- package/dist/components/ui/card.d.ts +8 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/card.js +17 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/carousel.d.ts +9 -0
- package/dist/components/ui/carousel.d.ts.map +1 -0
- package/dist/components/ui/carousel.js +110 -0
- package/dist/components/ui/carousel.js.map +1 -0
- package/dist/components/ui/chart.d.ts +28 -0
- package/dist/components/ui/chart.d.ts.map +1 -0
- package/dist/components/ui/chart.js +168 -0
- package/dist/components/ui/chart.js.map +1 -0
- package/dist/components/ui/checkbox.d.ts +3 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/checkbox.js +12 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/collapsible.d.ts.map +1 -0
- package/dist/components/ui/collapsible.js +7 -0
- package/dist/components/ui/collapsible.js.map +1 -0
- package/dist/components/ui/command.d.ts +16 -0
- package/dist/components/ui/command.d.ts.map +1 -0
- package/dist/components/ui/command.js +38 -0
- package/dist/components/ui/command.js.map +1 -0
- package/dist/components/ui/context-menu.d.ts +21 -0
- package/dist/components/ui/context-menu.d.ts.map +1 -0
- package/dist/components/ui/context-menu.js +52 -0
- package/dist/components/ui/context-menu.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +19 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dialog.js +31 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/drawer.d.ts +23 -0
- package/dist/components/ui/drawer.d.ts.map +1 -0
- package/dist/components/ui/drawer.js +28 -0
- package/dist/components/ui/drawer.js.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +21 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.js +55 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/empty.d.ts +10 -0
- package/dist/components/ui/empty.d.ts.map +1 -0
- package/dist/components/ui/empty.js +33 -0
- package/dist/components/ui/empty.js.map +1 -0
- package/dist/components/ui/field.d.ts +23 -0
- package/dist/components/ui/field.d.ts.map +1 -0
- package/dist/components/ui/field.js +82 -0
- package/dist/components/ui/field.js.map +1 -0
- package/dist/components/ui/form.d.ts +11 -0
- package/dist/components/ui/form.d.ts.map +1 -0
- package/dist/components/ui/form.js +71 -0
- package/dist/components/ui/form.js.map +1 -0
- package/dist/components/ui/hover-card.d.ts +5 -0
- package/dist/components/ui/hover-card.d.ts.map +1 -0
- package/dist/components/ui/hover-card.js +9 -0
- package/dist/components/ui/hover-card.js.map +1 -0
- package/dist/components/ui/index.d.ts +7 -0
- package/dist/components/ui/index.d.ts.map +1 -0
- package/dist/components/ui/index.js +7 -0
- package/dist/components/ui/index.js.map +1 -0
- package/dist/components/ui/input-group.d.ts +13 -0
- package/dist/components/ui/input-group.d.ts.map +1 -0
- package/dist/components/ui/input-group.js +63 -0
- package/dist/components/ui/input-group.js.map +1 -0
- package/dist/components/ui/input-otp.d.ts +6 -0
- package/dist/components/ui/input-otp.d.ts.map +1 -0
- package/dist/components/ui/input-otp.js +25 -0
- package/dist/components/ui/input-otp.js.map +1 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +8 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/item.d.ts +19 -0
- package/dist/components/ui/item.d.ts.map +1 -0
- package/dist/components/ui/item.js +67 -0
- package/dist/components/ui/item.js.map +1 -0
- package/dist/components/ui/kbd.d.ts +4 -0
- package/dist/components/ui/kbd.d.ts.map +1 -0
- package/dist/components/ui/kbd.js +9 -0
- package/dist/components/ui/kbd.js.map +1 -0
- package/dist/components/ui/label.d.ts +3 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/label.js +10 -0
- package/dist/components/ui/label.js.map +1 -0
- package/dist/components/ui/menubar.d.ts +23 -0
- package/dist/components/ui/menubar.d.ts.map +1 -0
- package/dist/components/ui/menubar.js +64 -0
- package/dist/components/ui/menubar.js.map +1 -0
- package/dist/components/ui/navigation-menu.d.ts +11 -0
- package/dist/components/ui/navigation-menu.d.ts.map +1 -0
- package/dist/components/ui/navigation-menu.js +34 -0
- package/dist/components/ui/navigation-menu.js.map +1 -0
- package/dist/components/ui/network-selector.d.ts +22 -0
- package/dist/components/ui/network-selector.d.ts.map +1 -0
- package/dist/components/ui/network-selector.js +99 -0
- package/dist/components/ui/network-selector.js.map +1 -0
- package/dist/components/ui/pagination.d.ts +29 -0
- package/dist/components/ui/pagination.d.ts.map +1 -0
- package/dist/components/ui/pagination.js +32 -0
- package/dist/components/ui/pagination.js.map +1 -0
- package/dist/components/ui/popover.d.ts +6 -0
- package/dist/components/ui/popover.d.ts.map +1 -0
- package/dist/components/ui/popover.js +12 -0
- package/dist/components/ui/popover.js.map +1 -0
- package/dist/components/ui/progress.d.ts +3 -0
- package/dist/components/ui/progress.d.ts.map +1 -0
- package/dist/components/ui/progress.js +10 -0
- package/dist/components/ui/progress.js.map +1 -0
- package/dist/components/ui/radio-group.d.ts +4 -0
- package/dist/components/ui/radio-group.d.ts.map +1 -0
- package/dist/components/ui/radio-group.js +18 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/resizable.d.ts +8 -0
- package/dist/components/ui/resizable.d.ts.map +1 -0
- package/dist/components/ui/resizable.js +13 -0
- package/dist/components/ui/resizable.js.map +1 -0
- package/dist/components/ui/scroll-area.d.ts +4 -0
- package/dist/components/ui/scroll-area.d.ts.map +1 -0
- package/dist/components/ui/scroll-area.js +19 -0
- package/dist/components/ui/scroll-area.js.map +1 -0
- package/dist/components/ui/select.d.ts +12 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/select.js +51 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/separator.d.ts +3 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/separator.js +7 -0
- package/dist/components/ui/separator.js.map +1 -0
- package/dist/components/ui/sheet.d.ts +19 -0
- package/dist/components/ui/sheet.d.ts.map +1 -0
- package/dist/components/ui/sheet.js +46 -0
- package/dist/components/ui/sheet.js.map +1 -0
- package/dist/components/ui/sidebar.d.ts +58 -0
- package/dist/components/ui/sidebar.d.ts.map +1 -0
- package/dist/components/ui/sidebar.js +246 -0
- package/dist/components/ui/sidebar.js.map +1 -0
- package/dist/components/ui/skeleton.d.ts +3 -0
- package/dist/components/ui/skeleton.d.ts.map +1 -0
- package/dist/components/ui/skeleton.js +6 -0
- package/dist/components/ui/skeleton.js.map +1 -0
- package/dist/components/ui/slider.d.ts +3 -0
- package/dist/components/ui/slider.d.ts.map +1 -0
- package/dist/components/ui/slider.js +12 -0
- package/dist/components/ui/slider.js.map +1 -0
- package/dist/components/ui/sonner.d.ts +5 -0
- package/dist/components/ui/sonner.d.ts.map +1 -0
- package/dist/components/ui/sonner.js +16 -0
- package/dist/components/ui/sonner.js.map +1 -0
- package/dist/components/ui/spinner.d.ts +3 -0
- package/dist/components/ui/spinner.d.ts.map +1 -0
- package/dist/components/ui/spinner.js +7 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/surface-variant.d.ts +4 -0
- package/dist/components/ui/surface-variant.d.ts.map +1 -0
- package/dist/components/ui/surface-variant.js +10 -0
- package/dist/components/ui/surface-variant.js.map +1 -0
- package/dist/components/ui/switch.d.ts +3 -0
- package/dist/components/ui/switch.d.ts.map +1 -0
- package/dist/components/ui/switch.js +9 -0
- package/dist/components/ui/switch.js.map +1 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/table.d.ts.map +1 -0
- package/dist/components/ui/table.js +22 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/tabs.d.ts +6 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/tabs.js +13 -0
- package/dist/components/ui/tabs.js.map +1 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/textarea.d.ts.map +1 -0
- package/dist/components/ui/textarea.js +8 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/components/ui/toast.d.ts +12 -0
- package/dist/components/ui/toast.d.ts.map +1 -0
- package/dist/components/ui/toast.js +35 -0
- package/dist/components/ui/toast.js.map +1 -0
- package/dist/components/ui/toaster.d.ts +2 -0
- package/dist/components/ui/toaster.d.ts.map +1 -0
- package/dist/components/ui/toaster.js +19 -0
- package/dist/components/ui/toaster.js.map +1 -0
- package/dist/components/ui/toggle-group.d.ts +4 -0
- package/dist/components/ui/toggle-group.d.ts.map +1 -0
- package/dist/components/ui/toggle-group.js +27 -0
- package/dist/components/ui/toggle-group.js.map +1 -0
- package/dist/components/ui/toggle.d.ts +4 -0
- package/dist/components/ui/toggle.d.ts.map +1 -0
- package/dist/components/ui/toggle.js +25 -0
- package/dist/components/ui/toggle.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +6 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip.js +13 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/components/visual/ManowarField.d.ts +9 -0
- package/dist/components/visual/ManowarField.d.ts.map +1 -0
- package/dist/components/visual/ManowarField.js +111 -0
- package/dist/components/visual/ManowarField.js.map +1 -0
- package/dist/components/warp-form.d.ts +22 -0
- package/dist/components/warp-form.d.ts.map +1 -0
- package/dist/components/warp-form.js +743 -0
- package/dist/components/warp-form.js.map +1 -0
- package/dist/hooks/use-agents.d.ts +17 -0
- package/dist/hooks/use-agents.d.ts.map +1 -0
- package/dist/hooks/use-agents.js +64 -0
- package/dist/hooks/use-agents.js.map +1 -0
- package/dist/hooks/use-api.d.ts +28 -0
- package/dist/hooks/use-api.d.ts.map +1 -0
- package/dist/hooks/use-api.js +114 -0
- package/dist/hooks/use-api.js.map +1 -0
- package/dist/hooks/use-chat.d.ts +64 -0
- package/dist/hooks/use-chat.d.ts.map +1 -0
- package/dist/hooks/use-chat.js +350 -0
- package/dist/hooks/use-chat.js.map +1 -0
- package/dist/hooks/use-coordinator.d.ts +41 -0
- package/dist/hooks/use-coordinator.d.ts.map +1 -0
- package/dist/hooks/use-coordinator.js +110 -0
- package/dist/hooks/use-coordinator.js.map +1 -0
- package/dist/hooks/use-dispenser.d.ts +68 -0
- package/dist/hooks/use-dispenser.d.ts.map +1 -0
- package/dist/hooks/use-dispenser.js +113 -0
- package/dist/hooks/use-dispenser.js.map +1 -0
- package/dist/hooks/use-lyria.d.ts +58 -0
- package/dist/hooks/use-lyria.d.ts.map +1 -0
- package/dist/hooks/use-lyria.js +254 -0
- package/dist/hooks/use-lyria.js.map +1 -0
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +16 -0
- package/dist/hooks/use-mobile.js.map +1 -0
- package/dist/hooks/use-model.d.ts +34 -0
- package/dist/hooks/use-model.d.ts.map +1 -0
- package/dist/hooks/use-model.js +105 -0
- package/dist/hooks/use-model.js.map +1 -0
- package/dist/hooks/use-motion-governor.d.ts +10 -0
- package/dist/hooks/use-motion-governor.d.ts.map +1 -0
- package/dist/hooks/use-motion-governor.js +63 -0
- package/dist/hooks/use-motion-governor.js.map +1 -0
- package/dist/hooks/use-multichain.d.ts +34 -0
- package/dist/hooks/use-multichain.d.ts.map +1 -0
- package/dist/hooks/use-multichain.js +120 -0
- package/dist/hooks/use-multichain.js.map +1 -0
- package/dist/hooks/use-onchain.d.ts +145 -0
- package/dist/hooks/use-onchain.d.ts.map +1 -0
- package/dist/hooks/use-onchain.js +652 -0
- package/dist/hooks/use-onchain.js.map +1 -0
- package/dist/hooks/use-registry.d.ts +140 -0
- package/dist/hooks/use-registry.d.ts.map +1 -0
- package/dist/hooks/use-registry.js +264 -0
- package/dist/hooks/use-registry.js.map +1 -0
- package/dist/hooks/use-services.d.ts +66 -0
- package/dist/hooks/use-services.d.ts.map +1 -0
- package/dist/hooks/use-services.js +216 -0
- package/dist/hooks/use-services.js.map +1 -0
- package/dist/hooks/use-session.d.ts +36 -0
- package/dist/hooks/use-session.d.ts.map +1 -0
- package/dist/hooks/use-session.js +449 -0
- package/dist/hooks/use-session.js.map +1 -0
- package/dist/hooks/use-sse.d.ts +8 -0
- package/dist/hooks/use-sse.d.ts.map +1 -0
- package/dist/hooks/use-sse.js +86 -0
- package/dist/hooks/use-sse.js.map +1 -0
- package/dist/hooks/use-tabs.d.ts +2 -0
- package/dist/hooks/use-tabs.d.ts.map +1 -0
- package/dist/hooks/use-tabs.js +43 -0
- package/dist/hooks/use-tabs.js.map +1 -0
- package/dist/hooks/use-toast.d.ts +41 -0
- package/dist/hooks/use-toast.d.ts.map +1 -0
- package/dist/hooks/use-toast.js +127 -0
- package/dist/hooks/use-toast.js.map +1 -0
- package/dist/hooks/use-triggers.d.ts +51 -0
- package/dist/hooks/use-triggers.d.ts.map +1 -0
- package/dist/hooks/use-triggers.js +212 -0
- package/dist/hooks/use-triggers.js.map +1 -0
- package/dist/hooks/use-warp.d.ts +53 -0
- package/dist/hooks/use-warp.d.ts.map +1 -0
- package/dist/hooks/use-warp.js +231 -0
- package/dist/hooks/use-warp.js.map +1 -0
- package/dist/hooks/use-workflow.d.ts +40 -0
- package/dist/hooks/use-workflow.d.ts.map +1 -0
- package/dist/hooks/use-workflow.js +358 -0
- package/dist/hooks/use-workflow.js.map +1 -0
- package/dist/lib/agents.d.ts +186 -0
- package/dist/lib/agents.d.ts.map +1 -0
- package/dist/lib/agents.js +633 -0
- package/dist/lib/agents.js.map +1 -0
- package/dist/lib/api.d.ts +224 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/api.js +443 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/chains.d.ts +151 -0
- package/dist/lib/chains.d.ts.map +1 -0
- package/dist/lib/chains.js +297 -0
- package/dist/lib/chains.js.map +1 -0
- package/dist/lib/contracts.d.ts +960 -0
- package/dist/lib/contracts.d.ts.map +1 -0
- package/dist/lib/contracts.js +716 -0
- package/dist/lib/contracts.js.map +1 -0
- package/dist/lib/cronos/aa.d.ts +111 -0
- package/dist/lib/cronos/aa.d.ts.map +1 -0
- package/dist/lib/cronos/aa.js +312 -0
- package/dist/lib/cronos/aa.js.map +1 -0
- package/dist/lib/cronos/facilitator.d.ts +87 -0
- package/dist/lib/cronos/facilitator.d.ts.map +1 -0
- package/dist/lib/cronos/facilitator.js +183 -0
- package/dist/lib/cronos/facilitator.js.map +1 -0
- package/dist/lib/evm.d.ts +45 -0
- package/dist/lib/evm.d.ts.map +1 -0
- package/dist/lib/evm.js +78 -0
- package/dist/lib/evm.js.map +1 -0
- package/dist/lib/mockData.d.ts +26 -0
- package/dist/lib/mockData.d.ts.map +1 -0
- package/dist/lib/mockData.js +89 -0
- package/dist/lib/mockData.js.map +1 -0
- package/dist/lib/models.d.ts +122 -0
- package/dist/lib/models.d.ts.map +1 -0
- package/dist/lib/models.js +174 -0
- package/dist/lib/models.js.map +1 -0
- package/dist/lib/multimodal.d.ts +53 -0
- package/dist/lib/multimodal.d.ts.map +1 -0
- package/dist/lib/multimodal.js +204 -0
- package/dist/lib/multimodal.js.map +1 -0
- package/dist/lib/payment.d.ts +67 -0
- package/dist/lib/payment.d.ts.map +1 -0
- package/dist/lib/payment.js +236 -0
- package/dist/lib/payment.js.map +1 -0
- package/dist/lib/pinata.d.ts +140 -0
- package/dist/lib/pinata.d.ts.map +1 -0
- package/dist/lib/pinata.js +209 -0
- package/dist/lib/pinata.js.map +1 -0
- package/dist/lib/queryClient.d.ts +9 -0
- package/dist/lib/queryClient.d.ts.map +1 -0
- package/dist/lib/queryClient.js +42 -0
- package/dist/lib/queryClient.js.map +1 -0
- package/dist/lib/services.d.ts +164 -0
- package/dist/lib/services.d.ts.map +1 -0
- package/dist/lib/services.js +304 -0
- package/dist/lib/services.js.map +1 -0
- package/dist/lib/share.d.ts +12 -0
- package/dist/lib/share.d.ts.map +1 -0
- package/dist/lib/share.js +39 -0
- package/dist/lib/share.js.map +1 -0
- package/dist/lib/triggers.d.ts +128 -0
- package/dist/lib/triggers.d.ts.map +1 -0
- package/dist/lib/triggers.js +305 -0
- package/dist/lib/triggers.js.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +6 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/visual-system.d.ts +39 -0
- package/dist/lib/visual-system.d.ts.map +1 -0
- package/dist/lib/visual-system.js +129 -0
- package/dist/lib/visual-system.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* x402 Payment Utilities
|
|
3
|
+
*
|
|
4
|
+
* Chain-aware payment routing for multichain x402 support:
|
|
5
|
+
* - Use ThirdWeb x402 V2 via wrapFetchWithPayment
|
|
6
|
+
* - Cronos chains (338, 25) use Cronos x402 V1 via wrapFetchWithCronosPayment
|
|
7
|
+
* This module is fully chain-agnostic - all chain configuration comes from @/lib/chains
|
|
8
|
+
*
|
|
9
|
+
* @module lib/payment
|
|
10
|
+
*/
|
|
11
|
+
import { wrapFetchWithPayment } from "thirdweb/x402";
|
|
12
|
+
import { isCronosChain, CHAIN_IDS, thirdwebClient, CHAIN_CONFIG } from "./chains";
|
|
13
|
+
import { wrapFetchWithCronosPayment } from "./cronos/facilitator";
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// Configuration
|
|
16
|
+
// =============================================================================
|
|
17
|
+
/**
|
|
18
|
+
* Set to true to enable ECDSA signature v-value normalization.
|
|
19
|
+
* This is typically only needed for older ThirdWeb SDK versions.
|
|
20
|
+
* Currently disabled as modern SDK handles signatures correctly.
|
|
21
|
+
*/
|
|
22
|
+
const ENABLE_SIGNATURE_NORMALIZATION = false;
|
|
23
|
+
export const SESSION_BUDGET_EVENT = "compose:session-budget";
|
|
24
|
+
export const SESSION_INVALID_EVENT = "compose:session-invalid";
|
|
25
|
+
// =============================================================================
|
|
26
|
+
// Signature Normalization (For ThirdWeb x402)
|
|
27
|
+
// =============================================================================
|
|
28
|
+
/**
|
|
29
|
+
* Normalizes ECDSA signature v value to legacy format (27/28)
|
|
30
|
+
* Some chains/wallets produce EIP-155 v values that need normalization.
|
|
31
|
+
*
|
|
32
|
+
* @param signature - The hex signature string
|
|
33
|
+
* @param chainId - The chain ID (used for EIP-155 recovery)
|
|
34
|
+
*/
|
|
35
|
+
function normalizeSignatureV(signature, chainId) {
|
|
36
|
+
const cleanSig = signature.startsWith('0x') ? signature.slice(2) : signature;
|
|
37
|
+
if (cleanSig.length !== 130) {
|
|
38
|
+
return signature;
|
|
39
|
+
}
|
|
40
|
+
const vHex = cleanSig.slice(128);
|
|
41
|
+
const vValue = parseInt(vHex, 16);
|
|
42
|
+
let normalizedV;
|
|
43
|
+
if (vValue === 0 || vValue === 1) {
|
|
44
|
+
normalizedV = vValue + 27;
|
|
45
|
+
}
|
|
46
|
+
else if (vValue === 27 || vValue === 28) {
|
|
47
|
+
normalizedV = vValue;
|
|
48
|
+
}
|
|
49
|
+
else if (vValue >= 35) {
|
|
50
|
+
const yParity = (vValue - 35 - chainId * 2) % 2;
|
|
51
|
+
normalizedV = yParity + 27;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
normalizedV = vValue;
|
|
55
|
+
}
|
|
56
|
+
const prefix = signature.startsWith('0x') ? '0x' : '';
|
|
57
|
+
return prefix + cleanSig.slice(0, 128) + normalizedV.toString(16).padStart(2, '0');
|
|
58
|
+
}
|
|
59
|
+
// =============================================================================
|
|
60
|
+
// Normalized Fetch (For ThirdWeb x402)
|
|
61
|
+
// =============================================================================
|
|
62
|
+
/**
|
|
63
|
+
* Creates a fetch wrapper that can optionally normalize payment signature headers.
|
|
64
|
+
* Used with ThirdWeb x402 for chains that need signature normalization.
|
|
65
|
+
*
|
|
66
|
+
* @param chainId - Chain ID for EIP-155 v-value calculation (defaults to Cronos Testnet)
|
|
67
|
+
* @returns A fetch-compatible function
|
|
68
|
+
*/
|
|
69
|
+
export function createNormalizedFetch(chainId = CHAIN_IDS.cronosTestnet) {
|
|
70
|
+
const normalizedFetch = async (input, init) => {
|
|
71
|
+
if (ENABLE_SIGNATURE_NORMALIZATION) {
|
|
72
|
+
let paymentHeader = null;
|
|
73
|
+
if (init?.headers instanceof Headers) {
|
|
74
|
+
paymentHeader = init.headers.get('payment-signature') || init.headers.get('PAYMENT-SIGNATURE');
|
|
75
|
+
}
|
|
76
|
+
else if (typeof init?.headers === 'object' && init.headers !== null) {
|
|
77
|
+
const headers = init.headers;
|
|
78
|
+
paymentHeader = headers['payment-signature'] || headers['PAYMENT-SIGNATURE'];
|
|
79
|
+
}
|
|
80
|
+
if (paymentHeader) {
|
|
81
|
+
try {
|
|
82
|
+
const decoded = JSON.parse(atob(paymentHeader));
|
|
83
|
+
if (decoded.payload?.signature) {
|
|
84
|
+
const normalizedSig = normalizeSignatureV(decoded.payload.signature, chainId);
|
|
85
|
+
decoded.payload.signature = normalizedSig;
|
|
86
|
+
const normalizedPaymentHeader = btoa(JSON.stringify(decoded));
|
|
87
|
+
if (init?.headers instanceof Headers) {
|
|
88
|
+
init.headers.set('PAYMENT-SIGNATURE', normalizedPaymentHeader);
|
|
89
|
+
}
|
|
90
|
+
else if (typeof init?.headers === 'object' && init.headers !== null) {
|
|
91
|
+
const headers = init.headers;
|
|
92
|
+
delete headers['payment-signature'];
|
|
93
|
+
delete headers['PAYMENT-SIGNATURE'];
|
|
94
|
+
headers['PAYMENT-SIGNATURE'] = normalizedPaymentHeader;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// Ignore normalization errors - proceed with original header
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return fetch(input, init);
|
|
104
|
+
};
|
|
105
|
+
// Cast to fetch type for compatibility with wrapFetchWithPayment
|
|
106
|
+
return normalizedFetch;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Chain-aware payment fetch wrapper factory
|
|
110
|
+
*
|
|
111
|
+
* Automatically routes payment handling based on chain:
|
|
112
|
+
* - Cronos chains (338, 25): Uses Cronos x402 V1 with EIP-712 via @crypto.com/facilitator-client
|
|
113
|
+
* - Other EVM chains: Uses ThirdWeb x402 V2
|
|
114
|
+
*
|
|
115
|
+
* SESSION BYPASS: When sessionToken is provided, skips x402 payment flow entirely
|
|
116
|
+
* and uses Compose Key bearer auth for <100ms latency.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* // Standard x402 flow
|
|
121
|
+
* const paymentFetch = createPaymentFetch({
|
|
122
|
+
* chainId: 338, // Cronos Testnet
|
|
123
|
+
* account,
|
|
124
|
+
* wallet,
|
|
125
|
+
* maxValue: BigInt(5000), // $0.005 USDC
|
|
126
|
+
* });
|
|
127
|
+
*
|
|
128
|
+
* // Session bypass flow (instant)
|
|
129
|
+
* const sessionFetch = createPaymentFetch({
|
|
130
|
+
* chainId: 43114,
|
|
131
|
+
* account,
|
|
132
|
+
* wallet,
|
|
133
|
+
* maxValue: BigInt(5000),
|
|
134
|
+
* sessionToken: 'compose-abc123...',
|
|
135
|
+
* });
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export function createPaymentFetch(params) {
|
|
139
|
+
const { chainId, account, wallet, maxValue, sessionToken } = params;
|
|
140
|
+
const chainName = CHAIN_CONFIG[chainId]?.name || `Chain ${chainId}`;
|
|
141
|
+
const isCronos = isCronosChain(chainId);
|
|
142
|
+
/**
|
|
143
|
+
* Helper to inject X-CHAIN-ID header into all requests.
|
|
144
|
+
* This tells the backend which chain the client is using,
|
|
145
|
+
* so it returns the correct 402 format (Cronos V1 vs ThirdWeb V2).
|
|
146
|
+
*/
|
|
147
|
+
function injectChainHeader(init) {
|
|
148
|
+
const headers = new Headers(init?.headers);
|
|
149
|
+
headers.set('X-CHAIN-ID', chainId.toString());
|
|
150
|
+
return { ...init, headers };
|
|
151
|
+
}
|
|
152
|
+
// SESSION BYPASS: Skip x402 entirely when we have a valid session token
|
|
153
|
+
// This provides <100ms latency instead of ~2-3s for payment flow
|
|
154
|
+
if (sessionToken) {
|
|
155
|
+
console.log(`[payment] Using session bypass for chain ${chainId}`);
|
|
156
|
+
return async (input, init) => {
|
|
157
|
+
const headers = new Headers(init?.headers);
|
|
158
|
+
headers.set('X-CHAIN-ID', chainId.toString());
|
|
159
|
+
headers.set('Authorization', `Bearer ${sessionToken}`);
|
|
160
|
+
headers.set('x-idempotency-key', crypto.randomUUID());
|
|
161
|
+
const response = await fetch(input, { ...init, headers });
|
|
162
|
+
// Emit authoritative session budget state from backend response headers.
|
|
163
|
+
// Header priority: payment session headers -> compose key budget headers -> fallback
|
|
164
|
+
if (typeof window !== "undefined") {
|
|
165
|
+
const budgetRemainingHeader = response.headers.get("x-budget-remaining") ??
|
|
166
|
+
response.headers.get("x-compose-key-budget-remaining");
|
|
167
|
+
const budgetUsedHeader = response.headers.get("x-compose-key-budget-used");
|
|
168
|
+
const budgetLimitHeader = response.headers.get("x-compose-key-budget-limit");
|
|
169
|
+
const budgetRemaining = budgetRemainingHeader ? Number.parseInt(budgetRemainingHeader, 10) : NaN;
|
|
170
|
+
const budgetUsed = budgetUsedHeader ? Number.parseInt(budgetUsedHeader, 10) : NaN;
|
|
171
|
+
const budgetLimit = budgetLimitHeader ? Number.parseInt(budgetLimitHeader, 10) : NaN;
|
|
172
|
+
if (Number.isFinite(budgetRemaining) && budgetRemaining >= 0) {
|
|
173
|
+
console.log(`[payment] Budget sync from headers: remaining=${budgetRemaining}, used=${budgetUsed}, limit=${budgetLimit}`);
|
|
174
|
+
window.dispatchEvent(new CustomEvent(SESSION_BUDGET_EVENT, {
|
|
175
|
+
detail: {
|
|
176
|
+
budgetRemaining,
|
|
177
|
+
budgetUsed: Number.isFinite(budgetUsed) && budgetUsed >= 0 ? budgetUsed : undefined,
|
|
178
|
+
budgetLimit: Number.isFinite(budgetLimit) && budgetLimit >= 0 ? budgetLimit : undefined,
|
|
179
|
+
},
|
|
180
|
+
}));
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
console.warn(`[payment] No valid budget headers in response; headers:`, {
|
|
184
|
+
"x-budget-remaining": response.headers.get("x-budget-remaining"),
|
|
185
|
+
"x-compose-key-budget-remaining": response.headers.get("x-compose-key-budget-remaining"),
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
if (response.status === 401 || response.status === 402 || response.status === 403) {
|
|
189
|
+
window.dispatchEvent(new CustomEvent(SESSION_INVALID_EVENT, {
|
|
190
|
+
detail: { status: response.status },
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return response;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
if (isCronos) {
|
|
198
|
+
// Route: Cronos x402 V1 payment flow
|
|
199
|
+
return async (input, init) => {
|
|
200
|
+
const url = typeof input === 'string'
|
|
201
|
+
? input
|
|
202
|
+
: input instanceof URL
|
|
203
|
+
? input.toString()
|
|
204
|
+
: input.url;
|
|
205
|
+
return wrapFetchWithCronosPayment(url, {
|
|
206
|
+
...injectChainHeader(init),
|
|
207
|
+
account,
|
|
208
|
+
chainId,
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
// Route: ThirdWeb x402 V2 payment flow
|
|
214
|
+
// Create fetch wrapper that injects X-CHAIN-ID header
|
|
215
|
+
const chainAwareFetch = async (input, init) => {
|
|
216
|
+
return fetch(input, injectChainHeader(init));
|
|
217
|
+
};
|
|
218
|
+
const normalizedFetch = createNormalizedFetch(chainId);
|
|
219
|
+
// Compose: chain header → normalize → ThirdWeb payment
|
|
220
|
+
const composedFetch = async (input, init) => {
|
|
221
|
+
const initWithChain = injectChainHeader(init);
|
|
222
|
+
return normalizedFetch(input, initWithChain);
|
|
223
|
+
};
|
|
224
|
+
const thirdwebFetch = wrapFetchWithPayment(composedFetch, thirdwebClient, wallet, { maxValue });
|
|
225
|
+
// Wrap to match our expected signature
|
|
226
|
+
return async (input, init) => {
|
|
227
|
+
const normalizedInput = input instanceof URL ? input.toString() : input;
|
|
228
|
+
return thirdwebFetch(normalizedInput, init);
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// =============================================================================
|
|
233
|
+
// Re-exports for convenience
|
|
234
|
+
// =============================================================================
|
|
235
|
+
export { isCronosChain, CHAIN_IDS } from "./chains";
|
|
236
|
+
//# sourceMappingURL=payment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.js","sourceRoot":"","sources":["../../src/lib/payment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAClF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElE,gFAAgF;AAChF,gBAAgB;AAChB,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,8BAA8B,GAAG,KAAK,CAAC;AAC7C,MAAM,CAAC,MAAM,oBAAoB,GAAG,wBAAwB,CAAC;AAC7D,MAAM,CAAC,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAE/D,gFAAgF;AAChF,8CAA8C;AAC9C,gFAAgF;AAEhF;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,SAAiB,EAAE,OAAe;IAC7D,MAAM,QAAQ,GAAG,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE7E,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC5B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,EAAE,EAAE,C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O;gBACP,OAAO;aACR,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,uCAAuC;QACvC,sDAAsD;QACtD,MAAM,eAAe,GAAG,KAAK,EAAE,KAAwB,EAAE,IAAkB,EAAqB,EAAE;YAChG,OAAO,KAAK,CAAC,KAAK,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,CAAC,CAAC;QAEF,MAAM,eAAe,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAEvD,uDAAuD;QACvD,MAAM,aAAa,GAAG,KAAK,EAAE,KAAwB,EAAE,IAAkB,EAAqB,EAAE;YAC9F,MAAM,aAAa,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;YAC9C,OAAO,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;QAC/C,CAAC,CAAC;QAEF,MAAM,aAAa,GAAG,oBAAoB,CACxC,aAA6B,EAC7B,cAAc,EACd,MAAM,EACN,EAAE,QAAQ,EAAE,CACb,CAAC;QAEF,uCAAuC;QACvC,OAAO,KAAK,EAAE,KAAwB,EAAE,IAAkB,EAAqB,EAAE;YAC/E,MAAM,eAAe,GAAG,KAAK,YAAY,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;YACxE,OAAO,aAAa,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QAC9C,CAAC,CAAC;IACJ,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,6BAA6B;AAC7B,gFAAgF;AAEhF,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pinata IPFS Storage Utility
|
|
3
|
+
* Used for storing agent avatars, agent cards, and Manowar metadata
|
|
4
|
+
*/
|
|
5
|
+
interface PinataMetadata {
|
|
6
|
+
name?: string;
|
|
7
|
+
keyvalues?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Upload a file to Pinata IPFS
|
|
11
|
+
*/
|
|
12
|
+
export declare function uploadFile(file: File, metadata?: PinataMetadata): Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Upload JSON data to Pinata IPFS
|
|
15
|
+
*/
|
|
16
|
+
export declare function uploadJSON<T extends object>(data: T, metadata?: PinataMetadata): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Get IPFS URL for a CID
|
|
19
|
+
*/
|
|
20
|
+
export declare function getIpfsUrl(cid: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Get IPFS URI (protocol format)
|
|
23
|
+
*/
|
|
24
|
+
export declare function getIpfsUri(cid: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Fetch JSON from IPFS
|
|
27
|
+
*/
|
|
28
|
+
export declare function fetchFromIpfs<T = unknown>(cid: string): Promise<T>;
|
|
29
|
+
/**
|
|
30
|
+
* Delete/unpin a file from Pinata by CID
|
|
31
|
+
* Used for cleaning up temporary uploads (e.g., conversation attachments)
|
|
32
|
+
*/
|
|
33
|
+
export declare function unpinFile(cid: string): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Upload a temporary file for conversation (will be cleaned up later)
|
|
36
|
+
* Returns both the CID and the gateway URL
|
|
37
|
+
*/
|
|
38
|
+
export declare function uploadConversationFile(file: File, conversationId: string): Promise<{
|
|
39
|
+
cid: string;
|
|
40
|
+
url: string;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Clean up all files for a conversation
|
|
44
|
+
*/
|
|
45
|
+
export declare function cleanupConversationFiles(cids: string[]): Promise<void>;
|
|
46
|
+
export interface AgentCard {
|
|
47
|
+
schemaVersion: string;
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
skills: string[];
|
|
51
|
+
image?: string;
|
|
52
|
+
avatar?: string;
|
|
53
|
+
dnaHash: string;
|
|
54
|
+
walletAddress: string;
|
|
55
|
+
walletTimestamp?: number;
|
|
56
|
+
chain: number;
|
|
57
|
+
model: string;
|
|
58
|
+
framework?: "eliza" | "langchain" | "openclaw";
|
|
59
|
+
licensePrice: string;
|
|
60
|
+
licenses: number;
|
|
61
|
+
cloneable: boolean;
|
|
62
|
+
endpoint?: string;
|
|
63
|
+
protocols: Array<{
|
|
64
|
+
name: string;
|
|
65
|
+
version: string;
|
|
66
|
+
}>;
|
|
67
|
+
plugins?: Array<{
|
|
68
|
+
registryId: string;
|
|
69
|
+
name: string;
|
|
70
|
+
origin: string;
|
|
71
|
+
}>;
|
|
72
|
+
createdAt: string;
|
|
73
|
+
creator?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Upload an agent avatar and return the IPFS CID
|
|
77
|
+
*/
|
|
78
|
+
export declare function uploadAgentAvatar(file: File, agentName: string): Promise<string>;
|
|
79
|
+
/**
|
|
80
|
+
* Upload an agent card to IPFS and return the CID
|
|
81
|
+
*/
|
|
82
|
+
export declare function uploadAgentCard(card: AgentCard): Promise<string>;
|
|
83
|
+
export interface ManowarMetadata {
|
|
84
|
+
schemaVersion: string;
|
|
85
|
+
title: string;
|
|
86
|
+
description: string;
|
|
87
|
+
image?: string;
|
|
88
|
+
dnaHash: string;
|
|
89
|
+
walletAddress: string;
|
|
90
|
+
walletTimestamp: number;
|
|
91
|
+
agents: AgentCard[];
|
|
92
|
+
edges?: Array<{
|
|
93
|
+
source: number;
|
|
94
|
+
target: number;
|
|
95
|
+
label?: string;
|
|
96
|
+
}>;
|
|
97
|
+
coordinator?: {
|
|
98
|
+
hasCoordinator: boolean;
|
|
99
|
+
model: string;
|
|
100
|
+
};
|
|
101
|
+
pricing: {
|
|
102
|
+
totalAgentPrice: string;
|
|
103
|
+
};
|
|
104
|
+
lease?: {
|
|
105
|
+
enabled: boolean;
|
|
106
|
+
durationDays: number;
|
|
107
|
+
creatorPercent: number;
|
|
108
|
+
};
|
|
109
|
+
rfa?: {
|
|
110
|
+
title: string;
|
|
111
|
+
description: string;
|
|
112
|
+
skills: string[];
|
|
113
|
+
offerAmount: string;
|
|
114
|
+
};
|
|
115
|
+
creator: string;
|
|
116
|
+
createdAt: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Upload a Manowar banner and return the IPFS CID
|
|
120
|
+
*/
|
|
121
|
+
export declare function uploadManowarBanner(file: File, title: string): Promise<string>;
|
|
122
|
+
/**
|
|
123
|
+
* Upload Manowar metadata to IPFS and return the CID
|
|
124
|
+
*/
|
|
125
|
+
export declare function uploadManowarMetadata(metadata: ManowarMetadata): Promise<string>;
|
|
126
|
+
/**
|
|
127
|
+
* Generate DNA hash from agent parameters
|
|
128
|
+
* Matches contract: keccak256(abi.encodePacked(skills, chain, model))
|
|
129
|
+
*/
|
|
130
|
+
export declare function generateDnaHash(skills: string[], chain: number, model: string): string;
|
|
131
|
+
/**
|
|
132
|
+
* Check if Pinata is configured
|
|
133
|
+
*/
|
|
134
|
+
export declare function isPinataConfigured(): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Convert file to base64 data URL for preview
|
|
137
|
+
*/
|
|
138
|
+
export declare function fileToDataUrl(file: File): Promise<string>;
|
|
139
|
+
export {};
|
|
140
|
+
//# sourceMappingURL=pinata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pinata.d.ts","sourceRoot":"","sources":["../../src/lib/pinata.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,IAAI,EACV,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,MAAM,CAAC,CA4BjB;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,CAAC,SAAS,MAAM,EAC/C,IAA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AAE,MAAM,CAAC;QACrB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,GAAG,CAAC,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAQpF;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAQtF;AAMD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAKtF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAOzD"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pinata IPFS Storage Utility
|
|
3
|
+
* Used for storing agent avatars, agent cards, and Manowar metadata
|
|
4
|
+
*/
|
|
5
|
+
const PINATA_JWT = import.meta.env.VITE_PINATA_JWT || "";
|
|
6
|
+
const PINATA_GATEWAY = import.meta.env.VITE_PINATA_GATEWAY || "compose.mypinata.cloud";
|
|
7
|
+
const PINATA_API_URL = "https://api.pinata.cloud";
|
|
8
|
+
/**
|
|
9
|
+
* Upload a file to Pinata IPFS
|
|
10
|
+
*/
|
|
11
|
+
export async function uploadFile(file, metadata) {
|
|
12
|
+
const formData = new FormData();
|
|
13
|
+
formData.append("file", file);
|
|
14
|
+
if (metadata) {
|
|
15
|
+
formData.append("pinataMetadata", JSON.stringify(metadata));
|
|
16
|
+
}
|
|
17
|
+
formData.append("pinataOptions", JSON.stringify({ cidVersion: 1 }));
|
|
18
|
+
const response = await fetch(`${PINATA_API_URL}/pinning/pinFileToIPFS`, {
|
|
19
|
+
method: "POST",
|
|
20
|
+
headers: {
|
|
21
|
+
Authorization: `Bearer ${PINATA_JWT}`,
|
|
22
|
+
},
|
|
23
|
+
body: formData,
|
|
24
|
+
});
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
const error = await response.text();
|
|
27
|
+
throw new Error(`Pinata upload failed: ${error}`);
|
|
28
|
+
}
|
|
29
|
+
const result = await response.json();
|
|
30
|
+
return result.IpfsHash;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Upload JSON data to Pinata IPFS
|
|
34
|
+
*/
|
|
35
|
+
export async function uploadJSON(data, metadata) {
|
|
36
|
+
const response = await fetch(`${PINATA_API_URL}/pinning/pinJSONToIPFS`, {
|
|
37
|
+
method: "POST",
|
|
38
|
+
headers: {
|
|
39
|
+
Authorization: `Bearer ${PINATA_JWT}`,
|
|
40
|
+
"Content-Type": "application/json",
|
|
41
|
+
},
|
|
42
|
+
body: JSON.stringify({
|
|
43
|
+
pinataContent: data,
|
|
44
|
+
pinataMetadata: metadata,
|
|
45
|
+
pinataOptions: { cidVersion: 1 },
|
|
46
|
+
}),
|
|
47
|
+
});
|
|
48
|
+
if (!response.ok) {
|
|
49
|
+
const error = await response.text();
|
|
50
|
+
throw new Error(`Pinata JSON upload failed: ${error}`);
|
|
51
|
+
}
|
|
52
|
+
const result = await response.json();
|
|
53
|
+
return result.IpfsHash;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get IPFS URL for a CID
|
|
57
|
+
*/
|
|
58
|
+
export function getIpfsUrl(cid) {
|
|
59
|
+
return `https://${PINATA_GATEWAY}/ipfs/${cid}`;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get IPFS URI (protocol format)
|
|
63
|
+
*/
|
|
64
|
+
export function getIpfsUri(cid) {
|
|
65
|
+
return `ipfs://${cid}`;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Fetch JSON from IPFS
|
|
69
|
+
*/
|
|
70
|
+
export async function fetchFromIpfs(cid) {
|
|
71
|
+
const response = await fetch(getIpfsUrl(cid));
|
|
72
|
+
if (!response.ok) {
|
|
73
|
+
throw new Error(`Failed to fetch from IPFS: ${response.statusText}`);
|
|
74
|
+
}
|
|
75
|
+
return response.json();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Delete/unpin a file from Pinata by CID
|
|
79
|
+
* Used for cleaning up temporary uploads (e.g., conversation attachments)
|
|
80
|
+
*/
|
|
81
|
+
export async function unpinFile(cid) {
|
|
82
|
+
if (!PINATA_JWT) {
|
|
83
|
+
console.warn("[pinata] No JWT configured, cannot unpin");
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const response = await fetch(`${PINATA_API_URL}/pinning/unpin/${cid}`, {
|
|
88
|
+
method: "DELETE",
|
|
89
|
+
headers: {
|
|
90
|
+
Authorization: `Bearer ${PINATA_JWT}`,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
if (!response.ok) {
|
|
94
|
+
const error = await response.text();
|
|
95
|
+
console.error(`[pinata] Failed to unpin ${cid}: ${error}`);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
console.log(`[pinata] Successfully unpinned ${cid}`);
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
console.error(`[pinata] Error unpinning ${cid}:`, error);
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Upload a temporary file for conversation (will be cleaned up later)
|
|
108
|
+
* Returns both the CID and the gateway URL
|
|
109
|
+
*/
|
|
110
|
+
export async function uploadConversationFile(file, conversationId) {
|
|
111
|
+
const cid = await uploadFile(file, {
|
|
112
|
+
name: `conversation-${conversationId}-${file.name}`,
|
|
113
|
+
keyvalues: {
|
|
114
|
+
type: "conversation-attachment",
|
|
115
|
+
conversationId,
|
|
116
|
+
originalName: file.name,
|
|
117
|
+
mimeType: file.type,
|
|
118
|
+
uploadedAt: new Date().toISOString(),
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
return { cid, url: getIpfsUrl(cid) };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Clean up all files for a conversation
|
|
125
|
+
*/
|
|
126
|
+
export async function cleanupConversationFiles(cids) {
|
|
127
|
+
console.log(`[pinata] Cleaning up ${cids.length} conversation files...`);
|
|
128
|
+
await Promise.all(cids.map(cid => unpinFile(cid)));
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Upload an agent avatar and return the IPFS CID
|
|
132
|
+
*/
|
|
133
|
+
export async function uploadAgentAvatar(file, agentName) {
|
|
134
|
+
return uploadFile(file, {
|
|
135
|
+
name: `${agentName}-avatar`,
|
|
136
|
+
keyvalues: {
|
|
137
|
+
type: "agent-avatar",
|
|
138
|
+
agent: agentName,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Upload an agent card to IPFS and return the CID
|
|
144
|
+
*/
|
|
145
|
+
export async function uploadAgentCard(card) {
|
|
146
|
+
return uploadJSON(card, {
|
|
147
|
+
name: `${card.name}-agent-card`,
|
|
148
|
+
keyvalues: {
|
|
149
|
+
type: "agent-card",
|
|
150
|
+
agent: card.name,
|
|
151
|
+
chain: card.chain.toString(),
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Upload a Manowar banner and return the IPFS CID
|
|
157
|
+
*/
|
|
158
|
+
export async function uploadManowarBanner(file, title) {
|
|
159
|
+
return uploadFile(file, {
|
|
160
|
+
name: `${title}-banner`,
|
|
161
|
+
keyvalues: {
|
|
162
|
+
type: "manowar-banner",
|
|
163
|
+
manowar: title,
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Upload Manowar metadata to IPFS and return the CID
|
|
169
|
+
*/
|
|
170
|
+
export async function uploadManowarMetadata(metadata) {
|
|
171
|
+
return uploadJSON(metadata, {
|
|
172
|
+
name: `${metadata.title}-metadata`,
|
|
173
|
+
keyvalues: {
|
|
174
|
+
type: "manowar-metadata",
|
|
175
|
+
manowar: metadata.title,
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
// =============================================================================
|
|
180
|
+
// Utility Functions
|
|
181
|
+
// =============================================================================
|
|
182
|
+
/**
|
|
183
|
+
* Generate DNA hash from agent parameters
|
|
184
|
+
* Matches contract: keccak256(abi.encodePacked(skills, chain, model))
|
|
185
|
+
*/
|
|
186
|
+
export function generateDnaHash(skills, chain, model) {
|
|
187
|
+
// Use Web Crypto API for keccak256-like hash
|
|
188
|
+
// Note: In production, use a proper keccak256 implementation (e.g., from viem)
|
|
189
|
+
const data = `${skills.sort().join(",")}:${chain}:${model}`;
|
|
190
|
+
return data; // This will be hashed on-chain; frontend stores the source data
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Check if Pinata is configured
|
|
194
|
+
*/
|
|
195
|
+
export function isPinataConfigured() {
|
|
196
|
+
return Boolean(PINATA_JWT);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Convert file to base64 data URL for preview
|
|
200
|
+
*/
|
|
201
|
+
export function fileToDataUrl(file) {
|
|
202
|
+
return new Promise((resolve, reject) => {
|
|
203
|
+
const reader = new FileReader();
|
|
204
|
+
reader.onload = () => resolve(reader.result);
|
|
205
|
+
reader.onerror = reject;
|
|
206
|
+
reader.readAsDataURL(file);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=pinata.js.map
|
|
@@ -0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EG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,QAAyB;IACnE,OAAO,UAAU,CAAC,QAAQ,EAAE;QAC1B,IAAI,EAAE,GAAG,QAAQ,CAAC,KAAK,WAAW;QAClC,SAAS,EAAE;YACT,IAAI,EAAE,kBAAkB;YACxB,OAAO,EAAE,QAAQ,CAAC,KAAK;SACxB;KACF,CAAC,CAAC;AACL,CAAC;AAED,gFAAgF;AAChF,oBAAoB;AACpB,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,MAAgB,EAAE,KAAa,EAAE,KAAa;IAC5E,6CAA6C;IAC7C,+EAA+E;IAC/E,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;IAC5D,OAAO,IAAI,CAAC,CAAC,gEAAgE;AAC/E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,IAAU;IACtC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAgB,CAAC,CAAC;QACvD,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;QACxB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { QueryFunction } from "@tanstack/react-query";
|
|
2
|
+
export declare function apiRequest(method: string, url: string, data?: unknown | undefined): Promise<Response>;
|
|
3
|
+
type UnauthorizedBehavior = "returnNull" | "throw";
|
|
4
|
+
export declare const getQueryFn: <T>(options: {
|
|
5
|
+
on401: UnauthorizedBehavior;
|
|
6
|
+
}) => QueryFunction<T>;
|
|
7
|
+
export declare const queryClient: any;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=queryClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryClient.d.ts","sourceRoot":"","sources":["../../src/lib/queryClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,aAAa,EAAE,MAAM,uBAAuB,CAAC;AASnE,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,GACzB,OAAO,CAAC,QAAQ,CAAC,CAUnB;AAED,KAAK,oBAAoB,GAAG,YAAY,GAAG,OAAO,CAAC;AACnD,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE;IACpC,KAAK,EAAE,oBAAoB,CAAC;CAC7B,KAAK,aAAa,CAAC,CAAC,CAalB,CAAC;AAEJ,eAAO,MAAM,WAAW,KAatB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
2
|
+
async function throwIfResNotOk(res) {
|
|
3
|
+
if (!res.ok) {
|
|
4
|
+
const text = (await res.text()) || res.statusText;
|
|
5
|
+
throw new Error(`${res.status}: ${text}`);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export async function apiRequest(method, url, data) {
|
|
9
|
+
const res = await fetch(url, {
|
|
10
|
+
method,
|
|
11
|
+
headers: data ? { "Content-Type": "application/json" } : {},
|
|
12
|
+
body: data ? JSON.stringify(data) : undefined,
|
|
13
|
+
credentials: "include",
|
|
14
|
+
});
|
|
15
|
+
await throwIfResNotOk(res);
|
|
16
|
+
return res;
|
|
17
|
+
}
|
|
18
|
+
export const getQueryFn = ({ on401: unauthorizedBehavior }) => async ({ queryKey }) => {
|
|
19
|
+
const res = await fetch(queryKey.join("/"), {
|
|
20
|
+
credentials: "include",
|
|
21
|
+
});
|
|
22
|
+
if (unauthorizedBehavior === "returnNull" && res.status === 401) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
await throwIfResNotOk(res);
|
|
26
|
+
return await res.json();
|
|
27
|
+
};
|
|
28
|
+
export const queryClient = new QueryClient({
|
|
29
|
+
defaultOptions: {
|
|
30
|
+
queries: {
|
|
31
|
+
queryFn: getQueryFn({ on401: "throw" }),
|
|
32
|
+
refetchInterval: false,
|
|
33
|
+
refetchOnWindowFocus: false,
|
|
34
|
+
staleTime: Infinity,
|
|
35
|
+
retry: false,
|
|
36
|
+
},
|
|
37
|
+
mutations: {
|
|
38
|
+
retry: false,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=queryClient.js.map
|