@btst/stack 3.0.0-rc.1 → 3.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -46
- package/dist/api/index.cjs +133 -29
- package/dist/api/index.d.cts +14 -32
- package/dist/api/index.d.mts +14 -32
- package/dist/api/index.d.ts +14 -32
- package/dist/api/index.mjs +133 -28
- package/dist/authorization/client.cjs +154 -0
- package/dist/authorization/client.d.cts +70 -0
- package/dist/authorization/client.d.mts +70 -0
- package/dist/authorization/client.d.ts +70 -0
- package/dist/authorization/client.mjs +152 -0
- package/dist/authorization/index.cjs +371 -0
- package/dist/authorization/index.d.cts +201 -0
- package/dist/authorization/index.d.mts +201 -0
- package/dist/authorization/index.d.ts +201 -0
- package/dist/authorization/index.mjs +365 -0
- package/dist/authorization/remote.cjs +117 -0
- package/dist/authorization/remote.d.cts +79 -0
- package/dist/authorization/remote.d.mts +79 -0
- package/dist/authorization/remote.d.ts +79 -0
- package/dist/authorization/remote.mjs +111 -0
- package/dist/authorization/server.cjs +77 -0
- package/dist/authorization/server.d.cts +51 -0
- package/dist/authorization/server.d.mts +51 -0
- package/dist/authorization/server.d.ts +51 -0
- package/dist/authorization/server.mjs +73 -0
- package/dist/client/components/index.cjs +1 -0
- package/dist/client/components/index.d.cts +23 -6
- package/dist/client/components/index.d.mts +23 -6
- package/dist/client/components/index.d.ts +23 -6
- package/dist/client/components/index.mjs +1 -1
- package/dist/client/hooks/index.cjs +8 -0
- package/dist/client/hooks/index.d.cts +25 -0
- package/dist/client/hooks/index.d.mts +25 -0
- package/dist/client/hooks/index.d.ts +25 -0
- package/dist/client/hooks/index.mjs +2 -0
- package/dist/client/index.cjs +38 -7
- package/dist/client/index.d.cts +30 -100
- package/dist/client/index.d.mts +30 -100
- package/dist/client/index.d.ts +30 -100
- package/dist/client/index.mjs +38 -7
- package/dist/client/server.cjs +96 -0
- package/dist/client/server.d.cts +57 -0
- package/dist/client/server.d.mts +57 -0
- package/dist/client/server.d.ts +57 -0
- package/dist/client/server.mjs +92 -0
- package/dist/components/auto-form/index.d.cts +2 -2
- package/dist/components/auto-form/index.d.mts +2 -2
- package/dist/components/auto-form/index.d.ts +2 -2
- package/dist/components/form-builder/index.d.cts +1 -1
- package/dist/components/form-builder/index.d.mts +1 -1
- package/dist/components/form-builder/index.d.ts +1 -1
- package/dist/components/stepped-auto-form/index.d.cts +1 -1
- package/dist/components/stepped-auto-form/index.d.mts +1 -1
- package/dist/components/stepped-auto-form/index.d.ts +1 -1
- package/dist/context/index.cjs +8 -2
- package/dist/context/index.d.cts +111 -89
- package/dist/context/index.d.mts +111 -89
- package/dist/context/index.d.ts +111 -89
- package/dist/context/index.mjs +3 -1
- package/dist/index.cjs +1 -2
- package/dist/index.d.cts +8 -3
- package/dist/index.d.mts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.mjs +1 -1
- package/dist/next/index.d.cts +30 -12
- package/dist/next/index.d.mts +30 -12
- package/dist/next/index.d.ts +30 -12
- package/dist/next/server.cjs +7 -0
- package/dist/next/server.d.cts +56 -0
- package/dist/next/server.d.mts +56 -0
- package/dist/next/server.d.ts +56 -0
- package/dist/next/server.mjs +1 -0
- package/dist/packages/stack/src/authorization/json.cjs +57 -0
- package/dist/packages/stack/src/authorization/json.mjs +55 -0
- package/dist/packages/stack/src/client/components/compose.cjs +91 -9
- package/dist/packages/stack/src/client/components/compose.mjs +92 -11
- package/dist/packages/stack/src/client/runtime.cjs +295 -0
- package/dist/packages/stack/src/client/runtime.mjs +293 -0
- package/dist/packages/stack/src/context/auth.cjs +141 -73
- package/dist/packages/stack/src/context/auth.mjs +139 -73
- package/dist/packages/stack/src/context/provider.cjs +11 -5
- package/dist/packages/stack/src/context/provider.mjs +11 -5
- package/dist/packages/stack/src/context/router.cjs +9 -0
- package/dist/packages/stack/src/context/router.mjs +7 -0
- package/dist/packages/stack/src/context/site-navigation.cjs +40 -0
- package/dist/packages/stack/src/context/site-navigation.mjs +38 -0
- package/dist/packages/stack/src/next/layout.cjs +27 -0
- package/dist/packages/stack/src/next/layout.mjs +25 -0
- package/dist/packages/stack/src/next/page.cjs +8 -6
- package/dist/packages/stack/src/next/page.mjs +8 -6
- package/dist/packages/stack/src/plugin-registration.cjs +59 -0
- package/dist/packages/stack/src/plugin-registration.mjs +57 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/lifecycle-migrations.cjs +18 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/lifecycle-migrations.mjs +16 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/operations.cjs +1341 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/operations.mjs +1333 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/plugin.cjs +82 -640
- package/dist/packages/stack/src/plugins/ai-chat/api/plugin.mjs +78 -641
- package/dist/packages/stack/src/plugins/ai-chat/api/serializers.cjs +23 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/serializers.mjs +20 -0
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-input.cjs +183 -111
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-input.mjs +187 -115
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-interface.cjs +562 -116
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-interface.mjs +567 -121
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-layout.cjs +6 -6
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-layout.mjs +6 -6
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-message.cjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-message.mjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-sidebar.cjs +45 -29
- package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-sidebar.mjs +46 -30
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/404-page.cjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/404-page.mjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.cjs +46 -7
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.internal.cjs +5 -3
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.internal.mjs +5 -3
- package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.mjs +48 -9
- package/dist/packages/stack/src/plugins/ai-chat/client/components/shared/default-error.cjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/shared/default-error.mjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/tool-call-display.cjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/components/tool-call-display.mjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/hooks/ai-chat-resource.cjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/hooks/ai-chat-resource.mjs +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/hooks/chat-hooks.cjs +179 -19
- package/dist/packages/stack/src/plugins/ai-chat/client/hooks/chat-hooks.mjs +180 -21
- package/dist/packages/stack/src/plugins/ai-chat/client/navigation.cjs +11 -0
- package/dist/packages/stack/src/plugins/ai-chat/client/navigation.mjs +9 -0
- package/dist/packages/stack/src/plugins/ai-chat/client/overrides.cjs +24 -0
- package/dist/packages/stack/src/plugins/ai-chat/client/overrides.mjs +21 -1
- package/dist/packages/stack/src/plugins/ai-chat/client/plugin.cjs +152 -82
- package/dist/packages/stack/src/plugins/ai-chat/client/plugin.mjs +152 -82
- package/dist/packages/stack/src/plugins/api/create-endpoint.cjs +27 -9
- package/dist/packages/stack/src/plugins/api/create-endpoint.mjs +27 -10
- package/dist/packages/stack/src/plugins/api/endpoint-inventory.cjs +125 -0
- package/dist/packages/stack/src/plugins/api/endpoint-inventory.mjs +123 -0
- package/dist/packages/stack/src/plugins/api/operation.cjs +208 -0
- package/dist/packages/stack/src/plugins/api/operation.mjs +198 -0
- package/dist/packages/stack/src/plugins/blog/api/lifecycle-migrations.cjs +17 -0
- package/dist/packages/stack/src/plugins/blog/api/lifecycle-migrations.mjs +15 -0
- package/dist/packages/stack/src/plugins/blog/api/mutations.cjs +10 -2
- package/dist/packages/stack/src/plugins/blog/api/mutations.mjs +10 -2
- package/dist/packages/stack/src/plugins/blog/api/operations.cjs +455 -0
- package/dist/packages/stack/src/plugins/blog/api/operations.mjs +448 -0
- package/dist/packages/stack/src/plugins/blog/api/plugin.cjs +51 -298
- package/dist/packages/stack/src/plugins/blog/api/plugin.mjs +55 -304
- package/dist/packages/stack/src/plugins/blog/client/components/forms/image-field.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/forms/image-field.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/forms/markdown-editor-with-overrides.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/forms/markdown-editor-with-overrides.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/forms/post-forms.cjs +82 -67
- package/dist/packages/stack/src/plugins/blog/client/components/forms/post-forms.mjs +84 -69
- package/dist/packages/stack/src/plugins/blog/client/components/pages/404-page.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/404-page.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.cjs +22 -4
- package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.internal.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.internal.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.mjs +23 -5
- package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.cjs +6 -2
- package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.internal.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.internal.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.mjs +6 -2
- package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.cjs +4 -2
- package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.internal.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.internal.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.mjs +4 -2
- package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.cjs +30 -3
- package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.internal.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.internal.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.mjs +31 -4
- package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.cjs +4 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.internal.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.internal.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.mjs +4 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/collapsible-tag-list.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/collapsible-tag-list.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/default-error.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/default-error.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/on-this-page.cjs +3 -2
- package/dist/packages/stack/src/plugins/blog/client/components/shared/on-this-page.mjs +3 -2
- package/dist/packages/stack/src/plugins/blog/client/components/shared/page-wrapper.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/page-wrapper.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/post-card.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/post-card.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/posts-list.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/posts-list.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/recent-posts-carousel.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/recent-posts-carousel.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/components/shared/search-input.cjs +2 -2
- package/dist/packages/stack/src/plugins/blog/client/components/shared/search-input.mjs +1 -1
- package/dist/packages/stack/src/plugins/blog/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/blog/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/blog/client/hooks/blog-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/hooks/blog-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/blog/client/plugin.cjs +169 -163
- package/dist/packages/stack/src/plugins/blog/client/plugin.mjs +169 -163
- package/dist/packages/stack/src/plugins/client/resource/hooks.cjs +31 -16
- package/dist/packages/stack/src/plugins/client/resource/hooks.mjs +31 -16
- package/dist/packages/stack/src/plugins/client/resource/internal.cjs +66 -52
- package/dist/packages/stack/src/plugins/client/resource/internal.mjs +66 -52
- package/dist/packages/stack/src/plugins/client/resource/use-form.cjs +20 -17
- package/dist/packages/stack/src/plugins/client/resource/use-form.mjs +20 -17
- package/dist/packages/stack/src/plugins/client/resource/use-select.cjs +39 -33
- package/dist/packages/stack/src/plugins/client/resource/use-select.mjs +39 -33
- package/dist/packages/stack/src/plugins/cms/api/lifecycle-migrations.cjs +13 -0
- package/dist/packages/stack/src/plugins/cms/api/lifecycle-migrations.mjs +11 -0
- package/dist/packages/stack/src/plugins/cms/api/operations.cjs +1763 -0
- package/dist/packages/stack/src/plugins/cms/api/operations.mjs +1756 -0
- package/dist/packages/stack/src/plugins/cms/api/plugin.cjs +165 -752
- package/dist/packages/stack/src/plugins/cms/api/plugin.mjs +164 -755
- package/dist/packages/stack/src/plugins/cms/client/components/forms/content-form.cjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/forms/content-form.mjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/forms/file-upload.cjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/forms/file-upload.mjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/forms/relation-field.cjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/forms/relation-field.mjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/inverse-relations-panel.cjs +23 -13
- package/dist/packages/stack/src/plugins/cms/client/components/inverse-relations-panel.mjs +24 -14
- package/dist/packages/stack/src/plugins/cms/client/components/pages/404-page.cjs +5 -4
- package/dist/packages/stack/src/plugins/cms/client/components/pages/404-page.mjs +6 -5
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.cjs +40 -7
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.cjs +15 -9
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.mjs +14 -8
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.mjs +41 -8
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.cjs +7 -1
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.internal.cjs +42 -29
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.internal.mjs +40 -27
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.mjs +7 -1
- package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.cjs +4 -1
- package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.internal.cjs +13 -7
- package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.internal.mjs +12 -6
- package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.mjs +4 -1
- package/dist/packages/stack/src/plugins/cms/client/components/shared/page-wrapper.cjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/components/shared/page-wrapper.mjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/cms/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/cms/client/hooks/cms-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/hooks/cms-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/cms/client/overrides.cjs +26 -0
- package/dist/packages/stack/src/plugins/cms/client/overrides.mjs +24 -0
- package/dist/packages/stack/src/plugins/cms/client/plugin.cjs +102 -81
- package/dist/packages/stack/src/plugins/cms/client/plugin.mjs +103 -82
- package/dist/packages/stack/src/plugins/comments/api/getters.cjs +6 -2
- package/dist/packages/stack/src/plugins/comments/api/getters.mjs +6 -3
- package/dist/packages/stack/src/plugins/comments/api/lifecycle-migrations.cjs +18 -0
- package/dist/packages/stack/src/plugins/comments/api/lifecycle-migrations.mjs +16 -0
- package/dist/packages/stack/src/plugins/comments/api/mutations.cjs +179 -68
- package/dist/packages/stack/src/plugins/comments/api/mutations.mjs +179 -68
- package/dist/packages/stack/src/plugins/comments/api/operations.cjs +453 -0
- package/dist/packages/stack/src/plugins/comments/api/operations.mjs +445 -0
- package/dist/packages/stack/src/plugins/comments/api/plugin.cjs +51 -276
- package/dist/packages/stack/src/plugins/comments/api/plugin.mjs +48 -277
- package/dist/packages/stack/src/plugins/comments/client/components/comment-count.cjs +32 -5
- package/dist/packages/stack/src/plugins/comments/client/components/comment-count.mjs +34 -7
- package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.cjs +161 -105
- package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.mjs +162 -106
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.cjs +14 -2
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.internal.cjs +141 -71
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.internal.mjs +142 -72
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.mjs +14 -2
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-state.cjs +12 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-state.mjs +9 -0
- package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.cjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.internal.cjs +40 -26
- package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.internal.mjs +40 -26
- package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.mjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.cjs +9 -1
- package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.internal.cjs +25 -20
- package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.internal.mjs +26 -21
- package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.mjs +9 -1
- package/dist/packages/stack/src/plugins/comments/client/components/shared/page-wrapper.cjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/components/shared/page-wrapper.mjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/components/shared/pagination.cjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/components/shared/pagination.mjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/comments/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.cjs +323 -290
- package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.mjs +325 -292
- package/dist/packages/stack/src/plugins/comments/client/localization/comments-thread.cjs +1 -0
- package/dist/packages/stack/src/plugins/comments/client/localization/comments-thread.mjs +1 -0
- package/dist/packages/stack/src/plugins/comments/client/plugin.cjs +78 -46
- package/dist/packages/stack/src/plugins/comments/client/plugin.mjs +80 -48
- package/dist/packages/stack/src/plugins/form-builder/api/getters.cjs +9 -0
- package/dist/packages/stack/src/plugins/form-builder/api/getters.mjs +9 -1
- package/dist/packages/stack/src/plugins/form-builder/api/lifecycle-migrations.cjs +15 -0
- package/dist/packages/stack/src/plugins/form-builder/api/lifecycle-migrations.mjs +13 -0
- package/dist/packages/stack/src/plugins/form-builder/api/operations.cjs +1093 -0
- package/dist/packages/stack/src/plugins/form-builder/api/operations.mjs +1082 -0
- package/dist/packages/stack/src/plugins/form-builder/api/plugin.cjs +97 -466
- package/dist/packages/stack/src/plugins/form-builder/api/plugin.mjs +92 -468
- package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.cjs +5 -0
- package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.mjs +5 -0
- package/dist/packages/stack/src/plugins/form-builder/client/components/forms/form-renderer.cjs +41 -11
- package/dist/packages/stack/src/plugins/form-builder/client/components/forms/form-renderer.mjs +42 -12
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/404-page.cjs +8 -5
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/404-page.mjs +9 -6
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.cjs +36 -3
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.cjs +32 -11
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.mjs +35 -14
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.mjs +37 -4
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.cjs +6 -1
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.cjs +34 -26
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.mjs +34 -26
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.mjs +6 -1
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.cjs +24 -7
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.cjs +72 -40
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.mjs +76 -44
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.mjs +25 -8
- package/dist/packages/stack/src/plugins/form-builder/client/components/shared/page-wrapper.cjs +2 -1
- package/dist/packages/stack/src/plugins/form-builder/client/components/shared/page-wrapper.mjs +2 -1
- package/dist/packages/stack/src/plugins/form-builder/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/form-builder/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-hooks.cjs +29 -0
- package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-hooks.mjs +28 -1
- package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/form-builder/client/plugin.cjs +113 -86
- package/dist/packages/stack/src/plugins/form-builder/client/plugin.mjs +114 -87
- package/dist/packages/stack/src/plugins/form-builder/schemas.cjs +9 -3
- package/dist/packages/stack/src/plugins/form-builder/schemas.mjs +9 -3
- package/dist/packages/stack/src/plugins/kanban/api/getters.cjs +47 -36
- package/dist/packages/stack/src/plugins/kanban/api/getters.mjs +47 -37
- package/dist/packages/stack/src/plugins/kanban/api/lifecycle-migrations.cjs +23 -0
- package/dist/packages/stack/src/plugins/kanban/api/lifecycle-migrations.mjs +21 -0
- package/dist/packages/stack/src/plugins/kanban/api/operations.cjs +1552 -0
- package/dist/packages/stack/src/plugins/kanban/api/operations.mjs +1543 -0
- package/dist/packages/stack/src/plugins/kanban/api/plugin.cjs +64 -631
- package/dist/packages/stack/src/plugins/kanban/api/plugin.mjs +62 -634
- package/dist/packages/stack/src/plugins/kanban/api/serializers.cjs +21 -0
- package/dist/packages/stack/src/plugins/kanban/api/serializers.mjs +21 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/board-form.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/board-form.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/column-form.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/column-form.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/task-form.cjs +72 -54
- package/dist/packages/stack/src/plugins/kanban/client/components/forms/task-form.mjs +74 -56
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/404-page.cjs +4 -6
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/404-page.mjs +5 -7
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.cjs +22 -6
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.internal.cjs +82 -77
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.internal.mjs +83 -78
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.mjs +23 -7
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.internal.cjs +34 -24
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.internal.mjs +35 -25
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.internal.cjs +6 -9
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.internal.mjs +7 -10
- package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/column-content.cjs +72 -45
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/column-content.mjs +73 -46
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/default-error.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/default-error.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/kanban-board.cjs +4 -4
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/kanban-board.mjs +4 -4
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/permission-access-any.cjs +23 -0
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/permission-access-any.mjs +21 -0
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/task-card.cjs +54 -17
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/task-card.mjs +55 -18
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/user-avatar.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/components/shared/user-avatar.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/kanban/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-hooks.cjs +38 -9
- package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-hooks.mjs +39 -10
- package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/kanban/client/plugin.cjs +177 -104
- package/dist/packages/stack/src/plugins/kanban/client/plugin.mjs +178 -105
- package/dist/packages/stack/src/plugins/kanban/schemas.cjs +32 -23
- package/dist/packages/stack/src/plugins/kanban/schemas.mjs +33 -21
- package/dist/packages/stack/src/plugins/media/api/lifecycle-migrations.cjs +9 -0
- package/dist/packages/stack/src/plugins/media/api/lifecycle-migrations.mjs +7 -0
- package/dist/packages/stack/src/plugins/media/api/mutations.cjs +7 -2
- package/dist/packages/stack/src/plugins/media/api/mutations.mjs +7 -2
- package/dist/packages/stack/src/plugins/media/api/operations.cjs +1299 -0
- package/dist/packages/stack/src/plugins/media/api/operations.mjs +1290 -0
- package/dist/packages/stack/src/plugins/media/api/plugin.cjs +131 -508
- package/dist/packages/stack/src/plugins/media/api/plugin.mjs +127 -510
- package/dist/packages/stack/src/plugins/media/api/query-key-defs.cjs +26 -2
- package/dist/packages/stack/src/plugins/media/api/query-key-defs.mjs +25 -3
- package/dist/packages/stack/src/plugins/media/api/serializers.cjs +4 -2
- package/dist/packages/stack/src/plugins/media/api/serializers.mjs +4 -2
- package/dist/packages/stack/src/plugins/media/asset-url.cjs +13 -0
- package/dist/packages/stack/src/plugins/media/asset-url.mjs +11 -0
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/asset-card.cjs +10 -10
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/asset-card.mjs +12 -12
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/folder-tree.cjs +47 -27
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/folder-tree.mjs +49 -29
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/index.cjs +225 -180
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/index.mjs +228 -183
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/upload-tab.cjs +1 -8
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/upload-tab.mjs +2 -9
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/url-tab.cjs +0 -6
- package/dist/packages/stack/src/plugins/media/client/components/media-picker/url-tab.mjs +1 -7
- package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.cjs +4 -2
- package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.internal.cjs +92 -75
- package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.internal.mjs +93 -76
- package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.mjs +4 -2
- package/dist/packages/stack/src/plugins/media/client/components/upload-permission-check.cjs +52 -0
- package/dist/packages/stack/src/plugins/media/client/components/upload-permission-check.mjs +49 -0
- package/dist/packages/stack/src/plugins/media/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/media/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/media/client/hooks/media-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/media/client/hooks/media-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/media/client/hooks/use-media.cjs +214 -43
- package/dist/packages/stack/src/plugins/media/client/hooks/use-media.mjs +217 -46
- package/dist/packages/stack/src/plugins/media/client/plugin.cjs +122 -62
- package/dist/packages/stack/src/plugins/media/client/plugin.mjs +123 -63
- package/dist/packages/stack/src/plugins/media/client/upload.cjs +121 -52
- package/dist/packages/stack/src/plugins/media/client/upload.mjs +121 -53
- package/dist/packages/stack/src/plugins/media/db.cjs +8 -0
- package/dist/packages/stack/src/plugins/media/db.mjs +8 -0
- package/dist/packages/stack/src/plugins/open-api/api/generator.cjs +36 -5
- package/dist/packages/stack/src/plugins/open-api/api/generator.mjs +36 -5
- package/dist/packages/stack/src/plugins/open-api/api/plugin.cjs +22 -11
- package/dist/packages/stack/src/plugins/open-api/api/plugin.mjs +22 -11
- package/dist/packages/stack/src/plugins/route-docs/client/components/pages/docs-page.cjs +65 -34
- package/dist/packages/stack/src/plugins/route-docs/client/components/pages/docs-page.mjs +56 -25
- package/dist/packages/stack/src/plugins/route-docs/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/route-docs/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/route-docs/client/hooks.cjs +9 -8
- package/dist/packages/stack/src/plugins/route-docs/client/hooks.mjs +10 -9
- package/dist/packages/stack/src/plugins/route-docs/client/plugin.cjs +143 -75
- package/dist/packages/stack/src/plugins/route-docs/client/plugin.mjs +144 -74
- package/dist/packages/stack/src/plugins/route-docs/client/schema.cjs +26 -0
- package/dist/packages/stack/src/plugins/route-docs/client/schema.mjs +23 -0
- package/dist/packages/stack/src/plugins/route-docs/generator.cjs +7 -4
- package/dist/packages/stack/src/plugins/route-docs/generator.mjs +7 -4
- package/dist/packages/stack/src/plugins/ui-builder/client/components/page-renderer.cjs +41 -12
- package/dist/packages/stack/src/plugins/ui-builder/client/components/page-renderer.mjs +42 -13
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.cjs +37 -3
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.cjs +32 -20
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.mjs +34 -22
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.mjs +38 -4
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.cjs +8 -2
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.internal.cjs +37 -19
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.internal.mjs +38 -20
- package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.mjs +8 -2
- package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/default-error.cjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/default-error.mjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/page-wrapper.cjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/page-wrapper.mjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/constants.cjs +5 -0
- package/dist/packages/stack/src/plugins/ui-builder/client/constants.mjs +3 -0
- package/dist/packages/stack/src/plugins/ui-builder/client/hooks/ui-builder-resource.cjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/hooks/ui-builder-resource.mjs +2 -1
- package/dist/packages/stack/src/plugins/ui-builder/client/overrides.cjs +8 -0
- package/dist/packages/stack/src/plugins/ui-builder/client/overrides.mjs +6 -0
- package/dist/packages/stack/src/plugins/ui-builder/client/plugin.cjs +93 -53
- package/dist/packages/stack/src/plugins/ui-builder/client/plugin.mjs +94 -54
- package/dist/packages/stack/src/plugins/utils.cjs +4 -12
- package/dist/packages/stack/src/plugins/utils.mjs +5 -12
- package/dist/packages/stack/src/react-router/layout.cjs +14 -0
- package/dist/packages/stack/src/react-router/layout.mjs +12 -0
- package/dist/packages/stack/src/react-router/page.cjs +27 -16
- package/dist/packages/stack/src/react-router/page.mjs +28 -17
- package/dist/packages/stack/src/shared/initial-identity.cjs +27 -0
- package/dist/packages/stack/src/shared/initial-identity.mjs +23 -0
- package/dist/packages/stack/src/tanstack/layout.cjs +10 -0
- package/dist/packages/stack/src/tanstack/layout.mjs +8 -0
- package/dist/packages/stack/src/tanstack/page.cjs +11 -5
- package/dist/packages/stack/src/tanstack/page.mjs +11 -5
- package/dist/plugins/ai-chat/api/index.cjs +10 -0
- package/dist/plugins/ai-chat/api/index.d.cts +31 -5
- package/dist/plugins/ai-chat/api/index.d.mts +31 -5
- package/dist/plugins/ai-chat/api/index.d.ts +31 -5
- package/dist/plugins/ai-chat/api/index.mjs +3 -1
- package/dist/plugins/ai-chat/client/components/index.d.cts +1 -1
- package/dist/plugins/ai-chat/client/components/index.d.mts +1 -1
- package/dist/plugins/ai-chat/client/components/index.d.ts +1 -1
- package/dist/plugins/ai-chat/client/hooks/index.cjs +1 -0
- package/dist/plugins/ai-chat/client/hooks/index.d.cts +14 -8
- package/dist/plugins/ai-chat/client/hooks/index.d.mts +14 -8
- package/dist/plugins/ai-chat/client/hooks/index.d.ts +14 -8
- package/dist/plugins/ai-chat/client/hooks/index.mjs +1 -1
- package/dist/plugins/ai-chat/client/index.d.cts +21 -25
- package/dist/plugins/ai-chat/client/index.d.mts +21 -25
- package/dist/plugins/ai-chat/client/index.d.ts +21 -25
- package/dist/plugins/ai-chat/permissions.cjs +90 -0
- package/dist/plugins/ai-chat/permissions.d.cts +84 -0
- package/dist/plugins/ai-chat/permissions.d.mts +84 -0
- package/dist/plugins/ai-chat/permissions.d.ts +84 -0
- package/dist/plugins/ai-chat/permissions.mjs +88 -0
- package/dist/plugins/ai-chat/query-keys.cjs +116 -18
- package/dist/plugins/ai-chat/query-keys.d.cts +6 -2
- package/dist/plugins/ai-chat/query-keys.d.mts +6 -2
- package/dist/plugins/ai-chat/query-keys.d.ts +6 -2
- package/dist/plugins/ai-chat/query-keys.mjs +116 -19
- package/dist/plugins/api/index.cjs +4 -0
- package/dist/plugins/api/index.d.cts +13 -18
- package/dist/plugins/api/index.d.mts +13 -18
- package/dist/plugins/api/index.d.ts +13 -18
- package/dist/plugins/api/index.mjs +1 -0
- package/dist/plugins/blog/api/index.cjs +9 -2
- package/dist/plugins/blog/api/index.d.cts +118 -4
- package/dist/plugins/blog/api/index.d.mts +118 -4
- package/dist/plugins/blog/api/index.d.ts +118 -4
- package/dist/plugins/blog/api/index.mjs +4 -1
- package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
- package/dist/plugins/blog/client/index.d.cts +210 -226
- package/dist/plugins/blog/client/index.d.mts +210 -226
- package/dist/plugins/blog/client/index.d.ts +210 -226
- package/dist/plugins/blog/permissions.cjs +47 -0
- package/dist/plugins/blog/permissions.d.cts +49 -0
- package/dist/plugins/blog/permissions.d.mts +49 -0
- package/dist/plugins/blog/permissions.d.ts +49 -0
- package/dist/plugins/blog/permissions.mjs +45 -0
- package/dist/plugins/blog/query-keys.d.cts +7 -3
- package/dist/plugins/blog/query-keys.d.mts +7 -3
- package/dist/plugins/blog/query-keys.d.ts +7 -3
- package/dist/plugins/client/hooks/index.d.cts +2 -2
- package/dist/plugins/client/hooks/index.d.mts +2 -2
- package/dist/plugins/client/hooks/index.d.ts +2 -2
- package/dist/plugins/client/index.cjs +3 -0
- package/dist/plugins/client/index.d.cts +30 -10
- package/dist/plugins/client/index.d.mts +30 -10
- package/dist/plugins/client/index.d.ts +30 -10
- package/dist/plugins/client/index.mjs +3 -0
- package/dist/plugins/cms/api/index.cjs +7 -0
- package/dist/plugins/cms/api/index.d.cts +173 -4
- package/dist/plugins/cms/api/index.d.mts +173 -4
- package/dist/plugins/cms/api/index.d.ts +173 -4
- package/dist/plugins/cms/api/index.mjs +2 -0
- package/dist/plugins/cms/client/hooks/index.d.cts +1 -1
- package/dist/plugins/cms/client/hooks/index.d.mts +1 -1
- package/dist/plugins/cms/client/hooks/index.d.ts +1 -1
- package/dist/plugins/cms/client/index.d.cts +188 -184
- package/dist/plugins/cms/client/index.d.mts +188 -184
- package/dist/plugins/cms/client/index.d.ts +188 -184
- package/dist/plugins/cms/permissions.cjs +46 -0
- package/dist/plugins/cms/permissions.d.cts +42 -0
- package/dist/plugins/cms/permissions.d.mts +42 -0
- package/dist/plugins/cms/permissions.d.ts +42 -0
- package/dist/plugins/cms/permissions.mjs +44 -0
- package/dist/plugins/cms/query-keys.d.cts +4 -4
- package/dist/plugins/cms/query-keys.d.mts +4 -4
- package/dist/plugins/cms/query-keys.d.ts +4 -4
- package/dist/plugins/comments/api/index.cjs +10 -0
- package/dist/plugins/comments/api/index.d.cts +54 -18
- package/dist/plugins/comments/api/index.d.mts +54 -18
- package/dist/plugins/comments/api/index.d.ts +54 -18
- package/dist/plugins/comments/api/index.mjs +3 -0
- package/dist/plugins/comments/client/components/index.d.cts +7 -2
- package/dist/plugins/comments/client/components/index.d.mts +7 -2
- package/dist/plugins/comments/client/components/index.d.ts +7 -2
- package/dist/plugins/comments/client/hooks/index.d.cts +12 -18
- package/dist/plugins/comments/client/hooks/index.d.mts +12 -18
- package/dist/plugins/comments/client/hooks/index.d.ts +12 -18
- package/dist/plugins/comments/client/index.d.cts +96 -114
- package/dist/plugins/comments/client/index.d.mts +96 -114
- package/dist/plugins/comments/client/index.d.ts +96 -114
- package/dist/plugins/comments/permissions.cjs +70 -0
- package/dist/plugins/comments/permissions.d.cts +76 -0
- package/dist/plugins/comments/permissions.d.mts +76 -0
- package/dist/plugins/comments/permissions.d.ts +76 -0
- package/dist/plugins/comments/permissions.mjs +68 -0
- package/dist/plugins/comments/query-keys.cjs +1 -1
- package/dist/plugins/comments/query-keys.d.cts +16 -19
- package/dist/plugins/comments/query-keys.d.mts +16 -19
- package/dist/plugins/comments/query-keys.d.ts +16 -19
- package/dist/plugins/comments/query-keys.mjs +1 -1
- package/dist/plugins/form-builder/api/index.cjs +8 -0
- package/dist/plugins/form-builder/api/index.d.cts +115 -4
- package/dist/plugins/form-builder/api/index.d.mts +115 -4
- package/dist/plugins/form-builder/api/index.d.ts +115 -4
- package/dist/plugins/form-builder/api/index.mjs +4 -1
- package/dist/plugins/form-builder/client/components/index.d.cts +6 -2
- package/dist/plugins/form-builder/client/components/index.d.mts +6 -2
- package/dist/plugins/form-builder/client/components/index.d.ts +6 -2
- package/dist/plugins/form-builder/client/hooks/index.cjs +2 -0
- package/dist/plugins/form-builder/client/hooks/index.d.cts +34 -8
- package/dist/plugins/form-builder/client/hooks/index.d.mts +34 -8
- package/dist/plugins/form-builder/client/hooks/index.d.ts +34 -8
- package/dist/plugins/form-builder/client/hooks/index.mjs +1 -1
- package/dist/plugins/form-builder/client/index.d.cts +153 -174
- package/dist/plugins/form-builder/client/index.d.mts +153 -174
- package/dist/plugins/form-builder/client/index.d.ts +153 -174
- package/dist/plugins/form-builder/permissions.cjs +95 -0
- package/dist/plugins/form-builder/permissions.d.cts +94 -0
- package/dist/plugins/form-builder/permissions.d.mts +94 -0
- package/dist/plugins/form-builder/permissions.d.ts +94 -0
- package/dist/plugins/form-builder/permissions.mjs +93 -0
- package/dist/plugins/form-builder/query-keys.cjs +11 -4
- package/dist/plugins/form-builder/query-keys.d.cts +38 -12
- package/dist/plugins/form-builder/query-keys.d.mts +38 -12
- package/dist/plugins/form-builder/query-keys.d.ts +38 -12
- package/dist/plugins/form-builder/query-keys.mjs +11 -4
- package/dist/plugins/kanban/api/index.cjs +9 -0
- package/dist/plugins/kanban/api/index.d.cts +137 -5
- package/dist/plugins/kanban/api/index.d.mts +137 -5
- package/dist/plugins/kanban/api/index.d.ts +137 -5
- package/dist/plugins/kanban/api/index.mjs +5 -2
- package/dist/plugins/kanban/client/components/index.d.cts +18 -10
- package/dist/plugins/kanban/client/components/index.d.mts +18 -10
- package/dist/plugins/kanban/client/components/index.d.ts +18 -10
- package/dist/plugins/kanban/client/hooks/index.d.cts +15 -7
- package/dist/plugins/kanban/client/hooks/index.d.mts +15 -7
- package/dist/plugins/kanban/client/hooks/index.d.ts +15 -7
- package/dist/plugins/kanban/client/index.d.cts +32 -28
- package/dist/plugins/kanban/client/index.d.mts +32 -28
- package/dist/plugins/kanban/client/index.d.ts +32 -28
- package/dist/plugins/kanban/permissions.cjs +101 -0
- package/dist/plugins/kanban/permissions.d.cts +109 -0
- package/dist/plugins/kanban/permissions.d.mts +109 -0
- package/dist/plugins/kanban/permissions.d.ts +109 -0
- package/dist/plugins/kanban/permissions.mjs +99 -0
- package/dist/plugins/kanban/query-keys.cjs +14 -15
- package/dist/plugins/kanban/query-keys.d.cts +63 -42
- package/dist/plugins/kanban/query-keys.d.mts +63 -42
- package/dist/plugins/kanban/query-keys.d.ts +63 -42
- package/dist/plugins/kanban/query-keys.mjs +14 -15
- package/dist/plugins/media/api/adapters/local.d.cts +1 -1
- package/dist/plugins/media/api/adapters/local.d.mts +1 -1
- package/dist/plugins/media/api/adapters/local.d.ts +1 -1
- package/dist/plugins/media/api/adapters/s3.d.cts +1 -1
- package/dist/plugins/media/api/adapters/s3.d.mts +1 -1
- package/dist/plugins/media/api/adapters/s3.d.ts +1 -1
- package/dist/plugins/media/api/adapters/vercel-blob.cjs +46 -0
- package/dist/plugins/media/api/adapters/vercel-blob.d.cts +6 -9
- package/dist/plugins/media/api/adapters/vercel-blob.d.mts +6 -9
- package/dist/plugins/media/api/adapters/vercel-blob.d.ts +6 -9
- package/dist/plugins/media/api/adapters/vercel-blob.mjs +46 -0
- package/dist/plugins/media/api/index.cjs +10 -0
- package/dist/plugins/media/api/index.d.cts +93 -6
- package/dist/plugins/media/api/index.d.mts +93 -6
- package/dist/plugins/media/api/index.d.ts +93 -6
- package/dist/plugins/media/api/index.mjs +2 -0
- package/dist/plugins/media/client/components/index.d.cts +1 -1
- package/dist/plugins/media/client/components/index.d.mts +1 -1
- package/dist/plugins/media/client/components/index.d.ts +1 -1
- package/dist/plugins/media/client/hooks/index.d.cts +20 -10
- package/dist/plugins/media/client/hooks/index.d.mts +20 -10
- package/dist/plugins/media/client/hooks/index.d.ts +20 -10
- package/dist/plugins/media/client/index.cjs +1 -0
- package/dist/plugins/media/client/index.d.cts +112 -100
- package/dist/plugins/media/client/index.d.mts +112 -100
- package/dist/plugins/media/client/index.d.ts +112 -100
- package/dist/plugins/media/client/index.mjs +1 -1
- package/dist/plugins/media/permissions.cjs +63 -0
- package/dist/plugins/media/permissions.d.cts +64 -0
- package/dist/plugins/media/permissions.d.mts +64 -0
- package/dist/plugins/media/permissions.d.ts +64 -0
- package/dist/plugins/media/permissions.mjs +61 -0
- package/dist/plugins/media/query-keys.cjs +29 -17
- package/dist/plugins/media/query-keys.d.cts +24 -31
- package/dist/plugins/media/query-keys.d.mts +24 -31
- package/dist/plugins/media/query-keys.d.ts +24 -31
- package/dist/plugins/media/query-keys.mjs +30 -18
- package/dist/plugins/open-api/api/index.d.cts +9 -4
- package/dist/plugins/open-api/api/index.d.mts +9 -4
- package/dist/plugins/open-api/api/index.d.ts +9 -4
- package/dist/plugins/route-docs/client/index.cjs +2 -2
- package/dist/plugins/route-docs/client/index.d.cts +54 -53
- package/dist/plugins/route-docs/client/index.d.mts +54 -53
- package/dist/plugins/route-docs/client/index.d.ts +54 -53
- package/dist/plugins/route-docs/client/index.mjs +2 -1
- package/dist/plugins/ui-builder/client/components/index.d.cts +8 -5
- package/dist/plugins/ui-builder/client/components/index.d.mts +8 -5
- package/dist/plugins/ui-builder/client/components/index.d.ts +8 -5
- package/dist/plugins/ui-builder/client/hooks/index.d.cts +5 -5
- package/dist/plugins/ui-builder/client/hooks/index.d.mts +5 -5
- package/dist/plugins/ui-builder/client/hooks/index.d.ts +5 -5
- package/dist/plugins/ui-builder/client/index.d.cts +151 -199
- package/dist/plugins/ui-builder/client/index.d.mts +151 -199
- package/dist/plugins/ui-builder/client/index.d.ts +151 -199
- package/dist/plugins/ui-builder/index.d.cts +11 -8
- package/dist/plugins/ui-builder/index.d.mts +11 -8
- package/dist/plugins/ui-builder/index.d.ts +11 -8
- package/dist/plugins/ui-builder/query-keys.d.cts +6 -6
- package/dist/plugins/ui-builder/query-keys.d.mts +6 -6
- package/dist/plugins/ui-builder/query-keys.d.ts +6 -6
- package/dist/react-router/index.cjs +2 -0
- package/dist/react-router/index.d.cts +41 -7
- package/dist/react-router/index.d.mts +41 -7
- package/dist/react-router/index.d.ts +41 -7
- package/dist/react-router/index.mjs +1 -0
- package/dist/shared/stack.0O62uXqP.d.ts +613 -0
- package/dist/shared/stack.0y6iTP03.d.ts +533 -0
- package/dist/shared/{stack.CbZenbej.d.cts → stack.1ukVJym7.d.cts} +3 -4
- package/dist/shared/{stack.CbZenbej.d.mts → stack.1ukVJym7.d.mts} +3 -4
- package/dist/shared/{stack.CbZenbej.d.ts → stack.1ukVJym7.d.ts} +3 -4
- package/dist/shared/stack.3Sr6qRtT.d.ts +507 -0
- package/dist/shared/{stack.9BAOaSqE.d.mts → stack.5_zzCejP.d.cts} +16 -14
- package/dist/shared/{stack.9BAOaSqE.d.ts → stack.5_zzCejP.d.mts} +16 -14
- package/dist/shared/{stack.9BAOaSqE.d.cts → stack.5_zzCejP.d.ts} +16 -14
- package/dist/shared/stack.B1UrNoVl.d.mts +533 -0
- package/dist/shared/{stack.B2xi4jj7.d.cts → stack.B1srlBud.d.mts} +2 -2
- package/dist/shared/stack.B3_aDcYL.d.cts +281 -0
- package/dist/shared/stack.B3_aDcYL.d.mts +281 -0
- package/dist/shared/stack.B3_aDcYL.d.ts +281 -0
- package/dist/shared/stack.B5yPgHsp.d.mts +507 -0
- package/dist/shared/stack.B8PG21zX.d.mts +764 -0
- package/dist/shared/stack.BFP_9pRX.d.cts +707 -0
- package/dist/shared/{stack.INBa9-TO.d.cts → stack.BGzgFx3R.d.cts} +5 -5
- package/dist/shared/stack.BJx1ZXrN.d.cts +118 -0
- package/dist/shared/{stack.7b3vsM8_.d.ts → stack.BK9Z2dcL.d.ts} +2 -2
- package/dist/shared/stack.BMHoxAn7.d.mts +707 -0
- package/dist/shared/stack.BMmvEBH_.d.ts +118 -0
- package/dist/shared/stack.BOZRaVpu.d.cts +1184 -0
- package/dist/shared/stack.BPLykw4s.d.ts +436 -0
- package/dist/shared/{stack.aqVZ6PEW.d.mts → stack.BRvqQWGt.d.cts} +40 -1
- package/dist/shared/{stack.aqVZ6PEW.d.cts → stack.BRvqQWGt.d.mts} +40 -1
- package/dist/shared/{stack.aqVZ6PEW.d.ts → stack.BRvqQWGt.d.ts} +40 -1
- package/dist/shared/stack.BSACE667.d.cts +23 -0
- package/dist/shared/stack.BYMentwB.d.cts +47 -0
- package/dist/shared/stack.BYMentwB.d.mts +47 -0
- package/dist/shared/stack.BYMentwB.d.ts +47 -0
- package/dist/shared/stack.Bt8hfw9o.d.ts +707 -0
- package/dist/shared/{stack.D7bewlgt.d.mts → stack.Bu2IPOLi.d.cts} +1 -0
- package/dist/shared/{stack.D7bewlgt.d.ts → stack.Bu2IPOLi.d.mts} +1 -0
- package/dist/shared/{stack.D7bewlgt.d.cts → stack.Bu2IPOLi.d.ts} +1 -0
- package/dist/shared/stack.BuxUQqL8.d.ts +408 -0
- package/dist/shared/stack.BzWGB5MG.d.cts +436 -0
- package/dist/shared/stack.C3bU9w6L.d.ts +351 -0
- package/dist/shared/stack.C4oVW2qK.d.cts +507 -0
- package/dist/shared/stack.CKXzdGiJ.d.cts +3 -0
- package/dist/shared/stack.CKXzdGiJ.d.mts +3 -0
- package/dist/shared/stack.CKXzdGiJ.d.ts +3 -0
- package/dist/shared/{stack.C3GBG8in.d.ts → stack.COrJrztD.d.cts} +1 -1
- package/dist/shared/{stack.C3GBG8in.d.cts → stack.COrJrztD.d.mts} +1 -1
- package/dist/shared/{stack.C3GBG8in.d.mts → stack.COrJrztD.d.ts} +1 -1
- package/dist/shared/stack.CX83YNuS.d.cts +408 -0
- package/dist/shared/stack.Cbd7sD5M.d.mts +118 -0
- package/dist/shared/{stack.B9NtGpAR.d.ts → stack.CcjENrr4.d.cts} +1 -5
- package/dist/shared/stack.CfK5NKlK.d.mts +613 -0
- package/dist/shared/{stack.3di7vQs6.d.mts → stack.CjCSDfWy.d.mts} +5 -5
- package/dist/shared/stack.Cmg7lzzy.d.cts +44 -0
- package/dist/shared/stack.Cmg7lzzy.d.mts +44 -0
- package/dist/shared/stack.Cmg7lzzy.d.ts +44 -0
- package/dist/shared/stack.CpE1mS3p.d.ts +331 -0
- package/dist/shared/stack.CskhFw3z.d.mts +23 -0
- package/dist/shared/stack.CvlC5kqe.d.cts +331 -0
- package/dist/shared/stack.CxKc9evq.d.ts +23 -0
- package/dist/shared/stack.CyalJ0j6.d.ts +764 -0
- package/dist/shared/stack.D6Pg-ufX.d.cts +764 -0
- package/dist/shared/{stack.lkebw2nj.d.mts → stack.DVEjWKCT.d.cts} +19 -5
- package/dist/shared/{stack.lkebw2nj.d.ts → stack.DVEjWKCT.d.mts} +19 -5
- package/dist/shared/{stack.lkebw2nj.d.cts → stack.DVEjWKCT.d.ts} +19 -5
- package/dist/shared/{stack.Cp_6mO5s.d.mts → stack.DbbvHbhn.d.mts} +1 -5
- package/dist/shared/stack.DiuRuzIs.d.cts +613 -0
- package/dist/shared/{stack.BMlLOMED.d.mts → stack.DjGixVx3.d.cts} +6 -2
- package/dist/shared/{stack.BMlLOMED.d.ts → stack.DjGixVx3.d.mts} +6 -2
- package/dist/shared/{stack.BMlLOMED.d.cts → stack.DjGixVx3.d.ts} +6 -2
- package/dist/shared/stack.DlBoNqYu.d.ts +1184 -0
- package/dist/shared/stack.DlCycSM-.d.mts +331 -0
- package/dist/shared/{stack.DycBcTeg.d.mts → stack.DmpPDPxA.d.cts} +2 -2
- package/dist/shared/{stack.CRelKJfH.d.ts → stack.Dpg_JjIo.d.ts} +5 -5
- package/dist/shared/stack.Dvy7FmaA.d.mts +1184 -0
- package/dist/shared/stack.DxHPKr2R.d.mts +436 -0
- package/dist/shared/stack.Egr3RWhA.d.mts +408 -0
- package/dist/shared/stack.Mak7pzIV.d.cts +533 -0
- package/dist/shared/stack.OYT8WU4n.d.mts +351 -0
- package/dist/shared/{stack.CPsYC2-Z.d.cts → stack.fdi94T4S.d.cts} +7 -7
- package/dist/shared/{stack.CPsYC2-Z.d.mts → stack.fdi94T4S.d.mts} +7 -7
- package/dist/shared/{stack.CPsYC2-Z.d.ts → stack.fdi94T4S.d.ts} +7 -7
- package/dist/shared/{stack.Dlgtumru.d.cts → stack.kaCV7vEL.d.ts} +1 -5
- package/dist/shared/stack.v2O65JqF.d.cts +351 -0
- package/dist/tanstack/index.cjs +2 -0
- package/dist/tanstack/index.d.cts +44 -14
- package/dist/tanstack/index.d.mts +44 -14
- package/dist/tanstack/index.d.ts +44 -14
- package/dist/tanstack/index.mjs +1 -0
- package/dist/tanstack/server.cjs +9 -0
- package/dist/tanstack/server.d.cts +15 -0
- package/dist/tanstack/server.d.mts +15 -0
- package/dist/tanstack/server.d.ts +15 -0
- package/dist/tanstack/server.mjs +7 -0
- package/package.json +203 -8
- package/src/__tests__/ai-chat-client-runtime.test.ts +481 -0
- package/src/__tests__/ai-chat-client-runtime.typecheck.tsx +130 -0
- package/src/__tests__/ai-chat-lifecycle-migrations.typecheck.ts +61 -0
- package/src/__tests__/ai-chat-query-keys.test.ts +125 -22
- package/src/__tests__/auth-provider.test.tsx +41 -314
- package/src/__tests__/auth-test-utils.ts +24 -0
- package/src/__tests__/authorization-client.test.tsx +767 -0
- package/src/__tests__/authorization-contraction.test.ts +182 -0
- package/src/__tests__/authorization-remote.test.ts +222 -0
- package/src/__tests__/authorization-server.test.ts +90 -0
- package/src/__tests__/authorization.test.ts +652 -0
- package/src/__tests__/authorization.typecheck.ts +671 -0
- package/src/__tests__/backend-plugin-factories.test.ts +54 -0
- package/src/__tests__/backend-plugin-factories.typecheck.ts +133 -0
- package/src/__tests__/client-plugin-ssr-loaders.test.ts +304 -138
- package/src/__tests__/client-runtime.test.ts +1021 -0
- package/src/__tests__/client-runtime.typecheck.ts +107 -0
- package/src/__tests__/client-stack-test-utils.ts +36 -0
- package/src/__tests__/content-lifecycle-migrations.typecheck.ts +122 -0
- package/src/__tests__/endpoint-inventory.test.ts +768 -0
- package/src/__tests__/entry-factories.test.tsx +104 -4
- package/src/__tests__/form-builder-query-keys.test.ts +32 -0
- package/src/__tests__/i18n-provider.test.tsx +4 -3
- package/src/__tests__/initial-identity-hydration.test.tsx +156 -0
- package/src/__tests__/initial-identity-layouts.test.tsx +204 -0
- package/src/__tests__/kanban-query-keys.test.ts +189 -2
- package/src/__tests__/managed-origin-hydration.browser.test.tsx +163 -0
- package/src/__tests__/media-query-keys.test.ts +91 -17
- package/src/__tests__/notify-provider.test.tsx +3 -2
- package/src/__tests__/package-metadata.test.ts +315 -0
- package/src/__tests__/page-component-overrides.test.tsx +3 -4
- package/src/__tests__/plugin-registration.test.tsx +183 -0
- package/src/__tests__/plugin-registration.typecheck.tsx +139 -0
- package/src/__tests__/plugins.test.tsx +72 -42
- package/src/__tests__/resource-factory.test.tsx +79 -2
- package/src/__tests__/resource-use-form.test.tsx +2 -2
- package/src/__tests__/resource-use-select.test.tsx +2 -4
- package/src/__tests__/router-overrides.test.tsx +20 -8
- package/src/__tests__/sitemap.test.ts +38 -22
- package/src/__tests__/stack-api.test.ts +39 -34
- package/src/__tests__/stack-auth.test.ts +44 -140
- package/src/__tests__/stack-constructors.test.ts +96 -0
- package/src/__tests__/stack-constructors.typecheck.ts +115 -0
- package/src/__tests__/use-list-state.test.tsx +7 -6
- package/src/__tests__/workflow-lifecycle-migrations.typecheck.ts +150 -0
- package/src/api/index.ts +204 -99
- package/src/authorization/client.tsx +310 -0
- package/src/authorization/index.ts +873 -0
- package/src/authorization/json.ts +70 -0
- package/src/authorization/remote.ts +234 -0
- package/src/authorization/server.ts +171 -0
- package/src/client/__tests__/server-origin.test.ts +119 -0
- package/src/client/components/compose.tsx +126 -18
- package/src/client/hooks/index.ts +12 -0
- package/src/client/hooks/use-list-state.ts +7 -13
- package/src/client/index.ts +105 -50
- package/src/client/runtime.ts +414 -0
- package/src/client/server.ts +174 -0
- package/src/context/auth.tsx +205 -154
- package/src/context/index.ts +10 -4
- package/src/context/provider.tsx +96 -57
- package/src/context/router.tsx +7 -0
- package/src/context/site-navigation.ts +52 -0
- package/src/next/index.tsx +2 -0
- package/src/next/layout.tsx +81 -0
- package/src/next/page.tsx +33 -12
- package/src/next/router.tsx +1 -1
- package/src/next/server.ts +5 -0
- package/src/plugin-registration.ts +70 -0
- package/src/plugins/ai-chat/__tests__/authorization.test.ts +2051 -0
- package/src/plugins/ai-chat/__tests__/chat-hooks.test.tsx +147 -0
- package/src/plugins/ai-chat/__tests__/chat-input-authorization.test.tsx +188 -0
- package/src/plugins/ai-chat/__tests__/client-sweep.test.tsx +1506 -34
- package/src/plugins/ai-chat/__tests__/hooks.test.tsx +131 -23
- package/src/plugins/ai-chat/api/getters.ts +2 -2
- package/src/plugins/ai-chat/api/index.ts +6 -1
- package/src/plugins/ai-chat/api/lifecycle-migrations.ts +20 -0
- package/src/plugins/ai-chat/api/operations.ts +1865 -0
- package/src/plugins/ai-chat/api/plugin.ts +78 -1168
- package/src/plugins/ai-chat/api/serializers.ts +30 -0
- package/src/plugins/ai-chat/client/components/chat-input.tsx +228 -129
- package/src/plugins/ai-chat/client/components/chat-interface.tsx +776 -183
- package/src/plugins/ai-chat/client/components/chat-layout.tsx +6 -7
- package/src/plugins/ai-chat/client/components/chat-message.tsx +1 -1
- package/src/plugins/ai-chat/client/components/chat-sidebar.tsx +57 -37
- package/src/plugins/ai-chat/client/components/pages/404-page.tsx +1 -1
- package/src/plugins/ai-chat/client/components/pages/chat-page.internal.tsx +5 -3
- package/src/plugins/ai-chat/client/components/pages/chat-page.tsx +56 -15
- package/src/plugins/ai-chat/client/components/shared/default-error.tsx +1 -1
- package/src/plugins/ai-chat/client/components/tool-call-display.tsx +1 -1
- package/src/plugins/ai-chat/client/hooks/ai-chat-resource.ts +1 -1
- package/src/plugins/ai-chat/client/hooks/chat-hooks.tsx +253 -20
- package/src/plugins/ai-chat/client/index.ts +1 -0
- package/src/plugins/ai-chat/client/navigation.ts +11 -0
- package/src/plugins/ai-chat/client/overrides.ts +47 -11
- package/src/plugins/ai-chat/client/plugin.tsx +208 -111
- package/src/plugins/ai-chat/permissions.ts +89 -0
- package/src/plugins/ai-chat/query-keys.ts +183 -25
- package/src/plugins/ai-chat/types.ts +7 -5
- package/src/plugins/api/create-endpoint.ts +40 -22
- package/src/plugins/api/endpoint-inventory.ts +206 -0
- package/src/plugins/api/index.ts +38 -4
- package/src/plugins/api/operation.ts +600 -0
- package/src/plugins/blog/__tests__/authorization.test.ts +1366 -0
- package/src/plugins/blog/__tests__/client-runtime.browser.test.tsx +257 -0
- package/src/plugins/blog/__tests__/client-runtime.test.ts +283 -0
- package/src/plugins/blog/__tests__/client-runtime.typecheck.tsx +98 -0
- package/src/plugins/blog/__tests__/client-sweep.test.tsx +212 -37
- package/src/plugins/blog/api/getters.ts +3 -3
- package/src/plugins/blog/api/index.ts +2 -0
- package/src/plugins/blog/api/lifecycle-migrations.ts +19 -0
- package/src/plugins/blog/api/mutations.ts +26 -5
- package/src/plugins/blog/api/operations.ts +727 -0
- package/src/plugins/blog/api/plugin.ts +99 -504
- package/src/plugins/blog/client/components/forms/image-field.tsx +2 -1
- package/src/plugins/blog/client/components/forms/markdown-editor-with-overrides.tsx +2 -1
- package/src/plugins/blog/client/components/forms/post-forms.tsx +61 -33
- package/src/plugins/blog/client/components/pages/404-page.tsx +3 -1
- package/src/plugins/blog/client/components/pages/edit-post-page.internal.tsx +2 -1
- package/src/plugins/blog/client/components/pages/edit-post-page.tsx +28 -5
- package/src/plugins/blog/client/components/pages/home-page.internal.tsx +2 -1
- package/src/plugins/blog/client/components/pages/home-page.tsx +7 -4
- package/src/plugins/blog/client/components/pages/new-post-page.internal.tsx +2 -1
- package/src/plugins/blog/client/components/pages/new-post-page.tsx +5 -2
- package/src/plugins/blog/client/components/pages/post-page.internal.tsx +2 -1
- package/src/plugins/blog/client/components/pages/post-page.tsx +38 -4
- package/src/plugins/blog/client/components/pages/tag-page.internal.tsx +2 -1
- package/src/plugins/blog/client/components/pages/tag-page.tsx +5 -1
- package/src/plugins/blog/client/components/shared/collapsible-tag-list.tsx +2 -1
- package/src/plugins/blog/client/components/shared/default-error.tsx +3 -1
- package/src/plugins/blog/client/components/shared/on-this-page.tsx +5 -2
- package/src/plugins/blog/client/components/shared/page-wrapper.tsx +2 -1
- package/src/plugins/blog/client/components/shared/post-card.tsx +2 -1
- package/src/plugins/blog/client/components/shared/posts-list.tsx +2 -1
- package/src/plugins/blog/client/components/shared/recent-posts-carousel.tsx +2 -1
- package/src/plugins/blog/client/components/shared/search-input.tsx +1 -1
- package/src/plugins/blog/client/constants.ts +2 -0
- package/src/plugins/blog/client/hooks/blog-resource.ts +2 -1
- package/src/plugins/blog/client/overrides.ts +1 -6
- package/src/plugins/blog/client/plugin.tsx +145 -129
- package/src/plugins/blog/permissions.ts +44 -0
- package/src/plugins/client/index.ts +108 -7
- package/src/plugins/client/resource/hooks.tsx +41 -18
- package/src/plugins/client/resource/internal.ts +77 -61
- package/src/plugins/client/resource/queries.ts +3 -4
- package/src/plugins/client/resource/use-form.ts +23 -20
- package/src/plugins/client/resource/use-select.ts +40 -34
- package/src/plugins/cms/__tests__/authorization.test.ts +2188 -0
- package/src/plugins/cms/__tests__/client-runtime.browser.test.tsx +245 -0
- package/src/plugins/cms/__tests__/client-runtime.test.ts +320 -0
- package/src/plugins/cms/__tests__/client-runtime.typecheck.tsx +208 -0
- package/src/plugins/cms/__tests__/client-sweep.test.tsx +202 -50
- package/src/plugins/cms/api/getters.ts +4 -4
- package/src/plugins/cms/api/index.ts +20 -0
- package/src/plugins/cms/api/lifecycle-migrations.ts +15 -0
- package/src/plugins/cms/api/mutations.ts +2 -2
- package/src/plugins/cms/api/operations.ts +2218 -0
- package/src/plugins/cms/api/plugin.ts +169 -1047
- package/src/plugins/cms/api/relations.ts +3 -1
- package/src/plugins/cms/client/components/forms/content-form.tsx +2 -1
- package/src/plugins/cms/client/components/forms/file-upload.tsx +3 -1
- package/src/plugins/cms/client/components/forms/relation-field.tsx +3 -1
- package/src/plugins/cms/client/components/inverse-relations-panel.tsx +29 -17
- package/src/plugins/cms/client/components/pages/404-page.tsx +7 -5
- package/src/plugins/cms/client/components/pages/content-editor-page.internal.tsx +19 -10
- package/src/plugins/cms/client/components/pages/content-editor-page.tsx +50 -12
- package/src/plugins/cms/client/components/pages/content-list-page.internal.tsx +48 -34
- package/src/plugins/cms/client/components/pages/content-list-page.tsx +8 -1
- package/src/plugins/cms/client/components/pages/dashboard-page.internal.tsx +15 -8
- package/src/plugins/cms/client/components/pages/dashboard-page.tsx +5 -1
- package/src/plugins/cms/client/components/shared/page-wrapper.tsx +2 -1
- package/src/plugins/cms/client/constants.ts +2 -0
- package/src/plugins/cms/client/hooks/cms-resource.ts +2 -1
- package/src/plugins/cms/client/index.ts +6 -1
- package/src/plugins/cms/client/overrides.ts +46 -6
- package/src/plugins/cms/client/plugin.tsx +135 -80
- package/src/plugins/cms/permissions.ts +43 -0
- package/src/plugins/cms/types.ts +174 -46
- package/src/plugins/comments/__tests__/authorization.test.ts +1570 -0
- package/src/plugins/comments/__tests__/client-runtime.browser.test.tsx +207 -0
- package/src/plugins/comments/__tests__/client-runtime.test.ts +224 -0
- package/src/plugins/comments/__tests__/client-runtime.typecheck.tsx +85 -0
- package/src/plugins/comments/__tests__/client-sweep.test.tsx +465 -79
- package/src/plugins/comments/api/getters.ts +19 -3
- package/src/plugins/comments/api/index.ts +2 -6
- package/src/plugins/comments/api/lifecycle-migrations.ts +20 -0
- package/src/plugins/comments/api/mutations.ts +261 -88
- package/src/plugins/comments/api/operations.ts +742 -0
- package/src/plugins/comments/api/plugin.ts +76 -548
- package/src/plugins/comments/client/components/comment-count.tsx +38 -5
- package/src/plugins/comments/client/components/comment-thread.tsx +154 -112
- package/src/plugins/comments/client/components/pages/moderation-page.internal.tsx +144 -78
- package/src/plugins/comments/client/components/pages/moderation-page.tsx +18 -2
- package/src/plugins/comments/client/components/pages/moderation-state.ts +13 -0
- package/src/plugins/comments/client/components/pages/my-comments-page.internal.tsx +38 -30
- package/src/plugins/comments/client/components/pages/my-comments-page.tsx +3 -1
- package/src/plugins/comments/client/components/pages/resource-comments-page.internal.tsx +29 -30
- package/src/plugins/comments/client/components/pages/resource-comments-page.tsx +10 -1
- package/src/plugins/comments/client/components/shared/page-wrapper.tsx +2 -1
- package/src/plugins/comments/client/components/shared/pagination.tsx +2 -1
- package/src/plugins/comments/client/constants.ts +2 -0
- package/src/plugins/comments/client/hooks/use-comments.tsx +430 -421
- package/src/plugins/comments/client/localization/comments-thread.ts +1 -0
- package/src/plugins/comments/client/plugin.tsx +113 -72
- package/src/plugins/comments/permissions.ts +68 -0
- package/src/plugins/comments/query-keys.ts +9 -10
- package/src/plugins/comments/schemas.ts +7 -8
- package/src/plugins/form-builder/__tests__/authorization.test.ts +1600 -0
- package/src/plugins/form-builder/__tests__/client-runtime.browser.test.tsx +255 -0
- package/src/plugins/form-builder/__tests__/client-runtime.test.ts +132 -0
- package/src/plugins/form-builder/__tests__/client-runtime.typecheck.tsx +77 -0
- package/src/plugins/form-builder/__tests__/client-sweep.test.tsx +350 -54
- package/src/plugins/form-builder/__tests__/form-renderer-authorization.test.tsx +162 -0
- package/src/plugins/form-builder/api/getters.ts +21 -5
- package/src/plugins/form-builder/api/index.ts +31 -0
- package/src/plugins/form-builder/api/lifecycle-migrations.ts +17 -0
- package/src/plugins/form-builder/api/operations.ts +1493 -0
- package/src/plugins/form-builder/api/plugin.ts +125 -632
- package/src/plugins/form-builder/api/query-key-defs.ts +7 -0
- package/src/plugins/form-builder/api/serializers.ts +1 -0
- package/src/plugins/form-builder/client/components/forms/form-renderer.tsx +49 -19
- package/src/plugins/form-builder/client/components/pages/404-page.tsx +9 -9
- package/src/plugins/form-builder/client/components/pages/form-builder-page.internal.tsx +54 -30
- package/src/plugins/form-builder/client/components/pages/form-builder-page.tsx +42 -9
- package/src/plugins/form-builder/client/components/pages/form-list-page.internal.tsx +46 -34
- package/src/plugins/form-builder/client/components/pages/form-list-page.tsx +6 -2
- package/src/plugins/form-builder/client/components/pages/submissions-page.internal.tsx +98 -64
- package/src/plugins/form-builder/client/components/pages/submissions-page.tsx +29 -9
- package/src/plugins/form-builder/client/components/shared/page-wrapper.tsx +2 -1
- package/src/plugins/form-builder/client/constants.ts +2 -0
- package/src/plugins/form-builder/client/hooks/form-builder-hooks.tsx +68 -4
- package/src/plugins/form-builder/client/hooks/form-builder-resource.ts +2 -1
- package/src/plugins/form-builder/client/hooks/index.tsx +1 -0
- package/src/plugins/form-builder/client/overrides.ts +1 -6
- package/src/plugins/form-builder/client/plugin.tsx +128 -96
- package/src/plugins/form-builder/permissions.ts +94 -0
- package/src/plugins/form-builder/query-keys.ts +28 -3
- package/src/plugins/form-builder/schemas.ts +9 -1
- package/src/plugins/form-builder/types.ts +173 -41
- package/src/plugins/kanban/__tests__/authorization.test.ts +1382 -0
- package/src/plugins/kanban/__tests__/client-runtime.browser.test.tsx +302 -0
- package/src/plugins/kanban/__tests__/client-runtime.test.ts +130 -0
- package/src/plugins/kanban/__tests__/client-runtime.typecheck.tsx +81 -0
- package/src/plugins/kanban/__tests__/client-sweep.test.tsx +418 -33
- package/src/plugins/kanban/__tests__/identity-partition.test.tsx +306 -0
- package/src/plugins/kanban/api/getters.ts +65 -50
- package/src/plugins/kanban/api/index.ts +55 -4
- package/src/plugins/kanban/api/lifecycle-migrations.ts +25 -0
- package/src/plugins/kanban/api/mutations.ts +3 -3
- package/src/plugins/kanban/api/operations.ts +2065 -0
- package/src/plugins/kanban/api/plugin.ts +83 -1013
- package/src/plugins/kanban/api/serializers.ts +26 -0
- package/src/plugins/kanban/client/components/forms/board-form.tsx +3 -1
- package/src/plugins/kanban/client/components/forms/column-form.tsx +3 -1
- package/src/plugins/kanban/client/components/forms/task-form.tsx +92 -74
- package/src/plugins/kanban/client/components/pages/404-page.tsx +6 -9
- package/src/plugins/kanban/client/components/pages/board-page.internal.tsx +57 -74
- package/src/plugins/kanban/client/components/pages/board-page.tsx +31 -7
- package/src/plugins/kanban/client/components/pages/boards-list-page.internal.tsx +54 -45
- package/src/plugins/kanban/client/components/pages/boards-list-page.tsx +2 -1
- package/src/plugins/kanban/client/components/pages/new-board-page.internal.tsx +8 -12
- package/src/plugins/kanban/client/components/pages/new-board-page.tsx +2 -1
- package/src/plugins/kanban/client/components/shared/column-content.tsx +61 -48
- package/src/plugins/kanban/client/components/shared/default-error.tsx +3 -1
- package/src/plugins/kanban/client/components/shared/kanban-board.tsx +6 -6
- package/src/plugins/kanban/client/components/shared/permission-access-any.tsx +32 -0
- package/src/plugins/kanban/client/components/shared/task-card.tsx +64 -20
- package/src/plugins/kanban/client/components/shared/user-avatar.tsx +3 -1
- package/src/plugins/kanban/client/constants.ts +2 -0
- package/src/plugins/kanban/client/hooks/kanban-hooks.tsx +55 -10
- package/src/plugins/kanban/client/hooks/kanban-resource.ts +2 -1
- package/src/plugins/kanban/client/overrides.ts +0 -5
- package/src/plugins/kanban/client/plugin.tsx +201 -113
- package/src/plugins/kanban/permissions.ts +100 -0
- package/src/plugins/kanban/query-keys.ts +61 -21
- package/src/plugins/kanban/schemas.ts +44 -18
- package/src/plugins/kanban/types.ts +381 -1
- package/src/plugins/media/__tests__/authorization.test.ts +1769 -0
- package/src/plugins/media/__tests__/client-runtime.browser.test.tsx +975 -0
- package/src/plugins/media/__tests__/client-runtime.test.ts +539 -0
- package/src/plugins/media/__tests__/client-runtime.typecheck.tsx +135 -0
- package/src/plugins/media/__tests__/client-sweep.test.tsx +292 -24
- package/src/plugins/media/__tests__/identity-partition.test.tsx +741 -0
- package/src/plugins/media/__tests__/plugin.test.ts +68 -28
- package/src/plugins/media/__tests__/query-key-defs.test.ts +32 -2
- package/src/plugins/media/api/adapters/vercel-blob.ts +84 -8
- package/src/plugins/media/api/getters.ts +6 -6
- package/src/plugins/media/api/index.ts +3 -0
- package/src/plugins/media/api/lifecycle-migrations.ts +11 -0
- package/src/plugins/media/api/mutations.ts +19 -13
- package/src/plugins/media/api/operations.ts +1873 -0
- package/src/plugins/media/api/plugin.ts +211 -899
- package/src/plugins/media/api/query-key-defs.ts +66 -4
- package/src/plugins/media/api/serializers.ts +4 -2
- package/src/plugins/media/api/storage-adapter.ts +22 -4
- package/src/plugins/media/asset-url.ts +14 -0
- package/src/plugins/media/client/components/media-picker/asset-card.tsx +105 -98
- package/src/plugins/media/client/components/media-picker/folder-tree.tsx +82 -60
- package/src/plugins/media/client/components/media-picker/index.tsx +235 -171
- package/src/plugins/media/client/components/media-picker/upload-tab.tsx +2 -10
- package/src/plugins/media/client/components/media-picker/url-tab.tsx +1 -8
- package/src/plugins/media/client/components/pages/library-page.internal.tsx +103 -82
- package/src/plugins/media/client/components/pages/library-page.tsx +4 -2
- package/src/plugins/media/client/components/upload-permission-check.tsx +75 -0
- package/src/plugins/media/client/constants.ts +2 -0
- package/src/plugins/media/client/hooks/media-resource.ts +2 -1
- package/src/plugins/media/client/hooks/use-media.tsx +292 -49
- package/src/plugins/media/client/index.ts +16 -3
- package/src/plugins/media/client/overrides.ts +6 -17
- package/src/plugins/media/client/plugin.tsx +188 -123
- package/src/plugins/media/client/upload.ts +170 -53
- package/src/plugins/media/db.ts +8 -0
- package/src/plugins/media/permissions.ts +61 -0
- package/src/plugins/media/query-keys.ts +63 -19
- package/src/plugins/media/types.ts +8 -2
- package/src/plugins/open-api/__tests__/route-introspection.test.ts +277 -0
- package/src/plugins/open-api/api/generator.ts +49 -8
- package/src/plugins/open-api/api/plugin.ts +36 -14
- package/src/plugins/route-docs/client/components/pages/docs-page.tsx +63 -23
- package/src/plugins/route-docs/client/constants.ts +2 -0
- package/src/plugins/route-docs/client/hooks.ts +23 -13
- package/src/plugins/route-docs/client/index.ts +7 -1
- package/src/plugins/route-docs/client/plugin.tsx +222 -145
- package/src/plugins/route-docs/client/schema.ts +31 -0
- package/src/plugins/route-docs/generator.ts +9 -5
- package/src/plugins/ui-builder/__tests__/client-sweep.test.tsx +427 -48
- package/src/plugins/ui-builder/client/components/page-renderer.tsx +58 -16
- package/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.tsx +47 -26
- package/src/plugins/ui-builder/client/components/pages/page-builder-page.tsx +43 -8
- package/src/plugins/ui-builder/client/components/pages/page-list-page.internal.tsx +38 -19
- package/src/plugins/ui-builder/client/components/pages/page-list-page.tsx +8 -2
- package/src/plugins/ui-builder/client/components/shared/default-error.tsx +2 -1
- package/src/plugins/ui-builder/client/components/shared/page-wrapper.tsx +2 -1
- package/src/plugins/ui-builder/client/constants.ts +2 -0
- package/src/plugins/ui-builder/client/hooks/ui-builder-resource.ts +2 -1
- package/src/plugins/ui-builder/client/index.ts +4 -1
- package/src/plugins/ui-builder/client/overrides.ts +16 -21
- package/src/plugins/ui-builder/client/plugin.tsx +119 -66
- package/src/plugins/ui-builder/client/registry.ts +3 -5
- package/src/plugins/ui-builder/types.ts +7 -4
- package/src/plugins/utils.ts +5 -1
- package/src/react-router/index.tsx +6 -0
- package/src/react-router/layout.ts +43 -0
- package/src/react-router/page.tsx +46 -17
- package/src/react-router/router.tsx +1 -1
- package/src/shared/auth-types.ts +19 -70
- package/src/shared/entry-factories.ts +12 -3
- package/src/shared/initial-identity.ts +73 -0
- package/src/shared/list-state.ts +12 -0
- package/src/shared/types.ts +1 -0
- package/src/tanstack/index.tsx +7 -0
- package/src/tanstack/layout.ts +36 -0
- package/src/tanstack/page.tsx +35 -13
- package/src/tanstack/router.tsx +1 -1
- package/src/tanstack/server.ts +18 -0
- package/src/types.ts +557 -65
- package/dist/shared/stack.80-y2TTR.d.mts +0 -840
- package/dist/shared/stack.B-hEIoUw.d.ts +0 -406
- package/dist/shared/stack.B8vdOMnQ.d.cts +0 -329
- package/dist/shared/stack.BISAZ5LX.d.mts +0 -492
- package/dist/shared/stack.BL5PvShn.d.mts +0 -193
- package/dist/shared/stack.Be1QIHEn.d.cts +0 -23
- package/dist/shared/stack.Be1QIHEn.d.mts +0 -23
- package/dist/shared/stack.Be1QIHEn.d.ts +0 -23
- package/dist/shared/stack.BjvOk_Bs.d.cts +0 -492
- package/dist/shared/stack.Bk5UB_BT.d.ts +0 -840
- package/dist/shared/stack.BozPgbrZ.d.cts +0 -201
- package/dist/shared/stack.BozPgbrZ.d.mts +0 -201
- package/dist/shared/stack.BozPgbrZ.d.ts +0 -201
- package/dist/shared/stack.BqTR6qi2.d.ts +0 -193
- package/dist/shared/stack.BvxHSZYT.d.cts +0 -406
- package/dist/shared/stack.C1ATQ3pd.d.ts +0 -416
- package/dist/shared/stack.C4_gEENS.d.cts +0 -97
- package/dist/shared/stack.C4_gEENS.d.mts +0 -97
- package/dist/shared/stack.C4_gEENS.d.ts +0 -97
- package/dist/shared/stack.C5Y5lViI.d.cts +0 -461
- package/dist/shared/stack.C8SwdUz8.d.ts +0 -461
- package/dist/shared/stack.CBsp9rDM.d.cts +0 -193
- package/dist/shared/stack.CMbX8Q5C.d.ts +0 -560
- package/dist/shared/stack.Cf-DbL1A.d.ts +0 -329
- package/dist/shared/stack.DHTvwoNG.d.mts +0 -329
- package/dist/shared/stack.DJaKVY7v.d.cts +0 -76
- package/dist/shared/stack.DJaKVY7v.d.mts +0 -76
- package/dist/shared/stack.DJaKVY7v.d.ts +0 -76
- package/dist/shared/stack.DKZMaVr6.d.cts +0 -416
- package/dist/shared/stack.DQq8DEIv.d.mts +0 -461
- package/dist/shared/stack.Dd-8shBE.d.ts +0 -492
- package/dist/shared/stack.Dj04W2c3.d.mts +0 -560
- package/dist/shared/stack.DrUBX-QE.d.cts +0 -34
- package/dist/shared/stack.DrUBX-QE.d.mts +0 -34
- package/dist/shared/stack.DrUBX-QE.d.ts +0 -34
- package/dist/shared/stack.H5B8miAV.d.cts +0 -840
- package/dist/shared/stack.aXdBOJAR.d.cts +0 -173
- package/dist/shared/stack.aXdBOJAR.d.mts +0 -173
- package/dist/shared/stack.aXdBOJAR.d.ts +0 -173
- package/dist/shared/stack.eq5eg1yt.d.cts +0 -560
- package/dist/shared/stack.f8Vke-eH.d.mts +0 -406
- package/dist/shared/stack.oBokjN_J.d.mts +0 -416
- package/dist/shared/{stack.B0muOwUF.d.cts → stack.Csi-4Mgz.d.cts} +8 -8
- package/dist/shared/{stack.B0muOwUF.d.mts → stack.Csi-4Mgz.d.mts} +8 -8
- package/dist/shared/{stack.B0muOwUF.d.ts → stack.Csi-4Mgz.d.ts} +8 -8
|
@@ -0,0 +1,1552 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const node_async_hooks = require('node:async_hooks');
|
|
4
|
+
const api = require('@btst/stack/plugins/api');
|
|
5
|
+
const z = require('zod');
|
|
6
|
+
const plugins_kanban_permissions = require('../../../../../../plugins/kanban/permissions.cjs');
|
|
7
|
+
const schemas = require('../schemas.cjs');
|
|
8
|
+
const utils = require('../utils.cjs');
|
|
9
|
+
const getters = require('./getters.cjs');
|
|
10
|
+
const serializers = require('./serializers.cjs');
|
|
11
|
+
|
|
12
|
+
const BoardIdOperationInputSchema = z.z.object({ id: z.z.string() });
|
|
13
|
+
const UpdateBoardOperationInputSchema = z.z.object({
|
|
14
|
+
id: z.z.string(),
|
|
15
|
+
data: schemas.updateBoardSchema.omit({ id: true })
|
|
16
|
+
});
|
|
17
|
+
const ColumnIdOperationInputSchema = z.z.object({ id: z.z.string() });
|
|
18
|
+
const UpdateColumnOperationInputSchema = z.z.object({
|
|
19
|
+
id: z.z.string(),
|
|
20
|
+
data: schemas.updateColumnSchema.omit({ id: true }).superRefine((data, context) => {
|
|
21
|
+
if (Object.hasOwn(data, "order") && data.order === void 0) {
|
|
22
|
+
context.addIssue({
|
|
23
|
+
code: "custom",
|
|
24
|
+
path: ["order"],
|
|
25
|
+
message: "Order must be a number when provided."
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
const TaskIdOperationInputSchema = z.z.object({ id: z.z.string() });
|
|
31
|
+
const UpdateTaskOperationInputSchema = z.z.object({
|
|
32
|
+
id: z.z.string(),
|
|
33
|
+
data: schemas.updateTaskSchema.omit({ id: true })
|
|
34
|
+
});
|
|
35
|
+
class KanbanOperationError extends api.OperationHttpError {
|
|
36
|
+
constructor(statusCode, message, code) {
|
|
37
|
+
super(statusCode, message, code);
|
|
38
|
+
this.name = "KanbanOperationError";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function boardSnapshot(board) {
|
|
42
|
+
return {
|
|
43
|
+
id: board.id,
|
|
44
|
+
...board.ownerId ? { ownerId: board.ownerId } : {},
|
|
45
|
+
...board.organizationId ? { organizationId: board.organizationId } : {},
|
|
46
|
+
updatedAt: board.updatedAt
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function columnSnapshot(column) {
|
|
50
|
+
return {
|
|
51
|
+
id: column.id,
|
|
52
|
+
boardId: column.boardId,
|
|
53
|
+
updatedAt: column.updatedAt
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function taskSnapshot(task) {
|
|
57
|
+
return {
|
|
58
|
+
id: task.id,
|
|
59
|
+
columnId: task.columnId,
|
|
60
|
+
...task.assigneeId ? { assigneeId: task.assigneeId } : {},
|
|
61
|
+
isArchived: task.isArchived,
|
|
62
|
+
updatedAt: task.updatedAt
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function sameDate(left, right) {
|
|
66
|
+
return left.getTime() === right.getTime();
|
|
67
|
+
}
|
|
68
|
+
function sameBoard(board, expected) {
|
|
69
|
+
return board !== null && board.id === expected.id && (board.ownerId || void 0) === expected.ownerId && (board.organizationId || void 0) === expected.organizationId && sameDate(board.updatedAt, expected.updatedAt);
|
|
70
|
+
}
|
|
71
|
+
function sameColumn(column, expected) {
|
|
72
|
+
return column !== null && column.id === expected.id && column.boardId === expected.boardId && sameDate(column.updatedAt, expected.updatedAt);
|
|
73
|
+
}
|
|
74
|
+
function sameTask(task, expected) {
|
|
75
|
+
return task !== null && task.id === expected.id && task.columnId === expected.columnId && (task.assigneeId || void 0) === expected.assigneeId && task.isArchived === expected.isArchived && sameDate(task.updatedAt, expected.updatedAt);
|
|
76
|
+
}
|
|
77
|
+
function sameColumnSnapshots(left, right) {
|
|
78
|
+
return left.id === right.id && left.boardId === right.boardId && sameDate(left.updatedAt, right.updatedAt);
|
|
79
|
+
}
|
|
80
|
+
function sameTaskSnapshots(left, right) {
|
|
81
|
+
return left.id === right.id && left.columnId === right.columnId && left.assigneeId === right.assigneeId && left.isArchived === right.isArchived && sameDate(left.updatedAt, right.updatedAt);
|
|
82
|
+
}
|
|
83
|
+
function sameSnapshotSet(current, expected, equal) {
|
|
84
|
+
if (current.length !== expected.length) return false;
|
|
85
|
+
const byId = new Map(current.map((value) => [value.id, value]));
|
|
86
|
+
return expected.every((snapshot) => {
|
|
87
|
+
const value = byId.get(snapshot.id);
|
|
88
|
+
return value !== void 0 && equal(value, snapshot);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function nextSnapshotDate(previous) {
|
|
92
|
+
return new Date(Math.max(Date.now(), previous.getTime() + 1));
|
|
93
|
+
}
|
|
94
|
+
const AFFECTED_ROW_KEYS = [
|
|
95
|
+
"rowCount",
|
|
96
|
+
"affectedRows",
|
|
97
|
+
"rowsAffected",
|
|
98
|
+
"changes",
|
|
99
|
+
"numUpdatedRows"
|
|
100
|
+
];
|
|
101
|
+
function hasPositiveCount(value) {
|
|
102
|
+
if (typeof value === "number") return Number.isFinite(value) && value > 0;
|
|
103
|
+
if (typeof value === "bigint") return value > 0n;
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
function didAffectRow(result, expectedId) {
|
|
107
|
+
if (typeof result === "number" || typeof result === "bigint") {
|
|
108
|
+
return hasPositiveCount(result);
|
|
109
|
+
}
|
|
110
|
+
if (!result || typeof result !== "object") return false;
|
|
111
|
+
const record = result;
|
|
112
|
+
if ("count" in record) return hasPositiveCount(record.count);
|
|
113
|
+
if (Array.isArray(result)) {
|
|
114
|
+
return result.length > 0 && didAffectRow(result[0], expectedId);
|
|
115
|
+
}
|
|
116
|
+
for (const key of AFFECTED_ROW_KEYS) {
|
|
117
|
+
if (key in record) return hasPositiveCount(record[key]);
|
|
118
|
+
}
|
|
119
|
+
if ("meta" in record) {
|
|
120
|
+
const meta = record.meta;
|
|
121
|
+
return Boolean(
|
|
122
|
+
meta && typeof meta === "object" && "changes" in meta && hasPositiveCount(meta.changes)
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
return record.id === expectedId;
|
|
126
|
+
}
|
|
127
|
+
const memoryRollbackMarkers = /* @__PURE__ */ new WeakMap();
|
|
128
|
+
function markMemoryRollback(adapter, error) {
|
|
129
|
+
memoryRollbackMarkers.get(adapter)?.(error);
|
|
130
|
+
}
|
|
131
|
+
function serializeMemoryOperations(adapter) {
|
|
132
|
+
if (adapter.id !== "memory" || memoryRollbackMarkers.has(adapter)) {
|
|
133
|
+
return adapter;
|
|
134
|
+
}
|
|
135
|
+
const source = { ...adapter };
|
|
136
|
+
const lockContext = new node_async_hooks.AsyncLocalStorage();
|
|
137
|
+
let tail = Promise.resolve();
|
|
138
|
+
let activeOwner;
|
|
139
|
+
const withLock = async (run) => {
|
|
140
|
+
const inherited = lockContext.getStore();
|
|
141
|
+
if (inherited && inherited.owner === activeOwner) {
|
|
142
|
+
return run(inherited.adapter);
|
|
143
|
+
}
|
|
144
|
+
let release = () => {
|
|
145
|
+
};
|
|
146
|
+
const previous = tail;
|
|
147
|
+
tail = new Promise((resolve) => {
|
|
148
|
+
release = resolve;
|
|
149
|
+
});
|
|
150
|
+
await previous;
|
|
151
|
+
const owner = {};
|
|
152
|
+
activeOwner = owner;
|
|
153
|
+
try {
|
|
154
|
+
return await lockContext.run(
|
|
155
|
+
{ owner, adapter: source },
|
|
156
|
+
() => run(source)
|
|
157
|
+
);
|
|
158
|
+
} finally {
|
|
159
|
+
if (activeOwner === owner) activeOwner = void 0;
|
|
160
|
+
release();
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const serialized = {
|
|
164
|
+
...source,
|
|
165
|
+
create: ((input) => withLock((active) => active.create(input))),
|
|
166
|
+
findOne: ((input) => withLock((active) => active.findOne(input))),
|
|
167
|
+
findMany: ((input) => withLock((active) => active.findMany(input))),
|
|
168
|
+
count: (input) => withLock((active) => active.count(input)),
|
|
169
|
+
update: ((input) => withLock((active) => active.update(input))),
|
|
170
|
+
updateMany: (input) => withLock((active) => active.updateMany(input)),
|
|
171
|
+
delete: ((input) => withLock((active) => active.delete(input))),
|
|
172
|
+
deleteMany: (input) => withLock((active) => active.deleteMany(input)),
|
|
173
|
+
consumeOne: ((input) => withLock((active) => active.consumeOne(input))),
|
|
174
|
+
transaction: ((callback) => withLock((active) => {
|
|
175
|
+
const context = lockContext.getStore();
|
|
176
|
+
if (!context) throw new TypeError("Missing memory lock context.");
|
|
177
|
+
if (context.inTransaction) {
|
|
178
|
+
return callback(active).catch((error) => {
|
|
179
|
+
context.rollbackOnly = true;
|
|
180
|
+
context.rollbackError = error;
|
|
181
|
+
throw error;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (!active.transaction) {
|
|
185
|
+
throw new TypeError("Missing memory transaction adapter.");
|
|
186
|
+
}
|
|
187
|
+
return active.transaction(
|
|
188
|
+
(tx) => lockContext.run(
|
|
189
|
+
{ owner: context.owner, adapter: tx, inTransaction: true },
|
|
190
|
+
async () => {
|
|
191
|
+
const transactionContext = lockContext.getStore();
|
|
192
|
+
const result = await callback(tx);
|
|
193
|
+
if (transactionContext?.rollbackOnly) {
|
|
194
|
+
throw transactionContext.rollbackError;
|
|
195
|
+
}
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
198
|
+
)
|
|
199
|
+
);
|
|
200
|
+
}))
|
|
201
|
+
};
|
|
202
|
+
memoryRollbackMarkers.set(adapter, (error) => {
|
|
203
|
+
const context = lockContext.getStore();
|
|
204
|
+
if (!context || context.owner !== activeOwner || !context.inTransaction) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
context.rollbackOnly = true;
|
|
208
|
+
context.rollbackError = error;
|
|
209
|
+
});
|
|
210
|
+
Object.assign(adapter, serialized);
|
|
211
|
+
return adapter;
|
|
212
|
+
}
|
|
213
|
+
function requireAtomicTransactions(adapter) {
|
|
214
|
+
if (adapter.id !== "memory" && typeof adapter.options?.adapterConfig.transaction !== "function") {
|
|
215
|
+
throw new KanbanOperationError(
|
|
216
|
+
500,
|
|
217
|
+
"Kanban writes require an adapter with isolated transaction support.",
|
|
218
|
+
"ATOMIC_TRANSACTION_REQUIRED"
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function boardWhere(snapshot) {
|
|
223
|
+
return [
|
|
224
|
+
{ field: "id", value: snapshot.id, operator: "eq" },
|
|
225
|
+
{
|
|
226
|
+
field: "ownerId",
|
|
227
|
+
value: snapshot.ownerId ?? null,
|
|
228
|
+
operator: "eq"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
field: "organizationId",
|
|
232
|
+
value: snapshot.organizationId ?? null,
|
|
233
|
+
operator: "eq"
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
field: "updatedAt",
|
|
237
|
+
value: snapshot.updatedAt,
|
|
238
|
+
operator: "eq"
|
|
239
|
+
}
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
function columnWhere(snapshot) {
|
|
243
|
+
return [
|
|
244
|
+
{ field: "id", value: snapshot.id, operator: "eq" },
|
|
245
|
+
{ field: "boardId", value: snapshot.boardId, operator: "eq" },
|
|
246
|
+
{
|
|
247
|
+
field: "updatedAt",
|
|
248
|
+
value: snapshot.updatedAt,
|
|
249
|
+
operator: "eq"
|
|
250
|
+
}
|
|
251
|
+
];
|
|
252
|
+
}
|
|
253
|
+
function taskWhere(snapshot) {
|
|
254
|
+
return [
|
|
255
|
+
{ field: "id", value: snapshot.id, operator: "eq" },
|
|
256
|
+
{ field: "columnId", value: snapshot.columnId, operator: "eq" },
|
|
257
|
+
{
|
|
258
|
+
field: "assigneeId",
|
|
259
|
+
value: snapshot.assigneeId ?? null,
|
|
260
|
+
operator: "eq"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
field: "isArchived",
|
|
264
|
+
value: snapshot.isArchived,
|
|
265
|
+
operator: "eq"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
field: "updatedAt",
|
|
269
|
+
value: snapshot.updatedAt,
|
|
270
|
+
operator: "eq"
|
|
271
|
+
}
|
|
272
|
+
];
|
|
273
|
+
}
|
|
274
|
+
async function claimSnapshot(adapter, model, snapshot) {
|
|
275
|
+
const claimedAt = nextSnapshotDate(snapshot.updatedAt);
|
|
276
|
+
const where = model === "kanbanBoard" ? boardWhere(snapshot) : model === "kanbanColumn" ? columnWhere(snapshot) : taskWhere(snapshot);
|
|
277
|
+
const claimed = await adapter.updateMany({
|
|
278
|
+
model,
|
|
279
|
+
where,
|
|
280
|
+
update: { updatedAt: claimedAt }
|
|
281
|
+
});
|
|
282
|
+
if (!didAffectRow(claimed, snapshot.id)) throw staleStateError();
|
|
283
|
+
return claimedAt;
|
|
284
|
+
}
|
|
285
|
+
async function restoreSnapshot(adapter, model, snapshot, claimedAt) {
|
|
286
|
+
const where = model === "kanbanBoard" ? boardWhere({ ...snapshot, updatedAt: claimedAt }) : columnWhere({ ...snapshot, updatedAt: claimedAt });
|
|
287
|
+
const restored = await adapter.updateMany({
|
|
288
|
+
model,
|
|
289
|
+
where,
|
|
290
|
+
update: { updatedAt: snapshot.updatedAt }
|
|
291
|
+
});
|
|
292
|
+
if (!didAffectRow(restored, snapshot.id)) throw staleStateError();
|
|
293
|
+
}
|
|
294
|
+
async function findBoard(adapter, id) {
|
|
295
|
+
return await adapter.findOne({
|
|
296
|
+
model: "kanbanBoard",
|
|
297
|
+
where: [{ field: "id", value: id, operator: "eq" }]
|
|
298
|
+
}) ?? null;
|
|
299
|
+
}
|
|
300
|
+
async function findColumn(adapter, id) {
|
|
301
|
+
return await adapter.findOne({
|
|
302
|
+
model: "kanbanColumn",
|
|
303
|
+
where: [{ field: "id", value: id, operator: "eq" }]
|
|
304
|
+
}) ?? null;
|
|
305
|
+
}
|
|
306
|
+
async function findTask(adapter, id) {
|
|
307
|
+
return await adapter.findOne({
|
|
308
|
+
model: "kanbanTask",
|
|
309
|
+
where: [{ field: "id", value: id, operator: "eq" }]
|
|
310
|
+
}) ?? null;
|
|
311
|
+
}
|
|
312
|
+
async function listColumns(adapter, boardId) {
|
|
313
|
+
return adapter.findMany({
|
|
314
|
+
model: "kanbanColumn",
|
|
315
|
+
where: [{ field: "boardId", value: boardId, operator: "eq" }],
|
|
316
|
+
sortBy: { field: "order", direction: "asc" }
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
async function listTasks(adapter, columnId) {
|
|
320
|
+
return adapter.findMany({
|
|
321
|
+
model: "kanbanTask",
|
|
322
|
+
where: [{ field: "columnId", value: columnId, operator: "eq" }],
|
|
323
|
+
sortBy: { field: "order", direction: "asc" }
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
function boardNotFoundError() {
|
|
327
|
+
return new KanbanOperationError(404, "Board not found", "BOARD_NOT_FOUND");
|
|
328
|
+
}
|
|
329
|
+
function columnNotFoundError() {
|
|
330
|
+
return new KanbanOperationError(404, "Column not found", "COLUMN_NOT_FOUND");
|
|
331
|
+
}
|
|
332
|
+
function taskNotFoundError() {
|
|
333
|
+
return new KanbanOperationError(404, "Task not found", "TASK_NOT_FOUND");
|
|
334
|
+
}
|
|
335
|
+
function staleStateError() {
|
|
336
|
+
return new KanbanOperationError(
|
|
337
|
+
409,
|
|
338
|
+
"Kanban state changed while authorization was being evaluated. Retry the operation.",
|
|
339
|
+
"KANBAN_STATE_CHANGED"
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
function invalidColumnSetError() {
|
|
343
|
+
return new KanbanOperationError(
|
|
344
|
+
400,
|
|
345
|
+
"columnIds must contain every current board column exactly once.",
|
|
346
|
+
"INVALID_COLUMN_SET"
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
function invalidTaskSetError() {
|
|
350
|
+
return new KanbanOperationError(
|
|
351
|
+
400,
|
|
352
|
+
"taskIds must contain every current column task exactly once.",
|
|
353
|
+
"INVALID_TASK_SET"
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
function invalidTargetColumnError() {
|
|
357
|
+
return new KanbanOperationError(
|
|
358
|
+
400,
|
|
359
|
+
"The target column must belong to the task's board.",
|
|
360
|
+
"INVALID_TARGET_COLUMN"
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
function sanitizeSlug(value) {
|
|
364
|
+
const slug = utils.slugify(value);
|
|
365
|
+
if (!slug) {
|
|
366
|
+
throw new KanbanOperationError(
|
|
367
|
+
400,
|
|
368
|
+
"Invalid slug: must contain at least one alphanumeric character",
|
|
369
|
+
"INVALID_SLUG"
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
return slug;
|
|
373
|
+
}
|
|
374
|
+
function normalizeError(error, fallback) {
|
|
375
|
+
return error instanceof Error ? error : new Error(typeof error === "string" ? error : fallback, { cause: error });
|
|
376
|
+
}
|
|
377
|
+
async function runDomainHook(run, code) {
|
|
378
|
+
try {
|
|
379
|
+
return await run();
|
|
380
|
+
} catch (error) {
|
|
381
|
+
throw new KanbanOperationError(
|
|
382
|
+
403,
|
|
383
|
+
normalizeError(error, "Kanban operation rejected").message,
|
|
384
|
+
code
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function hookContext(context, legacy = {}) {
|
|
389
|
+
return Object.freeze({
|
|
390
|
+
...context,
|
|
391
|
+
...context.request ? { request: context.request, headers: context.request.headers } : {},
|
|
392
|
+
...legacy
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
async function notifyBoardError(hook, error, context, legacy = {}) {
|
|
396
|
+
const normalized = normalizeError(error, "Kanban board operation failed");
|
|
397
|
+
const lifecycle = hookContext(context, legacy);
|
|
398
|
+
try {
|
|
399
|
+
await hook?.(normalized, lifecycle);
|
|
400
|
+
} catch {
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
function boardFacts(snapshot) {
|
|
404
|
+
return {
|
|
405
|
+
boardId: snapshot.id,
|
|
406
|
+
...snapshot.ownerId ? { ownerId: snapshot.ownerId } : {},
|
|
407
|
+
...snapshot.organizationId ? { organizationId: snapshot.organizationId } : {}
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
function taskFacts(snapshot) {
|
|
411
|
+
return {
|
|
412
|
+
...boardFacts(snapshot.board),
|
|
413
|
+
columnId: snapshot.column.id,
|
|
414
|
+
taskId: snapshot.task.id,
|
|
415
|
+
...snapshot.task.assigneeId ? { assigneeId: snapshot.task.assigneeId } : {},
|
|
416
|
+
isArchived: snapshot.task.isArchived
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
async function loadColumnAuthorization(adapter, columnId) {
|
|
420
|
+
const column = await findColumn(adapter, columnId);
|
|
421
|
+
if (!column) throw columnNotFoundError();
|
|
422
|
+
const board = await findBoard(adapter, column.boardId);
|
|
423
|
+
if (!board) throw boardNotFoundError();
|
|
424
|
+
return { board: boardSnapshot(board), column: columnSnapshot(column) };
|
|
425
|
+
}
|
|
426
|
+
async function loadTaskAuthorization(adapter, taskId) {
|
|
427
|
+
const task = await findTask(adapter, taskId);
|
|
428
|
+
if (!task) throw taskNotFoundError();
|
|
429
|
+
const parent = await loadColumnAuthorization(adapter, task.columnId);
|
|
430
|
+
return { ...parent, task: taskSnapshot(task) };
|
|
431
|
+
}
|
|
432
|
+
function sameIdSet(left, right) {
|
|
433
|
+
return left.length === right.length && new Set(left).size === left.length && left.every((id) => right.includes(id));
|
|
434
|
+
}
|
|
435
|
+
function operationTask(task) {
|
|
436
|
+
const serialized = serializers.serializeTask(task);
|
|
437
|
+
return { ...serialized };
|
|
438
|
+
}
|
|
439
|
+
function operationColumn(column) {
|
|
440
|
+
return {
|
|
441
|
+
...serializeBareColumn(column),
|
|
442
|
+
tasks: column.tasks.map(operationTask)
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
function operationBoard(board) {
|
|
446
|
+
return {
|
|
447
|
+
...serializeBareBoard(board),
|
|
448
|
+
columns: board.columns.map(operationColumn)
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function boardSummary(board) {
|
|
452
|
+
return serializers.serializeBoardSummary(board);
|
|
453
|
+
}
|
|
454
|
+
function serializeBareColumn(column) {
|
|
455
|
+
return {
|
|
456
|
+
...column,
|
|
457
|
+
createdAt: column.createdAt.toISOString(),
|
|
458
|
+
updatedAt: column.updatedAt.toISOString()
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
function serializeBareBoard(board) {
|
|
462
|
+
return {
|
|
463
|
+
...board,
|
|
464
|
+
createdAt: board.createdAt.toISOString(),
|
|
465
|
+
updatedAt: board.updatedAt.toISOString()
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
async function verifyBoard(adapter, expected) {
|
|
469
|
+
if (!sameBoard(await findBoard(adapter, expected.id), expected)) {
|
|
470
|
+
throw staleStateError();
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
async function verifyColumnAuthorization(adapter, expected) {
|
|
474
|
+
await verifyBoard(adapter, expected.board);
|
|
475
|
+
if (!sameColumn(await findColumn(adapter, expected.column.id), expected.column)) {
|
|
476
|
+
throw staleStateError();
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
async function verifyTaskAuthorization(adapter, expected) {
|
|
480
|
+
await verifyColumnAuthorization(adapter, expected);
|
|
481
|
+
if (!sameTask(await findTask(adapter, expected.task.id), expected.task)) {
|
|
482
|
+
throw staleStateError();
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
async function loadMoveSnapshot(adapter, primary, targetColumnId, targetOrder) {
|
|
486
|
+
await verifyTaskAuthorization(adapter, primary);
|
|
487
|
+
const targetColumn = await findColumn(adapter, targetColumnId);
|
|
488
|
+
if (!targetColumn) throw columnNotFoundError();
|
|
489
|
+
if (targetColumn.boardId !== primary.board.id) {
|
|
490
|
+
throw invalidTargetColumnError();
|
|
491
|
+
}
|
|
492
|
+
const [sourceTasks, targetTasks] = await Promise.all([
|
|
493
|
+
listTasks(adapter, primary.column.id),
|
|
494
|
+
targetColumn.id === primary.column.id ? Promise.resolve([]) : listTasks(adapter, targetColumn.id)
|
|
495
|
+
]);
|
|
496
|
+
return {
|
|
497
|
+
...primary,
|
|
498
|
+
targetColumn: columnSnapshot(targetColumn),
|
|
499
|
+
sourceTasks: sourceTasks.map(taskSnapshot),
|
|
500
|
+
targetTasks: targetColumn.id === primary.column.id ? sourceTasks.map(taskSnapshot) : targetTasks.map(taskSnapshot),
|
|
501
|
+
targetOrder
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
async function verifyMoveSnapshot(adapter, expected) {
|
|
505
|
+
await verifyTaskAuthorization(adapter, expected);
|
|
506
|
+
if (!sameColumn(
|
|
507
|
+
await findColumn(adapter, expected.targetColumn.id),
|
|
508
|
+
expected.targetColumn
|
|
509
|
+
)) {
|
|
510
|
+
throw staleStateError();
|
|
511
|
+
}
|
|
512
|
+
const sourceTasks = (await listTasks(adapter, expected.column.id)).map(
|
|
513
|
+
taskSnapshot
|
|
514
|
+
);
|
|
515
|
+
const targetTasks = expected.targetColumn.id === expected.column.id ? sourceTasks : (await listTasks(adapter, expected.targetColumn.id)).map(taskSnapshot);
|
|
516
|
+
if (!sameSnapshotSet(sourceTasks, expected.sourceTasks, sameTaskSnapshots) || !sameSnapshotSet(targetTasks, expected.targetTasks, sameTaskSnapshots)) {
|
|
517
|
+
throw staleStateError();
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
async function claimColumnAuthorization(adapter, snapshot) {
|
|
521
|
+
const boardClaimedAt = await claimSnapshot(
|
|
522
|
+
adapter,
|
|
523
|
+
"kanbanBoard",
|
|
524
|
+
snapshot.board
|
|
525
|
+
);
|
|
526
|
+
const columnClaimedAt = await claimSnapshot(
|
|
527
|
+
adapter,
|
|
528
|
+
"kanbanColumn",
|
|
529
|
+
snapshot.column
|
|
530
|
+
);
|
|
531
|
+
return { boardClaimedAt, columnClaimedAt };
|
|
532
|
+
}
|
|
533
|
+
async function restoreColumnAuthorization(adapter, snapshot, claims) {
|
|
534
|
+
await restoreSnapshot(
|
|
535
|
+
adapter,
|
|
536
|
+
"kanbanColumn",
|
|
537
|
+
snapshot.column,
|
|
538
|
+
claims.columnClaimedAt
|
|
539
|
+
);
|
|
540
|
+
await restoreSnapshot(
|
|
541
|
+
adapter,
|
|
542
|
+
"kanbanBoard",
|
|
543
|
+
snapshot.board,
|
|
544
|
+
claims.boardClaimedAt
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
async function claimMoveSnapshot(adapter, snapshot) {
|
|
548
|
+
const boardClaimedAt = await claimSnapshot(
|
|
549
|
+
adapter,
|
|
550
|
+
"kanbanBoard",
|
|
551
|
+
snapshot.board
|
|
552
|
+
);
|
|
553
|
+
const sourceColumnClaimedAt = await claimSnapshot(
|
|
554
|
+
adapter,
|
|
555
|
+
"kanbanColumn",
|
|
556
|
+
snapshot.column
|
|
557
|
+
);
|
|
558
|
+
const targetColumnClaimedAt = snapshot.targetColumn.id === snapshot.column.id ? sourceColumnClaimedAt : await claimSnapshot(adapter, "kanbanColumn", snapshot.targetColumn);
|
|
559
|
+
const taskClaims = /* @__PURE__ */ new Map();
|
|
560
|
+
const allTasks = /* @__PURE__ */ new Map();
|
|
561
|
+
for (const task of [...snapshot.sourceTasks, ...snapshot.targetTasks]) {
|
|
562
|
+
allTasks.set(task.id, task);
|
|
563
|
+
}
|
|
564
|
+
for (const task of allTasks.values()) {
|
|
565
|
+
taskClaims.set(task.id, await claimSnapshot(adapter, "kanbanTask", task));
|
|
566
|
+
}
|
|
567
|
+
return {
|
|
568
|
+
boardClaimedAt,
|
|
569
|
+
sourceColumnClaimedAt,
|
|
570
|
+
targetColumnClaimedAt,
|
|
571
|
+
taskClaims
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
async function applyTaskMove(adapter, snapshot, claims, extraUpdate) {
|
|
575
|
+
const sourceTasks = snapshot.sourceTasks.filter(
|
|
576
|
+
(task) => task.id !== snapshot.task.id
|
|
577
|
+
);
|
|
578
|
+
const targetBase = snapshot.targetColumn.id === snapshot.column.id ? sourceTasks : snapshot.targetTasks.filter((task) => task.id !== snapshot.task.id);
|
|
579
|
+
const targetOrder = Math.min(snapshot.targetOrder, targetBase.length);
|
|
580
|
+
const orderedTarget = [...targetBase];
|
|
581
|
+
orderedTarget.splice(targetOrder, 0, {
|
|
582
|
+
...snapshot.task,
|
|
583
|
+
columnId: snapshot.targetColumn.id
|
|
584
|
+
});
|
|
585
|
+
const finalRows = /* @__PURE__ */ new Map();
|
|
586
|
+
if (snapshot.targetColumn.id !== snapshot.column.id) {
|
|
587
|
+
sourceTasks.forEach((task, order) => {
|
|
588
|
+
finalRows.set(task.id, {
|
|
589
|
+
snapshot: task,
|
|
590
|
+
columnId: task.columnId,
|
|
591
|
+
order
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
orderedTarget.forEach((task, order) => {
|
|
596
|
+
const original = task.id === snapshot.task.id ? snapshot.task : snapshot.targetTasks.find((candidate) => candidate.id === task.id) ?? task;
|
|
597
|
+
finalRows.set(task.id, {
|
|
598
|
+
snapshot: original,
|
|
599
|
+
columnId: snapshot.targetColumn.id,
|
|
600
|
+
order
|
|
601
|
+
});
|
|
602
|
+
});
|
|
603
|
+
let moved = null;
|
|
604
|
+
for (const row of finalRows.values()) {
|
|
605
|
+
const claimedAt = claims.taskClaims.get(row.snapshot.id);
|
|
606
|
+
if (!claimedAt) throw staleStateError();
|
|
607
|
+
const matched = await adapter.updateMany({
|
|
608
|
+
model: "kanbanTask",
|
|
609
|
+
where: taskWhere({ ...row.snapshot, updatedAt: claimedAt }),
|
|
610
|
+
update: {
|
|
611
|
+
...row.snapshot.id === snapshot.task.id ? extraUpdate : {},
|
|
612
|
+
columnId: row.columnId,
|
|
613
|
+
order: row.order,
|
|
614
|
+
updatedAt: nextSnapshotDate(claimedAt)
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
if (!didAffectRow(matched, row.snapshot.id)) throw staleStateError();
|
|
618
|
+
if (row.snapshot.id === snapshot.task.id) {
|
|
619
|
+
moved = await findTask(adapter, row.snapshot.id);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
if (!moved) throw taskNotFoundError();
|
|
623
|
+
await restoreSnapshot(
|
|
624
|
+
adapter,
|
|
625
|
+
"kanbanColumn",
|
|
626
|
+
snapshot.column,
|
|
627
|
+
claims.sourceColumnClaimedAt
|
|
628
|
+
);
|
|
629
|
+
if (snapshot.targetColumn.id !== snapshot.column.id) {
|
|
630
|
+
await restoreSnapshot(
|
|
631
|
+
adapter,
|
|
632
|
+
"kanbanColumn",
|
|
633
|
+
snapshot.targetColumn,
|
|
634
|
+
claims.targetColumnClaimedAt
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
await restoreSnapshot(
|
|
638
|
+
adapter,
|
|
639
|
+
"kanbanBoard",
|
|
640
|
+
snapshot.board,
|
|
641
|
+
claims.boardClaimedAt
|
|
642
|
+
);
|
|
643
|
+
return moved;
|
|
644
|
+
}
|
|
645
|
+
function sameOptionalBoard(board, expected) {
|
|
646
|
+
return expected === null ? board === null : sameBoard(board, expected);
|
|
647
|
+
}
|
|
648
|
+
function createKanbanOperations(sourceAdapter, hooks) {
|
|
649
|
+
const adapter = serializeMemoryOperations(sourceAdapter);
|
|
650
|
+
const boardSnapshots = /* @__PURE__ */ new WeakMap();
|
|
651
|
+
const columnSnapshots = /* @__PURE__ */ new WeakMap();
|
|
652
|
+
const taskSnapshots = /* @__PURE__ */ new WeakMap();
|
|
653
|
+
const columnReorderSnapshots = /* @__PURE__ */ new WeakMap();
|
|
654
|
+
const taskReorderSnapshots = /* @__PURE__ */ new WeakMap();
|
|
655
|
+
const taskMoveSnapshots = /* @__PURE__ */ new WeakMap();
|
|
656
|
+
const updateTaskMoveSnapshots = /* @__PURE__ */ new WeakMap();
|
|
657
|
+
const reorderedColumns = /* @__PURE__ */ new WeakMap();
|
|
658
|
+
const reorderedTasks = /* @__PURE__ */ new WeakMap();
|
|
659
|
+
const listBoards = api.defineOperation({
|
|
660
|
+
input: schemas.BoardListQuerySchema,
|
|
661
|
+
permission: plugins_kanban_permissions.kanbanPermissions.board.read,
|
|
662
|
+
facts: () => ({ scope: "collection" }),
|
|
663
|
+
before: async (context) => {
|
|
664
|
+
await runDomainHook(
|
|
665
|
+
() => hooks?.onBeforeListBoards?.(
|
|
666
|
+
{ ...context.input },
|
|
667
|
+
hookContext(context, { query: context.input })
|
|
668
|
+
),
|
|
669
|
+
"LIST_BOARDS_REJECTED"
|
|
670
|
+
);
|
|
671
|
+
},
|
|
672
|
+
execute: async ({ input }) => {
|
|
673
|
+
const result = await getters.getBoardSummaries(adapter, input);
|
|
674
|
+
return {
|
|
675
|
+
items: result.items.map(boardSummary),
|
|
676
|
+
total: result.total,
|
|
677
|
+
...result.limit !== void 0 ? { limit: result.limit } : {},
|
|
678
|
+
...result.offset !== void 0 ? { offset: result.offset } : {}
|
|
679
|
+
};
|
|
680
|
+
},
|
|
681
|
+
after: async (context) => {
|
|
682
|
+
await hooks?.onAfterListBoards?.(
|
|
683
|
+
context.result.items,
|
|
684
|
+
{ ...context.input },
|
|
685
|
+
hookContext(context, { query: context.input })
|
|
686
|
+
);
|
|
687
|
+
},
|
|
688
|
+
onError: ({ error, ...context }) => notifyBoardError(hooks?.onErrorListBoards, error, context, {
|
|
689
|
+
query: context.input
|
|
690
|
+
})
|
|
691
|
+
});
|
|
692
|
+
const getBoard = api.defineOperation({
|
|
693
|
+
input: BoardIdOperationInputSchema,
|
|
694
|
+
permission: plugins_kanban_permissions.kanbanPermissions.board.read,
|
|
695
|
+
facts: async ({ input }) => {
|
|
696
|
+
const board = await findBoard(adapter, input.id);
|
|
697
|
+
const snapshot = board ? boardSnapshot(board) : null;
|
|
698
|
+
boardSnapshots.set(input, snapshot);
|
|
699
|
+
return {
|
|
700
|
+
scope: "record",
|
|
701
|
+
boardId: input.id,
|
|
702
|
+
exists: snapshot !== null,
|
|
703
|
+
...snapshot ? boardFacts(snapshot) : {}
|
|
704
|
+
};
|
|
705
|
+
},
|
|
706
|
+
before: async (context) => {
|
|
707
|
+
const expected = boardSnapshots.get(context.input) ?? null;
|
|
708
|
+
if (!sameOptionalBoard(await findBoard(adapter, context.input.id), expected)) {
|
|
709
|
+
throw staleStateError();
|
|
710
|
+
}
|
|
711
|
+
await runDomainHook(
|
|
712
|
+
() => hooks?.onBeforeGetBoard?.(
|
|
713
|
+
context.input.id,
|
|
714
|
+
hookContext(context, { params: { id: context.input.id } })
|
|
715
|
+
),
|
|
716
|
+
"READ_BOARD_REJECTED"
|
|
717
|
+
);
|
|
718
|
+
},
|
|
719
|
+
execute: async (context) => {
|
|
720
|
+
const expected = boardSnapshots.get(context.input) ?? null;
|
|
721
|
+
const board = await getters.getBoardById(adapter, context.input.id);
|
|
722
|
+
if (!sameOptionalBoard(board, expected)) {
|
|
723
|
+
throw staleStateError();
|
|
724
|
+
}
|
|
725
|
+
if (!board) throw boardNotFoundError();
|
|
726
|
+
return operationBoard(board);
|
|
727
|
+
},
|
|
728
|
+
after: async (context) => {
|
|
729
|
+
await hooks?.onAfterGetBoard?.(
|
|
730
|
+
context.result,
|
|
731
|
+
hookContext(context, { params: { id: context.input.id } })
|
|
732
|
+
);
|
|
733
|
+
},
|
|
734
|
+
onError: ({ error, ...context }) => notifyBoardError(hooks?.onErrorGetBoard, error, context, {
|
|
735
|
+
params: { id: context.input.id }
|
|
736
|
+
})
|
|
737
|
+
});
|
|
738
|
+
const createBoard = api.defineOperation({
|
|
739
|
+
input: schemas.createBoardSchema,
|
|
740
|
+
permission: plugins_kanban_permissions.kanbanPermissions.board.create,
|
|
741
|
+
facts: () => void 0,
|
|
742
|
+
execute: async (context) => {
|
|
743
|
+
const data = { ...context.input };
|
|
744
|
+
requireAtomicTransactions(adapter);
|
|
745
|
+
return adapter.transaction(async (tx) => {
|
|
746
|
+
await runDomainHook(
|
|
747
|
+
() => hooks?.onBeforeCreateBoard?.(
|
|
748
|
+
data,
|
|
749
|
+
hookContext(context, { body: data })
|
|
750
|
+
),
|
|
751
|
+
"CREATE_BOARD_REJECTED"
|
|
752
|
+
);
|
|
753
|
+
const input = {
|
|
754
|
+
...data,
|
|
755
|
+
slug: sanitizeSlug(data.slug || data.name),
|
|
756
|
+
...context.identity ? { ownerId: context.identity.id } : {}
|
|
757
|
+
};
|
|
758
|
+
const now = /* @__PURE__ */ new Date();
|
|
759
|
+
const board = await tx.create({
|
|
760
|
+
model: "kanbanBoard",
|
|
761
|
+
data: {
|
|
762
|
+
...input,
|
|
763
|
+
createdAt: now,
|
|
764
|
+
updatedAt: now
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
const columns = [];
|
|
768
|
+
for (const [order, title] of [
|
|
769
|
+
"To Do",
|
|
770
|
+
"In Progress",
|
|
771
|
+
"Done"
|
|
772
|
+
].entries()) {
|
|
773
|
+
columns.push(
|
|
774
|
+
await tx.create({
|
|
775
|
+
model: "kanbanColumn",
|
|
776
|
+
data: {
|
|
777
|
+
title,
|
|
778
|
+
boardId: board.id,
|
|
779
|
+
order,
|
|
780
|
+
createdAt: now,
|
|
781
|
+
updatedAt: now
|
|
782
|
+
}
|
|
783
|
+
})
|
|
784
|
+
);
|
|
785
|
+
}
|
|
786
|
+
return operationBoard({
|
|
787
|
+
...board,
|
|
788
|
+
columns: columns.map((column) => ({ ...column, tasks: [] }))
|
|
789
|
+
});
|
|
790
|
+
});
|
|
791
|
+
},
|
|
792
|
+
after: async (context) => {
|
|
793
|
+
await hooks?.onAfterCreateBoard?.(
|
|
794
|
+
context.result,
|
|
795
|
+
hookContext(context, { body: context.input })
|
|
796
|
+
);
|
|
797
|
+
},
|
|
798
|
+
onError: ({ error, ...context }) => {
|
|
799
|
+
markMemoryRollback(adapter, error);
|
|
800
|
+
return notifyBoardError(hooks?.onErrorCreateBoard, error, context, {
|
|
801
|
+
body: context.input
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
});
|
|
805
|
+
const updateBoard = api.defineOperation({
|
|
806
|
+
input: UpdateBoardOperationInputSchema,
|
|
807
|
+
permission: plugins_kanban_permissions.kanbanPermissions.board.update,
|
|
808
|
+
facts: async ({ input }) => {
|
|
809
|
+
const board = await findBoard(adapter, input.id);
|
|
810
|
+
if (!board) throw boardNotFoundError();
|
|
811
|
+
const snapshot = boardSnapshot(board);
|
|
812
|
+
boardSnapshots.set(input, snapshot);
|
|
813
|
+
return boardFacts(snapshot);
|
|
814
|
+
},
|
|
815
|
+
execute: async (context) => {
|
|
816
|
+
const snapshot = boardSnapshots.get(context.input);
|
|
817
|
+
if (!snapshot) throw staleStateError();
|
|
818
|
+
requireAtomicTransactions(adapter);
|
|
819
|
+
const data = {
|
|
820
|
+
...context.input.data,
|
|
821
|
+
...context.input.data.slug ? { slug: sanitizeSlug(context.input.data.slug) } : {}
|
|
822
|
+
};
|
|
823
|
+
return adapter.transaction(async (tx) => {
|
|
824
|
+
await verifyBoard(tx, snapshot);
|
|
825
|
+
const claimedAt = await claimSnapshot(tx, "kanbanBoard", snapshot);
|
|
826
|
+
await runDomainHook(
|
|
827
|
+
() => hooks?.onBeforeUpdateBoard?.(
|
|
828
|
+
context.input.id,
|
|
829
|
+
{ ...data, id: context.input.id },
|
|
830
|
+
hookContext(context, {
|
|
831
|
+
body: data,
|
|
832
|
+
params: { id: context.input.id }
|
|
833
|
+
})
|
|
834
|
+
),
|
|
835
|
+
"UPDATE_BOARD_REJECTED"
|
|
836
|
+
);
|
|
837
|
+
const matched = await tx.updateMany({
|
|
838
|
+
model: "kanbanBoard",
|
|
839
|
+
where: boardWhere({ ...snapshot, updatedAt: claimedAt }),
|
|
840
|
+
update: {
|
|
841
|
+
...data,
|
|
842
|
+
updatedAt: nextSnapshotDate(claimedAt)
|
|
843
|
+
}
|
|
844
|
+
});
|
|
845
|
+
if (!didAffectRow(matched, snapshot.id)) throw staleStateError();
|
|
846
|
+
const updated = await findBoard(tx, snapshot.id);
|
|
847
|
+
if (!updated) throw boardNotFoundError();
|
|
848
|
+
return serializeBareBoard(updated);
|
|
849
|
+
});
|
|
850
|
+
},
|
|
851
|
+
after: async (context) => {
|
|
852
|
+
await hooks?.onAfterUpdateBoard?.(
|
|
853
|
+
context.result,
|
|
854
|
+
hookContext(context, {
|
|
855
|
+
body: context.input.data,
|
|
856
|
+
params: { id: context.input.id }
|
|
857
|
+
})
|
|
858
|
+
);
|
|
859
|
+
},
|
|
860
|
+
onError: ({ error, ...context }) => {
|
|
861
|
+
markMemoryRollback(adapter, error);
|
|
862
|
+
return notifyBoardError(hooks?.onErrorUpdateBoard, error, context, {
|
|
863
|
+
body: context.input.data,
|
|
864
|
+
params: { id: context.input.id }
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
});
|
|
868
|
+
const deleteBoard = api.defineOperation({
|
|
869
|
+
input: BoardIdOperationInputSchema,
|
|
870
|
+
permission: plugins_kanban_permissions.kanbanPermissions.board.delete,
|
|
871
|
+
facts: async ({ input }) => {
|
|
872
|
+
const board = await findBoard(adapter, input.id);
|
|
873
|
+
if (!board) throw boardNotFoundError();
|
|
874
|
+
const snapshot = boardSnapshot(board);
|
|
875
|
+
boardSnapshots.set(input, snapshot);
|
|
876
|
+
return boardFacts(snapshot);
|
|
877
|
+
},
|
|
878
|
+
execute: async (context) => {
|
|
879
|
+
const snapshot = boardSnapshots.get(context.input);
|
|
880
|
+
if (!snapshot) throw staleStateError();
|
|
881
|
+
requireAtomicTransactions(adapter);
|
|
882
|
+
return adapter.transaction(async (tx) => {
|
|
883
|
+
await verifyBoard(tx, snapshot);
|
|
884
|
+
const claimedAt = await claimSnapshot(tx, "kanbanBoard", snapshot);
|
|
885
|
+
await runDomainHook(
|
|
886
|
+
() => hooks?.onBeforeDeleteBoard?.(
|
|
887
|
+
context.input.id,
|
|
888
|
+
hookContext(context, {
|
|
889
|
+
params: { id: context.input.id }
|
|
890
|
+
})
|
|
891
|
+
),
|
|
892
|
+
"DELETE_BOARD_REJECTED"
|
|
893
|
+
);
|
|
894
|
+
const deleted = await tx.deleteMany({
|
|
895
|
+
model: "kanbanBoard",
|
|
896
|
+
where: boardWhere({ ...snapshot, updatedAt: claimedAt })
|
|
897
|
+
});
|
|
898
|
+
if (!didAffectRow(deleted, snapshot.id)) throw staleStateError();
|
|
899
|
+
return { success: true };
|
|
900
|
+
});
|
|
901
|
+
},
|
|
902
|
+
after: async (context) => {
|
|
903
|
+
await hooks?.onAfterDeleteBoard?.(
|
|
904
|
+
context.input.id,
|
|
905
|
+
hookContext(context, { params: { id: context.input.id } })
|
|
906
|
+
);
|
|
907
|
+
},
|
|
908
|
+
onError: ({ error, ...context }) => {
|
|
909
|
+
markMemoryRollback(adapter, error);
|
|
910
|
+
return notifyBoardError(hooks?.onErrorDeleteBoard, error, context, {
|
|
911
|
+
params: { id: context.input.id }
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
const createColumn = api.defineOperation({
|
|
916
|
+
input: schemas.createColumnSchema,
|
|
917
|
+
permission: plugins_kanban_permissions.kanbanPermissions.column.create,
|
|
918
|
+
facts: async ({ input }) => {
|
|
919
|
+
const board = await findBoard(adapter, input.boardId);
|
|
920
|
+
if (!board) throw boardNotFoundError();
|
|
921
|
+
const snapshot = boardSnapshot(board);
|
|
922
|
+
boardSnapshots.set(input, snapshot);
|
|
923
|
+
return boardFacts(snapshot);
|
|
924
|
+
},
|
|
925
|
+
execute: async (context) => {
|
|
926
|
+
const board = boardSnapshots.get(context.input);
|
|
927
|
+
if (!board) throw staleStateError();
|
|
928
|
+
requireAtomicTransactions(adapter);
|
|
929
|
+
return adapter.transaction(async (tx) => {
|
|
930
|
+
await verifyBoard(tx, board);
|
|
931
|
+
const boardClaimedAt = await claimSnapshot(tx, "kanbanBoard", board);
|
|
932
|
+
await runDomainHook(
|
|
933
|
+
() => hooks?.onBeforeCreateColumn?.(
|
|
934
|
+
{ ...context.input },
|
|
935
|
+
hookContext(context, { body: context.input })
|
|
936
|
+
),
|
|
937
|
+
"CREATE_COLUMN_REJECTED"
|
|
938
|
+
);
|
|
939
|
+
const existing = await listColumns(tx, board.id);
|
|
940
|
+
const nextOrder = existing.length === 0 ? 0 : Math.max(...existing.map((column2) => column2.order)) + 1;
|
|
941
|
+
const now = /* @__PURE__ */ new Date();
|
|
942
|
+
const column = await tx.create({
|
|
943
|
+
model: "kanbanColumn",
|
|
944
|
+
data: {
|
|
945
|
+
...context.input,
|
|
946
|
+
order: context.input.order ?? nextOrder,
|
|
947
|
+
createdAt: now,
|
|
948
|
+
updatedAt: now
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
await restoreSnapshot(tx, "kanbanBoard", board, boardClaimedAt);
|
|
952
|
+
return serializeBareColumn(column);
|
|
953
|
+
});
|
|
954
|
+
},
|
|
955
|
+
after: async (context) => {
|
|
956
|
+
await hooks?.onAfterCreateColumn?.(
|
|
957
|
+
context.result,
|
|
958
|
+
hookContext(context, { body: context.input })
|
|
959
|
+
);
|
|
960
|
+
},
|
|
961
|
+
onError: ({ error }) => markMemoryRollback(adapter, error)
|
|
962
|
+
});
|
|
963
|
+
const updateColumn = api.defineOperation({
|
|
964
|
+
input: UpdateColumnOperationInputSchema,
|
|
965
|
+
permission: plugins_kanban_permissions.kanbanPermissions.column.update,
|
|
966
|
+
facts: async ({ input }) => {
|
|
967
|
+
const snapshot = await loadColumnAuthorization(adapter, input.id);
|
|
968
|
+
columnSnapshots.set(input, snapshot);
|
|
969
|
+
return {
|
|
970
|
+
...boardFacts(snapshot.board),
|
|
971
|
+
columnId: snapshot.column.id
|
|
972
|
+
};
|
|
973
|
+
},
|
|
974
|
+
additionalPermissions: ({ input }) => {
|
|
975
|
+
if (input.data.order === void 0) return [];
|
|
976
|
+
const snapshot = columnSnapshots.get(input);
|
|
977
|
+
if (!snapshot) throw staleStateError();
|
|
978
|
+
return [plugins_kanban_permissions.kanbanPermissions.column.reorder(boardFacts(snapshot.board))];
|
|
979
|
+
},
|
|
980
|
+
execute: async (context) => {
|
|
981
|
+
const snapshot = columnSnapshots.get(context.input);
|
|
982
|
+
if (!snapshot) throw staleStateError();
|
|
983
|
+
if (context.input.data.boardId && context.input.data.boardId !== snapshot.board.id) {
|
|
984
|
+
throw invalidTargetColumnError();
|
|
985
|
+
}
|
|
986
|
+
requireAtomicTransactions(adapter);
|
|
987
|
+
return adapter.transaction(async (tx) => {
|
|
988
|
+
await verifyColumnAuthorization(tx, snapshot);
|
|
989
|
+
const claims = await claimColumnAuthorization(tx, snapshot);
|
|
990
|
+
await runDomainHook(
|
|
991
|
+
() => hooks?.onBeforeUpdateColumn?.(
|
|
992
|
+
context.input.id,
|
|
993
|
+
{ ...context.input.data, id: context.input.id },
|
|
994
|
+
hookContext(context, {
|
|
995
|
+
body: context.input.data,
|
|
996
|
+
params: { id: context.input.id }
|
|
997
|
+
})
|
|
998
|
+
),
|
|
999
|
+
"UPDATE_COLUMN_REJECTED"
|
|
1000
|
+
);
|
|
1001
|
+
const matched = await tx.updateMany({
|
|
1002
|
+
model: "kanbanColumn",
|
|
1003
|
+
where: columnWhere({
|
|
1004
|
+
...snapshot.column,
|
|
1005
|
+
updatedAt: claims.columnClaimedAt
|
|
1006
|
+
}),
|
|
1007
|
+
update: {
|
|
1008
|
+
...context.input.data,
|
|
1009
|
+
boardId: snapshot.board.id,
|
|
1010
|
+
updatedAt: nextSnapshotDate(claims.columnClaimedAt)
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
if (!didAffectRow(matched, snapshot.column.id)) {
|
|
1014
|
+
throw staleStateError();
|
|
1015
|
+
}
|
|
1016
|
+
await restoreSnapshot(
|
|
1017
|
+
tx,
|
|
1018
|
+
"kanbanBoard",
|
|
1019
|
+
snapshot.board,
|
|
1020
|
+
claims.boardClaimedAt
|
|
1021
|
+
);
|
|
1022
|
+
const updated = await findColumn(tx, snapshot.column.id);
|
|
1023
|
+
if (!updated) throw columnNotFoundError();
|
|
1024
|
+
return serializeBareColumn(updated);
|
|
1025
|
+
});
|
|
1026
|
+
},
|
|
1027
|
+
after: async (context) => {
|
|
1028
|
+
await hooks?.onAfterUpdateColumn?.(
|
|
1029
|
+
context.result,
|
|
1030
|
+
hookContext(context, {
|
|
1031
|
+
body: context.input.data,
|
|
1032
|
+
params: { id: context.input.id }
|
|
1033
|
+
})
|
|
1034
|
+
);
|
|
1035
|
+
},
|
|
1036
|
+
onError: ({ error }) => markMemoryRollback(adapter, error)
|
|
1037
|
+
});
|
|
1038
|
+
const deleteColumn = api.defineOperation({
|
|
1039
|
+
input: ColumnIdOperationInputSchema,
|
|
1040
|
+
permission: plugins_kanban_permissions.kanbanPermissions.column.delete,
|
|
1041
|
+
facts: async ({ input }) => {
|
|
1042
|
+
const snapshot = await loadColumnAuthorization(adapter, input.id);
|
|
1043
|
+
columnSnapshots.set(input, snapshot);
|
|
1044
|
+
return {
|
|
1045
|
+
...boardFacts(snapshot.board),
|
|
1046
|
+
columnId: snapshot.column.id
|
|
1047
|
+
};
|
|
1048
|
+
},
|
|
1049
|
+
execute: async (context) => {
|
|
1050
|
+
const snapshot = columnSnapshots.get(context.input);
|
|
1051
|
+
if (!snapshot) throw staleStateError();
|
|
1052
|
+
requireAtomicTransactions(adapter);
|
|
1053
|
+
return adapter.transaction(async (tx) => {
|
|
1054
|
+
await verifyColumnAuthorization(tx, snapshot);
|
|
1055
|
+
const claims = await claimColumnAuthorization(tx, snapshot);
|
|
1056
|
+
await runDomainHook(
|
|
1057
|
+
() => hooks?.onBeforeDeleteColumn?.(
|
|
1058
|
+
context.input.id,
|
|
1059
|
+
hookContext(context, {
|
|
1060
|
+
params: { id: context.input.id }
|
|
1061
|
+
})
|
|
1062
|
+
),
|
|
1063
|
+
"DELETE_COLUMN_REJECTED"
|
|
1064
|
+
);
|
|
1065
|
+
const deleted = await tx.deleteMany({
|
|
1066
|
+
model: "kanbanColumn",
|
|
1067
|
+
where: columnWhere({
|
|
1068
|
+
...snapshot.column,
|
|
1069
|
+
updatedAt: claims.columnClaimedAt
|
|
1070
|
+
})
|
|
1071
|
+
});
|
|
1072
|
+
if (!didAffectRow(deleted, snapshot.column.id)) {
|
|
1073
|
+
throw staleStateError();
|
|
1074
|
+
}
|
|
1075
|
+
await restoreSnapshot(
|
|
1076
|
+
tx,
|
|
1077
|
+
"kanbanBoard",
|
|
1078
|
+
snapshot.board,
|
|
1079
|
+
claims.boardClaimedAt
|
|
1080
|
+
);
|
|
1081
|
+
return { success: true };
|
|
1082
|
+
});
|
|
1083
|
+
},
|
|
1084
|
+
after: async (context) => {
|
|
1085
|
+
await hooks?.onAfterDeleteColumn?.(
|
|
1086
|
+
context.input.id,
|
|
1087
|
+
hookContext(context, { params: { id: context.input.id } })
|
|
1088
|
+
);
|
|
1089
|
+
},
|
|
1090
|
+
onError: ({ error }) => markMemoryRollback(adapter, error)
|
|
1091
|
+
});
|
|
1092
|
+
const reorderColumns = api.defineOperation({
|
|
1093
|
+
input: schemas.reorderColumnsSchema,
|
|
1094
|
+
permission: plugins_kanban_permissions.kanbanPermissions.column.reorder,
|
|
1095
|
+
facts: async ({ input }) => {
|
|
1096
|
+
const board = await findBoard(adapter, input.boardId);
|
|
1097
|
+
if (!board) throw boardNotFoundError();
|
|
1098
|
+
const columns = await listColumns(adapter, board.id);
|
|
1099
|
+
if (!sameIdSet(
|
|
1100
|
+
input.columnIds,
|
|
1101
|
+
columns.map((column) => column.id)
|
|
1102
|
+
)) {
|
|
1103
|
+
throw invalidColumnSetError();
|
|
1104
|
+
}
|
|
1105
|
+
const snapshot = {
|
|
1106
|
+
board: boardSnapshot(board),
|
|
1107
|
+
columns: columns.map(columnSnapshot)
|
|
1108
|
+
};
|
|
1109
|
+
columnReorderSnapshots.set(input, snapshot);
|
|
1110
|
+
return boardFacts(snapshot.board);
|
|
1111
|
+
},
|
|
1112
|
+
execute: async (context) => {
|
|
1113
|
+
const snapshot = columnReorderSnapshots.get(context.input);
|
|
1114
|
+
if (!snapshot) throw staleStateError();
|
|
1115
|
+
requireAtomicTransactions(adapter);
|
|
1116
|
+
return adapter.transaction(async (tx) => {
|
|
1117
|
+
await verifyBoard(tx, snapshot.board);
|
|
1118
|
+
const current = (await listColumns(tx, snapshot.board.id)).map(
|
|
1119
|
+
columnSnapshot
|
|
1120
|
+
);
|
|
1121
|
+
if (!sameSnapshotSet(current, snapshot.columns, sameColumnSnapshots)) {
|
|
1122
|
+
throw staleStateError();
|
|
1123
|
+
}
|
|
1124
|
+
const boardClaimedAt = await claimSnapshot(
|
|
1125
|
+
tx,
|
|
1126
|
+
"kanbanBoard",
|
|
1127
|
+
snapshot.board
|
|
1128
|
+
);
|
|
1129
|
+
const claims = /* @__PURE__ */ new Map();
|
|
1130
|
+
for (const column of snapshot.columns) {
|
|
1131
|
+
claims.set(
|
|
1132
|
+
column.id,
|
|
1133
|
+
await claimSnapshot(tx, "kanbanColumn", column)
|
|
1134
|
+
);
|
|
1135
|
+
}
|
|
1136
|
+
for (const [order, columnId] of context.input.columnIds.entries()) {
|
|
1137
|
+
await runDomainHook(
|
|
1138
|
+
() => hooks?.onBeforeUpdateColumn?.(
|
|
1139
|
+
columnId,
|
|
1140
|
+
{ id: columnId, order },
|
|
1141
|
+
hookContext(context, { body: context.input })
|
|
1142
|
+
),
|
|
1143
|
+
"REORDER_COLUMNS_REJECTED"
|
|
1144
|
+
);
|
|
1145
|
+
}
|
|
1146
|
+
const updated = [];
|
|
1147
|
+
for (const [order, columnId] of context.input.columnIds.entries()) {
|
|
1148
|
+
const original = snapshot.columns.find(
|
|
1149
|
+
(column2) => column2.id === columnId
|
|
1150
|
+
);
|
|
1151
|
+
const claimedAt = claims.get(columnId);
|
|
1152
|
+
if (!original || !claimedAt) throw staleStateError();
|
|
1153
|
+
const matched = await tx.updateMany({
|
|
1154
|
+
model: "kanbanColumn",
|
|
1155
|
+
where: columnWhere({ ...original, updatedAt: claimedAt }),
|
|
1156
|
+
update: { order, updatedAt: nextSnapshotDate(claimedAt) }
|
|
1157
|
+
});
|
|
1158
|
+
if (!didAffectRow(matched, columnId)) throw staleStateError();
|
|
1159
|
+
const column = await findColumn(tx, columnId);
|
|
1160
|
+
if (!column) throw columnNotFoundError();
|
|
1161
|
+
updated.push(serializeBareColumn(column));
|
|
1162
|
+
}
|
|
1163
|
+
await restoreSnapshot(
|
|
1164
|
+
tx,
|
|
1165
|
+
"kanbanBoard",
|
|
1166
|
+
snapshot.board,
|
|
1167
|
+
boardClaimedAt
|
|
1168
|
+
);
|
|
1169
|
+
const result = { success: true };
|
|
1170
|
+
reorderedColumns.set(result, updated);
|
|
1171
|
+
return result;
|
|
1172
|
+
});
|
|
1173
|
+
},
|
|
1174
|
+
after: async (context) => {
|
|
1175
|
+
for (const column of reorderedColumns.get(context.result) ?? []) {
|
|
1176
|
+
await hooks?.onAfterUpdateColumn?.(
|
|
1177
|
+
column,
|
|
1178
|
+
hookContext(context, { body: context.input })
|
|
1179
|
+
);
|
|
1180
|
+
}
|
|
1181
|
+
},
|
|
1182
|
+
onError: ({ error }) => markMemoryRollback(adapter, error)
|
|
1183
|
+
});
|
|
1184
|
+
const createTask = api.defineOperation({
|
|
1185
|
+
input: schemas.createTaskSchema,
|
|
1186
|
+
permission: plugins_kanban_permissions.kanbanPermissions.task.create,
|
|
1187
|
+
facts: async ({ input }) => {
|
|
1188
|
+
const snapshot = await loadColumnAuthorization(adapter, input.columnId);
|
|
1189
|
+
columnSnapshots.set(input, snapshot);
|
|
1190
|
+
return {
|
|
1191
|
+
...boardFacts(snapshot.board),
|
|
1192
|
+
columnId: snapshot.column.id
|
|
1193
|
+
};
|
|
1194
|
+
},
|
|
1195
|
+
execute: async (context) => {
|
|
1196
|
+
const snapshot = columnSnapshots.get(context.input);
|
|
1197
|
+
if (!snapshot) throw staleStateError();
|
|
1198
|
+
requireAtomicTransactions(adapter);
|
|
1199
|
+
return adapter.transaction(async (tx) => {
|
|
1200
|
+
await verifyColumnAuthorization(tx, snapshot);
|
|
1201
|
+
const claims = await claimColumnAuthorization(tx, snapshot);
|
|
1202
|
+
await runDomainHook(
|
|
1203
|
+
() => hooks?.onBeforeCreateTask?.(
|
|
1204
|
+
{ ...context.input },
|
|
1205
|
+
hookContext(context, { body: context.input })
|
|
1206
|
+
),
|
|
1207
|
+
"CREATE_TASK_REJECTED"
|
|
1208
|
+
);
|
|
1209
|
+
const existing = await listTasks(tx, snapshot.column.id);
|
|
1210
|
+
const nextOrder = existing.length === 0 ? 0 : Math.max(...existing.map((task2) => task2.order)) + 1;
|
|
1211
|
+
const now = /* @__PURE__ */ new Date();
|
|
1212
|
+
const { completedAt, ...persistenceInput } = context.input;
|
|
1213
|
+
const task = await tx.create({
|
|
1214
|
+
model: "kanbanTask",
|
|
1215
|
+
data: {
|
|
1216
|
+
...persistenceInput,
|
|
1217
|
+
priority: context.input.priority ?? "MEDIUM",
|
|
1218
|
+
order: context.input.order ?? nextOrder,
|
|
1219
|
+
assigneeId: context.input.assigneeId ?? void 0,
|
|
1220
|
+
isArchived: context.input.isArchived ?? false,
|
|
1221
|
+
...completedAt ? { completedAt: new Date(completedAt) } : {},
|
|
1222
|
+
createdAt: now,
|
|
1223
|
+
updatedAt: now
|
|
1224
|
+
}
|
|
1225
|
+
});
|
|
1226
|
+
await restoreColumnAuthorization(tx, snapshot, claims);
|
|
1227
|
+
return operationTask(task);
|
|
1228
|
+
});
|
|
1229
|
+
},
|
|
1230
|
+
after: async (context) => {
|
|
1231
|
+
await hooks?.onAfterCreateTask?.(
|
|
1232
|
+
context.result,
|
|
1233
|
+
hookContext(context, { body: context.input })
|
|
1234
|
+
);
|
|
1235
|
+
},
|
|
1236
|
+
onError: ({ error }) => markMemoryRollback(adapter, error)
|
|
1237
|
+
});
|
|
1238
|
+
const updateTask = api.defineOperation({
|
|
1239
|
+
input: UpdateTaskOperationInputSchema,
|
|
1240
|
+
permission: plugins_kanban_permissions.kanbanPermissions.task.update,
|
|
1241
|
+
facts: async ({ input }) => {
|
|
1242
|
+
const snapshot = await loadTaskAuthorization(adapter, input.id);
|
|
1243
|
+
taskSnapshots.set(input, snapshot);
|
|
1244
|
+
return taskFacts(snapshot);
|
|
1245
|
+
},
|
|
1246
|
+
additionalPermissions: async ({ input }) => {
|
|
1247
|
+
const snapshot = taskSnapshots.get(input);
|
|
1248
|
+
if (!snapshot) throw staleStateError();
|
|
1249
|
+
const targetColumnId = input.data.columnId ?? snapshot.column.id;
|
|
1250
|
+
const changesColumn = targetColumnId !== snapshot.column.id;
|
|
1251
|
+
const changesOrder = input.data.order !== void 0;
|
|
1252
|
+
if (!changesColumn && !changesOrder) return [];
|
|
1253
|
+
const moveSnapshot = await loadMoveSnapshot(
|
|
1254
|
+
adapter,
|
|
1255
|
+
snapshot,
|
|
1256
|
+
targetColumnId,
|
|
1257
|
+
input.data.order ?? Number.MAX_SAFE_INTEGER
|
|
1258
|
+
);
|
|
1259
|
+
updateTaskMoveSnapshots.set(input, moveSnapshot);
|
|
1260
|
+
return [
|
|
1261
|
+
plugins_kanban_permissions.kanbanPermissions.task.move({
|
|
1262
|
+
...taskFacts(moveSnapshot),
|
|
1263
|
+
targetColumnId: moveSnapshot.targetColumn.id
|
|
1264
|
+
})
|
|
1265
|
+
];
|
|
1266
|
+
},
|
|
1267
|
+
execute: async (context) => {
|
|
1268
|
+
const snapshot = taskSnapshots.get(context.input);
|
|
1269
|
+
if (!snapshot) throw staleStateError();
|
|
1270
|
+
requireAtomicTransactions(adapter);
|
|
1271
|
+
const {
|
|
1272
|
+
columnId: _columnId,
|
|
1273
|
+
order: _order,
|
|
1274
|
+
completedAt,
|
|
1275
|
+
...operationTaskData
|
|
1276
|
+
} = context.input.data;
|
|
1277
|
+
const taskData = {
|
|
1278
|
+
...operationTaskData,
|
|
1279
|
+
...completedAt ? { completedAt: new Date(completedAt) } : {}
|
|
1280
|
+
};
|
|
1281
|
+
const moveSnapshot = updateTaskMoveSnapshots.get(context.input);
|
|
1282
|
+
if (moveSnapshot) {
|
|
1283
|
+
return adapter.transaction(async (tx) => {
|
|
1284
|
+
await verifyMoveSnapshot(tx, moveSnapshot);
|
|
1285
|
+
const claims = await claimMoveSnapshot(tx, moveSnapshot);
|
|
1286
|
+
await runDomainHook(
|
|
1287
|
+
() => hooks?.onBeforeUpdateTask?.(
|
|
1288
|
+
context.input.id,
|
|
1289
|
+
{ ...context.input.data, id: context.input.id },
|
|
1290
|
+
hookContext(context, {
|
|
1291
|
+
body: context.input.data,
|
|
1292
|
+
params: { id: context.input.id }
|
|
1293
|
+
})
|
|
1294
|
+
),
|
|
1295
|
+
"UPDATE_TASK_REJECTED"
|
|
1296
|
+
);
|
|
1297
|
+
return operationTask(
|
|
1298
|
+
await applyTaskMove(tx, moveSnapshot, claims, taskData)
|
|
1299
|
+
);
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
return adapter.transaction(async (tx) => {
|
|
1303
|
+
await verifyTaskAuthorization(tx, snapshot);
|
|
1304
|
+
const claims = await claimColumnAuthorization(tx, snapshot);
|
|
1305
|
+
const taskClaimedAt = await claimSnapshot(
|
|
1306
|
+
tx,
|
|
1307
|
+
"kanbanTask",
|
|
1308
|
+
snapshot.task
|
|
1309
|
+
);
|
|
1310
|
+
await runDomainHook(
|
|
1311
|
+
() => hooks?.onBeforeUpdateTask?.(
|
|
1312
|
+
context.input.id,
|
|
1313
|
+
{ ...context.input.data, id: context.input.id },
|
|
1314
|
+
hookContext(context, {
|
|
1315
|
+
body: context.input.data,
|
|
1316
|
+
params: { id: context.input.id }
|
|
1317
|
+
})
|
|
1318
|
+
),
|
|
1319
|
+
"UPDATE_TASK_REJECTED"
|
|
1320
|
+
);
|
|
1321
|
+
const matched = await tx.updateMany({
|
|
1322
|
+
model: "kanbanTask",
|
|
1323
|
+
where: taskWhere({
|
|
1324
|
+
...snapshot.task,
|
|
1325
|
+
updatedAt: taskClaimedAt
|
|
1326
|
+
}),
|
|
1327
|
+
update: {
|
|
1328
|
+
...taskData,
|
|
1329
|
+
updatedAt: nextSnapshotDate(taskClaimedAt)
|
|
1330
|
+
}
|
|
1331
|
+
});
|
|
1332
|
+
if (!didAffectRow(matched, snapshot.task.id)) {
|
|
1333
|
+
throw staleStateError();
|
|
1334
|
+
}
|
|
1335
|
+
await restoreColumnAuthorization(tx, snapshot, claims);
|
|
1336
|
+
const updated = await findTask(tx, snapshot.task.id);
|
|
1337
|
+
if (!updated) throw taskNotFoundError();
|
|
1338
|
+
return operationTask(updated);
|
|
1339
|
+
});
|
|
1340
|
+
},
|
|
1341
|
+
after: async (context) => {
|
|
1342
|
+
await hooks?.onAfterUpdateTask?.(
|
|
1343
|
+
context.result,
|
|
1344
|
+
hookContext(context, {
|
|
1345
|
+
body: context.input.data,
|
|
1346
|
+
params: { id: context.input.id }
|
|
1347
|
+
})
|
|
1348
|
+
);
|
|
1349
|
+
},
|
|
1350
|
+
onError: ({ error }) => markMemoryRollback(adapter, error)
|
|
1351
|
+
});
|
|
1352
|
+
const deleteTask = api.defineOperation({
|
|
1353
|
+
input: TaskIdOperationInputSchema,
|
|
1354
|
+
permission: plugins_kanban_permissions.kanbanPermissions.task.delete,
|
|
1355
|
+
facts: async ({ input }) => {
|
|
1356
|
+
const snapshot = await loadTaskAuthorization(adapter, input.id);
|
|
1357
|
+
taskSnapshots.set(input, snapshot);
|
|
1358
|
+
return taskFacts(snapshot);
|
|
1359
|
+
},
|
|
1360
|
+
execute: async (context) => {
|
|
1361
|
+
const snapshot = taskSnapshots.get(context.input);
|
|
1362
|
+
if (!snapshot) throw staleStateError();
|
|
1363
|
+
requireAtomicTransactions(adapter);
|
|
1364
|
+
return adapter.transaction(async (tx) => {
|
|
1365
|
+
await verifyTaskAuthorization(tx, snapshot);
|
|
1366
|
+
const claims = await claimColumnAuthorization(tx, snapshot);
|
|
1367
|
+
const taskClaimedAt = await claimSnapshot(
|
|
1368
|
+
tx,
|
|
1369
|
+
"kanbanTask",
|
|
1370
|
+
snapshot.task
|
|
1371
|
+
);
|
|
1372
|
+
await runDomainHook(
|
|
1373
|
+
() => hooks?.onBeforeDeleteTask?.(
|
|
1374
|
+
context.input.id,
|
|
1375
|
+
hookContext(context, {
|
|
1376
|
+
params: { id: context.input.id }
|
|
1377
|
+
})
|
|
1378
|
+
),
|
|
1379
|
+
"DELETE_TASK_REJECTED"
|
|
1380
|
+
);
|
|
1381
|
+
const deleted = await tx.deleteMany({
|
|
1382
|
+
model: "kanbanTask",
|
|
1383
|
+
where: taskWhere({
|
|
1384
|
+
...snapshot.task,
|
|
1385
|
+
updatedAt: taskClaimedAt
|
|
1386
|
+
})
|
|
1387
|
+
});
|
|
1388
|
+
if (!didAffectRow(deleted, snapshot.task.id)) {
|
|
1389
|
+
throw staleStateError();
|
|
1390
|
+
}
|
|
1391
|
+
await restoreColumnAuthorization(tx, snapshot, claims);
|
|
1392
|
+
return { success: true };
|
|
1393
|
+
});
|
|
1394
|
+
},
|
|
1395
|
+
after: async (context) => {
|
|
1396
|
+
await hooks?.onAfterDeleteTask?.(
|
|
1397
|
+
context.input.id,
|
|
1398
|
+
hookContext(context, { params: { id: context.input.id } })
|
|
1399
|
+
);
|
|
1400
|
+
},
|
|
1401
|
+
onError: ({ error }) => markMemoryRollback(adapter, error)
|
|
1402
|
+
});
|
|
1403
|
+
const moveTask = api.defineOperation({
|
|
1404
|
+
input: schemas.moveTaskSchema,
|
|
1405
|
+
permission: plugins_kanban_permissions.kanbanPermissions.task.move,
|
|
1406
|
+
facts: async ({ input }) => {
|
|
1407
|
+
const primary = await loadTaskAuthorization(adapter, input.taskId);
|
|
1408
|
+
const snapshot = await loadMoveSnapshot(
|
|
1409
|
+
adapter,
|
|
1410
|
+
primary,
|
|
1411
|
+
input.targetColumnId,
|
|
1412
|
+
input.targetOrder
|
|
1413
|
+
);
|
|
1414
|
+
taskMoveSnapshots.set(input, snapshot);
|
|
1415
|
+
return {
|
|
1416
|
+
...taskFacts(snapshot),
|
|
1417
|
+
targetColumnId: snapshot.targetColumn.id
|
|
1418
|
+
};
|
|
1419
|
+
},
|
|
1420
|
+
execute: async (context) => {
|
|
1421
|
+
const snapshot = taskMoveSnapshots.get(context.input);
|
|
1422
|
+
if (!snapshot) throw staleStateError();
|
|
1423
|
+
requireAtomicTransactions(adapter);
|
|
1424
|
+
return adapter.transaction(async (tx) => {
|
|
1425
|
+
await verifyMoveSnapshot(tx, snapshot);
|
|
1426
|
+
const claims = await claimMoveSnapshot(tx, snapshot);
|
|
1427
|
+
await runDomainHook(
|
|
1428
|
+
() => hooks?.onBeforeUpdateTask?.(
|
|
1429
|
+
context.input.taskId,
|
|
1430
|
+
{
|
|
1431
|
+
id: context.input.taskId,
|
|
1432
|
+
columnId: context.input.targetColumnId,
|
|
1433
|
+
order: context.input.targetOrder
|
|
1434
|
+
},
|
|
1435
|
+
hookContext(context, { body: context.input })
|
|
1436
|
+
),
|
|
1437
|
+
"MOVE_TASK_REJECTED"
|
|
1438
|
+
);
|
|
1439
|
+
return operationTask(await applyTaskMove(tx, snapshot, claims, {}));
|
|
1440
|
+
});
|
|
1441
|
+
},
|
|
1442
|
+
after: async (context) => {
|
|
1443
|
+
await hooks?.onAfterUpdateTask?.(
|
|
1444
|
+
context.result,
|
|
1445
|
+
hookContext(context, { body: context.input })
|
|
1446
|
+
);
|
|
1447
|
+
},
|
|
1448
|
+
onError: ({ error }) => markMemoryRollback(adapter, error)
|
|
1449
|
+
});
|
|
1450
|
+
const reorderTasks = api.defineOperation({
|
|
1451
|
+
input: schemas.reorderTasksSchema,
|
|
1452
|
+
permission: plugins_kanban_permissions.kanbanPermissions.task.reorder,
|
|
1453
|
+
facts: async ({ input }) => {
|
|
1454
|
+
const parent = await loadColumnAuthorization(adapter, input.columnId);
|
|
1455
|
+
const tasks = await listTasks(adapter, input.columnId);
|
|
1456
|
+
if (!sameIdSet(
|
|
1457
|
+
input.taskIds,
|
|
1458
|
+
tasks.map((task) => task.id)
|
|
1459
|
+
)) {
|
|
1460
|
+
throw invalidTaskSetError();
|
|
1461
|
+
}
|
|
1462
|
+
const snapshot = { ...parent, tasks: tasks.map(taskSnapshot) };
|
|
1463
|
+
taskReorderSnapshots.set(input, snapshot);
|
|
1464
|
+
return {
|
|
1465
|
+
...boardFacts(parent.board),
|
|
1466
|
+
columnId: parent.column.id
|
|
1467
|
+
};
|
|
1468
|
+
},
|
|
1469
|
+
execute: async (context) => {
|
|
1470
|
+
const snapshot = taskReorderSnapshots.get(context.input);
|
|
1471
|
+
if (!snapshot) throw staleStateError();
|
|
1472
|
+
requireAtomicTransactions(adapter);
|
|
1473
|
+
return adapter.transaction(async (tx) => {
|
|
1474
|
+
await verifyColumnAuthorization(tx, snapshot);
|
|
1475
|
+
const current = (await listTasks(tx, snapshot.column.id)).map(
|
|
1476
|
+
taskSnapshot
|
|
1477
|
+
);
|
|
1478
|
+
if (!sameSnapshotSet(current, snapshot.tasks, sameTaskSnapshots)) {
|
|
1479
|
+
throw staleStateError();
|
|
1480
|
+
}
|
|
1481
|
+
const parentClaims = await claimColumnAuthorization(tx, snapshot);
|
|
1482
|
+
const taskClaims = /* @__PURE__ */ new Map();
|
|
1483
|
+
for (const task of snapshot.tasks) {
|
|
1484
|
+
taskClaims.set(task.id, await claimSnapshot(tx, "kanbanTask", task));
|
|
1485
|
+
}
|
|
1486
|
+
for (const [order, taskId] of context.input.taskIds.entries()) {
|
|
1487
|
+
await runDomainHook(
|
|
1488
|
+
() => hooks?.onBeforeUpdateTask?.(
|
|
1489
|
+
taskId,
|
|
1490
|
+
{ id: taskId, order },
|
|
1491
|
+
hookContext(context, { body: context.input })
|
|
1492
|
+
),
|
|
1493
|
+
"REORDER_TASKS_REJECTED"
|
|
1494
|
+
);
|
|
1495
|
+
}
|
|
1496
|
+
const updated = [];
|
|
1497
|
+
for (const [order, taskId] of context.input.taskIds.entries()) {
|
|
1498
|
+
const original = snapshot.tasks.find((task2) => task2.id === taskId);
|
|
1499
|
+
const claimedAt = taskClaims.get(taskId);
|
|
1500
|
+
if (!original || !claimedAt) throw staleStateError();
|
|
1501
|
+
const matched = await tx.updateMany({
|
|
1502
|
+
model: "kanbanTask",
|
|
1503
|
+
where: taskWhere({ ...original, updatedAt: claimedAt }),
|
|
1504
|
+
update: { order, updatedAt: nextSnapshotDate(claimedAt) }
|
|
1505
|
+
});
|
|
1506
|
+
if (!didAffectRow(matched, taskId)) throw staleStateError();
|
|
1507
|
+
const task = await findTask(tx, taskId);
|
|
1508
|
+
if (!task) throw taskNotFoundError();
|
|
1509
|
+
updated.push(operationTask(task));
|
|
1510
|
+
}
|
|
1511
|
+
await restoreColumnAuthorization(tx, snapshot, parentClaims);
|
|
1512
|
+
const result = { success: true };
|
|
1513
|
+
reorderedTasks.set(result, updated);
|
|
1514
|
+
return result;
|
|
1515
|
+
});
|
|
1516
|
+
},
|
|
1517
|
+
after: async (context) => {
|
|
1518
|
+
for (const task of reorderedTasks.get(context.result) ?? []) {
|
|
1519
|
+
await hooks?.onAfterUpdateTask?.(
|
|
1520
|
+
task,
|
|
1521
|
+
hookContext(context, { body: context.input })
|
|
1522
|
+
);
|
|
1523
|
+
}
|
|
1524
|
+
},
|
|
1525
|
+
onError: ({ error }) => markMemoryRollback(adapter, error)
|
|
1526
|
+
});
|
|
1527
|
+
return {
|
|
1528
|
+
listBoards,
|
|
1529
|
+
getBoard,
|
|
1530
|
+
createBoard,
|
|
1531
|
+
updateBoard,
|
|
1532
|
+
deleteBoard,
|
|
1533
|
+
createColumn,
|
|
1534
|
+
updateColumn,
|
|
1535
|
+
deleteColumn,
|
|
1536
|
+
reorderColumns,
|
|
1537
|
+
createTask,
|
|
1538
|
+
updateTask,
|
|
1539
|
+
deleteTask,
|
|
1540
|
+
moveTask,
|
|
1541
|
+
reorderTasks
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
exports.BoardIdOperationInputSchema = BoardIdOperationInputSchema;
|
|
1546
|
+
exports.ColumnIdOperationInputSchema = ColumnIdOperationInputSchema;
|
|
1547
|
+
exports.KanbanOperationError = KanbanOperationError;
|
|
1548
|
+
exports.TaskIdOperationInputSchema = TaskIdOperationInputSchema;
|
|
1549
|
+
exports.UpdateBoardOperationInputSchema = UpdateBoardOperationInputSchema;
|
|
1550
|
+
exports.UpdateColumnOperationInputSchema = UpdateColumnOperationInputSchema;
|
|
1551
|
+
exports.UpdateTaskOperationInputSchema = UpdateTaskOperationInputSchema;
|
|
1552
|
+
exports.createKanbanOperations = createKanbanOperations;
|