@tulip-systems/core 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/client.d.ts +3 -1
- package/dist/auth/client.js +4 -2
- package/dist/auth/server.d.ts +2 -2
- package/dist/auth/server.js +3 -3
- package/dist/auth.d.ts +2 -1
- package/dist/auth.js +3 -2
- package/dist/commands/client.d.ts +4 -4
- package/dist/commands/client.js +4 -4
- package/dist/components/client.d.ts +5 -3
- package/dist/components/client.js +6 -4
- package/dist/components/common/icons.d.ts +5 -2
- package/dist/components/common/icons.d.ts.map +1 -1
- package/dist/components/common/icons.js +4 -1
- package/dist/components/common/icons.js.map +1 -1
- package/dist/components/common/status.d.ts +3 -3
- package/dist/components/editor/components/content.client.d.ts +2 -2
- package/dist/components/editor/components/fixed-menu.client.d.ts +2 -2
- package/dist/components/editor/context.client.d.ts +2 -2
- package/dist/components/editor/index.client.d.ts +2 -2
- package/dist/components/editor/preview.client.d.ts +2 -2
- package/dist/components/header/back-button.client.d.ts +2 -2
- package/dist/components/header/bottom-bar.client.d.ts +5 -5
- package/dist/components/header/bottom-bar.client.d.ts.map +1 -1
- package/dist/components/header/bottom-bar.client.js.map +1 -1
- package/dist/components/header/breadcrumbs.client.d.ts +7 -7
- package/dist/components/header/breadcrumbs.client.js +1 -1
- package/dist/components/header/header.client.d.ts +2 -2
- package/dist/components/header/mobile-nav-switcher.client.d.ts +2 -2
- package/dist/components/header/top-bar.client.d.ts +4 -4
- package/dist/components/layouts/admin-content.client.d.ts +13 -0
- package/dist/components/layouts/admin-content.client.d.ts.map +1 -0
- package/dist/components/layouts/admin-layout.d.ts +8 -0
- package/dist/components/layouts/admin-layout.d.ts.map +1 -0
- package/dist/components/layouts/admin-layout.js +15 -0
- package/dist/components/layouts/admin-layout.js.map +1 -0
- package/dist/components/layouts/admin-loading.d.ts +3 -3
- package/dist/components/layouts/admin-loading.d.ts.map +1 -1
- package/dist/components/layouts/admin-loading.js +2 -2
- package/dist/components/layouts/admin-loading.js.map +1 -1
- package/dist/components/layouts/empty-page.d.ts +4 -4
- package/dist/components/layouts/list-layout.d.ts +2 -2
- package/dist/components/layouts/not-found-page.d.ts +4 -3
- package/dist/components/layouts/not-found-page.d.ts.map +1 -1
- package/dist/components/layouts/not-found-page.js +8 -2
- package/dist/components/layouts/not-found-page.js.map +1 -1
- package/dist/components/layouts/not-found-section.js +1 -1
- package/dist/components/layouts/not-found-section.js.map +1 -1
- package/dist/components/layouts/providers.client.d.ts +2 -2
- package/dist/components/layouts/root-layout.server.d.ts +2 -2
- package/dist/components/layouts/root-layout.server.d.ts.map +1 -1
- package/dist/components/layouts/root-loading.d.ts +7 -0
- package/dist/components/layouts/root-loading.d.ts.map +1 -0
- package/dist/components/layouts/root-loading.js +14 -0
- package/dist/components/layouts/root-loading.js.map +1 -0
- package/dist/components/layouts/tab-layout.d.ts +2 -2
- package/dist/components/lists/data-list.d.ts +5 -5
- package/dist/components/lists/data-stack.d.ts +8 -8
- package/dist/components/{layouts → navigation}/admin-sidebar-header.client.js +8 -9
- package/dist/components/navigation/admin-sidebar-header.client.js.map +1 -0
- package/dist/components/navigation/admin-sidebar-paths.client.d.ts +81 -0
- package/dist/components/navigation/admin-sidebar-paths.client.d.ts.map +1 -0
- package/dist/components/navigation/admin-sidebar-paths.client.js +143 -0
- package/dist/components/navigation/admin-sidebar-paths.client.js.map +1 -0
- package/dist/components/navigation/admin-sidebar-skeleton.js +31 -0
- package/dist/components/navigation/admin-sidebar-skeleton.js.map +1 -0
- package/dist/components/server.d.ts +1 -1
- package/dist/components/server.js +1 -1
- package/dist/components/ui/accordion.d.ts +5 -5
- package/dist/components/ui/alert-dialog.d.ts +12 -12
- package/dist/components/ui/alert.d.ts +6 -6
- package/dist/components/ui/aspect-ratio.d.ts +2 -2
- package/dist/components/ui/avatar.client.d.ts +4 -4
- package/dist/components/ui/badge.d.ts +4 -4
- package/dist/components/ui/breadcrumb.d.ts +8 -8
- package/dist/components/ui/button.d.ts +4 -4
- package/dist/components/ui/calendar.d.ts +2 -2
- package/dist/components/ui/card.d.ts +7 -7
- package/dist/components/ui/carousel.d.ts +6 -6
- package/dist/components/ui/chart.client.d.ts +5 -5
- package/dist/components/ui/checkbox.d.ts +2 -2
- package/dist/components/ui/collapsible.client.d.ts +4 -4
- package/dist/components/ui/color-picker.client.d.ts +2 -2
- package/dist/components/ui/combobox-dropdown.client.d.ts +2 -2
- package/dist/components/ui/combobox.client.d.ts +2 -2
- package/dist/components/ui/command.d.ts +10 -10
- package/dist/components/ui/context-menu.d.ts +16 -16
- package/dist/components/ui/dialog.client.d.ts +11 -11
- package/dist/components/ui/drawer.client.d.ts +11 -11
- package/dist/components/ui/dropdown-menu.d.ts +16 -16
- package/dist/components/ui/form.client.d.ts +8 -8
- package/dist/components/ui/hover-card.client.d.ts +4 -4
- package/dist/components/ui/input.d.ts +2 -2
- package/dist/components/ui/label.d.ts +2 -2
- package/dist/components/ui/navigation-menu.d.ts +11 -11
- package/dist/components/ui/pagination.d.ts +8 -8
- package/dist/components/ui/popover.d.ts +5 -5
- package/dist/components/ui/progress.client.d.ts +2 -2
- package/dist/components/ui/radio-group.d.ts +3 -3
- package/dist/components/ui/resizable.client.d.ts +4 -4
- package/dist/components/ui/scroll-area.d.ts +3 -3
- package/dist/components/ui/select.client.d.ts +11 -11
- package/dist/components/ui/separator.d.ts +2 -2
- package/dist/components/ui/sheet.client.d.ts +9 -9
- package/dist/components/ui/sidebar.client.d.ts +24 -24
- package/dist/components/ui/sidebar.client.js +1 -1
- package/dist/components/ui/skeleton.d.ts +2 -2
- package/dist/components/ui/slider.d.ts +2 -2
- package/dist/components/ui/sonner.client.d.ts +2 -2
- package/dist/components/ui/sonner.client.js +1 -1
- package/dist/components/ui/spinner.js +63 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/switch.d.ts +2 -2
- package/dist/components/ui/tabs.d.ts +5 -5
- package/dist/components/ui/textarea.d.ts +2 -2
- package/dist/components/ui/time-input.client.d.ts +2 -2
- package/dist/components/ui/toggle-group.client.d.ts +3 -3
- package/dist/components/ui/toggle.d.ts +4 -4
- package/dist/components/ui/tooltip.client.d.ts +5 -5
- package/dist/components/ui/tree.client.d.ts +5 -5
- package/dist/components/ui/tree.client.d.ts.map +1 -1
- package/dist/components.d.ts +6 -5
- package/dist/components.js +8 -7
- package/dist/config/server.d.ts +2 -3
- package/dist/config/server.js +3 -4
- package/dist/config.d.ts +3 -2
- package/dist/config.js +2 -1
- package/dist/lib/client.js +1 -1
- package/dist/lib/hooks/use-action.d.ts +2 -2
- package/dist/modules/auth/components/allowed.client.js +1 -1
- package/dist/modules/auth/components/allowed.client.js.map +1 -1
- package/dist/modules/auth/components/auth-layout.server.d.ts +3 -4
- package/dist/modules/auth/components/auth-layout.server.d.ts.map +1 -1
- package/dist/modules/auth/components/auth-layout.server.js +1 -4
- package/dist/modules/auth/components/auth-layout.server.js.map +1 -1
- package/dist/modules/auth/components/auth-loading.d.ts +7 -0
- package/dist/modules/auth/components/auth-loading.d.ts.map +1 -0
- package/dist/modules/auth/components/auth-loading.js +18 -0
- package/dist/modules/auth/components/auth-loading.js.map +1 -0
- package/dist/modules/auth/components/forget-password-page.client.js +2 -2
- package/dist/modules/auth/components/guard.client.js +16 -0
- package/dist/modules/auth/components/guard.client.js.map +1 -0
- package/dist/modules/auth/components/login-page.client.d.ts +1 -5
- package/dist/modules/auth/components/login-page.client.d.ts.map +1 -1
- package/dist/modules/auth/components/login-page.client.js +41 -31
- package/dist/modules/auth/components/login-page.client.js.map +1 -1
- package/dist/modules/auth/components/reset-password-page.client.js +3 -3
- package/dist/modules/auth/components/update-password-command.d.ts +1 -1
- package/dist/modules/auth/components/update-password-command.js +1 -1
- package/dist/modules/auth/handler/client.client.d.ts +48 -48
- package/dist/modules/auth/handler/client.client.d.ts.map +1 -1
- package/dist/modules/auth/handler/proxy.server.d.ts +13 -0
- package/dist/modules/auth/handler/proxy.server.d.ts.map +1 -0
- package/dist/modules/auth/handler/proxy.server.js +22 -0
- package/dist/modules/auth/handler/proxy.server.js.map +1 -0
- package/dist/modules/auth/handler/server.server.js +3 -1
- package/dist/modules/auth/handler/server.server.js.map +1 -1
- package/dist/modules/auth/hooks/use-permission.d.ts +26 -0
- package/dist/modules/auth/hooks/use-permission.d.ts.map +1 -0
- package/dist/modules/auth/hooks/{use-permission.client.js → use-permission.js} +5 -3
- package/dist/modules/auth/hooks/use-permission.js.map +1 -0
- package/dist/modules/auth/hooks/use-session.d.ts +34 -0
- package/dist/modules/auth/hooks/use-session.d.ts.map +1 -0
- package/dist/modules/auth/hooks/use-session.js +21 -0
- package/dist/modules/auth/hooks/use-session.js.map +1 -0
- package/dist/modules/auth/lib/helpers.server.d.ts +2 -2
- package/dist/modules/auth/lib/helpers.server.d.ts.map +1 -1
- package/dist/modules/auth/lib/helpers.server.js +3 -6
- package/dist/modules/auth/lib/helpers.server.js.map +1 -1
- package/dist/modules/auth/lib/validators.d.ts +4 -4
- package/dist/modules/auth/lib/validators.d.ts.map +1 -1
- package/dist/modules/auth/lib/validators.js +1 -1
- package/dist/modules/auth/lib/validators.js.map +1 -1
- package/dist/modules/commands/components/alert-dialog-command.client.d.ts +11 -11
- package/dist/modules/commands/components/alert-dialog-command.client.js +1 -1
- package/dist/modules/commands/components/click-command.client.d.ts +2 -2
- package/dist/modules/commands/components/command-trigger.client.d.ts +4 -4
- package/dist/modules/commands/components/command-trigger.client.js +1 -1
- package/dist/modules/commands/components/dialog-command.client.d.ts +8 -8
- package/dist/modules/commands/components/dialog-command.client.js +1 -1
- package/dist/modules/commands/components/dropdown-command.client.d.ts +5 -5
- package/dist/modules/commands/components/empty-command.client.d.ts +2 -2
- package/dist/modules/commands/components/form-dialog-command.client.d.ts +12 -12
- package/dist/modules/commands/components/form-dialog-command.client.js +1 -1
- package/dist/modules/commands/hooks/use-command-action.client.js +1 -1
- package/dist/modules/commands/hooks/use-command-menu.client.js +1 -1
- package/dist/modules/commands/hooks/use-command-menu.client.js.map +1 -1
- package/dist/modules/commands/menus/context-menu.client.d.ts +2 -2
- package/dist/modules/commands/menus/dropdown-menu.client.d.ts +8 -4
- package/dist/modules/commands/menus/dropdown-menu.client.d.ts.map +1 -1
- package/dist/modules/commands/menus/dropdown-menu.client.js +9 -1
- package/dist/modules/commands/menus/dropdown-menu.client.js.map +1 -1
- package/dist/modules/commands/menus/inline-menu.client.d.ts +8 -4
- package/dist/modules/commands/menus/inline-menu.client.d.ts.map +1 -1
- package/dist/modules/commands/menus/inline-menu.client.js +12 -1
- package/dist/modules/commands/menus/inline-menu.client.js.map +1 -1
- package/dist/modules/commands/menus/responsive-menu.client.d.ts +2 -1
- package/dist/modules/commands/menus/responsive-menu.client.d.ts.map +1 -1
- package/dist/modules/commands/menus/responsive-menu.client.js +6 -3
- package/dist/modules/commands/menus/responsive-menu.client.js.map +1 -1
- package/dist/modules/commands/utils/archive-command.client.d.ts +3 -3
- package/dist/modules/commands/utils/delete-command.client.d.ts +2 -2
- package/dist/modules/commands/utils/send-mail-command.client.d.ts +2 -2
- package/dist/modules/commands/utils/send-mail-command.client.d.ts.map +1 -1
- package/dist/modules/commands/utils/send-mail-command.client.js +3 -3
- package/dist/modules/config/db/helpers.d.ts +5 -5
- package/dist/modules/config/db/helpers.d.ts.map +1 -1
- package/dist/modules/config/lib/config.server.d.ts +0 -2
- package/dist/modules/config/lib/config.server.d.ts.map +1 -1
- package/dist/modules/config/lib/config.server.js.map +1 -1
- package/dist/modules/config/lib/resolve.server.d.ts +192 -190
- package/dist/modules/config/lib/resolve.server.d.ts.map +1 -1
- package/dist/modules/config/paths/helpers.d.ts +11 -0
- package/dist/modules/config/paths/helpers.d.ts.map +1 -0
- package/dist/modules/config/paths/helpers.js +9 -0
- package/dist/modules/config/paths/helpers.js.map +1 -0
- package/dist/modules/config/paths/types.d.ts +8 -37
- package/dist/modules/config/paths/types.d.ts.map +1 -1
- package/dist/modules/config/router/client.server.d.ts +4 -4
- package/dist/modules/config/router/client.server.d.ts.map +1 -1
- package/dist/modules/config/router/context.server.d.ts +194 -192
- package/dist/modules/config/router/context.server.d.ts.map +1 -1
- package/dist/modules/config/router/init.server.d.ts +200 -198
- package/dist/modules/config/router/init.server.d.ts.map +1 -1
- package/dist/modules/data-tables/components/cell/common.client.d.ts +5 -5
- package/dist/modules/data-tables/components/cell/common.client.d.ts.map +1 -1
- package/dist/modules/data-tables/components/column-header.d.ts +2 -2
- package/dist/modules/data-tables/components/filters/combobox.client.d.ts +2 -2
- package/dist/modules/data-tables/components/filters/combobox.client.d.ts.map +1 -1
- package/dist/modules/data-tables/components/filters/combobox.client.js +1 -1
- package/dist/modules/data-tables/components/filters/combobox.client.js.map +1 -1
- package/dist/modules/data-tables/components/filters/slider.client.d.ts +2 -2
- package/dist/modules/data-tables/components/filters/slider.client.d.ts.map +1 -1
- package/dist/modules/data-tables/components/header.d.ts +4 -4
- package/dist/modules/data-tables/components/layout.d.ts +2 -2
- package/dist/modules/data-tables/components/search-input.client.d.ts +2 -2
- package/dist/modules/data-tables/components/search-input.client.d.ts.map +1 -1
- package/dist/modules/data-tables/components/skeleton.d.ts +2 -2
- package/dist/modules/data-tables/components/table.d.ts +7 -7
- package/dist/modules/data-tables/components/toolbar.d.ts +3 -3
- package/dist/modules/data-tables/hooks/use-context.client.d.ts +2 -2
- package/dist/modules/data-tables/hooks/use-context.client.d.ts.map +1 -1
- package/dist/modules/data-tables/lib/filters/resolvers.d.ts +1 -1
- package/dist/modules/data-tables/lib/filters/resolvers.d.ts.map +1 -1
- package/dist/modules/data-tables/lib/search-params.d.ts +5 -5
- package/dist/modules/data-tables/lib/search-params.d.ts.map +1 -1
- package/dist/modules/data-tables/lib/types.d.ts +1 -1
- package/dist/modules/data-tables/tables/data-table/components/table.d.ts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/cells/common.d.ts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/cells/common.d.ts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.d.ts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.d.ts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/combobox.client.d.ts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/inputs/input.client.d.ts +3 -3
- package/dist/modules/data-tables/tables/inline-table/components/inputs/read-only.d.ts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/inputs/select.client.d.ts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/table.d.ts +2 -2
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.ts +2 -2
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.js +1 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/use-input.client.js +1 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/use-input.client.js.map +1 -1
- package/dist/modules/inline-edit/components/combobox-dropdown.client.d.ts +2 -2
- package/dist/modules/inline-edit/components/combobox-dropdown.client.d.ts.map +1 -1
- package/dist/modules/inline-edit/components/combobox.client.d.ts +2 -2
- package/dist/modules/inline-edit/components/combobox.client.d.ts.map +1 -1
- package/dist/modules/inline-edit/components/date-input.client.d.ts +2 -2
- package/dist/modules/inline-edit/components/date-input.client.js +1 -1
- package/dist/modules/inline-edit/components/date-picker.client.d.ts +2 -2
- package/dist/modules/inline-edit/components/editor.client.d.ts +2 -2
- package/dist/modules/inline-edit/components/input-toggle.client.d.ts +2 -2
- package/dist/modules/inline-edit/components/input.client.d.ts +3 -3
- package/dist/modules/inline-edit/components/richtext.client.d.ts +2 -2
- package/dist/modules/inline-edit/components/select.client.d.ts +6 -6
- package/dist/modules/inline-edit/components/switch.client.d.ts +2 -2
- package/dist/modules/inline-edit/components/toggle.client.d.ts +2 -2
- package/dist/modules/inline-edit/hooks/context.client.d.ts +2 -2
- package/dist/modules/inline-edit/hooks/use-inline.client.js +1 -1
- package/dist/modules/inline-edit/hooks/use-inline.client.js.map +1 -1
- package/dist/modules/uploads/components/button.client.d.ts +2 -2
- package/dist/modules/uploads/components/button.client.d.ts.map +1 -1
- package/dist/modules/uploads/components/images/grid.client.d.ts +2 -2
- package/dist/modules/uploads/components/images/grid.client.d.ts.map +1 -1
- package/dist/modules/uploads/components/images/grid.client.js +1 -1
- package/dist/modules/uploads/components/images/input.client.d.ts +2 -2
- package/dist/modules/uploads/components/images/input.client.d.ts.map +1 -1
- package/dist/modules/uploads/components/preview-dialog.client.d.ts +2 -2
- package/dist/modules/uploads/components/preview-dialog.client.d.ts.map +1 -1
- package/dist/modules/uploads/components/zone.client.d.ts +2 -2
- package/dist/modules/uploads/components/zone.client.d.ts.map +1 -1
- package/dist/modules/uploads/hooks/use-upload-image.client.js +1 -1
- package/dist/modules/uploads/lib/proxy.server.d.ts +1 -1
- package/dist/modules/uploads/lib/proxy.server.js +4 -4
- package/dist/modules/uploads/lib/route.server.d.ts +1 -1
- package/dist/modules/uploads/lib/route.server.js +2 -2
- package/dist/modules/uploads/lib/router.server.d.ts +965 -965
- package/dist/modules/uploads/lib/router.server.d.ts.map +1 -1
- package/dist/modules/uploads/lib/router.server.js +2 -2
- package/dist/modules/uploads/lib/schema.d.ts +61 -61
- package/dist/modules/uploads/lib/validators.d.ts +56 -56
- package/dist/modules/uploads/lib/validators.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/components/common/icons.tsx +6 -0
- package/src/components/entry.client.ts +6 -0
- package/src/components/entry.server.ts +1 -1
- package/src/components/entry.ts +1 -0
- package/src/components/header/bottom-bar.client.tsx +2 -2
- package/src/components/layouts/admin-layout.tsx +13 -0
- package/src/components/layouts/admin-loading.tsx +1 -1
- package/src/components/layouts/not-found-page.tsx +9 -1
- package/src/components/layouts/not-found-section.tsx +10 -5
- package/src/components/layouts/root-loading.tsx +9 -0
- package/src/components/{layouts → navigation}/admin-sidebar-header.client.tsx +11 -6
- package/src/components/navigation/admin-sidebar-paths.client.tsx +190 -0
- package/src/components/navigation/admin-sidebar-skeleton.tsx +44 -0
- package/src/components/navigation/admin-sidebar.client.tsx +123 -0
- package/src/components/ui/spinner.tsx +51 -0
- package/src/modules/auth/components/allowed.client.tsx +1 -1
- package/src/modules/auth/components/auth-layout.server.tsx +2 -10
- package/src/modules/auth/components/auth-loading.tsx +11 -0
- package/src/modules/auth/components/guard.client.tsx +12 -0
- package/src/modules/auth/components/login-page.client.tsx +45 -37
- package/src/modules/auth/entry.client.ts +2 -0
- package/src/modules/auth/entry.server.ts +1 -1
- package/src/modules/auth/entry.ts +1 -0
- package/src/modules/auth/handler/proxy.server.ts +28 -0
- package/src/modules/auth/handler/server.server.ts +5 -0
- package/src/modules/auth/hooks/{use-permission.client.ts → use-permission.ts} +4 -2
- package/src/modules/auth/hooks/use-session.ts +18 -0
- package/src/modules/auth/lib/helpers.server.ts +1 -5
- package/src/modules/auth/lib/validators.ts +1 -1
- package/src/modules/commands/hooks/use-command-menu.client.tsx +6 -7
- package/src/modules/commands/menus/dropdown-menu.client.tsx +11 -2
- package/src/modules/commands/menus/inline-menu.client.tsx +14 -1
- package/src/modules/commands/menus/responsive-menu.client.tsx +11 -2
- package/src/modules/config/entry.server.ts +1 -2
- package/src/modules/config/entry.ts +3 -0
- package/src/modules/config/lib/config.server.ts +1 -2
- package/src/modules/config/lib/router.server.ts +64 -0
- package/src/modules/config/paths/helpers.ts +6 -0
- package/src/modules/config/paths/types.ts +26 -38
- package/src/modules/data-tables/components/filters/combobox.client.tsx +1 -1
- package/src/modules/data-tables/tables/inline-table/hooks/use-input.client.ts +1 -1
- package/src/modules/inline-edit/hooks/use-inline.client.tsx +1 -1
- package/dist/components/layouts/admin-layout.server.d.ts +0 -14
- package/dist/components/layouts/admin-layout.server.d.ts.map +0 -1
- package/dist/components/layouts/admin-layout.server.js +0 -26
- package/dist/components/layouts/admin-layout.server.js.map +0 -1
- package/dist/components/layouts/admin-sidebar-context.client.js +0 -28
- package/dist/components/layouts/admin-sidebar-context.client.js.map +0 -1
- package/dist/components/layouts/admin-sidebar-header.client.js.map +0 -1
- package/dist/components/layouts/admin-sidebar.client.js +0 -51
- package/dist/components/layouts/admin-sidebar.client.js.map +0 -1
- package/dist/modules/auth/components/allowed.server.d.ts +0 -23
- package/dist/modules/auth/components/allowed.server.d.ts.map +0 -1
- package/dist/modules/auth/components/allowed.server.js +0 -24
- package/dist/modules/auth/components/allowed.server.js.map +0 -1
- package/dist/modules/auth/hooks/use-permission.client.js.map +0 -1
- package/dist/modules/config/paths/create.server.d.ts +0 -14
- package/dist/modules/config/paths/create.server.d.ts.map +0 -1
- package/dist/modules/config/paths/create.server.js +0 -12
- package/dist/modules/config/paths/create.server.js.map +0 -1
- package/dist/modules/config/paths/get.server.js +0 -47
- package/dist/modules/config/paths/get.server.js.map +0 -1
- package/src/components/layouts/admin-layout.server.tsx +0 -31
- package/src/components/layouts/admin-sidebar-context.client.tsx +0 -34
- package/src/components/layouts/admin-sidebar.client.tsx +0 -88
- package/src/modules/auth/components/allowed.server.tsx +0 -41
- package/src/modules/config/paths/create.server.ts +0 -10
- package/src/modules/config/paths/get.server.ts +0 -69
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { getSession } from "../lib/helpers.server.js";
|
|
2
|
-
import { getTulip } from "../../config/lib/resolve.server.js";
|
|
3
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
4
|
-
import "server-cli-only";
|
|
5
|
-
|
|
6
|
-
//#region src/modules/auth/components/allowed.server.tsx
|
|
7
|
-
async function Allowed({ config, permission, fallback, children }) {
|
|
8
|
-
const { auth } = await getTulip({ config });
|
|
9
|
-
const { user } = await getSession({ auth });
|
|
10
|
-
const { success, error } = await auth.api.userHasPermission({ body: {
|
|
11
|
-
userId: user.id,
|
|
12
|
-
permission
|
|
13
|
-
} });
|
|
14
|
-
if (error) {
|
|
15
|
-
console.error(error);
|
|
16
|
-
return /* @__PURE__ */ jsx(Fragment, { children: fallback });
|
|
17
|
-
}
|
|
18
|
-
if (success) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
19
|
-
return /* @__PURE__ */ jsx(Fragment, { children: fallback });
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
//#endregion
|
|
23
|
-
export { Allowed };
|
|
24
|
-
//# sourceMappingURL=allowed.server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"allowed.server.js","names":[],"sources":["../../../../src/modules/auth/components/allowed.server.tsx"],"sourcesContent":["import \"server-cli-only\";\n\nimport { type Permission } from \"@/modules/auth/lib/permissions\";\nimport { type TDatabaseSchema } from \"@/modules/config/db/types\";\nimport { TulipConfig } from \"@/modules/config/lib/config.server\";\nimport { getTulip } from \"@/modules/config/lib/resolve.server\";\nimport { JSX } from \"react\";\nimport { getSession } from \"../lib/helpers.server\";\n\ntype AllowedProps<TSchema extends TDatabaseSchema> = {\n config: TulipConfig<TSchema>;\n permission: Permission;\n fallback?: JSX.Element | string;\n children: React.ReactNode;\n};\n\nexport async function Allowed<TSchema extends TDatabaseSchema>({\n config,\n permission,\n fallback,\n children,\n}: AllowedProps<TSchema>) {\n const { auth } = await getTulip({ config });\n const { user } = await getSession({ auth });\n\n const { success, error } = await auth.api.userHasPermission({\n body: {\n userId: user.id,\n permission,\n },\n });\n\n if (error) {\n console.error(error);\n return <>{fallback}</>;\n }\n\n if (success) return <>{children}</>;\n\n return <>{fallback}</>;\n}\n"],"mappings":";;;;;;AAgBA,eAAsB,QAAyC,EAC7D,QACA,YACA,UACA,YACwB;CACxB,MAAM,EAAE,SAAS,MAAM,SAAS,EAAE,QAAQ,CAAC;CAC3C,MAAM,EAAE,SAAS,MAAM,WAAW,EAAE,MAAM,CAAC;CAE3C,MAAM,EAAE,SAAS,UAAU,MAAM,KAAK,IAAI,kBAAkB,EAC1D,MAAM;EACJ,QAAQ,KAAK;EACb;EACD,EACF,CAAC;AAEF,KAAI,OAAO;AACT,UAAQ,MAAM,MAAM;AACpB,SAAO,0CAAG,WAAY;;AAGxB,KAAI,QAAS,QAAO,gCAAG,WAAY;AAEnC,QAAO,0CAAG,WAAY"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-permission.client.js","names":["permission","permission: Permission"],"sources":["../../../../src/modules/auth/hooks/use-permission.client.ts"],"sourcesContent":["\"use client\";\n\nimport { useSuspenseQueries } from \"@tanstack/react-query\";\nimport { LiteralString } from \"better-auth\";\nimport { authClient } from \"../handler/client.client\";\nimport { type Permission } from \"../lib/permissions\";\n\n/**\n * UsePermission\n */\nexport function usePermission(permission?: Permission) {\n const keys = Object.entries(permission ?? {}).flatMap(([resource, permissions]) =>\n permissions.map((permission) => [resource, permission] as const),\n );\n\n return useSuspenseQueries({\n queries: keys.map((key) => ({\n queryKey: [\"permission\", ...key],\n queryFn: async () => {\n const resource = key[0]?.toString() as string;\n const permission: Permission = { [resource]: [key[1]] as LiteralString[] };\n\n const session = await authClient.getSession();\n const userId = session.data?.user.id;\n\n const { data, error } = await authClient.admin.hasPermission({ permission, userId });\n if (error) {\n console.error(error);\n throw error;\n }\n\n return {\n permission,\n success: data.success,\n };\n },\n })),\n combine: (results) => {\n const errors = results.filter(({ error }) => error);\n if (errors.length) return { data: null, errors };\n\n const values = results.map(({ data }) => data);\n const success = results.every(({ data }) => data.success);\n\n return { data: { success, values }, errors: null };\n },\n });\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,cAAc,YAAyB;AAKrD,QAAO,mBAAmB;EACxB,SALW,OAAO,QAAQ,cAAc,EAAE,CAAC,CAAC,SAAS,CAAC,UAAU,iBAChE,YAAY,KAAK,iBAAe,CAAC,UAAUA,aAAW,CAAU,CACjE,CAGe,KAAK,SAAS;GAC1B,UAAU,CAAC,cAAc,GAAG,IAAI;GAChC,SAAS,YAAY;IAEnB,MAAMC,eAAyB,GADd,IAAI,IAAI,UAAU,GACU,CAAC,IAAI,GAAG,EAAqB;IAG1E,MAAM,UADU,MAAM,WAAW,YAAY,EACtB,MAAM,KAAK;IAElC,MAAM,EAAE,MAAM,UAAU,MAAM,WAAW,MAAM,cAAc;KAAE;KAAY;KAAQ,CAAC;AACpF,QAAI,OAAO;AACT,aAAQ,MAAM,MAAM;AACpB,WAAM;;AAGR,WAAO;KACL;KACA,SAAS,KAAK;KACf;;GAEJ,EAAE;EACH,UAAU,YAAY;GACpB,MAAM,SAAS,QAAQ,QAAQ,EAAE,YAAY,MAAM;AACnD,OAAI,OAAO,OAAQ,QAAO;IAAE,MAAM;IAAM;IAAQ;GAEhD,MAAM,SAAS,QAAQ,KAAK,EAAE,WAAW,KAAK;AAG9C,UAAO;IAAE,MAAM;KAAE,SAFD,QAAQ,OAAO,EAAE,WAAW,KAAK,QAAQ;KAE/B;KAAQ;IAAE,QAAQ;IAAM;;EAErD,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TDatabaseSchema } from "../db/types.js";
|
|
2
|
-
import { PathConfig } from "./types.js";
|
|
3
|
-
import "server-cli-only";
|
|
4
|
-
|
|
5
|
-
//#region src/modules/config/paths/create.server.d.ts
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Create the paths object
|
|
9
|
-
* @param {(() => Promise<PathOutput>)[]} config
|
|
10
|
-
*/
|
|
11
|
-
declare const createPaths: <TSchema extends TDatabaseSchema>(paths: PathConfig<TSchema>) => PathConfig<TSchema>;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { createPaths };
|
|
14
|
-
//# sourceMappingURL=create.server.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.server.d.ts","names":[],"sources":["../../../../src/modules/config/paths/create.server.ts"],"sourcesContent":[],"mappings":";;;;;;;;AASA;;AAA4C,cAA/B,WAA+B,EAAA,CAAA,gBAAA,eAAA,CAAA,CAAA,KAAA,EAAwB,UAAxB,CAAmC,OAAnC,CAAA,EAAA,GAA2C,UAA3C,CAA2C,OAA3C,CAAA"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import "server-cli-only";
|
|
2
|
-
|
|
3
|
-
//#region src/modules/config/paths/create.server.ts
|
|
4
|
-
/**
|
|
5
|
-
* Create the paths object
|
|
6
|
-
* @param {(() => Promise<PathOutput>)[]} config
|
|
7
|
-
*/
|
|
8
|
-
const createPaths = (paths) => paths;
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
|
-
export { createPaths };
|
|
12
|
-
//# sourceMappingURL=create.server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create.server.js","names":[],"sources":["../../../../src/modules/config/paths/create.server.ts"],"sourcesContent":["import \"server-cli-only\";\n\nimport { TDatabaseSchema } from \"../db/types\";\nimport { PathConfig } from \"./types\";\n\n/**\n * Create the paths object\n * @param {(() => Promise<PathOutput>)[]} config\n */\nexport const createPaths = <TSchema extends TDatabaseSchema>(paths: PathConfig<TSchema>) => paths;\n"],"mappings":";;;;;;;AASA,MAAa,eAAgD,UAA+B"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { getSession } from "../../auth/lib/helpers.server.js";
|
|
2
|
-
import { cache, createElement } from "react";
|
|
3
|
-
import "server-cli-only";
|
|
4
|
-
|
|
5
|
-
//#region src/modules/config/paths/get.server.ts
|
|
6
|
-
/**
|
|
7
|
-
* Get the paths that the user has access to
|
|
8
|
-
* @param {(() => Promise<PathOutput>)[][]} paths
|
|
9
|
-
* @param {User} user
|
|
10
|
-
* @returns {Promise<PathInput[][]>}
|
|
11
|
-
*/
|
|
12
|
-
const getPaths = cache(async (config) => {
|
|
13
|
-
const session = await getSession(config);
|
|
14
|
-
/**
|
|
15
|
-
* Filter out empty groups
|
|
16
|
-
*/
|
|
17
|
-
return (await Promise.all(config.paths.map(async (group) => {
|
|
18
|
-
/**
|
|
19
|
-
* Initialise the path by executing the path function
|
|
20
|
-
*/
|
|
21
|
-
const initialisedPaths = await Promise.all(group.items.map((path) => path(config)));
|
|
22
|
-
/**
|
|
23
|
-
* Resolve the icon component
|
|
24
|
-
*/
|
|
25
|
-
const resolvedPaths = (await Promise.all(initialisedPaths.map(async (path) => {
|
|
26
|
-
if (!path.permission) return path;
|
|
27
|
-
if (!(await config.auth.api.userHasPermission({ body: {
|
|
28
|
-
permission: path.permission,
|
|
29
|
-
userId: session.user?.id
|
|
30
|
-
} })).success) return null;
|
|
31
|
-
return path;
|
|
32
|
-
}))).filter((path) => !!path).map((path) => {
|
|
33
|
-
return {
|
|
34
|
-
...path,
|
|
35
|
-
icon: path.icon ? createElement(path.icon) : void 0
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
return {
|
|
39
|
-
...group,
|
|
40
|
-
items: resolvedPaths
|
|
41
|
-
};
|
|
42
|
-
}))).filter((group) => group.items.length > 0);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
//#endregion
|
|
46
|
-
export { getPaths };
|
|
47
|
-
//# sourceMappingURL=get.server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get.server.js","names":[],"sources":["../../../../src/modules/config/paths/get.server.ts"],"sourcesContent":["import \"server-cli-only\";\n\nimport { getSession } from \"@/modules/auth/lib/helpers.server\";\nimport { cache, createElement } from \"react\";\nimport { TDatabaseSchema } from \"../db/types\";\nimport { GetTulipReturn } from \"../lib/resolve.server\";\nimport { PathResult } from \"./types\";\n\n/**\n * Get the paths that the user has access to\n * @param {(() => Promise<PathOutput>)[][]} paths\n * @param {User} user\n * @returns {Promise<PathInput[][]>}\n */\nexport const getPaths = cache(\n async <TSchema extends TDatabaseSchema>(config: GetTulipReturn<TSchema>): Promise<PathResult> => {\n const session = await getSession(config);\n\n /**\n * Initialise the paths by executing the path functions\n */\n const resolvedPaths = await Promise.all(\n config.paths.map(async (group) => {\n /**\n * Initialise the path by executing the path function\n */\n const initialisedPaths = await Promise.all(group.items.map((path) => path(config)));\n\n /**\n * Filter out paths that the user doesn't have permission for\n */\n const validatedPaths = await Promise.all(\n initialisedPaths.map(async (path) => {\n if (!path.permission) return path;\n\n const hasPermission = await config.auth.api.userHasPermission({\n body: {\n permission: path.permission,\n userId: session.user?.id,\n },\n });\n if (!hasPermission.success) return null;\n\n return path;\n }),\n );\n\n /**\n * Resolve the icon component\n */\n const resolvedPaths = validatedPaths\n .filter((path) => !!path)\n .map((path) => {\n return {\n ...path,\n icon: path.icon ? createElement(path.icon) : undefined,\n };\n });\n\n return { ...group, items: resolvedPaths };\n }),\n );\n\n /**\n * Filter out empty groups\n */\n return resolvedPaths.filter((group) => group.items.length > 0);\n },\n);\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,WAAW,MACtB,OAAwC,WAAyD;CAC/F,MAAM,UAAU,MAAM,WAAW,OAAO;;;;AAkDxC,SA7CsB,MAAM,QAAQ,IAClC,OAAO,MAAM,IAAI,OAAO,UAAU;;;;EAIhC,MAAM,mBAAmB,MAAM,QAAQ,IAAI,MAAM,MAAM,KAAK,SAAS,KAAK,OAAO,CAAC,CAAC;;;;EAwBnF,MAAM,iBAnBiB,MAAM,QAAQ,IACnC,iBAAiB,IAAI,OAAO,SAAS;AACnC,OAAI,CAAC,KAAK,WAAY,QAAO;AAQ7B,OAAI,EANkB,MAAM,OAAO,KAAK,IAAI,kBAAkB,EAC5D,MAAM;IACJ,YAAY,KAAK;IACjB,QAAQ,QAAQ,MAAM;IACvB,EACF,CAAC,EACiB,QAAS,QAAO;AAEnC,UAAO;IACP,CACH,EAME,QAAQ,SAAS,CAAC,CAAC,KAAK,CACxB,KAAK,SAAS;AACb,UAAO;IACL,GAAG;IACH,MAAM,KAAK,OAAO,cAAc,KAAK,KAAK,GAAG;IAC9C;IACD;AAEJ,SAAO;GAAE,GAAG;GAAO,OAAO;GAAe;GACzC,CACH,EAKoB,QAAQ,UAAU,MAAM,MAAM,SAAS,EAAE;EAEjE"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import "server-cli-only";
|
|
2
|
-
|
|
3
|
-
import { getSession } from "@/modules/auth/lib/helpers.server";
|
|
4
|
-
import { TDatabaseSchema } from "@/modules/config/db/types";
|
|
5
|
-
import { getTulip, GetTulipParams } from "@/modules/config/lib/resolve.server";
|
|
6
|
-
import { getPaths } from "@/modules/config/paths/get.server";
|
|
7
|
-
import { PropsWithChildren } from "react";
|
|
8
|
-
import { AdminContent } from "./admin-content.client";
|
|
9
|
-
import { AdminSidebarProvider } from "./admin-sidebar-context.client";
|
|
10
|
-
import { AdminSidebar } from "./admin-sidebar.client";
|
|
11
|
-
|
|
12
|
-
export async function AdminLayout<TSchema extends TDatabaseSchema>({
|
|
13
|
-
config,
|
|
14
|
-
children,
|
|
15
|
-
}: PropsWithChildren<GetTulipParams<TSchema>>) {
|
|
16
|
-
const tulip = await getTulip({ config });
|
|
17
|
-
const session = await getSession(tulip);
|
|
18
|
-
|
|
19
|
-
const paths = await getPaths(tulip);
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<AdminSidebarProvider
|
|
23
|
-
value={{ paths, session }}
|
|
24
|
-
className="max-h-[100dvh] overflow-hidden border"
|
|
25
|
-
>
|
|
26
|
-
<AdminSidebar />
|
|
27
|
-
|
|
28
|
-
<AdminContent>{children}</AdminContent>
|
|
29
|
-
</AdminSidebarProvider>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { ClientSession } from "@/modules/auth/handler/client.client";
|
|
4
|
-
import { PathResult } from "@/modules/config/paths/types";
|
|
5
|
-
import React from "react";
|
|
6
|
-
import { SidebarProvider } from "../entry.client";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* AdminSidebarContextValue
|
|
10
|
-
*/
|
|
11
|
-
type AdminSidebarContextValue = {
|
|
12
|
-
paths: PathResult;
|
|
13
|
-
session: ClientSession;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* AdminSidebarContext
|
|
18
|
-
*/
|
|
19
|
-
export const AdminSidebarContext = React.createContext({} as AdminSidebarContextValue);
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* AdminSidebarProvider
|
|
23
|
-
*/
|
|
24
|
-
export function AdminSidebarProvider({
|
|
25
|
-
value,
|
|
26
|
-
children,
|
|
27
|
-
...props
|
|
28
|
-
}: React.ComponentProps<typeof SidebarProvider> & { value: AdminSidebarContextValue }) {
|
|
29
|
-
return (
|
|
30
|
-
<SidebarProvider {...props}>
|
|
31
|
-
<AdminSidebarContext.Provider value={value}>{children}</AdminSidebarContext.Provider>
|
|
32
|
-
</SidebarProvider>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Sidebar,
|
|
5
|
-
SidebarContent,
|
|
6
|
-
SidebarGroup,
|
|
7
|
-
SidebarGroupContent,
|
|
8
|
-
SidebarGroupLabel,
|
|
9
|
-
SidebarMenu,
|
|
10
|
-
SidebarMenuButton,
|
|
11
|
-
SidebarMenuItem,
|
|
12
|
-
SidebarMenuSub,
|
|
13
|
-
SidebarMenuSubButton,
|
|
14
|
-
SidebarMenuSubItem,
|
|
15
|
-
SidebarRail,
|
|
16
|
-
useSidebar,
|
|
17
|
-
} from "@/components/ui/sidebar.client";
|
|
18
|
-
import Link from "next/link";
|
|
19
|
-
import { useSelectedLayoutSegments } from "next/navigation";
|
|
20
|
-
import * as React from "react";
|
|
21
|
-
import { AdminSidebarContext } from "./admin-sidebar-context.client";
|
|
22
|
-
import { AdminSidebarHeader } from "./admin-sidebar-header.client";
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* AdminSidebar
|
|
26
|
-
*/
|
|
27
|
-
export function AdminSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
|
28
|
-
const currentSegments = useSelectedLayoutSegments();
|
|
29
|
-
|
|
30
|
-
const { paths } = React.useContext(AdminSidebarContext);
|
|
31
|
-
const { isMobile, toggleSidebar } = useSidebar();
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<Sidebar {...props}>
|
|
35
|
-
<AdminSidebarHeader />
|
|
36
|
-
|
|
37
|
-
<SidebarContent>
|
|
38
|
-
<SidebarMenu>
|
|
39
|
-
{paths.map((group, index) => (
|
|
40
|
-
<SidebarGroup key={index}>
|
|
41
|
-
{group.name && <SidebarGroupLabel>{group.name}</SidebarGroupLabel>}
|
|
42
|
-
|
|
43
|
-
<SidebarGroupContent>
|
|
44
|
-
<SidebarMenu>
|
|
45
|
-
{group.items.map((item) => {
|
|
46
|
-
const isActive = item.isActive || item.segment === currentSegments?.[0];
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<SidebarMenuItem key={item.name}>
|
|
50
|
-
<SidebarMenuButton asChild isActive={isActive}>
|
|
51
|
-
<Link href={item.href} onClick={isMobile ? toggleSidebar : undefined}>
|
|
52
|
-
{item.icon}
|
|
53
|
-
{item.name}
|
|
54
|
-
</Link>
|
|
55
|
-
</SidebarMenuButton>
|
|
56
|
-
|
|
57
|
-
{isActive && !!item.items?.length && (
|
|
58
|
-
<SidebarMenuSub>
|
|
59
|
-
{item.items.map((subItem) => (
|
|
60
|
-
<SidebarMenuSubItem key={subItem.name}>
|
|
61
|
-
<SidebarMenuSubButton
|
|
62
|
-
asChild
|
|
63
|
-
isActive={subItem.segment === currentSegments?.[1]}
|
|
64
|
-
>
|
|
65
|
-
<Link
|
|
66
|
-
href={subItem.href}
|
|
67
|
-
onClick={isMobile ? toggleSidebar : undefined}
|
|
68
|
-
>
|
|
69
|
-
{subItem.name}
|
|
70
|
-
</Link>
|
|
71
|
-
</SidebarMenuSubButton>
|
|
72
|
-
</SidebarMenuSubItem>
|
|
73
|
-
))}
|
|
74
|
-
</SidebarMenuSub>
|
|
75
|
-
)}
|
|
76
|
-
</SidebarMenuItem>
|
|
77
|
-
);
|
|
78
|
-
})}
|
|
79
|
-
</SidebarMenu>
|
|
80
|
-
</SidebarGroupContent>
|
|
81
|
-
</SidebarGroup>
|
|
82
|
-
))}
|
|
83
|
-
</SidebarMenu>
|
|
84
|
-
</SidebarContent>
|
|
85
|
-
<SidebarRail />
|
|
86
|
-
</Sidebar>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import "server-cli-only";
|
|
2
|
-
|
|
3
|
-
import { type Permission } from "@/modules/auth/lib/permissions";
|
|
4
|
-
import { type TDatabaseSchema } from "@/modules/config/db/types";
|
|
5
|
-
import { TulipConfig } from "@/modules/config/lib/config.server";
|
|
6
|
-
import { getTulip } from "@/modules/config/lib/resolve.server";
|
|
7
|
-
import { JSX } from "react";
|
|
8
|
-
import { getSession } from "../lib/helpers.server";
|
|
9
|
-
|
|
10
|
-
type AllowedProps<TSchema extends TDatabaseSchema> = {
|
|
11
|
-
config: TulipConfig<TSchema>;
|
|
12
|
-
permission: Permission;
|
|
13
|
-
fallback?: JSX.Element | string;
|
|
14
|
-
children: React.ReactNode;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export async function Allowed<TSchema extends TDatabaseSchema>({
|
|
18
|
-
config,
|
|
19
|
-
permission,
|
|
20
|
-
fallback,
|
|
21
|
-
children,
|
|
22
|
-
}: AllowedProps<TSchema>) {
|
|
23
|
-
const { auth } = await getTulip({ config });
|
|
24
|
-
const { user } = await getSession({ auth });
|
|
25
|
-
|
|
26
|
-
const { success, error } = await auth.api.userHasPermission({
|
|
27
|
-
body: {
|
|
28
|
-
userId: user.id,
|
|
29
|
-
permission,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
if (error) {
|
|
34
|
-
console.error(error);
|
|
35
|
-
return <>{fallback}</>;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (success) return <>{children}</>;
|
|
39
|
-
|
|
40
|
-
return <>{fallback}</>;
|
|
41
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import "server-cli-only";
|
|
2
|
-
|
|
3
|
-
import { TDatabaseSchema } from "../db/types";
|
|
4
|
-
import { PathConfig } from "./types";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Create the paths object
|
|
8
|
-
* @param {(() => Promise<PathOutput>)[]} config
|
|
9
|
-
*/
|
|
10
|
-
export const createPaths = <TSchema extends TDatabaseSchema>(paths: PathConfig<TSchema>) => paths;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import "server-cli-only";
|
|
2
|
-
|
|
3
|
-
import { getSession } from "@/modules/auth/lib/helpers.server";
|
|
4
|
-
import { cache, createElement } from "react";
|
|
5
|
-
import { TDatabaseSchema } from "../db/types";
|
|
6
|
-
import { GetTulipReturn } from "../lib/resolve.server";
|
|
7
|
-
import { PathResult } from "./types";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Get the paths that the user has access to
|
|
11
|
-
* @param {(() => Promise<PathOutput>)[][]} paths
|
|
12
|
-
* @param {User} user
|
|
13
|
-
* @returns {Promise<PathInput[][]>}
|
|
14
|
-
*/
|
|
15
|
-
export const getPaths = cache(
|
|
16
|
-
async <TSchema extends TDatabaseSchema>(config: GetTulipReturn<TSchema>): Promise<PathResult> => {
|
|
17
|
-
const session = await getSession(config);
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Initialise the paths by executing the path functions
|
|
21
|
-
*/
|
|
22
|
-
const resolvedPaths = await Promise.all(
|
|
23
|
-
config.paths.map(async (group) => {
|
|
24
|
-
/**
|
|
25
|
-
* Initialise the path by executing the path function
|
|
26
|
-
*/
|
|
27
|
-
const initialisedPaths = await Promise.all(group.items.map((path) => path(config)));
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Filter out paths that the user doesn't have permission for
|
|
31
|
-
*/
|
|
32
|
-
const validatedPaths = await Promise.all(
|
|
33
|
-
initialisedPaths.map(async (path) => {
|
|
34
|
-
if (!path.permission) return path;
|
|
35
|
-
|
|
36
|
-
const hasPermission = await config.auth.api.userHasPermission({
|
|
37
|
-
body: {
|
|
38
|
-
permission: path.permission,
|
|
39
|
-
userId: session.user?.id,
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
if (!hasPermission.success) return null;
|
|
43
|
-
|
|
44
|
-
return path;
|
|
45
|
-
}),
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Resolve the icon component
|
|
50
|
-
*/
|
|
51
|
-
const resolvedPaths = validatedPaths
|
|
52
|
-
.filter((path) => !!path)
|
|
53
|
-
.map((path) => {
|
|
54
|
-
return {
|
|
55
|
-
...path,
|
|
56
|
-
icon: path.icon ? createElement(path.icon) : undefined,
|
|
57
|
-
};
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
return { ...group, items: resolvedPaths };
|
|
61
|
-
}),
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Filter out empty groups
|
|
66
|
-
*/
|
|
67
|
-
return resolvedPaths.filter((group) => group.items.length > 0);
|
|
68
|
-
},
|
|
69
|
-
);
|