@btst/stack 3.0.0-rc.2 → 3.0.0-rc.4
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 +118 -38
- 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 +19 -7
- package/dist/next/index.d.mts +19 -7
- package/dist/next/index.d.ts +19 -7
- 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/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 +160 -104
- package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.mjs +161 -105
- 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 +10 -5
- package/dist/packages/stack/src/react-router/page.mjs +11 -6
- 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 +6 -2
- package/dist/packages/stack/src/tanstack/page.mjs +6 -2
- 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 +2 -2
- package/dist/plugins/comments/client/components/index.d.mts +2 -2
- package/dist/plugins/comments/client/components/index.d.ts +2 -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 +29 -5
- package/dist/react-router/index.d.mts +29 -5
- package/dist/react-router/index.d.ts +29 -5
- 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.cts → stack.5_zzCejP.d.cts} +16 -14
- package/dist/shared/{stack.9BAOaSqE.d.mts → stack.5_zzCejP.d.mts} +16 -14
- package/dist/shared/{stack.9BAOaSqE.d.ts → stack.5_zzCejP.d.ts} +16 -14
- package/dist/shared/{stack.oVIdV7XS.d.mts → stack.94kN3pEK.d.mts} +4 -4
- 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.BFP_9pRX.d.cts +707 -0
- 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.BMlTZnZp.d.ts +764 -0
- package/dist/shared/stack.BMmvEBH_.d.ts +118 -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.DzwZw-Ck.d.cts → stack.BTStHVTy.d.cts} +4 -4
- package/dist/shared/stack.BV0uNV4f.d.cts +764 -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.BggTHKlo.d.mts +1184 -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.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.CGmh-Lpe.d.ts +408 -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.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.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.CtrnoQgH.d.cts +1184 -0
- package/dist/shared/stack.CvlC5kqe.d.cts +331 -0
- package/dist/shared/stack.CxKc9evq.d.ts +23 -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.DseBJmGF.d.ts → stack.DfrRYOIl.d.ts} +4 -4
- package/dist/shared/stack.DiuRuzIs.d.cts +613 -0
- package/dist/shared/{stack.BMlLOMED.d.cts → stack.DjGixVx3.d.cts} +6 -2
- package/dist/shared/{stack.BMlLOMED.d.mts → stack.DjGixVx3.d.mts} +6 -2
- package/dist/shared/{stack.BMlLOMED.d.ts → stack.DjGixVx3.d.ts} +6 -2
- 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.Doy2_wgl.d.mts +408 -0
- package/dist/shared/stack.DxHPKr2R.d.mts +436 -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.lPKwd_v0.d.ts +1184 -0
- package/dist/shared/stack.lsbdKRj7.d.mts +764 -0
- package/dist/shared/stack.v2O65JqF.d.cts +351 -0
- package/dist/shared/stack.zch70Loj.d.cts +408 -0
- package/dist/tanstack/index.cjs +2 -0
- package/dist/tanstack/index.d.cts +27 -5
- package/dist/tanstack/index.d.mts +27 -5
- package/dist/tanstack/index.d.ts +27 -5
- 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 +198 -3
- 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__/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 +294 -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/layout.tsx +81 -0
- package/src/next/page.tsx +16 -3
- 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 +445 -82
- 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 +148 -110
- 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 +5 -0
- package/src/react-router/layout.ts +43 -0
- package/src/react-router/page.tsx +12 -5
- package/src/react-router/router.tsx +1 -1
- package/src/shared/auth-types.ts +19 -70
- package/src/shared/entry-factories.ts +3 -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 +5 -0
- package/src/tanstack/layout.ts +36 -0
- package/src/tanstack/page.tsx +7 -2
- package/src/tanstack/router.tsx +1 -1
- package/src/tanstack/server.ts +18 -0
- package/src/types.ts +557 -65
- 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.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.BsmDN8r9.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.CKGjOI3Z.d.cts +0 -840
- package/dist/shared/stack.Cf-DbL1A.d.ts +0 -329
- package/dist/shared/stack.CuI_-z-_.d.cts +0 -560
- package/dist/shared/stack.D2RVkQD8.d.mts +0 -560
- 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.DOzsgzkY.d.ts +0 -406
- package/dist/shared/stack.DQq8DEIv.d.mts +0 -461
- package/dist/shared/stack.DXrOtuek.d.ts +0 -560
- package/dist/shared/stack.DZHEHd-S.d.mts +0 -840
- package/dist/shared/stack.Dd-8shBE.d.ts +0 -492
- package/dist/shared/stack.EOPVnJrF.d.cts +0 -39
- package/dist/shared/stack.EOPVnJrF.d.mts +0 -39
- package/dist/shared/stack.EOPVnJrF.d.ts +0 -39
- package/dist/shared/stack.NGKtwA6S.d.mts +0 -406
- package/dist/shared/stack.WELCDuMs.d.ts +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.oBokjN_J.d.mts +0 -416
- package/dist/shared/{stack.D18Dq3ve.d.mts → stack.CKc_Bais.d.cts} +8 -8
- package/dist/shared/{stack.D18Dq3ve.d.ts → stack.CKc_Bais.d.mts} +8 -8
- package/dist/shared/{stack.D18Dq3ve.d.cts → stack.CKc_Bais.d.ts} +8 -8
|
@@ -0,0 +1,1382 @@
|
|
|
1
|
+
import { createMemoryAdapter } from "@btst/adapter-memory";
|
|
2
|
+
import { type DatabaseDefinition, type DBAdapter, defineDb } from "@btst/db";
|
|
3
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { createBackendStack } from "../../../api";
|
|
7
|
+
import { defineAuthorization } from "../../../authorization";
|
|
8
|
+
import {
|
|
9
|
+
createServerAuth,
|
|
10
|
+
type ServerAuth,
|
|
11
|
+
} from "../../../authorization/server";
|
|
12
|
+
import {
|
|
13
|
+
KANBAN_LIFECYCLE_HOOK_MIGRATIONS,
|
|
14
|
+
KANBAN_QUERY_KEYS,
|
|
15
|
+
kanbanBackendPlugin,
|
|
16
|
+
} from "../api";
|
|
17
|
+
import { kanbanPermissions } from "../permissions";
|
|
18
|
+
import type { Board, Column, KanbanBackendHooks, Task } from "../types";
|
|
19
|
+
|
|
20
|
+
const rawMemoryAdapter = (db: DatabaseDefinition) =>
|
|
21
|
+
createMemoryAdapter(db)({});
|
|
22
|
+
|
|
23
|
+
describe("Kanban authorization inventory", () => {
|
|
24
|
+
it("records every removed lifecycle spelling", () => {
|
|
25
|
+
expect(KANBAN_LIFECYCLE_HOOK_MIGRATIONS).toEqual({
|
|
26
|
+
onBeforeReadBoard: "onBeforeGetBoard",
|
|
27
|
+
onBoardsRead: "onAfterListBoards",
|
|
28
|
+
onBoardRead: "onAfterGetBoard",
|
|
29
|
+
onBoardCreated: "onAfterCreateBoard",
|
|
30
|
+
onBoardUpdated: "onAfterUpdateBoard",
|
|
31
|
+
onBoardDeleted: "onAfterDeleteBoard",
|
|
32
|
+
onListBoardsError: "onErrorListBoards",
|
|
33
|
+
onReadBoardError: "onErrorGetBoard",
|
|
34
|
+
onCreateBoardError: "onErrorCreateBoard",
|
|
35
|
+
onUpdateBoardError: "onErrorUpdateBoard",
|
|
36
|
+
onDeleteBoardError: "onErrorDeleteBoard",
|
|
37
|
+
onColumnCreated: "onAfterCreateColumn",
|
|
38
|
+
onColumnUpdated: "onAfterUpdateColumn",
|
|
39
|
+
onColumnDeleted: "onAfterDeleteColumn",
|
|
40
|
+
onTaskCreated: "onAfterCreateTask",
|
|
41
|
+
onTaskUpdated: "onAfterUpdateTask",
|
|
42
|
+
onTaskDeleted: "onAfterDeleteTask",
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("covers every maintained HTTP and programmatic operation with a stable descriptor", () => {
|
|
47
|
+
const plugin = kanbanBackendPlugin();
|
|
48
|
+
const adapter = createMemoryAdapter(defineDb({}).use(plugin.dbPlugin))({});
|
|
49
|
+
const operations = plugin.operations?.(adapter);
|
|
50
|
+
|
|
51
|
+
expect(Object.keys(operations ?? {}).sort()).toEqual([
|
|
52
|
+
"createBoard",
|
|
53
|
+
"createColumn",
|
|
54
|
+
"createTask",
|
|
55
|
+
"deleteBoard",
|
|
56
|
+
"deleteColumn",
|
|
57
|
+
"deleteTask",
|
|
58
|
+
"getBoard",
|
|
59
|
+
"listBoards",
|
|
60
|
+
"moveTask",
|
|
61
|
+
"reorderColumns",
|
|
62
|
+
"reorderTasks",
|
|
63
|
+
"updateBoard",
|
|
64
|
+
"updateColumn",
|
|
65
|
+
"updateTask",
|
|
66
|
+
]);
|
|
67
|
+
expect(
|
|
68
|
+
Object.fromEntries(
|
|
69
|
+
Object.entries(operations ?? {}).map(([key, operation]) => [
|
|
70
|
+
key,
|
|
71
|
+
operation.permission.id,
|
|
72
|
+
]),
|
|
73
|
+
),
|
|
74
|
+
).toEqual({
|
|
75
|
+
listBoards: "kanban:board.read",
|
|
76
|
+
getBoard: "kanban:board.read",
|
|
77
|
+
createBoard: "kanban:board.create",
|
|
78
|
+
updateBoard: "kanban:board.update",
|
|
79
|
+
deleteBoard: "kanban:board.delete",
|
|
80
|
+
createColumn: "kanban:column.create",
|
|
81
|
+
updateColumn: "kanban:column.update",
|
|
82
|
+
deleteColumn: "kanban:column.delete",
|
|
83
|
+
reorderColumns: "kanban:column.reorder",
|
|
84
|
+
createTask: "kanban:task.create",
|
|
85
|
+
updateTask: "kanban:task.update",
|
|
86
|
+
deleteTask: "kanban:task.delete",
|
|
87
|
+
moveTask: "kanban:task.move",
|
|
88
|
+
reorderTasks: "kanban:task.reorder",
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
expect(kanbanPermissions.board.read({ scope: "collection" })).toMatchObject(
|
|
92
|
+
{ id: "kanban:board.read" },
|
|
93
|
+
);
|
|
94
|
+
expect(
|
|
95
|
+
kanbanPermissions.task.move({
|
|
96
|
+
boardId: "board-1",
|
|
97
|
+
columnId: "column-1",
|
|
98
|
+
targetColumnId: "column-2",
|
|
99
|
+
taskId: "task-1",
|
|
100
|
+
isArchived: false,
|
|
101
|
+
}),
|
|
102
|
+
).toMatchObject({ id: "kanban:task.move" });
|
|
103
|
+
expect(() =>
|
|
104
|
+
kanbanPermissions.task.update({
|
|
105
|
+
boardId: "board-1",
|
|
106
|
+
columnId: "column-1",
|
|
107
|
+
taskId: "task-1",
|
|
108
|
+
// @ts-expect-error Task status must be present in the catalog facts.
|
|
109
|
+
isArchived: undefined,
|
|
110
|
+
}),
|
|
111
|
+
).toThrow();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const authorization = defineAuthorization({
|
|
116
|
+
identity: z.object({
|
|
117
|
+
id: z.string(),
|
|
118
|
+
role: z.enum(["user", "admin"]),
|
|
119
|
+
organizationIds: z.array(z.string()),
|
|
120
|
+
}),
|
|
121
|
+
permissions: [kanbanPermissions] as const,
|
|
122
|
+
rules: ({ kanban }) => {
|
|
123
|
+
const managesBoard = ({
|
|
124
|
+
identity,
|
|
125
|
+
facts,
|
|
126
|
+
}: {
|
|
127
|
+
identity: {
|
|
128
|
+
id: string;
|
|
129
|
+
role: "user" | "admin";
|
|
130
|
+
organizationIds: string[];
|
|
131
|
+
} | null;
|
|
132
|
+
facts: { ownerId?: string; organizationId?: string };
|
|
133
|
+
}) =>
|
|
134
|
+
identity?.role === "admin" ||
|
|
135
|
+
identity?.id === facts.ownerId ||
|
|
136
|
+
Boolean(
|
|
137
|
+
facts.organizationId &&
|
|
138
|
+
identity?.organizationIds.includes(facts.organizationId),
|
|
139
|
+
);
|
|
140
|
+
return [
|
|
141
|
+
kanban.board.read.when(({ identity, facts }) =>
|
|
142
|
+
facts.scope === "collection"
|
|
143
|
+
? identity?.role === "admin"
|
|
144
|
+
: managesBoard({ identity, facts }),
|
|
145
|
+
),
|
|
146
|
+
kanban.board.create.when(({ identity }) => identity !== null),
|
|
147
|
+
kanban.board.update.when(
|
|
148
|
+
({ identity, facts }) =>
|
|
149
|
+
identity?.role === "admin" || identity?.id === facts.ownerId,
|
|
150
|
+
),
|
|
151
|
+
kanban.board.delete.when(
|
|
152
|
+
({ identity, facts }) =>
|
|
153
|
+
identity?.role === "admin" || identity?.id === facts.ownerId,
|
|
154
|
+
),
|
|
155
|
+
kanban.column.create.when(managesBoard),
|
|
156
|
+
kanban.column.update.when(managesBoard),
|
|
157
|
+
kanban.column.delete.when(managesBoard),
|
|
158
|
+
kanban.column.reorder.when(managesBoard),
|
|
159
|
+
kanban.task.create.when(managesBoard),
|
|
160
|
+
kanban.task.update.when(managesBoard),
|
|
161
|
+
kanban.task.delete.when(managesBoard),
|
|
162
|
+
kanban.task.move.when(managesBoard),
|
|
163
|
+
kanban.task.reorder.when(managesBoard),
|
|
164
|
+
];
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
type Identity = {
|
|
169
|
+
id: string;
|
|
170
|
+
role: "user" | "admin";
|
|
171
|
+
organizationIds: string[];
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
function createAuth(
|
|
175
|
+
getIdentity: (
|
|
176
|
+
request: Request,
|
|
177
|
+
) => Identity | null | Promise<Identity | null> = (request) => {
|
|
178
|
+
const id = request.headers.get("x-user-id");
|
|
179
|
+
const role = request.headers.get("x-user-role");
|
|
180
|
+
if (!id || (role !== "user" && role !== "admin")) return null;
|
|
181
|
+
return {
|
|
182
|
+
id,
|
|
183
|
+
role,
|
|
184
|
+
organizationIds:
|
|
185
|
+
request.headers.get("x-organization-ids")?.split(",").filter(Boolean) ??
|
|
186
|
+
[],
|
|
187
|
+
};
|
|
188
|
+
},
|
|
189
|
+
definition = authorization,
|
|
190
|
+
) {
|
|
191
|
+
return createServerAuth({
|
|
192
|
+
authorization: definition,
|
|
193
|
+
getIdentity: ({ request }) => getIdentity(request),
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function makeBackend(options?: {
|
|
198
|
+
hooks?: KanbanBackendHooks;
|
|
199
|
+
auth?: ServerAuth<any>;
|
|
200
|
+
adapter?: (db: DatabaseDefinition) => DBAdapter;
|
|
201
|
+
}) {
|
|
202
|
+
return createBackendStack({
|
|
203
|
+
basePath: "/api",
|
|
204
|
+
plugins: {
|
|
205
|
+
kanban: kanbanBackendPlugin(
|
|
206
|
+
options?.hooks ? { hooks: options.hooks } : {},
|
|
207
|
+
),
|
|
208
|
+
},
|
|
209
|
+
adapter: options?.adapter ?? rawMemoryAdapter,
|
|
210
|
+
...(options?.auth ? { auth: options.auth as never } : {}),
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function request(
|
|
215
|
+
path: string,
|
|
216
|
+
options?: { method?: string; identity?: Identity; body?: unknown },
|
|
217
|
+
) {
|
|
218
|
+
const headers = new Headers();
|
|
219
|
+
if (options?.identity) {
|
|
220
|
+
headers.set("x-user-id", options.identity.id);
|
|
221
|
+
headers.set("x-user-role", options.identity.role);
|
|
222
|
+
headers.set(
|
|
223
|
+
"x-organization-ids",
|
|
224
|
+
options.identity.organizationIds.join(","),
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
if (options?.body !== undefined)
|
|
228
|
+
headers.set("content-type", "application/json");
|
|
229
|
+
return new Request(`http://localhost/api${path}`, {
|
|
230
|
+
method: options?.method ?? "GET",
|
|
231
|
+
headers,
|
|
232
|
+
...(options?.body !== undefined
|
|
233
|
+
? { body: JSON.stringify(options.body) }
|
|
234
|
+
: {}),
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const owner = {
|
|
239
|
+
id: "owner-1",
|
|
240
|
+
role: "user",
|
|
241
|
+
organizationIds: [],
|
|
242
|
+
} as const satisfies Identity;
|
|
243
|
+
const member = {
|
|
244
|
+
id: "member-1",
|
|
245
|
+
role: "user",
|
|
246
|
+
organizationIds: ["org-1"],
|
|
247
|
+
} as const satisfies Identity;
|
|
248
|
+
const viewer = {
|
|
249
|
+
id: "viewer-1",
|
|
250
|
+
role: "user",
|
|
251
|
+
organizationIds: [],
|
|
252
|
+
} as const satisfies Identity;
|
|
253
|
+
const admin = {
|
|
254
|
+
id: "admin-1",
|
|
255
|
+
role: "admin",
|
|
256
|
+
organizationIds: [],
|
|
257
|
+
} as const satisfies Identity;
|
|
258
|
+
|
|
259
|
+
async function seedBoard(
|
|
260
|
+
backend: ReturnType<typeof makeBackend>,
|
|
261
|
+
overrides: Partial<Board> = {},
|
|
262
|
+
) {
|
|
263
|
+
const now = new Date("2026-01-01T00:00:00.000Z");
|
|
264
|
+
return backend.adapter.create<Board>({
|
|
265
|
+
model: "kanbanBoard",
|
|
266
|
+
data: {
|
|
267
|
+
name: "Roadmap",
|
|
268
|
+
slug: "roadmap",
|
|
269
|
+
ownerId: owner.id,
|
|
270
|
+
organizationId: "org-1",
|
|
271
|
+
createdAt: now,
|
|
272
|
+
updatedAt: now,
|
|
273
|
+
...overrides,
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
async function seedColumn(
|
|
279
|
+
backend: ReturnType<typeof makeBackend>,
|
|
280
|
+
boardId: string,
|
|
281
|
+
overrides: Partial<Column> = {},
|
|
282
|
+
) {
|
|
283
|
+
const now = new Date("2026-01-01T00:00:00.000Z");
|
|
284
|
+
return backend.adapter.create<Column>({
|
|
285
|
+
model: "kanbanColumn",
|
|
286
|
+
data: {
|
|
287
|
+
title: "Todo",
|
|
288
|
+
order: 0,
|
|
289
|
+
boardId,
|
|
290
|
+
createdAt: now,
|
|
291
|
+
updatedAt: now,
|
|
292
|
+
...overrides,
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
async function seedTask(
|
|
298
|
+
backend: ReturnType<typeof makeBackend>,
|
|
299
|
+
columnId: string,
|
|
300
|
+
overrides: Partial<Task> = {},
|
|
301
|
+
) {
|
|
302
|
+
const now = new Date("2026-01-01T00:00:00.000Z");
|
|
303
|
+
return backend.adapter.create<Task>({
|
|
304
|
+
model: "kanbanTask",
|
|
305
|
+
data: {
|
|
306
|
+
title: "Ship authorization",
|
|
307
|
+
priority: "HIGH",
|
|
308
|
+
order: 0,
|
|
309
|
+
columnId,
|
|
310
|
+
assigneeId: member.id,
|
|
311
|
+
isArchived: false,
|
|
312
|
+
createdAt: now,
|
|
313
|
+
updatedAt: now,
|
|
314
|
+
...overrides,
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
describe("Kanban operation-first authorization", () => {
|
|
320
|
+
it("runs every renamed hook across request-authorized and trusted calls", async () => {
|
|
321
|
+
const events: string[] = [];
|
|
322
|
+
let rejectedBoardAction: string | undefined;
|
|
323
|
+
const reject = (action: string) => {
|
|
324
|
+
if (rejectedBoardAction === action) throw new Error(`${action} rejected`);
|
|
325
|
+
};
|
|
326
|
+
const backend = makeBackend({
|
|
327
|
+
auth: createAuth(),
|
|
328
|
+
hooks: {
|
|
329
|
+
onBeforeListBoards: () => reject("listBoards"),
|
|
330
|
+
onAfterListBoards: (_boards, _filter, context) => {
|
|
331
|
+
events.push(`afterListBoards:${context.identity?.id}`);
|
|
332
|
+
},
|
|
333
|
+
onErrorListBoards: () => {
|
|
334
|
+
events.push("errorListBoards");
|
|
335
|
+
},
|
|
336
|
+
onBeforeGetBoard: () => reject("getBoard"),
|
|
337
|
+
onAfterGetBoard: (_board, context) => {
|
|
338
|
+
events.push(`afterGetBoard:${context.identity?.id}`);
|
|
339
|
+
},
|
|
340
|
+
onErrorGetBoard: () => {
|
|
341
|
+
events.push("errorGetBoard");
|
|
342
|
+
},
|
|
343
|
+
onBeforeCreateBoard: () => reject("createBoard"),
|
|
344
|
+
onAfterCreateBoard: (_board, context) => {
|
|
345
|
+
events.push(`afterCreateBoard:${context.identity?.id ?? "trusted"}`);
|
|
346
|
+
},
|
|
347
|
+
onErrorCreateBoard: () => {
|
|
348
|
+
events.push("errorCreateBoard");
|
|
349
|
+
},
|
|
350
|
+
onBeforeUpdateBoard: () => reject("updateBoard"),
|
|
351
|
+
onAfterUpdateBoard: (_board, context) => {
|
|
352
|
+
events.push(`afterUpdateBoard:${context.identity?.id}`);
|
|
353
|
+
},
|
|
354
|
+
onErrorUpdateBoard: () => {
|
|
355
|
+
events.push("errorUpdateBoard");
|
|
356
|
+
},
|
|
357
|
+
onBeforeDeleteBoard: () => reject("deleteBoard"),
|
|
358
|
+
onAfterDeleteBoard: (_id, context) => {
|
|
359
|
+
events.push(`afterDeleteBoard:${context.identity?.id}`);
|
|
360
|
+
},
|
|
361
|
+
onErrorDeleteBoard: () => {
|
|
362
|
+
events.push("errorDeleteBoard");
|
|
363
|
+
},
|
|
364
|
+
onAfterCreateColumn: (_column, context) => {
|
|
365
|
+
events.push(`afterCreateColumn:${context.identity?.id ?? "trusted"}`);
|
|
366
|
+
},
|
|
367
|
+
onAfterUpdateColumn: (_column, context) => {
|
|
368
|
+
events.push(`afterUpdateColumn:${context.identity?.id}`);
|
|
369
|
+
},
|
|
370
|
+
onAfterDeleteColumn: (_id, context) => {
|
|
371
|
+
events.push(`afterDeleteColumn:${context.identity?.id}`);
|
|
372
|
+
},
|
|
373
|
+
onAfterCreateTask: (_task, context) => {
|
|
374
|
+
events.push(`afterCreateTask:${context.identity?.id ?? "trusted"}`);
|
|
375
|
+
},
|
|
376
|
+
onAfterUpdateTask: (_task, context) => {
|
|
377
|
+
events.push(`afterUpdateTask:${context.identity?.id}`);
|
|
378
|
+
},
|
|
379
|
+
onAfterDeleteTask: (_id, context) => {
|
|
380
|
+
events.push(`afterDeleteTask:${context.identity?.id}`);
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
});
|
|
384
|
+
const requested = backend.forRequest(
|
|
385
|
+
request("/lifecycle", { identity: admin }),
|
|
386
|
+
).operations.kanban;
|
|
387
|
+
|
|
388
|
+
rejectedBoardAction = "createBoard";
|
|
389
|
+
await expect(
|
|
390
|
+
requested.createBoard({ name: "Rejected" }),
|
|
391
|
+
).rejects.toMatchObject({ code: "CREATE_BOARD_REJECTED" });
|
|
392
|
+
rejectedBoardAction = undefined;
|
|
393
|
+
const board = await backend.trusted.kanban.createBoard({
|
|
394
|
+
name: "Lifecycle",
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
rejectedBoardAction = "listBoards";
|
|
398
|
+
await expect(requested.listBoards({})).rejects.toMatchObject({
|
|
399
|
+
code: "LIST_BOARDS_REJECTED",
|
|
400
|
+
});
|
|
401
|
+
rejectedBoardAction = undefined;
|
|
402
|
+
await requested.listBoards({});
|
|
403
|
+
|
|
404
|
+
rejectedBoardAction = "getBoard";
|
|
405
|
+
await expect(requested.getBoard({ id: board.id })).rejects.toMatchObject({
|
|
406
|
+
code: "READ_BOARD_REJECTED",
|
|
407
|
+
});
|
|
408
|
+
rejectedBoardAction = undefined;
|
|
409
|
+
await requested.getBoard({ id: board.id });
|
|
410
|
+
|
|
411
|
+
rejectedBoardAction = "updateBoard";
|
|
412
|
+
await expect(
|
|
413
|
+
requested.updateBoard({ id: board.id, data: { name: "Rejected" } }),
|
|
414
|
+
).rejects.toMatchObject({ code: "UPDATE_BOARD_REJECTED" });
|
|
415
|
+
rejectedBoardAction = undefined;
|
|
416
|
+
await requested.updateBoard({ id: board.id, data: { name: "Updated" } });
|
|
417
|
+
|
|
418
|
+
const column = await backend.trusted.kanban.createColumn({
|
|
419
|
+
boardId: board.id,
|
|
420
|
+
title: "Lifecycle",
|
|
421
|
+
});
|
|
422
|
+
await requested.updateColumn({
|
|
423
|
+
id: column.id,
|
|
424
|
+
data: { title: "Updated column" },
|
|
425
|
+
});
|
|
426
|
+
const task = await backend.trusted.kanban.createTask({
|
|
427
|
+
columnId: column.id,
|
|
428
|
+
title: "Lifecycle",
|
|
429
|
+
});
|
|
430
|
+
await requested.updateTask({
|
|
431
|
+
id: task.id,
|
|
432
|
+
data: { title: "Updated task" },
|
|
433
|
+
});
|
|
434
|
+
await requested.deleteTask({ id: task.id });
|
|
435
|
+
await requested.deleteColumn({ id: column.id });
|
|
436
|
+
|
|
437
|
+
rejectedBoardAction = "deleteBoard";
|
|
438
|
+
await expect(requested.deleteBoard({ id: board.id })).rejects.toMatchObject(
|
|
439
|
+
{
|
|
440
|
+
code: "DELETE_BOARD_REJECTED",
|
|
441
|
+
},
|
|
442
|
+
);
|
|
443
|
+
rejectedBoardAction = undefined;
|
|
444
|
+
await requested.deleteBoard({ id: board.id });
|
|
445
|
+
|
|
446
|
+
expect(events).toEqual([
|
|
447
|
+
"errorCreateBoard",
|
|
448
|
+
"afterCreateBoard:trusted",
|
|
449
|
+
"errorListBoards",
|
|
450
|
+
"afterListBoards:admin-1",
|
|
451
|
+
"errorGetBoard",
|
|
452
|
+
"afterGetBoard:admin-1",
|
|
453
|
+
"errorUpdateBoard",
|
|
454
|
+
"afterUpdateBoard:admin-1",
|
|
455
|
+
"afterCreateColumn:trusted",
|
|
456
|
+
"afterUpdateColumn:admin-1",
|
|
457
|
+
"afterCreateTask:trusted",
|
|
458
|
+
"afterUpdateTask:admin-1",
|
|
459
|
+
"afterDeleteTask:admin-1",
|
|
460
|
+
"afterDeleteColumn:admin-1",
|
|
461
|
+
"errorDeleteBoard",
|
|
462
|
+
"afterDeleteBoard:admin-1",
|
|
463
|
+
]);
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
it("preserves omitted-auth compatibility while retaining validation and hooks", async () => {
|
|
467
|
+
const events: string[] = [];
|
|
468
|
+
const backend = makeBackend({
|
|
469
|
+
adapter: rawMemoryAdapter,
|
|
470
|
+
hooks: {
|
|
471
|
+
onBeforeCreateBoard: (_input, context) => {
|
|
472
|
+
events.push(`before:${context.identity?.id ?? "anonymous"}`);
|
|
473
|
+
},
|
|
474
|
+
onAfterCreateBoard: (_board, context) => {
|
|
475
|
+
events.push(`after:${context.identity?.id ?? "anonymous"}`);
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
});
|
|
479
|
+
const response = await backend.handler(
|
|
480
|
+
request("/boards", { method: "POST", body: { name: "Compatible" } }),
|
|
481
|
+
);
|
|
482
|
+
expect(response.status).toBe(200);
|
|
483
|
+
const board = (await response.json()) as Board;
|
|
484
|
+
expect(board).toMatchObject({ name: "Compatible" });
|
|
485
|
+
const updateResponse = await backend.handler(
|
|
486
|
+
request(`/boards/${board.id}`, {
|
|
487
|
+
method: "PUT",
|
|
488
|
+
body: { name: "Still compatible" },
|
|
489
|
+
}),
|
|
490
|
+
);
|
|
491
|
+
expect(updateResponse.status).toBe(200);
|
|
492
|
+
expect(await updateResponse.json()).toMatchObject({
|
|
493
|
+
name: "Still compatible",
|
|
494
|
+
});
|
|
495
|
+
expect(events).toEqual(["before:anonymous", "after:anonymous"]);
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
it("runs typed board error hooks without replacing the domain failure", async () => {
|
|
499
|
+
const events: string[] = [];
|
|
500
|
+
const contexts: unknown[] = [];
|
|
501
|
+
const backend = makeBackend({
|
|
502
|
+
auth: createAuth(),
|
|
503
|
+
hooks: {
|
|
504
|
+
onBeforeCreateBoard: (input, context) => {
|
|
505
|
+
events.push("before");
|
|
506
|
+
expect(input).toEqual({ name: "Rejected" });
|
|
507
|
+
expect(context.identity).toEqual(owner);
|
|
508
|
+
throw new Error("workflow rejected");
|
|
509
|
+
},
|
|
510
|
+
onErrorCreateBoard: (error, context) => {
|
|
511
|
+
events.push("error");
|
|
512
|
+
contexts.push(context);
|
|
513
|
+
expect(error).toMatchObject({
|
|
514
|
+
message: "workflow rejected",
|
|
515
|
+
code: "CREATE_BOARD_REJECTED",
|
|
516
|
+
});
|
|
517
|
+
throw new Error("observer failed");
|
|
518
|
+
},
|
|
519
|
+
onAfterCreateBoard: () => {
|
|
520
|
+
events.push("after");
|
|
521
|
+
},
|
|
522
|
+
},
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
await expect(
|
|
526
|
+
backend
|
|
527
|
+
.forRequest(request("/create", { identity: owner }))
|
|
528
|
+
.operations.kanban.createBoard({ name: "Rejected" }),
|
|
529
|
+
).rejects.toMatchObject({
|
|
530
|
+
message: "workflow rejected",
|
|
531
|
+
code: "CREATE_BOARD_REJECTED",
|
|
532
|
+
});
|
|
533
|
+
expect(events).toEqual(["before", "error"]);
|
|
534
|
+
expect(contexts).toEqual([
|
|
535
|
+
expect.objectContaining({
|
|
536
|
+
input: { name: "Rejected" },
|
|
537
|
+
facts: undefined,
|
|
538
|
+
identity: owner,
|
|
539
|
+
}),
|
|
540
|
+
]);
|
|
541
|
+
expect(contexts[0]).not.toHaveProperty("result");
|
|
542
|
+
expect(await backend.adapter.count({ model: "kanbanBoard" })).toBe(0);
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
it("rejects board creation without atomic transactions before hooks or writes", async () => {
|
|
546
|
+
const beforeCreate = vi.fn();
|
|
547
|
+
const sequentialAdapter = (db: DatabaseDefinition) => {
|
|
548
|
+
const memory = rawMemoryAdapter(db);
|
|
549
|
+
const adapterConfig = memory.options?.adapterConfig;
|
|
550
|
+
if (!adapterConfig) throw new Error("Missing adapter config");
|
|
551
|
+
return {
|
|
552
|
+
...memory,
|
|
553
|
+
id: "sequential",
|
|
554
|
+
options: {
|
|
555
|
+
...memory.options,
|
|
556
|
+
adapterConfig: {
|
|
557
|
+
...adapterConfig,
|
|
558
|
+
transaction: false,
|
|
559
|
+
},
|
|
560
|
+
},
|
|
561
|
+
} satisfies DBAdapter;
|
|
562
|
+
};
|
|
563
|
+
const backend = makeBackend({
|
|
564
|
+
adapter: sequentialAdapter,
|
|
565
|
+
hooks: { onBeforeCreateBoard: beforeCreate },
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
await expect(
|
|
569
|
+
backend.trusted.kanban.createBoard({ name: "Unsafe" }),
|
|
570
|
+
).rejects.toMatchObject({
|
|
571
|
+
statusCode: 500,
|
|
572
|
+
code: "ATOMIC_TRANSACTION_REQUIRED",
|
|
573
|
+
});
|
|
574
|
+
expect(beforeCreate).not.toHaveBeenCalled();
|
|
575
|
+
expect(await backend.adapter.count({ model: "kanbanBoard" })).toBe(0);
|
|
576
|
+
expect(await backend.adapter.count({ model: "kanbanColumn" })).toBe(0);
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
it("rolls back nested board creation when its outer before hook rejects", async () => {
|
|
580
|
+
let backend: ReturnType<typeof makeBackend>;
|
|
581
|
+
backend = makeBackend({
|
|
582
|
+
hooks: {
|
|
583
|
+
onBeforeCreateBoard: async (input) => {
|
|
584
|
+
if (input.name !== "Outer") return;
|
|
585
|
+
await backend.trusted.kanban.createBoard({ name: "Nested" });
|
|
586
|
+
throw new Error("outer rejected");
|
|
587
|
+
},
|
|
588
|
+
},
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
await expect(
|
|
592
|
+
backend.trusted.kanban.createBoard({ name: "Outer" }),
|
|
593
|
+
).rejects.toMatchObject({
|
|
594
|
+
statusCode: 403,
|
|
595
|
+
code: "CREATE_BOARD_REJECTED",
|
|
596
|
+
});
|
|
597
|
+
expect(await backend.adapter.count({ model: "kanbanBoard" })).toBe(0);
|
|
598
|
+
expect(await backend.adapter.count({ model: "kanbanColumn" })).toBe(0);
|
|
599
|
+
}, 1_000);
|
|
600
|
+
|
|
601
|
+
it("returns 401/403 before hooks and allows owner, member, and admin where declared", async () => {
|
|
602
|
+
const events: string[] = [];
|
|
603
|
+
const backend = makeBackend({
|
|
604
|
+
auth: createAuth(),
|
|
605
|
+
hooks: {
|
|
606
|
+
onBeforeGetBoard: () => {
|
|
607
|
+
events.push("read");
|
|
608
|
+
},
|
|
609
|
+
onBeforeUpdateTask: () => {
|
|
610
|
+
events.push("task");
|
|
611
|
+
},
|
|
612
|
+
},
|
|
613
|
+
});
|
|
614
|
+
const board = await seedBoard(backend);
|
|
615
|
+
const column = await seedColumn(backend, board.id);
|
|
616
|
+
await seedTask(backend, column.id, { title: "Earlier", order: 0 });
|
|
617
|
+
const task = await seedTask(backend, column.id, { order: 1 });
|
|
618
|
+
|
|
619
|
+
expect((await backend.handler(request(`/boards/${board.id}`))).status).toBe(
|
|
620
|
+
401,
|
|
621
|
+
);
|
|
622
|
+
expect(
|
|
623
|
+
(
|
|
624
|
+
await backend.handler(
|
|
625
|
+
request(`/boards/${board.id}`, { identity: viewer }),
|
|
626
|
+
)
|
|
627
|
+
).status,
|
|
628
|
+
).toBe(403);
|
|
629
|
+
expect(events).toEqual([]);
|
|
630
|
+
expect(
|
|
631
|
+
authorization.can(
|
|
632
|
+
kanbanPermissions.task.update({
|
|
633
|
+
boardId: board.id,
|
|
634
|
+
ownerId: viewer.id,
|
|
635
|
+
organizationId: "spoofed-org",
|
|
636
|
+
columnId: column.id,
|
|
637
|
+
taskId: task.id,
|
|
638
|
+
isArchived: false,
|
|
639
|
+
}),
|
|
640
|
+
viewer,
|
|
641
|
+
),
|
|
642
|
+
).toBe(true);
|
|
643
|
+
await expect(
|
|
644
|
+
backend
|
|
645
|
+
.forRequest(request("/spoofed", { identity: viewer }))
|
|
646
|
+
.operations.kanban.updateTask({
|
|
647
|
+
id: task.id,
|
|
648
|
+
data: { title: "Spoofed" },
|
|
649
|
+
}),
|
|
650
|
+
).rejects.toMatchObject({ statusCode: 403 });
|
|
651
|
+
expect(events).toEqual([]);
|
|
652
|
+
|
|
653
|
+
expect(
|
|
654
|
+
(
|
|
655
|
+
await backend.handler(
|
|
656
|
+
request(`/boards/${board.id}`, { identity: owner }),
|
|
657
|
+
)
|
|
658
|
+
).status,
|
|
659
|
+
).toBe(200);
|
|
660
|
+
await expect(
|
|
661
|
+
backend
|
|
662
|
+
.forRequest(request("/member", { identity: member }))
|
|
663
|
+
.operations.kanban.updateTask({
|
|
664
|
+
id: task.id,
|
|
665
|
+
data: { title: "Member edit" },
|
|
666
|
+
}),
|
|
667
|
+
).resolves.toMatchObject({
|
|
668
|
+
title: "Member edit",
|
|
669
|
+
priority: "HIGH",
|
|
670
|
+
order: 1,
|
|
671
|
+
isArchived: false,
|
|
672
|
+
});
|
|
673
|
+
await expect(
|
|
674
|
+
backend
|
|
675
|
+
.forRequest(request("/admin", { identity: admin }))
|
|
676
|
+
.operations.kanban.listBoards({}),
|
|
677
|
+
).resolves.toMatchObject({ total: 1 });
|
|
678
|
+
expect(events).toEqual(["read", "task"]);
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
it("requires column reorder permission when ordinary updates include order", async () => {
|
|
682
|
+
const events: string[] = [];
|
|
683
|
+
const updateWithoutReorder = defineAuthorization({
|
|
684
|
+
identity: z.object({
|
|
685
|
+
id: z.string(),
|
|
686
|
+
role: z.enum(["user", "admin"]),
|
|
687
|
+
organizationIds: z.array(z.string()),
|
|
688
|
+
}),
|
|
689
|
+
permissions: [kanbanPermissions] as const,
|
|
690
|
+
rules: ({ kanban }) => [
|
|
691
|
+
kanban.column.update.when(() => true),
|
|
692
|
+
kanban.column.reorder.when(() => false),
|
|
693
|
+
],
|
|
694
|
+
});
|
|
695
|
+
const backend = makeBackend({
|
|
696
|
+
auth: createAuth(undefined, updateWithoutReorder),
|
|
697
|
+
hooks: {
|
|
698
|
+
onBeforeUpdateColumn: () => {
|
|
699
|
+
events.push("before");
|
|
700
|
+
},
|
|
701
|
+
},
|
|
702
|
+
});
|
|
703
|
+
const board = await seedBoard(backend);
|
|
704
|
+
const column = await seedColumn(backend, board.id);
|
|
705
|
+
const response = await backend.handler(
|
|
706
|
+
request(`/columns/${column.id}`, {
|
|
707
|
+
method: "PUT",
|
|
708
|
+
identity: owner,
|
|
709
|
+
body: { order: 1 },
|
|
710
|
+
}),
|
|
711
|
+
);
|
|
712
|
+
expect(response.status).toBe(403);
|
|
713
|
+
expect(events).toEqual([]);
|
|
714
|
+
expect(
|
|
715
|
+
await backend.adapter.findOne<Column>({
|
|
716
|
+
model: "kanbanColumn",
|
|
717
|
+
where: [{ field: "id", value: column.id }],
|
|
718
|
+
}),
|
|
719
|
+
).toMatchObject({ order: 0 });
|
|
720
|
+
|
|
721
|
+
await expect(
|
|
722
|
+
backend
|
|
723
|
+
.forRequest(request("/member", { identity: owner }))
|
|
724
|
+
.operations.kanban.updateColumn({
|
|
725
|
+
id: column.id,
|
|
726
|
+
data: { order: undefined },
|
|
727
|
+
}),
|
|
728
|
+
).rejects.toBeInstanceOf(z.ZodError);
|
|
729
|
+
expect(events).toEqual([]);
|
|
730
|
+
expect(
|
|
731
|
+
await backend.adapter.findOne<Column>({
|
|
732
|
+
model: "kanbanColumn",
|
|
733
|
+
where: [{ field: "id", value: column.id }],
|
|
734
|
+
}),
|
|
735
|
+
).toMatchObject({ order: 0 });
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
it("fails closed across every anonymous HTTP operation", async () => {
|
|
739
|
+
const backend = makeBackend({ auth: createAuth() });
|
|
740
|
+
const board = await seedBoard(backend);
|
|
741
|
+
const first = await seedColumn(backend, board.id);
|
|
742
|
+
const second = await seedColumn(backend, board.id, {
|
|
743
|
+
title: "Done",
|
|
744
|
+
order: 1,
|
|
745
|
+
});
|
|
746
|
+
const task = await seedTask(backend, first.id);
|
|
747
|
+
const protectedRequests = [
|
|
748
|
+
request("/boards"),
|
|
749
|
+
request(`/boards/${board.id}`),
|
|
750
|
+
request("/boards", { method: "POST", body: { name: "Denied" } }),
|
|
751
|
+
request(`/boards/${board.id}`, {
|
|
752
|
+
method: "PUT",
|
|
753
|
+
body: { name: "Denied" },
|
|
754
|
+
}),
|
|
755
|
+
request(`/boards/${board.id}`, { method: "DELETE" }),
|
|
756
|
+
request("/columns", {
|
|
757
|
+
method: "POST",
|
|
758
|
+
body: { title: "Denied", boardId: board.id },
|
|
759
|
+
}),
|
|
760
|
+
request(`/columns/${first.id}`, {
|
|
761
|
+
method: "PUT",
|
|
762
|
+
body: { title: "Denied" },
|
|
763
|
+
}),
|
|
764
|
+
request(`/columns/${first.id}`, { method: "DELETE" }),
|
|
765
|
+
request("/columns/reorder", {
|
|
766
|
+
method: "POST",
|
|
767
|
+
body: { boardId: board.id, columnIds: [second.id, first.id] },
|
|
768
|
+
}),
|
|
769
|
+
request("/tasks", {
|
|
770
|
+
method: "POST",
|
|
771
|
+
body: { title: "Denied", columnId: first.id },
|
|
772
|
+
}),
|
|
773
|
+
request(`/tasks/${task.id}`, {
|
|
774
|
+
method: "PUT",
|
|
775
|
+
body: { title: "Denied" },
|
|
776
|
+
}),
|
|
777
|
+
request(`/tasks/${task.id}`, { method: "DELETE" }),
|
|
778
|
+
request("/tasks/move", {
|
|
779
|
+
method: "POST",
|
|
780
|
+
body: { taskId: task.id, targetColumnId: second.id, targetOrder: 0 },
|
|
781
|
+
}),
|
|
782
|
+
request("/tasks/reorder", {
|
|
783
|
+
method: "POST",
|
|
784
|
+
body: { columnId: first.id, taskIds: [task.id] },
|
|
785
|
+
}),
|
|
786
|
+
];
|
|
787
|
+
for (const protectedRequest of protectedRequests) {
|
|
788
|
+
expect((await backend.handler(protectedRequest)).status).toBe(401);
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
it("ignores client-supplied ownership on board create and update", async () => {
|
|
792
|
+
const backend = makeBackend({ auth: createAuth() });
|
|
793
|
+
const createdResponse = await backend.handler(
|
|
794
|
+
request("/boards", {
|
|
795
|
+
method: "POST",
|
|
796
|
+
identity: viewer,
|
|
797
|
+
body: {
|
|
798
|
+
name: "Owned by the caller",
|
|
799
|
+
ownerId: admin.id,
|
|
800
|
+
organizationId: "other-tenant",
|
|
801
|
+
},
|
|
802
|
+
}),
|
|
803
|
+
);
|
|
804
|
+
expect(createdResponse.status).toBe(200);
|
|
805
|
+
const created = (await createdResponse.json()) as Board;
|
|
806
|
+
expect(created).toMatchObject({ ownerId: viewer.id });
|
|
807
|
+
expect(created.organizationId).toBeUndefined();
|
|
808
|
+
|
|
809
|
+
const updatedResponse = await backend.handler(
|
|
810
|
+
request(`/boards/${created.id}`, {
|
|
811
|
+
method: "PUT",
|
|
812
|
+
identity: viewer,
|
|
813
|
+
body: {
|
|
814
|
+
name: "Still owned by the caller",
|
|
815
|
+
ownerId: admin.id,
|
|
816
|
+
organizationId: "other-tenant",
|
|
817
|
+
},
|
|
818
|
+
}),
|
|
819
|
+
);
|
|
820
|
+
expect(updatedResponse.status).toBe(200);
|
|
821
|
+
expect(await updatedResponse.json()).toMatchObject({
|
|
822
|
+
name: "Still owned by the caller",
|
|
823
|
+
ownerId: viewer.id,
|
|
824
|
+
});
|
|
825
|
+
expect(
|
|
826
|
+
await backend.adapter.findOne<Board>({
|
|
827
|
+
model: "kanbanBoard",
|
|
828
|
+
where: [{ field: "id", value: created.id }],
|
|
829
|
+
}),
|
|
830
|
+
).toMatchObject({ ownerId: viewer.id, organizationId: undefined });
|
|
831
|
+
|
|
832
|
+
const requestApi = backend.forRequest(
|
|
833
|
+
request("/programmatic", { identity: viewer }),
|
|
834
|
+
).operations.kanban;
|
|
835
|
+
const programmatic = await requestApi.createBoard({
|
|
836
|
+
name: "Programmatic",
|
|
837
|
+
ownerId: admin.id,
|
|
838
|
+
organizationId: "other-tenant",
|
|
839
|
+
} as { name: string });
|
|
840
|
+
expect(programmatic).toMatchObject({ ownerId: viewer.id });
|
|
841
|
+
expect(programmatic.organizationId).toBeUndefined();
|
|
842
|
+
await requestApi.updateBoard({
|
|
843
|
+
id: programmatic.id,
|
|
844
|
+
data: {
|
|
845
|
+
name: "Programmatic update",
|
|
846
|
+
ownerId: admin.id,
|
|
847
|
+
organizationId: "other-tenant",
|
|
848
|
+
} as { name: string },
|
|
849
|
+
});
|
|
850
|
+
expect(
|
|
851
|
+
await backend.adapter.findOne<Board>({
|
|
852
|
+
model: "kanbanBoard",
|
|
853
|
+
where: [{ field: "id", value: programmatic.id }],
|
|
854
|
+
}),
|
|
855
|
+
).toMatchObject({
|
|
856
|
+
name: "Programmatic update",
|
|
857
|
+
ownerId: viewer.id,
|
|
858
|
+
organizationId: undefined,
|
|
859
|
+
});
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
it("keeps HTTP, request, and trusted behavior on one validated lifecycle", async () => {
|
|
863
|
+
const getIdentity = vi.fn(({ headers }: Request) =>
|
|
864
|
+
headers.get("x-user-id"),
|
|
865
|
+
);
|
|
866
|
+
const events: string[] = [];
|
|
867
|
+
const backend = makeBackend({
|
|
868
|
+
adapter: rawMemoryAdapter,
|
|
869
|
+
auth: createAuth((incoming) => {
|
|
870
|
+
getIdentity(incoming);
|
|
871
|
+
return owner;
|
|
872
|
+
}),
|
|
873
|
+
hooks: {
|
|
874
|
+
onBeforeUpdateBoard: (_id, _data, context) => {
|
|
875
|
+
events.push(`before:${context.identity?.id ?? "trusted"}`);
|
|
876
|
+
},
|
|
877
|
+
onAfterUpdateBoard: (_board, context) => {
|
|
878
|
+
events.push(`after:${context.identity?.id ?? "trusted"}`);
|
|
879
|
+
},
|
|
880
|
+
},
|
|
881
|
+
});
|
|
882
|
+
const board = await seedBoard(backend);
|
|
883
|
+
const response = await backend.handler(
|
|
884
|
+
request(`/boards/${board.id}`, {
|
|
885
|
+
method: "PUT",
|
|
886
|
+
identity: owner,
|
|
887
|
+
body: { name: "HTTP" },
|
|
888
|
+
}),
|
|
889
|
+
);
|
|
890
|
+
expect(response.status).toBe(200);
|
|
891
|
+
await backend
|
|
892
|
+
.forRequest(request("/request", { identity: owner }))
|
|
893
|
+
.operations.kanban.updateBoard({
|
|
894
|
+
id: board.id,
|
|
895
|
+
data: { name: "Request" },
|
|
896
|
+
});
|
|
897
|
+
await expect(
|
|
898
|
+
backend.trusted.kanban.updateBoard({ id: board.id, data: { name: "" } }),
|
|
899
|
+
).rejects.toThrow();
|
|
900
|
+
await backend.trusted.kanban.updateBoard({
|
|
901
|
+
id: board.id,
|
|
902
|
+
data: { name: "Trusted" },
|
|
903
|
+
});
|
|
904
|
+
expect(events).toEqual([
|
|
905
|
+
"before:owner-1",
|
|
906
|
+
"after:owner-1",
|
|
907
|
+
"before:owner-1",
|
|
908
|
+
"after:owner-1",
|
|
909
|
+
"before:trusted",
|
|
910
|
+
"after:trusted",
|
|
911
|
+
]);
|
|
912
|
+
expect(getIdentity).toHaveBeenCalledTimes(2);
|
|
913
|
+
});
|
|
914
|
+
|
|
915
|
+
it("keeps task ordering and lifecycle hooks active for trusted jobs", async () => {
|
|
916
|
+
const events: string[] = [];
|
|
917
|
+
const backend = makeBackend({
|
|
918
|
+
adapter: rawMemoryAdapter,
|
|
919
|
+
auth: createAuth(() => {
|
|
920
|
+
throw new Error("trusted must not resolve identity");
|
|
921
|
+
}),
|
|
922
|
+
hooks: {
|
|
923
|
+
onBeforeUpdateTask: (_id, _data, context) => {
|
|
924
|
+
events.push(`before:${context.identity?.id ?? "trusted"}`);
|
|
925
|
+
},
|
|
926
|
+
onAfterUpdateTask: (_task, context) => {
|
|
927
|
+
events.push(`after:${context.identity?.id ?? "trusted"}`);
|
|
928
|
+
},
|
|
929
|
+
},
|
|
930
|
+
});
|
|
931
|
+
const board = await seedBoard(backend);
|
|
932
|
+
const source = await seedColumn(backend, board.id);
|
|
933
|
+
const target = await seedColumn(backend, board.id, {
|
|
934
|
+
title: "Done",
|
|
935
|
+
order: 1,
|
|
936
|
+
});
|
|
937
|
+
const moved = await seedTask(backend, source.id);
|
|
938
|
+
const sibling = await seedTask(backend, target.id, {
|
|
939
|
+
title: "Existing",
|
|
940
|
+
order: 0,
|
|
941
|
+
});
|
|
942
|
+
await backend.trusted.kanban.moveTask({
|
|
943
|
+
taskId: moved.id,
|
|
944
|
+
targetColumnId: target.id,
|
|
945
|
+
targetOrder: 0,
|
|
946
|
+
});
|
|
947
|
+
const tasks = await backend.adapter.findMany<Task>({
|
|
948
|
+
model: "kanbanTask",
|
|
949
|
+
where: [{ field: "columnId", value: target.id }],
|
|
950
|
+
sortBy: { field: "order", direction: "asc" },
|
|
951
|
+
});
|
|
952
|
+
expect(tasks.map(({ id, order }) => [id, order])).toEqual([
|
|
953
|
+
[moved.id, 0],
|
|
954
|
+
[sibling.id, 1],
|
|
955
|
+
]);
|
|
956
|
+
expect(events).toEqual(["before:trusted", "after:trusted"]);
|
|
957
|
+
});
|
|
958
|
+
|
|
959
|
+
it("preserves identity/rule/fact failures and missing rules before hooks", async () => {
|
|
960
|
+
const missing = defineAuthorization({
|
|
961
|
+
identity: z.object({
|
|
962
|
+
id: z.string(),
|
|
963
|
+
role: z.enum(["user", "admin"]),
|
|
964
|
+
organizationIds: z.array(z.string()),
|
|
965
|
+
}),
|
|
966
|
+
permissions: [kanbanPermissions] as const,
|
|
967
|
+
rules: ({ kanban }) => [kanban.board.create.when(() => true)],
|
|
968
|
+
});
|
|
969
|
+
const missingBackend = makeBackend({
|
|
970
|
+
auth: createAuth(undefined, missing),
|
|
971
|
+
});
|
|
972
|
+
const board = await seedBoard(missingBackend);
|
|
973
|
+
await expect(
|
|
974
|
+
missingBackend
|
|
975
|
+
.forRequest(request("/missing", { identity: owner }))
|
|
976
|
+
.operations.kanban.updateBoard({ id: board.id, data: { name: "No" } }),
|
|
977
|
+
).rejects.toMatchObject({ statusCode: 403 });
|
|
978
|
+
|
|
979
|
+
const identityFailure = makeBackend({
|
|
980
|
+
auth: createAuth(() => {
|
|
981
|
+
throw new Error("session unavailable");
|
|
982
|
+
}),
|
|
983
|
+
});
|
|
984
|
+
const identityBoard = await seedBoard(identityFailure, {
|
|
985
|
+
slug: "identity",
|
|
986
|
+
});
|
|
987
|
+
await expect(
|
|
988
|
+
identityFailure
|
|
989
|
+
.forRequest(request("/identity"))
|
|
990
|
+
.operations.kanban.updateBoard({
|
|
991
|
+
id: identityBoard.id,
|
|
992
|
+
data: { name: "No" },
|
|
993
|
+
}),
|
|
994
|
+
).rejects.toThrow("session unavailable");
|
|
995
|
+
|
|
996
|
+
const failing = defineAuthorization({
|
|
997
|
+
identity: z.object({
|
|
998
|
+
id: z.string(),
|
|
999
|
+
role: z.enum(["user", "admin"]),
|
|
1000
|
+
organizationIds: z.array(z.string()),
|
|
1001
|
+
}),
|
|
1002
|
+
permissions: [kanbanPermissions] as const,
|
|
1003
|
+
rules: ({ kanban }) => [
|
|
1004
|
+
kanban.board.update.when(() => {
|
|
1005
|
+
throw new Error("policy unavailable");
|
|
1006
|
+
}),
|
|
1007
|
+
],
|
|
1008
|
+
});
|
|
1009
|
+
const ruleFailure = makeBackend({ auth: createAuth(undefined, failing) });
|
|
1010
|
+
const ruleBoard = await seedBoard(ruleFailure, { slug: "rule" });
|
|
1011
|
+
await expect(
|
|
1012
|
+
ruleFailure
|
|
1013
|
+
.forRequest(request("/rule", { identity: owner }))
|
|
1014
|
+
.operations.kanban.updateBoard({
|
|
1015
|
+
id: ruleBoard.id,
|
|
1016
|
+
data: { name: "No" },
|
|
1017
|
+
}),
|
|
1018
|
+
).rejects.toThrow("policy unavailable");
|
|
1019
|
+
|
|
1020
|
+
const factEvents: string[] = [];
|
|
1021
|
+
const factFailure = makeBackend({
|
|
1022
|
+
auth: createAuth(),
|
|
1023
|
+
hooks: {
|
|
1024
|
+
onBeforeUpdateBoard: () => {
|
|
1025
|
+
factEvents.push("hook");
|
|
1026
|
+
},
|
|
1027
|
+
},
|
|
1028
|
+
});
|
|
1029
|
+
const factBoard = await seedBoard(factFailure, { slug: "facts" });
|
|
1030
|
+
vi.spyOn(factFailure.adapter, "findOne").mockRejectedValueOnce(
|
|
1031
|
+
new Error("database unavailable"),
|
|
1032
|
+
);
|
|
1033
|
+
await expect(
|
|
1034
|
+
factFailure
|
|
1035
|
+
.forRequest(request("/facts", { identity: owner }))
|
|
1036
|
+
.operations.kanban.updateBoard({
|
|
1037
|
+
id: factBoard.id,
|
|
1038
|
+
data: { name: "No" },
|
|
1039
|
+
}),
|
|
1040
|
+
).rejects.toThrow("database unavailable");
|
|
1041
|
+
expect(factEvents).toEqual([]);
|
|
1042
|
+
});
|
|
1043
|
+
|
|
1044
|
+
it("rejects stale authoritative facts before hooks without reverting the winner", async () => {
|
|
1045
|
+
const events: string[] = [];
|
|
1046
|
+
let backend: ReturnType<typeof makeBackend>;
|
|
1047
|
+
let raced = false;
|
|
1048
|
+
backend = makeBackend({
|
|
1049
|
+
auth: createAuth(async () => {
|
|
1050
|
+
if (!raced) {
|
|
1051
|
+
raced = true;
|
|
1052
|
+
const board = await backend.adapter.findOne<Board>({
|
|
1053
|
+
model: "kanbanBoard",
|
|
1054
|
+
where: [{ field: "slug", value: "race" }],
|
|
1055
|
+
});
|
|
1056
|
+
if (board) {
|
|
1057
|
+
await backend.adapter.update<Board>({
|
|
1058
|
+
model: "kanbanBoard",
|
|
1059
|
+
where: [{ field: "id", value: board.id }],
|
|
1060
|
+
update: {
|
|
1061
|
+
ownerId: viewer.id,
|
|
1062
|
+
updatedAt: new Date("2026-02-01T00:00:00.000Z"),
|
|
1063
|
+
},
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
return owner;
|
|
1068
|
+
}),
|
|
1069
|
+
hooks: {
|
|
1070
|
+
onBeforeUpdateBoard: () => {
|
|
1071
|
+
events.push("hook");
|
|
1072
|
+
},
|
|
1073
|
+
},
|
|
1074
|
+
});
|
|
1075
|
+
const board = await seedBoard(backend, { slug: "race" });
|
|
1076
|
+
await expect(
|
|
1077
|
+
backend.forRequest(request("/race")).operations.kanban.updateBoard({
|
|
1078
|
+
id: board.id,
|
|
1079
|
+
data: { name: "Stale" },
|
|
1080
|
+
}),
|
|
1081
|
+
).rejects.toMatchObject({ statusCode: 409, code: "KANBAN_STATE_CHANGED" });
|
|
1082
|
+
expect(events).toEqual([]);
|
|
1083
|
+
expect(
|
|
1084
|
+
await backend.adapter.findOne<Board>({
|
|
1085
|
+
model: "kanbanBoard",
|
|
1086
|
+
where: [{ field: "id", value: board.id }],
|
|
1087
|
+
}),
|
|
1088
|
+
).toMatchObject({ ownerId: viewer.id, name: "Roadmap" });
|
|
1089
|
+
});
|
|
1090
|
+
|
|
1091
|
+
it("serializes raw-memory rollback without overwriting API or raw winners", async () => {
|
|
1092
|
+
const events: string[] = [];
|
|
1093
|
+
let markRejectedHookStarted = () => {};
|
|
1094
|
+
const rejectedHookStarted = new Promise<void>((resolve) => {
|
|
1095
|
+
markRejectedHookStarted = resolve;
|
|
1096
|
+
});
|
|
1097
|
+
let releaseRejectedHook = () => {};
|
|
1098
|
+
const rejectedHookGate = new Promise<void>((resolve) => {
|
|
1099
|
+
releaseRejectedHook = resolve;
|
|
1100
|
+
});
|
|
1101
|
+
const backend = makeBackend({
|
|
1102
|
+
auth: createAuth(),
|
|
1103
|
+
adapter: rawMemoryAdapter,
|
|
1104
|
+
hooks: {
|
|
1105
|
+
onBeforeUpdateBoard: async (_id, data) => {
|
|
1106
|
+
events.push(data.name ?? "missing");
|
|
1107
|
+
if (data.name === "Rejected") {
|
|
1108
|
+
markRejectedHookStarted();
|
|
1109
|
+
await rejectedHookGate;
|
|
1110
|
+
throw new Error("workflow rejected");
|
|
1111
|
+
}
|
|
1112
|
+
},
|
|
1113
|
+
},
|
|
1114
|
+
});
|
|
1115
|
+
const board = await seedBoard(backend);
|
|
1116
|
+
const api = backend.forRequest(request("/race", { identity: owner }))
|
|
1117
|
+
.operations.kanban;
|
|
1118
|
+
const rejected = api.updateBoard({
|
|
1119
|
+
id: board.id,
|
|
1120
|
+
data: { name: "Rejected" },
|
|
1121
|
+
});
|
|
1122
|
+
await rejectedHookStarted;
|
|
1123
|
+
const now = new Date();
|
|
1124
|
+
const rawWinner = backend.adapter.create<Board>({
|
|
1125
|
+
model: "kanbanBoard",
|
|
1126
|
+
data: {
|
|
1127
|
+
name: "Raw winner",
|
|
1128
|
+
slug: "raw-winner",
|
|
1129
|
+
createdAt: now,
|
|
1130
|
+
updatedAt: now,
|
|
1131
|
+
},
|
|
1132
|
+
});
|
|
1133
|
+
const winner = api.updateBoard({
|
|
1134
|
+
id: board.id,
|
|
1135
|
+
data: { name: "Winner" },
|
|
1136
|
+
});
|
|
1137
|
+
releaseRejectedHook();
|
|
1138
|
+
await expect(rejected).rejects.toMatchObject({
|
|
1139
|
+
statusCode: 403,
|
|
1140
|
+
code: "UPDATE_BOARD_REJECTED",
|
|
1141
|
+
});
|
|
1142
|
+
await expect(winner).resolves.toMatchObject({ name: "Winner" });
|
|
1143
|
+
await expect(rawWinner).resolves.toMatchObject({ name: "Raw winner" });
|
|
1144
|
+
expect(events).toEqual(["Rejected", "Winner"]);
|
|
1145
|
+
expect(
|
|
1146
|
+
await backend.adapter.findOne<Board>({
|
|
1147
|
+
model: "kanbanBoard",
|
|
1148
|
+
where: [{ field: "id", value: board.id }],
|
|
1149
|
+
}),
|
|
1150
|
+
).toMatchObject({ name: "Winner" });
|
|
1151
|
+
expect(
|
|
1152
|
+
await backend.adapter.findOne<Board>({
|
|
1153
|
+
model: "kanbanBoard",
|
|
1154
|
+
where: [{ field: "slug", value: "raw-winner" }],
|
|
1155
|
+
}),
|
|
1156
|
+
).toMatchObject({ name: "Raw winner" });
|
|
1157
|
+
});
|
|
1158
|
+
|
|
1159
|
+
it("keeps awaited nested hook operations in the raw-memory transaction context", async () => {
|
|
1160
|
+
let backend: ReturnType<typeof makeBackend>;
|
|
1161
|
+
const nestedNames: string[] = [];
|
|
1162
|
+
backend = makeBackend({
|
|
1163
|
+
auth: createAuth(),
|
|
1164
|
+
adapter: rawMemoryAdapter,
|
|
1165
|
+
hooks: {
|
|
1166
|
+
onBeforeUpdateBoard: async (id) => {
|
|
1167
|
+
const nested = await backend.trusted.kanban.getBoard({ id });
|
|
1168
|
+
nestedNames.push(nested.name);
|
|
1169
|
+
},
|
|
1170
|
+
},
|
|
1171
|
+
});
|
|
1172
|
+
const board = await seedBoard(backend);
|
|
1173
|
+
await expect(
|
|
1174
|
+
backend
|
|
1175
|
+
.forRequest(request("/nested", { identity: owner }))
|
|
1176
|
+
.operations.kanban.updateBoard({
|
|
1177
|
+
id: board.id,
|
|
1178
|
+
data: { name: "Updated" },
|
|
1179
|
+
}),
|
|
1180
|
+
).resolves.toMatchObject({ name: "Updated" });
|
|
1181
|
+
expect(nestedNames).toEqual(["Roadmap"]);
|
|
1182
|
+
}, 1_000);
|
|
1183
|
+
|
|
1184
|
+
it("rolls back a caught nested after-hook failure with its raw-memory parent", async () => {
|
|
1185
|
+
let backend: ReturnType<typeof makeBackend>;
|
|
1186
|
+
let outerId = "";
|
|
1187
|
+
let nestedId = "";
|
|
1188
|
+
const caught: string[] = [];
|
|
1189
|
+
backend = makeBackend({
|
|
1190
|
+
auth: createAuth(),
|
|
1191
|
+
adapter: rawMemoryAdapter,
|
|
1192
|
+
hooks: {
|
|
1193
|
+
onBeforeUpdateBoard: async (id) => {
|
|
1194
|
+
if (id !== outerId) return;
|
|
1195
|
+
try {
|
|
1196
|
+
await backend.trusted.kanban.updateBoard({
|
|
1197
|
+
id: nestedId,
|
|
1198
|
+
data: { name: "Nested change" },
|
|
1199
|
+
});
|
|
1200
|
+
} catch (error) {
|
|
1201
|
+
caught.push(error instanceof Error ? error.message : "unknown");
|
|
1202
|
+
}
|
|
1203
|
+
},
|
|
1204
|
+
onAfterUpdateBoard: (board) => {
|
|
1205
|
+
if (board.id === nestedId) throw new Error("nested after rejected");
|
|
1206
|
+
},
|
|
1207
|
+
},
|
|
1208
|
+
});
|
|
1209
|
+
const outer = await seedBoard(backend, { slug: "outer" });
|
|
1210
|
+
const nested = await seedBoard(backend, {
|
|
1211
|
+
name: "Nested original",
|
|
1212
|
+
slug: "nested",
|
|
1213
|
+
});
|
|
1214
|
+
outerId = outer.id;
|
|
1215
|
+
nestedId = nested.id;
|
|
1216
|
+
await expect(
|
|
1217
|
+
backend
|
|
1218
|
+
.forRequest(request("/nested-write", { identity: owner }))
|
|
1219
|
+
.operations.kanban.updateBoard({
|
|
1220
|
+
id: outer.id,
|
|
1221
|
+
data: { name: "Outer change" },
|
|
1222
|
+
}),
|
|
1223
|
+
).rejects.toThrow("nested after rejected");
|
|
1224
|
+
expect(caught).toEqual(["nested after rejected"]);
|
|
1225
|
+
expect(
|
|
1226
|
+
await backend.adapter.findOne<Board>({
|
|
1227
|
+
model: "kanbanBoard",
|
|
1228
|
+
where: [{ field: "id", value: outer.id }],
|
|
1229
|
+
}),
|
|
1230
|
+
).toMatchObject({ name: "Roadmap" });
|
|
1231
|
+
expect(
|
|
1232
|
+
await backend.adapter.findOne<Board>({
|
|
1233
|
+
model: "kanbanBoard",
|
|
1234
|
+
where: [{ field: "id", value: nested.id }],
|
|
1235
|
+
}),
|
|
1236
|
+
).toMatchObject({ name: "Nested original" });
|
|
1237
|
+
}, 1_000);
|
|
1238
|
+
|
|
1239
|
+
it("serializes competing moves, preserves ordering, and runs only the winning hook", async () => {
|
|
1240
|
+
const events: string[] = [];
|
|
1241
|
+
const backend = makeBackend({
|
|
1242
|
+
auth: createAuth(),
|
|
1243
|
+
adapter: rawMemoryAdapter,
|
|
1244
|
+
hooks: {
|
|
1245
|
+
onBeforeUpdateTask: (id) => {
|
|
1246
|
+
events.push(id);
|
|
1247
|
+
},
|
|
1248
|
+
},
|
|
1249
|
+
});
|
|
1250
|
+
const board = await seedBoard(backend);
|
|
1251
|
+
const source = await seedColumn(backend, board.id);
|
|
1252
|
+
const target = await seedColumn(backend, board.id, {
|
|
1253
|
+
title: "Done",
|
|
1254
|
+
order: 1,
|
|
1255
|
+
});
|
|
1256
|
+
const moved = await seedTask(backend, source.id);
|
|
1257
|
+
const sourceSibling = await seedTask(backend, source.id, {
|
|
1258
|
+
title: "Source sibling",
|
|
1259
|
+
order: 1,
|
|
1260
|
+
});
|
|
1261
|
+
const targetSibling = await seedTask(backend, target.id, {
|
|
1262
|
+
title: "Target sibling",
|
|
1263
|
+
order: 0,
|
|
1264
|
+
});
|
|
1265
|
+
const api = backend.forRequest(request("/move", { identity: owner }))
|
|
1266
|
+
.operations.kanban;
|
|
1267
|
+
const settled = await Promise.allSettled([
|
|
1268
|
+
api.moveTask({
|
|
1269
|
+
taskId: moved.id,
|
|
1270
|
+
targetColumnId: target.id,
|
|
1271
|
+
targetOrder: 0,
|
|
1272
|
+
}),
|
|
1273
|
+
api.moveTask({
|
|
1274
|
+
taskId: moved.id,
|
|
1275
|
+
targetColumnId: target.id,
|
|
1276
|
+
targetOrder: 1,
|
|
1277
|
+
}),
|
|
1278
|
+
]);
|
|
1279
|
+
expect(settled.filter(({ status }) => status === "fulfilled")).toHaveLength(
|
|
1280
|
+
1,
|
|
1281
|
+
);
|
|
1282
|
+
expect(settled.filter(({ status }) => status === "rejected")).toHaveLength(
|
|
1283
|
+
1,
|
|
1284
|
+
);
|
|
1285
|
+
expect(events).toEqual([moved.id]);
|
|
1286
|
+
const sourceTasks = await backend.adapter.findMany<Task>({
|
|
1287
|
+
model: "kanbanTask",
|
|
1288
|
+
where: [{ field: "columnId", value: source.id }],
|
|
1289
|
+
sortBy: { field: "order", direction: "asc" },
|
|
1290
|
+
});
|
|
1291
|
+
const targetTasks = await backend.adapter.findMany<Task>({
|
|
1292
|
+
model: "kanbanTask",
|
|
1293
|
+
where: [{ field: "columnId", value: target.id }],
|
|
1294
|
+
sortBy: { field: "order", direction: "asc" },
|
|
1295
|
+
});
|
|
1296
|
+
expect(sourceTasks.map(({ id, order }) => [id, order])).toEqual([
|
|
1297
|
+
[sourceSibling.id, 0],
|
|
1298
|
+
]);
|
|
1299
|
+
expect(targetTasks.map((task) => task.id).sort()).toEqual(
|
|
1300
|
+
[moved.id, targetSibling.id].sort(),
|
|
1301
|
+
);
|
|
1302
|
+
expect(targetTasks.map((task) => task.order).sort()).toEqual([0, 1]);
|
|
1303
|
+
});
|
|
1304
|
+
|
|
1305
|
+
it("rolls back move claims when a post-authorization domain hook rejects", async () => {
|
|
1306
|
+
const backend = makeBackend({
|
|
1307
|
+
auth: createAuth(),
|
|
1308
|
+
hooks: {
|
|
1309
|
+
onBeforeUpdateTask: () => {
|
|
1310
|
+
throw new Error("workflow rejected");
|
|
1311
|
+
},
|
|
1312
|
+
},
|
|
1313
|
+
});
|
|
1314
|
+
const board = await seedBoard(backend);
|
|
1315
|
+
const source = await seedColumn(backend, board.id);
|
|
1316
|
+
const target = await seedColumn(backend, board.id, {
|
|
1317
|
+
title: "Done",
|
|
1318
|
+
order: 1,
|
|
1319
|
+
});
|
|
1320
|
+
const task = await seedTask(backend, source.id);
|
|
1321
|
+
await expect(
|
|
1322
|
+
backend
|
|
1323
|
+
.forRequest(request("/rejected", { identity: owner }))
|
|
1324
|
+
.operations.kanban.moveTask({
|
|
1325
|
+
taskId: task.id,
|
|
1326
|
+
targetColumnId: target.id,
|
|
1327
|
+
targetOrder: 0,
|
|
1328
|
+
}),
|
|
1329
|
+
).rejects.toMatchObject({ statusCode: 403, code: "MOVE_TASK_REJECTED" });
|
|
1330
|
+
expect(
|
|
1331
|
+
await backend.adapter.findOne<Task>({
|
|
1332
|
+
model: "kanbanTask",
|
|
1333
|
+
where: [{ field: "id", value: task.id }],
|
|
1334
|
+
}),
|
|
1335
|
+
).toMatchObject({ columnId: source.id, order: 0 });
|
|
1336
|
+
});
|
|
1337
|
+
|
|
1338
|
+
it("keeps raw helpers out of authorized namespaces and documents raw SSG data", async () => {
|
|
1339
|
+
const backend = makeBackend({ auth: createAuth() });
|
|
1340
|
+
const board = await seedBoard(backend);
|
|
1341
|
+
const column = await seedColumn(backend, board.id);
|
|
1342
|
+
await seedTask(backend, column.id);
|
|
1343
|
+
expect("prefetchForRoute" in backend.trusted.kanban).toBe(false);
|
|
1344
|
+
expect("getAllBoards" in backend.trusted.kanban).toBe(false);
|
|
1345
|
+
expect("createTask" in backend.trusted.kanban).toBe(true);
|
|
1346
|
+
expect(
|
|
1347
|
+
"prefetchForRoute" in
|
|
1348
|
+
backend.forRequest(request("/raw")).operations.kanban,
|
|
1349
|
+
).toBe(false);
|
|
1350
|
+
const queryClient = new QueryClient();
|
|
1351
|
+
const prefetchFindMany = vi.spyOn(backend.adapter, "findMany");
|
|
1352
|
+
await backend.raw.kanban.prefetchForRoute("boards", queryClient);
|
|
1353
|
+
expect(
|
|
1354
|
+
prefetchFindMany.mock.calls.some(
|
|
1355
|
+
([query]) => query.model === "kanbanBoard",
|
|
1356
|
+
),
|
|
1357
|
+
).toBe(true);
|
|
1358
|
+
expect(
|
|
1359
|
+
prefetchFindMany.mock.calls.some(
|
|
1360
|
+
([query]) => query.model === "kanbanTask",
|
|
1361
|
+
),
|
|
1362
|
+
).toBe(false);
|
|
1363
|
+
expect(
|
|
1364
|
+
queryClient.getQueryData<Array<{ columns: Array<unknown> }>>(
|
|
1365
|
+
KANBAN_QUERY_KEYS.boardsList({}),
|
|
1366
|
+
),
|
|
1367
|
+
).toEqual([
|
|
1368
|
+
expect.objectContaining({
|
|
1369
|
+
id: board.id,
|
|
1370
|
+
columns: [expect.not.objectContaining({ tasks: expect.anything() })],
|
|
1371
|
+
}),
|
|
1372
|
+
]);
|
|
1373
|
+
await backend.raw.kanban.prefetchForRoute("board", queryClient, {
|
|
1374
|
+
boardId: board.id,
|
|
1375
|
+
});
|
|
1376
|
+
expect(
|
|
1377
|
+
queryClient.getQueryData(KANBAN_QUERY_KEYS.boardDetail(board.id)),
|
|
1378
|
+
).toMatchObject({
|
|
1379
|
+
id: board.id,
|
|
1380
|
+
});
|
|
1381
|
+
});
|
|
1382
|
+
});
|