@btst/stack 3.0.0-rc.1 → 3.0.0-rc.3
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/README.md +122 -46
- package/dist/api/index.cjs +133 -29
- package/dist/api/index.d.cts +14 -32
- package/dist/api/index.d.mts +14 -32
- package/dist/api/index.d.ts +14 -32
- package/dist/api/index.mjs +133 -28
- package/dist/authorization/client.cjs +154 -0
- package/dist/authorization/client.d.cts +70 -0
- package/dist/authorization/client.d.mts +70 -0
- package/dist/authorization/client.d.ts +70 -0
- package/dist/authorization/client.mjs +152 -0
- package/dist/authorization/index.cjs +371 -0
- package/dist/authorization/index.d.cts +201 -0
- package/dist/authorization/index.d.mts +201 -0
- package/dist/authorization/index.d.ts +201 -0
- package/dist/authorization/index.mjs +365 -0
- package/dist/authorization/remote.cjs +117 -0
- package/dist/authorization/remote.d.cts +79 -0
- package/dist/authorization/remote.d.mts +79 -0
- package/dist/authorization/remote.d.ts +79 -0
- package/dist/authorization/remote.mjs +111 -0
- package/dist/authorization/server.cjs +77 -0
- package/dist/authorization/server.d.cts +51 -0
- package/dist/authorization/server.d.mts +51 -0
- package/dist/authorization/server.d.ts +51 -0
- package/dist/authorization/server.mjs +73 -0
- package/dist/client/components/index.cjs +1 -0
- package/dist/client/components/index.d.cts +23 -6
- package/dist/client/components/index.d.mts +23 -6
- package/dist/client/components/index.d.ts +23 -6
- package/dist/client/components/index.mjs +1 -1
- package/dist/client/hooks/index.cjs +8 -0
- package/dist/client/hooks/index.d.cts +25 -0
- package/dist/client/hooks/index.d.mts +25 -0
- package/dist/client/hooks/index.d.ts +25 -0
- package/dist/client/hooks/index.mjs +2 -0
- package/dist/client/index.cjs +38 -7
- package/dist/client/index.d.cts +30 -100
- package/dist/client/index.d.mts +30 -100
- package/dist/client/index.d.ts +30 -100
- package/dist/client/index.mjs +38 -7
- package/dist/client/server.cjs +96 -0
- package/dist/client/server.d.cts +57 -0
- package/dist/client/server.d.mts +57 -0
- package/dist/client/server.d.ts +57 -0
- package/dist/client/server.mjs +92 -0
- package/dist/components/auto-form/index.d.cts +2 -2
- package/dist/components/auto-form/index.d.mts +2 -2
- package/dist/components/auto-form/index.d.ts +2 -2
- package/dist/components/form-builder/index.d.cts +1 -1
- package/dist/components/form-builder/index.d.mts +1 -1
- package/dist/components/form-builder/index.d.ts +1 -1
- package/dist/components/stepped-auto-form/index.d.cts +1 -1
- package/dist/components/stepped-auto-form/index.d.mts +1 -1
- package/dist/components/stepped-auto-form/index.d.ts +1 -1
- package/dist/context/index.cjs +8 -2
- package/dist/context/index.d.cts +111 -89
- package/dist/context/index.d.mts +111 -89
- package/dist/context/index.d.ts +111 -89
- package/dist/context/index.mjs +3 -1
- package/dist/index.cjs +1 -2
- package/dist/index.d.cts +8 -3
- package/dist/index.d.mts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.mjs +1 -1
- package/dist/next/index.d.cts +30 -12
- package/dist/next/index.d.mts +30 -12
- package/dist/next/index.d.ts +30 -12
- package/dist/next/server.cjs +7 -0
- package/dist/next/server.d.cts +56 -0
- package/dist/next/server.d.mts +56 -0
- package/dist/next/server.d.ts +56 -0
- package/dist/next/server.mjs +1 -0
- package/dist/packages/stack/src/authorization/json.cjs +57 -0
- package/dist/packages/stack/src/authorization/json.mjs +55 -0
- package/dist/packages/stack/src/client/components/compose.cjs +91 -9
- package/dist/packages/stack/src/client/components/compose.mjs +92 -11
- package/dist/packages/stack/src/client/runtime.cjs +295 -0
- package/dist/packages/stack/src/client/runtime.mjs +293 -0
- package/dist/packages/stack/src/context/auth.cjs +141 -73
- package/dist/packages/stack/src/context/auth.mjs +139 -73
- package/dist/packages/stack/src/context/provider.cjs +11 -5
- package/dist/packages/stack/src/context/provider.mjs +11 -5
- package/dist/packages/stack/src/context/router.cjs +9 -0
- package/dist/packages/stack/src/context/router.mjs +7 -0
- package/dist/packages/stack/src/context/site-navigation.cjs +40 -0
- package/dist/packages/stack/src/context/site-navigation.mjs +38 -0
- package/dist/packages/stack/src/next/layout.cjs +27 -0
- package/dist/packages/stack/src/next/layout.mjs +25 -0
- package/dist/packages/stack/src/next/page.cjs +8 -6
- package/dist/packages/stack/src/next/page.mjs +8 -6
- package/dist/packages/stack/src/plugin-registration.cjs +59 -0
- package/dist/packages/stack/src/plugin-registration.mjs +57 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/lifecycle-migrations.cjs +18 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/lifecycle-migrations.mjs +16 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/operations.cjs +1341 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/operations.mjs +1333 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/plugin.cjs +82 -640
- package/dist/packages/stack/src/plugins/ai-chat/api/plugin.mjs +78 -641
- package/dist/packages/stack/src/plugins/ai-chat/api/serializers.cjs +23 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/serializers.mjs +20 -0
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-input.cjs +183 -111
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-input.mjs +187 -115
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-interface.cjs +562 -116
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-interface.mjs +567 -121
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-layout.cjs +6 -6
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-layout.mjs +6 -6
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-message.cjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-message.mjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-sidebar.cjs +45 -29
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-sidebar.mjs +46 -30
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/404-page.cjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/404-page.mjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.cjs +46 -7
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.internal.cjs +5 -3
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.internal.mjs +5 -3
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.mjs +48 -9
- package/dist/packages/stack/src/plugins/ai-chat/client/components/shared/default-error.cjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/shared/default-error.mjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/tool-call-display.cjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/tool-call-display.mjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/hooks/ai-chat-resource.cjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/hooks/ai-chat-resource.mjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/hooks/chat-hooks.cjs +179 -19
- package/dist/packages/stack/src/plugins/ai-chat/client/hooks/chat-hooks.mjs +180 -21
- package/dist/packages/stack/src/plugins/ai-chat/client/navigation.cjs +11 -0
- package/dist/packages/stack/src/plugins/ai-chat/client/navigation.mjs +9 -0
- package/dist/packages/stack/src/plugins/ai-chat/client/overrides.cjs +24 -0
- package/dist/packages/stack/src/plugins/ai-chat/client/overrides.mjs +21 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/plugin.cjs +152 -82
- package/dist/packages/stack/src/plugins/ai-chat/client/plugin.mjs +152 -82
- package/dist/packages/stack/src/plugins/api/create-endpoint.cjs +27 -9
- package/dist/packages/stack/src/plugins/api/create-endpoint.mjs +27 -10
- package/dist/packages/stack/src/plugins/api/endpoint-inventory.cjs +125 -0
- package/dist/packages/stack/src/plugins/api/endpoint-inventory.mjs +123 -0
- package/dist/packages/stack/src/plugins/api/operation.cjs +208 -0
- package/dist/packages/stack/src/plugins/api/operation.mjs +198 -0
- package/dist/packages/stack/src/plugins/blog/api/lifecycle-migrations.cjs +17 -0
- package/dist/packages/stack/src/plugins/blog/api/lifecycle-migrations.mjs +15 -0
- package/dist/packages/stack/src/plugins/blog/api/mutations.cjs +10 -2
- package/dist/packages/stack/src/plugins/blog/api/mutations.mjs +10 -2
- package/dist/packages/stack/src/plugins/blog/api/operations.cjs +455 -0
- package/dist/packages/stack/src/plugins/blog/api/operations.mjs +448 -0
- package/dist/packages/stack/src/plugins/blog/api/plugin.cjs +51 -298
- package/dist/packages/stack/src/plugins/blog/api/plugin.mjs +55 -304
- package/dist/packages/stack/src/plugins/blog/client/components/forms/image-field.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/forms/image-field.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/forms/markdown-editor-with-overrides.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/forms/markdown-editor-with-overrides.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/forms/post-forms.cjs +82 -67
- package/dist/packages/stack/src/plugins/blog/client/components/forms/post-forms.mjs +84 -69
- package/dist/packages/stack/src/plugins/blog/client/components/pages/404-page.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/404-page.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.cjs +22 -4
- package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.internal.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.internal.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.mjs +23 -5
- package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.cjs +6 -2
- package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.internal.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.internal.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.mjs +6 -2
- package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.cjs +4 -2
- package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.internal.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.internal.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.mjs +4 -2
- package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.cjs +30 -3
- package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.internal.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.internal.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.mjs +31 -4
- package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.cjs +4 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.internal.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.internal.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.mjs +4 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/collapsible-tag-list.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/collapsible-tag-list.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/default-error.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/default-error.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/on-this-page.cjs +3 -2
- package/dist/packages/stack/src/plugins/blog/client/components/shared/on-this-page.mjs +3 -2
- package/dist/packages/stack/src/plugins/blog/client/components/shared/page-wrapper.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/page-wrapper.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/post-card.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/post-card.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/posts-list.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/posts-list.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/recent-posts-carousel.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/recent-posts-carousel.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/search-input.cjs +2 -2
- package/dist/packages/stack/src/plugins/blog/client/components/shared/search-input.mjs +1 -1
- package/dist/packages/stack/src/plugins/blog/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/blog/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/blog/client/hooks/blog-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/hooks/blog-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/plugin.cjs +169 -163
- package/dist/packages/stack/src/plugins/blog/client/plugin.mjs +169 -163
- package/dist/packages/stack/src/plugins/client/resource/hooks.cjs +31 -16
- package/dist/packages/stack/src/plugins/client/resource/hooks.mjs +31 -16
- package/dist/packages/stack/src/plugins/client/resource/internal.cjs +66 -52
- package/dist/packages/stack/src/plugins/client/resource/internal.mjs +66 -52
- package/dist/packages/stack/src/plugins/client/resource/use-form.cjs +20 -17
- package/dist/packages/stack/src/plugins/client/resource/use-form.mjs +20 -17
- package/dist/packages/stack/src/plugins/client/resource/use-select.cjs +39 -33
- package/dist/packages/stack/src/plugins/client/resource/use-select.mjs +39 -33
- package/dist/packages/stack/src/plugins/cms/api/lifecycle-migrations.cjs +13 -0
- package/dist/packages/stack/src/plugins/cms/api/lifecycle-migrations.mjs +11 -0
- package/dist/packages/stack/src/plugins/cms/api/operations.cjs +1763 -0
- package/dist/packages/stack/src/plugins/cms/api/operations.mjs +1756 -0
- package/dist/packages/stack/src/plugins/cms/api/plugin.cjs +165 -752
- package/dist/packages/stack/src/plugins/cms/api/plugin.mjs +164 -755
- package/dist/packages/stack/src/plugins/cms/client/components/forms/content-form.cjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/forms/content-form.mjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/forms/file-upload.cjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/forms/file-upload.mjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/forms/relation-field.cjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/forms/relation-field.mjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/inverse-relations-panel.cjs +23 -13
- package/dist/packages/stack/src/plugins/cms/client/components/inverse-relations-panel.mjs +24 -14
- package/dist/packages/stack/src/plugins/cms/client/components/pages/404-page.cjs +5 -4
- package/dist/packages/stack/src/plugins/cms/client/components/pages/404-page.mjs +6 -5
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.cjs +40 -7
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.cjs +15 -9
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.mjs +14 -8
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.mjs +41 -8
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.cjs +7 -1
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.internal.cjs +42 -29
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.internal.mjs +40 -27
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.mjs +7 -1
- package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.cjs +4 -1
- package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.internal.cjs +13 -7
- package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.internal.mjs +12 -6
- package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.mjs +4 -1
- package/dist/packages/stack/src/plugins/cms/client/components/shared/page-wrapper.cjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/shared/page-wrapper.mjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/cms/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/cms/client/hooks/cms-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/hooks/cms-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/overrides.cjs +26 -0
- package/dist/packages/stack/src/plugins/cms/client/overrides.mjs +24 -0
- package/dist/packages/stack/src/plugins/cms/client/plugin.cjs +102 -81
- package/dist/packages/stack/src/plugins/cms/client/plugin.mjs +103 -82
- package/dist/packages/stack/src/plugins/comments/api/getters.cjs +6 -2
- package/dist/packages/stack/src/plugins/comments/api/getters.mjs +6 -3
- package/dist/packages/stack/src/plugins/comments/api/lifecycle-migrations.cjs +18 -0
- package/dist/packages/stack/src/plugins/comments/api/lifecycle-migrations.mjs +16 -0
- package/dist/packages/stack/src/plugins/comments/api/mutations.cjs +179 -68
- package/dist/packages/stack/src/plugins/comments/api/mutations.mjs +179 -68
- package/dist/packages/stack/src/plugins/comments/api/operations.cjs +453 -0
- package/dist/packages/stack/src/plugins/comments/api/operations.mjs +445 -0
- package/dist/packages/stack/src/plugins/comments/api/plugin.cjs +51 -276
- package/dist/packages/stack/src/plugins/comments/api/plugin.mjs +48 -277
- package/dist/packages/stack/src/plugins/comments/client/components/comment-count.cjs +32 -5
- package/dist/packages/stack/src/plugins/comments/client/components/comment-count.mjs +34 -7
- package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.cjs +161 -105
- package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.mjs +162 -106
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.cjs +14 -2
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.internal.cjs +141 -71
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.internal.mjs +142 -72
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.mjs +14 -2
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-state.cjs +12 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-state.mjs +9 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.cjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.internal.cjs +40 -26
- package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.internal.mjs +40 -26
- package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.mjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.cjs +9 -1
- package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.internal.cjs +25 -20
- package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.internal.mjs +26 -21
- package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.mjs +9 -1
- package/dist/packages/stack/src/plugins/comments/client/components/shared/page-wrapper.cjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/components/shared/page-wrapper.mjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/components/shared/pagination.cjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/components/shared/pagination.mjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/comments/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.cjs +323 -290
- package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.mjs +325 -292
- package/dist/packages/stack/src/plugins/comments/client/localization/comments-thread.cjs +1 -0
- package/dist/packages/stack/src/plugins/comments/client/localization/comments-thread.mjs +1 -0
- package/dist/packages/stack/src/plugins/comments/client/plugin.cjs +78 -46
- package/dist/packages/stack/src/plugins/comments/client/plugin.mjs +80 -48
- package/dist/packages/stack/src/plugins/form-builder/api/getters.cjs +9 -0
- package/dist/packages/stack/src/plugins/form-builder/api/getters.mjs +9 -1
- package/dist/packages/stack/src/plugins/form-builder/api/lifecycle-migrations.cjs +15 -0
- package/dist/packages/stack/src/plugins/form-builder/api/lifecycle-migrations.mjs +13 -0
- package/dist/packages/stack/src/plugins/form-builder/api/operations.cjs +1093 -0
- package/dist/packages/stack/src/plugins/form-builder/api/operations.mjs +1082 -0
- package/dist/packages/stack/src/plugins/form-builder/api/plugin.cjs +97 -466
- package/dist/packages/stack/src/plugins/form-builder/api/plugin.mjs +92 -468
- package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.cjs +5 -0
- package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.mjs +5 -0
- package/dist/packages/stack/src/plugins/form-builder/client/components/forms/form-renderer.cjs +41 -11
- package/dist/packages/stack/src/plugins/form-builder/client/components/forms/form-renderer.mjs +42 -12
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/404-page.cjs +8 -5
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/404-page.mjs +9 -6
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.cjs +36 -3
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.cjs +32 -11
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.mjs +35 -14
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.mjs +37 -4
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.cjs +6 -1
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.cjs +34 -26
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.mjs +34 -26
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.mjs +6 -1
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.cjs +24 -7
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.cjs +72 -40
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.mjs +76 -44
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.mjs +25 -8
- package/dist/packages/stack/src/plugins/form-builder/client/components/shared/page-wrapper.cjs +2 -1
- package/dist/packages/stack/src/plugins/form-builder/client/components/shared/page-wrapper.mjs +2 -1
- package/dist/packages/stack/src/plugins/form-builder/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/form-builder/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-hooks.cjs +29 -0
- package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-hooks.mjs +28 -1
- package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/form-builder/client/plugin.cjs +113 -86
- package/dist/packages/stack/src/plugins/form-builder/client/plugin.mjs +114 -87
- package/dist/packages/stack/src/plugins/form-builder/schemas.cjs +9 -3
- package/dist/packages/stack/src/plugins/form-builder/schemas.mjs +9 -3
- package/dist/packages/stack/src/plugins/kanban/api/getters.cjs +47 -36
- package/dist/packages/stack/src/plugins/kanban/api/getters.mjs +47 -37
- package/dist/packages/stack/src/plugins/kanban/api/lifecycle-migrations.cjs +23 -0
- package/dist/packages/stack/src/plugins/kanban/api/lifecycle-migrations.mjs +21 -0
- package/dist/packages/stack/src/plugins/kanban/api/operations.cjs +1552 -0
- package/dist/packages/stack/src/plugins/kanban/api/operations.mjs +1543 -0
- package/dist/packages/stack/src/plugins/kanban/api/plugin.cjs +64 -631
- package/dist/packages/stack/src/plugins/kanban/api/plugin.mjs +62 -634
- package/dist/packages/stack/src/plugins/kanban/api/serializers.cjs +21 -0
- package/dist/packages/stack/src/plugins/kanban/api/serializers.mjs +21 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/board-form.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/board-form.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/column-form.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/column-form.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/task-form.cjs +72 -54
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/task-form.mjs +74 -56
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/404-page.cjs +4 -6
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/404-page.mjs +5 -7
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.cjs +22 -6
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.internal.cjs +82 -77
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.internal.mjs +83 -78
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.mjs +23 -7
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.internal.cjs +34 -24
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.internal.mjs +35 -25
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.internal.cjs +6 -9
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.internal.mjs +7 -10
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/column-content.cjs +72 -45
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/column-content.mjs +73 -46
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/default-error.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/default-error.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/kanban-board.cjs +4 -4
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/kanban-board.mjs +4 -4
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/permission-access-any.cjs +23 -0
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/permission-access-any.mjs +21 -0
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/task-card.cjs +54 -17
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/task-card.mjs +55 -18
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/user-avatar.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/user-avatar.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/kanban/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-hooks.cjs +38 -9
- package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-hooks.mjs +39 -10
- package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/plugin.cjs +177 -104
- package/dist/packages/stack/src/plugins/kanban/client/plugin.mjs +178 -105
- package/dist/packages/stack/src/plugins/kanban/schemas.cjs +32 -23
- package/dist/packages/stack/src/plugins/kanban/schemas.mjs +33 -21
- package/dist/packages/stack/src/plugins/media/api/lifecycle-migrations.cjs +9 -0
- package/dist/packages/stack/src/plugins/media/api/lifecycle-migrations.mjs +7 -0
- package/dist/packages/stack/src/plugins/media/api/mutations.cjs +7 -2
- package/dist/packages/stack/src/plugins/media/api/mutations.mjs +7 -2
- package/dist/packages/stack/src/plugins/media/api/operations.cjs +1299 -0
- package/dist/packages/stack/src/plugins/media/api/operations.mjs +1290 -0
- package/dist/packages/stack/src/plugins/media/api/plugin.cjs +131 -508
- package/dist/packages/stack/src/plugins/media/api/plugin.mjs +127 -510
- package/dist/packages/stack/src/plugins/media/api/query-key-defs.cjs +26 -2
- package/dist/packages/stack/src/plugins/media/api/query-key-defs.mjs +25 -3
- package/dist/packages/stack/src/plugins/media/api/serializers.cjs +4 -2
- package/dist/packages/stack/src/plugins/media/api/serializers.mjs +4 -2
- package/dist/packages/stack/src/plugins/media/asset-url.cjs +13 -0
- package/dist/packages/stack/src/plugins/media/asset-url.mjs +11 -0
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/asset-card.cjs +10 -10
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/asset-card.mjs +12 -12
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/folder-tree.cjs +47 -27
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/folder-tree.mjs +49 -29
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/index.cjs +225 -180
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/index.mjs +228 -183
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/upload-tab.cjs +1 -8
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/upload-tab.mjs +2 -9
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/url-tab.cjs +0 -6
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/url-tab.mjs +1 -7
- package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.cjs +4 -2
- package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.internal.cjs +92 -75
- package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.internal.mjs +93 -76
- package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.mjs +4 -2
- package/dist/packages/stack/src/plugins/media/client/components/upload-permission-check.cjs +52 -0
- package/dist/packages/stack/src/plugins/media/client/components/upload-permission-check.mjs +49 -0
- package/dist/packages/stack/src/plugins/media/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/media/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/media/client/hooks/media-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/media/client/hooks/media-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/media/client/hooks/use-media.cjs +214 -43
- package/dist/packages/stack/src/plugins/media/client/hooks/use-media.mjs +217 -46
- package/dist/packages/stack/src/plugins/media/client/plugin.cjs +122 -62
- package/dist/packages/stack/src/plugins/media/client/plugin.mjs +123 -63
- package/dist/packages/stack/src/plugins/media/client/upload.cjs +121 -52
- package/dist/packages/stack/src/plugins/media/client/upload.mjs +121 -53
- package/dist/packages/stack/src/plugins/media/db.cjs +8 -0
- package/dist/packages/stack/src/plugins/media/db.mjs +8 -0
- package/dist/packages/stack/src/plugins/open-api/api/generator.cjs +36 -5
- package/dist/packages/stack/src/plugins/open-api/api/generator.mjs +36 -5
- package/dist/packages/stack/src/plugins/open-api/api/plugin.cjs +22 -11
- package/dist/packages/stack/src/plugins/open-api/api/plugin.mjs +22 -11
- package/dist/packages/stack/src/plugins/route-docs/client/components/pages/docs-page.cjs +65 -34
- package/dist/packages/stack/src/plugins/route-docs/client/components/pages/docs-page.mjs +56 -25
- package/dist/packages/stack/src/plugins/route-docs/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/route-docs/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/route-docs/client/hooks.cjs +9 -8
- package/dist/packages/stack/src/plugins/route-docs/client/hooks.mjs +10 -9
- package/dist/packages/stack/src/plugins/route-docs/client/plugin.cjs +143 -75
- package/dist/packages/stack/src/plugins/route-docs/client/plugin.mjs +144 -74
- package/dist/packages/stack/src/plugins/route-docs/client/schema.cjs +26 -0
- package/dist/packages/stack/src/plugins/route-docs/client/schema.mjs +23 -0
- package/dist/packages/stack/src/plugins/route-docs/generator.cjs +7 -4
- package/dist/packages/stack/src/plugins/route-docs/generator.mjs +7 -4
- package/dist/packages/stack/src/plugins/ui-builder/client/components/page-renderer.cjs +41 -12
- package/dist/packages/stack/src/plugins/ui-builder/client/components/page-renderer.mjs +42 -13
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.cjs +37 -3
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.cjs +32 -20
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.mjs +34 -22
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.mjs +38 -4
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.cjs +8 -2
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.internal.cjs +37 -19
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.internal.mjs +38 -20
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.mjs +8 -2
- package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/default-error.cjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/default-error.mjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/page-wrapper.cjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/page-wrapper.mjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/ui-builder/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/ui-builder/client/hooks/ui-builder-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/hooks/ui-builder-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/overrides.cjs +8 -0
- package/dist/packages/stack/src/plugins/ui-builder/client/overrides.mjs +6 -0
- package/dist/packages/stack/src/plugins/ui-builder/client/plugin.cjs +93 -53
- package/dist/packages/stack/src/plugins/ui-builder/client/plugin.mjs +94 -54
- package/dist/packages/stack/src/plugins/utils.cjs +4 -12
- package/dist/packages/stack/src/plugins/utils.mjs +5 -12
- package/dist/packages/stack/src/react-router/layout.cjs +14 -0
- package/dist/packages/stack/src/react-router/layout.mjs +12 -0
- package/dist/packages/stack/src/react-router/page.cjs +27 -16
- package/dist/packages/stack/src/react-router/page.mjs +28 -17
- package/dist/packages/stack/src/shared/initial-identity.cjs +27 -0
- package/dist/packages/stack/src/shared/initial-identity.mjs +23 -0
- package/dist/packages/stack/src/tanstack/layout.cjs +10 -0
- package/dist/packages/stack/src/tanstack/layout.mjs +8 -0
- package/dist/packages/stack/src/tanstack/page.cjs +11 -5
- package/dist/packages/stack/src/tanstack/page.mjs +11 -5
- package/dist/plugins/ai-chat/api/index.cjs +10 -0
- package/dist/plugins/ai-chat/api/index.d.cts +31 -5
- package/dist/plugins/ai-chat/api/index.d.mts +31 -5
- package/dist/plugins/ai-chat/api/index.d.ts +31 -5
- package/dist/plugins/ai-chat/api/index.mjs +3 -1
- package/dist/plugins/ai-chat/client/components/index.d.cts +1 -1
- package/dist/plugins/ai-chat/client/components/index.d.mts +1 -1
- package/dist/plugins/ai-chat/client/components/index.d.ts +1 -1
- package/dist/plugins/ai-chat/client/hooks/index.cjs +1 -0
- package/dist/plugins/ai-chat/client/hooks/index.d.cts +14 -8
- package/dist/plugins/ai-chat/client/hooks/index.d.mts +14 -8
- package/dist/plugins/ai-chat/client/hooks/index.d.ts +14 -8
- package/dist/plugins/ai-chat/client/hooks/index.mjs +1 -1
- package/dist/plugins/ai-chat/client/index.d.cts +21 -25
- package/dist/plugins/ai-chat/client/index.d.mts +21 -25
- package/dist/plugins/ai-chat/client/index.d.ts +21 -25
- package/dist/plugins/ai-chat/permissions.cjs +90 -0
- package/dist/plugins/ai-chat/permissions.d.cts +84 -0
- package/dist/plugins/ai-chat/permissions.d.mts +84 -0
- package/dist/plugins/ai-chat/permissions.d.ts +84 -0
- package/dist/plugins/ai-chat/permissions.mjs +88 -0
- package/dist/plugins/ai-chat/query-keys.cjs +116 -18
- package/dist/plugins/ai-chat/query-keys.d.cts +6 -2
- package/dist/plugins/ai-chat/query-keys.d.mts +6 -2
- package/dist/plugins/ai-chat/query-keys.d.ts +6 -2
- package/dist/plugins/ai-chat/query-keys.mjs +116 -19
- package/dist/plugins/api/index.cjs +4 -0
- package/dist/plugins/api/index.d.cts +13 -18
- package/dist/plugins/api/index.d.mts +13 -18
- package/dist/plugins/api/index.d.ts +13 -18
- package/dist/plugins/api/index.mjs +1 -0
- package/dist/plugins/blog/api/index.cjs +9 -2
- package/dist/plugins/blog/api/index.d.cts +118 -4
- package/dist/plugins/blog/api/index.d.mts +118 -4
- package/dist/plugins/blog/api/index.d.ts +118 -4
- package/dist/plugins/blog/api/index.mjs +4 -1
- package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
- package/dist/plugins/blog/client/index.d.cts +210 -226
- package/dist/plugins/blog/client/index.d.mts +210 -226
- package/dist/plugins/blog/client/index.d.ts +210 -226
- package/dist/plugins/blog/permissions.cjs +47 -0
- package/dist/plugins/blog/permissions.d.cts +49 -0
- package/dist/plugins/blog/permissions.d.mts +49 -0
- package/dist/plugins/blog/permissions.d.ts +49 -0
- package/dist/plugins/blog/permissions.mjs +45 -0
- package/dist/plugins/blog/query-keys.d.cts +7 -3
- package/dist/plugins/blog/query-keys.d.mts +7 -3
- package/dist/plugins/blog/query-keys.d.ts +7 -3
- package/dist/plugins/client/hooks/index.d.cts +2 -2
- package/dist/plugins/client/hooks/index.d.mts +2 -2
- package/dist/plugins/client/hooks/index.d.ts +2 -2
- package/dist/plugins/client/index.cjs +3 -0
- package/dist/plugins/client/index.d.cts +30 -10
- package/dist/plugins/client/index.d.mts +30 -10
- package/dist/plugins/client/index.d.ts +30 -10
- package/dist/plugins/client/index.mjs +3 -0
- package/dist/plugins/cms/api/index.cjs +7 -0
- package/dist/plugins/cms/api/index.d.cts +173 -4
- package/dist/plugins/cms/api/index.d.mts +173 -4
- package/dist/plugins/cms/api/index.d.ts +173 -4
- package/dist/plugins/cms/api/index.mjs +2 -0
- package/dist/plugins/cms/client/hooks/index.d.cts +1 -1
- package/dist/plugins/cms/client/hooks/index.d.mts +1 -1
- package/dist/plugins/cms/client/hooks/index.d.ts +1 -1
- package/dist/plugins/cms/client/index.d.cts +188 -184
- package/dist/plugins/cms/client/index.d.mts +188 -184
- package/dist/plugins/cms/client/index.d.ts +188 -184
- package/dist/plugins/cms/permissions.cjs +46 -0
- package/dist/plugins/cms/permissions.d.cts +42 -0
- package/dist/plugins/cms/permissions.d.mts +42 -0
- package/dist/plugins/cms/permissions.d.ts +42 -0
- package/dist/plugins/cms/permissions.mjs +44 -0
- package/dist/plugins/cms/query-keys.d.cts +4 -4
- package/dist/plugins/cms/query-keys.d.mts +4 -4
- package/dist/plugins/cms/query-keys.d.ts +4 -4
- package/dist/plugins/comments/api/index.cjs +10 -0
- package/dist/plugins/comments/api/index.d.cts +54 -18
- package/dist/plugins/comments/api/index.d.mts +54 -18
- package/dist/plugins/comments/api/index.d.ts +54 -18
- package/dist/plugins/comments/api/index.mjs +3 -0
- package/dist/plugins/comments/client/components/index.d.cts +7 -2
- package/dist/plugins/comments/client/components/index.d.mts +7 -2
- package/dist/plugins/comments/client/components/index.d.ts +7 -2
- package/dist/plugins/comments/client/hooks/index.d.cts +12 -18
- package/dist/plugins/comments/client/hooks/index.d.mts +12 -18
- package/dist/plugins/comments/client/hooks/index.d.ts +12 -18
- package/dist/plugins/comments/client/index.d.cts +96 -114
- package/dist/plugins/comments/client/index.d.mts +96 -114
- package/dist/plugins/comments/client/index.d.ts +96 -114
- package/dist/plugins/comments/permissions.cjs +70 -0
- package/dist/plugins/comments/permissions.d.cts +76 -0
- package/dist/plugins/comments/permissions.d.mts +76 -0
- package/dist/plugins/comments/permissions.d.ts +76 -0
- package/dist/plugins/comments/permissions.mjs +68 -0
- package/dist/plugins/comments/query-keys.cjs +1 -1
- package/dist/plugins/comments/query-keys.d.cts +16 -19
- package/dist/plugins/comments/query-keys.d.mts +16 -19
- package/dist/plugins/comments/query-keys.d.ts +16 -19
- package/dist/plugins/comments/query-keys.mjs +1 -1
- package/dist/plugins/form-builder/api/index.cjs +8 -0
- package/dist/plugins/form-builder/api/index.d.cts +115 -4
- package/dist/plugins/form-builder/api/index.d.mts +115 -4
- package/dist/plugins/form-builder/api/index.d.ts +115 -4
- package/dist/plugins/form-builder/api/index.mjs +4 -1
- package/dist/plugins/form-builder/client/components/index.d.cts +6 -2
- package/dist/plugins/form-builder/client/components/index.d.mts +6 -2
- package/dist/plugins/form-builder/client/components/index.d.ts +6 -2
- package/dist/plugins/form-builder/client/hooks/index.cjs +2 -0
- package/dist/plugins/form-builder/client/hooks/index.d.cts +34 -8
- package/dist/plugins/form-builder/client/hooks/index.d.mts +34 -8
- package/dist/plugins/form-builder/client/hooks/index.d.ts +34 -8
- package/dist/plugins/form-builder/client/hooks/index.mjs +1 -1
- package/dist/plugins/form-builder/client/index.d.cts +153 -174
- package/dist/plugins/form-builder/client/index.d.mts +153 -174
- package/dist/plugins/form-builder/client/index.d.ts +153 -174
- package/dist/plugins/form-builder/permissions.cjs +95 -0
- package/dist/plugins/form-builder/permissions.d.cts +94 -0
- package/dist/plugins/form-builder/permissions.d.mts +94 -0
- package/dist/plugins/form-builder/permissions.d.ts +94 -0
- package/dist/plugins/form-builder/permissions.mjs +93 -0
- package/dist/plugins/form-builder/query-keys.cjs +11 -4
- package/dist/plugins/form-builder/query-keys.d.cts +38 -12
- package/dist/plugins/form-builder/query-keys.d.mts +38 -12
- package/dist/plugins/form-builder/query-keys.d.ts +38 -12
- package/dist/plugins/form-builder/query-keys.mjs +11 -4
- package/dist/plugins/kanban/api/index.cjs +9 -0
- package/dist/plugins/kanban/api/index.d.cts +137 -5
- package/dist/plugins/kanban/api/index.d.mts +137 -5
- package/dist/plugins/kanban/api/index.d.ts +137 -5
- package/dist/plugins/kanban/api/index.mjs +5 -2
- package/dist/plugins/kanban/client/components/index.d.cts +18 -10
- package/dist/plugins/kanban/client/components/index.d.mts +18 -10
- package/dist/plugins/kanban/client/components/index.d.ts +18 -10
- package/dist/plugins/kanban/client/hooks/index.d.cts +15 -7
- package/dist/plugins/kanban/client/hooks/index.d.mts +15 -7
- package/dist/plugins/kanban/client/hooks/index.d.ts +15 -7
- package/dist/plugins/kanban/client/index.d.cts +32 -28
- package/dist/plugins/kanban/client/index.d.mts +32 -28
- package/dist/plugins/kanban/client/index.d.ts +32 -28
- package/dist/plugins/kanban/permissions.cjs +101 -0
- package/dist/plugins/kanban/permissions.d.cts +109 -0
- package/dist/plugins/kanban/permissions.d.mts +109 -0
- package/dist/plugins/kanban/permissions.d.ts +109 -0
- package/dist/plugins/kanban/permissions.mjs +99 -0
- package/dist/plugins/kanban/query-keys.cjs +14 -15
- package/dist/plugins/kanban/query-keys.d.cts +63 -42
- package/dist/plugins/kanban/query-keys.d.mts +63 -42
- package/dist/plugins/kanban/query-keys.d.ts +63 -42
- package/dist/plugins/kanban/query-keys.mjs +14 -15
- package/dist/plugins/media/api/adapters/local.d.cts +1 -1
- package/dist/plugins/media/api/adapters/local.d.mts +1 -1
- package/dist/plugins/media/api/adapters/local.d.ts +1 -1
- package/dist/plugins/media/api/adapters/s3.d.cts +1 -1
- package/dist/plugins/media/api/adapters/s3.d.mts +1 -1
- package/dist/plugins/media/api/adapters/s3.d.ts +1 -1
- package/dist/plugins/media/api/adapters/vercel-blob.cjs +46 -0
- package/dist/plugins/media/api/adapters/vercel-blob.d.cts +6 -9
- package/dist/plugins/media/api/adapters/vercel-blob.d.mts +6 -9
- package/dist/plugins/media/api/adapters/vercel-blob.d.ts +6 -9
- package/dist/plugins/media/api/adapters/vercel-blob.mjs +46 -0
- package/dist/plugins/media/api/index.cjs +10 -0
- package/dist/plugins/media/api/index.d.cts +93 -6
- package/dist/plugins/media/api/index.d.mts +93 -6
- package/dist/plugins/media/api/index.d.ts +93 -6
- package/dist/plugins/media/api/index.mjs +2 -0
- package/dist/plugins/media/client/components/index.d.cts +1 -1
- package/dist/plugins/media/client/components/index.d.mts +1 -1
- package/dist/plugins/media/client/components/index.d.ts +1 -1
- package/dist/plugins/media/client/hooks/index.d.cts +20 -10
- package/dist/plugins/media/client/hooks/index.d.mts +20 -10
- package/dist/plugins/media/client/hooks/index.d.ts +20 -10
- package/dist/plugins/media/client/index.cjs +1 -0
- package/dist/plugins/media/client/index.d.cts +112 -100
- package/dist/plugins/media/client/index.d.mts +112 -100
- package/dist/plugins/media/client/index.d.ts +112 -100
- package/dist/plugins/media/client/index.mjs +1 -1
- package/dist/plugins/media/permissions.cjs +63 -0
- package/dist/plugins/media/permissions.d.cts +64 -0
- package/dist/plugins/media/permissions.d.mts +64 -0
- package/dist/plugins/media/permissions.d.ts +64 -0
- package/dist/plugins/media/permissions.mjs +61 -0
- package/dist/plugins/media/query-keys.cjs +29 -17
- package/dist/plugins/media/query-keys.d.cts +24 -31
- package/dist/plugins/media/query-keys.d.mts +24 -31
- package/dist/plugins/media/query-keys.d.ts +24 -31
- package/dist/plugins/media/query-keys.mjs +30 -18
- package/dist/plugins/open-api/api/index.d.cts +9 -4
- package/dist/plugins/open-api/api/index.d.mts +9 -4
- package/dist/plugins/open-api/api/index.d.ts +9 -4
- package/dist/plugins/route-docs/client/index.cjs +2 -2
- package/dist/plugins/route-docs/client/index.d.cts +54 -53
- package/dist/plugins/route-docs/client/index.d.mts +54 -53
- package/dist/plugins/route-docs/client/index.d.ts +54 -53
- package/dist/plugins/route-docs/client/index.mjs +2 -1
- package/dist/plugins/ui-builder/client/components/index.d.cts +8 -5
- package/dist/plugins/ui-builder/client/components/index.d.mts +8 -5
- package/dist/plugins/ui-builder/client/components/index.d.ts +8 -5
- package/dist/plugins/ui-builder/client/hooks/index.d.cts +5 -5
- package/dist/plugins/ui-builder/client/hooks/index.d.mts +5 -5
- package/dist/plugins/ui-builder/client/hooks/index.d.ts +5 -5
- package/dist/plugins/ui-builder/client/index.d.cts +151 -199
- package/dist/plugins/ui-builder/client/index.d.mts +151 -199
- package/dist/plugins/ui-builder/client/index.d.ts +151 -199
- package/dist/plugins/ui-builder/index.d.cts +11 -8
- package/dist/plugins/ui-builder/index.d.mts +11 -8
- package/dist/plugins/ui-builder/index.d.ts +11 -8
- package/dist/plugins/ui-builder/query-keys.d.cts +6 -6
- package/dist/plugins/ui-builder/query-keys.d.mts +6 -6
- package/dist/plugins/ui-builder/query-keys.d.ts +6 -6
- package/dist/react-router/index.cjs +2 -0
- package/dist/react-router/index.d.cts +41 -7
- package/dist/react-router/index.d.mts +41 -7
- package/dist/react-router/index.d.ts +41 -7
- package/dist/react-router/index.mjs +1 -0
- package/dist/shared/stack.0O62uXqP.d.ts +613 -0
- package/dist/shared/stack.0y6iTP03.d.ts +533 -0
- package/dist/shared/{stack.CbZenbej.d.cts → stack.1ukVJym7.d.cts} +3 -4
- package/dist/shared/{stack.CbZenbej.d.mts → stack.1ukVJym7.d.mts} +3 -4
- package/dist/shared/{stack.CbZenbej.d.ts → stack.1ukVJym7.d.ts} +3 -4
- package/dist/shared/stack.3Sr6qRtT.d.ts +507 -0
- package/dist/shared/{stack.9BAOaSqE.d.mts → stack.5_zzCejP.d.cts} +16 -14
- package/dist/shared/{stack.9BAOaSqE.d.ts → stack.5_zzCejP.d.mts} +16 -14
- package/dist/shared/{stack.9BAOaSqE.d.cts → stack.5_zzCejP.d.ts} +16 -14
- package/dist/shared/stack.B1UrNoVl.d.mts +533 -0
- package/dist/shared/{stack.B2xi4jj7.d.cts → stack.B1srlBud.d.mts} +2 -2
- package/dist/shared/stack.B3_aDcYL.d.cts +281 -0
- package/dist/shared/stack.B3_aDcYL.d.mts +281 -0
- package/dist/shared/stack.B3_aDcYL.d.ts +281 -0
- package/dist/shared/stack.B5yPgHsp.d.mts +507 -0
- package/dist/shared/stack.B8PG21zX.d.mts +764 -0
- package/dist/shared/stack.BFP_9pRX.d.cts +707 -0
- package/dist/shared/{stack.INBa9-TO.d.cts → stack.BGzgFx3R.d.cts} +5 -5
- package/dist/shared/stack.BJx1ZXrN.d.cts +118 -0
- package/dist/shared/{stack.7b3vsM8_.d.ts → stack.BK9Z2dcL.d.ts} +2 -2
- package/dist/shared/stack.BMHoxAn7.d.mts +707 -0
- package/dist/shared/stack.BMmvEBH_.d.ts +118 -0
- package/dist/shared/stack.BOZRaVpu.d.cts +1184 -0
- package/dist/shared/stack.BPLykw4s.d.ts +436 -0
- package/dist/shared/{stack.aqVZ6PEW.d.mts → stack.BRvqQWGt.d.cts} +40 -1
- package/dist/shared/{stack.aqVZ6PEW.d.cts → stack.BRvqQWGt.d.mts} +40 -1
- package/dist/shared/{stack.aqVZ6PEW.d.ts → stack.BRvqQWGt.d.ts} +40 -1
- package/dist/shared/stack.BSACE667.d.cts +23 -0
- package/dist/shared/stack.BYMentwB.d.cts +47 -0
- package/dist/shared/stack.BYMentwB.d.mts +47 -0
- package/dist/shared/stack.BYMentwB.d.ts +47 -0
- package/dist/shared/stack.Bt8hfw9o.d.ts +707 -0
- package/dist/shared/{stack.D7bewlgt.d.mts → stack.Bu2IPOLi.d.cts} +1 -0
- package/dist/shared/{stack.D7bewlgt.d.ts → stack.Bu2IPOLi.d.mts} +1 -0
- package/dist/shared/{stack.D7bewlgt.d.cts → stack.Bu2IPOLi.d.ts} +1 -0
- package/dist/shared/stack.BuxUQqL8.d.ts +408 -0
- package/dist/shared/stack.BzWGB5MG.d.cts +436 -0
- package/dist/shared/stack.C3bU9w6L.d.ts +351 -0
- package/dist/shared/stack.C4oVW2qK.d.cts +507 -0
- package/dist/shared/stack.CKXzdGiJ.d.cts +3 -0
- package/dist/shared/stack.CKXzdGiJ.d.mts +3 -0
- package/dist/shared/stack.CKXzdGiJ.d.ts +3 -0
- package/dist/shared/{stack.C3GBG8in.d.ts → stack.COrJrztD.d.cts} +1 -1
- package/dist/shared/{stack.C3GBG8in.d.cts → stack.COrJrztD.d.mts} +1 -1
- package/dist/shared/{stack.C3GBG8in.d.mts → stack.COrJrztD.d.ts} +1 -1
- package/dist/shared/stack.CX83YNuS.d.cts +408 -0
- package/dist/shared/stack.Cbd7sD5M.d.mts +118 -0
- package/dist/shared/{stack.B9NtGpAR.d.ts → stack.CcjENrr4.d.cts} +1 -5
- package/dist/shared/stack.CfK5NKlK.d.mts +613 -0
- package/dist/shared/{stack.3di7vQs6.d.mts → stack.CjCSDfWy.d.mts} +5 -5
- package/dist/shared/stack.Cmg7lzzy.d.cts +44 -0
- package/dist/shared/stack.Cmg7lzzy.d.mts +44 -0
- package/dist/shared/stack.Cmg7lzzy.d.ts +44 -0
- package/dist/shared/stack.CpE1mS3p.d.ts +331 -0
- package/dist/shared/stack.CskhFw3z.d.mts +23 -0
- package/dist/shared/stack.CvlC5kqe.d.cts +331 -0
- package/dist/shared/stack.CxKc9evq.d.ts +23 -0
- package/dist/shared/stack.CyalJ0j6.d.ts +764 -0
- package/dist/shared/stack.D6Pg-ufX.d.cts +764 -0
- package/dist/shared/{stack.lkebw2nj.d.mts → stack.DVEjWKCT.d.cts} +19 -5
- package/dist/shared/{stack.lkebw2nj.d.ts → stack.DVEjWKCT.d.mts} +19 -5
- package/dist/shared/{stack.lkebw2nj.d.cts → stack.DVEjWKCT.d.ts} +19 -5
- package/dist/shared/{stack.Cp_6mO5s.d.mts → stack.DbbvHbhn.d.mts} +1 -5
- package/dist/shared/stack.DiuRuzIs.d.cts +613 -0
- package/dist/shared/{stack.BMlLOMED.d.mts → stack.DjGixVx3.d.cts} +6 -2
- package/dist/shared/{stack.BMlLOMED.d.ts → stack.DjGixVx3.d.mts} +6 -2
- package/dist/shared/{stack.BMlLOMED.d.cts → stack.DjGixVx3.d.ts} +6 -2
- package/dist/shared/stack.DlBoNqYu.d.ts +1184 -0
- package/dist/shared/stack.DlCycSM-.d.mts +331 -0
- package/dist/shared/{stack.DycBcTeg.d.mts → stack.DmpPDPxA.d.cts} +2 -2
- package/dist/shared/{stack.CRelKJfH.d.ts → stack.Dpg_JjIo.d.ts} +5 -5
- package/dist/shared/stack.Dvy7FmaA.d.mts +1184 -0
- package/dist/shared/stack.DxHPKr2R.d.mts +436 -0
- package/dist/shared/stack.Egr3RWhA.d.mts +408 -0
- package/dist/shared/stack.Mak7pzIV.d.cts +533 -0
- package/dist/shared/stack.OYT8WU4n.d.mts +351 -0
- package/dist/shared/{stack.CPsYC2-Z.d.cts → stack.fdi94T4S.d.cts} +7 -7
- package/dist/shared/{stack.CPsYC2-Z.d.mts → stack.fdi94T4S.d.mts} +7 -7
- package/dist/shared/{stack.CPsYC2-Z.d.ts → stack.fdi94T4S.d.ts} +7 -7
- package/dist/shared/{stack.Dlgtumru.d.cts → stack.kaCV7vEL.d.ts} +1 -5
- package/dist/shared/stack.v2O65JqF.d.cts +351 -0
- package/dist/tanstack/index.cjs +2 -0
- package/dist/tanstack/index.d.cts +44 -14
- package/dist/tanstack/index.d.mts +44 -14
- package/dist/tanstack/index.d.ts +44 -14
- package/dist/tanstack/index.mjs +1 -0
- package/dist/tanstack/server.cjs +9 -0
- package/dist/tanstack/server.d.cts +15 -0
- package/dist/tanstack/server.d.mts +15 -0
- package/dist/tanstack/server.d.ts +15 -0
- package/dist/tanstack/server.mjs +7 -0
- package/package.json +203 -8
- package/src/__tests__/ai-chat-client-runtime.test.ts +481 -0
- package/src/__tests__/ai-chat-client-runtime.typecheck.tsx +130 -0
- package/src/__tests__/ai-chat-lifecycle-migrations.typecheck.ts +61 -0
- package/src/__tests__/ai-chat-query-keys.test.ts +125 -22
- package/src/__tests__/auth-provider.test.tsx +41 -314
- package/src/__tests__/auth-test-utils.ts +24 -0
- package/src/__tests__/authorization-client.test.tsx +767 -0
- package/src/__tests__/authorization-contraction.test.ts +182 -0
- package/src/__tests__/authorization-remote.test.ts +222 -0
- package/src/__tests__/authorization-server.test.ts +90 -0
- package/src/__tests__/authorization.test.ts +652 -0
- package/src/__tests__/authorization.typecheck.ts +671 -0
- package/src/__tests__/backend-plugin-factories.test.ts +54 -0
- package/src/__tests__/backend-plugin-factories.typecheck.ts +133 -0
- package/src/__tests__/client-plugin-ssr-loaders.test.ts +304 -138
- package/src/__tests__/client-runtime.test.ts +1021 -0
- package/src/__tests__/client-runtime.typecheck.ts +107 -0
- package/src/__tests__/client-stack-test-utils.ts +36 -0
- package/src/__tests__/content-lifecycle-migrations.typecheck.ts +122 -0
- package/src/__tests__/endpoint-inventory.test.ts +768 -0
- package/src/__tests__/entry-factories.test.tsx +104 -4
- package/src/__tests__/form-builder-query-keys.test.ts +32 -0
- package/src/__tests__/i18n-provider.test.tsx +4 -3
- package/src/__tests__/initial-identity-hydration.test.tsx +156 -0
- package/src/__tests__/initial-identity-layouts.test.tsx +204 -0
- package/src/__tests__/kanban-query-keys.test.ts +189 -2
- package/src/__tests__/managed-origin-hydration.browser.test.tsx +163 -0
- package/src/__tests__/media-query-keys.test.ts +91 -17
- package/src/__tests__/notify-provider.test.tsx +3 -2
- package/src/__tests__/package-metadata.test.ts +315 -0
- package/src/__tests__/page-component-overrides.test.tsx +3 -4
- package/src/__tests__/plugin-registration.test.tsx +183 -0
- package/src/__tests__/plugin-registration.typecheck.tsx +139 -0
- package/src/__tests__/plugins.test.tsx +72 -42
- package/src/__tests__/resource-factory.test.tsx +79 -2
- package/src/__tests__/resource-use-form.test.tsx +2 -2
- package/src/__tests__/resource-use-select.test.tsx +2 -4
- package/src/__tests__/router-overrides.test.tsx +20 -8
- package/src/__tests__/sitemap.test.ts +38 -22
- package/src/__tests__/stack-api.test.ts +39 -34
- package/src/__tests__/stack-auth.test.ts +44 -140
- package/src/__tests__/stack-constructors.test.ts +96 -0
- package/src/__tests__/stack-constructors.typecheck.ts +115 -0
- package/src/__tests__/use-list-state.test.tsx +7 -6
- package/src/__tests__/workflow-lifecycle-migrations.typecheck.ts +150 -0
- package/src/api/index.ts +204 -99
- package/src/authorization/client.tsx +310 -0
- package/src/authorization/index.ts +873 -0
- package/src/authorization/json.ts +70 -0
- package/src/authorization/remote.ts +234 -0
- package/src/authorization/server.ts +171 -0
- package/src/client/__tests__/server-origin.test.ts +119 -0
- package/src/client/components/compose.tsx +126 -18
- package/src/client/hooks/index.ts +12 -0
- package/src/client/hooks/use-list-state.ts +7 -13
- package/src/client/index.ts +105 -50
- package/src/client/runtime.ts +414 -0
- package/src/client/server.ts +174 -0
- package/src/context/auth.tsx +205 -154
- package/src/context/index.ts +10 -4
- package/src/context/provider.tsx +96 -57
- package/src/context/router.tsx +7 -0
- package/src/context/site-navigation.ts +52 -0
- package/src/next/index.tsx +2 -0
- package/src/next/layout.tsx +81 -0
- package/src/next/page.tsx +33 -12
- package/src/next/router.tsx +1 -1
- package/src/next/server.ts +5 -0
- package/src/plugin-registration.ts +70 -0
- package/src/plugins/ai-chat/__tests__/authorization.test.ts +2051 -0
- package/src/plugins/ai-chat/__tests__/chat-hooks.test.tsx +147 -0
- package/src/plugins/ai-chat/__tests__/chat-input-authorization.test.tsx +188 -0
- package/src/plugins/ai-chat/__tests__/client-sweep.test.tsx +1506 -34
- package/src/plugins/ai-chat/__tests__/hooks.test.tsx +131 -23
- package/src/plugins/ai-chat/api/getters.ts +2 -2
- package/src/plugins/ai-chat/api/index.ts +6 -1
- package/src/plugins/ai-chat/api/lifecycle-migrations.ts +20 -0
- package/src/plugins/ai-chat/api/operations.ts +1865 -0
- package/src/plugins/ai-chat/api/plugin.ts +78 -1168
- package/src/plugins/ai-chat/api/serializers.ts +30 -0
- package/src/plugins/ai-chat/client/components/chat-input.tsx +228 -129
- package/src/plugins/ai-chat/client/components/chat-interface.tsx +776 -183
- package/src/plugins/ai-chat/client/components/chat-layout.tsx +6 -7
- package/src/plugins/ai-chat/client/components/chat-message.tsx +1 -1
- package/src/plugins/ai-chat/client/components/chat-sidebar.tsx +57 -37
- package/src/plugins/ai-chat/client/components/pages/404-page.tsx +1 -1
- package/src/plugins/ai-chat/client/components/pages/chat-page.internal.tsx +5 -3
- package/src/plugins/ai-chat/client/components/pages/chat-page.tsx +56 -15
- package/src/plugins/ai-chat/client/components/shared/default-error.tsx +1 -1
- package/src/plugins/ai-chat/client/components/tool-call-display.tsx +1 -1
- package/src/plugins/ai-chat/client/hooks/ai-chat-resource.ts +1 -1
- package/src/plugins/ai-chat/client/hooks/chat-hooks.tsx +253 -20
- package/src/plugins/ai-chat/client/index.ts +1 -0
- package/src/plugins/ai-chat/client/navigation.ts +11 -0
- package/src/plugins/ai-chat/client/overrides.ts +47 -11
- package/src/plugins/ai-chat/client/plugin.tsx +208 -111
- package/src/plugins/ai-chat/permissions.ts +89 -0
- package/src/plugins/ai-chat/query-keys.ts +183 -25
- package/src/plugins/ai-chat/types.ts +7 -5
- package/src/plugins/api/create-endpoint.ts +40 -22
- package/src/plugins/api/endpoint-inventory.ts +206 -0
- package/src/plugins/api/index.ts +38 -4
- package/src/plugins/api/operation.ts +600 -0
- package/src/plugins/blog/__tests__/authorization.test.ts +1366 -0
- package/src/plugins/blog/__tests__/client-runtime.browser.test.tsx +257 -0
- package/src/plugins/blog/__tests__/client-runtime.test.ts +283 -0
- package/src/plugins/blog/__tests__/client-runtime.typecheck.tsx +98 -0
- package/src/plugins/blog/__tests__/client-sweep.test.tsx +212 -37
- package/src/plugins/blog/api/getters.ts +3 -3
- package/src/plugins/blog/api/index.ts +2 -0
- package/src/plugins/blog/api/lifecycle-migrations.ts +19 -0
- package/src/plugins/blog/api/mutations.ts +26 -5
- package/src/plugins/blog/api/operations.ts +727 -0
- package/src/plugins/blog/api/plugin.ts +99 -504
- package/src/plugins/blog/client/components/forms/image-field.tsx +2 -1
- package/src/plugins/blog/client/components/forms/markdown-editor-with-overrides.tsx +2 -1
- package/src/plugins/blog/client/components/forms/post-forms.tsx +61 -33
- package/src/plugins/blog/client/components/pages/404-page.tsx +3 -1
- package/src/plugins/blog/client/components/pages/edit-post-page.internal.tsx +2 -1
- package/src/plugins/blog/client/components/pages/edit-post-page.tsx +28 -5
- package/src/plugins/blog/client/components/pages/home-page.internal.tsx +2 -1
- package/src/plugins/blog/client/components/pages/home-page.tsx +7 -4
- package/src/plugins/blog/client/components/pages/new-post-page.internal.tsx +2 -1
- package/src/plugins/blog/client/components/pages/new-post-page.tsx +5 -2
- package/src/plugins/blog/client/components/pages/post-page.internal.tsx +2 -1
- package/src/plugins/blog/client/components/pages/post-page.tsx +38 -4
- package/src/plugins/blog/client/components/pages/tag-page.internal.tsx +2 -1
- package/src/plugins/blog/client/components/pages/tag-page.tsx +5 -1
- package/src/plugins/blog/client/components/shared/collapsible-tag-list.tsx +2 -1
- package/src/plugins/blog/client/components/shared/default-error.tsx +3 -1
- package/src/plugins/blog/client/components/shared/on-this-page.tsx +5 -2
- package/src/plugins/blog/client/components/shared/page-wrapper.tsx +2 -1
- package/src/plugins/blog/client/components/shared/post-card.tsx +2 -1
- package/src/plugins/blog/client/components/shared/posts-list.tsx +2 -1
- package/src/plugins/blog/client/components/shared/recent-posts-carousel.tsx +2 -1
- package/src/plugins/blog/client/components/shared/search-input.tsx +1 -1
- package/src/plugins/blog/client/constants.ts +2 -0
- package/src/plugins/blog/client/hooks/blog-resource.ts +2 -1
- package/src/plugins/blog/client/overrides.ts +1 -6
- package/src/plugins/blog/client/plugin.tsx +145 -129
- package/src/plugins/blog/permissions.ts +44 -0
- package/src/plugins/client/index.ts +108 -7
- package/src/plugins/client/resource/hooks.tsx +41 -18
- package/src/plugins/client/resource/internal.ts +77 -61
- package/src/plugins/client/resource/queries.ts +3 -4
- package/src/plugins/client/resource/use-form.ts +23 -20
- package/src/plugins/client/resource/use-select.ts +40 -34
- package/src/plugins/cms/__tests__/authorization.test.ts +2188 -0
- package/src/plugins/cms/__tests__/client-runtime.browser.test.tsx +245 -0
- package/src/plugins/cms/__tests__/client-runtime.test.ts +320 -0
- package/src/plugins/cms/__tests__/client-runtime.typecheck.tsx +208 -0
- package/src/plugins/cms/__tests__/client-sweep.test.tsx +202 -50
- package/src/plugins/cms/api/getters.ts +4 -4
- package/src/plugins/cms/api/index.ts +20 -0
- package/src/plugins/cms/api/lifecycle-migrations.ts +15 -0
- package/src/plugins/cms/api/mutations.ts +2 -2
- package/src/plugins/cms/api/operations.ts +2218 -0
- package/src/plugins/cms/api/plugin.ts +169 -1047
- package/src/plugins/cms/api/relations.ts +3 -1
- package/src/plugins/cms/client/components/forms/content-form.tsx +2 -1
- package/src/plugins/cms/client/components/forms/file-upload.tsx +3 -1
- package/src/plugins/cms/client/components/forms/relation-field.tsx +3 -1
- package/src/plugins/cms/client/components/inverse-relations-panel.tsx +29 -17
- package/src/plugins/cms/client/components/pages/404-page.tsx +7 -5
- package/src/plugins/cms/client/components/pages/content-editor-page.internal.tsx +19 -10
- package/src/plugins/cms/client/components/pages/content-editor-page.tsx +50 -12
- package/src/plugins/cms/client/components/pages/content-list-page.internal.tsx +48 -34
- package/src/plugins/cms/client/components/pages/content-list-page.tsx +8 -1
- package/src/plugins/cms/client/components/pages/dashboard-page.internal.tsx +15 -8
- package/src/plugins/cms/client/components/pages/dashboard-page.tsx +5 -1
- package/src/plugins/cms/client/components/shared/page-wrapper.tsx +2 -1
- package/src/plugins/cms/client/constants.ts +2 -0
- package/src/plugins/cms/client/hooks/cms-resource.ts +2 -1
- package/src/plugins/cms/client/index.ts +6 -1
- package/src/plugins/cms/client/overrides.ts +46 -6
- package/src/plugins/cms/client/plugin.tsx +135 -80
- package/src/plugins/cms/permissions.ts +43 -0
- package/src/plugins/cms/types.ts +174 -46
- package/src/plugins/comments/__tests__/authorization.test.ts +1570 -0
- package/src/plugins/comments/__tests__/client-runtime.browser.test.tsx +207 -0
- package/src/plugins/comments/__tests__/client-runtime.test.ts +224 -0
- package/src/plugins/comments/__tests__/client-runtime.typecheck.tsx +85 -0
- package/src/plugins/comments/__tests__/client-sweep.test.tsx +465 -79
- package/src/plugins/comments/api/getters.ts +19 -3
- package/src/plugins/comments/api/index.ts +2 -6
- package/src/plugins/comments/api/lifecycle-migrations.ts +20 -0
- package/src/plugins/comments/api/mutations.ts +261 -88
- package/src/plugins/comments/api/operations.ts +742 -0
- package/src/plugins/comments/api/plugin.ts +76 -548
- package/src/plugins/comments/client/components/comment-count.tsx +38 -5
- package/src/plugins/comments/client/components/comment-thread.tsx +154 -112
- package/src/plugins/comments/client/components/pages/moderation-page.internal.tsx +144 -78
- package/src/plugins/comments/client/components/pages/moderation-page.tsx +18 -2
- package/src/plugins/comments/client/components/pages/moderation-state.ts +13 -0
- package/src/plugins/comments/client/components/pages/my-comments-page.internal.tsx +38 -30
- package/src/plugins/comments/client/components/pages/my-comments-page.tsx +3 -1
- package/src/plugins/comments/client/components/pages/resource-comments-page.internal.tsx +29 -30
- package/src/plugins/comments/client/components/pages/resource-comments-page.tsx +10 -1
- package/src/plugins/comments/client/components/shared/page-wrapper.tsx +2 -1
- package/src/plugins/comments/client/components/shared/pagination.tsx +2 -1
- package/src/plugins/comments/client/constants.ts +2 -0
- package/src/plugins/comments/client/hooks/use-comments.tsx +430 -421
- package/src/plugins/comments/client/localization/comments-thread.ts +1 -0
- package/src/plugins/comments/client/plugin.tsx +113 -72
- package/src/plugins/comments/permissions.ts +68 -0
- package/src/plugins/comments/query-keys.ts +9 -10
- package/src/plugins/comments/schemas.ts +7 -8
- package/src/plugins/form-builder/__tests__/authorization.test.ts +1600 -0
- package/src/plugins/form-builder/__tests__/client-runtime.browser.test.tsx +255 -0
- package/src/plugins/form-builder/__tests__/client-runtime.test.ts +132 -0
- package/src/plugins/form-builder/__tests__/client-runtime.typecheck.tsx +77 -0
- package/src/plugins/form-builder/__tests__/client-sweep.test.tsx +350 -54
- package/src/plugins/form-builder/__tests__/form-renderer-authorization.test.tsx +162 -0
- package/src/plugins/form-builder/api/getters.ts +21 -5
- package/src/plugins/form-builder/api/index.ts +31 -0
- package/src/plugins/form-builder/api/lifecycle-migrations.ts +17 -0
- package/src/plugins/form-builder/api/operations.ts +1493 -0
- package/src/plugins/form-builder/api/plugin.ts +125 -632
- package/src/plugins/form-builder/api/query-key-defs.ts +7 -0
- package/src/plugins/form-builder/api/serializers.ts +1 -0
- package/src/plugins/form-builder/client/components/forms/form-renderer.tsx +49 -19
- package/src/plugins/form-builder/client/components/pages/404-page.tsx +9 -9
- package/src/plugins/form-builder/client/components/pages/form-builder-page.internal.tsx +54 -30
- package/src/plugins/form-builder/client/components/pages/form-builder-page.tsx +42 -9
- package/src/plugins/form-builder/client/components/pages/form-list-page.internal.tsx +46 -34
- package/src/plugins/form-builder/client/components/pages/form-list-page.tsx +6 -2
- package/src/plugins/form-builder/client/components/pages/submissions-page.internal.tsx +98 -64
- package/src/plugins/form-builder/client/components/pages/submissions-page.tsx +29 -9
- package/src/plugins/form-builder/client/components/shared/page-wrapper.tsx +2 -1
- package/src/plugins/form-builder/client/constants.ts +2 -0
- package/src/plugins/form-builder/client/hooks/form-builder-hooks.tsx +68 -4
- package/src/plugins/form-builder/client/hooks/form-builder-resource.ts +2 -1
- package/src/plugins/form-builder/client/hooks/index.tsx +1 -0
- package/src/plugins/form-builder/client/overrides.ts +1 -6
- package/src/plugins/form-builder/client/plugin.tsx +128 -96
- package/src/plugins/form-builder/permissions.ts +94 -0
- package/src/plugins/form-builder/query-keys.ts +28 -3
- package/src/plugins/form-builder/schemas.ts +9 -1
- package/src/plugins/form-builder/types.ts +173 -41
- package/src/plugins/kanban/__tests__/authorization.test.ts +1382 -0
- package/src/plugins/kanban/__tests__/client-runtime.browser.test.tsx +302 -0
- package/src/plugins/kanban/__tests__/client-runtime.test.ts +130 -0
- package/src/plugins/kanban/__tests__/client-runtime.typecheck.tsx +81 -0
- package/src/plugins/kanban/__tests__/client-sweep.test.tsx +418 -33
- package/src/plugins/kanban/__tests__/identity-partition.test.tsx +306 -0
- package/src/plugins/kanban/api/getters.ts +65 -50
- package/src/plugins/kanban/api/index.ts +55 -4
- package/src/plugins/kanban/api/lifecycle-migrations.ts +25 -0
- package/src/plugins/kanban/api/mutations.ts +3 -3
- package/src/plugins/kanban/api/operations.ts +2065 -0
- package/src/plugins/kanban/api/plugin.ts +83 -1013
- package/src/plugins/kanban/api/serializers.ts +26 -0
- package/src/plugins/kanban/client/components/forms/board-form.tsx +3 -1
- package/src/plugins/kanban/client/components/forms/column-form.tsx +3 -1
- package/src/plugins/kanban/client/components/forms/task-form.tsx +92 -74
- package/src/plugins/kanban/client/components/pages/404-page.tsx +6 -9
- package/src/plugins/kanban/client/components/pages/board-page.internal.tsx +57 -74
- package/src/plugins/kanban/client/components/pages/board-page.tsx +31 -7
- package/src/plugins/kanban/client/components/pages/boards-list-page.internal.tsx +54 -45
- package/src/plugins/kanban/client/components/pages/boards-list-page.tsx +2 -1
- package/src/plugins/kanban/client/components/pages/new-board-page.internal.tsx +8 -12
- package/src/plugins/kanban/client/components/pages/new-board-page.tsx +2 -1
- package/src/plugins/kanban/client/components/shared/column-content.tsx +61 -48
- package/src/plugins/kanban/client/components/shared/default-error.tsx +3 -1
- package/src/plugins/kanban/client/components/shared/kanban-board.tsx +6 -6
- package/src/plugins/kanban/client/components/shared/permission-access-any.tsx +32 -0
- package/src/plugins/kanban/client/components/shared/task-card.tsx +64 -20
- package/src/plugins/kanban/client/components/shared/user-avatar.tsx +3 -1
- package/src/plugins/kanban/client/constants.ts +2 -0
- package/src/plugins/kanban/client/hooks/kanban-hooks.tsx +55 -10
- package/src/plugins/kanban/client/hooks/kanban-resource.ts +2 -1
- package/src/plugins/kanban/client/overrides.ts +0 -5
- package/src/plugins/kanban/client/plugin.tsx +201 -113
- package/src/plugins/kanban/permissions.ts +100 -0
- package/src/plugins/kanban/query-keys.ts +61 -21
- package/src/plugins/kanban/schemas.ts +44 -18
- package/src/plugins/kanban/types.ts +381 -1
- package/src/plugins/media/__tests__/authorization.test.ts +1769 -0
- package/src/plugins/media/__tests__/client-runtime.browser.test.tsx +975 -0
- package/src/plugins/media/__tests__/client-runtime.test.ts +539 -0
- package/src/plugins/media/__tests__/client-runtime.typecheck.tsx +135 -0
- package/src/plugins/media/__tests__/client-sweep.test.tsx +292 -24
- package/src/plugins/media/__tests__/identity-partition.test.tsx +741 -0
- package/src/plugins/media/__tests__/plugin.test.ts +68 -28
- package/src/plugins/media/__tests__/query-key-defs.test.ts +32 -2
- package/src/plugins/media/api/adapters/vercel-blob.ts +84 -8
- package/src/plugins/media/api/getters.ts +6 -6
- package/src/plugins/media/api/index.ts +3 -0
- package/src/plugins/media/api/lifecycle-migrations.ts +11 -0
- package/src/plugins/media/api/mutations.ts +19 -13
- package/src/plugins/media/api/operations.ts +1873 -0
- package/src/plugins/media/api/plugin.ts +211 -899
- package/src/plugins/media/api/query-key-defs.ts +66 -4
- package/src/plugins/media/api/serializers.ts +4 -2
- package/src/plugins/media/api/storage-adapter.ts +22 -4
- package/src/plugins/media/asset-url.ts +14 -0
- package/src/plugins/media/client/components/media-picker/asset-card.tsx +105 -98
- package/src/plugins/media/client/components/media-picker/folder-tree.tsx +82 -60
- package/src/plugins/media/client/components/media-picker/index.tsx +235 -171
- package/src/plugins/media/client/components/media-picker/upload-tab.tsx +2 -10
- package/src/plugins/media/client/components/media-picker/url-tab.tsx +1 -8
- package/src/plugins/media/client/components/pages/library-page.internal.tsx +103 -82
- package/src/plugins/media/client/components/pages/library-page.tsx +4 -2
- package/src/plugins/media/client/components/upload-permission-check.tsx +75 -0
- package/src/plugins/media/client/constants.ts +2 -0
- package/src/plugins/media/client/hooks/media-resource.ts +2 -1
- package/src/plugins/media/client/hooks/use-media.tsx +292 -49
- package/src/plugins/media/client/index.ts +16 -3
- package/src/plugins/media/client/overrides.ts +6 -17
- package/src/plugins/media/client/plugin.tsx +188 -123
- package/src/plugins/media/client/upload.ts +170 -53
- package/src/plugins/media/db.ts +8 -0
- package/src/plugins/media/permissions.ts +61 -0
- package/src/plugins/media/query-keys.ts +63 -19
- package/src/plugins/media/types.ts +8 -2
- package/src/plugins/open-api/__tests__/route-introspection.test.ts +277 -0
- package/src/plugins/open-api/api/generator.ts +49 -8
- package/src/plugins/open-api/api/plugin.ts +36 -14
- package/src/plugins/route-docs/client/components/pages/docs-page.tsx +63 -23
- package/src/plugins/route-docs/client/constants.ts +2 -0
- package/src/plugins/route-docs/client/hooks.ts +23 -13
- package/src/plugins/route-docs/client/index.ts +7 -1
- package/src/plugins/route-docs/client/plugin.tsx +222 -145
- package/src/plugins/route-docs/client/schema.ts +31 -0
- package/src/plugins/route-docs/generator.ts +9 -5
- package/src/plugins/ui-builder/__tests__/client-sweep.test.tsx +427 -48
- package/src/plugins/ui-builder/client/components/page-renderer.tsx +58 -16
- package/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.tsx +47 -26
- package/src/plugins/ui-builder/client/components/pages/page-builder-page.tsx +43 -8
- package/src/plugins/ui-builder/client/components/pages/page-list-page.internal.tsx +38 -19
- package/src/plugins/ui-builder/client/components/pages/page-list-page.tsx +8 -2
- package/src/plugins/ui-builder/client/components/shared/default-error.tsx +2 -1
- package/src/plugins/ui-builder/client/components/shared/page-wrapper.tsx +2 -1
- package/src/plugins/ui-builder/client/constants.ts +2 -0
- package/src/plugins/ui-builder/client/hooks/ui-builder-resource.ts +2 -1
- package/src/plugins/ui-builder/client/index.ts +4 -1
- package/src/plugins/ui-builder/client/overrides.ts +16 -21
- package/src/plugins/ui-builder/client/plugin.tsx +119 -66
- package/src/plugins/ui-builder/client/registry.ts +3 -5
- package/src/plugins/ui-builder/types.ts +7 -4
- package/src/plugins/utils.ts +5 -1
- package/src/react-router/index.tsx +6 -0
- package/src/react-router/layout.ts +43 -0
- package/src/react-router/page.tsx +46 -17
- package/src/react-router/router.tsx +1 -1
- package/src/shared/auth-types.ts +19 -70
- package/src/shared/entry-factories.ts +12 -3
- package/src/shared/initial-identity.ts +73 -0
- package/src/shared/list-state.ts +12 -0
- package/src/shared/types.ts +1 -0
- package/src/tanstack/index.tsx +7 -0
- package/src/tanstack/layout.ts +36 -0
- package/src/tanstack/page.tsx +35 -13
- package/src/tanstack/router.tsx +1 -1
- package/src/tanstack/server.ts +18 -0
- package/src/types.ts +557 -65
- package/dist/shared/stack.80-y2TTR.d.mts +0 -840
- package/dist/shared/stack.B-hEIoUw.d.ts +0 -406
- package/dist/shared/stack.B8vdOMnQ.d.cts +0 -329
- package/dist/shared/stack.BISAZ5LX.d.mts +0 -492
- package/dist/shared/stack.BL5PvShn.d.mts +0 -193
- package/dist/shared/stack.Be1QIHEn.d.cts +0 -23
- package/dist/shared/stack.Be1QIHEn.d.mts +0 -23
- package/dist/shared/stack.Be1QIHEn.d.ts +0 -23
- package/dist/shared/stack.BjvOk_Bs.d.cts +0 -492
- package/dist/shared/stack.Bk5UB_BT.d.ts +0 -840
- package/dist/shared/stack.BozPgbrZ.d.cts +0 -201
- package/dist/shared/stack.BozPgbrZ.d.mts +0 -201
- package/dist/shared/stack.BozPgbrZ.d.ts +0 -201
- package/dist/shared/stack.BqTR6qi2.d.ts +0 -193
- package/dist/shared/stack.BvxHSZYT.d.cts +0 -406
- package/dist/shared/stack.C1ATQ3pd.d.ts +0 -416
- package/dist/shared/stack.C4_gEENS.d.cts +0 -97
- package/dist/shared/stack.C4_gEENS.d.mts +0 -97
- package/dist/shared/stack.C4_gEENS.d.ts +0 -97
- package/dist/shared/stack.C5Y5lViI.d.cts +0 -461
- package/dist/shared/stack.C8SwdUz8.d.ts +0 -461
- package/dist/shared/stack.CBsp9rDM.d.cts +0 -193
- package/dist/shared/stack.CMbX8Q5C.d.ts +0 -560
- package/dist/shared/stack.Cf-DbL1A.d.ts +0 -329
- package/dist/shared/stack.DHTvwoNG.d.mts +0 -329
- package/dist/shared/stack.DJaKVY7v.d.cts +0 -76
- package/dist/shared/stack.DJaKVY7v.d.mts +0 -76
- package/dist/shared/stack.DJaKVY7v.d.ts +0 -76
- package/dist/shared/stack.DKZMaVr6.d.cts +0 -416
- package/dist/shared/stack.DQq8DEIv.d.mts +0 -461
- package/dist/shared/stack.Dd-8shBE.d.ts +0 -492
- package/dist/shared/stack.Dj04W2c3.d.mts +0 -560
- package/dist/shared/stack.DrUBX-QE.d.cts +0 -34
- package/dist/shared/stack.DrUBX-QE.d.mts +0 -34
- package/dist/shared/stack.DrUBX-QE.d.ts +0 -34
- package/dist/shared/stack.H5B8miAV.d.cts +0 -840
- package/dist/shared/stack.aXdBOJAR.d.cts +0 -173
- package/dist/shared/stack.aXdBOJAR.d.mts +0 -173
- package/dist/shared/stack.aXdBOJAR.d.ts +0 -173
- package/dist/shared/stack.eq5eg1yt.d.cts +0 -560
- package/dist/shared/stack.f8Vke-eH.d.mts +0 -406
- package/dist/shared/stack.oBokjN_J.d.mts +0 -416
- package/dist/shared/{stack.B0muOwUF.d.cts → stack.Csi-4Mgz.d.cts} +8 -8
- package/dist/shared/{stack.B0muOwUF.d.mts → stack.Csi-4Mgz.d.mts} +8 -8
- package/dist/shared/{stack.B0muOwUF.d.ts → stack.Csi-4Mgz.d.ts} +8 -8
|
@@ -1,972 +1,284 @@
|
|
|
1
1
|
import type { DBAdapter as Adapter } from "@btst/db";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
createEndpoint,
|
|
4
|
+
defineBackendPlugin,
|
|
5
|
+
type OperationData,
|
|
6
|
+
} from "@btst/stack/plugins/api";
|
|
7
|
+
import type { QueryClient } from "@tanstack/react-query";
|
|
4
8
|
import { mediaSchema as dbSchema } from "../db";
|
|
5
|
-
import type { Asset, Folder } from "../types";
|
|
6
9
|
import {
|
|
7
10
|
AssetListQuerySchema,
|
|
8
11
|
FolderListQuerySchema,
|
|
9
12
|
createAssetSchema,
|
|
10
|
-
updateAssetSchema,
|
|
11
13
|
createFolderSchema,
|
|
14
|
+
updateAssetSchema,
|
|
12
15
|
uploadTokenRequestSchema,
|
|
13
16
|
} from "../schemas";
|
|
17
|
+
import { listAssets, listFolders } from "./getters";
|
|
14
18
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} from "./
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (/^[a-z][a-z\d+.-]*:\/\//i.test(trimmedPrefix)) {
|
|
49
|
-
if (trimmedPrefix.endsWith("://")) {
|
|
50
|
-
return url.startsWith(trimmedPrefix);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const normalizedPrefix = trimmedPrefix.replace(/\/+$/, "");
|
|
54
|
-
return url === normalizedPrefix || url.startsWith(`${normalizedPrefix}/`);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const normalizedPrefix = `${trimmedPrefix.replace(/\/+$/, "")}/`;
|
|
58
|
-
return url.startsWith(normalizedPrefix);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Context passed to media API hooks.
|
|
63
|
-
*/
|
|
64
|
-
export interface MediaApiContext<
|
|
65
|
-
TBody = unknown,
|
|
66
|
-
TParams = unknown,
|
|
67
|
-
TQuery = unknown,
|
|
68
|
-
> {
|
|
69
|
-
body?: TBody;
|
|
70
|
-
params?: TParams;
|
|
71
|
-
query?: TQuery;
|
|
72
|
-
request?: Request;
|
|
73
|
-
headers?: Headers;
|
|
74
|
-
[key: string]: unknown;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Configuration hooks for the media backend plugin.
|
|
79
|
-
* All hooks are optional and allow consumers to customise behaviour.
|
|
80
|
-
*/
|
|
81
|
-
export interface MediaBackendHooks {
|
|
82
|
-
/**
|
|
83
|
-
* Called before a file upload is allowed (both direct and signed adapters).
|
|
84
|
-
* Throw an Error to reject the upload (e.g. if the user is not authenticated).
|
|
85
|
-
*/
|
|
86
|
-
onBeforeUpload?: (
|
|
87
|
-
meta: { filename: string; mimeType: string; size?: number },
|
|
88
|
-
context: MediaApiContext,
|
|
89
|
-
) => Promise<void> | void;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Called after an asset record is created in the database.
|
|
93
|
-
*/
|
|
94
|
-
onAfterUpload?: (
|
|
95
|
-
asset: Asset,
|
|
96
|
-
context: MediaApiContext,
|
|
97
|
-
) => Promise<void> | void;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Called before an asset is deleted. Throw to prevent deletion.
|
|
101
|
-
*/
|
|
102
|
-
onBeforeDelete?: (
|
|
103
|
-
asset: Asset,
|
|
104
|
-
context: MediaApiContext,
|
|
105
|
-
) => Promise<void> | void;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Called after an asset has been deleted from the DB and storage.
|
|
109
|
-
*/
|
|
110
|
-
onAfterDelete?: (
|
|
111
|
-
assetId: string,
|
|
112
|
-
context: MediaApiContext,
|
|
113
|
-
) => Promise<void> | void;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Called before listing assets. Throw to deny access.
|
|
117
|
-
*/
|
|
118
|
-
onBeforeListAssets?: (
|
|
119
|
-
filter: z.infer<typeof AssetListQuerySchema>,
|
|
120
|
-
context: MediaApiContext,
|
|
121
|
-
) => Promise<void> | void;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Called before updating an asset (PATCH). Throw to deny access.
|
|
125
|
-
*/
|
|
126
|
-
onBeforeUpdateAsset?: (
|
|
127
|
-
asset: Asset,
|
|
128
|
-
updates: z.infer<typeof updateAssetSchema>,
|
|
129
|
-
context: MediaApiContext,
|
|
130
|
-
) => Promise<void> | void;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Called before listing folders. Throw to deny access.
|
|
134
|
-
*/
|
|
135
|
-
onBeforeListFolders?: (
|
|
136
|
-
filter: { parentId?: string | null },
|
|
137
|
-
context: MediaApiContext,
|
|
138
|
-
) => Promise<void> | void;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Called before creating a folder. Throw to deny access.
|
|
142
|
-
*/
|
|
143
|
-
onBeforeCreateFolder?: (
|
|
144
|
-
input: z.infer<typeof createFolderSchema>,
|
|
145
|
-
context: MediaApiContext,
|
|
146
|
-
) => Promise<void> | void;
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Called before deleting a folder. Throw to deny access.
|
|
150
|
-
*/
|
|
151
|
-
onBeforeDeleteFolder?: (
|
|
152
|
-
folder: Folder,
|
|
153
|
-
context: MediaApiContext,
|
|
154
|
-
) => Promise<void> | void;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Configuration for the media backend plugin.
|
|
159
|
-
*/
|
|
19
|
+
FolderListOperationInputSchema,
|
|
20
|
+
MediaOperationError,
|
|
21
|
+
createMediaOperations,
|
|
22
|
+
type MediaBackendHooks,
|
|
23
|
+
type MediaOperationsConfig,
|
|
24
|
+
} from "./operations";
|
|
25
|
+
import { MEDIA_QUERY_KEYS } from "./query-key-defs";
|
|
26
|
+
import { serializeAsset, serializeFolder } from "./serializers";
|
|
27
|
+
import type { StorageAdapter } from "./storage-adapter";
|
|
28
|
+
import { resolveMediaAsset } from "../asset-url";
|
|
29
|
+
import type { MediaEndpointPartition } from "./query-key-defs";
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
AssetIdOperationInputSchema,
|
|
33
|
+
DirectUploadOperationInputSchema,
|
|
34
|
+
FolderIdOperationInputSchema,
|
|
35
|
+
FolderListOperationInputSchema,
|
|
36
|
+
UpdateAssetOperationInputSchema,
|
|
37
|
+
VercelBlobOperationInputSchema,
|
|
38
|
+
MediaOperationError,
|
|
39
|
+
} from "./operations";
|
|
40
|
+
export type {
|
|
41
|
+
MediaApiContext,
|
|
42
|
+
MediaApiResultContext,
|
|
43
|
+
MediaBackendHooks,
|
|
44
|
+
MediaOperationHookContext,
|
|
45
|
+
MediaOperations,
|
|
46
|
+
MediaUploadOperationInput,
|
|
47
|
+
MediaUploadResultOperationInput,
|
|
48
|
+
} from "./operations";
|
|
49
|
+
|
|
50
|
+
/** Configuration for the Media backend plugin. */
|
|
160
51
|
export interface MediaBackendConfig {
|
|
161
|
-
/**
|
|
162
|
-
* The storage adapter to use for file uploads.
|
|
163
|
-
* - `localAdapter()` — writes to the local filesystem (dev / self-hosted)
|
|
164
|
-
* - `s3Adapter()` — presigned PUT URL (AWS S3, Cloudflare R2, MinIO)
|
|
165
|
-
* - `vercelBlobAdapter()` — signed direct upload via Vercel Blob
|
|
166
|
-
*/
|
|
52
|
+
/** Storage implementation used for upload initialization, writes, and cleanup. */
|
|
167
53
|
storageAdapter: StorageAdapter;
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Maximum file size in bytes.
|
|
171
|
-
* Enforced server-side for `localAdapter`.
|
|
172
|
-
* Passed into the Vercel Blob token for edge enforcement.
|
|
173
|
-
* Validated against the client-reported size for `s3Adapter`.
|
|
174
|
-
* @default 10485760 (10 MB)
|
|
175
|
-
*/
|
|
54
|
+
/** Maximum accepted upload size. @default 10485760 */
|
|
176
55
|
maxFileSizeBytes?: number;
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* MIME type allowlist (e.g. `["image/jpeg", "image/png"]`).
|
|
180
|
-
* If omitted, all MIME types are accepted.
|
|
181
|
-
* Enforced server-side for `localAdapter`.
|
|
182
|
-
* Passed to Vercel Blob token for edge enforcement.
|
|
183
|
-
* Validated against the client-reported MIME type for `s3Adapter`.
|
|
184
|
-
*/
|
|
56
|
+
/** Optional MIME allowlist, including wildcard forms such as `image/*`. */
|
|
185
57
|
allowedMimeTypes?: string[];
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* URL prefixes that are allowed when creating asset records via `POST /media/assets`.
|
|
189
|
-
* When omitted the plugin automatically derives a safe default from the storage adapter:
|
|
190
|
-
* - `s3Adapter` → the configured `publicBaseUrl`
|
|
191
|
-
* - `vercelBlobAdapter` → any URL whose hostname ends with `.public.blob.vercel-storage.com`
|
|
192
|
-
* - `localAdapter` → rejects client-supplied URLs; use `POST /media/upload` instead
|
|
193
|
-
*
|
|
194
|
-
* Provide this option only when you need to override the automatic default (e.g. to allow
|
|
195
|
-
* assets from a CDN in front of your storage that uses a different domain). When using
|
|
196
|
-
* `localAdapter`, setting `allowedUrlPrefixes` explicitly opts `POST /media/assets` back in.
|
|
197
|
-
*
|
|
198
|
-
* @remarks
|
|
199
|
-
* Protocol-only prefixes such as `"https://"` (and especially `"http://"`) disable
|
|
200
|
-
* origin-based restrictions entirely — any URL with that scheme will be accepted.
|
|
201
|
-
* Only use them when you intentionally want to allow assets from arbitrary hosts:
|
|
202
|
-
* `"http://"` URLs will be blocked as mixed content on HTTPS pages, and if your
|
|
203
|
-
* `onAfterUpload` hook fetches asset URLs server-side, accepting arbitrary hosts
|
|
204
|
-
* can expose an SSRF surface. Prefer full origin prefixes like
|
|
205
|
-
* `"https://cdn.example.com"` whenever possible.
|
|
206
|
-
*/
|
|
58
|
+
/** Trusted URL prefixes accepted by asset finalization/registration. */
|
|
207
59
|
allowedUrlPrefixes?: string[];
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Optional lifecycle hooks for the media backend plugin.
|
|
211
|
-
*/
|
|
60
|
+
/** Post-authorization domain lifecycle hooks. */
|
|
212
61
|
hooks?: MediaBackendHooks;
|
|
213
|
-
|
|
214
62
|
/**
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* When provided, all asset and folder list/create operations through the HTTP
|
|
218
|
-
* API are automatically scoped to the returned tenant ID:
|
|
219
|
-
* - GET /media/assets → filters results to the resolved tenant
|
|
220
|
-
* - POST /media/assets → tags the created asset with the resolved tenant
|
|
221
|
-
* - POST /media/upload → tags the uploaded asset with the resolved tenant
|
|
222
|
-
* - GET /media/folders → filters results to the resolved tenant
|
|
223
|
-
* - POST /media/folders → tags the created folder with the resolved tenant
|
|
224
|
-
*
|
|
225
|
-
* When absent, no tenant filtering is applied (existing behaviour).
|
|
226
|
-
*
|
|
227
|
-
* Returning `null` or `undefined` means "no tenant" for this request —
|
|
228
|
-
* the operation proceeds without tenant scoping (useful for super-admin routes).
|
|
63
|
+
* Server-only collection scope resolver. Its result is never accepted from a
|
|
64
|
+
* browser and remains separate from boolean authorization rules.
|
|
229
65
|
*/
|
|
230
|
-
resolveTenantId?:
|
|
231
|
-
|
|
232
|
-
|
|
66
|
+
resolveTenantId?: MediaOperationsConfig["resolveTenantId"];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Raw route key exposed only on `stack.raw.media`. */
|
|
70
|
+
export type MediaRouteKey = "library";
|
|
71
|
+
|
|
72
|
+
interface MediaPrefetchForRoute {
|
|
73
|
+
(
|
|
74
|
+
key: "library",
|
|
75
|
+
queryClient: QueryClient,
|
|
76
|
+
endpoint: MediaEndpointPartition,
|
|
77
|
+
): Promise<void>;
|
|
233
78
|
}
|
|
234
79
|
|
|
235
80
|
/**
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
* @example
|
|
241
|
-
* ```ts
|
|
242
|
-
* import { mediaBackendPlugin, localAdapter } from "@btst/stack/plugins/media/api";
|
|
243
|
-
*
|
|
244
|
-
* mediaBackendPlugin({
|
|
245
|
-
* storageAdapter: localAdapter(),
|
|
246
|
-
* hooks: {
|
|
247
|
-
* onBeforeUpload: async (_meta, ctx) => {
|
|
248
|
-
* const session = await getSession(ctx.headers as Headers);
|
|
249
|
-
* if (!session) throw new Error("Unauthorized");
|
|
250
|
-
* },
|
|
251
|
-
* },
|
|
252
|
-
* })
|
|
253
|
-
* ```
|
|
81
|
+
* Raw SSG prefetch. It bypasses request authorization and is never
|
|
82
|
+
* reachable through HTTP or `forRequest()`. Protect generated output at the
|
|
83
|
+
* deployment boundary when the Media library is not public.
|
|
254
84
|
*/
|
|
85
|
+
function createMediaPrefetchForRoute(adapter: Adapter): MediaPrefetchForRoute {
|
|
86
|
+
return async (_key, queryClient, endpoint) => {
|
|
87
|
+
const [assets, folders] = await Promise.all([
|
|
88
|
+
listAssets(adapter, { limit: 40 }),
|
|
89
|
+
listFolders(adapter),
|
|
90
|
+
]);
|
|
91
|
+
queryClient.setQueryData(
|
|
92
|
+
MEDIA_QUERY_KEYS.assetsList({ limit: 40 }, undefined, endpoint),
|
|
93
|
+
{
|
|
94
|
+
pages: [
|
|
95
|
+
{
|
|
96
|
+
...assets,
|
|
97
|
+
items: assets.items.map((asset) => {
|
|
98
|
+
const { tenantId: _tenantId, ...safe } = serializeAsset(asset);
|
|
99
|
+
return resolveMediaAsset(safe, endpoint.baseURL);
|
|
100
|
+
}),
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
pageParams: [0],
|
|
104
|
+
},
|
|
105
|
+
);
|
|
106
|
+
queryClient.setQueryData(
|
|
107
|
+
MEDIA_QUERY_KEYS.foldersList(undefined, undefined, endpoint),
|
|
108
|
+
folders.map((folder) => {
|
|
109
|
+
const { tenantId: _tenantId, ...safe } = serializeFolder(folder);
|
|
110
|
+
return safe;
|
|
111
|
+
}),
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function parseMultipartFile(body: unknown) {
|
|
117
|
+
if (!body || typeof body !== "object") {
|
|
118
|
+
throw new MediaOperationError(
|
|
119
|
+
400,
|
|
120
|
+
"Expected multipart/form-data request body",
|
|
121
|
+
"INVALID_UPLOAD_BODY",
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
const record = body as Record<string, unknown>;
|
|
125
|
+
const file = record.file as Record<string, unknown> | undefined;
|
|
126
|
+
if (!file || typeof file.arrayBuffer !== "function") {
|
|
127
|
+
throw new MediaOperationError(
|
|
128
|
+
400,
|
|
129
|
+
"Missing 'file' field in form data",
|
|
130
|
+
"MISSING_UPLOAD_FILE",
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
if (typeof file.size !== "number" || file.size < 0) {
|
|
134
|
+
throw new MediaOperationError(
|
|
135
|
+
400,
|
|
136
|
+
"File 'size' is missing or invalid",
|
|
137
|
+
"INVALID_UPLOAD_FILE",
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
if (typeof file.name !== "string" || !file.name) {
|
|
141
|
+
throw new MediaOperationError(
|
|
142
|
+
400,
|
|
143
|
+
"File 'name' is missing or invalid",
|
|
144
|
+
"INVALID_UPLOAD_FILE",
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
if (typeof file.type !== "string") {
|
|
148
|
+
throw new MediaOperationError(
|
|
149
|
+
400,
|
|
150
|
+
"File 'type' is missing or invalid",
|
|
151
|
+
"INVALID_UPLOAD_FILE",
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
file: file as unknown as Pick<
|
|
156
|
+
File,
|
|
157
|
+
"name" | "type" | "size" | "arrayBuffer"
|
|
158
|
+
>,
|
|
159
|
+
folderId:
|
|
160
|
+
typeof record.folderId === "string" && record.folderId
|
|
161
|
+
? record.folderId
|
|
162
|
+
: undefined,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Media backend plugin backed by one operation inventory. */
|
|
255
167
|
export const mediaBackendPlugin = (config: MediaBackendConfig) =>
|
|
256
168
|
defineBackendPlugin({
|
|
257
|
-
|
|
258
|
-
|
|
169
|
+
id: "media",
|
|
259
170
|
dbPlugin: dbSchema,
|
|
171
|
+
operations: (adapter: Adapter) => createMediaOperations(adapter, config),
|
|
260
172
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
getAssetById: (id: string) => getAssetById(adapter, id),
|
|
265
|
-
createAsset: (input: Parameters<typeof createAsset>[1]) =>
|
|
266
|
-
createAsset(adapter, input),
|
|
267
|
-
updateAsset: (id: string, input: Parameters<typeof updateAsset>[2]) =>
|
|
268
|
-
updateAsset(adapter, id, input),
|
|
269
|
-
listFolders: (params?: Parameters<typeof listFolders>[1]) =>
|
|
270
|
-
listFolders(adapter, params),
|
|
271
|
-
getFolderById: (id: string) => getFolderById(adapter, id),
|
|
272
|
-
getFolderByName: (
|
|
273
|
-
name: string,
|
|
274
|
-
parentId?: string | null,
|
|
275
|
-
tenantId?: string,
|
|
276
|
-
) => getFolderByName(adapter, name, parentId, tenantId),
|
|
277
|
-
createFolder: (input: Parameters<typeof createFolder>[1]) =>
|
|
278
|
-
createFolder(adapter, input),
|
|
173
|
+
/** Lower-level SSG helper that intentionally bypasses auth and hooks. */
|
|
174
|
+
raw: (adapter: Adapter) => ({
|
|
175
|
+
prefetchForRoute: createMediaPrefetchForRoute(adapter),
|
|
279
176
|
}),
|
|
280
177
|
|
|
281
|
-
routes: (
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
return mimeType === pattern;
|
|
298
|
-
});
|
|
299
|
-
if (!allowed) {
|
|
300
|
-
throw ctx.error(415, {
|
|
301
|
-
message: `MIME type '${mimeType}' is not allowed. Allowed: ${allowedMimeTypes.join(", ")}`,
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// ── Asset endpoints ────────────────────────────────────────────────────
|
|
308
|
-
|
|
178
|
+
routes: (_adapter: Adapter, _context, operations) => {
|
|
179
|
+
// Keep the transport boundary shallow; expanding the generated route
|
|
180
|
+
// handler type exceeds TypeScript's limit for the nested Vercel body union.
|
|
181
|
+
const bindVercelBlobRoute = operations.uploadVercelBlob
|
|
182
|
+
.route as unknown as (
|
|
183
|
+
resolveInput: (ctx: {
|
|
184
|
+
body: unknown;
|
|
185
|
+
request: Request;
|
|
186
|
+
error: (...args: any[]) => Error;
|
|
187
|
+
}) => Promise<{ body: unknown }>,
|
|
188
|
+
) => (ctx: {
|
|
189
|
+
body: unknown;
|
|
190
|
+
request: Request;
|
|
191
|
+
error: (...args: any[]) => Error;
|
|
192
|
+
}) => Promise<OperationData>;
|
|
309
193
|
const listAssetsEndpoint = createEndpoint(
|
|
310
194
|
"/media/assets",
|
|
311
|
-
{
|
|
312
|
-
|
|
313
|
-
query: AssetListQuerySchema,
|
|
314
|
-
},
|
|
315
|
-
async (ctx) => {
|
|
316
|
-
const { query, headers } = ctx;
|
|
317
|
-
const context: MediaApiContext = { query, headers };
|
|
318
|
-
|
|
319
|
-
const tenantId = resolveTenantId
|
|
320
|
-
? ((await resolveTenantId(context)) ?? undefined)
|
|
321
|
-
: undefined;
|
|
322
|
-
|
|
323
|
-
if (hooks?.onBeforeListAssets) {
|
|
324
|
-
await runHook(
|
|
325
|
-
() => hooks.onBeforeListAssets!(query, context),
|
|
326
|
-
ctx.error,
|
|
327
|
-
"Unauthorized: Cannot list assets",
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return listAssets(adapter, { ...query, tenantId });
|
|
332
|
-
},
|
|
195
|
+
{ method: "GET", query: AssetListQuerySchema, requireRequest: true },
|
|
196
|
+
operations.listAssets.route((ctx) => ctx.query),
|
|
333
197
|
);
|
|
334
|
-
|
|
335
198
|
const createAssetEndpoint = createEndpoint(
|
|
336
199
|
"/media/assets",
|
|
337
|
-
{
|
|
338
|
-
|
|
339
|
-
body: createAssetSchema,
|
|
340
|
-
},
|
|
341
|
-
async (ctx) => {
|
|
342
|
-
const context: MediaApiContext = {
|
|
343
|
-
body: ctx.body,
|
|
344
|
-
headers: ctx.headers,
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
const tenantId = resolveTenantId
|
|
348
|
-
? ((await resolveTenantId(context)) ?? undefined)
|
|
349
|
-
: undefined;
|
|
350
|
-
|
|
351
|
-
if (hooks?.onBeforeUpload) {
|
|
352
|
-
await runHook(
|
|
353
|
-
() =>
|
|
354
|
-
hooks.onBeforeUpload!(
|
|
355
|
-
{
|
|
356
|
-
filename: ctx.body.filename,
|
|
357
|
-
mimeType: ctx.body.mimeType,
|
|
358
|
-
size: ctx.body.size,
|
|
359
|
-
},
|
|
360
|
-
context,
|
|
361
|
-
),
|
|
362
|
-
ctx.error,
|
|
363
|
-
"Unauthorized: Cannot upload asset",
|
|
364
|
-
);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
validateMimeType(ctx.body.mimeType, ctx);
|
|
368
|
-
|
|
369
|
-
if (ctx.body.size > maxFileSizeBytes) {
|
|
370
|
-
throw ctx.error(413, {
|
|
371
|
-
message: `File size ${ctx.body.size} bytes exceeds the limit of ${maxFileSizeBytes} bytes`,
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
{
|
|
376
|
-
const url = ctx.body.url;
|
|
377
|
-
let urlAllowed = true;
|
|
378
|
-
let denialReason = "";
|
|
379
|
-
|
|
380
|
-
if (allowedUrlPrefixes && allowedUrlPrefixes.length > 0) {
|
|
381
|
-
// Consumer-supplied override — validate against explicit list.
|
|
382
|
-
urlAllowed = allowedUrlPrefixes.some((p) =>
|
|
383
|
-
matchesUrlPrefix(url, p),
|
|
384
|
-
);
|
|
385
|
-
denialReason = `URL must start with one of: ${allowedUrlPrefixes.join(", ")}`;
|
|
386
|
-
} else if (isDirectAdapter(storageAdapter)) {
|
|
387
|
-
// localAdapter writes files server-side via POST /media/upload and returns
|
|
388
|
-
// relative URLs. Reject client-supplied asset URLs unless the consumer
|
|
389
|
-
// explicitly opts into trusted prefixes via allowedUrlPrefixes.
|
|
390
|
-
urlAllowed = false;
|
|
391
|
-
denialReason =
|
|
392
|
-
"Client-supplied asset URLs are not allowed with localAdapter. Use POST /media/upload instead, or configure allowedUrlPrefixes to explicitly allow trusted URL prefixes.";
|
|
393
|
-
} else if (isS3Adapter(storageAdapter)) {
|
|
394
|
-
// Auto-derived from s3Adapter's publicBaseUrl.
|
|
395
|
-
urlAllowed = matchesUrlPrefix(url, storageAdapter.urlPrefix);
|
|
396
|
-
denialReason = `URL must start with the configured S3 publicBaseUrl: ${storageAdapter.urlPrefix}`;
|
|
397
|
-
} else if (isVercelBlobAdapter(storageAdapter)) {
|
|
398
|
-
// Vercel Blob public URLs always belong to a known CDN hostname suffix.
|
|
399
|
-
try {
|
|
400
|
-
const hostname = new URL(url).hostname;
|
|
401
|
-
urlAllowed = hostname.endsWith(
|
|
402
|
-
storageAdapter.urlHostnameSuffix,
|
|
403
|
-
);
|
|
404
|
-
} catch {
|
|
405
|
-
urlAllowed = false;
|
|
406
|
-
}
|
|
407
|
-
denialReason = `URL hostname must end with ${storageAdapter.urlHostnameSuffix}`;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
if (!urlAllowed) {
|
|
411
|
-
throw ctx.error(400, { message: denialReason });
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
if (ctx.body.folderId) {
|
|
416
|
-
const folder = await getFolderById(adapter, ctx.body.folderId);
|
|
417
|
-
if (!folder) {
|
|
418
|
-
throw ctx.error(404, { message: "Folder not found" });
|
|
419
|
-
}
|
|
420
|
-
if (tenantId !== undefined && folder.tenantId !== tenantId) {
|
|
421
|
-
throw ctx.error(404, { message: "Folder not found" });
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
const asset = await createAsset(adapter, { ...ctx.body, tenantId });
|
|
426
|
-
|
|
427
|
-
if (hooks?.onAfterUpload) {
|
|
428
|
-
await hooks.onAfterUpload(asset, context);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
return asset;
|
|
432
|
-
},
|
|
200
|
+
{ method: "POST", body: createAssetSchema, requireRequest: true },
|
|
201
|
+
operations.createAsset.route((ctx) => ctx.body),
|
|
433
202
|
);
|
|
434
|
-
|
|
435
203
|
const updateAssetEndpoint = createEndpoint(
|
|
436
204
|
"/media/assets/:id",
|
|
437
|
-
{
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
const existing = await getAssetById(adapter, ctx.params.id);
|
|
443
|
-
if (!existing) {
|
|
444
|
-
throw ctx.error(404, { message: "Asset not found" });
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
const context: MediaApiContext = {
|
|
448
|
-
body: ctx.body,
|
|
449
|
-
params: ctx.params,
|
|
450
|
-
headers: ctx.headers,
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
const tenantId = resolveTenantId
|
|
454
|
-
? ((await resolveTenantId(context)) ?? undefined)
|
|
455
|
-
: undefined;
|
|
456
|
-
|
|
457
|
-
if (tenantId !== undefined && existing.tenantId !== tenantId) {
|
|
458
|
-
throw ctx.error(404, { message: "Asset not found" });
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
if (hooks?.onBeforeUpdateAsset) {
|
|
462
|
-
await runHook(
|
|
463
|
-
() => hooks.onBeforeUpdateAsset!(existing, ctx.body, context),
|
|
464
|
-
ctx.error,
|
|
465
|
-
"Unauthorized: Cannot update asset",
|
|
466
|
-
);
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
if (ctx.body.folderId != null) {
|
|
470
|
-
const folder = await getFolderById(adapter, ctx.body.folderId);
|
|
471
|
-
if (!folder) {
|
|
472
|
-
throw ctx.error(404, { message: "Folder not found" });
|
|
473
|
-
}
|
|
474
|
-
if (tenantId !== undefined && folder.tenantId !== tenantId) {
|
|
475
|
-
throw ctx.error(404, { message: "Folder not found" });
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
const updated = await updateAsset(adapter, ctx.params.id, ctx.body);
|
|
480
|
-
if (!updated) {
|
|
481
|
-
throw ctx.error(404, { message: "Asset not found" });
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
return updated;
|
|
485
|
-
},
|
|
205
|
+
{ method: "PATCH", body: updateAssetSchema, requireRequest: true },
|
|
206
|
+
operations.updateAsset.route((ctx) => ({
|
|
207
|
+
id: ctx.params.id,
|
|
208
|
+
data: ctx.body,
|
|
209
|
+
})),
|
|
486
210
|
);
|
|
487
|
-
|
|
488
211
|
const deleteAssetEndpoint = createEndpoint(
|
|
489
212
|
"/media/assets/:id",
|
|
490
|
-
{
|
|
491
|
-
|
|
492
|
-
},
|
|
493
|
-
async (ctx) => {
|
|
494
|
-
const context: MediaApiContext = {
|
|
495
|
-
params: ctx.params,
|
|
496
|
-
headers: ctx.headers,
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
const tenantId = resolveTenantId
|
|
500
|
-
? ((await resolveTenantId(context)) ?? undefined)
|
|
501
|
-
: undefined;
|
|
502
|
-
|
|
503
|
-
const asset = await getAssetById(adapter, ctx.params.id);
|
|
504
|
-
if (!asset) {
|
|
505
|
-
throw ctx.error(404, { message: "Asset not found" });
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
if (tenantId !== undefined && asset.tenantId !== tenantId) {
|
|
509
|
-
throw ctx.error(404, { message: "Asset not found" });
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
if (hooks?.onBeforeDelete) {
|
|
513
|
-
await runHook(
|
|
514
|
-
() => hooks.onBeforeDelete!(asset, context),
|
|
515
|
-
ctx.error,
|
|
516
|
-
"Unauthorized: Cannot delete asset",
|
|
517
|
-
);
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
// Delete the storage file FIRST — if this fails the DB record is
|
|
521
|
-
// still intact and the deletion can be retried. Removing the DB
|
|
522
|
-
// record first would silently orphan the file in storage with no
|
|
523
|
-
// way to track or clean it up.
|
|
524
|
-
try {
|
|
525
|
-
await storageAdapter.delete(asset.url);
|
|
526
|
-
} catch (err) {
|
|
527
|
-
console.error(
|
|
528
|
-
`[btst/media] Failed to delete file from storage: ${asset.url}`,
|
|
529
|
-
err,
|
|
530
|
-
);
|
|
531
|
-
throw ctx.error(500, {
|
|
532
|
-
message: "Failed to delete file from storage",
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
await deleteAsset(adapter, ctx.params.id);
|
|
537
|
-
|
|
538
|
-
if (hooks?.onAfterDelete) {
|
|
539
|
-
await hooks.onAfterDelete(ctx.params.id, context);
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
return { success: true };
|
|
543
|
-
},
|
|
213
|
+
{ method: "DELETE", requireRequest: true },
|
|
214
|
+
operations.deleteAsset.route((ctx) => ({ id: ctx.params.id })),
|
|
544
215
|
);
|
|
545
|
-
|
|
546
|
-
// ── Folder endpoints ────────────────────────────────────────────────────
|
|
547
|
-
|
|
548
216
|
const listFoldersEndpoint = createEndpoint(
|
|
549
217
|
"/media/folders",
|
|
550
|
-
{
|
|
551
|
-
|
|
552
|
-
query
|
|
553
|
-
|
|
554
|
-
async (ctx) => {
|
|
555
|
-
const filter = { parentId: ctx.query.parentId };
|
|
556
|
-
const context: MediaApiContext = {
|
|
557
|
-
query: ctx.query,
|
|
558
|
-
headers: ctx.headers,
|
|
559
|
-
};
|
|
560
|
-
|
|
561
|
-
const tenantId = resolveTenantId
|
|
562
|
-
? ((await resolveTenantId(context)) ?? undefined)
|
|
563
|
-
: undefined;
|
|
564
|
-
|
|
565
|
-
if (hooks?.onBeforeListFolders) {
|
|
566
|
-
await runHook(
|
|
567
|
-
() => hooks.onBeforeListFolders!(filter, context),
|
|
568
|
-
ctx.error,
|
|
569
|
-
"Unauthorized: Cannot list folders",
|
|
570
|
-
);
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
return listFolders(adapter, { ...filter, tenantId });
|
|
574
|
-
},
|
|
218
|
+
{ method: "GET", query: FolderListQuerySchema, requireRequest: true },
|
|
219
|
+
operations.listFolders.route((ctx) =>
|
|
220
|
+
FolderListOperationInputSchema.parse(ctx.query),
|
|
221
|
+
),
|
|
575
222
|
);
|
|
576
|
-
|
|
577
223
|
const createFolderEndpoint = createEndpoint(
|
|
578
224
|
"/media/folders",
|
|
579
|
-
{
|
|
580
|
-
|
|
581
|
-
body: createFolderSchema,
|
|
582
|
-
},
|
|
583
|
-
async (ctx) => {
|
|
584
|
-
const context: MediaApiContext = {
|
|
585
|
-
body: ctx.body,
|
|
586
|
-
headers: ctx.headers,
|
|
587
|
-
};
|
|
588
|
-
|
|
589
|
-
const tenantId = resolveTenantId
|
|
590
|
-
? ((await resolveTenantId(context)) ?? undefined)
|
|
591
|
-
: undefined;
|
|
592
|
-
|
|
593
|
-
if (hooks?.onBeforeCreateFolder) {
|
|
594
|
-
await runHook(
|
|
595
|
-
() => hooks.onBeforeCreateFolder!(ctx.body, context),
|
|
596
|
-
ctx.error,
|
|
597
|
-
"Unauthorized: Cannot create folder",
|
|
598
|
-
);
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
if (ctx.body.parentId) {
|
|
602
|
-
const folder = await getFolderById(adapter, ctx.body.parentId);
|
|
603
|
-
if (!folder) {
|
|
604
|
-
throw ctx.error(404, { message: "Folder not found" });
|
|
605
|
-
}
|
|
606
|
-
if (tenantId !== undefined && folder.tenantId !== tenantId) {
|
|
607
|
-
throw ctx.error(404, { message: "Folder not found" });
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
return createFolder(adapter, { ...ctx.body, tenantId });
|
|
612
|
-
},
|
|
225
|
+
{ method: "POST", body: createFolderSchema, requireRequest: true },
|
|
226
|
+
operations.createFolder.route((ctx) => ctx.body),
|
|
613
227
|
);
|
|
614
|
-
|
|
615
228
|
const deleteFolderEndpoint = createEndpoint(
|
|
616
229
|
"/media/folders/:id",
|
|
617
|
-
{
|
|
618
|
-
|
|
619
|
-
},
|
|
620
|
-
async (ctx) => {
|
|
621
|
-
const context: MediaApiContext = {
|
|
622
|
-
params: ctx.params,
|
|
623
|
-
headers: ctx.headers,
|
|
624
|
-
};
|
|
625
|
-
|
|
626
|
-
const tenantId = resolveTenantId
|
|
627
|
-
? ((await resolveTenantId(context)) ?? undefined)
|
|
628
|
-
: undefined;
|
|
629
|
-
|
|
630
|
-
const folder = await getFolderById(adapter, ctx.params.id);
|
|
631
|
-
if (!folder) {
|
|
632
|
-
throw ctx.error(404, { message: "Folder not found" });
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
if (tenantId !== undefined && folder.tenantId !== tenantId) {
|
|
636
|
-
throw ctx.error(404, { message: "Folder not found" });
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
if (hooks?.onBeforeDeleteFolder) {
|
|
640
|
-
await runHook(
|
|
641
|
-
() => hooks.onBeforeDeleteFolder!(folder, context),
|
|
642
|
-
ctx.error,
|
|
643
|
-
"Unauthorized: Cannot delete folder",
|
|
644
|
-
);
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
try {
|
|
648
|
-
await deleteFolder(adapter, ctx.params.id);
|
|
649
|
-
} catch (err) {
|
|
650
|
-
throw ctx.error(409, {
|
|
651
|
-
message:
|
|
652
|
-
err instanceof Error ? err.message : "Cannot delete folder",
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
return { success: true };
|
|
657
|
-
},
|
|
230
|
+
{ method: "DELETE", requireRequest: true },
|
|
231
|
+
operations.deleteFolder.route((ctx) => ({ id: ctx.params.id })),
|
|
658
232
|
);
|
|
659
|
-
|
|
660
|
-
// ── Upload endpoints (adapter-specific) ────────────────────────────────
|
|
661
|
-
|
|
662
|
-
// Direct upload — local adapter only
|
|
663
233
|
const uploadDirectEndpoint = createEndpoint(
|
|
664
234
|
"/media/upload",
|
|
665
235
|
{
|
|
666
236
|
method: "POST",
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
// parses the body into a FormData object and exposes it as ctx.body.
|
|
670
|
-
// Without this, Better Call may pre-read the body stream and calling
|
|
671
|
-
// ctx.request.formData() afterwards fails with "Body already read".
|
|
672
|
-
allowedMediaTypes: ["multipart/form-data"],
|
|
673
|
-
},
|
|
237
|
+
requireRequest: true,
|
|
238
|
+
metadata: { allowedMediaTypes: ["multipart/form-data"] },
|
|
674
239
|
},
|
|
675
|
-
async (ctx) => {
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
// Better Call parses multipart/form-data into a plain object on ctx.body,
|
|
684
|
-
// where each field's value is preserved as-is (File instances for file fields).
|
|
685
|
-
const body = ctx.body as Record<string, unknown> | undefined;
|
|
686
|
-
|
|
687
|
-
if (!body || typeof body !== "object") {
|
|
688
|
-
throw ctx.error(400, {
|
|
689
|
-
message: "Expected multipart/form-data request body",
|
|
690
|
-
});
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
const fileRaw = body.file;
|
|
694
|
-
|
|
695
|
-
// Use a duck-type check instead of instanceof File to avoid
|
|
696
|
-
// cross-module-boundary failures (e.g. undici's File vs globalThis.File).
|
|
697
|
-
if (
|
|
698
|
-
!fileRaw ||
|
|
699
|
-
typeof fileRaw !== "object" ||
|
|
700
|
-
typeof (fileRaw as any).arrayBuffer !== "function"
|
|
701
|
-
) {
|
|
702
|
-
throw ctx.error(400, {
|
|
703
|
-
message: "Missing 'file' field in form data",
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
if (
|
|
708
|
-
typeof (fileRaw as any).size !== "number" ||
|
|
709
|
-
(fileRaw as any).size < 0
|
|
710
|
-
) {
|
|
711
|
-
throw ctx.error(400, {
|
|
712
|
-
message: "File 'size' is missing or invalid",
|
|
713
|
-
});
|
|
714
|
-
}
|
|
715
|
-
if (
|
|
716
|
-
typeof (fileRaw as any).name !== "string" ||
|
|
717
|
-
!(fileRaw as any).name
|
|
718
|
-
) {
|
|
719
|
-
throw ctx.error(400, {
|
|
720
|
-
message: "File 'name' is missing or invalid",
|
|
721
|
-
});
|
|
722
|
-
}
|
|
723
|
-
if (typeof (fileRaw as any).type !== "string") {
|
|
724
|
-
throw ctx.error(400, {
|
|
725
|
-
message: "File 'type' is missing or invalid",
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
// Safe to treat as a File-like object after the duck-type check above.
|
|
730
|
-
const file = fileRaw as Pick<
|
|
731
|
-
File,
|
|
732
|
-
"name" | "type" | "size" | "arrayBuffer"
|
|
733
|
-
>;
|
|
734
|
-
|
|
735
|
-
const context: MediaApiContext = { headers: ctx.headers };
|
|
736
|
-
|
|
737
|
-
const tenantId = resolveTenantId
|
|
738
|
-
? ((await resolveTenantId(context)) ?? undefined)
|
|
739
|
-
: undefined;
|
|
740
|
-
|
|
741
|
-
if (hooks?.onBeforeUpload) {
|
|
742
|
-
await runHook(
|
|
743
|
-
() =>
|
|
744
|
-
hooks.onBeforeUpload!(
|
|
745
|
-
{
|
|
746
|
-
filename: file.name,
|
|
747
|
-
mimeType: file.type,
|
|
748
|
-
size: file.size,
|
|
749
|
-
},
|
|
750
|
-
context,
|
|
751
|
-
),
|
|
752
|
-
ctx.error,
|
|
753
|
-
"Unauthorized: Cannot upload asset",
|
|
240
|
+
operations.uploadDirect.route(async (ctx) => {
|
|
241
|
+
const { file, folderId } = parseMultipartFile(ctx.body);
|
|
242
|
+
const maximumSize = config.maxFileSizeBytes ?? 10 * 1024 * 1024;
|
|
243
|
+
if (file.size > maximumSize) {
|
|
244
|
+
throw new MediaOperationError(
|
|
245
|
+
413,
|
|
246
|
+
`File size ${file.size} bytes exceeds the limit of ${maximumSize} bytes`,
|
|
247
|
+
"FILE_TOO_LARGE",
|
|
754
248
|
);
|
|
755
249
|
}
|
|
756
|
-
|
|
757
|
-
validateMimeType(file.type, ctx);
|
|
758
|
-
|
|
759
|
-
if (file.size > maxFileSizeBytes) {
|
|
760
|
-
throw ctx.error(413, {
|
|
761
|
-
message: `File size ${file.size} bytes exceeds the limit of ${maxFileSizeBytes} bytes`,
|
|
762
|
-
});
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
const buffer = Buffer.from(await file.arrayBuffer());
|
|
766
|
-
const folderId =
|
|
767
|
-
typeof body.folderId === "string" && body.folderId
|
|
768
|
-
? body.folderId
|
|
769
|
-
: undefined;
|
|
770
|
-
|
|
771
|
-
if (folderId) {
|
|
772
|
-
const folder = await getFolderById(adapter, folderId);
|
|
773
|
-
if (!folder) {
|
|
774
|
-
throw ctx.error(404, { message: "Folder not found" });
|
|
775
|
-
}
|
|
776
|
-
if (tenantId !== undefined && folder.tenantId !== tenantId) {
|
|
777
|
-
throw ctx.error(404, { message: "Folder not found" });
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
const { url } = await storageAdapter.upload(buffer, {
|
|
250
|
+
return {
|
|
782
251
|
filename: file.name,
|
|
783
252
|
mimeType: file.type,
|
|
784
253
|
size: file.size,
|
|
254
|
+
contentBase64: Buffer.from(await file.arrayBuffer()).toString(
|
|
255
|
+
"base64",
|
|
256
|
+
),
|
|
785
257
|
folderId,
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
// Create the DB record. If this fails, clean up the already-uploaded
|
|
789
|
-
// storage file so it does not become a silently orphaned file.
|
|
790
|
-
let asset: Asset;
|
|
791
|
-
try {
|
|
792
|
-
asset = await createAsset(adapter, {
|
|
793
|
-
filename: url.split("/").pop() ?? file.name,
|
|
794
|
-
originalName: file.name,
|
|
795
|
-
mimeType: file.type,
|
|
796
|
-
size: file.size,
|
|
797
|
-
url,
|
|
798
|
-
folderId,
|
|
799
|
-
tenantId,
|
|
800
|
-
});
|
|
801
|
-
} catch (err) {
|
|
802
|
-
try {
|
|
803
|
-
await storageAdapter.delete(url);
|
|
804
|
-
} catch (cleanupErr) {
|
|
805
|
-
console.error(
|
|
806
|
-
`[btst/media] Failed to clean up orphaned storage file after DB error: ${url}`,
|
|
807
|
-
cleanupErr,
|
|
808
|
-
);
|
|
809
|
-
}
|
|
810
|
-
throw err;
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
if (hooks?.onAfterUpload) {
|
|
814
|
-
await hooks.onAfterUpload(asset, context);
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
return asset;
|
|
818
|
-
},
|
|
258
|
+
};
|
|
259
|
+
}),
|
|
819
260
|
);
|
|
820
|
-
|
|
821
|
-
// Token generation — S3 adapter
|
|
822
261
|
const uploadTokenEndpoint = createEndpoint(
|
|
823
262
|
"/media/upload/token",
|
|
824
263
|
{
|
|
825
264
|
method: "POST",
|
|
826
265
|
body: uploadTokenRequestSchema,
|
|
266
|
+
requireRequest: true,
|
|
827
267
|
},
|
|
828
|
-
|
|
829
|
-
if (!isS3Adapter(storageAdapter)) {
|
|
830
|
-
throw ctx.error(400, {
|
|
831
|
-
message:
|
|
832
|
-
"Upload token endpoint is only supported with the S3 storage adapter",
|
|
833
|
-
});
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
const context: MediaApiContext = {
|
|
837
|
-
body: ctx.body,
|
|
838
|
-
headers: ctx.headers,
|
|
839
|
-
};
|
|
840
|
-
|
|
841
|
-
// Resolve tenant for auth checks and folder ownership validation.
|
|
842
|
-
// The token response does not embed tenantId — the follow-up POST /media/assets
|
|
843
|
-
// call tags the asset automatically via resolveTenantId.
|
|
844
|
-
const tenantId = resolveTenantId
|
|
845
|
-
? ((await resolveTenantId(context)) ?? undefined)
|
|
846
|
-
: undefined;
|
|
847
|
-
|
|
848
|
-
if (hooks?.onBeforeUpload) {
|
|
849
|
-
await runHook(
|
|
850
|
-
() =>
|
|
851
|
-
hooks.onBeforeUpload!(
|
|
852
|
-
{
|
|
853
|
-
filename: ctx.body.filename,
|
|
854
|
-
mimeType: ctx.body.mimeType,
|
|
855
|
-
size: ctx.body.size,
|
|
856
|
-
},
|
|
857
|
-
context,
|
|
858
|
-
),
|
|
859
|
-
ctx.error,
|
|
860
|
-
"Unauthorized: Cannot upload asset",
|
|
861
|
-
);
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
validateMimeType(ctx.body.mimeType, ctx);
|
|
865
|
-
|
|
866
|
-
if (ctx.body.size > maxFileSizeBytes) {
|
|
867
|
-
throw ctx.error(413, {
|
|
868
|
-
message: `File size ${ctx.body.size} bytes exceeds the limit of ${maxFileSizeBytes} bytes`,
|
|
869
|
-
});
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
let folderId: string | undefined = ctx.body.folderId;
|
|
873
|
-
if (folderId) {
|
|
874
|
-
const folder = await getFolderById(adapter, folderId);
|
|
875
|
-
if (!folder) {
|
|
876
|
-
throw ctx.error(404, {
|
|
877
|
-
message: "Folder not found",
|
|
878
|
-
});
|
|
879
|
-
}
|
|
880
|
-
if (tenantId !== undefined && folder.tenantId !== tenantId) {
|
|
881
|
-
throw ctx.error(404, { message: "Folder not found" });
|
|
882
|
-
}
|
|
883
|
-
folderId = folder.id;
|
|
884
|
-
}
|
|
885
|
-
const filename = sanitizeS3KeySegment(ctx.body.filename);
|
|
886
|
-
|
|
887
|
-
return storageAdapter.generateUploadToken({
|
|
888
|
-
filename,
|
|
889
|
-
mimeType: ctx.body.mimeType,
|
|
890
|
-
size: ctx.body.size,
|
|
891
|
-
folderId,
|
|
892
|
-
});
|
|
893
|
-
},
|
|
268
|
+
operations.uploadToken.route((ctx) => ctx.body),
|
|
894
269
|
);
|
|
895
|
-
|
|
896
|
-
// Vercel Blob token exchange — vercel-blob adapter
|
|
897
270
|
const uploadVercelBlobEndpoint = createEndpoint(
|
|
898
271
|
"/media/upload/vercel-blob",
|
|
899
|
-
{
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
const context: MediaApiContext = { headers: ctx.headers };
|
|
911
|
-
|
|
912
|
-
// Resolve tenant for hook side-effects (e.g. auth checks). The token
|
|
913
|
-
// response does not embed tenantId — the follow-up POST /media/assets
|
|
914
|
-
// call tags the asset automatically via resolveTenantId.
|
|
915
|
-
if (resolveTenantId) {
|
|
916
|
-
await resolveTenantId(context);
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
if (!ctx.request) {
|
|
920
|
-
throw ctx.error(400, {
|
|
921
|
-
message: "Request object is not available",
|
|
922
|
-
});
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
return storageAdapter.handleRequest(ctx.request, ctx.body, {
|
|
926
|
-
onBeforeGenerateToken: async (pathname, clientPayload) => {
|
|
927
|
-
const filename = pathname.split("/").pop() ?? pathname;
|
|
928
|
-
let parsed: Record<string, unknown> = {};
|
|
929
|
-
try {
|
|
930
|
-
parsed = clientPayload ? JSON.parse(clientPayload) : {};
|
|
931
|
-
} catch {
|
|
932
|
-
/* ignore invalid JSON — fall back to defaults */
|
|
933
|
-
}
|
|
934
|
-
const mimeType =
|
|
935
|
-
(parsed.mimeType as string | undefined) ??
|
|
936
|
-
"application/octet-stream";
|
|
937
|
-
const size = parsed.size as number | undefined;
|
|
938
|
-
|
|
939
|
-
if (hooks?.onBeforeUpload) {
|
|
940
|
-
await runHook(
|
|
941
|
-
() =>
|
|
942
|
-
hooks.onBeforeUpload!(
|
|
943
|
-
{ filename, mimeType, size },
|
|
944
|
-
context,
|
|
945
|
-
),
|
|
946
|
-
ctx.error,
|
|
947
|
-
"Unauthorized: Cannot upload asset",
|
|
948
|
-
);
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
validateMimeType(mimeType, ctx);
|
|
952
|
-
|
|
953
|
-
if (size != null && size > maxFileSizeBytes) {
|
|
954
|
-
throw ctx.error(413, {
|
|
955
|
-
message: `File size ${size} bytes exceeds the limit of ${maxFileSizeBytes} bytes`,
|
|
956
|
-
});
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
return {
|
|
960
|
-
addRandomSuffix: true,
|
|
961
|
-
allowedContentTypes:
|
|
962
|
-
allowedMimeTypes && allowedMimeTypes.length > 0
|
|
963
|
-
? allowedMimeTypes
|
|
964
|
-
: undefined,
|
|
965
|
-
maximumSizeInBytes: maxFileSizeBytes,
|
|
966
|
-
};
|
|
967
|
-
},
|
|
968
|
-
});
|
|
969
|
-
},
|
|
272
|
+
{ method: "POST", requireRequest: true },
|
|
273
|
+
bindVercelBlobRoute(async (ctx) => {
|
|
274
|
+
const body =
|
|
275
|
+
ctx.body ??
|
|
276
|
+
(await ctx.request
|
|
277
|
+
.clone()
|
|
278
|
+
.json()
|
|
279
|
+
.catch(() => ({})));
|
|
280
|
+
return { body };
|
|
281
|
+
}),
|
|
970
282
|
);
|
|
971
283
|
|
|
972
284
|
return {
|