@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.d.mts","names":[],"sources":["../../../../src/modules/storage/lib/validators.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"validators.d.mts","names":[],"sources":["../../../../src/modules/storage/lib/validators.ts"],"mappings":";;;;;;;;;;KASY,YAAA,UAAsB,aAAA,CAAc,YAAA;;AAAhD;;cAKa,4BAAA,EAA4B,GAAA,CAAA,OAAA;;;;KAC7B,sBAAA,GAAyB,GAAA,CAAE,KAAA,QAAa,4BAAA;;;;cAKvC,wBAAA,eAAwB,WAAA;YAAoC,oBAAA,CAAA,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAE7D,uBAAA,GAA0B,GAAA,CAAE,KAAA,QAAa,wBAAA;AAAA,KACzC,wBAAA,GAA2B,GAAA,CAAE,KAAA,QAAa,wBAAA;;;;cAKzC,wBAAA,eAAwB,WAAA;YAAoC,oBAAA,CAAA,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAE7D,uBAAA,GAA0B,GAAA,CAAE,KAAA,QAAa,wBAAA;AAAA,KACzC,wBAAA,GAA2B,GAAA,CAAE,KAAA,QAAa,wBAAA;;;;cAKzC,wBAAA,eAAwB,WAAA;YAAoC,oBAAA,CAAA,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAE7D,wBAAA,GAA2B,GAAA,CAAE,KAAA,QAAa,wBAAA;;;;cAOzC,iBAAA,EAAiB,GAAA,CAAA,SAAA;;;;;;;;;;;cASjB,wBAAA,EAAwB,GAAA,CAAA,SAAA;;;;;;;;;;;cASxB,yBAAA,EAAyB,GAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAIzB,wBAAA,EAAwB,GAAA,CAAA,OAAA;AAAA,KAIzB,WAAA,GAAc,GAAA,CAAE,KAAA,QAAa,iBAAA;AAAA,KAC7B,kBAAA,GAAqB,GAAA,CAAE,KAAA,QAAa,wBAAA;AAAA,KACpC,mBAAA,GAAsB,GAAA,CAAE,KAAA,QAAa,yBAAA;AAAA,KACrC,kBAAA,GAAqB,GAAA,CAAE,KAAA,QAAa,wBAAA;;;;cAKnC,iBAAA,EAAiB,GAAA,CAAA,SAAA;;;;;;KAIlB,gBAAA,GAAmB,GAAA,CAAE,KAAA,QAAa,iBAAA;AAAA,KAClC,iBAAA,GAAoB,GAAA,CAAE,KAAA,QAAa,iBAAA"}
|
|
@@ -1,97 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { nodeModeEnum, nodes } from "./schema.mjs";
|
|
5
|
-
import { nodesTableFilters } from "../config/filters.mjs";
|
|
1
|
+
import { imageDispositions } from "./constants.mjs";
|
|
2
|
+
import { storageAssetVisibilityEnum, storageAssets } from "./schema.mjs";
|
|
3
|
+
import { getObjectOptionsDefaults, objectBodyInputSchema } from "../providers/lib/validators.mjs";
|
|
6
4
|
import { createInsertSchema, createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
7
5
|
import { z as z$1 } from "zod";
|
|
8
6
|
|
|
9
7
|
//#region src/modules/storage/lib/validators.ts
|
|
10
8
|
/**
|
|
11
|
-
*
|
|
9
|
+
* StorageAsset visibility enum
|
|
12
10
|
*/
|
|
13
|
-
const
|
|
11
|
+
const storageAssetVisibilitySchema = z$1.enum(storageAssetVisibilityEnum.enumValues);
|
|
14
12
|
/**
|
|
15
|
-
* Create
|
|
13
|
+
* Create storageAsset
|
|
16
14
|
*/
|
|
17
|
-
const
|
|
15
|
+
const createStorageAssetSchema = createInsertSchema(storageAssets);
|
|
18
16
|
/**
|
|
19
|
-
* Update
|
|
17
|
+
* Update storageAsset
|
|
20
18
|
*/
|
|
21
|
-
const
|
|
19
|
+
const updateStorageAssetSchema = createUpdateSchema(storageAssets);
|
|
22
20
|
/**
|
|
23
|
-
* Select
|
|
21
|
+
* Select storageAsset
|
|
24
22
|
*/
|
|
25
|
-
const
|
|
26
|
-
const
|
|
23
|
+
const selectStorageAssetSchema = createSelectSchema(storageAssets);
|
|
24
|
+
const assetMetadataSchema = z$1.record(z$1.string(), z$1.string()).optional();
|
|
27
25
|
/**
|
|
28
|
-
*
|
|
26
|
+
* Upload schema
|
|
29
27
|
*/
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
orphanedAt: input?.isOrphaned ?? false
|
|
38
|
-
}));
|
|
39
|
-
/**
|
|
40
|
-
* Create folder node
|
|
41
|
-
*/
|
|
42
|
-
const createFolderNodeSchema = createNodeSchema.omit({
|
|
43
|
-
type: true,
|
|
44
|
-
contentType: true,
|
|
45
|
-
size: true,
|
|
46
|
-
subtype: true
|
|
47
|
-
});
|
|
48
|
-
/**
|
|
49
|
-
* Upload file schema
|
|
50
|
-
*/
|
|
51
|
-
const uploadFileSchema = createNodeSchema.omit({ type: true });
|
|
52
|
-
/**
|
|
53
|
-
* Presign file schema
|
|
54
|
-
*/
|
|
55
|
-
const presignFileSchema = uploadFileSchema.extend({ id: z$1.uuid() });
|
|
56
|
-
/**
|
|
57
|
-
* Get file url schema
|
|
58
|
-
*/
|
|
59
|
-
const getFileURLSchemaDefaults = {
|
|
60
|
-
variant: "main",
|
|
61
|
-
disposition: "inline"
|
|
62
|
-
};
|
|
63
|
-
const getFileURLSchema = z$1.object({
|
|
64
|
-
variant: z$1.enum(imageVariants).optional().default(getFileURLSchemaDefaults.variant),
|
|
65
|
-
disposition: z$1.enum(imageDispositions).optional().default(getFileURLSchemaDefaults.disposition)
|
|
28
|
+
const uploadInputSchema = z$1.object({
|
|
29
|
+
name: z$1.string().min(1),
|
|
30
|
+
visibility: storageAssetVisibilitySchema.optional().default("private"),
|
|
31
|
+
size: z$1.number().int().nonnegative().nullable().optional(),
|
|
32
|
+
contentType: z$1.string().nullable().optional(),
|
|
33
|
+
metadata: assetMetadataSchema,
|
|
34
|
+
body: objectBodyInputSchema
|
|
66
35
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}).extend({ filters: nodesTableFiltersSchema });
|
|
75
|
-
/**
|
|
76
|
-
* Get object input
|
|
77
|
-
*/
|
|
78
|
-
const getObjectSchema = z$1.object({
|
|
79
|
-
id: z$1.string(),
|
|
80
|
-
variant: z$1.enum(imageVariants).optional().default(getFileURLSchemaDefaults.variant),
|
|
81
|
-
disposition: z$1.string().optional().default(getFileURLSchemaDefaults.disposition)
|
|
36
|
+
const presignUploadInputSchema = z$1.object({
|
|
37
|
+
uploadId: z$1.uuid().optional(),
|
|
38
|
+
name: z$1.string().min(1),
|
|
39
|
+
visibility: storageAssetVisibilitySchema.optional().default("private"),
|
|
40
|
+
size: z$1.number().int().nonnegative().nullable().optional(),
|
|
41
|
+
contentType: z$1.string().nullable().optional(),
|
|
42
|
+
metadata: assetMetadataSchema
|
|
82
43
|
});
|
|
44
|
+
const presignUploadOutputSchema = selectStorageAssetSchema.extend({ presignedUrl: z$1.string() });
|
|
45
|
+
const confirmUploadInputSchema = z$1.uuid().describe("The upload id of the pending upload to confirm, returned from the presign endpoint");
|
|
83
46
|
/**
|
|
84
|
-
*
|
|
47
|
+
* Get file url schema
|
|
85
48
|
*/
|
|
86
|
-
const
|
|
87
|
-
id: z$1.string(),
|
|
88
|
-
name: z$1.string().optional().default(""),
|
|
89
|
-
variant: z$1.enum(imageVariants).optional().default("main"),
|
|
90
|
-
body: z$1.any().optional(),
|
|
91
|
-
contentType: z$1.string().nullable().optional(),
|
|
92
|
-
size: z$1.number().nullable().optional()
|
|
93
|
-
});
|
|
49
|
+
const getAssetURLSchema = z$1.object({ disposition: z$1.enum(imageDispositions).optional().default(getObjectOptionsDefaults.disposition) });
|
|
94
50
|
|
|
95
51
|
//#endregion
|
|
96
|
-
export {
|
|
52
|
+
export { confirmUploadInputSchema, createStorageAssetSchema, getAssetURLSchema, presignUploadInputSchema, presignUploadOutputSchema, selectStorageAssetSchema, storageAssetVisibilitySchema, updateStorageAssetSchema, uploadInputSchema };
|
|
97
53
|
//# sourceMappingURL=validators.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.mjs","names":["z"],"sources":["../../../../src/modules/storage/lib/validators.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"validators.mjs","names":["z"],"sources":["../../../../src/modules/storage/lib/validators.ts"],"sourcesContent":["import { createInsertSchema, createSelectSchema, createUpdateSchema } from \"drizzle-zod\";\nimport { z } from \"zod\";\nimport { getObjectOptionsDefaults, objectBodyInputSchema } from \"../providers/lib/validators\";\nimport { imageDispositions } from \"./constants\";\nimport { storageAssets, storageAssetVisibilityEnum } from \"./schema\";\n\n/**\n * StorageAssets\n */\nexport type StorageAsset = typeof storageAssets.$inferSelect;\n\n/**\n * StorageAsset visibility enum\n */\nexport const storageAssetVisibilitySchema = z.enum(storageAssetVisibilityEnum.enumValues);\nexport type StorageAssetVisibility = z.infer<typeof storageAssetVisibilitySchema>;\n\n/**\n * Create storageAsset\n */\nexport const createStorageAssetSchema = createInsertSchema(storageAssets);\n\nexport type CreateStorageAssetInput = z.input<typeof createStorageAssetSchema>;\nexport type CreateStorageAssetSchema = z.infer<typeof createStorageAssetSchema>;\n\n/**\n * Update storageAsset\n */\nexport const updateStorageAssetSchema = createUpdateSchema(storageAssets);\n\nexport type UpdateStorageAssetInput = z.input<typeof updateStorageAssetSchema>;\nexport type UpdateStorageAssetSchema = z.infer<typeof updateStorageAssetSchema>;\n\n/**\n * Select storageAsset\n */\nexport const selectStorageAssetSchema = createSelectSchema(storageAssets);\n\nexport type SelectStorageAssetSchema = z.infer<typeof selectStorageAssetSchema>;\n\nconst assetMetadataSchema = z.record(z.string(), z.string()).optional();\n\n/**\n * Upload schema\n */\nexport const uploadInputSchema = z.object({\n name: z.string().min(1),\n visibility: storageAssetVisibilitySchema.optional().default(\"private\"),\n size: z.number().int().nonnegative().nullable().optional(),\n contentType: z.string().nullable().optional(),\n metadata: assetMetadataSchema,\n body: objectBodyInputSchema,\n});\n\nexport const presignUploadInputSchema = z.object({\n uploadId: z.uuid().optional(),\n name: z.string().min(1),\n visibility: storageAssetVisibilitySchema.optional().default(\"private\"),\n size: z.number().int().nonnegative().nullable().optional(),\n contentType: z.string().nullable().optional(),\n metadata: assetMetadataSchema,\n});\n\nexport const presignUploadOutputSchema = selectStorageAssetSchema.extend({\n presignedUrl: z.string(),\n});\n\nexport const confirmUploadInputSchema = z\n .uuid()\n .describe(\"The upload id of the pending upload to confirm, returned from the presign endpoint\");\n\nexport type UploadInput = z.input<typeof uploadInputSchema>;\nexport type PresignUploadInput = z.input<typeof presignUploadInputSchema>;\nexport type PresignUploadOutput = z.infer<typeof presignUploadOutputSchema>;\nexport type ConfirmUploadInput = z.input<typeof confirmUploadInputSchema>;\n\n/**\n * Get file url schema\n */\nexport const getAssetURLSchema = z.object({\n disposition: z.enum(imageDispositions).optional().default(getObjectOptionsDefaults.disposition),\n});\n\nexport type GetAssetURLInput = z.input<typeof getAssetURLSchema>;\nexport type GetAssetURLSchema = z.infer<typeof getAssetURLSchema>;\n"],"mappings":";;;;;;;;;;AAcA,MAAa,+BAA+BA,IAAE,KAAK,2BAA2B,WAAW;;;;AAMzF,MAAa,2BAA2B,mBAAmB,cAAc;;;;AAQzE,MAAa,2BAA2B,mBAAmB,cAAc;;;;AAQzE,MAAa,2BAA2B,mBAAmB,cAAc;AAIzE,MAAM,sBAAsBA,IAAE,OAAOA,IAAE,QAAQ,EAAEA,IAAE,QAAQ,CAAC,CAAC,UAAU;;;;AAKvE,MAAa,oBAAoBA,IAAE,OAAO;CACxC,MAAMA,IAAE,QAAQ,CAAC,IAAI,EAAE;CACvB,YAAY,6BAA6B,UAAU,CAAC,QAAQ,UAAU;CACtE,MAAMA,IAAE,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,UAAU;CAC1D,aAAaA,IAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;CAC7C,UAAU;CACV,MAAM;CACP,CAAC;AAEF,MAAa,2BAA2BA,IAAE,OAAO;CAC/C,UAAUA,IAAE,MAAM,CAAC,UAAU;CAC7B,MAAMA,IAAE,QAAQ,CAAC,IAAI,EAAE;CACvB,YAAY,6BAA6B,UAAU,CAAC,QAAQ,UAAU;CACtE,MAAMA,IAAE,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,UAAU;CAC1D,aAAaA,IAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;CAC7C,UAAU;CACX,CAAC;AAEF,MAAa,4BAA4B,yBAAyB,OAAO,EACvE,cAAcA,IAAE,QAAQ,EACzB,CAAC;AAEF,MAAa,2BAA2BA,IACrC,MAAM,CACN,SAAS,qFAAqF;;;;AAUjG,MAAa,oBAAoBA,IAAE,OAAO,EACxC,aAAaA,IAAE,KAAK,kBAAkB,CAAC,UAAU,CAAC,QAAQ,yBAAyB,YAAY,EAChG,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { StorageAdapter } from "../lib/types.mjs";
|
|
2
|
+
import { S3ClientConfig } from "@aws-sdk/client-s3";
|
|
3
|
+
|
|
4
|
+
//#region src/modules/storage/providers/adapters/s3.server.d.ts
|
|
5
|
+
type StorageS3AdapterConfig = S3ClientConfig & {
|
|
6
|
+
bucketName: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* S3 Storage Adapter
|
|
10
|
+
*
|
|
11
|
+
* This adapter implements the storage service interface using AWS S3 as the backend.
|
|
12
|
+
* It provides methods for uploading, retrieving, and managing files in an S3 bucket.
|
|
13
|
+
*
|
|
14
|
+
* @returns An instance of the S3StorageAdapter class.
|
|
15
|
+
*/
|
|
16
|
+
declare function storageS3Adapter(config: StorageS3AdapterConfig): StorageAdapter;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { StorageS3AdapterConfig, storageS3Adapter };
|
|
19
|
+
//# sourceMappingURL=s3.server.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.server.d.mts","names":[],"sources":["../../../../../src/modules/storage/providers/adapters/s3.server.ts"],"mappings":";;;;KAwCY,sBAAA,GAAyB,cAAA;EACnC,UAAA;AAAA;;;;;AA6OF;;;;iBAAgB,gBAAA,CAAiB,MAAA,EAAQ,sBAAA,GAAyB,cAAA"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { getObjectInputSchema, getObjectOptionsSchema, getObjectOutputSchema, getObjectURLOptionsSchema, headObjectInputSchema, headObjectOutputSchema, putObjectInputSchema, putObjectOutputSchema, putObjectURLInputSchema, putObjectURLOptionsSchema } from "../lib/validators.mjs";
|
|
2
|
+
import { StorageAdapterError } from "../lib/errors.mjs";
|
|
3
|
+
import z from "zod";
|
|
4
|
+
import { Readable } from "node:stream";
|
|
5
|
+
import { DeleteObjectCommand, DeleteObjectsCommand, GetObjectCommand, HeadObjectCommand, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
|
|
6
|
+
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
7
|
+
|
|
8
|
+
//#region src/modules/storage/providers/adapters/s3.server.ts
|
|
9
|
+
/**
|
|
10
|
+
* S3 Storage Adapter
|
|
11
|
+
* This adapter implements the storage service interface using AWS S3 as the backend.
|
|
12
|
+
* It provides methods for uploading, retrieving, and managing files in an S3 bucket.
|
|
13
|
+
*/
|
|
14
|
+
var StorageS3Adapter = class {
|
|
15
|
+
/**
|
|
16
|
+
* S3 Client
|
|
17
|
+
*/
|
|
18
|
+
key = "s3";
|
|
19
|
+
client;
|
|
20
|
+
bucketName;
|
|
21
|
+
/**
|
|
22
|
+
* Constructor
|
|
23
|
+
*/
|
|
24
|
+
constructor({ bucketName, ...config }) {
|
|
25
|
+
this.client = new S3Client(config);
|
|
26
|
+
this.bucketName = bucketName;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create get command
|
|
30
|
+
*/
|
|
31
|
+
#createGetCommand(input, options = {}) {
|
|
32
|
+
const key = getObjectInputSchema.parse(input);
|
|
33
|
+
const { disposition } = getObjectOptionsSchema.parse(options);
|
|
34
|
+
return new GetObjectCommand({
|
|
35
|
+
Bucket: this.bucketName,
|
|
36
|
+
Key: key,
|
|
37
|
+
ResponseContentDisposition: disposition
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get object
|
|
42
|
+
*/
|
|
43
|
+
async getObject(input, options = {}) {
|
|
44
|
+
const getCommand = this.#createGetCommand(input, options);
|
|
45
|
+
const result = await this.client.send(getCommand);
|
|
46
|
+
if (result.Body == null) throw new StorageAdapterError("OBJECT_NOT_READABLE", "Object body is missing", { cause: /* @__PURE__ */ new Error(`ContentLength: ${result.ContentLength}, ContentType: ${result.ContentType}, Body: ${result.Body}`) });
|
|
47
|
+
return getObjectOutputSchema.parse({
|
|
48
|
+
contentType: result.ContentType,
|
|
49
|
+
size: result.ContentLength,
|
|
50
|
+
metadata: result.Metadata,
|
|
51
|
+
body: this.#toReadable(result.Body)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get object URL
|
|
56
|
+
*/
|
|
57
|
+
async getObjectURL(input, options = {}) {
|
|
58
|
+
const { expiresIn } = getObjectURLOptionsSchema.parse(options);
|
|
59
|
+
const getCommand = this.#createGetCommand(input, options);
|
|
60
|
+
return await getSignedUrl(this.client, getCommand, { expiresIn });
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Create head command
|
|
64
|
+
*/
|
|
65
|
+
#createHeadCommand(input) {
|
|
66
|
+
const { key } = headObjectInputSchema.parse(input);
|
|
67
|
+
return new HeadObjectCommand({
|
|
68
|
+
Bucket: this.bucketName,
|
|
69
|
+
Key: key
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Head object
|
|
74
|
+
*/
|
|
75
|
+
async headObject(input) {
|
|
76
|
+
const headCommand = this.#createHeadCommand(input);
|
|
77
|
+
const result = await this.client.send(headCommand);
|
|
78
|
+
if (result.ContentLength == null || result.ContentType == null) throw new StorageAdapterError("OBJECT_NOT_FOUND", "Object metadata could not be resolved", { cause: /* @__PURE__ */ new Error(`ContentLength: ${result.ContentLength}, ContentType: ${result.ContentType}`) });
|
|
79
|
+
return headObjectOutputSchema.parse({
|
|
80
|
+
contentType: result.ContentType,
|
|
81
|
+
size: result.ContentLength,
|
|
82
|
+
metadata: result.Metadata
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Create put command
|
|
87
|
+
*/
|
|
88
|
+
#createPutCommand(data) {
|
|
89
|
+
return new PutObjectCommand({
|
|
90
|
+
Bucket: this.bucketName,
|
|
91
|
+
Key: data.key,
|
|
92
|
+
Body: "body" in data ? data.body : void 0,
|
|
93
|
+
ContentType: data.contentType ?? void 0,
|
|
94
|
+
ContentLength: data.size ?? void 0,
|
|
95
|
+
Metadata: data.metadata ?? void 0
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Put object
|
|
100
|
+
*/
|
|
101
|
+
async putObject(input) {
|
|
102
|
+
const data = putObjectInputSchema.parse(input);
|
|
103
|
+
const putCommand = this.#createPutCommand(data);
|
|
104
|
+
const result = await this.client.send(putCommand);
|
|
105
|
+
return putObjectOutputSchema.parse({ size: result.Size });
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get signed URL
|
|
109
|
+
*/
|
|
110
|
+
async putObjectURL(input, options = {}) {
|
|
111
|
+
const { expiresIn } = putObjectURLOptionsSchema.parse(options);
|
|
112
|
+
const data = putObjectURLInputSchema.parse(input);
|
|
113
|
+
const putCommand = this.#createPutCommand(data);
|
|
114
|
+
return await getSignedUrl(this.client, putCommand, { expiresIn });
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Delete object
|
|
118
|
+
*/
|
|
119
|
+
async deleteObject(input) {
|
|
120
|
+
const key = z.string().parse(input);
|
|
121
|
+
const deleteCommand = new DeleteObjectCommand({
|
|
122
|
+
Bucket: this.bucketName,
|
|
123
|
+
Key: key
|
|
124
|
+
});
|
|
125
|
+
const response = await this.client.send(deleteCommand);
|
|
126
|
+
if (response.DeleteMarker !== true && response.VersionId) throw new StorageAdapterError("OBJECT_DELETE_FAILED", "Failed to delete object", { cause: /* @__PURE__ */ new Error(`DeleteMarker: ${response.DeleteMarker}, VersionId: ${response.VersionId}`) });
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Delete multiple objects
|
|
130
|
+
*/
|
|
131
|
+
async deleteObjects(input) {
|
|
132
|
+
const keys = z.array(z.string()).parse(input);
|
|
133
|
+
const deleteCommand = new DeleteObjectsCommand({
|
|
134
|
+
Bucket: this.bucketName,
|
|
135
|
+
Delete: { Objects: keys.map((Key) => ({ Key })) }
|
|
136
|
+
});
|
|
137
|
+
const response = await this.client.send(deleteCommand);
|
|
138
|
+
if (response.Errors && response.Errors.length > 0) throw new StorageAdapterError("OBJECT_DELETE_FAILED", "Failed to delete objects", { cause: new Error(JSON.stringify(response.Errors)) });
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Transform the GetObjectCommandOutput Body into a normalized Readable stream
|
|
142
|
+
* S3 can return the Body in different formats depending on the environment and AWS SDK version:
|
|
143
|
+
* - In Node.js, it may return a Readable stream.
|
|
144
|
+
* - In newer AWS SDK versions in Node 18+, it may return a web ReadableStream with transformToWebStream method.
|
|
145
|
+
* - In older AWS SDK versions in Node 16, it may return a web ReadableStream without transformToWebStream.
|
|
146
|
+
* - It may also return a string, Buffer, or Uint8Array for small objects.
|
|
147
|
+
*
|
|
148
|
+
* This method normalizes all these cases into a Node.js Readable stream for consistent handling in the application.
|
|
149
|
+
*/
|
|
150
|
+
#toReadable(body) {
|
|
151
|
+
if (!body) throw new StorageAdapterError("OBJECT_NOT_READABLE", "S3 object body is empty");
|
|
152
|
+
if (body instanceof Readable) return body;
|
|
153
|
+
if (typeof body.transformToWebStream === "function") return Readable.fromWeb(body.transformToWebStream());
|
|
154
|
+
if (typeof body.getReader === "function") return Readable.fromWeb(body);
|
|
155
|
+
if (typeof body === "string" || body instanceof Uint8Array || Buffer.isBuffer(body)) return Readable.from([body]);
|
|
156
|
+
throw new StorageAdapterError("UNSUPPORTED_BODY_TYPE", "Unsupported object body type");
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* S3 Storage Adapter
|
|
161
|
+
*
|
|
162
|
+
* This adapter implements the storage service interface using AWS S3 as the backend.
|
|
163
|
+
* It provides methods for uploading, retrieving, and managing files in an S3 bucket.
|
|
164
|
+
*
|
|
165
|
+
* @returns An instance of the S3StorageAdapter class.
|
|
166
|
+
*/
|
|
167
|
+
function storageS3Adapter(config) {
|
|
168
|
+
return new StorageS3Adapter(config);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
//#endregion
|
|
172
|
+
export { storageS3Adapter };
|
|
173
|
+
//# sourceMappingURL=s3.server.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.server.mjs","names":["#createGetCommand","#toReadable","#createHeadCommand","#createPutCommand"],"sources":["../../../../../src/modules/storage/providers/adapters/s3.server.ts"],"sourcesContent":["import { Readable } from \"node:stream\";\nimport type { ReadableStream } from \"node:stream/web\";\nimport {\n DeleteObjectCommand,\n DeleteObjectsCommand,\n GetObjectCommand,\n type GetObjectCommandOutput,\n HeadObjectCommand,\n PutObjectCommand,\n S3Client,\n type S3ClientConfig,\n} from \"@aws-sdk/client-s3\";\nimport { getSignedUrl } from \"@aws-sdk/s3-request-presigner\";\nimport z from \"zod\";\nimport type { StorageProvider } from \"../lib/constants\";\nimport { StorageAdapterError } from \"../lib/errors\";\nimport type { StorageAdapter } from \"../lib/types\";\nimport {\n type GetObjectInput,\n type GetObjectOptions,\n type GetObjectOutput,\n type GetObjectURLOptions,\n getObjectInputSchema,\n getObjectOptionsSchema,\n getObjectOutputSchema,\n getObjectURLOptionsSchema,\n type HeadObjectInput,\n type HeadObjectOutput,\n headObjectInputSchema,\n headObjectOutputSchema,\n type PutObjectInput,\n type PutObjectOutput,\n type PutObjectURLInput,\n type PutObjectURLOptions,\n putObjectInputSchema,\n putObjectOutputSchema,\n putObjectURLInputSchema,\n putObjectURLOptionsSchema,\n} from \"../lib/validators\";\n\nexport type StorageS3AdapterConfig = S3ClientConfig & {\n bucketName: string;\n};\n\n/**\n * S3 Storage Adapter\n * This adapter implements the storage service interface using AWS S3 as the backend.\n * It provides methods for uploading, retrieving, and managing files in an S3 bucket.\n */\nclass StorageS3Adapter implements StorageAdapter {\n /**\n * S3 Client\n */\n key: StorageProvider = \"s3\";\n client: S3Client;\n bucketName: string;\n\n /**\n * Constructor\n */\n constructor({ bucketName, ...config }: StorageS3AdapterConfig) {\n this.client = new S3Client(config);\n this.bucketName = bucketName;\n }\n\n /**\n * Create get command\n */\n #createGetCommand(input: GetObjectInput, options: GetObjectOptions = {}) {\n const key = getObjectInputSchema.parse(input);\n const { disposition } = getObjectOptionsSchema.parse(options);\n\n return new GetObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n ResponseContentDisposition: disposition,\n });\n }\n\n /**\n * Get object\n */\n async getObject(input: GetObjectInput, options: GetObjectOptions = {}): Promise<GetObjectOutput> {\n const getCommand = this.#createGetCommand(input, options);\n\n const result = await this.client.send(getCommand);\n\n if (result.Body == null) {\n throw new StorageAdapterError(\"OBJECT_NOT_READABLE\", \"Object body is missing\", {\n cause: new Error(\n `ContentLength: ${result.ContentLength}, ContentType: ${result.ContentType}, Body: ${result.Body}`,\n ),\n });\n }\n\n return getObjectOutputSchema.parse({\n contentType: result.ContentType,\n size: result.ContentLength,\n metadata: result.Metadata,\n body: this.#toReadable(result.Body),\n });\n }\n\n /**\n * Get object URL\n */\n async getObjectURL(input: GetObjectInput, options: GetObjectURLOptions = {}) {\n const { expiresIn } = getObjectURLOptionsSchema.parse(options);\n\n // Validate input and create get command\n const getCommand = this.#createGetCommand(input, options);\n\n // Generate the presigned url\n return await getSignedUrl(this.client, getCommand, { expiresIn });\n }\n\n /**\n * Create head command\n */\n #createHeadCommand(input: HeadObjectInput) {\n const { key } = headObjectInputSchema.parse(input);\n\n return new HeadObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n }\n\n /**\n * Head object\n */\n async headObject(input: HeadObjectInput): Promise<HeadObjectOutput> {\n const headCommand = this.#createHeadCommand(input);\n\n const result = await this.client.send(headCommand);\n\n if (result.ContentLength == null || result.ContentType == null) {\n throw new StorageAdapterError(\"OBJECT_NOT_FOUND\", \"Object metadata could not be resolved\", {\n cause: new Error(\n `ContentLength: ${result.ContentLength}, ContentType: ${result.ContentType}`,\n ),\n });\n }\n\n return headObjectOutputSchema.parse({\n contentType: result.ContentType,\n size: result.ContentLength,\n metadata: result.Metadata,\n });\n }\n\n /**\n * Create put command\n */\n #createPutCommand(\n data: z.infer<typeof putObjectInputSchema> | z.infer<typeof putObjectURLInputSchema>,\n ) {\n return new PutObjectCommand({\n Bucket: this.bucketName,\n Key: data.key,\n Body: \"body\" in data ? data.body : undefined,\n ContentType: data.contentType ?? undefined,\n ContentLength: data.size ?? undefined,\n Metadata: data.metadata ?? undefined,\n });\n }\n\n /**\n * Put object\n */\n async putObject(input: PutObjectInput): Promise<PutObjectOutput> {\n const data = putObjectInputSchema.parse(input);\n const putCommand = this.#createPutCommand(data);\n\n const result = await this.client.send(putCommand);\n\n return putObjectOutputSchema.parse({ size: result.Size });\n }\n\n /**\n * Get signed URL\n */\n async putObjectURL(input: PutObjectURLInput, options: PutObjectURLOptions = {}) {\n const { expiresIn } = putObjectURLOptionsSchema.parse(options);\n\n // Validate input and create put command\n const data = putObjectURLInputSchema.parse(input);\n const putCommand = this.#createPutCommand(data);\n\n // Generate the presigned url\n return await getSignedUrl(this.client, putCommand, { expiresIn });\n }\n\n /**\n * Delete object\n */\n async deleteObject(input: string): Promise<void> {\n const key = z.string().parse(input);\n\n const deleteCommand = new DeleteObjectCommand({\n Bucket: this.bucketName,\n Key: key,\n });\n\n const response = await this.client.send(deleteCommand);\n\n if (response.DeleteMarker !== true && response.VersionId) {\n throw new StorageAdapterError(\"OBJECT_DELETE_FAILED\", \"Failed to delete object\", {\n cause: new Error(\n `DeleteMarker: ${response.DeleteMarker}, VersionId: ${response.VersionId}`,\n ),\n });\n }\n }\n\n /**\n * Delete multiple objects\n */\n async deleteObjects(input: string[]): Promise<void> {\n const keys = z.array(z.string()).parse(input);\n\n const deleteCommand = new DeleteObjectsCommand({\n Bucket: this.bucketName,\n Delete: { Objects: keys.map((Key) => ({ Key })) },\n });\n\n const response = await this.client.send(deleteCommand);\n\n if (response.Errors && response.Errors.length > 0) {\n throw new StorageAdapterError(\"OBJECT_DELETE_FAILED\", \"Failed to delete objects\", {\n cause: new Error(JSON.stringify(response.Errors)),\n });\n }\n }\n\n /**\n * Transform the GetObjectCommandOutput Body into a normalized Readable stream\n * S3 can return the Body in different formats depending on the environment and AWS SDK version:\n * - In Node.js, it may return a Readable stream.\n * - In newer AWS SDK versions in Node 18+, it may return a web ReadableStream with transformToWebStream method.\n * - In older AWS SDK versions in Node 16, it may return a web ReadableStream without transformToWebStream.\n * - It may also return a string, Buffer, or Uint8Array for small objects.\n *\n * This method normalizes all these cases into a Node.js Readable stream for consistent handling in the application.\n */\n #toReadable(body: GetObjectCommandOutput[\"Body\"]): Readable {\n if (!body) throw new StorageAdapterError(\"OBJECT_NOT_READABLE\", \"S3 object body is empty\");\n\n // If it's already a Node Readable, return as is\n if (body instanceof Readable) return body;\n\n if (typeof body.transformToWebStream === \"function\") {\n // biome-ignore lint/suspicious/noExplicitAny: The AWS SDK v3 in Node 18+ returns a web ReadableStream with a transformToWebStream method, but the types don't reflect this correctly, so we need to use 'any' here.\n return Readable.fromWeb((body as any).transformToWebStream());\n }\n\n // biome-ignore lint/suspicious/noExplicitAny: The AWS SDK v3 in Node 16 returns a web ReadableStream without a transformToWebStream method, but the types don't reflect this correctly, so we need to use 'any' here.\n if (typeof (body as any).getReader === \"function\") {\n return Readable.fromWeb(body as unknown as ReadableStream);\n }\n\n // If it's a string, Buffer, or Uint8Array, convert to Readable\n if (typeof body === \"string\" || body instanceof Uint8Array || Buffer.isBuffer(body)) {\n return Readable.from([body]);\n }\n\n throw new StorageAdapterError(\"UNSUPPORTED_BODY_TYPE\", \"Unsupported object body type\");\n }\n}\n\n/**\n * S3 Storage Adapter\n *\n * This adapter implements the storage service interface using AWS S3 as the backend.\n * It provides methods for uploading, retrieving, and managing files in an S3 bucket.\n *\n * @returns An instance of the S3StorageAdapter class.\n */\nexport function storageS3Adapter(config: StorageS3AdapterConfig): StorageAdapter {\n return new StorageS3Adapter(config);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/modules/storage/providers/lib/constants.d.ts
|
|
2
|
+
declare const storageProviders: readonly ["s3"];
|
|
3
|
+
type StorageProvider = (typeof storageProviders)[number];
|
|
4
|
+
//#endregion
|
|
5
|
+
export { StorageProvider, storageProviders };
|
|
6
|
+
//# sourceMappingURL=constants.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.mts","names":[],"sources":["../../../../../src/modules/storage/providers/lib/constants.ts"],"mappings":";cACa,gBAAA;AAAA,KACD,eAAA,WAA0B,gBAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../../../../../src/modules/storage/providers/lib/constants.ts"],"sourcesContent":["// Storage providers\nexport const storageProviders = [\"s3\"] as const;\nexport type StorageProvider = (typeof storageProviders)[number];\n"],"mappings":";AACA,MAAa,mBAAmB,CAAC,KAAK"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/modules/storage/providers/lib/errors.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Storage adapter error codes and class
|
|
4
|
+
*/
|
|
5
|
+
type StorageAdapterErrorCode = "OBJECT_NOT_FOUND" | "OBJECT_NOT_READABLE" | "OBJECT_DELETE_FAILED" | "OBJECT_HEAD_FAILED" | "OBJECT_UPLOAD_FAILED" | "OBJECT_URL_FAILED" | "UNSUPPORTED_BODY_TYPE";
|
|
6
|
+
declare class StorageAdapterError extends Error {
|
|
7
|
+
code: StorageAdapterErrorCode;
|
|
8
|
+
constructor(code: StorageAdapterErrorCode, message: string, options?: ErrorOptions);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { StorageAdapterError, StorageAdapterErrorCode };
|
|
12
|
+
//# sourceMappingURL=errors.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.mts","names":[],"sources":["../../../../../src/modules/storage/providers/lib/errors.ts"],"mappings":";;AAGA;;KAAY,uBAAA;AAAA,cASC,mBAAA,SAA4B,KAAA;EACvC,IAAA,EAAM,uBAAA;cAEM,IAAA,EAAM,uBAAA,EAAyB,OAAA,UAAiB,OAAA,GAAU,YAAA;AAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/modules/storage/providers/lib/errors.ts
|
|
2
|
+
var StorageAdapterError = class extends Error {
|
|
3
|
+
code;
|
|
4
|
+
constructor(code, message, options) {
|
|
5
|
+
super(message, options);
|
|
6
|
+
this.name = "StorageError";
|
|
7
|
+
this.code = code;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { StorageAdapterError };
|
|
13
|
+
//# sourceMappingURL=errors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.mjs","names":[],"sources":["../../../../../src/modules/storage/providers/lib/errors.ts"],"sourcesContent":["/**\n * Storage adapter error codes and class\n */\nexport type StorageAdapterErrorCode =\n | \"OBJECT_NOT_FOUND\"\n | \"OBJECT_NOT_READABLE\"\n | \"OBJECT_DELETE_FAILED\"\n | \"OBJECT_HEAD_FAILED\"\n | \"OBJECT_UPLOAD_FAILED\"\n | \"OBJECT_URL_FAILED\"\n | \"UNSUPPORTED_BODY_TYPE\";\n\nexport class StorageAdapterError extends Error {\n code: StorageAdapterErrorCode;\n\n constructor(code: StorageAdapterErrorCode, message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = \"StorageError\";\n this.code = code;\n }\n}\n"],"mappings":";AAYA,IAAa,sBAAb,cAAyC,MAAM;CAC7C;CAEA,YAAY,MAA+B,SAAiB,SAAwB;AAClF,QAAM,SAAS,QAAQ;AACvB,OAAK,OAAO;AACZ,OAAK,OAAO"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { StorageProvider } from "./constants.mjs";
|
|
2
|
+
import { GetObjectInput, GetObjectOptions, GetObjectOutput, GetObjectURLOptions, HeadObjectInput, HeadObjectOutput, PutObjectInput, PutObjectOutput, PutObjectURLInput, PutObjectURLOptions } from "./validators.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/modules/storage/providers/lib/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Storage adapter interface
|
|
7
|
+
*/
|
|
8
|
+
interface StorageAdapter {
|
|
9
|
+
key: StorageProvider;
|
|
10
|
+
bucketName: string;
|
|
11
|
+
getObject: (input: GetObjectInput, options?: GetObjectOptions) => Promise<GetObjectOutput>;
|
|
12
|
+
getObjectURL: (input: GetObjectInput, options?: GetObjectURLOptions) => Promise<string>;
|
|
13
|
+
headObject: (input: HeadObjectInput) => Promise<HeadObjectOutput>;
|
|
14
|
+
putObject: (props: PutObjectInput) => Promise<PutObjectOutput>;
|
|
15
|
+
putObjectURL: (props: PutObjectURLInput, options?: PutObjectURLOptions) => Promise<string>;
|
|
16
|
+
deleteObject: (key: string) => Promise<void>;
|
|
17
|
+
deleteObjects: (keys: string[]) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { StorageAdapter };
|
|
21
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../../../src/modules/storage/providers/lib/types.ts"],"mappings":";;;;;;AAiBA;UAAiB,cAAA;EACf,GAAA,EAAK,eAAA;EACL,UAAA;EACA,SAAA,GAAY,KAAA,EAAO,cAAA,EAAgB,OAAA,GAAU,gBAAA,KAAqB,OAAA,CAAQ,eAAA;EAC1E,YAAA,GAAe,KAAA,EAAO,cAAA,EAAgB,OAAA,GAAU,mBAAA,KAAwB,OAAA;EACxE,UAAA,GAAa,KAAA,EAAO,eAAA,KAAoB,OAAA,CAAQ,gBAAA;EAChD,SAAA,GAAY,KAAA,EAAO,cAAA,KAAmB,OAAA,CAAQ,eAAA;EAC9C,YAAA,GAAe,KAAA,EAAO,iBAAA,EAAmB,OAAA,GAAU,mBAAA,KAAwB,OAAA;EAC3E,YAAA,GAAe,GAAA,aAAgB,OAAA;EAC/B,aAAA,GAAgB,IAAA,eAAmB,OAAA;AAAA"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { z as z$1 } from "zod";
|
|
2
|
+
import { Readable } from "node:stream";
|
|
3
|
+
|
|
4
|
+
//#region src/modules/storage/providers/lib/validators.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Object body schema
|
|
7
|
+
*/
|
|
8
|
+
declare const objectBodyInputSchema: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z$1.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z$1.ZodCustom<Readable, Readable>]>;
|
|
9
|
+
type ObjectBodyInput = z$1.infer<typeof objectBodyInputSchema>;
|
|
10
|
+
/**
|
|
11
|
+
* Object body output schema (normalized)
|
|
12
|
+
*/
|
|
13
|
+
declare const objectBodyOutputSchema: z$1.ZodCustom<Readable, Readable>;
|
|
14
|
+
type ObjectBodyOutput = z$1.infer<typeof objectBodyOutputSchema>;
|
|
15
|
+
/**
|
|
16
|
+
* Object schema
|
|
17
|
+
*/
|
|
18
|
+
declare const objectSchema: z$1.ZodObject<{
|
|
19
|
+
contentType: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
20
|
+
size: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
21
|
+
metadata: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
22
|
+
}, z$1.core.$strip>;
|
|
23
|
+
type ObjectSchema = z$1.infer<typeof objectSchema>;
|
|
24
|
+
/**
|
|
25
|
+
* Get object input
|
|
26
|
+
*/
|
|
27
|
+
declare const getObjectInputSchema: z$1.ZodString;
|
|
28
|
+
type GetObjectInput = z$1.input<typeof getObjectInputSchema>;
|
|
29
|
+
/**
|
|
30
|
+
* Get object options schema
|
|
31
|
+
*/
|
|
32
|
+
declare const getObjectOptionsDefaults: {
|
|
33
|
+
readonly disposition: "inline";
|
|
34
|
+
};
|
|
35
|
+
declare const getObjectOptionsSchema: z$1.ZodObject<{
|
|
36
|
+
disposition: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodString>>;
|
|
37
|
+
}, z$1.core.$strip>;
|
|
38
|
+
type GetObjectOptions = z$1.input<typeof getObjectOptionsSchema>;
|
|
39
|
+
/**
|
|
40
|
+
* Get object URL input
|
|
41
|
+
*/
|
|
42
|
+
declare const getObjectURLOptionsSchema: z$1.ZodObject<{
|
|
43
|
+
disposition: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodString>>;
|
|
44
|
+
expiresIn: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
|
|
45
|
+
}, z$1.core.$strip>;
|
|
46
|
+
type GetObjectURLOptions = z$1.input<typeof getObjectURLOptionsSchema>;
|
|
47
|
+
/**
|
|
48
|
+
* Get object output
|
|
49
|
+
*/
|
|
50
|
+
declare const getObjectOutputSchema: z$1.ZodObject<{
|
|
51
|
+
contentType: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
52
|
+
size: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
53
|
+
metadata: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
54
|
+
body: z$1.ZodCustom<Readable, Readable>;
|
|
55
|
+
}, z$1.core.$strip>;
|
|
56
|
+
type GetObjectOutput = z$1.infer<typeof getObjectOutputSchema>;
|
|
57
|
+
/**
|
|
58
|
+
* Get object head input
|
|
59
|
+
*/
|
|
60
|
+
declare const headObjectInputSchema: z$1.ZodObject<{
|
|
61
|
+
key: z$1.ZodString;
|
|
62
|
+
}, z$1.core.$strip>;
|
|
63
|
+
type HeadObjectInput = z$1.input<typeof headObjectInputSchema>;
|
|
64
|
+
/**
|
|
65
|
+
* Head object output
|
|
66
|
+
*/
|
|
67
|
+
declare const headObjectOutputSchema: z$1.ZodObject<{
|
|
68
|
+
contentType: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
69
|
+
size: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
70
|
+
metadata: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
71
|
+
}, z$1.core.$strip>;
|
|
72
|
+
type HeadObjectOutput = z$1.infer<typeof headObjectOutputSchema>;
|
|
73
|
+
/**
|
|
74
|
+
* Put object URL input
|
|
75
|
+
*/
|
|
76
|
+
declare const putObjectURLInputSchema: z$1.ZodObject<{
|
|
77
|
+
key: z$1.ZodString;
|
|
78
|
+
contentType: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
79
|
+
size: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
80
|
+
metadata: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
81
|
+
}, z$1.core.$strip>;
|
|
82
|
+
type PutObjectURLInput = z$1.input<typeof putObjectURLInputSchema>;
|
|
83
|
+
/**
|
|
84
|
+
* Put object URL input
|
|
85
|
+
*/
|
|
86
|
+
declare const putObjectURLOptionsSchema: z$1.ZodObject<{
|
|
87
|
+
expiresIn: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
|
|
88
|
+
}, z$1.core.$strip>;
|
|
89
|
+
type PutObjectURLOptions = z$1.input<typeof putObjectURLOptionsSchema>;
|
|
90
|
+
/**
|
|
91
|
+
* Put object input
|
|
92
|
+
*/
|
|
93
|
+
declare const putObjectInputSchema: z$1.ZodObject<{
|
|
94
|
+
key: z$1.ZodString;
|
|
95
|
+
contentType: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
96
|
+
size: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
97
|
+
metadata: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
98
|
+
body: z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z$1.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>, z$1.ZodCustom<Readable, Readable>]>;
|
|
99
|
+
}, z$1.core.$strip>;
|
|
100
|
+
type PutObjectInput = z$1.input<typeof putObjectInputSchema>;
|
|
101
|
+
/**
|
|
102
|
+
* Put object schema
|
|
103
|
+
*/
|
|
104
|
+
declare const putObjectOutputSchema: z$1.ZodObject<{
|
|
105
|
+
contentType: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>;
|
|
106
|
+
size: z$1.ZodOptional<z$1.ZodNullable<z$1.ZodNumber>>;
|
|
107
|
+
metadata: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
108
|
+
}, z$1.core.$strip>;
|
|
109
|
+
type PutObjectOutput = z$1.infer<typeof putObjectOutputSchema>;
|
|
110
|
+
//#endregion
|
|
111
|
+
export { GetObjectInput, GetObjectOptions, GetObjectOutput, GetObjectURLOptions, HeadObjectInput, HeadObjectOutput, ObjectBodyInput, ObjectBodyOutput, ObjectSchema, PutObjectInput, PutObjectOutput, PutObjectURLInput, PutObjectURLOptions, getObjectInputSchema, getObjectOptionsDefaults, getObjectOptionsSchema, getObjectOutputSchema, getObjectURLOptionsSchema, headObjectInputSchema, headObjectOutputSchema, objectBodyInputSchema, objectBodyOutputSchema, objectSchema, putObjectInputSchema, putObjectOutputSchema, putObjectURLInputSchema, putObjectURLOptionsSchema };
|
|
112
|
+
//# sourceMappingURL=validators.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.mts","names":[],"sources":["../../../../../src/modules/storage/providers/lib/validators.ts"],"mappings":";;;;;;AAMA;cAAa,qBAAA,EAAqB,GAAA,CAAA,QAAA,WAAA,GAAA,CAAA,SAAA,EAAA,GAAA,CAAA,SAAA,CAAA,UAAA,CAAA,WAAA,GAAA,UAAA,CAAA,WAAA,IAAA,GAAA,CAAA,SAAA,CAAA,MAAA,CAAA,eAAA,GAAA,MAAA,CAAA,eAAA,IAAA,GAAA,CAAA,SAAA,CAAA,QAAA,EAAA,QAAA;AAAA,KAOtB,eAAA,GAAkB,GAAA,CAAE,KAAA,QAAa,qBAAA;;;;cAKhC,sBAAA,EAAsB,GAAA,CAAA,SAAA,CAAA,QAAA,EAAA,QAAA;AAAA,KAEvB,gBAAA,GAAmB,GAAA,CAAE,KAAA,QAAa,sBAAA;;;;cAKjC,YAAA,EAAY,GAAA,CAAA,SAAA;;;;;KAMb,YAAA,GAAe,GAAA,CAAE,KAAA,QAAa,YAAA;;;;cAK7B,oBAAA,EAAoB,GAAA,CAAA,SAAA;AAAA,KACrB,cAAA,GAAiB,GAAA,CAAE,KAAA,QAAa,oBAAA;;;;cAK/B,wBAAA;EAAA,SAA6D,WAAA;AAAA;AAAA,cAE7D,sBAAA,EAAsB,GAAA,CAAA,SAAA;;;KAIvB,gBAAA,GAAmB,GAAA,CAAE,KAAA,QAAa,sBAAA;;;;cAKjC,yBAAA,EAAyB,GAAA,CAAA,SAAA;;;;KAO1B,mBAAA,GAAsB,GAAA,CAAE,KAAA,QAAa,yBAAA;;;AA/CjD;cAoDa,qBAAA,EAAqB,GAAA,CAAA,SAAA;;;;;;KAItB,eAAA,GAAkB,GAAA,CAAE,KAAA,QAAa,qBAAA;;AAnD7C;;cAwDa,qBAAA,EAAqB,GAAA,CAAA,SAAA;;;KAItB,eAAA,GAAkB,GAAA,CAAE,KAAA,QAAa,qBAAA;;;;cAKhC,sBAAA,EAAsB,GAAA,CAAA,SAAA;;;;;KAEvB,gBAAA,GAAmB,GAAA,CAAE,KAAA,QAAa,sBAAA;;;;cAKjC,uBAAA,EAAuB,GAAA,CAAA,SAAA;;;;;;KAOxB,iBAAA,GAAoB,GAAA,CAAE,KAAA,QAAa,uBAAA;;;;cAKlC,yBAAA,EAAyB,GAAA,CAAA,SAAA;;;KAI1B,mBAAA,GAAsB,GAAA,CAAE,KAAA,QAAa,yBAAA;;;;cAKpC,oBAAA,EAAoB,GAAA,CAAA,SAAA;;;;;;;KAIrB,cAAA,GAAiB,GAAA,CAAE,KAAA,QAAa,oBAAA;;;;cAK/B,qBAAA,EAAqB,GAAA,CAAA,SAAA;;;;;KACtB,eAAA,GAAkB,GAAA,CAAE,KAAA,QAAa,qBAAA"}
|