@tulip-systems/core 0.7.0 → 0.8.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/server.d.mts +3 -3
- package/dist/auth/server.mjs +3 -3
- package/dist/components/editor/components/editor.client.d.mts +4 -3
- package/dist/components/editor/components/editor.client.d.mts.map +1 -1
- package/dist/components/editor/components/editor.client.mjs +5 -2
- package/dist/components/editor/components/editor.client.mjs.map +1 -1
- package/dist/components/editor/extensions/file-handler/extension.d.mts +4 -4
- package/dist/components/editor/extensions/file-handler/extension.d.mts.map +1 -1
- package/dist/components/editor/extensions/file-handler/extension.mjs.map +1 -1
- package/dist/components/editor/extensions/file-handler/strategy.d.mts +4 -6
- package/dist/components/editor/extensions/file-handler/strategy.d.mts.map +1 -1
- package/dist/components/editor/extensions/file-handler/strategy.mjs +11 -11
- package/dist/components/editor/extensions/file-handler/strategy.mjs.map +1 -1
- package/dist/components/editor/extensions/file-handler/utils.mjs +1 -1
- package/dist/components/editor/extensions/file-handler/utils.mjs.map +1 -1
- package/dist/components/editor/extensions/image/extension.mjs +9 -9
- package/dist/components/editor/extensions/image/extension.mjs.map +1 -1
- package/dist/components/editor/lib/constants.d.mts +1 -1
- package/dist/components/editor/lib/constants.mjs +1 -1
- package/dist/components/editor/lib/extensions.d.mts +1 -1
- package/dist/components/editor/lib/helpers.d.mts +11 -3
- package/dist/components/editor/lib/helpers.d.mts.map +1 -1
- package/dist/components/editor/lib/helpers.mjs +27 -13
- package/dist/components/editor/lib/helpers.mjs.map +1 -1
- package/dist/components/ui/combobox-dropdown.client.mjs +1 -0
- package/dist/components/ui/combobox-dropdown.client.mjs.map +1 -1
- package/dist/components/ui/combobox.client.mjs +1 -1
- package/dist/components/ui/combobox.client.mjs.map +1 -1
- package/dist/components.d.mts +2 -2
- package/dist/components.mjs +2 -2
- package/dist/config/server.d.mts +1 -3
- package/dist/config/server.mjs +1 -4
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/data-tables/client.d.mts +2 -1
- package/dist/data-tables/client.mjs +2 -1
- package/dist/data-tables.d.mts +1 -1
- package/dist/database/client.d.mts +1 -0
- package/dist/database/client.mjs +1 -0
- package/dist/database/server.d.mts +2 -0
- package/dist/database/server.mjs +3 -0
- package/dist/database.d.mts +3 -0
- package/dist/database.mjs +3 -0
- package/dist/emails/client.d.mts +1 -0
- package/dist/emails/client.mjs +1 -0
- package/dist/emails/server.d.mts +2 -0
- package/dist/emails/server.mjs +3 -0
- package/dist/emails.d.mts +1 -0
- package/dist/emails.mjs +1 -0
- package/dist/lib/utils/markdown.d.mts +10 -0
- package/dist/lib/utils/markdown.d.mts.map +1 -0
- package/dist/lib/utils/markdown.mjs +15 -0
- package/dist/lib/utils/markdown.mjs.map +1 -0
- package/dist/lib/utils/url.mjs +2 -1
- package/dist/lib/utils/url.mjs.map +1 -1
- package/dist/lib/utils/user-agent.mjs +15 -0
- package/dist/lib/utils/user-agent.mjs.map +1 -1
- package/dist/lib.d.mts +2 -2
- package/dist/lib.mjs +2 -2
- package/dist/modules/auth/components/create-first-user-guard.server.d.mts +16 -0
- package/dist/modules/auth/components/create-first-user-guard.server.d.mts.map +1 -0
- package/dist/modules/auth/components/create-first-user-guard.server.mjs +16 -0
- package/dist/modules/auth/components/create-first-user-guard.server.mjs.map +1 -0
- package/dist/modules/auth/components/guard.server.d.mts +2 -2
- package/dist/modules/auth/components/guard.server.mjs +1 -1
- package/dist/modules/auth/components/guard.server.mjs.map +1 -1
- package/dist/modules/auth/db/schema.d.mts +1 -1
- package/dist/modules/auth/db/schema.mjs +2 -2
- package/dist/modules/auth/handler/create-client.client.d.mts +4838 -229
- package/dist/modules/auth/handler/create-client.client.d.mts.map +1 -1
- package/dist/modules/auth/handler/create-client.client.mjs.map +1 -1
- package/dist/modules/auth/handler/proxy.server.mjs +2 -2
- package/dist/modules/auth/handler/proxy.server.mjs.map +1 -1
- package/dist/modules/auth/handler/route.server.d.mts +2 -2
- package/dist/modules/auth/handler/route.server.d.mts.map +1 -1
- package/dist/modules/auth/handler/route.server.mjs.map +1 -1
- package/dist/modules/auth/handler/{init.d.mts → service.server.d.mts} +322 -90
- package/dist/modules/auth/handler/service.server.d.mts.map +1 -0
- package/dist/modules/auth/handler/{init.mjs → service.server.mjs} +19 -8
- package/dist/modules/auth/handler/service.server.mjs.map +1 -0
- package/dist/modules/auth/hooks/use-session.d.mts +9 -4
- package/dist/modules/auth/hooks/use-session.d.mts.map +1 -1
- package/dist/modules/auth/lib/helpers.server.d.mts +1 -1
- package/dist/modules/auth/lib/permissions.d.mts +1 -1
- package/dist/modules/auth/lib/validators.mjs +1 -1
- package/dist/modules/config/lib/context.d.mts +9 -10
- 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/lib/converters/search.d.mts +1 -1
- package/dist/modules/data-tables/lib/converters/sorting.d.mts +1 -1
- package/dist/modules/data-tables/server/get-data.server.d.mts +3 -3
- package/dist/modules/data-tables/server/get-data.server.mjs +1 -1
- package/dist/modules/data-tables/server/get-data.server.mjs.map +1 -1
- package/dist/modules/data-tables/strategies/infinite/strategy.d.mts +1 -1
- package/dist/modules/data-tables/strategies/infinite/strategy.mjs +3 -0
- package/dist/modules/data-tables/strategies/infinite/strategy.mjs.map +1 -1
- package/dist/modules/data-tables/tables/data-table/components/row.mjs +5 -15
- package/dist/modules/data-tables/tables/data-table/components/row.mjs.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/body.mjs +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/body.mjs.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/row.client.mjs +13 -23
- package/dist/modules/data-tables/tables/inline-table/components/row.client.mjs.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/table.d.mts +1 -0
- package/dist/modules/data-tables/tables/inline-table/components/table.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/components/table.mjs +2 -1
- package/dist/modules/data-tables/tables/inline-table/components/table.mjs.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts +5 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.d.mts.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.mjs +2 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/context.client.mjs.map +1 -1
- package/dist/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.d.mts +30 -0
- package/dist/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.d.mts.map +1 -0
- package/dist/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.mjs +77 -9
- package/dist/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.mjs.map +1 -1
- package/dist/modules/{config/db → database/lib}/helpers.d.mts +2 -2
- package/dist/modules/database/lib/helpers.d.mts.map +1 -0
- package/dist/modules/{config/db → database/lib}/helpers.mjs +1 -1
- package/dist/modules/database/lib/helpers.mjs.map +1 -0
- package/dist/modules/database/lib/service.server.d.mts +34 -0
- package/dist/modules/database/lib/service.server.d.mts.map +1 -0
- package/dist/modules/database/lib/service.server.mjs +24 -0
- package/dist/modules/database/lib/service.server.mjs.map +1 -0
- package/dist/modules/{config/db → database/lib}/types.d.mts +1 -1
- package/dist/modules/database/lib/types.d.mts.map +1 -0
- package/dist/modules/emails/lib/service.server.d.mts +29 -0
- package/dist/modules/emails/lib/service.server.d.mts.map +1 -0
- package/dist/modules/emails/lib/service.server.mjs +21 -0
- package/dist/modules/emails/lib/service.server.mjs.map +1 -0
- package/dist/modules/inline-edit/components/date-input.client.mjs +1 -1
- package/dist/modules/inline-edit/components/date-input.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/date-picker.client.mjs +1 -0
- package/dist/modules/inline-edit/components/date-picker.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/date-time.client.mjs +1 -0
- package/dist/modules/inline-edit/components/date-time.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/editor.client.mjs +1 -0
- package/dist/modules/inline-edit/components/editor.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/input-recipient.client.mjs +1 -0
- package/dist/modules/inline-edit/components/input-recipient.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/input-toggle.client.mjs +1 -0
- package/dist/modules/inline-edit/components/input-toggle.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/input.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/input.client.mjs +3 -0
- package/dist/modules/inline-edit/components/input.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/select.client.d.mts.map +1 -1
- package/dist/modules/inline-edit/components/select.client.mjs +1 -0
- package/dist/modules/inline-edit/components/select.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/switch.client.mjs +1 -0
- package/dist/modules/inline-edit/components/switch.client.mjs.map +1 -1
- package/dist/modules/inline-edit/components/toggle.client.mjs +1 -0
- package/dist/modules/inline-edit/components/toggle.client.mjs.map +1 -1
- package/dist/modules/router/handler/context.server.d.mts +12 -10
- package/dist/modules/router/handler/context.server.d.mts.map +1 -1
- package/dist/modules/router/handler/init.server.d.mts +13 -11
- package/dist/modules/router/handler/init.server.d.mts.map +1 -1
- package/dist/modules/router/handler/init.server.mjs +2 -2
- package/dist/modules/router/handler/init.server.mjs.map +1 -1
- package/dist/modules/router/handler/route.server.d.mts +1 -1
- package/dist/modules/storage/components/dropzone.client.d.mts +2 -2
- package/dist/modules/storage/components/dropzone.client.d.mts.map +1 -1
- package/dist/modules/storage/components/dropzone.client.mjs.map +1 -1
- package/dist/modules/storage/components/image-grid.client.d.mts +3 -3
- package/dist/modules/storage/components/image-grid.client.d.mts.map +1 -1
- package/dist/modules/storage/components/image-grid.client.mjs +20 -22
- package/dist/modules/storage/components/image-grid.client.mjs.map +1 -1
- package/dist/modules/storage/components/image.client.d.mts +8 -0
- package/dist/modules/storage/components/image.client.d.mts.map +1 -0
- package/dist/modules/storage/components/image.client.mjs +17 -0
- package/dist/modules/storage/components/image.client.mjs.map +1 -0
- package/dist/modules/storage/components/upload-button.client.d.mts +12 -0
- package/dist/modules/storage/components/upload-button.client.d.mts.map +1 -0
- package/dist/modules/storage/components/upload-button.client.mjs +34 -0
- package/dist/modules/storage/components/upload-button.client.mjs.map +1 -0
- package/dist/modules/storage/components/upload-zone-context.client.d.mts +5 -5
- package/dist/modules/storage/components/upload-zone-context.client.d.mts.map +1 -1
- package/dist/modules/storage/components/upload-zone-context.client.mjs +2 -2
- package/dist/modules/storage/components/upload-zone-context.client.mjs.map +1 -1
- package/dist/modules/storage/components/upload-zone.client.d.mts +4 -4
- package/dist/modules/storage/components/upload-zone.client.d.mts.map +1 -1
- package/dist/modules/storage/components/upload-zone.client.mjs +16 -9
- package/dist/modules/storage/components/upload-zone.client.mjs.map +1 -1
- package/dist/modules/storage/lib/constants.d.mts +1 -5
- package/dist/modules/storage/lib/constants.d.mts.map +1 -1
- package/dist/modules/storage/lib/constants.mjs +1 -13
- package/dist/modules/storage/lib/constants.mjs.map +1 -1
- package/dist/modules/storage/lib/helpers.d.mts +14 -28
- package/dist/modules/storage/lib/helpers.d.mts.map +1 -1
- package/dist/modules/storage/lib/helpers.mjs +17 -75
- package/dist/modules/storage/lib/helpers.mjs.map +1 -1
- package/dist/modules/storage/lib/procedures.server.d.mts +1991 -0
- package/dist/modules/{auth/handler/init.d.mts.map → storage/lib/procedures.server.d.mts.map} +1 -1
- package/dist/modules/storage/lib/procedures.server.mjs +22 -0
- package/dist/modules/storage/lib/procedures.server.mjs.map +1 -0
- package/dist/modules/storage/lib/router-handlers.server.d.mts +41 -0
- package/dist/modules/storage/lib/router-handlers.server.d.mts.map +1 -0
- package/dist/modules/storage/lib/router-handlers.server.mjs +124 -0
- package/dist/modules/storage/lib/router-handlers.server.mjs.map +1 -0
- package/dist/modules/storage/lib/schema.d.mts +68 -958
- package/dist/modules/storage/lib/schema.d.mts.map +1 -1
- package/dist/modules/storage/lib/schema.mjs +28 -65
- package/dist/modules/storage/lib/schema.mjs.map +1 -1
- package/dist/modules/storage/lib/service.server.d.mts +2155 -141
- package/dist/modules/storage/lib/service.server.d.mts.map +1 -1
- package/dist/modules/storage/lib/service.server.mjs +453 -242
- package/dist/modules/storage/lib/service.server.mjs.map +1 -1
- package/dist/modules/storage/lib/upload.client.d.mts +58 -0
- package/dist/modules/storage/lib/upload.client.d.mts.map +1 -0
- package/dist/modules/storage/lib/upload.client.mjs +87 -0
- package/dist/modules/storage/lib/upload.client.mjs.map +1 -0
- package/dist/modules/storage/lib/validators.d.mts +297 -835
- package/dist/modules/storage/lib/validators.d.mts.map +1 -1
- package/dist/modules/storage/lib/validators.mjs +32 -76
- package/dist/modules/storage/lib/validators.mjs.map +1 -1
- package/dist/modules/storage/providers/adapters/s3.server.d.mts +19 -0
- package/dist/modules/storage/providers/adapters/s3.server.d.mts.map +1 -0
- package/dist/modules/storage/providers/adapters/s3.server.mjs +173 -0
- package/dist/modules/storage/providers/adapters/s3.server.mjs.map +1 -0
- package/dist/modules/storage/providers/lib/constants.d.mts +6 -0
- package/dist/modules/storage/providers/lib/constants.d.mts.map +1 -0
- package/dist/modules/storage/providers/lib/constants.mjs +6 -0
- package/dist/modules/storage/providers/lib/constants.mjs.map +1 -0
- package/dist/modules/storage/providers/lib/errors.d.mts +12 -0
- package/dist/modules/storage/providers/lib/errors.d.mts.map +1 -0
- package/dist/modules/storage/providers/lib/errors.mjs +13 -0
- package/dist/modules/storage/providers/lib/errors.mjs.map +1 -0
- package/dist/modules/storage/providers/lib/types.d.mts +21 -0
- package/dist/modules/storage/providers/lib/types.d.mts.map +1 -0
- package/dist/modules/storage/providers/lib/validators.d.mts +112 -0
- package/dist/modules/storage/providers/lib/validators.d.mts.map +1 -0
- package/dist/modules/storage/providers/lib/validators.mjs +75 -0
- package/dist/modules/storage/providers/lib/validators.mjs.map +1 -0
- package/dist/router/server.d.mts +1 -1
- package/dist/storage/client.d.mts +4 -2
- package/dist/storage/client.mjs +4 -2
- package/dist/storage/server.d.mts +5 -4
- package/dist/storage/server.mjs +5 -4
- package/dist/storage.d.mts +9 -6
- package/dist/storage.mjs +8 -6
- package/package.json +18 -5
- package/src/components/editor/components/editor.client.tsx +9 -1
- package/src/components/editor/extensions/file-handler/extension.ts +4 -4
- package/src/components/editor/extensions/file-handler/strategy.ts +15 -40
- package/src/components/editor/extensions/file-handler/utils.ts +1 -1
- package/src/components/editor/extensions/image/extension.ts +10 -10
- package/src/components/editor/lib/helpers.ts +28 -11
- package/src/components/ui/combobox-dropdown.client.tsx +1 -0
- package/src/components/ui/combobox.client.tsx +1 -1
- package/src/entry.ts +12 -51
- package/src/lib/entry.ts +1 -5
- package/src/lib/utils/markdown.ts +10 -0
- package/src/lib/utils/url.ts +2 -1
- package/src/lib/utils/user-agent.ts +15 -0
- package/src/modules/auth/components/{guard-first-user.server.tsx → create-first-user-guard.server.tsx} +8 -8
- package/src/modules/auth/components/guard.server.tsx +1 -1
- package/src/modules/auth/entry.server.ts +4 -5
- package/src/modules/auth/handler/create-client.client.ts +2 -2
- package/src/modules/auth/handler/proxy.server.ts +1 -1
- package/src/modules/auth/handler/route.server.ts +2 -2
- package/src/modules/auth/handler/{init.ts → service.server.ts} +30 -9
- package/src/modules/config/entry.server.ts +0 -9
- package/src/modules/config/entry.ts +2 -2
- package/src/modules/config/lib/context.ts +9 -9
- package/src/modules/data-tables/entry.client.ts +1 -0
- package/src/modules/data-tables/server/get-data.server.ts +1 -1
- package/src/modules/data-tables/strategies/infinite/strategy.ts +4 -1
- package/src/modules/data-tables/tables/data-table/components/row.tsx +12 -21
- package/src/modules/data-tables/tables/inline-table/components/body.tsx +1 -1
- package/src/modules/data-tables/tables/inline-table/components/row.client.tsx +24 -30
- package/src/modules/data-tables/tables/inline-table/components/table.tsx +6 -1
- package/src/modules/data-tables/tables/inline-table/hooks/context.client.tsx +5 -0
- package/src/modules/data-tables/tables/inline-table/hooks/use-hotkeys.client.ts +119 -91
- package/src/modules/database/entry.client.ts +0 -0
- package/src/modules/database/entry.server.ts +4 -0
- package/src/modules/database/entry.ts +5 -0
- package/src/modules/database/lib/service.server.ts +33 -0
- package/src/modules/emails/entry.client.ts +0 -0
- package/src/modules/emails/entry.server.ts +4 -0
- package/src/modules/emails/entry.ts +0 -0
- package/src/modules/emails/lib/service.server.ts +29 -0
- package/src/modules/inline-edit/components/date-input.client.tsx +1 -1
- package/src/modules/inline-edit/components/date-picker.client.tsx +1 -0
- package/src/modules/inline-edit/components/date-time.client.tsx +1 -0
- package/src/modules/inline-edit/components/editor.client.tsx +3 -0
- package/src/modules/inline-edit/components/input-recipient.client.tsx +1 -0
- package/src/modules/inline-edit/components/input-toggle.client.tsx +1 -0
- package/src/modules/inline-edit/components/input.client.tsx +3 -0
- package/src/modules/inline-edit/components/select.client.tsx +5 -1
- package/src/modules/inline-edit/components/switch.client.tsx +1 -0
- package/src/modules/inline-edit/components/toggle.client.tsx +1 -0
- package/src/modules/router/handler/init.server.ts +2 -2
- package/src/modules/storage/components/dropzone.client.tsx +1 -1
- package/src/modules/storage/components/image-grid.client.tsx +23 -20
- package/src/modules/storage/components/image.client.tsx +8 -0
- package/src/modules/storage/components/upload-zone-context.client.tsx +11 -8
- package/src/modules/storage/components/upload-zone.client.tsx +22 -16
- package/src/modules/storage/entry.client.ts +3 -1
- package/src/modules/storage/entry.server.ts +9 -3
- package/src/modules/storage/entry.ts +13 -1
- package/src/modules/storage/lib/constants.ts +0 -11
- package/src/modules/storage/lib/helpers.ts +18 -65
- package/src/modules/storage/lib/procedures.server.ts +60 -0
- package/src/modules/storage/lib/router-handlers.server.ts +178 -0
- package/src/modules/storage/lib/schema.ts +26 -97
- package/src/modules/storage/lib/service.server.ts +636 -374
- package/src/modules/storage/lib/upload.client.ts +156 -0
- package/src/modules/storage/lib/validators.ts +50 -111
- package/src/modules/storage/providers/adapters/s3.server.ts +281 -0
- package/src/modules/storage/providers/lib/constants.ts +3 -0
- package/src/modules/storage/providers/lib/errors.ts +21 -0
- package/src/modules/storage/providers/lib/types.ts +28 -0
- package/src/modules/storage/providers/lib/validators.ts +122 -0
- package/dist/lib/config/constants.d.mts +0 -5
- package/dist/lib/config/constants.d.mts.map +0 -1
- package/dist/lib/config/constants.mjs +0 -6
- package/dist/lib/config/constants.mjs.map +0 -1
- package/dist/modules/auth/components/guard-first-user.server.d.mts +0 -18
- package/dist/modules/auth/components/guard-first-user.server.d.mts.map +0 -1
- package/dist/modules/auth/components/guard-first-user.server.mjs +0 -16
- package/dist/modules/auth/components/guard-first-user.server.mjs.map +0 -1
- package/dist/modules/auth/handler/init.mjs.map +0 -1
- package/dist/modules/config/db/helpers.d.mts.map +0 -1
- package/dist/modules/config/db/helpers.mjs.map +0 -1
- package/dist/modules/config/db/init.d.mts +0 -20
- package/dist/modules/config/db/init.d.mts.map +0 -1
- package/dist/modules/config/db/init.mjs +0 -15
- package/dist/modules/config/db/init.mjs.map +0 -1
- package/dist/modules/config/db/types.d.mts.map +0 -1
- package/dist/modules/config/providers/email.d.mts +0 -12
- package/dist/modules/config/providers/email.d.mts.map +0 -1
- package/dist/modules/config/providers/email.mjs +0 -11
- package/dist/modules/config/providers/email.mjs.map +0 -1
- package/dist/modules/storage/config/filters.d.mts +0 -17
- package/dist/modules/storage/config/filters.d.mts.map +0 -1
- package/dist/modules/storage/config/filters.mjs +0 -17
- package/dist/modules/storage/config/filters.mjs.map +0 -1
- package/dist/modules/storage/lib/create-client.server.d.mts +0 -11
- package/dist/modules/storage/lib/create-client.server.d.mts.map +0 -1
- package/dist/modules/storage/lib/create-client.server.mjs +0 -11
- package/dist/modules/storage/lib/create-client.server.mjs.map +0 -1
- package/dist/modules/storage/lib/create-upload.client.d.mts +0 -56
- package/dist/modules/storage/lib/create-upload.client.d.mts.map +0 -1
- package/dist/modules/storage/lib/create-upload.client.mjs +0 -98
- package/dist/modules/storage/lib/create-upload.client.mjs.map +0 -1
- package/dist/modules/storage/lib/proxy.server.d.mts +0 -21
- package/dist/modules/storage/lib/proxy.server.d.mts.map +0 -1
- package/dist/modules/storage/lib/proxy.server.mjs +0 -46
- package/dist/modules/storage/lib/proxy.server.mjs.map +0 -1
- package/dist/modules/storage/lib/router.server.d.mts +0 -31002
- package/dist/modules/storage/lib/router.server.d.mts.map +0 -1
- package/dist/modules/storage/lib/router.server.mjs +0 -86
- package/dist/modules/storage/lib/router.server.mjs.map +0 -1
- package/src/lib/config/constants.ts +0 -1
- package/src/lib/utils/time-picker.ts +0 -139
- package/src/modules/config/db/init.ts +0 -21
- package/src/modules/config/providers/email.ts +0 -13
- package/src/modules/storage/config/filters.ts +0 -12
- package/src/modules/storage/lib/create-client.server.ts +0 -14
- package/src/modules/storage/lib/create-upload.client.ts +0 -134
- package/src/modules/storage/lib/proxy.server.ts +0 -63
- package/src/modules/storage/lib/router.server.ts +0 -182
- /package/src/modules/{config/db → database/lib}/helpers.ts +0 -0
- /package/src/modules/{config/db → database/lib}/types.ts +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { UploadHooks } from "../lib/
|
|
1
|
+
import { StorageAsset, UploadInput } from "../lib/validators.mjs";
|
|
2
|
+
import { UploadHooks } from "../lib/upload.client.mjs";
|
|
3
3
|
import { UploadZoneContextValue } from "./upload-zone-context.client.mjs";
|
|
4
4
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
5
|
import { ComponentProps } from "react";
|
|
6
6
|
|
|
7
7
|
//#region src/modules/storage/components/upload-zone.client.d.ts
|
|
8
8
|
type UploadZoneProps = ComponentProps<"div"> & Pick<UploadZoneContextValue, "optimistic" | "uploadClient" | "disabled"> & {
|
|
9
|
-
variables: Pick<
|
|
9
|
+
variables: Pick<UploadInput, "visibility">;
|
|
10
10
|
uploadHooks?: UploadHooks;
|
|
11
|
-
onUploadCompleted?: (
|
|
11
|
+
onUploadCompleted?: (asset: StorageAsset) => Promise<void> | void;
|
|
12
12
|
onUploadFailed?: (error: unknown) => Promise<void> | void;
|
|
13
13
|
};
|
|
14
14
|
declare function UploadZone({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-zone.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/upload-zone.client.tsx"],"mappings":";;;;;;;KAWY,eAAA,GAAkB,cAAA,UAC5B,IAAA,CAAK,sBAAA;EACH,SAAA,EAAW,IAAA,CAAK,
|
|
1
|
+
{"version":3,"file":"upload-zone.client.d.mts","names":[],"sources":["../../../../src/modules/storage/components/upload-zone.client.tsx"],"mappings":";;;;;;;KAWY,eAAA,GAAkB,cAAA,UAC5B,IAAA,CAAK,sBAAA;EACH,SAAA,EAAW,IAAA,CAAK,WAAA;EAChB,WAAA,GAAc,WAAA;EAEd,iBAAA,IAAqB,KAAA,EAAO,YAAA,KAAiB,OAAA;EAC7C,cAAA,IAAkB,KAAA,cAAmB,OAAA;AAAA;AAAA,iBAGzB,UAAA,CAAA;EACd,SAAA;EACA,UAAA;EACA,YAAA;EACA,WAAA;EACA,iBAAA;EACA,cAAA;EACA,QAAA;EACA,QAAA;EACA,SAAA;EAAA,GACG;AAAA,GACF,eAAA,GAAe,kBAAA,CAAA,GAAA,CAAA,OAAA"}
|
|
@@ -14,7 +14,9 @@ function UploadZone({ variables, optimistic, uploadClient, uploadHooks, onUpload
|
|
|
14
14
|
* Delete mutation
|
|
15
15
|
*/
|
|
16
16
|
const deleteMutation = useAction({
|
|
17
|
-
mutationFn: async (ids) =>
|
|
17
|
+
mutationFn: async (ids) => {
|
|
18
|
+
await uploadClient.deleteAssets(ids);
|
|
19
|
+
},
|
|
18
20
|
onMutate: async (ids) => {
|
|
19
21
|
await optimistic?.cancel?.();
|
|
20
22
|
await optimistic?.remove?.(ids);
|
|
@@ -33,24 +35,29 @@ function UploadZone({ variables, optimistic, uploadClient, uploadHooks, onUpload
|
|
|
33
35
|
const uploadMutation = useAction({
|
|
34
36
|
mutationFn: async (params) => uploadClient.upload(params, uploadHooks),
|
|
35
37
|
onMutate: async (variables) => {
|
|
36
|
-
|
|
38
|
+
await optimistic?.cancel?.();
|
|
39
|
+
const newAsset = {
|
|
37
40
|
...variables,
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
visibility: variables.visibility ?? "private",
|
|
42
|
+
status: "pending",
|
|
43
|
+
name: variables.file.name,
|
|
44
|
+
size: variables.file.size,
|
|
45
|
+
contentType: variables.file.type || "application/octet-stream",
|
|
46
|
+
etag: null,
|
|
47
|
+
metadata: null,
|
|
48
|
+
uploadedAt: /* @__PURE__ */ new Date(),
|
|
49
|
+
deletedAt: null
|
|
40
50
|
};
|
|
41
|
-
await optimistic?.
|
|
42
|
-
await optimistic?.add?.(newNode);
|
|
51
|
+
await optimistic?.add?.(newAsset);
|
|
43
52
|
},
|
|
44
53
|
onSuccess: async (data) => {
|
|
45
54
|
await onUploadCompleted?.(data);
|
|
46
55
|
toast.success(`Succesvol geupload: ${data.name}`);
|
|
47
56
|
},
|
|
48
|
-
onError: async (error
|
|
57
|
+
onError: async (error) => {
|
|
49
58
|
await onUploadFailed?.(error);
|
|
50
59
|
console.error("Upload error: ", error);
|
|
51
60
|
toast.error("Bestand uploaden mislukt", { description: error instanceof Error ? error.message : void 0 });
|
|
52
|
-
console.info("Deleting failed upload");
|
|
53
|
-
await deleteMutation.mutateAsync([variables.id]);
|
|
54
61
|
},
|
|
55
62
|
onSettled: () => {
|
|
56
63
|
optimistic?.invalidate?.();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-zone.client.mjs","names":[],"sources":["../../../../src/modules/storage/components/upload-zone.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentProps, useCallback } from \"react\";\nimport { useDropzone } from \"react-dropzone\";\nimport { toast } from \"@/components/ui/sonner.client\";\nimport { useAction } from \"@/lib/hooks/use-action\";\nimport { cn } from \"@/lib/utils/cn\";\nimport type { UploadFileRequest, UploadHooks } from \"../lib/
|
|
1
|
+
{"version":3,"file":"upload-zone.client.mjs","names":[],"sources":["../../../../src/modules/storage/components/upload-zone.client.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ComponentProps, useCallback } from \"react\";\nimport { useDropzone } from \"react-dropzone\";\nimport { toast } from \"@/components/ui/sonner.client\";\nimport { useAction } from \"@/lib/hooks/use-action\";\nimport { cn } from \"@/lib/utils/cn\";\nimport type { UploadFileRequest, UploadHooks } from \"../lib/upload.client\";\nimport type { StorageAsset, UploadInput } from \"../lib/validators\";\nimport { UploadZoneContext, type UploadZoneContextValue } from \"./upload-zone-context.client\";\n\nexport type UploadZoneProps = ComponentProps<\"div\"> &\n Pick<UploadZoneContextValue, \"optimistic\" | \"uploadClient\" | \"disabled\"> & {\n variables: Pick<UploadInput, \"visibility\">;\n uploadHooks?: UploadHooks;\n\n onUploadCompleted?: (asset: StorageAsset) => Promise<void> | void;\n onUploadFailed?: (error: unknown) => Promise<void> | void;\n };\n\nexport function UploadZone({\n variables,\n optimistic,\n uploadClient,\n uploadHooks,\n onUploadCompleted,\n onUploadFailed,\n disabled = false,\n children,\n className,\n ...props\n}: UploadZoneProps) {\n /**\n * Delete mutation\n */\n const deleteMutation = useAction({\n mutationFn: async (ids: string[]) => {\n await uploadClient.deleteAssets(ids);\n },\n onMutate: async (ids) => {\n await optimistic?.cancel?.();\n await optimistic?.remove?.(ids);\n },\n onError: async (error) => {\n console.error(\"Delete failed upload error: \", error);\n await onUploadFailed?.(error);\n },\n onSettled: () => {\n optimistic?.invalidate?.();\n },\n });\n\n /**\n * Upload mutation\n */\n const uploadMutation = useAction({\n mutationFn: async (params: UploadFileRequest) => uploadClient.upload(params, uploadHooks),\n onMutate: async (variables) => {\n await optimistic?.cancel?.();\n\n const newAsset = {\n ...variables,\n visibility: variables.visibility ?? \"private\",\n status: \"pending\",\n name: variables.file.name,\n size: variables.file.size,\n contentType: variables.file.type || \"application/octet-stream\",\n etag: null,\n metadata: null,\n uploadedAt: new Date(),\n deletedAt: null,\n } as Omit<StorageAsset, \"id\" | \"key\" | \"bucket\" | \"provider\" | \"createdAt\" | \"updatedAt\">;\n\n await optimistic?.add?.(newAsset);\n },\n onSuccess: async (data) => {\n await onUploadCompleted?.(data);\n toast.success(`Succesvol geupload: ${data.name}`);\n },\n onError: async (error) => {\n await onUploadFailed?.(error);\n\n console.error(\"Upload error: \", error);\n toast.error(\"Bestand uploaden mislukt\", {\n description: error instanceof Error ? error.message : undefined,\n });\n },\n onSettled: () => {\n optimistic?.invalidate?.();\n },\n });\n\n /**\n * Upload file handler\n */\n const onUpload = useCallback(\n async (file: File) => {\n console.info(\"Uploading file\", file);\n const req = uploadClient.prepareUpload({ ...variables, file });\n return await uploadMutation.mutateAsync(req);\n },\n [uploadClient, variables, uploadMutation],\n );\n\n /**\n * Drop handler\n */\n const onDrop = useCallback(\n async (acceptedFiles: File[]) => {\n if (acceptedFiles.length === 0) return;\n await Promise.allSettled(acceptedFiles.map(onUpload));\n },\n [onUpload],\n );\n\n const { getRootProps, getInputProps, isDragActive } = useDropzone({\n onDrop,\n noClick: true,\n disabled,\n });\n\n return (\n <div {...props} {...getRootProps()} className={cn(\"relative z-0\", className)}>\n <input {...getInputProps()} />\n\n {/* Show drag overlay when drag is active */}\n {isDragActive && (\n <div className=\"absolute inset-0 z-10 rounded-md bg-primary/20 opacity-70 backdrop-blur-3xl\" />\n )}\n\n <UploadZoneContext\n value={{\n uploadClient,\n onUpload,\n onRemove: deleteMutation.mutateAsync,\n optimistic,\n disabled,\n }}\n >\n {children}\n </UploadZoneContext>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AAoBA,SAAgB,WAAW,EACzB,WACA,YACA,cACA,aACA,mBACA,gBACA,WAAW,OACX,UACA,WACA,GAAG,SACe;;;;CAIlB,MAAM,iBAAiB,UAAU;EAC/B,YAAY,OAAO,QAAkB;AACnC,SAAM,aAAa,aAAa,IAAI;;EAEtC,UAAU,OAAO,QAAQ;AACvB,SAAM,YAAY,UAAU;AAC5B,SAAM,YAAY,SAAS,IAAI;;EAEjC,SAAS,OAAO,UAAU;AACxB,WAAQ,MAAM,gCAAgC,MAAM;AACpD,SAAM,iBAAiB,MAAM;;EAE/B,iBAAiB;AACf,eAAY,cAAc;;EAE7B,CAAC;;;;CAKF,MAAM,iBAAiB,UAAU;EAC/B,YAAY,OAAO,WAA8B,aAAa,OAAO,QAAQ,YAAY;EACzF,UAAU,OAAO,cAAc;AAC7B,SAAM,YAAY,UAAU;GAE5B,MAAM,WAAW;IACf,GAAG;IACH,YAAY,UAAU,cAAc;IACpC,QAAQ;IACR,MAAM,UAAU,KAAK;IACrB,MAAM,UAAU,KAAK;IACrB,aAAa,UAAU,KAAK,QAAQ;IACpC,MAAM;IACN,UAAU;IACV,4BAAY,IAAI,MAAM;IACtB,WAAW;IACZ;AAED,SAAM,YAAY,MAAM,SAAS;;EAEnC,WAAW,OAAO,SAAS;AACzB,SAAM,oBAAoB,KAAK;AAC/B,SAAM,QAAQ,uBAAuB,KAAK,OAAO;;EAEnD,SAAS,OAAO,UAAU;AACxB,SAAM,iBAAiB,MAAM;AAE7B,WAAQ,MAAM,kBAAkB,MAAM;AACtC,SAAM,MAAM,4BAA4B,EACtC,aAAa,iBAAiB,QAAQ,MAAM,UAAU,QACvD,CAAC;;EAEJ,iBAAiB;AACf,eAAY,cAAc;;EAE7B,CAAC;;;;CAKF,MAAM,WAAW,YACf,OAAO,SAAe;AACpB,UAAQ,KAAK,kBAAkB,KAAK;EACpC,MAAM,MAAM,aAAa,cAAc;GAAE,GAAG;GAAW;GAAM,CAAC;AAC9D,SAAO,MAAM,eAAe,YAAY,IAAI;IAE9C;EAAC;EAAc;EAAW;EAAe,CAC1C;CAaD,MAAM,EAAE,cAAc,eAAe,iBAAiB,YAAY;EAChE,QATa,YACb,OAAO,kBAA0B;AAC/B,OAAI,cAAc,WAAW,EAAG;AAChC,SAAM,QAAQ,WAAW,cAAc,IAAI,SAAS,CAAC;KAEvD,CAAC,SAAS,CACX;EAIC,SAAS;EACT;EACD,CAAC;AAEF,QACE,qBAAC;EAAI,GAAI;EAAO,GAAI,cAAc;EAAE,WAAW,GAAG,gBAAgB,UAAU;;GAC1E,oBAAC,WAAM,GAAI,eAAe,GAAI;GAG7B,gBACC,oBAAC,SAAI,WAAU,gFAAgF;GAGjG,oBAAC;IACC,OAAO;KACL;KACA;KACA,UAAU,eAAe;KACzB;KACA;KACD;IAEA;KACiB;;GAChB"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
//#region src/modules/storage/lib/constants.d.ts
|
|
2
|
-
declare const deviceSizes: number[];
|
|
3
|
-
declare const imageSizes: number[];
|
|
4
|
-
declare const imageVariants: readonly ["main", ...`preview-${number}`[]];
|
|
5
|
-
type ImageVariant = (typeof imageVariants)[number];
|
|
6
2
|
declare const imageDispositions: readonly ["inline", "attachment"];
|
|
7
3
|
type ImageDisposition = (typeof imageDispositions)[number];
|
|
8
4
|
//#endregion
|
|
9
|
-
export { ImageDisposition,
|
|
5
|
+
export { ImageDisposition, imageDispositions };
|
|
10
6
|
//# sourceMappingURL=constants.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.mts","names":[],"sources":["../../../../src/modules/storage/lib/constants.ts"],"mappings":";cACa,
|
|
1
|
+
{"version":3,"file":"constants.d.mts","names":[],"sources":["../../../../src/modules/storage/lib/constants.ts"],"mappings":";cACa,iBAAA;AAAA,KACD,gBAAA,WAA2B,iBAAA"}
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
//#region src/modules/storage/lib/constants.ts
|
|
2
|
-
const deviceSizes = [
|
|
3
|
-
640,
|
|
4
|
-
750,
|
|
5
|
-
828,
|
|
6
|
-
1080,
|
|
7
|
-
1200,
|
|
8
|
-
1920,
|
|
9
|
-
2048,
|
|
10
|
-
3840
|
|
11
|
-
];
|
|
12
|
-
const imageSizes = deviceSizes;
|
|
13
|
-
const imageVariants = ["main", ...deviceSizes.map((size) => `preview-${size}`)];
|
|
14
2
|
const imageDispositions = ["inline", "attachment"];
|
|
15
3
|
|
|
16
4
|
//#endregion
|
|
17
|
-
export {
|
|
5
|
+
export { imageDispositions };
|
|
18
6
|
//# sourceMappingURL=constants.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","names":[],"sources":["../../../../src/modules/storage/lib/constants.ts"],"sourcesContent":["//
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../../../../src/modules/storage/lib/constants.ts"],"sourcesContent":["// Image dispositions\nexport const imageDispositions = [\"inline\", \"attachment\"] as const;\nexport type ImageDisposition = (typeof imageDispositions)[number];\n"],"mappings":";AACA,MAAa,oBAAoB,CAAC,UAAU,aAAa"}
|
|
@@ -1,44 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CreateNodeSchema, GetFileURLSchema, Node } from "./validators.mjs";
|
|
1
|
+
import { GetAssetURLInput } from "./validators.mjs";
|
|
3
2
|
import { ImageLoaderProps } from "next/image";
|
|
4
3
|
|
|
5
4
|
//#region src/modules/storage/lib/helpers.d.ts
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
6
|
+
* Builds the public API route URL for a storage file proxy request.
|
|
7
|
+
*
|
|
8
|
+
* Use this helper when you need a stable file URL in the client/UI
|
|
9
|
+
* without manually composing the route path.
|
|
10
|
+
*
|
|
11
|
+
* @param id - Storage asset id
|
|
12
|
+
* @returns File proxy URL for the storage route handler
|
|
13
|
+
* @example
|
|
14
|
+
* const url = getAssetURL("019d0051-2c0d-741e-9e3c-e5a5bc4d16a2", { disposition: "attachment" });
|
|
15
|
+
* // /api/storage/files/019d0051-2c0d-741e-9e3c-e5a5bc4d16a2?disposition=attachment
|
|
8
16
|
*/
|
|
9
|
-
declare function
|
|
10
|
-
/**
|
|
11
|
-
* Check if the node is a folder
|
|
12
|
-
*/
|
|
13
|
-
declare function isFolder(node: Pick<Node, "type">): node is Node;
|
|
14
|
-
/**
|
|
15
|
-
* Get file url
|
|
16
|
-
*/
|
|
17
|
-
declare function getFileUrl(id: string, options?: Partial<GetFileURLSchema>): string;
|
|
17
|
+
declare function getAssetURL(id: string, options?: Partial<GetAssetURLInput>): string;
|
|
18
18
|
/**
|
|
19
19
|
* Image loader
|
|
20
20
|
*/
|
|
21
21
|
declare function imageLoader({
|
|
22
|
-
src
|
|
23
|
-
width
|
|
22
|
+
src
|
|
24
23
|
}: ImageLoaderProps): string;
|
|
25
|
-
/**
|
|
26
|
-
* Generate object key
|
|
27
|
-
*/
|
|
28
|
-
declare function getDriveBucketKey(id: string, variant: ImageVariant): string;
|
|
29
|
-
/**
|
|
30
|
-
* Node subtype
|
|
31
|
-
*/
|
|
32
|
-
declare const nodeSubtypes: readonly ["image", "document", "spreadsheet", "video", "audio", "archive", "other"];
|
|
33
|
-
type NodeSubtype = (typeof nodeSubtypes)[number];
|
|
34
|
-
declare function inferNodeSubtype({
|
|
35
|
-
name,
|
|
36
|
-
contentType
|
|
37
|
-
}: Pick<CreateNodeSchema, "name" | "contentType">): NodeSubtype;
|
|
38
24
|
/**
|
|
39
25
|
* Render bytes
|
|
40
26
|
*/
|
|
41
27
|
declare function renderBytes(bytes: number): string;
|
|
42
28
|
//#endregion
|
|
43
|
-
export {
|
|
29
|
+
export { getAssetURL, imageLoader, renderBytes };
|
|
44
30
|
//# sourceMappingURL=helpers.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.mts","names":[],"sources":["../../../../src/modules/storage/lib/helpers.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.d.mts","names":[],"sources":["../../../../src/modules/storage/lib/helpers.ts"],"mappings":";;;;;;AAgBA;;;;;;;;;;iBAAgB,WAAA,CAAY,EAAA,UAAY,OAAA,GAAS,OAAA,CAAQ,gBAAA;;;;iBAYzC,WAAA,CAAA;EAAc;AAAA,GAAO,gBAAA;;;;iBAUrB,WAAA,CAAY,KAAA"}
|
|
@@ -1,86 +1,28 @@
|
|
|
1
1
|
//#region src/modules/storage/lib/helpers.ts
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Builds the public API route URL for a storage file proxy request.
|
|
4
|
+
*
|
|
5
|
+
* Use this helper when you need a stable file URL in the client/UI
|
|
6
|
+
* without manually composing the route path.
|
|
7
|
+
*
|
|
8
|
+
* @param id - Storage asset id
|
|
9
|
+
* @returns File proxy URL for the storage route handler
|
|
10
|
+
* @example
|
|
11
|
+
* const url = getAssetURL("019d0051-2c0d-741e-9e3c-e5a5bc4d16a2", { disposition: "attachment" });
|
|
12
|
+
* // /api/storage/files/019d0051-2c0d-741e-9e3c-e5a5bc4d16a2?disposition=attachment
|
|
4
13
|
*/
|
|
5
|
-
function
|
|
6
|
-
return node.type === "file";
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Check if the node is a folder
|
|
10
|
-
*/
|
|
11
|
-
function isFolder(node) {
|
|
12
|
-
return node.type === "folder";
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Get file url
|
|
16
|
-
*/
|
|
17
|
-
function getFileUrl(id, options = {}) {
|
|
14
|
+
function getAssetURL(id, options = {}) {
|
|
18
15
|
const searchParams = new URLSearchParams();
|
|
19
|
-
searchParams.set("id", id);
|
|
20
|
-
if (options?.variant) searchParams.set("variant", options.variant);
|
|
21
16
|
if (options?.disposition) searchParams.set("disposition", options.disposition);
|
|
22
|
-
|
|
17
|
+
const queryString = searchParams.toString();
|
|
18
|
+
return `/api/storage/files/${id}${queryString ? `?${queryString}` : ""}`;
|
|
23
19
|
}
|
|
24
20
|
/**
|
|
25
21
|
* Image loader
|
|
26
22
|
*/
|
|
27
|
-
function imageLoader({ src
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return url.toString();
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Generate object key
|
|
34
|
-
*/
|
|
35
|
-
function getDriveBucketKey(id, variant) {
|
|
36
|
-
return `storage/${id}/${variant}`;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Node subtype
|
|
40
|
-
*/
|
|
41
|
-
const nodeSubtypes = [
|
|
42
|
-
"image",
|
|
43
|
-
"document",
|
|
44
|
-
"spreadsheet",
|
|
45
|
-
"video",
|
|
46
|
-
"audio",
|
|
47
|
-
"archive",
|
|
48
|
-
"other"
|
|
49
|
-
];
|
|
50
|
-
function inferNodeSubtype({ name, contentType }) {
|
|
51
|
-
if (!contentType) return "other";
|
|
52
|
-
if (contentType?.startsWith("image/")) return "image";
|
|
53
|
-
if (contentType === "application/pdf") return "document";
|
|
54
|
-
if (contentType?.includes("spreadsheet")) return "spreadsheet";
|
|
55
|
-
if (contentType?.startsWith("video/")) return "video";
|
|
56
|
-
if (contentType?.startsWith("audio/")) return "audio";
|
|
57
|
-
if (contentType?.includes("zip") || contentType?.includes("archive")) return "archive";
|
|
58
|
-
const ext = name.split(".").pop()?.toLowerCase();
|
|
59
|
-
if ([
|
|
60
|
-
"jpg",
|
|
61
|
-
"jpeg",
|
|
62
|
-
"png",
|
|
63
|
-
"gif",
|
|
64
|
-
"bmp",
|
|
65
|
-
"webp"
|
|
66
|
-
].includes(ext ?? "")) return "image";
|
|
67
|
-
if ([
|
|
68
|
-
"pdf",
|
|
69
|
-
"doc",
|
|
70
|
-
"docx",
|
|
71
|
-
"txt"
|
|
72
|
-
].includes(ext ?? "")) return "document";
|
|
73
|
-
if ([
|
|
74
|
-
"xls",
|
|
75
|
-
"xlsx",
|
|
76
|
-
"ods"
|
|
77
|
-
].includes(ext ?? "")) return "spreadsheet";
|
|
78
|
-
if ([
|
|
79
|
-
"zip",
|
|
80
|
-
"rar",
|
|
81
|
-
"7z"
|
|
82
|
-
].includes(ext ?? "")) return "archive";
|
|
83
|
-
return "other";
|
|
23
|
+
function imageLoader({ src }) {
|
|
24
|
+
if (typeof window === "undefined") return src;
|
|
25
|
+
return new URL(src, window.location.origin).toString();
|
|
84
26
|
}
|
|
85
27
|
/**
|
|
86
28
|
* Render bytes
|
|
@@ -104,5 +46,5 @@ function renderBytes(bytes) {
|
|
|
104
46
|
}
|
|
105
47
|
|
|
106
48
|
//#endregion
|
|
107
|
-
export {
|
|
49
|
+
export { getAssetURL, imageLoader, renderBytes };
|
|
108
50
|
//# sourceMappingURL=helpers.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.mjs","names":[],"sources":["../../../../src/modules/storage/lib/helpers.ts"],"sourcesContent":["import type { ImageLoaderProps } from \"next/image\";\nimport type {
|
|
1
|
+
{"version":3,"file":"helpers.mjs","names":[],"sources":["../../../../src/modules/storage/lib/helpers.ts"],"sourcesContent":["import type { ImageLoaderProps } from \"next/image\";\nimport type { GetAssetURLInput } from \"../lib/validators\";\n\n/**\n * Builds the public API route URL for a storage file proxy request.\n *\n * Use this helper when you need a stable file URL in the client/UI\n * without manually composing the route path.\n *\n * @param id - Storage asset id\n * @returns File proxy URL for the storage route handler\n * @example\n * const url = getAssetURL(\"019d0051-2c0d-741e-9e3c-e5a5bc4d16a2\", { disposition: \"attachment\" });\n * // /api/storage/files/019d0051-2c0d-741e-9e3c-e5a5bc4d16a2?disposition=attachment\n */\n\nexport function getAssetURL(id: string, options: Partial<GetAssetURLInput> = {}) {\n const searchParams = new URLSearchParams();\n if (options?.disposition) searchParams.set(\"disposition\", options.disposition);\n\n const queryString = searchParams.toString();\n\n return `/api/storage/files/${id}${queryString ? `?${queryString}` : \"\"}`;\n}\n\n/**\n * Image loader\n */\nexport function imageLoader({ src }: ImageLoaderProps) {\n if (typeof window === \"undefined\") return src;\n\n const url = new URL(src, window.location.origin);\n return url.toString();\n}\n\n/**\n * Render bytes\n */\nexport function renderBytes(bytes: number) {\n const units = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\"];\n\n let size = bytes;\n let unitIndex = 0;\n\n while (size >= 1024 && unitIndex < units.length - 1) {\n size /= 1024;\n unitIndex++;\n }\n\n return `${size.toFixed(2)}${units[unitIndex]}`;\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,SAAgB,YAAY,IAAY,UAAqC,EAAE,EAAE;CAC/E,MAAM,eAAe,IAAI,iBAAiB;AAC1C,KAAI,SAAS,YAAa,cAAa,IAAI,eAAe,QAAQ,YAAY;CAE9E,MAAM,cAAc,aAAa,UAAU;AAE3C,QAAO,sBAAsB,KAAK,cAAc,IAAI,gBAAgB;;;;;AAMtE,SAAgB,YAAY,EAAE,OAAyB;AACrD,KAAI,OAAO,WAAW,YAAa,QAAO;AAG1C,QADY,IAAI,IAAI,KAAK,OAAO,SAAS,OAAO,CACrC,UAAU;;;;;AAMvB,SAAgB,YAAY,OAAe;CACzC,MAAM,QAAQ;EAAC;EAAK;EAAM;EAAM;EAAM;EAAM;EAAK;CAEjD,IAAI,OAAO;CACX,IAAI,YAAY;AAEhB,QAAO,QAAQ,QAAQ,YAAY,MAAM,SAAS,GAAG;AACnD,UAAQ;AACR;;AAGF,QAAO,GAAG,KAAK,QAAQ,EAAE,GAAG,MAAM"}
|