@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,52 +1,48 @@
|
|
|
1
1
|
import type { DBAdapter as Adapter } from "@btst/db";
|
|
2
|
-
import { defineBackendPlugin } from "@btst/stack/plugins/api";
|
|
3
|
-
import {
|
|
2
|
+
import { createEndpoint, defineBackendPlugin } from "@btst/stack/plugins/api";
|
|
3
|
+
import type { QueryClient } from "@tanstack/react-query";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import {
|
|
6
|
-
zodToFormSchema,
|
|
7
|
-
formSchemaToZod,
|
|
8
|
-
} from "@workspace/ui/lib/schema-converter";
|
|
5
|
+
import { zodToFormSchema } from "@workspace/ui/lib/schema-converter";
|
|
9
6
|
import { cmsSchema as dbSchema } from "../db";
|
|
10
|
-
import type {
|
|
11
|
-
ContentType,
|
|
12
|
-
ContentItem,
|
|
13
|
-
ContentItemWithType,
|
|
14
|
-
ContentRelation,
|
|
15
|
-
CMSBackendConfig,
|
|
16
|
-
CMSHookContext,
|
|
17
|
-
SerializedContentItemWithType,
|
|
18
|
-
RelationValue,
|
|
19
|
-
InverseRelation,
|
|
20
|
-
} from "../types";
|
|
21
7
|
import {
|
|
22
8
|
createListContentQuerySchema,
|
|
23
9
|
DEFAULT_MAX_PAGE_SIZE,
|
|
24
10
|
} from "../schemas";
|
|
25
|
-
import {
|
|
11
|
+
import type { CMSBackendConfig, CMSBackendHooks, ContentType } from "../types";
|
|
12
|
+
export { CMS_LIFECYCLE_HOOK_MIGRATIONS } from "./lifecycle-migrations";
|
|
26
13
|
import {
|
|
27
|
-
getAllContentTypes,
|
|
28
14
|
getAllContentItems,
|
|
29
|
-
|
|
15
|
+
getAllContentTypes,
|
|
30
16
|
getContentItemById,
|
|
31
|
-
serializeContentType,
|
|
32
|
-
serializeContentItem,
|
|
33
|
-
serializeContentItemWithType,
|
|
34
17
|
} from "./getters";
|
|
35
|
-
import { createCMSContentItem } from "./mutations";
|
|
36
18
|
import {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
19
|
+
CMSContentItemParamsSchema,
|
|
20
|
+
CMSContentTypeParamsSchema,
|
|
21
|
+
CMSCreateContentItemBodySchema,
|
|
22
|
+
CMSUpdateContentItemBodySchema,
|
|
23
|
+
createCMSOperations,
|
|
24
|
+
} from "./operations";
|
|
43
25
|
import { CMS_QUERY_KEYS } from "./query-key-defs";
|
|
44
|
-
import { runHook } from "../../utils";
|
|
45
26
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
27
|
+
export {
|
|
28
|
+
CMSContentItemParamsSchema,
|
|
29
|
+
CMSContentTypeParamsSchema,
|
|
30
|
+
CMSCreateContentItemBodySchema,
|
|
31
|
+
CMSUpdateContentItemBodySchema,
|
|
32
|
+
} from "./operations";
|
|
33
|
+
export type {
|
|
34
|
+
CMSBackendHooks,
|
|
35
|
+
CMSCreateOperationContext,
|
|
36
|
+
CMSCreateResultContext,
|
|
37
|
+
CMSDeleteOperationContext,
|
|
38
|
+
CMSDeleteResultContext,
|
|
39
|
+
CMSOperationErrorContext,
|
|
40
|
+
CMSOperationLifecycleContext,
|
|
41
|
+
CMSUpdateOperationContext,
|
|
42
|
+
CMSUpdateResultContext,
|
|
43
|
+
} from "../types";
|
|
44
|
+
|
|
45
|
+
/** Route keys returned by the CMS client plugin. */
|
|
50
46
|
export type CMSRouteKey =
|
|
51
47
|
| "dashboard"
|
|
52
48
|
| "contentList"
|
|
@@ -67,362 +63,119 @@ interface CMSPrefetchForRoute {
|
|
|
67
63
|
): Promise<void>;
|
|
68
64
|
}
|
|
69
65
|
|
|
70
|
-
/**
|
|
71
|
-
* Sync content types from config to database
|
|
72
|
-
* Creates or updates content types based on the developer's Zod schemas
|
|
73
|
-
*
|
|
74
|
-
* Always writes version 2 format:
|
|
75
|
-
* - fieldType is embedded in jsonSchema via .meta()
|
|
76
|
-
* - fieldConfig is set to null (no longer used)
|
|
77
|
-
* - autoFormVersion is set to 2
|
|
78
|
-
*
|
|
79
|
-
* Handles race conditions from multiple instances by catching unique constraint
|
|
80
|
-
* errors and verifying the record exists (another instance created it first).
|
|
81
|
-
*/
|
|
82
66
|
async function syncContentTypes(
|
|
83
67
|
adapter: Adapter,
|
|
84
68
|
config: CMSBackendConfig,
|
|
85
69
|
): Promise<void> {
|
|
86
|
-
for (const
|
|
87
|
-
|
|
88
|
-
// This properly handles dates, date constraints, and steps metadata
|
|
89
|
-
const jsonSchema = JSON.stringify(zodToFormSchema(ct.schema));
|
|
90
|
-
|
|
70
|
+
for (const definition of config.contentTypes) {
|
|
71
|
+
const jsonSchema = JSON.stringify(zodToFormSchema(definition.schema));
|
|
91
72
|
const existing = await adapter.findOne<ContentType>({
|
|
92
73
|
model: "contentType",
|
|
93
|
-
where: [
|
|
74
|
+
where: [
|
|
75
|
+
{ field: "slug", value: definition.slug, operator: "eq" as const },
|
|
76
|
+
],
|
|
94
77
|
});
|
|
95
|
-
|
|
96
78
|
if (existing) {
|
|
97
79
|
await adapter.update({
|
|
98
80
|
model: "contentType",
|
|
99
81
|
where: [{ field: "id", value: existing.id, operator: "eq" as const }],
|
|
100
82
|
update: {
|
|
101
|
-
name:
|
|
102
|
-
description:
|
|
83
|
+
name: definition.name,
|
|
84
|
+
description: definition.description ?? null,
|
|
103
85
|
jsonSchema,
|
|
104
|
-
fieldConfig: null,
|
|
86
|
+
fieldConfig: null,
|
|
105
87
|
autoFormVersion: 2,
|
|
106
88
|
updatedAt: new Date(),
|
|
107
89
|
},
|
|
108
90
|
});
|
|
109
|
-
} else {
|
|
110
|
-
try {
|
|
111
|
-
await adapter.create({
|
|
112
|
-
model: "contentType",
|
|
113
|
-
data: {
|
|
114
|
-
name: ct.name,
|
|
115
|
-
slug: ct.slug,
|
|
116
|
-
description: ct.description ?? null,
|
|
117
|
-
jsonSchema,
|
|
118
|
-
fieldConfig: null, // No longer used in version 2
|
|
119
|
-
autoFormVersion: 2,
|
|
120
|
-
createdAt: new Date(),
|
|
121
|
-
updatedAt: new Date(),
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
} catch (err) {
|
|
125
|
-
// Handle race condition: another instance may have created this content type
|
|
126
|
-
// Check if the record now exists - if so, another instance beat us to it
|
|
127
|
-
const nowExists = await adapter.findOne<ContentType>({
|
|
128
|
-
model: "contentType",
|
|
129
|
-
where: [{ field: "slug", value: ct.slug, operator: "eq" as const }],
|
|
130
|
-
});
|
|
131
|
-
if (nowExists) {
|
|
132
|
-
// Record exists now (created by another instance), continue to next content type
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
// Record still doesn't exist - this is a genuine database error, re-throw with context
|
|
136
|
-
const message =
|
|
137
|
-
err instanceof Error ? err.message : "Unknown database error";
|
|
138
|
-
throw new Error(
|
|
139
|
-
`Failed to create content type "${ct.slug}": ${message}`,
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Get Zod schema for a content type from its JSON Schema
|
|
148
|
-
* Uses formSchemaToZod to properly handle dates, date constraints, and steps metadata
|
|
149
|
-
*/
|
|
150
|
-
function getContentTypeZodSchema(contentType: ContentType): z.ZodTypeAny {
|
|
151
|
-
const jsonSchema = JSON.parse(contentType.jsonSchema);
|
|
152
|
-
return formSchemaToZod(jsonSchema);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// ========== Relation Helpers ==========
|
|
156
|
-
// `extractRelationFields`, `isNewRelationValue`, `isExistingRelationValue`,
|
|
157
|
-
// and `syncRelations` live in ./relations so both this HTTP route module
|
|
158
|
-
// and the programmatic mutations helper can share them.
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Process relation fields in content data:
|
|
162
|
-
* 1. Create new items from _new values
|
|
163
|
-
* 2. Extract IDs for junction table
|
|
164
|
-
* 3. Return cleaned data with only IDs stored
|
|
165
|
-
*
|
|
166
|
-
* Only processes relation fields that are explicitly present in the data.
|
|
167
|
-
* Fields not present in data are skipped entirely - this preserves existing
|
|
168
|
-
* relations during partial updates.
|
|
169
|
-
*
|
|
170
|
-
* @returns Object with processedData (for storing) and relationIds (for junction table sync)
|
|
171
|
-
*/
|
|
172
|
-
async function processRelationsInData(
|
|
173
|
-
adapter: Adapter,
|
|
174
|
-
contentType: ContentType,
|
|
175
|
-
data: Record<string, unknown>,
|
|
176
|
-
getContentTypeFn: (slug: string) => Promise<ContentType | null>,
|
|
177
|
-
): Promise<{
|
|
178
|
-
processedData: Record<string, unknown>;
|
|
179
|
-
relationIds: Record<string, string[]>;
|
|
180
|
-
}> {
|
|
181
|
-
const relationFields = extractRelationFields(contentType);
|
|
182
|
-
const processedData = { ...data };
|
|
183
|
-
const relationIds: Record<string, string[]> = {};
|
|
184
|
-
|
|
185
|
-
for (const [fieldName, relationConfig] of Object.entries(relationFields)) {
|
|
186
|
-
// Skip fields not present in the data - this preserves existing relations
|
|
187
|
-
// during partial updates. Only process fields explicitly included.
|
|
188
|
-
if (!(fieldName in data)) {
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
const fieldValue = data[fieldName];
|
|
193
|
-
// Field is present but null/undefined/empty - clear relations for this field
|
|
194
|
-
if (!fieldValue) {
|
|
195
|
-
relationIds[fieldName] = [];
|
|
196
91
|
continue;
|
|
197
92
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
93
|
+
try {
|
|
94
|
+
await adapter.create({
|
|
95
|
+
model: "contentType",
|
|
96
|
+
data: {
|
|
97
|
+
name: definition.name,
|
|
98
|
+
slug: definition.slug,
|
|
99
|
+
description: definition.description ?? null,
|
|
100
|
+
jsonSchema,
|
|
101
|
+
fieldConfig: null,
|
|
102
|
+
autoFormVersion: 2,
|
|
103
|
+
createdAt: new Date(),
|
|
104
|
+
updatedAt: new Date(),
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
} catch (error) {
|
|
108
|
+
const nowExists = await adapter.findOne<ContentType>({
|
|
109
|
+
model: "contentType",
|
|
110
|
+
where: [
|
|
111
|
+
{ field: "slug", value: definition.slug, operator: "eq" as const },
|
|
112
|
+
],
|
|
113
|
+
});
|
|
114
|
+
if (nowExists) continue;
|
|
202
115
|
throw new Error(
|
|
203
|
-
`
|
|
116
|
+
`Failed to create content type "${definition.slug}": ${
|
|
117
|
+
error instanceof Error ? error.message : "Unknown database error"
|
|
118
|
+
}`,
|
|
204
119
|
);
|
|
205
120
|
}
|
|
206
|
-
|
|
207
|
-
const ids: string[] = [];
|
|
208
|
-
|
|
209
|
-
if (relationConfig.type === "belongsTo") {
|
|
210
|
-
// Single relation
|
|
211
|
-
const value = fieldValue as RelationValue;
|
|
212
|
-
if (isNewRelationValue(value)) {
|
|
213
|
-
// Create the new item
|
|
214
|
-
const newItem = await createRelatedItem(
|
|
215
|
-
adapter,
|
|
216
|
-
targetContentType,
|
|
217
|
-
value.data,
|
|
218
|
-
);
|
|
219
|
-
ids.push(newItem.id);
|
|
220
|
-
// Store only the ID in processedData
|
|
221
|
-
processedData[fieldName] = { id: newItem.id };
|
|
222
|
-
} else if (isExistingRelationValue(value)) {
|
|
223
|
-
ids.push(value.id);
|
|
224
|
-
// Keep as-is (already an ID reference)
|
|
225
|
-
}
|
|
226
|
-
} else {
|
|
227
|
-
// Array relation (hasMany / manyToMany)
|
|
228
|
-
const values = (
|
|
229
|
-
Array.isArray(fieldValue) ? fieldValue : []
|
|
230
|
-
) as RelationValue[];
|
|
231
|
-
const processedValues: Array<{ id: string }> = [];
|
|
232
|
-
|
|
233
|
-
for (const value of values) {
|
|
234
|
-
if (isNewRelationValue(value)) {
|
|
235
|
-
// Create the new item
|
|
236
|
-
const newItem = await createRelatedItem(
|
|
237
|
-
adapter,
|
|
238
|
-
targetContentType,
|
|
239
|
-
value.data,
|
|
240
|
-
);
|
|
241
|
-
ids.push(newItem.id);
|
|
242
|
-
processedValues.push({ id: newItem.id });
|
|
243
|
-
} else if (isExistingRelationValue(value)) {
|
|
244
|
-
ids.push(value.id);
|
|
245
|
-
processedValues.push({ id: value.id });
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
processedData[fieldName] = processedValues;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
relationIds[fieldName] = ids;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
return { processedData, relationIds };
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Create a related content item
|
|
260
|
-
*/
|
|
261
|
-
async function createRelatedItem(
|
|
262
|
-
adapter: Adapter,
|
|
263
|
-
targetContentType: ContentType,
|
|
264
|
-
data: Record<string, unknown>,
|
|
265
|
-
): Promise<ContentItem> {
|
|
266
|
-
// Generate slug from common name fields or use timestamp
|
|
267
|
-
const slug = slugify(
|
|
268
|
-
(data.slug as string) ||
|
|
269
|
-
(data.name as string) ||
|
|
270
|
-
(data.title as string) ||
|
|
271
|
-
`item-${Date.now()}`,
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
// Validate against target content type schema
|
|
275
|
-
const zodSchema = getContentTypeZodSchema(targetContentType);
|
|
276
|
-
const validation = zodSchema.safeParse(data);
|
|
277
|
-
if (!validation.success) {
|
|
278
|
-
throw new Error(
|
|
279
|
-
`Validation failed for new ${targetContentType.slug}: ${JSON.stringify(validation.error.issues)}`,
|
|
280
|
-
);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// Check for duplicate slug
|
|
284
|
-
const existing = await adapter.findOne<ContentItem>({
|
|
285
|
-
model: "contentItem",
|
|
286
|
-
where: [
|
|
287
|
-
{
|
|
288
|
-
field: "contentTypeId",
|
|
289
|
-
value: targetContentType.id,
|
|
290
|
-
operator: "eq" as const,
|
|
291
|
-
},
|
|
292
|
-
{ field: "slug", value: slug, operator: "eq" as const },
|
|
293
|
-
],
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
if (existing) {
|
|
297
|
-
// If item with same slug exists, return it instead of creating duplicate
|
|
298
|
-
return existing;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// Create the item
|
|
302
|
-
const item = await adapter.create<ContentItem>({
|
|
303
|
-
model: "contentItem",
|
|
304
|
-
data: {
|
|
305
|
-
contentTypeId: targetContentType.id,
|
|
306
|
-
slug,
|
|
307
|
-
data: JSON.stringify(validation.data),
|
|
308
|
-
createdAt: new Date(),
|
|
309
|
-
updatedAt: new Date(),
|
|
310
|
-
},
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
return item;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Populate relations for a content item by fetching related items
|
|
318
|
-
*/
|
|
319
|
-
async function populateRelations(
|
|
320
|
-
adapter: Adapter,
|
|
321
|
-
item: ContentItemWithType,
|
|
322
|
-
): Promise<Record<string, SerializedContentItemWithType[]>> {
|
|
323
|
-
const relations: Record<string, SerializedContentItemWithType[]> = {};
|
|
324
|
-
|
|
325
|
-
// Get all relations for this item
|
|
326
|
-
const contentRelations = await adapter.findMany<ContentRelation>({
|
|
327
|
-
model: "contentRelation",
|
|
328
|
-
where: [{ field: "sourceId", value: item.id, operator: "eq" as const }],
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
// Group by field name
|
|
332
|
-
const relationsByField: Record<string, string[]> = {};
|
|
333
|
-
for (const rel of contentRelations) {
|
|
334
|
-
if (!relationsByField[rel.fieldName]) {
|
|
335
|
-
relationsByField[rel.fieldName] = [];
|
|
336
|
-
}
|
|
337
|
-
relationsByField[rel.fieldName]!.push(rel.targetId);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Fetch related items for each field
|
|
341
|
-
for (const [fieldName, targetIds] of Object.entries(relationsByField)) {
|
|
342
|
-
if (targetIds.length === 0) {
|
|
343
|
-
relations[fieldName] = [];
|
|
344
|
-
continue;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
const relatedItems: SerializedContentItemWithType[] = [];
|
|
348
|
-
for (const targetId of targetIds) {
|
|
349
|
-
const relatedItem = await adapter.findOne<ContentItemWithType>({
|
|
350
|
-
model: "contentItem",
|
|
351
|
-
where: [{ field: "id", value: targetId, operator: "eq" as const }],
|
|
352
|
-
join: { contentType: true },
|
|
353
|
-
});
|
|
354
|
-
if (relatedItem) {
|
|
355
|
-
relatedItems.push(serializeContentItemWithType(relatedItem));
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
relations[fieldName] = relatedItems;
|
|
359
121
|
}
|
|
360
|
-
|
|
361
|
-
return relations;
|
|
362
122
|
}
|
|
363
123
|
|
|
364
|
-
/**
|
|
365
|
-
* CMS backend plugin
|
|
366
|
-
* Provides API endpoints for managing content types and content items
|
|
367
|
-
*
|
|
368
|
-
* @param config - Configuration with content types and optional hooks
|
|
369
|
-
*/
|
|
124
|
+
/** CMS backend plugin backed by one operation inventory for every transport. */
|
|
370
125
|
export const cmsBackendPlugin = (config: CMSBackendConfig) => {
|
|
371
|
-
// Shared sync state — used by both the api factory and routes handlers so
|
|
372
|
-
// that calling a getter before any HTTP request has been made still
|
|
373
|
-
// triggers the one-time content-type sync.
|
|
374
126
|
let syncPromise: Promise<void> | null = null;
|
|
375
|
-
|
|
376
127
|
const ensureSynced = (adapter: Adapter) => {
|
|
377
128
|
if (!syncPromise) {
|
|
378
|
-
syncPromise = syncContentTypes(adapter, config).catch((
|
|
379
|
-
// Allow retry on next call if sync fails
|
|
129
|
+
syncPromise = syncContentTypes(adapter, config).catch((error) => {
|
|
380
130
|
syncPromise = null;
|
|
381
|
-
throw
|
|
131
|
+
throw error;
|
|
382
132
|
});
|
|
383
133
|
}
|
|
384
134
|
return syncPromise;
|
|
385
135
|
};
|
|
386
|
-
|
|
387
136
|
const getContentTypesWithCounts = async (adapter: Adapter) => {
|
|
388
137
|
const contentTypes = await getAllContentTypes(adapter);
|
|
389
138
|
return Promise.all(
|
|
390
|
-
contentTypes.map(async (
|
|
391
|
-
|
|
139
|
+
contentTypes.map(async (contentType) => ({
|
|
140
|
+
...contentType,
|
|
141
|
+
itemCount: await adapter.count({
|
|
392
142
|
model: "contentItem",
|
|
393
143
|
where: [
|
|
394
|
-
{
|
|
144
|
+
{
|
|
145
|
+
field: "contentTypeId",
|
|
146
|
+
value: contentType.id,
|
|
147
|
+
operator: "eq" as const,
|
|
148
|
+
},
|
|
395
149
|
],
|
|
396
|
-
})
|
|
397
|
-
|
|
398
|
-
}),
|
|
150
|
+
}),
|
|
151
|
+
})),
|
|
399
152
|
);
|
|
400
153
|
};
|
|
401
154
|
|
|
402
|
-
|
|
403
|
-
|
|
155
|
+
/** Raw SSG path; unavailable from HTTP/request operation APIs. */
|
|
156
|
+
const createCMSPrefetchForRoute = (adapter: Adapter): CMSPrefetchForRoute =>
|
|
157
|
+
async function prefetchForRoute(
|
|
404
158
|
key: CMSRouteKey,
|
|
405
|
-
|
|
159
|
+
queryClient: QueryClient,
|
|
406
160
|
params?: Record<string, string>,
|
|
407
161
|
): Promise<void> {
|
|
408
|
-
// Sync content types once at the top — idempotent for concurrent SSG calls
|
|
409
162
|
await ensureSynced(adapter);
|
|
410
|
-
|
|
411
163
|
switch (key) {
|
|
412
164
|
case "dashboard":
|
|
413
|
-
case "newContent":
|
|
414
|
-
|
|
415
|
-
|
|
165
|
+
case "newContent":
|
|
166
|
+
queryClient.setQueryData(
|
|
167
|
+
CMS_QUERY_KEYS.typesList(),
|
|
168
|
+
await getContentTypesWithCounts(adapter),
|
|
169
|
+
);
|
|
416
170
|
break;
|
|
417
|
-
}
|
|
418
171
|
case "contentList": {
|
|
419
172
|
const typeSlug = params?.typeSlug ?? "";
|
|
420
173
|
const [contentTypes, contentItems] = await Promise.all([
|
|
421
174
|
getContentTypesWithCounts(adapter),
|
|
422
175
|
getAllContentItems(adapter, typeSlug, { limit: 20, offset: 0 }),
|
|
423
176
|
]);
|
|
424
|
-
|
|
425
|
-
|
|
177
|
+
queryClient.setQueryData(CMS_QUERY_KEYS.typesList(), contentTypes);
|
|
178
|
+
queryClient.setQueryData(
|
|
426
179
|
CMS_QUERY_KEYS.contentList({ typeSlug, limit: 20, offset: 0 }),
|
|
427
180
|
{
|
|
428
181
|
pages: [
|
|
@@ -445,61 +198,39 @@ export const cmsBackendPlugin = (config: CMSBackendConfig) => {
|
|
|
445
198
|
getContentTypesWithCounts(adapter),
|
|
446
199
|
id ? getContentItemById(adapter, id) : Promise.resolve(null),
|
|
447
200
|
]);
|
|
448
|
-
|
|
201
|
+
queryClient.setQueryData(CMS_QUERY_KEYS.typesList(), contentTypes);
|
|
449
202
|
if (id) {
|
|
450
|
-
|
|
203
|
+
queryClient.setQueryData(
|
|
204
|
+
CMS_QUERY_KEYS.contentDetail(typeSlug, id),
|
|
205
|
+
item,
|
|
206
|
+
);
|
|
451
207
|
}
|
|
452
208
|
break;
|
|
453
209
|
}
|
|
454
|
-
default:
|
|
455
|
-
break;
|
|
456
210
|
}
|
|
457
211
|
} as CMSPrefetchForRoute;
|
|
458
|
-
};
|
|
459
212
|
|
|
460
213
|
return defineBackendPlugin({
|
|
461
|
-
|
|
462
|
-
|
|
214
|
+
id: "cms",
|
|
463
215
|
dbPlugin: dbSchema,
|
|
216
|
+
operations: (adapter: Adapter) =>
|
|
217
|
+
createCMSOperations(adapter, {
|
|
218
|
+
ensureSynced: () => ensureSynced(adapter),
|
|
219
|
+
getContentTypesWithCounts: () => getContentTypesWithCounts(adapter),
|
|
220
|
+
...(config.maxPageSize !== undefined
|
|
221
|
+
? { maxPageSize: config.maxPageSize }
|
|
222
|
+
: {}),
|
|
223
|
+
...(config.hooks ? { hooks: config.hooks as CMSBackendHooks } : {}),
|
|
224
|
+
}),
|
|
464
225
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
await ensureSynced(adapter);
|
|
468
|
-
return getAllContentTypes(adapter);
|
|
469
|
-
},
|
|
470
|
-
getAllContentItems: async (
|
|
471
|
-
contentTypeSlug: string,
|
|
472
|
-
params?: Parameters<typeof getAllContentItems>[2],
|
|
473
|
-
) => {
|
|
474
|
-
await ensureSynced(adapter);
|
|
475
|
-
return getAllContentItems(adapter, contentTypeSlug, params);
|
|
476
|
-
},
|
|
477
|
-
getContentItemBySlug: async (contentTypeSlug: string, slug: string) => {
|
|
478
|
-
await ensureSynced(adapter);
|
|
479
|
-
return getContentItemBySlug(adapter, contentTypeSlug, slug);
|
|
480
|
-
},
|
|
481
|
-
getContentItemById: async (id: string) => {
|
|
482
|
-
await ensureSynced(adapter);
|
|
483
|
-
return getContentItemById(adapter, id);
|
|
484
|
-
},
|
|
226
|
+
/** Lower-level SSG helper that intentionally bypasses auth and hooks. */
|
|
227
|
+
raw: (adapter: Adapter) => ({
|
|
485
228
|
prefetchForRoute: createCMSPrefetchForRoute(adapter),
|
|
486
|
-
// Mutations
|
|
487
|
-
createContentItem: async (
|
|
488
|
-
typeSlug: string,
|
|
489
|
-
input: Parameters<typeof createCMSContentItem>[2],
|
|
490
|
-
options?: Parameters<typeof createCMSContentItem>[3],
|
|
491
|
-
) => {
|
|
492
|
-
await ensureSynced(adapter);
|
|
493
|
-
return createCMSContentItem(adapter, typeSlug, input, options);
|
|
494
|
-
},
|
|
495
229
|
}),
|
|
496
230
|
|
|
497
|
-
routes: (
|
|
498
|
-
|
|
499
|
-
const
|
|
500
|
-
config.maxPageSize,
|
|
501
|
-
);
|
|
502
|
-
const paginationQuerySchema = z.object({
|
|
231
|
+
routes: (_adapter: Adapter, _context, operations) => {
|
|
232
|
+
const listQuerySchema = createListContentQuerySchema(config.maxPageSize);
|
|
233
|
+
const paginationSchema = z.object({
|
|
503
234
|
limit: z.coerce
|
|
504
235
|
.number()
|
|
505
236
|
.min(1)
|
|
@@ -508,742 +239,133 @@ export const cmsBackendPlugin = (config: CMSBackendConfig) => {
|
|
|
508
239
|
.default(20),
|
|
509
240
|
offset: z.coerce.number().min(0).optional().default(0),
|
|
510
241
|
});
|
|
511
|
-
|
|
512
|
-
// Helper to get content type by slug
|
|
513
|
-
const getContentType = async (
|
|
514
|
-
slug: string,
|
|
515
|
-
): Promise<ContentType | null> => {
|
|
516
|
-
await ensureSynced(adapter);
|
|
517
|
-
return adapter.findOne<ContentType>({
|
|
518
|
-
model: "contentType",
|
|
519
|
-
where: [{ field: "slug", value: slug, operator: "eq" as const }],
|
|
520
|
-
});
|
|
521
|
-
};
|
|
522
|
-
|
|
523
|
-
// Helper to create hook context
|
|
524
|
-
const createContext = (
|
|
525
|
-
typeSlug: string,
|
|
526
|
-
headers?: Headers,
|
|
527
|
-
): CMSHookContext => ({
|
|
528
|
-
typeSlug,
|
|
529
|
-
headers,
|
|
530
|
-
});
|
|
531
|
-
|
|
532
|
-
// ========== Content Type Endpoints ==========
|
|
533
|
-
|
|
534
242
|
const listContentTypes = createEndpoint(
|
|
535
243
|
"/content-types",
|
|
536
|
-
{ method: "GET" },
|
|
537
|
-
|
|
538
|
-
await ensureSynced(adapter);
|
|
539
|
-
|
|
540
|
-
const contentTypes = await adapter.findMany<ContentType>({
|
|
541
|
-
model: "contentType",
|
|
542
|
-
sortBy: { field: "name", direction: "asc" },
|
|
543
|
-
});
|
|
544
|
-
|
|
545
|
-
// Get item counts for each content type via adapter.count() (avoids N+1 scan)
|
|
546
|
-
const typesWithCounts = await Promise.all(
|
|
547
|
-
contentTypes.map(async (ct) => {
|
|
548
|
-
const itemCount: number = await adapter.count({
|
|
549
|
-
model: "contentItem",
|
|
550
|
-
where: [
|
|
551
|
-
{
|
|
552
|
-
field: "contentTypeId",
|
|
553
|
-
value: ct.id,
|
|
554
|
-
operator: "eq" as const,
|
|
555
|
-
},
|
|
556
|
-
],
|
|
557
|
-
});
|
|
558
|
-
return {
|
|
559
|
-
...serializeContentType(ct),
|
|
560
|
-
itemCount,
|
|
561
|
-
};
|
|
562
|
-
}),
|
|
563
|
-
);
|
|
564
|
-
|
|
565
|
-
return typesWithCounts;
|
|
566
|
-
},
|
|
244
|
+
{ method: "GET", requireRequest: true },
|
|
245
|
+
operations.listContentTypes.route(() => ({})),
|
|
567
246
|
);
|
|
568
|
-
|
|
569
247
|
const getContentTypeBySlug = createEndpoint(
|
|
570
248
|
"/content-types/:slug",
|
|
571
249
|
{
|
|
572
250
|
method: "GET",
|
|
573
|
-
params:
|
|
574
|
-
|
|
575
|
-
async (ctx) => {
|
|
576
|
-
const { slug } = ctx.params;
|
|
577
|
-
const contentType = await getContentType(slug);
|
|
578
|
-
|
|
579
|
-
if (!contentType) {
|
|
580
|
-
throw ctx.error(404, { message: "Content type not found" });
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
return serializeContentType(contentType);
|
|
251
|
+
params: CMSContentTypeParamsSchema,
|
|
252
|
+
requireRequest: true,
|
|
584
253
|
},
|
|
254
|
+
operations.getContentTypeBySlug.route((ctx) => ctx.params),
|
|
585
255
|
);
|
|
586
|
-
|
|
587
|
-
// ========== Content Item Endpoints ==========
|
|
588
|
-
|
|
589
256
|
const listContentItems = createEndpoint(
|
|
590
257
|
"/content/:typeSlug",
|
|
591
258
|
{
|
|
592
259
|
method: "GET",
|
|
593
|
-
params: z.object({ typeSlug: z.string() }),
|
|
594
|
-
query:
|
|
595
|
-
|
|
596
|
-
async (ctx) => {
|
|
597
|
-
const { typeSlug } = ctx.params;
|
|
598
|
-
const { slug, search, limit, offset } = ctx.query;
|
|
599
|
-
|
|
600
|
-
const contentType = await getContentType(typeSlug);
|
|
601
|
-
if (!contentType) {
|
|
602
|
-
throw ctx.error(404, { message: "Content type not found" });
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
return getAllContentItems(adapter, typeSlug, {
|
|
606
|
-
slug,
|
|
607
|
-
search,
|
|
608
|
-
limit,
|
|
609
|
-
offset,
|
|
610
|
-
});
|
|
260
|
+
params: z.object({ typeSlug: z.string().min(1) }),
|
|
261
|
+
query: listQuerySchema,
|
|
262
|
+
requireRequest: true,
|
|
611
263
|
},
|
|
264
|
+
operations.listContentItems.route((ctx) => ({
|
|
265
|
+
typeSlug: ctx.params.typeSlug,
|
|
266
|
+
query: ctx.query,
|
|
267
|
+
})),
|
|
612
268
|
);
|
|
613
|
-
|
|
614
269
|
const getContentItem = createEndpoint(
|
|
615
270
|
"/content/:typeSlug/:id",
|
|
616
271
|
{
|
|
617
272
|
method: "GET",
|
|
618
|
-
params:
|
|
619
|
-
|
|
620
|
-
async (ctx) => {
|
|
621
|
-
const { typeSlug, id } = ctx.params;
|
|
622
|
-
|
|
623
|
-
const contentType = await getContentType(typeSlug);
|
|
624
|
-
if (!contentType) {
|
|
625
|
-
throw ctx.error(404, { message: "Content type not found" });
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
const item = await adapter.findOne<ContentItemWithType>({
|
|
629
|
-
model: "contentItem",
|
|
630
|
-
where: [{ field: "id", value: id, operator: "eq" as const }],
|
|
631
|
-
join: { contentType: true },
|
|
632
|
-
});
|
|
633
|
-
|
|
634
|
-
if (!item || item.contentTypeId !== contentType.id) {
|
|
635
|
-
throw ctx.error(404, { message: "Content item not found" });
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
return serializeContentItemWithType(item);
|
|
273
|
+
params: CMSContentItemParamsSchema,
|
|
274
|
+
requireRequest: true,
|
|
639
275
|
},
|
|
276
|
+
operations.getContentItem.route((ctx) => ctx.params),
|
|
640
277
|
);
|
|
641
|
-
|
|
642
278
|
const createContentItem = createEndpoint(
|
|
643
279
|
"/content/:typeSlug",
|
|
644
280
|
{
|
|
645
281
|
method: "POST",
|
|
646
|
-
params: z.object({ typeSlug: z.string() }),
|
|
647
|
-
body:
|
|
648
|
-
|
|
649
|
-
// Use passthrough object instead of z.record(z.unknown()) due to Zod v4 bug
|
|
650
|
-
data: z.object({}).passthrough(),
|
|
651
|
-
}),
|
|
652
|
-
},
|
|
653
|
-
async (ctx) => {
|
|
654
|
-
const { typeSlug } = ctx.params;
|
|
655
|
-
const { slug: rawSlug, data } = ctx.body;
|
|
656
|
-
const context = createContext(typeSlug, ctx.headers);
|
|
657
|
-
|
|
658
|
-
// Sanitize slug to ensure it's URL-safe
|
|
659
|
-
const slug = slugify(rawSlug);
|
|
660
|
-
|
|
661
|
-
// Validate that slugification produced a non-empty result
|
|
662
|
-
if (!slug) {
|
|
663
|
-
throw ctx.error(400, {
|
|
664
|
-
message:
|
|
665
|
-
"Invalid slug: must contain at least one alphanumeric character",
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
const contentType = await getContentType(typeSlug);
|
|
670
|
-
if (!contentType) {
|
|
671
|
-
throw ctx.error(404, { message: "Content type not found" });
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
// Process relation fields FIRST - this creates new items from _new values
|
|
675
|
-
// and converts them to ID references before Zod validation
|
|
676
|
-
const { processedData: dataWithResolvedRelations, relationIds } =
|
|
677
|
-
await processRelationsInData(
|
|
678
|
-
adapter,
|
|
679
|
-
contentType,
|
|
680
|
-
data as Record<string, unknown>,
|
|
681
|
-
getContentType,
|
|
682
|
-
);
|
|
683
|
-
|
|
684
|
-
// Validate data against content type schema (now with resolved relations)
|
|
685
|
-
const zodSchema = getContentTypeZodSchema(contentType);
|
|
686
|
-
const validation = zodSchema.safeParse(dataWithResolvedRelations);
|
|
687
|
-
if (!validation.success) {
|
|
688
|
-
// `issues` matches the shape better-call emits for body
|
|
689
|
-
// validation errors, so clients get field-level errors
|
|
690
|
-
// (StackError.errors) for inline form display.
|
|
691
|
-
throw ctx.error(400, {
|
|
692
|
-
message: "Validation failed",
|
|
693
|
-
issues: validation.error.issues,
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
// Check for duplicate slug within content type
|
|
698
|
-
const existing = await adapter.findOne<ContentItem>({
|
|
699
|
-
model: "contentItem",
|
|
700
|
-
where: [
|
|
701
|
-
{
|
|
702
|
-
field: "contentTypeId",
|
|
703
|
-
value: contentType.id,
|
|
704
|
-
operator: "eq" as const,
|
|
705
|
-
},
|
|
706
|
-
{ field: "slug", value: slug, operator: "eq" as const },
|
|
707
|
-
],
|
|
708
|
-
});
|
|
709
|
-
if (existing) {
|
|
710
|
-
throw ctx.error(409, {
|
|
711
|
-
message: "Content item with this slug already exists",
|
|
712
|
-
});
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
// Call before hook - may deny operation
|
|
716
|
-
const processedData = validation.data as Record<string, unknown>;
|
|
717
|
-
if (config.hooks?.onBeforeCreate) {
|
|
718
|
-
await runHook(
|
|
719
|
-
() => config.hooks!.onBeforeCreate!(processedData, context),
|
|
720
|
-
ctx.error,
|
|
721
|
-
"Create operation denied",
|
|
722
|
-
);
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
const item = await adapter.create<ContentItem>({
|
|
726
|
-
model: "contentItem",
|
|
727
|
-
data: {
|
|
728
|
-
contentTypeId: contentType.id,
|
|
729
|
-
slug,
|
|
730
|
-
data: JSON.stringify(processedData),
|
|
731
|
-
createdAt: new Date(),
|
|
732
|
-
updatedAt: new Date(),
|
|
733
|
-
},
|
|
734
|
-
});
|
|
735
|
-
|
|
736
|
-
// Sync relations to junction table
|
|
737
|
-
await syncRelations(adapter, item.id, relationIds);
|
|
738
|
-
|
|
739
|
-
const serialized = serializeContentItem(item);
|
|
740
|
-
|
|
741
|
-
// Call after hook
|
|
742
|
-
if (config.hooks?.onAfterCreate) {
|
|
743
|
-
await config.hooks.onAfterCreate(serialized, context);
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
return {
|
|
747
|
-
...serialized,
|
|
748
|
-
parsedData: processedData,
|
|
749
|
-
};
|
|
282
|
+
params: z.object({ typeSlug: z.string().min(1) }),
|
|
283
|
+
body: CMSCreateContentItemBodySchema,
|
|
284
|
+
requireRequest: true,
|
|
750
285
|
},
|
|
286
|
+
operations.createContentItem.route((ctx) => ({
|
|
287
|
+
typeSlug: ctx.params.typeSlug,
|
|
288
|
+
body: ctx.body,
|
|
289
|
+
})),
|
|
751
290
|
);
|
|
752
|
-
|
|
753
291
|
const updateContentItem = createEndpoint(
|
|
754
292
|
"/content/:typeSlug/:id",
|
|
755
293
|
{
|
|
756
294
|
method: "PUT",
|
|
757
|
-
params:
|
|
758
|
-
body:
|
|
759
|
-
|
|
760
|
-
// Use passthrough object instead of z.record(z.unknown()) due to Zod v4 bug
|
|
761
|
-
data: z.object({}).passthrough().optional(),
|
|
762
|
-
}),
|
|
763
|
-
},
|
|
764
|
-
async (ctx) => {
|
|
765
|
-
const { typeSlug, id } = ctx.params;
|
|
766
|
-
const { slug: rawSlug, data } = ctx.body;
|
|
767
|
-
const context = createContext(typeSlug, ctx.headers);
|
|
768
|
-
|
|
769
|
-
// Sanitize slug if provided to ensure it's URL-safe
|
|
770
|
-
const slug = rawSlug ? slugify(rawSlug) : undefined;
|
|
771
|
-
|
|
772
|
-
// Validate that slugification produced a non-empty result (if slug was provided)
|
|
773
|
-
if (rawSlug && !slug) {
|
|
774
|
-
throw ctx.error(400, {
|
|
775
|
-
message:
|
|
776
|
-
"Invalid slug: must contain at least one alphanumeric character",
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
const contentType = await getContentType(typeSlug);
|
|
781
|
-
if (!contentType) {
|
|
782
|
-
throw ctx.error(404, { message: "Content type not found" });
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
const existing = await adapter.findOne<ContentItem>({
|
|
786
|
-
model: "contentItem",
|
|
787
|
-
where: [{ field: "id", value: id, operator: "eq" as const }],
|
|
788
|
-
});
|
|
789
|
-
|
|
790
|
-
if (!existing || existing.contentTypeId !== contentType.id) {
|
|
791
|
-
throw ctx.error(404, { message: "Content item not found" });
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
// Check for duplicate slug if slug is being changed
|
|
795
|
-
if (slug && slug !== existing.slug) {
|
|
796
|
-
const duplicate = await adapter.findOne<ContentItem>({
|
|
797
|
-
model: "contentItem",
|
|
798
|
-
where: [
|
|
799
|
-
{
|
|
800
|
-
field: "contentTypeId",
|
|
801
|
-
value: contentType.id,
|
|
802
|
-
operator: "eq" as const,
|
|
803
|
-
},
|
|
804
|
-
{ field: "slug", value: slug, operator: "eq" as const },
|
|
805
|
-
],
|
|
806
|
-
});
|
|
807
|
-
if (duplicate) {
|
|
808
|
-
throw ctx.error(409, {
|
|
809
|
-
message: "Content item with this slug already exists",
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
// Process relation fields FIRST if data is being updated
|
|
815
|
-
// This creates new items from _new values before Zod validation
|
|
816
|
-
let dataWithResolvedRelations: Record<string, unknown> | undefined;
|
|
817
|
-
let relationIds: Record<string, string[]> | undefined;
|
|
818
|
-
if (data) {
|
|
819
|
-
const result = await processRelationsInData(
|
|
820
|
-
adapter,
|
|
821
|
-
contentType,
|
|
822
|
-
data as Record<string, unknown>,
|
|
823
|
-
getContentType,
|
|
824
|
-
);
|
|
825
|
-
dataWithResolvedRelations = result.processedData;
|
|
826
|
-
relationIds = result.relationIds;
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
// Validate data if provided (now with resolved relations)
|
|
830
|
-
// IMPORTANT: Merge with existing data BEFORE Zod validation to prevent
|
|
831
|
-
// schema defaults (like .default([])) from overwriting existing values
|
|
832
|
-
// for fields not included in the partial update.
|
|
833
|
-
let validatedData = dataWithResolvedRelations;
|
|
834
|
-
if (dataWithResolvedRelations) {
|
|
835
|
-
// Parse existing data and merge with update data
|
|
836
|
-
// Update data takes precedence, but existing fields are preserved
|
|
837
|
-
const existingData = existing.data
|
|
838
|
-
? (JSON.parse(existing.data) as Record<string, unknown>)
|
|
839
|
-
: {};
|
|
840
|
-
const mergedData = {
|
|
841
|
-
...existingData,
|
|
842
|
-
...dataWithResolvedRelations,
|
|
843
|
-
};
|
|
844
|
-
|
|
845
|
-
const zodSchema = getContentTypeZodSchema(contentType);
|
|
846
|
-
const validation = zodSchema.safeParse(mergedData);
|
|
847
|
-
if (!validation.success) {
|
|
848
|
-
// See the create endpoint: `issues` → StackError.errors
|
|
849
|
-
throw ctx.error(400, {
|
|
850
|
-
message: "Validation failed",
|
|
851
|
-
issues: validation.error.issues,
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
validatedData = validation.data as Record<string, unknown>;
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
// Call before hook - may deny operation
|
|
858
|
-
const processedData = validatedData;
|
|
859
|
-
if (config.hooks?.onBeforeUpdate && validatedData) {
|
|
860
|
-
await runHook(
|
|
861
|
-
() => config.hooks!.onBeforeUpdate!(id, validatedData, context),
|
|
862
|
-
ctx.error,
|
|
863
|
-
"Update operation denied",
|
|
864
|
-
);
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
// Sync relations to junction table if data was updated
|
|
868
|
-
if (relationIds) {
|
|
869
|
-
await syncRelations(adapter, id, relationIds);
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
const updateData: Partial<ContentItem> = {
|
|
873
|
-
updatedAt: new Date(),
|
|
874
|
-
};
|
|
875
|
-
if (slug) updateData.slug = slug;
|
|
876
|
-
if (processedData) updateData.data = JSON.stringify(processedData);
|
|
877
|
-
|
|
878
|
-
await adapter.update({
|
|
879
|
-
model: "contentItem",
|
|
880
|
-
where: [{ field: "id", value: id, operator: "eq" as const }],
|
|
881
|
-
update: updateData,
|
|
882
|
-
});
|
|
883
|
-
|
|
884
|
-
const updated = await adapter.findOne<ContentItemWithType>({
|
|
885
|
-
model: "contentItem",
|
|
886
|
-
where: [{ field: "id", value: id, operator: "eq" as const }],
|
|
887
|
-
join: { contentType: true },
|
|
888
|
-
});
|
|
889
|
-
|
|
890
|
-
if (!updated) {
|
|
891
|
-
throw ctx.error(500, { message: "Failed to fetch updated item" });
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
const serialized = serializeContentItem(updated);
|
|
895
|
-
|
|
896
|
-
// Call after hook
|
|
897
|
-
if (config.hooks?.onAfterUpdate) {
|
|
898
|
-
await config.hooks.onAfterUpdate(serialized, context);
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
return serializeContentItemWithType(updated);
|
|
295
|
+
params: CMSContentItemParamsSchema,
|
|
296
|
+
body: CMSUpdateContentItemBodySchema,
|
|
297
|
+
requireRequest: true,
|
|
902
298
|
},
|
|
299
|
+
operations.updateContentItem.route((ctx) => ({
|
|
300
|
+
...ctx.params,
|
|
301
|
+
body: ctx.body,
|
|
302
|
+
})),
|
|
903
303
|
);
|
|
904
|
-
|
|
905
304
|
const deleteContentItem = createEndpoint(
|
|
906
305
|
"/content/:typeSlug/:id",
|
|
907
306
|
{
|
|
908
307
|
method: "DELETE",
|
|
909
|
-
params:
|
|
910
|
-
|
|
911
|
-
async (ctx) => {
|
|
912
|
-
const { typeSlug, id } = ctx.params;
|
|
913
|
-
const context = createContext(typeSlug, ctx.headers);
|
|
914
|
-
|
|
915
|
-
const contentType = await getContentType(typeSlug);
|
|
916
|
-
if (!contentType) {
|
|
917
|
-
throw ctx.error(404, { message: "Content type not found" });
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
const existing = await adapter.findOne<ContentItem>({
|
|
921
|
-
model: "contentItem",
|
|
922
|
-
where: [{ field: "id", value: id, operator: "eq" as const }],
|
|
923
|
-
});
|
|
924
|
-
|
|
925
|
-
if (!existing || existing.contentTypeId !== contentType.id) {
|
|
926
|
-
throw ctx.error(404, { message: "Content item not found" });
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
// Call before hook
|
|
930
|
-
if (config.hooks?.onBeforeDelete) {
|
|
931
|
-
await runHook(
|
|
932
|
-
() => config.hooks!.onBeforeDelete!(id, context),
|
|
933
|
-
ctx.error,
|
|
934
|
-
"Delete operation denied",
|
|
935
|
-
);
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
await adapter.delete({
|
|
939
|
-
model: "contentItem",
|
|
940
|
-
where: [{ field: "id", value: id, operator: "eq" as const }],
|
|
941
|
-
});
|
|
942
|
-
|
|
943
|
-
// Call after hook
|
|
944
|
-
if (config.hooks?.onAfterDelete) {
|
|
945
|
-
await config.hooks.onAfterDelete(id, context);
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
return { success: true };
|
|
308
|
+
params: CMSContentItemParamsSchema,
|
|
309
|
+
requireRequest: true,
|
|
949
310
|
},
|
|
311
|
+
operations.deleteContentItem.route((ctx) => ctx.params),
|
|
950
312
|
);
|
|
951
|
-
|
|
952
|
-
// ========== Relation Endpoints ==========
|
|
953
|
-
|
|
954
313
|
const getContentItemPopulated = createEndpoint(
|
|
955
314
|
"/content/:typeSlug/:id/populated",
|
|
956
315
|
{
|
|
957
316
|
method: "GET",
|
|
958
|
-
params:
|
|
959
|
-
|
|
960
|
-
async (ctx) => {
|
|
961
|
-
const { typeSlug, id } = ctx.params;
|
|
962
|
-
|
|
963
|
-
const contentType = await getContentType(typeSlug);
|
|
964
|
-
if (!contentType) {
|
|
965
|
-
throw ctx.error(404, { message: "Content type not found" });
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
const item = await adapter.findOne<ContentItemWithType>({
|
|
969
|
-
model: "contentItem",
|
|
970
|
-
where: [{ field: "id", value: id, operator: "eq" as const }],
|
|
971
|
-
join: { contentType: true },
|
|
972
|
-
});
|
|
973
|
-
|
|
974
|
-
if (!item || item.contentTypeId !== contentType.id) {
|
|
975
|
-
throw ctx.error(404, { message: "Content item not found" });
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
// Populate relations
|
|
979
|
-
const _relations = await populateRelations(adapter, item);
|
|
980
|
-
|
|
981
|
-
return {
|
|
982
|
-
...serializeContentItemWithType(item),
|
|
983
|
-
_relations,
|
|
984
|
-
};
|
|
317
|
+
params: CMSContentItemParamsSchema,
|
|
318
|
+
requireRequest: true,
|
|
985
319
|
},
|
|
320
|
+
operations.getContentItemPopulated.route((ctx) => ctx.params),
|
|
986
321
|
);
|
|
987
|
-
|
|
988
322
|
const listContentByRelation = createEndpoint(
|
|
989
323
|
"/content/:typeSlug/by-relation",
|
|
990
324
|
{
|
|
991
325
|
method: "GET",
|
|
992
|
-
params: z.object({ typeSlug: z.string() }),
|
|
326
|
+
params: z.object({ typeSlug: z.string().min(1) }),
|
|
993
327
|
query: z
|
|
994
|
-
.object({
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
})
|
|
998
|
-
.merge(paginationQuerySchema),
|
|
999
|
-
},
|
|
1000
|
-
async (ctx) => {
|
|
1001
|
-
const { typeSlug } = ctx.params;
|
|
1002
|
-
const { field, targetId, limit, offset } = ctx.query;
|
|
1003
|
-
|
|
1004
|
-
const contentType = await getContentType(typeSlug);
|
|
1005
|
-
if (!contentType) {
|
|
1006
|
-
throw ctx.error(404, { message: "Content type not found" });
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
// Find all content relations where the target matches
|
|
1010
|
-
const contentRelations = await adapter.findMany<ContentRelation>({
|
|
1011
|
-
model: "contentRelation",
|
|
1012
|
-
where: [
|
|
1013
|
-
{ field: "targetId", value: targetId, operator: "eq" as const },
|
|
1014
|
-
{ field: "fieldName", value: field, operator: "eq" as const },
|
|
1015
|
-
],
|
|
1016
|
-
});
|
|
1017
|
-
|
|
1018
|
-
// Get unique source IDs that belong to this content type
|
|
1019
|
-
const sourceIds = [
|
|
1020
|
-
...new Set(contentRelations.map((r) => r.sourceId)),
|
|
1021
|
-
];
|
|
1022
|
-
|
|
1023
|
-
if (sourceIds.length === 0) {
|
|
1024
|
-
return {
|
|
1025
|
-
items: [],
|
|
1026
|
-
total: 0,
|
|
1027
|
-
limit,
|
|
1028
|
-
offset,
|
|
1029
|
-
};
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
// Fetch all matching items (filtering by content type)
|
|
1033
|
-
const allItems: ContentItemWithType[] = [];
|
|
1034
|
-
for (const sourceId of sourceIds) {
|
|
1035
|
-
const item = await adapter.findOne<ContentItemWithType>({
|
|
1036
|
-
model: "contentItem",
|
|
1037
|
-
where: [
|
|
1038
|
-
{ field: "id", value: sourceId, operator: "eq" as const },
|
|
1039
|
-
{
|
|
1040
|
-
field: "contentTypeId",
|
|
1041
|
-
value: contentType.id,
|
|
1042
|
-
operator: "eq" as const,
|
|
1043
|
-
},
|
|
1044
|
-
],
|
|
1045
|
-
join: { contentType: true },
|
|
1046
|
-
});
|
|
1047
|
-
if (item) {
|
|
1048
|
-
allItems.push(item);
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
// Sort by createdAt desc
|
|
1053
|
-
allItems.sort(
|
|
1054
|
-
(a, b) => b.createdAt.getTime() - a.createdAt.getTime(),
|
|
1055
|
-
);
|
|
1056
|
-
|
|
1057
|
-
const total = allItems.length;
|
|
1058
|
-
const paginatedItems = allItems.slice(offset, offset + limit);
|
|
1059
|
-
|
|
1060
|
-
return {
|
|
1061
|
-
items: paginatedItems.map(serializeContentItemWithType),
|
|
1062
|
-
total,
|
|
1063
|
-
limit,
|
|
1064
|
-
offset,
|
|
1065
|
-
};
|
|
328
|
+
.object({ field: z.string(), targetId: z.string() })
|
|
329
|
+
.merge(paginationSchema),
|
|
330
|
+
requireRequest: true,
|
|
1066
331
|
},
|
|
332
|
+
operations.listContentByRelation.route((ctx) => ({
|
|
333
|
+
typeSlug: ctx.params.typeSlug,
|
|
334
|
+
query: ctx.query,
|
|
335
|
+
})),
|
|
1067
336
|
);
|
|
1068
|
-
|
|
1069
|
-
// ========== Inverse Relation Endpoints ==========
|
|
1070
|
-
|
|
1071
337
|
const getInverseRelations = createEndpoint(
|
|
1072
338
|
"/content-types/:slug/inverse-relations",
|
|
1073
339
|
{
|
|
1074
340
|
method: "GET",
|
|
1075
|
-
params:
|
|
1076
|
-
query: z.object({
|
|
1077
|
-
|
|
1078
|
-
}),
|
|
1079
|
-
},
|
|
1080
|
-
async (ctx) => {
|
|
1081
|
-
const { slug } = ctx.params;
|
|
1082
|
-
const { itemId } = ctx.query;
|
|
1083
|
-
|
|
1084
|
-
await ensureSynced(adapter);
|
|
1085
|
-
|
|
1086
|
-
// Get the target content type
|
|
1087
|
-
const targetContentType = await getContentType(slug);
|
|
1088
|
-
if (!targetContentType) {
|
|
1089
|
-
throw ctx.error(404, { message: "Content type not found" });
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
// Find all content types that have belongsTo relations pointing to this type
|
|
1093
|
-
const allContentTypes = await adapter.findMany<ContentType>({
|
|
1094
|
-
model: "contentType",
|
|
1095
|
-
});
|
|
1096
|
-
|
|
1097
|
-
const inverseRelations: InverseRelation[] = [];
|
|
1098
|
-
|
|
1099
|
-
for (const contentType of allContentTypes) {
|
|
1100
|
-
const relationFields = extractRelationFields(contentType);
|
|
1101
|
-
|
|
1102
|
-
for (const [fieldName, relationConfig] of Object.entries(
|
|
1103
|
-
relationFields,
|
|
1104
|
-
)) {
|
|
1105
|
-
// Only include belongsTo relations that point to the target type
|
|
1106
|
-
if (
|
|
1107
|
-
relationConfig.type === "belongsTo" &&
|
|
1108
|
-
relationConfig.targetType === slug
|
|
1109
|
-
) {
|
|
1110
|
-
let count = 0;
|
|
1111
|
-
|
|
1112
|
-
// If itemId is provided, count items that reference this specific item
|
|
1113
|
-
if (itemId) {
|
|
1114
|
-
const relations = await adapter.findMany<ContentRelation>({
|
|
1115
|
-
model: "contentRelation",
|
|
1116
|
-
where: [
|
|
1117
|
-
{
|
|
1118
|
-
field: "targetId",
|
|
1119
|
-
value: itemId,
|
|
1120
|
-
operator: "eq" as const,
|
|
1121
|
-
},
|
|
1122
|
-
{
|
|
1123
|
-
field: "fieldName",
|
|
1124
|
-
value: fieldName,
|
|
1125
|
-
operator: "eq" as const,
|
|
1126
|
-
},
|
|
1127
|
-
],
|
|
1128
|
-
});
|
|
1129
|
-
// Filter to only include relations from this content type
|
|
1130
|
-
const itemIds = relations.map((r) => r.sourceId);
|
|
1131
|
-
for (const sourceId of itemIds) {
|
|
1132
|
-
const item = await adapter.findOne<ContentItem>({
|
|
1133
|
-
model: "contentItem",
|
|
1134
|
-
where: [
|
|
1135
|
-
{
|
|
1136
|
-
field: "id",
|
|
1137
|
-
value: sourceId,
|
|
1138
|
-
operator: "eq" as const,
|
|
1139
|
-
},
|
|
1140
|
-
{
|
|
1141
|
-
field: "contentTypeId",
|
|
1142
|
-
value: contentType.id,
|
|
1143
|
-
operator: "eq" as const,
|
|
1144
|
-
},
|
|
1145
|
-
],
|
|
1146
|
-
});
|
|
1147
|
-
if (item) count++;
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
inverseRelations.push({
|
|
1152
|
-
sourceType: contentType.slug,
|
|
1153
|
-
sourceTypeName: contentType.name,
|
|
1154
|
-
fieldName,
|
|
1155
|
-
count,
|
|
1156
|
-
});
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
return { inverseRelations };
|
|
341
|
+
params: CMSContentTypeParamsSchema,
|
|
342
|
+
query: z.object({ itemId: z.string().optional() }),
|
|
343
|
+
requireRequest: true,
|
|
1162
344
|
},
|
|
345
|
+
operations.getInverseRelations.route((ctx) => ({
|
|
346
|
+
slug: ctx.params.slug,
|
|
347
|
+
query: ctx.query,
|
|
348
|
+
})),
|
|
1163
349
|
);
|
|
1164
|
-
|
|
1165
350
|
const listInverseRelationItems = createEndpoint(
|
|
1166
351
|
"/content-types/:slug/inverse-relations/:sourceType",
|
|
1167
352
|
{
|
|
1168
353
|
method: "GET",
|
|
1169
354
|
params: z.object({
|
|
1170
|
-
slug: z.string(),
|
|
1171
|
-
sourceType: z.string(),
|
|
355
|
+
slug: z.string().min(1),
|
|
356
|
+
sourceType: z.string().min(1),
|
|
1172
357
|
}),
|
|
1173
358
|
query: z
|
|
1174
|
-
.object({
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
})
|
|
1178
|
-
.merge(paginationQuerySchema),
|
|
1179
|
-
},
|
|
1180
|
-
async (ctx) => {
|
|
1181
|
-
const { slug, sourceType } = ctx.params;
|
|
1182
|
-
const { itemId, fieldName, limit, offset } = ctx.query;
|
|
1183
|
-
|
|
1184
|
-
await ensureSynced(adapter);
|
|
1185
|
-
|
|
1186
|
-
// Verify target content type exists
|
|
1187
|
-
const targetContentType = await getContentType(slug);
|
|
1188
|
-
if (!targetContentType) {
|
|
1189
|
-
throw ctx.error(404, { message: "Target content type not found" });
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
// Verify source content type exists
|
|
1193
|
-
const sourceContentType = await getContentType(sourceType);
|
|
1194
|
-
if (!sourceContentType) {
|
|
1195
|
-
throw ctx.error(404, { message: "Source content type not found" });
|
|
1196
|
-
}
|
|
1197
|
-
|
|
1198
|
-
// Find all relations pointing to this item
|
|
1199
|
-
const relations = await adapter.findMany<ContentRelation>({
|
|
1200
|
-
model: "contentRelation",
|
|
1201
|
-
where: [
|
|
1202
|
-
{ field: "targetId", value: itemId, operator: "eq" as const },
|
|
1203
|
-
{ field: "fieldName", value: fieldName, operator: "eq" as const },
|
|
1204
|
-
],
|
|
1205
|
-
});
|
|
1206
|
-
|
|
1207
|
-
// Get unique source IDs
|
|
1208
|
-
const sourceIds = [...new Set(relations.map((r) => r.sourceId))];
|
|
1209
|
-
|
|
1210
|
-
// Fetch all matching items from the source content type
|
|
1211
|
-
const allItems: ContentItemWithType[] = [];
|
|
1212
|
-
for (const sourceId of sourceIds) {
|
|
1213
|
-
const item = await adapter.findOne<ContentItemWithType>({
|
|
1214
|
-
model: "contentItem",
|
|
1215
|
-
where: [
|
|
1216
|
-
{ field: "id", value: sourceId, operator: "eq" as const },
|
|
1217
|
-
{
|
|
1218
|
-
field: "contentTypeId",
|
|
1219
|
-
value: sourceContentType.id,
|
|
1220
|
-
operator: "eq" as const,
|
|
1221
|
-
},
|
|
1222
|
-
],
|
|
1223
|
-
join: { contentType: true },
|
|
1224
|
-
});
|
|
1225
|
-
if (item) {
|
|
1226
|
-
allItems.push(item);
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
|
-
// Sort by createdAt desc
|
|
1231
|
-
allItems.sort(
|
|
1232
|
-
(a, b) => b.createdAt.getTime() - a.createdAt.getTime(),
|
|
1233
|
-
);
|
|
1234
|
-
|
|
1235
|
-
const total = allItems.length;
|
|
1236
|
-
const paginatedItems = allItems.slice(offset, offset + limit);
|
|
1237
|
-
|
|
1238
|
-
return {
|
|
1239
|
-
items: paginatedItems.map(serializeContentItemWithType),
|
|
1240
|
-
total,
|
|
1241
|
-
limit,
|
|
1242
|
-
offset,
|
|
1243
|
-
};
|
|
359
|
+
.object({ itemId: z.string(), fieldName: z.string() })
|
|
360
|
+
.merge(paginationSchema),
|
|
361
|
+
requireRequest: true,
|
|
1244
362
|
},
|
|
363
|
+
operations.listInverseRelationItems.route((ctx) => ({
|
|
364
|
+
slug: ctx.params.slug,
|
|
365
|
+
sourceType: ctx.params.sourceType,
|
|
366
|
+
query: ctx.query,
|
|
367
|
+
})),
|
|
1245
368
|
);
|
|
1246
|
-
|
|
1247
369
|
return {
|
|
1248
370
|
listContentTypes,
|
|
1249
371
|
getContentTypeBySlug,
|
|
@@ -1256,7 +378,7 @@ export const cmsBackendPlugin = (config: CMSBackendConfig) => {
|
|
|
1256
378
|
listContentByRelation,
|
|
1257
379
|
getInverseRelations,
|
|
1258
380
|
listInverseRelationItems,
|
|
1259
|
-
};
|
|
381
|
+
} as const;
|
|
1260
382
|
},
|
|
1261
383
|
});
|
|
1262
384
|
};
|