@tulip-systems/core 0.4.1 → 0.5.1
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.mts +2 -2
- package/dist/auth/client.mjs +2 -2
- package/dist/commands/client.d.mts +3 -3
- package/dist/commands/client.mjs +3 -3
- package/dist/components/client.d.mts +3 -5
- package/dist/components/client.mjs +3 -5
- package/dist/components/common/icons.d.mts +52 -52
- package/dist/components/common/status.d.mts +3 -3
- package/dist/components/editor/components/content.client.d.mts +2 -2
- package/dist/components/editor/components/content.client.mjs +1 -1
- package/dist/components/editor/components/content.client.mjs.map +1 -1
- package/dist/components/editor/components/editor.client.d.mts +48 -0
- package/dist/components/editor/components/editor.client.d.mts.map +1 -0
- package/dist/components/editor/components/editor.client.mjs +53 -0
- package/dist/components/editor/components/editor.client.mjs.map +1 -0
- package/dist/components/editor/components/{block-dropdown.mjs → menu-nodes.client.mjs} +25 -15
- package/dist/components/editor/components/menu-nodes.client.mjs.map +1 -0
- package/dist/components/editor/components/menu.client.d.mts +10 -0
- package/dist/components/editor/components/menu.client.d.mts.map +1 -0
- package/dist/components/editor/components/menu.client.mjs +166 -0
- package/dist/components/editor/components/menu.client.mjs.map +1 -0
- package/dist/components/editor/lib/constants.d.mts +60 -0
- package/dist/components/editor/lib/constants.d.mts.map +1 -0
- package/dist/components/editor/lib/constants.mjs +90 -0
- package/dist/components/editor/lib/constants.mjs.map +1 -0
- package/dist/components/editor/lib/extensions.d.mts +65 -0
- package/dist/components/editor/lib/extensions.d.mts.map +1 -0
- package/dist/components/editor/lib/extensions.mjs +52 -0
- package/dist/components/editor/lib/extensions.mjs.map +1 -0
- package/dist/components/editor/lib/helpers.mjs +3 -3
- package/dist/components/editor/lib/helpers.mjs.map +1 -1
- package/dist/components/editor/lib/variants.mjs +8 -0
- package/dist/components/editor/lib/variants.mjs.map +1 -0
- package/dist/components/header/back-button.client.d.mts +2 -2
- package/dist/components/header/bottom-bar.client.d.mts +3 -3
- package/dist/components/header/breadcrumbs.client.d.mts +7 -7
- package/dist/components/header/header.client.d.mts +2 -2
- package/dist/components/header/mobile-nav-switcher.client.d.mts +2 -2
- package/dist/components/header/top-bar.client.d.mts +4 -4
- package/dist/components/header/top-bar.client.mjs +1 -1
- package/dist/components/header/top-bar.client.mjs.map +1 -1
- package/dist/components/layouts/admin-content.client.d.mts +2 -2
- package/dist/components/layouts/admin-content.client.mjs +1 -1
- package/dist/components/layouts/admin-content.client.mjs.map +1 -1
- package/dist/components/layouts/admin-layout.d.mts +2 -2
- package/dist/components/layouts/admin-layout.d.mts.map +1 -1
- package/dist/components/layouts/admin-loading.d.mts +2 -2
- package/dist/components/layouts/empty-page.d.mts +4 -4
- package/dist/components/layouts/list-layout.d.mts +2 -2
- package/dist/components/layouts/not-found-page.d.mts +3 -3
- package/dist/components/layouts/providers.client.d.mts +2 -2
- package/dist/components/layouts/root-layout.server.d.mts +4 -4
- package/dist/components/layouts/root-layout.server.d.mts.map +1 -1
- package/dist/components/layouts/root-loading.d.mts +2 -2
- package/dist/components/layouts/tab-layout.d.mts +2 -2
- package/dist/components/lists/data-list.d.mts +5 -5
- package/dist/components/lists/data-stack.d.mts +8 -8
- package/dist/components/navigation/admin-sidebar-paths.client.d.mts +10 -10
- package/dist/components/ui/accordion.d.mts +5 -5
- package/dist/components/ui/alert-dialog.d.mts +12 -12
- package/dist/components/ui/alert.d.mts +6 -6
- package/dist/components/ui/aspect-ratio.d.mts +2 -2
- package/dist/components/ui/avatar.client.d.mts +4 -4
- package/dist/components/ui/badge.d.mts +4 -4
- package/dist/components/ui/breadcrumb.d.mts +8 -8
- package/dist/components/ui/breadcrumb.d.mts.map +1 -1
- package/dist/components/ui/button.d.mts +5 -5
- package/dist/components/ui/button.d.mts.map +1 -1
- package/dist/components/ui/calendar.d.mts +17 -4
- package/dist/components/ui/calendar.d.mts.map +1 -1
- package/dist/components/ui/calendar.mjs +90 -37
- package/dist/components/ui/calendar.mjs.map +1 -1
- package/dist/components/ui/card.d.mts +7 -7
- package/dist/components/ui/card.d.mts.map +1 -1
- package/dist/components/ui/carousel.d.mts +6 -6
- package/dist/components/ui/carousel.d.mts.map +1 -1
- package/dist/components/ui/chart.client.d.mts +5 -5
- package/dist/components/ui/checkbox.d.mts +2 -2
- package/dist/components/ui/checkbox.d.mts.map +1 -1
- package/dist/components/ui/collapsible.client.d.mts +4 -4
- package/dist/components/ui/color-picker.client.d.mts +2 -2
- package/dist/components/ui/combobox-dropdown.client.d.mts +2 -2
- package/dist/components/ui/combobox.client.d.mts +2 -2
- package/dist/components/ui/command.d.mts +10 -10
- package/dist/components/ui/command.d.mts.map +1 -1
- package/dist/components/ui/context-menu.d.mts +16 -16
- package/dist/components/ui/date-picker.client.d.mts +2 -2
- package/dist/components/ui/dialog.client.d.mts +11 -11
- package/dist/components/ui/drawer.client.d.mts +11 -11
- package/dist/components/ui/dropdown-menu.d.mts +16 -16
- package/dist/components/ui/form.client.d.mts +7 -7
- package/dist/components/ui/hover-card.client.d.mts +4 -4
- package/dist/components/ui/input-recipient.d.mts +3 -1
- package/dist/components/ui/input-recipient.d.mts.map +1 -1
- package/dist/components/ui/input-recipient.mjs +2 -2
- package/dist/components/ui/input-recipient.mjs.map +1 -1
- package/dist/components/ui/input.d.mts +2 -2
- package/dist/components/ui/label.d.mts +2 -2
- package/dist/components/ui/navigation-menu.d.mts +11 -11
- package/dist/components/ui/pagination.d.mts +8 -8
- package/dist/components/ui/popover.d.mts +5 -5
- package/dist/components/ui/progress.client.d.mts +2 -2
- package/dist/components/ui/radio-group.d.mts +3 -3
- package/dist/components/ui/resizable.client.d.mts +4 -4
- package/dist/components/ui/scroll-area.d.mts +3 -3
- package/dist/components/ui/select.client.d.mts +11 -11
- package/dist/components/ui/separator.d.mts +2 -2
- package/dist/components/ui/sheet.client.d.mts +9 -9
- package/dist/components/ui/sidebar.client.d.mts +26 -26
- package/dist/components/ui/skeleton.d.mts +2 -2
- package/dist/components/ui/slider.d.mts +2 -2
- package/dist/components/ui/sonner.client.d.mts +2 -2
- package/dist/components/ui/switch.d.mts +2 -2
- package/dist/components/ui/tabs.d.mts +5 -5
- package/dist/components/ui/textarea.d.mts +2 -2
- package/dist/components/ui/time-input.client.d.mts +2 -2
- package/dist/components/ui/toggle-group.client.d.mts +3 -3
- package/dist/components/ui/toggle.d.mts +4 -4
- package/dist/components/ui/toggle.d.mts.map +1 -1
- package/dist/components/ui/tooltip.client.d.mts +5 -5
- package/dist/components/ui/tooltip.client.d.mts.map +1 -1
- package/dist/components.d.mts +2 -2
- package/dist/components.mjs +2 -2
- package/dist/config/server.d.mts +1 -2
- package/dist/config/server.mjs +1 -2
- package/dist/data-tables.d.mts +6 -5
- package/dist/data-tables.mjs +4 -3
- package/dist/inline-edit/client.d.mts +4 -4
- package/dist/inline-edit/client.mjs +3 -3
- package/dist/lib/hooks/use-action.d.mts +2 -2
- package/dist/lib/hooks/use-indicator.d.mts +2 -2
- package/dist/lib/hooks/use-indicator.d.mts.map +1 -1
- package/dist/lib.mjs +1 -1
- package/dist/modules/auth/components/allowed.client.d.mts +2 -2
- package/dist/modules/auth/components/allowed.client.d.mts.map +1 -1
- package/dist/modules/auth/components/auth-layout.server.d.mts +2 -2
- package/dist/modules/auth/components/auth-layout.server.d.mts.map +1 -1
- package/dist/modules/auth/components/auth-loading.d.mts +2 -2
- package/dist/modules/auth/components/auth-loading.d.mts.map +1 -1
- package/dist/modules/auth/components/create-first-user-page.client.d.mts +2 -2
- package/dist/modules/auth/components/create-first-user-page.client.d.mts.map +1 -1
- package/dist/modules/auth/components/forget-password-page.client.d.mts +2 -2
- package/dist/modules/auth/components/forget-password-page.client.d.mts.map +1 -1
- package/dist/modules/auth/components/guard-first-user.server.d.mts +2 -2
- package/dist/modules/auth/components/guard-first-user.server.d.mts.map +1 -1
- package/dist/modules/auth/components/guard.server.d.mts +2 -2
- package/dist/modules/auth/components/guard.server.d.mts.map +1 -1
- package/dist/modules/auth/components/login-page.client.d.mts +2 -2
- package/dist/modules/auth/components/login-page.client.d.mts.map +1 -1
- package/dist/modules/auth/components/reset-password-page.client.d.mts +2 -2
- package/dist/modules/auth/components/reset-password-page.client.d.mts.map +1 -1
- package/dist/modules/auth/components/update-password-command.d.mts +2 -2
- package/dist/modules/auth/components/update-password-command.d.mts.map +1 -1
- package/dist/modules/auth/db/schema.d.mts +247 -230
- package/dist/modules/auth/db/schema.d.mts.map +1 -1
- package/dist/modules/auth/db/schema.mjs +12 -20
- package/dist/modules/auth/db/schema.mjs.map +1 -1
- package/dist/modules/auth/handler/client.client.d.mts +131 -131
- package/dist/modules/auth/handler/client.client.d.mts.map +1 -1
- package/dist/modules/auth/handler/client.client.mjs +10 -6
- package/dist/modules/auth/handler/client.client.mjs.map +1 -1
- package/dist/modules/auth/handler/init.d.mts +134 -131
- package/dist/modules/auth/handler/init.d.mts.map +1 -1
- package/dist/modules/auth/handler/init.mjs +5 -2
- package/dist/modules/auth/handler/init.mjs.map +1 -1
- package/dist/modules/auth/hooks/use-permission.d.mts +2 -2
- package/dist/modules/auth/hooks/use-permission.d.mts.map +1 -1
- package/dist/modules/auth/hooks/use-permission.mjs +7 -2
- package/dist/modules/auth/hooks/use-permission.mjs.map +1 -1
- package/dist/modules/auth/hooks/use-session.d.mts +119 -3
- package/dist/modules/auth/hooks/use-session.d.mts.map +1 -1
- package/dist/modules/auth/hooks/use-session.mjs +15 -10
- package/dist/modules/auth/hooks/use-session.mjs.map +1 -1
- package/dist/modules/auth/lib/helpers.server.d.mts +5 -5
- package/dist/modules/auth/lib/helpers.server.d.mts.map +1 -1
- package/dist/modules/auth/lib/validators.d.mts +3 -3
- package/dist/modules/auth/lib/validators.d.mts.map +1 -1
- package/dist/modules/auth/lib/validators.mjs +1 -1
- package/dist/modules/auth/lib/validators.mjs.map +1 -1
- package/dist/modules/commands/components/alert-dialog-command.client.d.mts +10 -10
- package/dist/modules/commands/components/alert-dialog-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/alert-dialog-command.client.mjs +2 -2
- package/dist/modules/commands/components/alert-dialog-command.client.mjs.map +1 -1
- package/dist/modules/commands/components/click-command.client.d.mts +2 -2
- package/dist/modules/commands/components/click-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/click-command.client.mjs +2 -2
- package/dist/modules/commands/components/click-command.client.mjs.map +1 -1
- package/dist/modules/commands/components/command-trigger.client.d.mts +6 -6
- package/dist/modules/commands/components/command-trigger.client.d.mts.map +1 -1
- package/dist/modules/commands/components/dialog-command.client.d.mts +18 -8
- package/dist/modules/commands/components/dialog-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/dialog-command.client.mjs +12 -8
- package/dist/modules/commands/components/dialog-command.client.mjs.map +1 -1
- package/dist/modules/commands/components/dropdown-command.client.d.mts +5 -5
- package/dist/modules/commands/components/dropdown-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/dropdown-command.client.mjs +2 -2
- package/dist/modules/commands/components/dropdown-command.client.mjs.map +1 -1
- package/dist/modules/commands/components/empty-command.client.d.mts +2 -2
- package/dist/modules/commands/components/empty-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/form-dialog-command.client.d.mts +11 -11
- package/dist/modules/commands/components/form-dialog-command.client.d.mts.map +1 -1
- package/dist/modules/commands/components/form-dialog-command.client.mjs +2 -2
- package/dist/modules/commands/components/form-dialog-command.client.mjs.map +1 -1
- package/dist/modules/commands/hooks/use-command-mutation.client.d.mts +17 -0
- package/dist/modules/commands/hooks/use-command-mutation.client.d.mts.map +1 -0
- package/dist/modules/commands/hooks/use-command-mutation.client.mjs +42 -0
- package/dist/modules/commands/hooks/use-command-mutation.client.mjs.map +1 -0
- package/dist/modules/commands/menus/context-menu.client.d.mts +2 -2
- package/dist/modules/commands/menus/context-menu.client.d.mts.map +1 -1
- package/dist/modules/commands/menus/dropdown-menu.client.d.mts +3 -3
- package/dist/modules/commands/menus/dropdown-menu.client.d.mts.map +1 -1
- package/dist/modules/commands/menus/inline-menu.client.d.mts +3 -3
- package/dist/modules/commands/menus/inline-menu.client.d.mts.map +1 -1
- package/dist/modules/commands/menus/responsive-menu.client.d.mts +3 -3
- package/dist/modules/commands/menus/responsive-menu.client.d.mts.map +1 -1
- package/dist/modules/commands/utils/archive-command.client.d.mts +3 -3
- package/dist/modules/commands/utils/archive-command.client.d.mts.map +1 -1
- package/dist/modules/commands/utils/delete-command.client.d.mts +13 -8
- package/dist/modules/commands/utils/delete-command.client.d.mts.map +1 -1
- package/dist/modules/commands/utils/delete-command.client.mjs +10 -1
- package/dist/modules/commands/utils/delete-command.client.mjs.map +1 -1
- package/dist/modules/config/db/helpers.d.mts +5 -5
- package/dist/modules/config/db/helpers.d.mts.map +1 -1
- package/dist/modules/config/lib/config.d.mts +3 -3
- package/dist/modules/config/lib/config.d.mts.map +1 -1
- package/dist/modules/config/lib/config.mjs.map +1 -1
- package/dist/modules/config/lib/context.d.mts +2 -2
- package/dist/modules/config/lib/context.d.mts.map +1 -1
- package/dist/modules/config/lib/context.mjs.map +1 -1
- package/dist/modules/data-tables/components/cell/common.client.d.mts +5 -5
- package/dist/modules/data-tables/components/column-header.d.mts +2 -2
- package/dist/modules/data-tables/components/filters/combobox.client.d.mts +2 -2
- package/dist/modules/data-tables/components/filters/combobox.client.mjs +5 -2
- package/dist/modules/data-tables/components/filters/combobox.client.mjs.map +1 -1
- package/dist/modules/data-tables/components/filters/slider.client.d.mts +2 -2
- package/dist/modules/data-tables/components/header.d.mts +4 -4
- package/dist/modules/data-tables/components/layout.d.mts +2 -2
- package/dist/modules/data-tables/components/layout.d.mts.map +1 -1
- package/dist/modules/data-tables/components/search-input.client.d.mts +2 -2
- package/dist/modules/data-tables/components/skeleton.d.mts +2 -2
- package/dist/modules/data-tables/components/skeleton.d.mts.map +1 -1
- package/dist/modules/data-tables/components/table.d.mts +7 -7
- package/dist/modules/data-tables/components/table.d.mts.map +1 -1
- package/dist/modules/data-tables/components/toolbar.d.mts +3 -3
- package/dist/modules/data-tables/components/toolbar.d.mts.map +1 -1
- package/dist/modules/data-tables/hooks/use-context.client.d.mts +13 -10
- package/dist/modules/data-tables/hooks/use-context.client.d.mts.map +1 -1
- package/dist/modules/data-tables/hooks/use-context.client.mjs.map +1 -1
- package/dist/modules/data-tables/hooks/use-table.client.d.mts +2 -1
- package/dist/modules/data-tables/hooks/use-table.client.d.mts.map +1 -1
- package/dist/modules/data-tables/hooks/use-table.client.mjs.map +1 -1
- package/dist/modules/data-tables/lib/converters/search.d.mts +1 -1
- package/dist/modules/data-tables/lib/converters/sorting.d.mts +1 -1
- package/dist/modules/data-tables/lib/filters/config.d.mts +4 -1
- package/dist/modules/data-tables/lib/filters/config.d.mts.map +1 -1
- package/dist/modules/data-tables/lib/filters/config.mjs.map +1 -1
- package/dist/modules/data-tables/lib/filters/helpers.d.mts +11 -0
- package/dist/modules/data-tables/lib/filters/helpers.d.mts.map +1 -0
- package/dist/modules/data-tables/lib/filters/helpers.mjs +17 -0
- package/dist/modules/data-tables/lib/filters/helpers.mjs.map +1 -0
- package/dist/modules/data-tables/lib/filters/parsers.d.mts +7 -2
- package/dist/modules/data-tables/lib/filters/parsers.d.mts.map +1 -1
- package/dist/modules/data-tables/lib/filters/parsers.mjs +6 -1
- package/dist/modules/data-tables/lib/filters/parsers.mjs.map +1 -1
- package/dist/modules/data-tables/lib/filters/resolvers.d.mts +6 -1
- package/dist/modules/data-tables/lib/filters/resolvers.d.mts.map +1 -1
- package/dist/modules/data-tables/lib/filters/resolvers.mjs +8 -1
- package/dist/modules/data-tables/lib/filters/resolvers.mjs.map +1 -1
- package/dist/modules/data-tables/lib/types.d.mts +8 -5
- package/dist/modules/data-tables/lib/types.d.mts.map +1 -1
- package/dist/modules/data-tables/server/get-data.server.d.mts +1 -1
- package/dist/modules/data-tables/tables/data-table/components/table.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/cells/common.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.mjs +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.mjs.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/inputs/advanced-select.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/inputs/combobox.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/inputs/input.client.d.mts +3 -3
- package/dist/modules/data-tables/tables/inline-table/components/inputs/read-only.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/inputs/select.client.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/components/table.d.mts +2 -2
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts +2 -2
- package/dist/modules/inline-edit/components/combobox-dropdown.client.d.mts +5 -2
- package/dist/modules/inline-edit/components/combobox-dropdown.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/combobox-dropdown.client.mjs +7 -3
- package/dist/modules/inline-edit/components/combobox-dropdown.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/combobox.client.d.mts +3 -0
- package/dist/modules/inline-edit/components/combobox.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/combobox.client.mjs +6 -2
- package/dist/modules/inline-edit/components/combobox.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/date-input.client.d.mts +6 -3
- package/dist/modules/inline-edit/components/date-input.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/date-input.client.mjs +5 -3
- package/dist/modules/inline-edit/components/date-input.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/date-picker.client.d.mts +7 -3
- package/dist/modules/inline-edit/components/date-picker.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/date-picker.client.mjs +5 -3
- package/dist/modules/inline-edit/components/date-picker.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/deprecated-editor.client.d.mts +21 -0
- package/dist/modules/inline-edit/components/deprecated-editor.client.d.mts.map +1 -0
- package/dist/modules/inline-edit/components/deprecated-editor.client.mjs +37 -0
- package/dist/modules/inline-edit/components/deprecated-editor.client.mjs.map +1 -0
- package/dist/modules/inline-edit/components/editor.client.d.mts +10 -7
- package/dist/modules/inline-edit/components/editor.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/editor.client.mjs +13 -18
- package/dist/modules/inline-edit/components/editor.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/input-recipient.client.d.mts +4 -2
- package/dist/modules/inline-edit/components/input-recipient.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/input-recipient.client.mjs +7 -3
- package/dist/modules/inline-edit/components/input-recipient.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/input-toggle.client.d.mts +3 -2
- package/dist/modules/inline-edit/components/input-toggle.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/input-toggle.client.mjs +3 -2
- package/dist/modules/inline-edit/components/input-toggle.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/input.client.d.mts +18 -4
- package/dist/modules/inline-edit/components/input.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/input.client.mjs +26 -5
- package/dist/modules/inline-edit/components/input.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/select.client.d.mts +8 -6
- package/dist/modules/inline-edit/components/select.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/select.client.mjs +3 -2
- package/dist/modules/inline-edit/components/select.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/switch.client.d.mts +1 -0
- package/dist/modules/inline-edit/components/switch.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/switch.client.mjs +3 -2
- package/dist/modules/inline-edit/components/switch.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/toggle.client.d.mts +1 -0
- package/dist/modules/inline-edit/components/toggle.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/toggle.client.mjs +3 -2
- package/dist/modules/inline-edit/components/toggle.client.mjs.map +1 -1
- package/dist/modules/inline-edit/hooks/context.client.d.mts +2 -2
- package/dist/modules/inline-edit/hooks/use-inline.client.d.mts +1 -1
- package/dist/modules/inline-edit/hooks/use-inline.client.mjs.map +1 -1
- package/dist/modules/inline-edit/lib/variants.d.mts +2 -2
- package/dist/modules/inline-edit/lib/variants.mjs +1 -1
- package/dist/modules/inline-edit/lib/variants.mjs.map +1 -1
- package/dist/modules/router/handler/context.server.d.mts +2 -2
- package/dist/modules/router/handler/context.server.d.mts.map +1 -1
- package/dist/modules/router/handler/init.server.d.mts +7 -7
- package/dist/modules/{uploads/components/dropzone/context.d.mts → storage/components/dropzone-context.client.d.mts} +2 -2
- package/dist/modules/storage/components/dropzone-context.client.d.mts.map +1 -0
- package/dist/modules/{uploads/components/dropzone/context.mjs → storage/components/dropzone-context.client.mjs} +2 -2
- package/dist/modules/storage/components/dropzone-context.client.mjs.map +1 -0
- package/dist/modules/{uploads/components/dropzone/index.d.mts → storage/components/dropzone.client.d.mts} +6 -6
- package/dist/modules/storage/components/dropzone.client.d.mts.map +1 -0
- package/dist/modules/{uploads/components/dropzone/index.mjs → storage/components/dropzone.client.mjs} +6 -6
- package/dist/modules/storage/components/dropzone.client.mjs.map +1 -0
- package/dist/modules/storage/components/image-grid.client.d.mts +26 -0
- package/dist/modules/storage/components/image-grid.client.d.mts.map +1 -0
- package/dist/modules/storage/components/image-grid.client.mjs +169 -0
- package/dist/modules/storage/components/image-grid.client.mjs.map +1 -0
- package/dist/modules/storage/components/upload-zone-context.client.d.mts +34 -0
- package/dist/modules/storage/components/upload-zone-context.client.d.mts.map +1 -0
- package/dist/modules/storage/components/upload-zone-context.client.mjs +21 -0
- package/dist/modules/storage/components/upload-zone-context.client.mjs.map +1 -0
- package/dist/modules/storage/components/upload-zone.client.d.mts +51 -0
- package/dist/modules/storage/components/upload-zone.client.d.mts.map +1 -0
- package/dist/modules/storage/components/upload-zone.client.mjs +196 -0
- package/dist/modules/storage/components/upload-zone.client.mjs.map +1 -0
- package/dist/modules/{uploads/lib → storage/config}/filters.d.mts +2 -2
- package/dist/modules/storage/config/filters.d.mts.map +1 -0
- package/dist/modules/{uploads/lib → storage/config}/filters.mjs +3 -3
- package/dist/modules/storage/config/filters.mjs.map +1 -0
- package/dist/modules/storage/lib/constants.d.mts +10 -0
- package/dist/modules/storage/lib/constants.d.mts.map +1 -0
- package/dist/modules/{uploads → storage}/lib/constants.mjs +3 -2
- package/dist/modules/storage/lib/constants.mjs.map +1 -0
- package/dist/modules/storage/lib/create-client.server.d.mts +11 -0
- package/dist/modules/storage/lib/create-client.server.d.mts.map +1 -0
- package/dist/modules/storage/lib/create-client.server.mjs +11 -0
- package/dist/modules/storage/lib/create-client.server.mjs.map +1 -0
- package/dist/modules/storage/lib/helpers.d.mts +45 -0
- package/dist/modules/storage/lib/helpers.d.mts.map +1 -0
- package/dist/modules/{uploads → storage}/lib/helpers.mjs +20 -6
- package/dist/modules/storage/lib/helpers.mjs.map +1 -0
- package/dist/modules/storage/lib/proxy.server.d.mts +21 -0
- package/dist/modules/storage/lib/proxy.server.d.mts.map +1 -0
- package/dist/modules/storage/lib/proxy.server.mjs +46 -0
- package/dist/modules/storage/lib/proxy.server.mjs.map +1 -0
- package/dist/modules/storage/lib/router.server.d.mts +29074 -0
- package/dist/modules/storage/lib/router.server.d.mts.map +1 -0
- package/dist/modules/storage/lib/router.server.mjs +84 -0
- package/dist/modules/storage/lib/router.server.mjs.map +1 -0
- package/dist/modules/{uploads → storage}/lib/schema.d.mts +414 -150
- package/dist/modules/storage/lib/schema.d.mts.map +1 -0
- package/dist/modules/{uploads → storage}/lib/schema.mjs +23 -18
- package/dist/modules/storage/lib/schema.mjs.map +1 -0
- package/dist/modules/storage/lib/service.server.d.mts +188 -0
- package/dist/modules/storage/lib/service.server.d.mts.map +1 -0
- package/dist/modules/storage/lib/service.server.mjs +298 -0
- package/dist/modules/storage/lib/service.server.mjs.map +1 -0
- package/dist/modules/{uploads → storage}/lib/validators.d.mts +358 -53
- package/dist/modules/storage/lib/validators.d.mts.map +1 -0
- package/dist/modules/storage/lib/validators.mjs +106 -0
- package/dist/modules/storage/lib/validators.mjs.map +1 -0
- package/dist/storage/client.d.mts +6 -0
- package/dist/storage/client.mjs +14 -0
- package/dist/storage/client.mjs.map +1 -0
- package/dist/storage/server.d.mts +4 -0
- package/dist/storage/server.mjs +5 -0
- package/dist/storage.d.mts +6 -0
- package/dist/storage.mjs +7 -0
- package/package.json +32 -20
- package/src/components/editor/components/content.client.tsx +1 -1
- package/src/components/editor/components/editor.client.tsx +95 -0
- package/src/components/editor/components/{block-dropdown.tsx → menu-nodes.client.tsx} +17 -4
- package/src/components/editor/components/menu.client.tsx +214 -0
- package/src/components/editor/components/spinner.tsx +2 -2
- package/src/components/editor/lib/constants.ts +109 -0
- package/src/components/editor/lib/extensions.ts +195 -0
- package/src/components/editor/lib/helpers.ts +3 -3
- package/src/components/editor/lib/variants.ts +5 -0
- package/src/components/entry.client.ts +2 -4
- package/src/components/header/top-bar.client.tsx +1 -1
- package/src/components/layouts/admin-content.client.tsx +1 -1
- package/src/components/ui/calendar.tsx +152 -44
- package/src/components/ui/input-recipient.tsx +3 -0
- package/src/entry.ts +4 -4
- package/src/modules/auth/db/schema.ts +13 -21
- package/src/modules/auth/handler/client.client.ts +2 -0
- package/src/modules/auth/handler/init.ts +4 -1
- package/src/modules/auth/hooks/use-permission.ts +3 -2
- package/src/modules/auth/hooks/use-session.ts +16 -10
- package/src/modules/auth/lib/validators.ts +1 -1
- package/src/modules/commands/components/alert-dialog-command.client.tsx +2 -2
- package/src/modules/commands/components/click-command.client.tsx +2 -2
- package/src/modules/commands/components/dialog-command.client.tsx +20 -8
- package/src/modules/commands/components/dropdown-command.client.tsx +2 -2
- package/src/modules/commands/components/form-dialog-command.client.tsx +2 -2
- package/src/modules/commands/entry.client.ts +1 -1
- package/src/modules/commands/hooks/{use-command-action.client.tsx → use-command-mutation.client.tsx} +9 -47
- package/src/modules/commands/utils/delete-command.client.tsx +14 -2
- package/src/modules/config/db/create-client.ts +11 -4
- package/src/modules/config/entry.server.ts +0 -1
- package/src/modules/config/lib/config.ts +3 -3
- package/src/modules/config/lib/context.ts +2 -2
- package/src/modules/data-tables/components/filters/combobox.client.tsx +3 -3
- package/src/modules/data-tables/entry.ts +1 -1
- package/src/modules/data-tables/hooks/use-context.client.tsx +31 -13
- package/src/modules/data-tables/hooks/use-table.client.ts +6 -3
- package/src/modules/data-tables/lib/filters/config.ts +1 -0
- package/src/modules/data-tables/lib/filters/helpers.ts +19 -0
- package/src/modules/data-tables/lib/filters/parsers.ts +14 -1
- package/src/modules/data-tables/lib/filters/resolvers.ts +8 -0
- package/src/modules/data-tables/lib/types.ts +10 -3
- package/src/modules/data-tables/tables/inline-table/components/cells/drag-handle.client.tsx +1 -1
- package/src/modules/inline-edit/components/combobox-dropdown.client.tsx +9 -2
- package/src/modules/inline-edit/components/combobox.client.tsx +8 -1
- package/src/modules/inline-edit/components/date-input.client.tsx +7 -3
- package/src/modules/inline-edit/components/date-picker.client.tsx +10 -3
- package/src/modules/inline-edit/components/deprecated-editor.client.tsx +48 -0
- package/src/modules/inline-edit/components/editor.client.tsx +32 -29
- package/src/modules/inline-edit/components/input-recipient.client.tsx +6 -2
- package/src/modules/inline-edit/components/input-toggle.client.tsx +2 -0
- package/src/modules/inline-edit/components/input.client.tsx +39 -0
- package/src/modules/inline-edit/components/select.client.tsx +9 -2
- package/src/modules/inline-edit/components/switch.client.tsx +2 -0
- package/src/modules/inline-edit/components/toggle.client.tsx +2 -0
- package/src/modules/inline-edit/entry.client.ts +1 -1
- package/src/modules/inline-edit/hooks/use-inline.client.tsx +2 -2
- package/src/modules/inline-edit/lib/variants.ts +1 -1
- package/src/modules/{uploads/components/dropzone/index.tsx → storage/components/dropzone.client.tsx} +2 -2
- package/src/modules/storage/components/image-grid.client.tsx +225 -0
- package/src/modules/{uploads/components/button.client.tsx → storage/components/upload-button.client.tsx} +1 -1
- package/src/modules/storage/components/upload-zone-context.client.tsx +32 -0
- package/src/modules/storage/components/upload-zone.client.tsx +258 -0
- package/src/modules/{uploads/lib → storage/config}/filters.ts +2 -2
- package/src/modules/storage/entry.client.ts +12 -0
- package/src/modules/storage/entry.server.ts +6 -0
- package/src/modules/{uploads → storage}/entry.ts +1 -1
- package/src/modules/storage/lib/constants.ts +14 -0
- package/src/modules/storage/lib/create-client.server.ts +14 -0
- package/src/modules/{uploads → storage}/lib/helpers.ts +23 -9
- package/src/modules/storage/lib/proxy.server.ts +63 -0
- package/src/modules/storage/lib/router.server.ts +180 -0
- package/src/modules/{uploads → storage}/lib/schema.ts +34 -13
- package/src/modules/storage/lib/service.server.ts +476 -0
- package/src/modules/storage/lib/validators.ts +156 -0
- package/dist/components/editor/components/block-dropdown.mjs.map +0 -1
- package/dist/components/editor/components/fixed-menu.client.d.mts +0 -7
- package/dist/components/editor/components/fixed-menu.client.d.mts.map +0 -1
- package/dist/components/editor/components/fixed-menu.client.mjs +0 -134
- package/dist/components/editor/components/fixed-menu.client.mjs.map +0 -1
- package/dist/components/editor/context.client.d.mts +0 -33
- package/dist/components/editor/context.client.d.mts.map +0 -1
- package/dist/components/editor/context.client.mjs +0 -45
- package/dist/components/editor/context.client.mjs.map +0 -1
- package/dist/components/editor/index.client.d.mts +0 -11
- package/dist/components/editor/index.client.d.mts.map +0 -1
- package/dist/components/editor/index.client.mjs +0 -17
- package/dist/components/editor/index.client.mjs.map +0 -1
- package/dist/components/editor/preview.client.d.mts +0 -12
- package/dist/components/editor/preview.client.d.mts.map +0 -1
- package/dist/components/editor/preview.client.mjs +0 -19
- package/dist/components/editor/preview.client.mjs.map +0 -1
- package/dist/modules/commands/hooks/use-command-action.client.d.mts +0 -22
- package/dist/modules/commands/hooks/use-command-action.client.d.mts.map +0 -1
- package/dist/modules/commands/hooks/use-command-action.client.mjs +0 -74
- package/dist/modules/commands/hooks/use-command-action.client.mjs.map +0 -1
- package/dist/modules/config/providers/blob.d.mts +0 -10
- package/dist/modules/config/providers/blob.d.mts.map +0 -1
- package/dist/modules/config/providers/blob.mjs +0 -11
- package/dist/modules/config/providers/blob.mjs.map +0 -1
- package/dist/modules/inline-edit/components/richtext.client.d.mts +0 -15
- package/dist/modules/inline-edit/components/richtext.client.d.mts.map +0 -1
- package/dist/modules/inline-edit/components/richtext.client.mjs +0 -31
- package/dist/modules/inline-edit/components/richtext.client.mjs.map +0 -1
- package/dist/modules/uploads/components/button.client.d.mts +0 -12
- package/dist/modules/uploads/components/button.client.d.mts.map +0 -1
- package/dist/modules/uploads/components/button.client.mjs +0 -34
- package/dist/modules/uploads/components/button.client.mjs.map +0 -1
- package/dist/modules/uploads/components/dropzone/context.d.mts.map +0 -1
- package/dist/modules/uploads/components/dropzone/context.mjs.map +0 -1
- package/dist/modules/uploads/components/dropzone/index.d.mts.map +0 -1
- package/dist/modules/uploads/components/dropzone/index.mjs.map +0 -1
- package/dist/modules/uploads/components/images/grid.client.d.mts +0 -11
- package/dist/modules/uploads/components/images/grid.client.d.mts.map +0 -1
- package/dist/modules/uploads/components/images/grid.client.mjs +0 -119
- package/dist/modules/uploads/components/images/grid.client.mjs.map +0 -1
- package/dist/modules/uploads/components/images/input.client.d.mts +0 -16
- package/dist/modules/uploads/components/images/input.client.d.mts.map +0 -1
- package/dist/modules/uploads/components/images/input.client.mjs +0 -28
- package/dist/modules/uploads/components/images/input.client.mjs.map +0 -1
- package/dist/modules/uploads/components/preview-dialog.client.d.mts +0 -16
- package/dist/modules/uploads/components/preview-dialog.client.d.mts.map +0 -1
- package/dist/modules/uploads/components/preview-dialog.client.mjs +0 -22
- package/dist/modules/uploads/components/preview-dialog.client.mjs.map +0 -1
- package/dist/modules/uploads/components/zone.client.d.mts +0 -21
- package/dist/modules/uploads/components/zone.client.d.mts.map +0 -1
- package/dist/modules/uploads/components/zone.client.mjs +0 -38
- package/dist/modules/uploads/components/zone.client.mjs.map +0 -1
- package/dist/modules/uploads/hooks/use-upload-image.client.d.mts +0 -34
- package/dist/modules/uploads/hooks/use-upload-image.client.d.mts.map +0 -1
- package/dist/modules/uploads/hooks/use-upload-image.client.mjs +0 -101
- package/dist/modules/uploads/hooks/use-upload-image.client.mjs.map +0 -1
- package/dist/modules/uploads/hooks/use-upload-zone.client.d.mts +0 -39
- package/dist/modules/uploads/hooks/use-upload-zone.client.d.mts.map +0 -1
- package/dist/modules/uploads/hooks/use-upload-zone.client.mjs +0 -20
- package/dist/modules/uploads/hooks/use-upload-zone.client.mjs.map +0 -1
- package/dist/modules/uploads/lib/constants.d.mts +0 -9
- package/dist/modules/uploads/lib/constants.d.mts.map +0 -1
- package/dist/modules/uploads/lib/constants.mjs.map +0 -1
- package/dist/modules/uploads/lib/filters.d.mts.map +0 -1
- package/dist/modules/uploads/lib/filters.mjs.map +0 -1
- package/dist/modules/uploads/lib/helpers.d.mts +0 -36
- package/dist/modules/uploads/lib/helpers.d.mts.map +0 -1
- package/dist/modules/uploads/lib/helpers.mjs.map +0 -1
- package/dist/modules/uploads/lib/procedures.server.d.mts +0 -13628
- package/dist/modules/uploads/lib/procedures.server.d.mts.map +0 -1
- package/dist/modules/uploads/lib/procedures.server.mjs +0 -176
- package/dist/modules/uploads/lib/procedures.server.mjs.map +0 -1
- package/dist/modules/uploads/lib/proxy.server.d.mts +0 -54
- package/dist/modules/uploads/lib/proxy.server.d.mts.map +0 -1
- package/dist/modules/uploads/lib/proxy.server.mjs +0 -97
- package/dist/modules/uploads/lib/proxy.server.mjs.map +0 -1
- package/dist/modules/uploads/lib/route.server.d.mts +0 -43
- package/dist/modules/uploads/lib/route.server.d.mts.map +0 -1
- package/dist/modules/uploads/lib/route.server.mjs +0 -70
- package/dist/modules/uploads/lib/route.server.mjs.map +0 -1
- package/dist/modules/uploads/lib/schema.d.mts.map +0 -1
- package/dist/modules/uploads/lib/schema.mjs.map +0 -1
- package/dist/modules/uploads/lib/validators.d.mts.map +0 -1
- package/dist/modules/uploads/lib/validators.mjs +0 -26
- package/dist/modules/uploads/lib/validators.mjs.map +0 -1
- package/dist/uploads/client.d.mts +0 -10
- package/dist/uploads/client.mjs +0 -11
- package/dist/uploads/server.d.mts +0 -4
- package/dist/uploads/server.mjs +0 -5
- package/dist/uploads.d.mts +0 -6
- package/dist/uploads.mjs +0 -7
- package/src/components/editor/components/fixed-menu.client.tsx +0 -143
- package/src/components/editor/context.client.tsx +0 -116
- package/src/components/editor/index.client.tsx +0 -13
- package/src/components/editor/preview.client.tsx +0 -13
- package/src/modules/config/providers/blob.ts +0 -11
- package/src/modules/inline-edit/components/richtext.client.tsx +0 -38
- package/src/modules/uploads/components/images/grid.client.tsx +0 -162
- package/src/modules/uploads/components/images/input.client.tsx +0 -34
- package/src/modules/uploads/components/preview-dialog.client.tsx +0 -21
- package/src/modules/uploads/components/zone.client.tsx +0 -56
- package/src/modules/uploads/entry.client.ts +0 -16
- package/src/modules/uploads/entry.server.ts +0 -6
- package/src/modules/uploads/hooks/use-upload-image.client.tsx +0 -131
- package/src/modules/uploads/hooks/use-upload-zone.client.ts +0 -44
- package/src/modules/uploads/lib/constants.ts +0 -10
- package/src/modules/uploads/lib/procedures.server.ts +0 -332
- package/src/modules/uploads/lib/proxy.server.ts +0 -139
- package/src/modules/uploads/lib/route.server.ts +0 -93
- package/src/modules/uploads/lib/validators.ts +0 -50
- /package/src/modules/{uploads/components/dropzone/context.tsx → storage/components/dropzone-context.client.tsx} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.mts","names":[],"sources":["../../../../src/modules/storage/lib/schema.ts"],"sourcesContent":[],"mappings":";;;;cAOa,cAAuD,uBAAA,CAA3C;cACZ,cAAyD,uBAAA,CAA7C;;;AADzB;AACa,cAKA,KALyD,0BAKpD,kBALO,CAAA;EAKZ,IAAA,EAAA,OAcV;EAAA,MAAA,EAAA,SAAA;;UAAA,uBAAA,CAAA;;;;;;;;;;;;;;;0BAde;IAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA;IAgBL,SAAA,kCAWV,CAAA;MAAA,IAAA,EAAA,WAAA;;;;UAXwB,EAAA,MAAA;MAAA,WAAA,EAAA,MAAA;MAgBd,OA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KACW,WAAA,UAAqB"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { users } from "../../auth/db/schema.mjs";
|
|
2
1
|
import { baseColumns } from "../../config/db/helpers.mjs";
|
|
2
|
+
import { users } from "../../auth/db/schema.mjs";
|
|
3
3
|
import { imageDispositions, imageVariants } from "./constants.mjs";
|
|
4
4
|
import { nodeSubtypes } from "./helpers.mjs";
|
|
5
|
-
import { relations } from "drizzle-orm";
|
|
6
5
|
import { boolean, pgEnum, pgTable, unique } from "drizzle-orm/pg-core";
|
|
6
|
+
import { relations } from "drizzle-orm";
|
|
7
7
|
|
|
8
|
-
//#region src/modules/
|
|
8
|
+
//#region src/modules/storage/lib/schema.ts
|
|
9
9
|
const nodeTypeEnum = pgEnum("node_types", ["file", "folder"]);
|
|
10
10
|
const nodeModeEnum = pgEnum("node_mode", ["private", "public"]);
|
|
11
11
|
/**
|
|
@@ -21,7 +21,7 @@ const nodes = pgTable("nodes", (t) => ({
|
|
|
21
21
|
size: t.integer().default(0),
|
|
22
22
|
contentType: t.varchar({ length: 255 }),
|
|
23
23
|
readonly: boolean().default(false),
|
|
24
|
-
createdBy: t.
|
|
24
|
+
createdBy: t.uuid().references(() => users.id, { onDelete: "set null" }),
|
|
25
25
|
isPending: t.boolean().default(false).notNull(),
|
|
26
26
|
isDeleted: t.boolean().default(false).notNull(),
|
|
27
27
|
parentId: t.uuid().references(() => nodes.id, { onDelete: "cascade" })
|
|
@@ -33,9 +33,24 @@ const nodesRelations = relations(nodes, ({ one, many }) => ({
|
|
|
33
33
|
relationName: "parent"
|
|
34
34
|
}),
|
|
35
35
|
children: many(nodes, { relationName: "parent" }),
|
|
36
|
-
urls: many(nodePresignedUrls)
|
|
36
|
+
urls: many(nodePresignedUrls),
|
|
37
|
+
variants: many(nodeVariants)
|
|
37
38
|
}));
|
|
38
39
|
/**
|
|
40
|
+
* Node variants table
|
|
41
|
+
*/
|
|
42
|
+
const nodeVariants = pgTable("node_variants", (t) => ({
|
|
43
|
+
...baseColumns,
|
|
44
|
+
nodeId: t.uuid().notNull().references(() => nodes.id, { onDelete: "cascade" }),
|
|
45
|
+
variant: t.text({ enum: imageVariants }).notNull(),
|
|
46
|
+
width: t.integer().notNull()
|
|
47
|
+
}));
|
|
48
|
+
const nodeVariantsRelations = relations(nodeVariants, ({ one }) => ({ node: one(nodes, {
|
|
49
|
+
fields: [nodeVariants.nodeId],
|
|
50
|
+
references: [nodes.id],
|
|
51
|
+
relationName: "node"
|
|
52
|
+
}) }));
|
|
53
|
+
/**
|
|
39
54
|
* Node presigned urls table
|
|
40
55
|
*/
|
|
41
56
|
const nodePresignedUrls = pgTable("node_presigned_urls", (t) => ({
|
|
@@ -44,25 +59,15 @@ const nodePresignedUrls = pgTable("node_presigned_urls", (t) => ({
|
|
|
44
59
|
variant: t.text({ enum: imageVariants }).notNull(),
|
|
45
60
|
disposition: t.text({ enum: imageDispositions }).notNull(),
|
|
46
61
|
expiresAt: t.timestamp().notNull(),
|
|
47
|
-
nodeId: t.uuid().notNull().references(() => nodes.id, { onDelete: "cascade" })
|
|
62
|
+
nodeId: t.uuid().notNull().references(() => nodes.id, { onDelete: "cascade" }),
|
|
63
|
+
variantId: t.uuid().references(() => nodeVariants.id, { onDelete: "set null" })
|
|
48
64
|
}), (t) => [unique("node_presigned_url_unique").on(t.nodeId, t.variant, t.disposition)]);
|
|
49
65
|
const nodePresignedUrlsRelations = relations(nodePresignedUrls, ({ one }) => ({ node: one(nodes, {
|
|
50
66
|
fields: [nodePresignedUrls.nodeId],
|
|
51
67
|
references: [nodes.id],
|
|
52
68
|
relationName: "node"
|
|
53
69
|
}) }));
|
|
54
|
-
/**
|
|
55
|
-
* @deprecated
|
|
56
|
-
*/
|
|
57
|
-
const assets = pgTable("assets", (t) => ({
|
|
58
|
-
...baseColumns,
|
|
59
|
-
name: t.text().notNull(),
|
|
60
|
-
pathname: t.text().notNull(),
|
|
61
|
-
url: t.text().notNull().unique(),
|
|
62
|
-
size: t.integer().default(0),
|
|
63
|
-
contentType: t.varchar({ length: 255 })
|
|
64
|
-
}));
|
|
65
70
|
|
|
66
71
|
//#endregion
|
|
67
|
-
export {
|
|
72
|
+
export { nodeModeEnum, nodePresignedUrls, nodePresignedUrlsRelations, nodeTypeEnum, nodeVariants, nodeVariantsRelations, nodes, nodesRelations };
|
|
68
73
|
//# sourceMappingURL=schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.mjs","names":[],"sources":["../../../../src/modules/storage/lib/schema.ts"],"sourcesContent":["import { users } from \"@/modules/auth/db/schema\";\nimport { baseColumns } from \"@/modules/config/db/helpers\";\nimport { relations } from \"drizzle-orm\";\nimport { AnyPgColumn, boolean, pgEnum, pgTable, unique } from \"drizzle-orm/pg-core\";\nimport { imageDispositions, imageVariants } from \"./constants\";\nimport { nodeSubtypes } from \"./helpers\";\n\nexport const nodeTypeEnum = pgEnum(\"node_types\", [\"file\", \"folder\"]);\nexport const nodeModeEnum = pgEnum(\"node_mode\", [\"private\", \"public\"]);\n\n/**\n * Node table\n */\nexport const nodes = pgTable(\"nodes\", (t) => ({\n ...baseColumns,\n name: t.text().notNull(),\n namespace: t.text().notNull().default(\"global\"),\n type: nodeTypeEnum(),\n mode: nodeModeEnum().default(\"private\"),\n subtype: t.text({ enum: nodeSubtypes }).notNull().default(\"other\"),\n size: t.integer().default(0),\n contentType: t.varchar({ length: 255 }),\n readonly: boolean().default(false),\n createdBy: t.uuid().references(() => users.id, { onDelete: \"set null\" }),\n isPending: t.boolean().default(false).notNull(),\n isDeleted: t.boolean().default(false).notNull(),\n parentId: t.uuid().references((): AnyPgColumn => nodes.id, { onDelete: \"cascade\" }),\n}));\n\nexport const nodesRelations = relations(nodes, ({ one, many }) => ({\n parent: one(nodes, {\n fields: [nodes.parentId],\n references: [nodes.id],\n relationName: \"parent\",\n }),\n children: many(nodes, {\n relationName: \"parent\",\n }),\n urls: many(nodePresignedUrls),\n variants: many(nodeVariants),\n}));\n\n/**\n * Node variants table\n */\nexport const nodeVariants = pgTable(\"node_variants\", (t) => ({\n ...baseColumns,\n nodeId: t\n .uuid()\n .notNull()\n .references(() => nodes.id, { onDelete: \"cascade\" }),\n variant: t.text({ enum: imageVariants }).notNull(),\n width: t.integer().notNull(),\n}));\n\nexport const nodeVariantsRelations = relations(nodeVariants, ({ one }) => ({\n node: one(nodes, {\n fields: [nodeVariants.nodeId],\n references: [nodes.id],\n relationName: \"node\",\n }),\n}));\n\n/**\n * Node presigned urls table\n */\nexport const nodePresignedUrls = pgTable(\n \"node_presigned_urls\",\n (t) => ({\n ...baseColumns,\n url: t.text().notNull().unique(),\n variant: t.text({ enum: imageVariants }).notNull(),\n disposition: t.text({ enum: imageDispositions }).notNull(),\n expiresAt: t.timestamp().notNull(),\n nodeId: t\n .uuid()\n .notNull()\n .references(() => nodes.id, { onDelete: \"cascade\" }),\n variantId: t.uuid().references(() => nodeVariants.id, { onDelete: \"set null\" }),\n }),\n (t) => [unique(\"node_presigned_url_unique\").on(t.nodeId, t.variant, t.disposition)],\n);\n\nexport const nodePresignedUrlsRelations = relations(nodePresignedUrls, ({ one }) => ({\n node: one(nodes, {\n fields: [nodePresignedUrls.nodeId],\n references: [nodes.id],\n relationName: \"node\",\n }),\n}));\n\n/**\n * Drive schema\n **/\nconst driveSchema = {\n nodes,\n nodesRelations,\n nodeVariants,\n nodeVariantsRelations,\n nodePresignedUrls,\n nodePresignedUrlsRelations,\n};\nexport type DriveSchema = typeof driveSchema;\n"],"mappings":";;;;;;;;AAOA,MAAa,eAAe,OAAO,cAAc,CAAC,QAAQ,SAAS,CAAC;AACpE,MAAa,eAAe,OAAO,aAAa,CAAC,WAAW,SAAS,CAAC;;;;AAKtE,MAAa,QAAQ,QAAQ,UAAU,OAAO;CAC5C,GAAG;CACH,MAAM,EAAE,MAAM,CAAC,SAAS;CACxB,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC,QAAQ,SAAS;CAC/C,MAAM,cAAc;CACpB,MAAM,cAAc,CAAC,QAAQ,UAAU;CACvC,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC,CAAC,SAAS,CAAC,QAAQ,QAAQ;CAClE,MAAM,EAAE,SAAS,CAAC,QAAQ,EAAE;CAC5B,aAAa,EAAE,QAAQ,EAAE,QAAQ,KAAK,CAAC;CACvC,UAAU,SAAS,CAAC,QAAQ,MAAM;CAClC,WAAW,EAAE,MAAM,CAAC,iBAAiB,MAAM,IAAI,EAAE,UAAU,YAAY,CAAC;CACxE,WAAW,EAAE,SAAS,CAAC,QAAQ,MAAM,CAAC,SAAS;CAC/C,WAAW,EAAE,SAAS,CAAC,QAAQ,MAAM,CAAC,SAAS;CAC/C,UAAU,EAAE,MAAM,CAAC,iBAA8B,MAAM,IAAI,EAAE,UAAU,WAAW,CAAC;CACpF,EAAE;AAEH,MAAa,iBAAiB,UAAU,QAAQ,EAAE,KAAK,YAAY;CACjE,QAAQ,IAAI,OAAO;EACjB,QAAQ,CAAC,MAAM,SAAS;EACxB,YAAY,CAAC,MAAM,GAAG;EACtB,cAAc;EACf,CAAC;CACF,UAAU,KAAK,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import { TDatabaseSchema } from "../../config/db/types.mjs";
|
|
2
|
+
import { DatabaseClient } from "../../config/db/init.mjs";
|
|
3
|
+
import "../../../config/server.mjs";
|
|
4
|
+
import { BulkActionSchema } from "../../router/lib/validators.mjs";
|
|
5
|
+
import "../../../router.mjs";
|
|
6
|
+
import { CreateFolderNodeSchema, GetFileURLSchema, GetNodesByParentIdInput, Node, PresignFileSchema, PutObjectInput, UpdateNodeSchema, UploadFileSchema } from "./validators.mjs";
|
|
7
|
+
import "../../../config.mjs";
|
|
8
|
+
import * as _aws_sdk_client_s30 from "@aws-sdk/client-s3";
|
|
9
|
+
import { S3Client, S3ClientConfig } from "@aws-sdk/client-s3";
|
|
10
|
+
|
|
11
|
+
//#region src/modules/storage/lib/service.server.d.ts
|
|
12
|
+
/**
|
|
13
|
+
* Storage Service Config
|
|
14
|
+
*/
|
|
15
|
+
type StorageServiceConfig<TSchema extends TDatabaseSchema> = {
|
|
16
|
+
db: DatabaseClient<TSchema>;
|
|
17
|
+
config: S3ClientConfig;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Storage Service
|
|
21
|
+
*/
|
|
22
|
+
declare class StorageService<TSchema extends TDatabaseSchema> {
|
|
23
|
+
#private;
|
|
24
|
+
/**
|
|
25
|
+
* Constructor
|
|
26
|
+
*/
|
|
27
|
+
constructor({
|
|
28
|
+
db,
|
|
29
|
+
config
|
|
30
|
+
}: StorageServiceConfig<TSchema>);
|
|
31
|
+
/**
|
|
32
|
+
* Get Blob
|
|
33
|
+
*/
|
|
34
|
+
blob(): S3Client;
|
|
35
|
+
/**
|
|
36
|
+
* Get object
|
|
37
|
+
*/
|
|
38
|
+
getObject(id: string, options?: GetFileURLSchema): Promise<_aws_sdk_client_s30.GetObjectCommandOutput>;
|
|
39
|
+
/**
|
|
40
|
+
* Get nodes by parent id
|
|
41
|
+
*/
|
|
42
|
+
getNodesByParentId({
|
|
43
|
+
filters,
|
|
44
|
+
...query
|
|
45
|
+
}: GetNodesByParentIdInput): Promise<{
|
|
46
|
+
name: string;
|
|
47
|
+
namespace: string;
|
|
48
|
+
type: "file" | "folder" | null;
|
|
49
|
+
mode: "private" | "public" | null;
|
|
50
|
+
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
51
|
+
size: number | null;
|
|
52
|
+
contentType: string | null;
|
|
53
|
+
readonly: boolean | null;
|
|
54
|
+
createdBy: string | null;
|
|
55
|
+
isPending: boolean;
|
|
56
|
+
isDeleted: boolean;
|
|
57
|
+
parentId: string | null;
|
|
58
|
+
id: string;
|
|
59
|
+
createdAt: Date;
|
|
60
|
+
updatedAt: Date;
|
|
61
|
+
}[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Get file url
|
|
64
|
+
*/
|
|
65
|
+
getSignedURL(node: Node, options?: GetFileURLSchema): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Upload file to S3 and add it to the database
|
|
68
|
+
**/
|
|
69
|
+
uploadFile(input: UploadFileSchema & Pick<PutObjectInput, "body">): Promise<{
|
|
70
|
+
id: string;
|
|
71
|
+
createdAt: Date;
|
|
72
|
+
updatedAt: Date;
|
|
73
|
+
name: string;
|
|
74
|
+
type: "file" | "folder" | null;
|
|
75
|
+
readonly: boolean | null;
|
|
76
|
+
mode: "private" | "public" | null;
|
|
77
|
+
size: number | null;
|
|
78
|
+
namespace: string;
|
|
79
|
+
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
80
|
+
contentType: string | null;
|
|
81
|
+
createdBy: string | null;
|
|
82
|
+
isPending: boolean;
|
|
83
|
+
isDeleted: boolean;
|
|
84
|
+
parentId: string | null;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* Presign a new upload
|
|
88
|
+
*/
|
|
89
|
+
presignUpload(input: PresignFileSchema): Promise<{
|
|
90
|
+
id: string;
|
|
91
|
+
presignedUrl: string;
|
|
92
|
+
node: {
|
|
93
|
+
id: string;
|
|
94
|
+
createdAt: Date;
|
|
95
|
+
updatedAt: Date;
|
|
96
|
+
name: string;
|
|
97
|
+
type: "file" | "folder" | null;
|
|
98
|
+
readonly: boolean | null;
|
|
99
|
+
mode: "private" | "public" | null;
|
|
100
|
+
size: number | null;
|
|
101
|
+
namespace: string;
|
|
102
|
+
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
103
|
+
contentType: string | null;
|
|
104
|
+
createdBy: string | null;
|
|
105
|
+
isPending: boolean;
|
|
106
|
+
isDeleted: boolean;
|
|
107
|
+
parentId: string | null;
|
|
108
|
+
};
|
|
109
|
+
}>;
|
|
110
|
+
/**
|
|
111
|
+
* Confirm a new upload
|
|
112
|
+
*/
|
|
113
|
+
confirmUpload(input: {
|
|
114
|
+
id: string;
|
|
115
|
+
}): Promise<{
|
|
116
|
+
name: string;
|
|
117
|
+
namespace: string;
|
|
118
|
+
type: "file" | "folder" | null;
|
|
119
|
+
mode: "private" | "public" | null;
|
|
120
|
+
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
121
|
+
size: number | null;
|
|
122
|
+
contentType: string | null;
|
|
123
|
+
readonly: boolean | null;
|
|
124
|
+
createdBy: string | null;
|
|
125
|
+
isPending: boolean;
|
|
126
|
+
isDeleted: boolean;
|
|
127
|
+
parentId: string | null;
|
|
128
|
+
id: string;
|
|
129
|
+
createdAt: Date;
|
|
130
|
+
updatedAt: Date;
|
|
131
|
+
}>;
|
|
132
|
+
/**
|
|
133
|
+
* Generate preview version of the file
|
|
134
|
+
*/
|
|
135
|
+
generatePreviews(input: {
|
|
136
|
+
id: string;
|
|
137
|
+
}): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* Create a new folder
|
|
140
|
+
*/
|
|
141
|
+
createFolder(input: CreateFolderNodeSchema): Promise<{
|
|
142
|
+
id: string;
|
|
143
|
+
createdAt: Date;
|
|
144
|
+
updatedAt: Date;
|
|
145
|
+
name: string;
|
|
146
|
+
type: "file" | "folder" | null;
|
|
147
|
+
readonly: boolean | null;
|
|
148
|
+
mode: "private" | "public" | null;
|
|
149
|
+
size: number | null;
|
|
150
|
+
namespace: string;
|
|
151
|
+
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
152
|
+
contentType: string | null;
|
|
153
|
+
createdBy: string | null;
|
|
154
|
+
isPending: boolean;
|
|
155
|
+
isDeleted: boolean;
|
|
156
|
+
parentId: string | null;
|
|
157
|
+
}>;
|
|
158
|
+
/**
|
|
159
|
+
* Update a node
|
|
160
|
+
*/
|
|
161
|
+
updateNode(input: {
|
|
162
|
+
id: string;
|
|
163
|
+
data: UpdateNodeSchema;
|
|
164
|
+
}): Promise<{
|
|
165
|
+
name: string;
|
|
166
|
+
namespace: string;
|
|
167
|
+
type: "file" | "folder" | null;
|
|
168
|
+
mode: "private" | "public" | null;
|
|
169
|
+
subtype: "image" | "document" | "spreadsheet" | "video" | "audio" | "archive" | "other";
|
|
170
|
+
size: number | null;
|
|
171
|
+
contentType: string | null;
|
|
172
|
+
readonly: boolean | null;
|
|
173
|
+
createdBy: string | null;
|
|
174
|
+
isPending: boolean;
|
|
175
|
+
isDeleted: boolean;
|
|
176
|
+
parentId: string | null;
|
|
177
|
+
id: string;
|
|
178
|
+
createdAt: Date;
|
|
179
|
+
updatedAt: Date;
|
|
180
|
+
}>;
|
|
181
|
+
/**
|
|
182
|
+
* Delete nodes
|
|
183
|
+
*/
|
|
184
|
+
deleteNodes(input: BulkActionSchema): Promise<void>;
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
export { StorageService, StorageServiceConfig };
|
|
188
|
+
//# sourceMappingURL=service.server.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.server.d.mts","names":[],"sources":["../../../../src/modules/storage/lib/service.server.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;KAyCY,qCAAqC;MAC3C,eAAe;UACX;AAFV,CAAA;;;;AAEU,cAMG,cANH,CA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;;;;MAqCH;;;;;;;;;;;;;;;;;;;;;;MAuBG;;;;sBAwDlB,yBAAsB;;;;;;;;;;;;;;;;;;;;;;UA0CJ;MAAkB;;;;;;;;;;;;;;;;;;;;qBA4BrC,mBAAgB"}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { generateDefaultUUID } from "../../config/db/helpers.mjs";
|
|
2
|
+
import { BUCKET_NAME } from "../../../lib/config/constants.mjs";
|
|
3
|
+
import { ServerError } from "../../router/lib/error.server.mjs";
|
|
4
|
+
import { convertSearchToQueryParams } from "../../data-tables/lib/converters/search.mjs";
|
|
5
|
+
import { convertOrderByToQueryParams } from "../../data-tables/lib/converters/sorting.mjs";
|
|
6
|
+
import { deviceSizes } from "./constants.mjs";
|
|
7
|
+
import { getDriveBucketKey, inferNodeSubtype, isFile, isFolder } from "./helpers.mjs";
|
|
8
|
+
import { nodePresignedUrls, nodeVariants, nodes } from "./schema.mjs";
|
|
9
|
+
import { getFileURLSchemaDefaults, getObjectSchema, putObjectSchema } from "./validators.mjs";
|
|
10
|
+
import { and, asc, eq, inArray, isNull } from "drizzle-orm";
|
|
11
|
+
import { after } from "next/server";
|
|
12
|
+
import { addSeconds } from "date-fns";
|
|
13
|
+
import { DeleteObjectsCommand, GetObjectCommand, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
|
14
|
+
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
15
|
+
|
|
16
|
+
//#region src/modules/storage/lib/service.server.ts
|
|
17
|
+
/**
|
|
18
|
+
* Storage Service
|
|
19
|
+
*/
|
|
20
|
+
var StorageService = class {
|
|
21
|
+
/**
|
|
22
|
+
* S3 Client
|
|
23
|
+
*/
|
|
24
|
+
#blob;
|
|
25
|
+
#db;
|
|
26
|
+
/**
|
|
27
|
+
* Constructor
|
|
28
|
+
*/
|
|
29
|
+
constructor({ db, config }) {
|
|
30
|
+
this.#db = db;
|
|
31
|
+
this.#blob = new S3Client(config);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get Blob
|
|
35
|
+
*/
|
|
36
|
+
blob() {
|
|
37
|
+
return this.#blob;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Create get command
|
|
41
|
+
*/
|
|
42
|
+
#createGetCommand(props) {
|
|
43
|
+
const input = getObjectSchema.parse(props);
|
|
44
|
+
return new GetObjectCommand({
|
|
45
|
+
Bucket: BUCKET_NAME,
|
|
46
|
+
Key: getDriveBucketKey(input.id, input.variant),
|
|
47
|
+
ResponseContentDisposition: input.disposition
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get object
|
|
52
|
+
*/
|
|
53
|
+
async getObject(id, options = getFileURLSchemaDefaults) {
|
|
54
|
+
const getCommand = this.#createGetCommand({
|
|
55
|
+
...options,
|
|
56
|
+
id
|
|
57
|
+
});
|
|
58
|
+
return await this.#blob.send(getCommand);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create put command
|
|
62
|
+
*/
|
|
63
|
+
#createPutCommand(props) {
|
|
64
|
+
const input = putObjectSchema.parse(props);
|
|
65
|
+
return new PutObjectCommand({
|
|
66
|
+
Bucket: BUCKET_NAME,
|
|
67
|
+
Key: getDriveBucketKey(input.id, input.variant),
|
|
68
|
+
Body: input.body,
|
|
69
|
+
ContentType: input.contentType,
|
|
70
|
+
ContentLength: input.size,
|
|
71
|
+
Metadata: { nodeId: input.id }
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Put object
|
|
76
|
+
*/
|
|
77
|
+
async #putObject(props) {
|
|
78
|
+
const putCommand = this.#createPutCommand(props);
|
|
79
|
+
return await this.#blob.send(putCommand);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get nodes by parent id
|
|
83
|
+
*/
|
|
84
|
+
async getNodesByParentId({ filters, ...query }) {
|
|
85
|
+
const orderBy = convertOrderByToQueryParams(query, nodes, asc(nodes.createdAt));
|
|
86
|
+
const search = convertSearchToQueryParams(query, [nodes.name]);
|
|
87
|
+
return this.#db.select().from(nodes).where(and(filters.nodeIds != null ? inArray(nodes.id, filters.nodeIds) : void 0, filters.types != null ? inArray(nodes.type, filters.types) : void 0, filters.isDeleted != null ? eq(nodes.isDeleted, filters.isDeleted) : void 0, filters.parentId ? eq(nodes.parentId, filters.parentId) : isNull(nodes.parentId), eq(nodes.namespace, filters.namespace), search)).orderBy(orderBy);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get file url
|
|
91
|
+
*/
|
|
92
|
+
async getSignedURL(node, options = getFileURLSchemaDefaults) {
|
|
93
|
+
const [presignedUrl] = await this.#db.select({
|
|
94
|
+
url: nodePresignedUrls.url,
|
|
95
|
+
expiresAt: nodePresignedUrls.expiresAt
|
|
96
|
+
}).from(nodePresignedUrls).where(and(eq(nodePresignedUrls.nodeId, node.id), eq(nodePresignedUrls.variant, options.variant), eq(nodePresignedUrls.disposition, options.disposition)));
|
|
97
|
+
if (presignedUrl && presignedUrl.expiresAt > /* @__PURE__ */ new Date()) return presignedUrl.url;
|
|
98
|
+
const expiresIn = 3600 * 24;
|
|
99
|
+
const variant = (await this.#db.select().from(nodeVariants).where(eq(nodeVariants.nodeId, node.id))).find((v) => v.variant === options.variant) ? options.variant : "main";
|
|
100
|
+
console.info(`Generating new signed url for file: ${node.id} with variant: ${variant} and disposition: ${options.disposition}`);
|
|
101
|
+
const getCommand = this.#createGetCommand({
|
|
102
|
+
id: node.id,
|
|
103
|
+
variant,
|
|
104
|
+
disposition: `${options.disposition}; filename="${node.name}"`
|
|
105
|
+
});
|
|
106
|
+
const url = await getSignedUrl(this.#blob, getCommand, { expiresIn });
|
|
107
|
+
after(async () => {
|
|
108
|
+
await this.#db.insert(nodePresignedUrls).values({
|
|
109
|
+
nodeId: node.id,
|
|
110
|
+
url,
|
|
111
|
+
variant,
|
|
112
|
+
disposition: options.disposition,
|
|
113
|
+
expiresAt: addSeconds(/* @__PURE__ */ new Date(), expiresIn)
|
|
114
|
+
}).onConflictDoUpdate({
|
|
115
|
+
target: [
|
|
116
|
+
nodePresignedUrls.nodeId,
|
|
117
|
+
nodePresignedUrls.variant,
|
|
118
|
+
nodePresignedUrls.disposition
|
|
119
|
+
],
|
|
120
|
+
set: {
|
|
121
|
+
url,
|
|
122
|
+
expiresAt: addSeconds(/* @__PURE__ */ new Date(), expiresIn)
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
return url;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Upload file to S3 and add it to the database
|
|
130
|
+
**/
|
|
131
|
+
async uploadFile(input) {
|
|
132
|
+
const id = generateDefaultUUID();
|
|
133
|
+
return await this.#db.transaction(async (tx) => {
|
|
134
|
+
const [result] = await tx.insert(nodes).values({
|
|
135
|
+
id,
|
|
136
|
+
type: "file",
|
|
137
|
+
name: input.name,
|
|
138
|
+
namespace: input.namespace,
|
|
139
|
+
parentId: input.parentId,
|
|
140
|
+
size: input.size,
|
|
141
|
+
contentType: input.contentType,
|
|
142
|
+
mode: input.mode,
|
|
143
|
+
subtype: inferNodeSubtype(input)
|
|
144
|
+
}).returning();
|
|
145
|
+
if (!result) throw new ServerError("INTERNAL_SERVER_ERROR", { message: "Oep! Er is iets fout gegaan" });
|
|
146
|
+
await this.#putObject({
|
|
147
|
+
id,
|
|
148
|
+
body: input.body,
|
|
149
|
+
variant: "main",
|
|
150
|
+
name: input.name,
|
|
151
|
+
contentType: input.contentType,
|
|
152
|
+
size: input.size
|
|
153
|
+
});
|
|
154
|
+
return result;
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Presign a new upload
|
|
159
|
+
*/
|
|
160
|
+
async presignUpload(input) {
|
|
161
|
+
const putCommand = this.#createPutCommand({
|
|
162
|
+
id: input.id,
|
|
163
|
+
name: input.name,
|
|
164
|
+
variant: "main",
|
|
165
|
+
contentType: input.contentType,
|
|
166
|
+
size: input.size
|
|
167
|
+
});
|
|
168
|
+
const presignedUrl = await getSignedUrl(this.#blob, putCommand, { expiresIn: 3600 });
|
|
169
|
+
const [node] = await this.#db.insert(nodes).values({
|
|
170
|
+
...input,
|
|
171
|
+
subtype: inferNodeSubtype(input),
|
|
172
|
+
isPending: true,
|
|
173
|
+
type: "file",
|
|
174
|
+
id: input.id
|
|
175
|
+
}).returning();
|
|
176
|
+
if (!node) throw new ServerError("INTERNAL_SERVER_ERROR", { message: "Oep! Er is iets fout gegaan" });
|
|
177
|
+
return {
|
|
178
|
+
id: input.id,
|
|
179
|
+
presignedUrl,
|
|
180
|
+
node
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Confirm a new upload
|
|
185
|
+
*/
|
|
186
|
+
async confirmUpload(input) {
|
|
187
|
+
const [result] = await this.#db.update(nodes).set({ isPending: false }).where(eq(nodes.id, input.id)).returning();
|
|
188
|
+
if (!result) throw new ServerError("NOT_FOUND", { message: "File not found" });
|
|
189
|
+
/**
|
|
190
|
+
* Generate the preview version of the file
|
|
191
|
+
*/
|
|
192
|
+
await this.generatePreviews(input);
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Generate preview version of the file
|
|
197
|
+
*/
|
|
198
|
+
async generatePreviews(input) {
|
|
199
|
+
/**
|
|
200
|
+
* Get the main version of the file
|
|
201
|
+
*/
|
|
202
|
+
const getCommand = this.#createGetCommand({
|
|
203
|
+
id: input.id,
|
|
204
|
+
variant: "main"
|
|
205
|
+
});
|
|
206
|
+
const response = await this.#blob.send(getCommand);
|
|
207
|
+
const contentType = response.ContentType;
|
|
208
|
+
if (!response.Body) throw new ServerError("INTERNAL_SERVER_ERROR", { message: "Oep! Er is iets fout gegaan" });
|
|
209
|
+
/**
|
|
210
|
+
* Transform the main version of the file to a buffer
|
|
211
|
+
*/
|
|
212
|
+
const byteArray = await response.Body.transformToByteArray();
|
|
213
|
+
const buffer = Buffer.from(byteArray);
|
|
214
|
+
/**
|
|
215
|
+
* Generate the preview versions for images
|
|
216
|
+
*/
|
|
217
|
+
if (contentType?.startsWith("image/")) {
|
|
218
|
+
const sharp = await import("sharp");
|
|
219
|
+
await Promise.allSettled(deviceSizes.flatMap(async (width) => {
|
|
220
|
+
const preview = await sharp.default(buffer).resize({ width }).webp().toBuffer();
|
|
221
|
+
return this.#db.transaction(async (tx) => {
|
|
222
|
+
await this.#putObject({
|
|
223
|
+
id: input.id,
|
|
224
|
+
body: preview,
|
|
225
|
+
variant: `preview-${width}`,
|
|
226
|
+
contentType: "image/webp",
|
|
227
|
+
size: preview.byteLength
|
|
228
|
+
});
|
|
229
|
+
await tx.insert(nodeVariants).values({
|
|
230
|
+
nodeId: input.id,
|
|
231
|
+
variant: `preview-${width}`,
|
|
232
|
+
width
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Create a new folder
|
|
240
|
+
*/
|
|
241
|
+
async createFolder(input) {
|
|
242
|
+
const [parent] = input.parentId ? await this.#db.select().from(nodes).where(eq(nodes.id, input.parentId)) : [];
|
|
243
|
+
/**
|
|
244
|
+
* Validate
|
|
245
|
+
*/
|
|
246
|
+
if (input.parentId && !parent) throw new ServerError("BAD_REQUEST", { message: "Parent not found" });
|
|
247
|
+
if (parent && !isFolder(parent)) throw new ServerError("BAD_REQUEST", { message: "Parent is not a folder" });
|
|
248
|
+
if (parent && parent.namespace !== input.namespace) throw new ServerError("BAD_REQUEST", { message: "Parent is not in the same namespace" });
|
|
249
|
+
/**
|
|
250
|
+
* Create the folder
|
|
251
|
+
*/
|
|
252
|
+
const [result] = await this.#db.insert(nodes).values({
|
|
253
|
+
...input,
|
|
254
|
+
type: "folder"
|
|
255
|
+
}).returning();
|
|
256
|
+
if (!result) throw new ServerError("INTERNAL_SERVER_ERROR", { message: "Folder kon niet worden aangemaakt" });
|
|
257
|
+
return result;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Update a node
|
|
261
|
+
*/
|
|
262
|
+
async updateNode(input) {
|
|
263
|
+
const [node] = await this.#db.select({ readonly: nodes.readonly }).from(nodes).where(eq(nodes.id, input.id));
|
|
264
|
+
if (node?.readonly) throw new ServerError("BAD_REQUEST", { message: "Node is readonly" });
|
|
265
|
+
const [result] = await this.#db.update(nodes).set(input.data).where(eq(nodes.id, input.id)).returning();
|
|
266
|
+
if (!result) throw new ServerError("INTERNAL_SERVER_ERROR", { message: "Node kon niet worden gewijzigd" });
|
|
267
|
+
return result;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Delete nodes
|
|
271
|
+
*/
|
|
272
|
+
async deleteNodes(input) {
|
|
273
|
+
const items = await this.#db.select({
|
|
274
|
+
id: nodes.id,
|
|
275
|
+
type: nodes.type,
|
|
276
|
+
readonly: nodes.readonly
|
|
277
|
+
}).from(nodes).where(inArray(nodes.id, input.ids));
|
|
278
|
+
if (items.some((item) => item.readonly)) throw new ServerError("BAD_REQUEST", { message: "Nodes are readonly" });
|
|
279
|
+
const folders = items.filter(isFolder).map((folder) => folder.id);
|
|
280
|
+
const files = items.filter(isFile).map((file) => file.id);
|
|
281
|
+
const deleteCommand = files.length > 0 ? new DeleteObjectsCommand({
|
|
282
|
+
Bucket: BUCKET_NAME,
|
|
283
|
+
Delete: { Objects: files.map((id) => ({ Key: id })) }
|
|
284
|
+
}) : void 0;
|
|
285
|
+
/**
|
|
286
|
+
* Delete files and folders in a transaction
|
|
287
|
+
*/
|
|
288
|
+
await this.#db.transaction(async (tx) => {
|
|
289
|
+
await tx.delete(nodes).where(inArray(nodes.id, folders));
|
|
290
|
+
await tx.delete(nodes).where(inArray(nodes.id, files));
|
|
291
|
+
if (deleteCommand) await this.#blob.send(deleteCommand);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
//#endregion
|
|
297
|
+
export { StorageService };
|
|
298
|
+
//# sourceMappingURL=service.server.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.server.mjs","names":["#db","#blob","#createGetCommand","#putObject","#createPutCommand"],"sources":["../../../../src/modules/storage/lib/service.server.ts"],"sourcesContent":["import { BUCKET_NAME } from \"@/lib/config/constants\";\nimport { generateDefaultUUID, TDatabaseSchema } from \"@/modules/config/entry\";\nimport { DatabaseClient } from \"@/modules/config/entry.server\";\nimport {\n convertOrderByToQueryParams,\n convertSearchToQueryParams,\n} from \"@/modules/data-tables/entry.server\";\nimport { BulkActionSchema } from \"@/modules/router/entry\";\nimport { ServerError } from \"@/modules/router/lib/error.server\";\nimport {\n DeleteObjectsCommand,\n GetObjectCommand,\n PutObjectCommand,\n S3Client,\n S3ClientConfig,\n} from \"@aws-sdk/client-s3\";\nimport { getSignedUrl } from \"@aws-sdk/s3-request-presigner\";\nimport { addSeconds } from \"date-fns\";\nimport { and, asc, eq, inArray, isNull, SQL } from \"drizzle-orm\";\nimport { after } from \"next/server\";\nimport { deviceSizes } from \"./constants\";\nimport { getDriveBucketKey, inferNodeSubtype, isFile, isFolder } from \"./helpers\";\nimport { nodePresignedUrls, nodes, nodeVariants } from \"./schema\";\nimport {\n CreateFolderNodeSchema,\n GetFileURLSchema,\n getFileURLSchemaDefaults,\n GetNodesByParentIdInput,\n GetObjectInput,\n getObjectSchema,\n Node,\n PresignFileSchema,\n PutObjectInput,\n putObjectSchema,\n UpdateNodeSchema,\n UploadFileSchema,\n} from \"./validators\";\n\n/**\n * Storage Service Config\n */\nexport type StorageServiceConfig<TSchema extends TDatabaseSchema> = {\n db: DatabaseClient<TSchema>;\n config: S3ClientConfig;\n};\n\n/**\n * Storage Service\n */\nexport class StorageService<TSchema extends TDatabaseSchema> {\n /**\n * S3 Client\n */\n #blob: S3Client;\n #db: DatabaseClient<TSchema>;\n\n /**\n * Constructor\n */\n constructor({ db, config }: StorageServiceConfig<TSchema>) {\n this.#db = db;\n this.#blob = new S3Client(config);\n }\n\n /**\n * Get Blob\n */\n blob() {\n return this.#blob;\n }\n\n /**\n * Create get command\n */\n #createGetCommand(props: GetObjectInput) {\n const input = getObjectSchema.parse(props);\n\n return new GetObjectCommand({\n Bucket: BUCKET_NAME,\n Key: getDriveBucketKey(input.id, input.variant),\n ResponseContentDisposition: input.disposition,\n });\n }\n\n /**\n * Get object\n */\n async getObject(id: string, options: GetFileURLSchema = getFileURLSchemaDefaults) {\n const getCommand = this.#createGetCommand({ ...options, id });\n\n return await this.#blob.send(getCommand);\n }\n\n /**\n * Create put command\n */\n #createPutCommand(props: PutObjectInput) {\n const input = putObjectSchema.parse(props);\n\n return new PutObjectCommand({\n Bucket: BUCKET_NAME,\n Key: getDriveBucketKey(input.id, input.variant),\n Body: input.body,\n ContentType: input.contentType,\n ContentLength: input.size,\n Metadata: {\n nodeId: input.id,\n },\n });\n }\n\n /**\n * Put object\n */\n async #putObject(props: PutObjectInput) {\n const putCommand = this.#createPutCommand(props);\n return await this.#blob.send(putCommand);\n }\n\n /**\n * Get nodes by parent id\n */\n async getNodesByParentId({ filters, ...query }: GetNodesByParentIdInput) {\n const orderBy = convertOrderByToQueryParams(query, nodes, asc(nodes.createdAt));\n const search = convertSearchToQueryParams(query, [nodes.name]);\n\n return this.#db\n .select()\n .from(nodes)\n .where(\n and(\n filters.nodeIds != null ? inArray(nodes.id, filters.nodeIds) : undefined,\n filters.types != null ? inArray(nodes.type, filters.types) : undefined,\n filters.isDeleted != null ? eq(nodes.isDeleted, filters.isDeleted) : undefined,\n filters.parentId ? eq(nodes.parentId, filters.parentId) : isNull(nodes.parentId),\n eq(nodes.namespace, filters.namespace),\n search,\n ),\n )\n .orderBy(orderBy as SQL);\n }\n\n /**\n * Get file url\n */\n async getSignedURL(node: Node, options: GetFileURLSchema = getFileURLSchemaDefaults) {\n const [presignedUrl] = await this.#db\n .select({ url: nodePresignedUrls.url, expiresAt: nodePresignedUrls.expiresAt })\n .from(nodePresignedUrls)\n .where(\n and(\n eq(nodePresignedUrls.nodeId, node.id),\n eq(nodePresignedUrls.variant, options.variant),\n eq(nodePresignedUrls.disposition, options.disposition),\n ),\n );\n\n if (presignedUrl && presignedUrl.expiresAt > new Date()) return presignedUrl.url;\n\n const expiresIn = 3600 * 24;\n\n // Get the variants\n const variants = await this.#db\n .select()\n .from(nodeVariants)\n .where(eq(nodeVariants.nodeId, node.id));\n\n // If the requested variant does not exist, fallback to main\n const variantExists = variants.find((v) => v.variant === options.variant);\n const variant = variantExists ? options.variant : \"main\";\n\n console.info(\n `Generating new signed url for file: ${node.id} with variant: ${variant} and disposition: ${options.disposition}`,\n );\n\n // Generate the get command\n const getCommand = this.#createGetCommand({\n id: node.id,\n variant,\n disposition: `${options.disposition}; filename=\"${node.name}\"`,\n });\n\n // Generate the presigned url that expires in 24 hours\n const url = await getSignedUrl(this.#blob, getCommand, { expiresIn });\n\n // Add the presigned url to the database\n after(async () => {\n await this.#db\n .insert(nodePresignedUrls)\n .values({\n nodeId: node.id,\n url,\n variant,\n disposition: options.disposition,\n expiresAt: addSeconds(new Date(), expiresIn),\n })\n .onConflictDoUpdate({\n target: [\n nodePresignedUrls.nodeId,\n nodePresignedUrls.variant,\n nodePresignedUrls.disposition,\n ],\n set: { url, expiresAt: addSeconds(new Date(), expiresIn) },\n });\n });\n\n return url;\n }\n\n /**\n * Upload file to S3 and add it to the database\n **/\n async uploadFile(input: UploadFileSchema & Pick<PutObjectInput, \"body\">) {\n const id = generateDefaultUUID();\n\n return await this.#db.transaction(async (tx) => {\n const [result] = await tx\n .insert(nodes)\n .values({\n id,\n type: \"file\",\n name: input.name,\n namespace: input.namespace,\n parentId: input.parentId,\n size: input.size,\n contentType: input.contentType,\n mode: input.mode,\n subtype: inferNodeSubtype(input),\n })\n .returning();\n\n if (!result) {\n throw new ServerError(\"INTERNAL_SERVER_ERROR\", {\n message: \"Oep! Er is iets fout gegaan\",\n });\n }\n\n await this.#putObject({\n id,\n body: input.body,\n variant: \"main\",\n name: input.name,\n contentType: input.contentType,\n size: input.size,\n });\n\n return result;\n });\n }\n\n /**\n * Presign a new upload\n */\n async presignUpload(input: PresignFileSchema) {\n // Generate the put command\n const putCommand = this.#createPutCommand({\n id: input.id,\n name: input.name,\n variant: \"main\",\n contentType: input.contentType,\n size: input.size,\n });\n\n // Generate the presigned url\n const presignedUrl = await getSignedUrl(this.#blob, putCommand, { expiresIn: 3600 });\n\n const [node] = await this.#db\n .insert(nodes)\n .values({\n ...input,\n subtype: inferNodeSubtype(input),\n isPending: true,\n type: \"file\",\n id: input.id,\n })\n .returning();\n\n if (!node) {\n throw new ServerError(\"INTERNAL_SERVER_ERROR\", {\n message: \"Oep! Er is iets fout gegaan\",\n });\n }\n\n // Return the result\n return { id: input.id, presignedUrl, node };\n }\n\n /**\n * Confirm a new upload\n */\n async confirmUpload(input: { id: string }) {\n const [result] = await this.#db\n .update(nodes)\n .set({ isPending: false })\n .where(eq(nodes.id, input.id))\n .returning();\n\n if (!result) {\n throw new ServerError(\"NOT_FOUND\", { message: \"File not found\" });\n }\n\n /**\n * Generate the preview version of the file\n */\n // after(async () => {});\n await this.generatePreviews(input);\n\n return result;\n }\n\n /**\n * Generate preview version of the file\n */\n async generatePreviews(input: { id: string }) {\n /**\n * Get the main version of the file\n */\n const getCommand = this.#createGetCommand({ id: input.id, variant: \"main\" });\n\n const response = await this.#blob.send(getCommand);\n const contentType = response.ContentType;\n if (!response.Body) {\n throw new ServerError(\"INTERNAL_SERVER_ERROR\", {\n message: \"Oep! Er is iets fout gegaan\",\n });\n }\n\n /**\n * Transform the main version of the file to a buffer\n */\n const byteArray = await response.Body.transformToByteArray();\n const buffer = Buffer.from(byteArray);\n\n /**\n * Generate the preview versions for images\n */\n if (contentType?.startsWith(\"image/\")) {\n const sharp = await import(\"sharp\");\n\n // Generate the preview versions\n await Promise.allSettled(\n deviceSizes.flatMap(async (width) => {\n // Generate the preview\n const preview = await sharp.default(buffer).resize({ width }).webp().toBuffer();\n\n // Upload the preview and add the variant to the database\n return this.#db.transaction(async (tx) => {\n await this.#putObject({\n id: input.id,\n body: preview,\n variant: `preview-${width}`,\n contentType: \"image/webp\",\n size: preview.byteLength,\n });\n\n await tx.insert(nodeVariants).values({\n nodeId: input.id,\n variant: `preview-${width}`,\n width,\n });\n });\n }),\n );\n }\n }\n\n /**\n * Create a new folder\n */\n async createFolder(input: CreateFolderNodeSchema) {\n const [parent] = input.parentId\n ? await this.#db.select().from(nodes).where(eq(nodes.id, input.parentId))\n : [];\n\n /**\n * Validate\n */\n if (input.parentId && !parent) {\n throw new ServerError(\"BAD_REQUEST\", { message: \"Parent not found\" });\n }\n\n if (parent && !isFolder(parent)) {\n throw new ServerError(\"BAD_REQUEST\", { message: \"Parent is not a folder\" });\n }\n\n if (parent && parent.namespace !== input.namespace) {\n throw new ServerError(\"BAD_REQUEST\", {\n message: \"Parent is not in the same namespace\",\n });\n }\n\n /**\n * Create the folder\n */\n const [result] = await this.#db\n .insert(nodes)\n .values({ ...input, type: \"folder\" })\n .returning();\n\n if (!result) {\n throw new ServerError(\"INTERNAL_SERVER_ERROR\", {\n message: \"Folder kon niet worden aangemaakt\",\n });\n }\n\n return result;\n }\n\n /**\n * Update a node\n */\n async updateNode(input: { id: string; data: UpdateNodeSchema }) {\n const [node] = await this.#db\n .select({ readonly: nodes.readonly })\n .from(nodes)\n .where(eq(nodes.id, input.id));\n\n if (node?.readonly) {\n throw new ServerError(\"BAD_REQUEST\", { message: \"Node is readonly\" });\n }\n\n const [result] = await this.#db\n .update(nodes)\n .set(input.data)\n .where(eq(nodes.id, input.id))\n .returning();\n\n if (!result) {\n throw new ServerError(\"INTERNAL_SERVER_ERROR\", {\n message: \"Node kon niet worden gewijzigd\",\n });\n }\n\n return result;\n }\n\n /**\n * Delete nodes\n */\n async deleteNodes(input: BulkActionSchema) {\n const items = await this.#db\n .select({ id: nodes.id, type: nodes.type, readonly: nodes.readonly })\n .from(nodes)\n .where(inArray(nodes.id, input.ids));\n\n // Check if the nodes are readonly\n if (items.some((item) => item.readonly)) {\n throw new ServerError(\"BAD_REQUEST\", { message: \"Nodes are readonly\" });\n }\n\n // Split the nodes into folders and files\n const folders = items.filter(isFolder).map((folder) => folder.id);\n const files = items.filter(isFile).map((file) => file.id);\n\n // Delete command for S3\n const deleteCommand =\n files.length > 0\n ? new DeleteObjectsCommand({\n Bucket: BUCKET_NAME,\n Delete: {\n Objects: files.map((id) => ({ Key: id })),\n },\n })\n : undefined;\n\n /**\n * Delete files and folders in a transaction\n */\n await this.#db.transaction(async (tx) => {\n await tx.delete(nodes).where(inArray(nodes.id, folders));\n await tx.delete(nodes).where(inArray(nodes.id, files));\n\n if (deleteCommand) await this.#blob.send(deleteCommand);\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiDA,IAAa,iBAAb,MAA6D;;;;CAI3D;CACA;;;;CAKA,YAAY,EAAE,IAAI,UAAyC;AACzD,QAAKA,KAAM;AACX,QAAKC,OAAQ,IAAI,SAAS,OAAO;;;;;CAMnC,OAAO;AACL,SAAO,MAAKA;;;;;CAMd,kBAAkB,OAAuB;EACvC,MAAM,QAAQ,gBAAgB,MAAM,MAAM;AAE1C,SAAO,IAAI,iBAAiB;GAC1B,QAAQ;GACR,KAAK,kBAAkB,MAAM,IAAI,MAAM,QAAQ;GAC/C,4BAA4B,MAAM;GACnC,CAAC;;;;;CAMJ,MAAM,UAAU,IAAY,UAA4B,0BAA0B;EAChF,MAAM,aAAa,MAAKC,iBAAkB;GAAE,GAAG;GAAS;GAAI,CAAC;AAE7D,SAAO,MAAM,MAAKD,KAAM,KAAK,WAAW;;;;;CAM1C,kBAAkB,OAAuB;EACvC,MAAM,QAAQ,gBAAgB,MAAM,MAAM;AAE1C,SAAO,IAAI,iBAAiB;GAC1B,QAAQ;GACR,KAAK,kBAAkB,MAAM,IAAI,MAAM,QAAQ;GAC/C,MAAM,MAAM;GACZ,aAAa,MAAM;GACnB,eAAe,MAAM;GACrB,UAAU,EACR,QAAQ,MAAM,IACf;GACF,C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