@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
|
@@ -5,16 +5,16 @@ import { useDropzone } from "react-dropzone";
|
|
|
5
5
|
import { toast } from "@/components/ui/sonner.client";
|
|
6
6
|
import { useAction } from "@/lib/hooks/use-action";
|
|
7
7
|
import { cn } from "@/lib/utils/cn";
|
|
8
|
-
import type { UploadFileRequest, UploadHooks } from "../lib/
|
|
9
|
-
import type {
|
|
8
|
+
import type { UploadFileRequest, UploadHooks } from "../lib/upload.client";
|
|
9
|
+
import type { StorageAsset, UploadInput } from "../lib/validators";
|
|
10
10
|
import { UploadZoneContext, type UploadZoneContextValue } from "./upload-zone-context.client";
|
|
11
11
|
|
|
12
12
|
export type UploadZoneProps = ComponentProps<"div"> &
|
|
13
13
|
Pick<UploadZoneContextValue, "optimistic" | "uploadClient" | "disabled"> & {
|
|
14
|
-
variables: Pick<
|
|
14
|
+
variables: Pick<UploadInput, "visibility">;
|
|
15
15
|
uploadHooks?: UploadHooks;
|
|
16
16
|
|
|
17
|
-
onUploadCompleted?: (
|
|
17
|
+
onUploadCompleted?: (asset: StorageAsset) => Promise<void> | void;
|
|
18
18
|
onUploadFailed?: (error: unknown) => Promise<void> | void;
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -34,7 +34,9 @@ export function UploadZone({
|
|
|
34
34
|
* Delete mutation
|
|
35
35
|
*/
|
|
36
36
|
const deleteMutation = useAction({
|
|
37
|
-
mutationFn: async (ids: string[]) =>
|
|
37
|
+
mutationFn: async (ids: string[]) => {
|
|
38
|
+
await uploadClient.deleteAssets(ids);
|
|
39
|
+
},
|
|
38
40
|
onMutate: async (ids) => {
|
|
39
41
|
await optimistic?.cancel?.();
|
|
40
42
|
await optimistic?.remove?.(ids);
|
|
@@ -54,30 +56,34 @@ export function UploadZone({
|
|
|
54
56
|
const uploadMutation = useAction({
|
|
55
57
|
mutationFn: async (params: UploadFileRequest) => uploadClient.upload(params, uploadHooks),
|
|
56
58
|
onMutate: async (variables) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
await optimistic?.cancel?.();
|
|
60
|
+
|
|
61
|
+
const newAsset = {
|
|
59
62
|
...variables,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
visibility: variables.visibility ?? "private",
|
|
64
|
+
status: "pending",
|
|
65
|
+
name: variables.file.name,
|
|
66
|
+
size: variables.file.size,
|
|
67
|
+
contentType: variables.file.type || "application/octet-stream",
|
|
68
|
+
etag: null,
|
|
69
|
+
metadata: null,
|
|
70
|
+
uploadedAt: new Date(),
|
|
71
|
+
deletedAt: null,
|
|
72
|
+
} as Omit<StorageAsset, "id" | "key" | "bucket" | "provider" | "createdAt" | "updatedAt">;
|
|
63
73
|
|
|
64
|
-
await optimistic?.
|
|
65
|
-
await optimistic?.add?.(newNode);
|
|
74
|
+
await optimistic?.add?.(newAsset);
|
|
66
75
|
},
|
|
67
76
|
onSuccess: async (data) => {
|
|
68
77
|
await onUploadCompleted?.(data);
|
|
69
78
|
toast.success(`Succesvol geupload: ${data.name}`);
|
|
70
79
|
},
|
|
71
|
-
onError: async (error
|
|
80
|
+
onError: async (error) => {
|
|
72
81
|
await onUploadFailed?.(error);
|
|
73
82
|
|
|
74
83
|
console.error("Upload error: ", error);
|
|
75
84
|
toast.error("Bestand uploaden mislukt", {
|
|
76
85
|
description: error instanceof Error ? error.message : undefined,
|
|
77
86
|
});
|
|
78
|
-
|
|
79
|
-
console.info("Deleting failed upload");
|
|
80
|
-
await deleteMutation.mutateAsync([variables.id]);
|
|
81
87
|
},
|
|
82
88
|
onSettled: () => {
|
|
83
89
|
optimistic?.invalidate?.();
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
export * from "./components/dropzone.client";
|
|
6
6
|
export * from "./components/dropzone-context.client";
|
|
7
|
+
export * from "./components/image.client";
|
|
7
8
|
export * from "./components/image-grid.client";
|
|
9
|
+
export * from "./components/upload-button.client";
|
|
8
10
|
export * from "./components/upload-zone.client";
|
|
9
11
|
export * from "./components/upload-zone-context.client";
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Lib
|
|
13
15
|
*/
|
|
14
|
-
export * from "./lib/
|
|
16
|
+
export * from "./lib/upload.client";
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Lib
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
export * from "./lib/
|
|
6
|
-
export * from "./lib/router.server";
|
|
4
|
+
|
|
5
|
+
export * from "./lib/procedures.server";
|
|
6
|
+
export * from "./lib/router-handlers.server";
|
|
7
|
+
export * from "./lib/service.server";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Providers
|
|
11
|
+
*/
|
|
12
|
+
export * from "./providers/adapters/s3.server";
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Lib
|
|
3
|
+
*/
|
|
4
|
+
|
|
2
5
|
export * from "./lib/constants";
|
|
3
6
|
export * from "./lib/helpers";
|
|
4
7
|
export * from "./lib/schema";
|
|
5
8
|
export * from "./lib/validators";
|
|
9
|
+
export * from "./lib/validators";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Providers
|
|
13
|
+
*/
|
|
14
|
+
export * from "./providers/lib/constants";
|
|
15
|
+
export * from "./providers/lib/errors";
|
|
16
|
+
export * from "./providers/lib/types";
|
|
17
|
+
export * from "./providers/lib/validators";
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
// Device sizes
|
|
2
|
-
export const deviceSizes = [640, 750, 828, 1080, 1200, 1920, 2048, 3840];
|
|
3
|
-
export const imageSizes = deviceSizes;
|
|
4
|
-
|
|
5
|
-
// Image variants
|
|
6
|
-
export const imageVariants = [
|
|
7
|
-
"main",
|
|
8
|
-
...deviceSizes.map((size) => `preview-${size}` as const),
|
|
9
|
-
] as const;
|
|
10
|
-
export type ImageVariant = (typeof imageVariants)[number];
|
|
11
|
-
|
|
12
1
|
// Image dispositions
|
|
13
2
|
export const imageDispositions = ["inline", "attachment"] as const;
|
|
14
3
|
export type ImageDisposition = (typeof imageDispositions)[number];
|
|
@@ -1,85 +1,38 @@
|
|
|
1
1
|
import type { ImageLoaderProps } from "next/image";
|
|
2
|
-
import type {
|
|
3
|
-
import type { CreateNodeSchema, GetFileURLSchema, Node } from "./validators";
|
|
2
|
+
import type { GetAssetURLInput } from "../lib/validators";
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
5
|
+
* Builds the public API route URL for a storage file proxy request.
|
|
6
|
+
*
|
|
7
|
+
* Use this helper when you need a stable file URL in the client/UI
|
|
8
|
+
* without manually composing the route path.
|
|
9
|
+
*
|
|
10
|
+
* @param id - Storage asset id
|
|
11
|
+
* @returns File proxy URL for the storage route handler
|
|
12
|
+
* @example
|
|
13
|
+
* const url = getAssetURL("019d0051-2c0d-741e-9e3c-e5a5bc4d16a2", { disposition: "attachment" });
|
|
14
|
+
* // /api/storage/files/019d0051-2c0d-741e-9e3c-e5a5bc4d16a2?disposition=attachment
|
|
7
15
|
*/
|
|
8
|
-
export function isFile(node: Pick<Node, "type">): node is Node {
|
|
9
|
-
return node.type === "file";
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Check if the node is a folder
|
|
14
|
-
*/
|
|
15
|
-
export function isFolder(node: Pick<Node, "type">): node is Node {
|
|
16
|
-
return node.type === "folder";
|
|
17
|
-
}
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
* Get file url
|
|
21
|
-
*/
|
|
22
|
-
export function getFileUrl(id: string, options: Partial<GetFileURLSchema> = {}) {
|
|
17
|
+
export function getAssetURL(id: string, options: Partial<GetAssetURLInput> = {}) {
|
|
23
18
|
const searchParams = new URLSearchParams();
|
|
24
|
-
searchParams.set("id", id);
|
|
25
|
-
if (options?.variant) searchParams.set("variant", options.variant);
|
|
26
19
|
if (options?.disposition) searchParams.set("disposition", options.disposition);
|
|
27
20
|
|
|
28
|
-
|
|
21
|
+
const queryString = searchParams.toString();
|
|
22
|
+
|
|
23
|
+
return `/api/storage/files/${id}${queryString ? `?${queryString}` : ""}`;
|
|
29
24
|
}
|
|
30
25
|
|
|
31
26
|
/**
|
|
32
27
|
* Image loader
|
|
33
28
|
*/
|
|
34
|
-
export function imageLoader({ src
|
|
29
|
+
export function imageLoader({ src }: ImageLoaderProps) {
|
|
30
|
+
if (typeof window === "undefined") return src;
|
|
31
|
+
|
|
35
32
|
const url = new URL(src, window.location.origin);
|
|
36
|
-
url.searchParams.set("variant", `preview-${width}`);
|
|
37
33
|
return url.toString();
|
|
38
34
|
}
|
|
39
35
|
|
|
40
|
-
/**
|
|
41
|
-
* Generate object key
|
|
42
|
-
*/
|
|
43
|
-
export function getDriveBucketKey(id: string, variant: ImageVariant) {
|
|
44
|
-
return `storage/${id}/${variant}`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Node subtype
|
|
49
|
-
*/
|
|
50
|
-
export const nodeSubtypes = [
|
|
51
|
-
"image",
|
|
52
|
-
"document",
|
|
53
|
-
"spreadsheet",
|
|
54
|
-
"video",
|
|
55
|
-
"audio",
|
|
56
|
-
"archive",
|
|
57
|
-
"other",
|
|
58
|
-
] as const;
|
|
59
|
-
|
|
60
|
-
export type NodeSubtype = (typeof nodeSubtypes)[number];
|
|
61
|
-
|
|
62
|
-
export function inferNodeSubtype({
|
|
63
|
-
name,
|
|
64
|
-
contentType,
|
|
65
|
-
}: Pick<CreateNodeSchema, "name" | "contentType">): NodeSubtype {
|
|
66
|
-
if (!contentType) return "other";
|
|
67
|
-
if (contentType?.startsWith("image/")) return "image";
|
|
68
|
-
if (contentType === "application/pdf") return "document";
|
|
69
|
-
if (contentType?.includes("spreadsheet")) return "spreadsheet";
|
|
70
|
-
if (contentType?.startsWith("video/")) return "video";
|
|
71
|
-
if (contentType?.startsWith("audio/")) return "audio";
|
|
72
|
-
if (contentType?.includes("zip") || contentType?.includes("archive")) return "archive";
|
|
73
|
-
|
|
74
|
-
const ext = name.split(".").pop()?.toLowerCase();
|
|
75
|
-
if (["jpg", "jpeg", "png", "gif", "bmp", "webp"].includes(ext ?? "")) return "image";
|
|
76
|
-
if (["pdf", "doc", "docx", "txt"].includes(ext ?? "")) return "document";
|
|
77
|
-
if (["xls", "xlsx", "ods"].includes(ext ?? "")) return "spreadsheet";
|
|
78
|
-
if (["zip", "rar", "7z"].includes(ext ?? "")) return "archive";
|
|
79
|
-
|
|
80
|
-
return "other";
|
|
81
|
-
}
|
|
82
|
-
|
|
83
36
|
/**
|
|
84
37
|
* Render bytes
|
|
85
38
|
*/
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { InferRouterInputs, InferRouterOutputs } from "@orpc/server";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import type { TDatabaseSchema } from "@/modules/config/db/types";
|
|
4
|
+
import { initRPC } from "@/modules/router/handler/init.server";
|
|
5
|
+
import {
|
|
6
|
+
confirmUploadInputSchema,
|
|
7
|
+
presignUploadInputSchema,
|
|
8
|
+
presignUploadOutputSchema,
|
|
9
|
+
selectStorageAssetSchema,
|
|
10
|
+
} from "./validators";
|
|
11
|
+
|
|
12
|
+
export function createStorageProcedures<TSchema extends TDatabaseSchema>() {
|
|
13
|
+
const { protectedProcedure } = initRPC<TSchema>();
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
presign: protectedProcedure
|
|
17
|
+
.input(presignUploadInputSchema)
|
|
18
|
+
.output(presignUploadOutputSchema)
|
|
19
|
+
.handler(async ({ context, input }) => context.storage.presignUpload(input)),
|
|
20
|
+
|
|
21
|
+
confirm: protectedProcedure
|
|
22
|
+
.input(confirmUploadInputSchema)
|
|
23
|
+
.output(selectStorageAssetSchema)
|
|
24
|
+
.handler(async ({ context, input }) => context.storage.confirmUpload(input)),
|
|
25
|
+
|
|
26
|
+
deleteAsset: protectedProcedure
|
|
27
|
+
.input(z.uuid())
|
|
28
|
+
.output(selectStorageAssetSchema.nullable())
|
|
29
|
+
.handler(async ({ context, input }) => context.storage.deleteAsset(input)),
|
|
30
|
+
|
|
31
|
+
deleteAssets: protectedProcedure
|
|
32
|
+
.input(z.string().array())
|
|
33
|
+
.output(z.array(selectStorageAssetSchema))
|
|
34
|
+
.handler(async ({ context, input }) => context.storage.deleteAssets(input)),
|
|
35
|
+
|
|
36
|
+
restoreAsset: protectedProcedure
|
|
37
|
+
.input(z.uuid())
|
|
38
|
+
.output(selectStorageAssetSchema.nullable())
|
|
39
|
+
.handler(async ({ context, input }) => context.storage.restoreAsset(input)),
|
|
40
|
+
|
|
41
|
+
restoreAssets: protectedProcedure
|
|
42
|
+
.input(z.string().array())
|
|
43
|
+
.output(z.array(selectStorageAssetSchema))
|
|
44
|
+
.handler(async ({ context, input }) => context.storage.restoreAssets(input)),
|
|
45
|
+
|
|
46
|
+
purgeAsset: protectedProcedure
|
|
47
|
+
.input(z.uuid())
|
|
48
|
+
.output(selectStorageAssetSchema.nullable())
|
|
49
|
+
.handler(async ({ context, input }) => context.storage.purgeAsset(input)),
|
|
50
|
+
|
|
51
|
+
purgeAssets: protectedProcedure
|
|
52
|
+
.input(z.string().array())
|
|
53
|
+
.output(z.array(selectStorageAssetSchema))
|
|
54
|
+
.handler(async ({ context, input }) => context.storage.purgeAssets(input)),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type StorageRouter = ReturnType<typeof createStorageProcedures>;
|
|
59
|
+
export type StorageRouterOutputs = InferRouterOutputs<StorageRouter>;
|
|
60
|
+
export type StorageRouterInputs = InferRouterInputs<StorageRouter>;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { connection, type NextRequest } from "next/server";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
import { getSession } from "@/modules/auth/lib/helpers.server";
|
|
4
|
+
import type { TDatabaseSchema } from "@/modules/config/db/types";
|
|
5
|
+
import type { TulipContext } from "@/modules/config/lib/context";
|
|
6
|
+
import { ServerError } from "@/modules/router/lib/error.server";
|
|
7
|
+
import { getAssetURLSchema } from "../entry";
|
|
8
|
+
|
|
9
|
+
type RouteCtx = {
|
|
10
|
+
params: Promise<{ rest?: string[] }>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type CreateStorageRouteHandlerProps<TSchema extends TDatabaseSchema> = {
|
|
14
|
+
context: Pick<TulipContext<TSchema>, "auth" | "storage">;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Creates a catch-all storage route handler for `/api/storage/[[...rest]]`.
|
|
19
|
+
*
|
|
20
|
+
* Current support:
|
|
21
|
+
* - `GET /api/storage/files/:id`:
|
|
22
|
+
* resolves a storage asset, enforces visibility checks, and redirects
|
|
23
|
+
* to a short-lived signed read URL.
|
|
24
|
+
*
|
|
25
|
+
* Reserved for future extension:
|
|
26
|
+
* - `POST /api/storage/assets/presign`
|
|
27
|
+
* - `POST /api/storage/assets/confirm`
|
|
28
|
+
* - additional storage endpoints under the same catch-all route.
|
|
29
|
+
*
|
|
30
|
+
* @param props - Route handler dependencies (application context)
|
|
31
|
+
* @returns Next.js route handlers for GET, POST, PUT, PATCH, and DELETE
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
export function createStorageRouteHandler<TSchema extends TDatabaseSchema>({
|
|
35
|
+
context,
|
|
36
|
+
}: CreateStorageRouteHandlerProps<TSchema>) {
|
|
37
|
+
/**
|
|
38
|
+
* GET /api/storage/[[...rest]]
|
|
39
|
+
*
|
|
40
|
+
* Current route support:
|
|
41
|
+
* - /api/storage/files/:id
|
|
42
|
+
*
|
|
43
|
+
* The file route resolves an asset by id, enforces visibility rules,
|
|
44
|
+
* and redirects to a short-lived signed object URL.
|
|
45
|
+
*/
|
|
46
|
+
async function GET(request: NextRequest, ctx: RouteCtx) {
|
|
47
|
+
// Get the params
|
|
48
|
+
const { rest = [] } = await ctx.params;
|
|
49
|
+
const resource = rest[0];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Proxy file request
|
|
53
|
+
* GET /api/storage/files/:id
|
|
54
|
+
*/
|
|
55
|
+
if (resource === "files") {
|
|
56
|
+
const id = rest[1];
|
|
57
|
+
|
|
58
|
+
// Guard required path segment: /api/storage/files/:id
|
|
59
|
+
if (!id) {
|
|
60
|
+
return Response.json(
|
|
61
|
+
{ error: { code: "BAD_REQUEST", message: "Missing id" } },
|
|
62
|
+
{ status: 400 },
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
console.info("Proxying file: ", id);
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
// Resolve storage asset record by id
|
|
70
|
+
const asset = await context.storage.getAssetById(id);
|
|
71
|
+
|
|
72
|
+
if (!asset) {
|
|
73
|
+
return Response.json(
|
|
74
|
+
{ error: { code: "NOT_FOUND", message: "Asset not found" } },
|
|
75
|
+
{ status: 404 },
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Enforce private visibility with session auth
|
|
80
|
+
if (asset.visibility === "private") {
|
|
81
|
+
const session = await getSession(context);
|
|
82
|
+
if (!session) {
|
|
83
|
+
return Response.json(
|
|
84
|
+
{ error: { code: "UNAUTHORIZED", message: "Unauthorized" } },
|
|
85
|
+
{ status: 401 },
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Handle searchParams for disposition
|
|
91
|
+
const searchParams = request.nextUrl.searchParams;
|
|
92
|
+
const disposition = searchParams.get("disposition") ?? undefined;
|
|
93
|
+
|
|
94
|
+
// Parse the options
|
|
95
|
+
const options = getAssetURLSchema.parse({ disposition });
|
|
96
|
+
|
|
97
|
+
// Resolve signed read URL and redirect to object storage
|
|
98
|
+
const url = await context.storage.getObjectURL(asset.id, options);
|
|
99
|
+
|
|
100
|
+
// Return the file
|
|
101
|
+
return Response.redirect(url, 307);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if (error instanceof z.ZodError) {
|
|
104
|
+
return Response.json(
|
|
105
|
+
{ error: { code: "BAD_REQUEST", message: "Invalid request input" } },
|
|
106
|
+
{ status: 400 },
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (error instanceof ServerError) {
|
|
111
|
+
const code = error.code;
|
|
112
|
+
|
|
113
|
+
if (code === "BAD_REQUEST") {
|
|
114
|
+
return Response.json(
|
|
115
|
+
{ error: { code: "BAD_REQUEST", message: error.message } },
|
|
116
|
+
{ status: 400 },
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (code === "NOT_FOUND") {
|
|
121
|
+
return Response.json(
|
|
122
|
+
{ error: { code: "NOT_FOUND", message: error.message } },
|
|
123
|
+
{ status: 404 },
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (code === "UNAUTHORIZED") {
|
|
128
|
+
return Response.json(
|
|
129
|
+
{ error: { code: "UNAUTHORIZED", message: error.message } },
|
|
130
|
+
{ status: 401 },
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (error instanceof Error && error.message === "Storage asset not found") {
|
|
136
|
+
return Response.json(
|
|
137
|
+
{ error: { code: "NOT_FOUND", message: "Asset not found" } },
|
|
138
|
+
{ status: 404 },
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
console.error("Storage route error", error);
|
|
143
|
+
|
|
144
|
+
return Response.json(
|
|
145
|
+
{ error: { code: "INTERNAL_SERVER_ERROR", message: "Something went wrong" } },
|
|
146
|
+
{ status: 500 },
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return Response.json(
|
|
152
|
+
{ error: { code: "NOT_FOUND", message: "Route not found" } },
|
|
153
|
+
{ status: 404 },
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* POST, PUT, PATCH, DELETE /api/storage/[[...rest]]
|
|
159
|
+
*
|
|
160
|
+
* Reserved for future extension, for example:
|
|
161
|
+
* - POST /api/storage/assets/presign
|
|
162
|
+
* - POST /api/storage/assets/confirm
|
|
163
|
+
*/
|
|
164
|
+
async function POST() {
|
|
165
|
+
// Make endpoint dynamic
|
|
166
|
+
await connection();
|
|
167
|
+
|
|
168
|
+
// future:
|
|
169
|
+
// POST /api/storage/assets/presign
|
|
170
|
+
// POST /api/storage/assets/confirm
|
|
171
|
+
return Response.json(
|
|
172
|
+
{ error: { code: "NOT_FOUND", message: "Route not found" } },
|
|
173
|
+
{ status: 404 },
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return { GET, POST, PUT: POST, PATCH: POST, DELETE: POST };
|
|
178
|
+
}
|
|
@@ -1,105 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { baseColumns } from "@/modules/config/db/helpers";
|
|
5
|
-
import { imageDispositions, imageVariants } from "./constants";
|
|
6
|
-
import { nodeSubtypes } from "./helpers";
|
|
1
|
+
import { index, pgEnum, pgTable, unique } from "drizzle-orm/pg-core";
|
|
2
|
+
import { baseColumns } from "@/modules/database/lib/helpers";
|
|
3
|
+
import { storageProviders } from "../providers/lib/constants";
|
|
7
4
|
|
|
8
|
-
export const
|
|
9
|
-
export const
|
|
5
|
+
export const storageAssetStatusEnum = pgEnum("storage_asset_status", ["pending", "ready", "error"]);
|
|
6
|
+
export const storageAssetVisibilityEnum = pgEnum("storage_asset_visibility", ["private", "public"]);
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
|
-
*
|
|
9
|
+
* Storage objects table
|
|
13
10
|
*/
|
|
14
|
-
export const
|
|
15
|
-
|
|
16
|
-
name: t.text().notNull(),
|
|
17
|
-
namespace: t.text().notNull().default("global"),
|
|
18
|
-
type: nodeTypeEnum(),
|
|
19
|
-
mode: nodeModeEnum().default("private"),
|
|
20
|
-
subtype: t.text({ enum: nodeSubtypes }).notNull().default("other"),
|
|
21
|
-
size: t.integer().default(0),
|
|
22
|
-
contentType: t.varchar({ length: 255 }),
|
|
23
|
-
readonly: boolean().default(false),
|
|
24
|
-
hidden: boolean().default(false),
|
|
25
|
-
createdBy: t.uuid().references(() => users.id, { onDelete: "set null" }),
|
|
26
|
-
isPending: t.boolean().default(false).notNull(),
|
|
27
|
-
isDeleted: t.boolean().default(false).notNull(),
|
|
28
|
-
orphanedAt: t.timestamp(),
|
|
29
|
-
parentId: t.uuid().references((): AnyPgColumn => nodes.id, { onDelete: "cascade" }),
|
|
30
|
-
}));
|
|
31
|
-
|
|
32
|
-
export const nodesRelations = relations(nodes, ({ one, many }) => ({
|
|
33
|
-
parent: one(nodes, {
|
|
34
|
-
fields: [nodes.parentId],
|
|
35
|
-
references: [nodes.id],
|
|
36
|
-
relationName: "parent",
|
|
37
|
-
}),
|
|
38
|
-
children: many(nodes, {
|
|
39
|
-
relationName: "parent",
|
|
40
|
-
}),
|
|
41
|
-
urls: many(nodePresignedUrls),
|
|
42
|
-
variants: many(nodeVariants),
|
|
43
|
-
}));
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Node variants table
|
|
47
|
-
*/
|
|
48
|
-
export const nodeVariants = pgTable("node_variants", (t) => ({
|
|
49
|
-
...baseColumns,
|
|
50
|
-
nodeId: t
|
|
51
|
-
.uuid()
|
|
52
|
-
.notNull()
|
|
53
|
-
.references(() => nodes.id, { onDelete: "cascade" }),
|
|
54
|
-
variant: t.text({ enum: imageVariants }).notNull(),
|
|
55
|
-
width: t.integer().notNull(),
|
|
56
|
-
}));
|
|
57
|
-
|
|
58
|
-
export const nodeVariantsRelations = relations(nodeVariants, ({ one }) => ({
|
|
59
|
-
node: one(nodes, {
|
|
60
|
-
fields: [nodeVariants.nodeId],
|
|
61
|
-
references: [nodes.id],
|
|
62
|
-
relationName: "node",
|
|
63
|
-
}),
|
|
64
|
-
}));
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Node presigned urls table
|
|
68
|
-
*/
|
|
69
|
-
export const nodePresignedUrls = pgTable(
|
|
70
|
-
"node_presigned_urls",
|
|
11
|
+
export const storageAssets = pgTable(
|
|
12
|
+
"storage_assets",
|
|
71
13
|
(t) => ({
|
|
72
14
|
...baseColumns,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
15
|
+
provider: t.text({ enum: storageProviders }).notNull(),
|
|
16
|
+
bucket: t.text().notNull(),
|
|
17
|
+
key: t.text().notNull(),
|
|
18
|
+
status: storageAssetStatusEnum().notNull(),
|
|
19
|
+
visibility: storageAssetVisibilityEnum().notNull().default("private"),
|
|
20
|
+
size: t.integer().default(0),
|
|
21
|
+
contentType: t.varchar({ length: 255 }),
|
|
22
|
+
uploadId: t.uuid().notNull().defaultRandom(),
|
|
23
|
+
name: t.text(),
|
|
24
|
+
metadata: t.jsonb(),
|
|
25
|
+
etag: t.text(),
|
|
26
|
+
uploadedAt: t.timestamp().defaultNow().notNull(),
|
|
27
|
+
deletedAt: t.timestamp(),
|
|
82
28
|
}),
|
|
83
|
-
(t) => [
|
|
29
|
+
(t) => [
|
|
30
|
+
unique("storage_assets_provider_bucket_key_unique").on(t.provider, t.bucket, t.key),
|
|
31
|
+
index("storage_assets_status_idx").on(t.status),
|
|
32
|
+
index("storage_assets_bucket_key_idx").on(t.bucket, t.key),
|
|
33
|
+
],
|
|
84
34
|
);
|
|
85
|
-
|
|
86
|
-
export const nodePresignedUrlsRelations = relations(nodePresignedUrls, ({ one }) => ({
|
|
87
|
-
node: one(nodes, {
|
|
88
|
-
fields: [nodePresignedUrls.nodeId],
|
|
89
|
-
references: [nodes.id],
|
|
90
|
-
relationName: "node",
|
|
91
|
-
}),
|
|
92
|
-
}));
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Drive schema
|
|
96
|
-
**/
|
|
97
|
-
const driveSchema = {
|
|
98
|
-
nodes,
|
|
99
|
-
nodesRelations,
|
|
100
|
-
nodeVariants,
|
|
101
|
-
nodeVariantsRelations,
|
|
102
|
-
nodePresignedUrls,
|
|
103
|
-
nodePresignedUrlsRelations,
|
|
104
|
-
};
|
|
105
|
-
export type DriveSchema = typeof driveSchema;
|