@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,1600 @@
|
|
|
1
|
+
import { createMemoryAdapter } from "@btst/adapter-memory";
|
|
2
|
+
import { type DBAdapter, defineDb, type DatabaseDefinition } from "@btst/db";
|
|
3
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { createBackendStack } from "../../../api";
|
|
7
|
+
import { defineAuthorization } from "../../../authorization";
|
|
8
|
+
import {
|
|
9
|
+
createServerAuth,
|
|
10
|
+
type ServerAuth,
|
|
11
|
+
} from "../../../authorization/server";
|
|
12
|
+
import {
|
|
13
|
+
FORM_BUILDER_LIFECYCLE_HOOK_MIGRATIONS,
|
|
14
|
+
FORM_QUERY_KEYS,
|
|
15
|
+
formBuilderBackendPlugin,
|
|
16
|
+
} from "../api";
|
|
17
|
+
import { formBuilderPermissions } from "../permissions";
|
|
18
|
+
import type { Form, FormBuilderBackendHooks, FormSubmission } from "../types";
|
|
19
|
+
|
|
20
|
+
const rawMemoryAdapter = (db: DatabaseDefinition) =>
|
|
21
|
+
createMemoryAdapter(db)({});
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The published memory adapter rolls back by restoring its whole shared data
|
|
25
|
+
* structure and does not isolate concurrent calls. Wrap every public adapter
|
|
26
|
+
* call in the same queue so mutation tests exercise real transaction isolation.
|
|
27
|
+
*/
|
|
28
|
+
function serializedMemoryAdapter(db: DatabaseDefinition): DBAdapter {
|
|
29
|
+
const adapter = rawMemoryAdapter(db);
|
|
30
|
+
let tail = Promise.resolve();
|
|
31
|
+
|
|
32
|
+
const withLock = async <T>(run: () => Promise<T>): Promise<T> => {
|
|
33
|
+
let release = () => {};
|
|
34
|
+
const previous = tail;
|
|
35
|
+
tail = new Promise<void>((resolve) => {
|
|
36
|
+
release = resolve;
|
|
37
|
+
});
|
|
38
|
+
await previous;
|
|
39
|
+
try {
|
|
40
|
+
return await run();
|
|
41
|
+
} finally {
|
|
42
|
+
release();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
...adapter,
|
|
48
|
+
id: "serialized-memory-test",
|
|
49
|
+
create: ((input) =>
|
|
50
|
+
withLock(() => adapter.create(input))) as DBAdapter["create"],
|
|
51
|
+
findOne: ((input) =>
|
|
52
|
+
withLock(() => adapter.findOne(input))) as DBAdapter["findOne"],
|
|
53
|
+
findMany: ((input) =>
|
|
54
|
+
withLock(() => adapter.findMany(input))) as DBAdapter["findMany"],
|
|
55
|
+
count: (input) => withLock(() => adapter.count(input)),
|
|
56
|
+
update: ((input) =>
|
|
57
|
+
withLock(() => adapter.update(input))) as DBAdapter["update"],
|
|
58
|
+
updateMany: (input) => withLock(() => adapter.updateMany(input)),
|
|
59
|
+
delete: ((input) =>
|
|
60
|
+
withLock(() => adapter.delete(input))) as DBAdapter["delete"],
|
|
61
|
+
deleteMany: (input) => withLock(() => adapter.deleteMany(input)),
|
|
62
|
+
consumeOne: ((input) =>
|
|
63
|
+
withLock(() => adapter.consumeOne(input))) as DBAdapter["consumeOne"],
|
|
64
|
+
transaction: ((callback) =>
|
|
65
|
+
withLock(() =>
|
|
66
|
+
adapter.transaction(callback),
|
|
67
|
+
)) as DBAdapter["transaction"],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const memoryAdapter = serializedMemoryAdapter;
|
|
72
|
+
|
|
73
|
+
describe("Form Builder authorization inventory", () => {
|
|
74
|
+
it("records every removed lifecycle spelling", () => {
|
|
75
|
+
expect(FORM_BUILDER_LIFECYCLE_HOOK_MIGRATIONS).toEqual({
|
|
76
|
+
onBeforeFormCreated: "onBeforeCreateForm",
|
|
77
|
+
onAfterFormCreated: "onAfterCreateForm",
|
|
78
|
+
onBeforeFormUpdated: "onBeforeUpdateForm",
|
|
79
|
+
onAfterFormUpdated: "onAfterUpdateForm",
|
|
80
|
+
onBeforeFormDeleted: "onBeforeDeleteForm",
|
|
81
|
+
onAfterFormDeleted: "onAfterDeleteForm",
|
|
82
|
+
onSubmissionError: "onErrorSubmission",
|
|
83
|
+
onBeforeSubmissionDeleted: "onBeforeDeleteSubmission",
|
|
84
|
+
onAfterSubmissionDeleted: "onAfterDeleteSubmission",
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("covers every maintained HTTP and programmatic operation with a stable descriptor", () => {
|
|
89
|
+
const plugin = formBuilderBackendPlugin();
|
|
90
|
+
const adapter = memoryAdapter(defineDb({}).use(plugin.dbPlugin));
|
|
91
|
+
const operations = plugin.operations?.(adapter);
|
|
92
|
+
|
|
93
|
+
expect(Object.keys(operations ?? {}).sort()).toEqual([
|
|
94
|
+
"createForm",
|
|
95
|
+
"deleteForm",
|
|
96
|
+
"deleteSubmission",
|
|
97
|
+
"getFormById",
|
|
98
|
+
"getFormBySlug",
|
|
99
|
+
"getFormForUpdate",
|
|
100
|
+
"getSubmission",
|
|
101
|
+
"listForms",
|
|
102
|
+
"listSubmissions",
|
|
103
|
+
"submitForm",
|
|
104
|
+
"updateForm",
|
|
105
|
+
]);
|
|
106
|
+
expect(
|
|
107
|
+
Object.fromEntries(
|
|
108
|
+
Object.entries(operations ?? {}).map(([key, operation]) => [
|
|
109
|
+
key,
|
|
110
|
+
operation.permission.id,
|
|
111
|
+
]),
|
|
112
|
+
),
|
|
113
|
+
).toEqual({
|
|
114
|
+
listForms: "forms:form.read",
|
|
115
|
+
getFormBySlug: "forms:form.render",
|
|
116
|
+
getFormById: "forms:form.read",
|
|
117
|
+
getFormForUpdate: "forms:form.update",
|
|
118
|
+
createForm: "forms:form.create",
|
|
119
|
+
updateForm: "forms:form.update",
|
|
120
|
+
deleteForm: "forms:form.delete",
|
|
121
|
+
submitForm: "forms:submission.create",
|
|
122
|
+
listSubmissions: "forms:submission.read",
|
|
123
|
+
getSubmission: "forms:submission.read",
|
|
124
|
+
deleteSubmission: "forms:submission.delete",
|
|
125
|
+
});
|
|
126
|
+
expect(
|
|
127
|
+
formBuilderPermissions.form.read({ scope: "collection" }),
|
|
128
|
+
).toMatchObject({ id: "forms:form.read" });
|
|
129
|
+
expect(formBuilderPermissions.form.create()).toMatchObject({
|
|
130
|
+
id: "forms:form.create",
|
|
131
|
+
});
|
|
132
|
+
expect(
|
|
133
|
+
formBuilderPermissions.submission.delete({
|
|
134
|
+
formId: "form-1",
|
|
135
|
+
submissionId: "submission-1",
|
|
136
|
+
exists: true,
|
|
137
|
+
}),
|
|
138
|
+
).toMatchObject({ id: "forms:submission.delete" });
|
|
139
|
+
expect(() =>
|
|
140
|
+
formBuilderPermissions.form.update({
|
|
141
|
+
formId: "form-1",
|
|
142
|
+
// @ts-expect-error Form update facts require the catalog's status vocabulary.
|
|
143
|
+
status: "draft",
|
|
144
|
+
}),
|
|
145
|
+
).toThrow();
|
|
146
|
+
expect(() =>
|
|
147
|
+
// @ts-expect-error Submission delete facts must explicitly declare existence.
|
|
148
|
+
formBuilderPermissions.submission.delete({
|
|
149
|
+
formId: "form-1",
|
|
150
|
+
submissionId: "submission-1",
|
|
151
|
+
}),
|
|
152
|
+
).toThrow();
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const authorization = defineAuthorization({
|
|
157
|
+
identity: z.object({
|
|
158
|
+
id: z.string(),
|
|
159
|
+
role: z.enum(["user", "admin"]),
|
|
160
|
+
}),
|
|
161
|
+
permissions: [formBuilderPermissions] as const,
|
|
162
|
+
rules: ({ forms }) => [
|
|
163
|
+
forms.form.read.when(
|
|
164
|
+
({ identity, facts }) =>
|
|
165
|
+
identity?.role === "admin" ||
|
|
166
|
+
(facts.scope === "record" && identity?.id === facts.ownerId),
|
|
167
|
+
),
|
|
168
|
+
forms.form.render.allow(),
|
|
169
|
+
forms.form.create.when(({ identity }) => identity?.role === "admin"),
|
|
170
|
+
forms.form.update.when(
|
|
171
|
+
({ identity, facts }) =>
|
|
172
|
+
identity?.role === "admin" || identity?.id === facts.ownerId,
|
|
173
|
+
),
|
|
174
|
+
forms.form.delete.when(
|
|
175
|
+
({ identity, facts }) =>
|
|
176
|
+
identity?.role === "admin" || identity?.id === facts.ownerId,
|
|
177
|
+
),
|
|
178
|
+
forms.submission.create.allow(),
|
|
179
|
+
forms.submission.read.when(
|
|
180
|
+
({ identity, facts }) =>
|
|
181
|
+
identity?.role === "admin" ||
|
|
182
|
+
identity?.id === facts.ownerId ||
|
|
183
|
+
(facts.scope === "record" && identity?.id === facts.submittedBy),
|
|
184
|
+
),
|
|
185
|
+
forms.submission.delete.when(
|
|
186
|
+
({ identity, facts }) =>
|
|
187
|
+
identity?.role === "admin" ||
|
|
188
|
+
identity?.id === facts.ownerId ||
|
|
189
|
+
identity?.id === facts.submittedBy,
|
|
190
|
+
),
|
|
191
|
+
],
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
type Identity = { id: string; role: "user" | "admin" };
|
|
195
|
+
|
|
196
|
+
function createAuth(
|
|
197
|
+
getIdentity: (
|
|
198
|
+
request: Request,
|
|
199
|
+
) => Identity | null | Promise<Identity | null> = (request) => {
|
|
200
|
+
const id = request.headers.get("x-user-id");
|
|
201
|
+
const role = request.headers.get("x-user-role");
|
|
202
|
+
if (!id || (role !== "user" && role !== "admin")) return null;
|
|
203
|
+
return { id, role };
|
|
204
|
+
},
|
|
205
|
+
definition = authorization,
|
|
206
|
+
) {
|
|
207
|
+
return createServerAuth({
|
|
208
|
+
authorization: definition,
|
|
209
|
+
getIdentity: ({ request }) => getIdentity(request),
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function makeBackend(options?: {
|
|
214
|
+
hooks?: FormBuilderBackendHooks;
|
|
215
|
+
auth?: ServerAuth<any>;
|
|
216
|
+
adapter?: (db: DatabaseDefinition) => DBAdapter;
|
|
217
|
+
}) {
|
|
218
|
+
return createBackendStack({
|
|
219
|
+
basePath: "/api",
|
|
220
|
+
plugins: {
|
|
221
|
+
formBuilder: formBuilderBackendPlugin({ hooks: options?.hooks }),
|
|
222
|
+
},
|
|
223
|
+
adapter: options?.adapter ?? memoryAdapter,
|
|
224
|
+
...(options?.auth ? { auth: options.auth as never } : {}),
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function request(
|
|
229
|
+
path: string,
|
|
230
|
+
options?: { method?: string; identity?: Identity; body?: unknown },
|
|
231
|
+
) {
|
|
232
|
+
const headers = new Headers();
|
|
233
|
+
if (options?.identity) {
|
|
234
|
+
headers.set("x-user-id", options.identity.id);
|
|
235
|
+
headers.set("x-user-role", options.identity.role);
|
|
236
|
+
}
|
|
237
|
+
if (options?.body !== undefined)
|
|
238
|
+
headers.set("content-type", "application/json");
|
|
239
|
+
return new Request(`http://localhost/api${path}`, {
|
|
240
|
+
method: options?.method ?? "GET",
|
|
241
|
+
headers,
|
|
242
|
+
...(options?.body !== undefined
|
|
243
|
+
? { body: JSON.stringify(options.body) }
|
|
244
|
+
: {}),
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const activeSchema = JSON.stringify({
|
|
249
|
+
type: "object",
|
|
250
|
+
properties: { name: { type: "string" } },
|
|
251
|
+
required: ["name"],
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
async function seedForm(
|
|
255
|
+
backend: ReturnType<typeof makeBackend>,
|
|
256
|
+
overrides: Partial<Form> = {},
|
|
257
|
+
) {
|
|
258
|
+
const now = new Date("2026-01-01T00:00:00.000Z");
|
|
259
|
+
return backend.adapter.create<Form>({
|
|
260
|
+
model: "form",
|
|
261
|
+
data: {
|
|
262
|
+
name: "Contact",
|
|
263
|
+
slug: "contact",
|
|
264
|
+
schema: activeSchema,
|
|
265
|
+
status: "active",
|
|
266
|
+
createdBy: "owner-1",
|
|
267
|
+
createdAt: now,
|
|
268
|
+
updatedAt: now,
|
|
269
|
+
...overrides,
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
async function seedSubmission(
|
|
275
|
+
backend: ReturnType<typeof makeBackend>,
|
|
276
|
+
formId: string,
|
|
277
|
+
overrides: Partial<FormSubmission> = {},
|
|
278
|
+
) {
|
|
279
|
+
return backend.adapter.create<FormSubmission>({
|
|
280
|
+
model: "formSubmission",
|
|
281
|
+
data: {
|
|
282
|
+
formId,
|
|
283
|
+
data: JSON.stringify({ name: "Ada" }),
|
|
284
|
+
submittedBy: "submitter-1",
|
|
285
|
+
submittedAt: new Date("2026-01-02T00:00:00.000Z"),
|
|
286
|
+
...overrides,
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const owner = { id: "owner-1", role: "user" } as const;
|
|
292
|
+
const viewer = { id: "viewer-1", role: "user" } as const;
|
|
293
|
+
const admin = { id: "admin-1", role: "admin" } as const;
|
|
294
|
+
|
|
295
|
+
describe("Form Builder operation-first authorization", () => {
|
|
296
|
+
it("runs every renamed form and submission hook across request and trusted calls", async () => {
|
|
297
|
+
const events: string[] = [];
|
|
298
|
+
const backend = makeBackend({
|
|
299
|
+
auth: createAuth(),
|
|
300
|
+
hooks: {
|
|
301
|
+
onBeforeCreateForm: (data, context) => {
|
|
302
|
+
events.push(`beforeCreate:${context.identity?.id}`);
|
|
303
|
+
return { ...data, name: "Created by hook" };
|
|
304
|
+
},
|
|
305
|
+
onAfterCreateForm: (_form, context) => {
|
|
306
|
+
events.push(`afterCreate:${context.identity?.id}`);
|
|
307
|
+
},
|
|
308
|
+
onBeforeUpdateForm: (_id, data, context) => {
|
|
309
|
+
events.push(`beforeUpdate:${context.identity?.id ?? "trusted"}`);
|
|
310
|
+
return { ...data, name: "Updated by hook" };
|
|
311
|
+
},
|
|
312
|
+
onAfterUpdateForm: (_form, context) => {
|
|
313
|
+
events.push(`afterUpdate:${context.identity?.id ?? "trusted"}`);
|
|
314
|
+
},
|
|
315
|
+
onBeforeSubmission: (_slug, data, context) => {
|
|
316
|
+
events.push(`beforeSubmission:${context.identity?.id ?? "trusted"}`);
|
|
317
|
+
return { ...data, normalized: true };
|
|
318
|
+
},
|
|
319
|
+
onAfterSubmission: (_submission, _form, context) => {
|
|
320
|
+
events.push(`afterSubmission:${context.identity?.id ?? "trusted"}`);
|
|
321
|
+
},
|
|
322
|
+
onErrorSubmission: (_error, _slug, _data, context) => {
|
|
323
|
+
events.push(
|
|
324
|
+
`errorSubmission:${context.request ? "request" : "trusted"}`,
|
|
325
|
+
);
|
|
326
|
+
},
|
|
327
|
+
onBeforeDeleteSubmission: (_id, context) => {
|
|
328
|
+
events.push(`beforeDeleteSubmission:${context.identity?.id}`);
|
|
329
|
+
},
|
|
330
|
+
onAfterDeleteSubmission: (_id, context) => {
|
|
331
|
+
events.push(`afterDeleteSubmission:${context.identity?.id}`);
|
|
332
|
+
},
|
|
333
|
+
onBeforeDeleteForm: (_id, context) => {
|
|
334
|
+
events.push(`beforeDeleteForm:${context.identity?.id ?? "trusted"}`);
|
|
335
|
+
},
|
|
336
|
+
onAfterDeleteForm: (_id, context) => {
|
|
337
|
+
events.push(`afterDeleteForm:${context.identity?.id ?? "trusted"}`);
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
});
|
|
341
|
+
const requested = backend.forRequest(
|
|
342
|
+
request("/lifecycle", { identity: admin }),
|
|
343
|
+
).operations.formBuilder;
|
|
344
|
+
const created = await requested.createForm({
|
|
345
|
+
name: "Original",
|
|
346
|
+
slug: "lifecycle",
|
|
347
|
+
schema: activeSchema,
|
|
348
|
+
status: "active",
|
|
349
|
+
});
|
|
350
|
+
expect(created.name).toBe("Created by hook");
|
|
351
|
+
const updated = await backend.trusted.formBuilder.updateForm({
|
|
352
|
+
id: created.id,
|
|
353
|
+
data: { name: "Original update" },
|
|
354
|
+
});
|
|
355
|
+
expect(updated.name).toBe("Updated by hook");
|
|
356
|
+
|
|
357
|
+
await expect(
|
|
358
|
+
backend
|
|
359
|
+
.forRequest(request("/lifecycle-submit"))
|
|
360
|
+
.operations.formBuilder.submitForm({ slug: created.slug, data: {} }),
|
|
361
|
+
).rejects.toMatchObject({ code: "SUBMISSION_VALIDATION_FAILED" });
|
|
362
|
+
const submission = await backend.trusted.formBuilder.submitForm({
|
|
363
|
+
slug: created.slug,
|
|
364
|
+
data: { name: "Ada" },
|
|
365
|
+
});
|
|
366
|
+
expect(JSON.parse(submission.data)).toMatchObject({ normalized: true });
|
|
367
|
+
await requested.deleteSubmission({
|
|
368
|
+
formId: created.id,
|
|
369
|
+
submissionId: submission.id,
|
|
370
|
+
});
|
|
371
|
+
await backend.trusted.formBuilder.deleteForm({ id: created.id });
|
|
372
|
+
|
|
373
|
+
expect(events).toEqual([
|
|
374
|
+
"beforeCreate:admin-1",
|
|
375
|
+
"afterCreate:admin-1",
|
|
376
|
+
"beforeUpdate:trusted",
|
|
377
|
+
"afterUpdate:trusted",
|
|
378
|
+
"errorSubmission:request",
|
|
379
|
+
"beforeSubmission:trusted",
|
|
380
|
+
"afterSubmission:trusted",
|
|
381
|
+
"beforeDeleteSubmission:admin-1",
|
|
382
|
+
"afterDeleteSubmission:admin-1",
|
|
383
|
+
"beforeDeleteForm:trusted",
|
|
384
|
+
"afterDeleteForm:trusted",
|
|
385
|
+
]);
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
it("preserves permissive compatibility when stack authorization is omitted", async () => {
|
|
389
|
+
const events: string[] = [];
|
|
390
|
+
const backend = makeBackend({
|
|
391
|
+
hooks: {
|
|
392
|
+
onBeforeUpdateForm: () => {
|
|
393
|
+
events.push("before");
|
|
394
|
+
},
|
|
395
|
+
onAfterUpdateForm: () => {
|
|
396
|
+
events.push("after");
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
});
|
|
400
|
+
const form = await seedForm(backend);
|
|
401
|
+
const response = await backend.handler(
|
|
402
|
+
request(`/forms/${form.id}`, {
|
|
403
|
+
method: "PUT",
|
|
404
|
+
body: { name: "Compatible" },
|
|
405
|
+
}),
|
|
406
|
+
);
|
|
407
|
+
expect(response.status).toBe(200);
|
|
408
|
+
expect(await response.json()).toMatchObject({ name: "Compatible" });
|
|
409
|
+
expect(events).toEqual(["before", "after"]);
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
it.each(["slug", "schema"] as const)(
|
|
413
|
+
"rejects an empty %s returned by the update hook without persisting it",
|
|
414
|
+
async (field) => {
|
|
415
|
+
const afterUpdate = vi.fn();
|
|
416
|
+
const backend = makeBackend({
|
|
417
|
+
auth: createAuth(),
|
|
418
|
+
hooks: {
|
|
419
|
+
onBeforeUpdateForm: (_id, data) => ({
|
|
420
|
+
...data,
|
|
421
|
+
[field]: "",
|
|
422
|
+
}),
|
|
423
|
+
onAfterUpdateForm: afterUpdate,
|
|
424
|
+
},
|
|
425
|
+
});
|
|
426
|
+
const form = await seedForm(backend, { slug: `hook-empty-${field}` });
|
|
427
|
+
|
|
428
|
+
await expect(
|
|
429
|
+
backend
|
|
430
|
+
.forRequest(request(`/forms/${form.id}`, { identity: owner }))
|
|
431
|
+
.operations.formBuilder.updateForm({
|
|
432
|
+
id: form.id,
|
|
433
|
+
data: { name: "Should not persist" },
|
|
434
|
+
}),
|
|
435
|
+
).rejects.toMatchObject({
|
|
436
|
+
statusCode: 400,
|
|
437
|
+
code: "FORM_VALIDATION_FAILED",
|
|
438
|
+
issues: [expect.objectContaining({ path: [field] })],
|
|
439
|
+
});
|
|
440
|
+
expect(afterUpdate).not.toHaveBeenCalled();
|
|
441
|
+
expect(
|
|
442
|
+
await backend.adapter.findOne<Form>({
|
|
443
|
+
model: "form",
|
|
444
|
+
where: [{ field: "id", value: form.id }],
|
|
445
|
+
}),
|
|
446
|
+
).toMatchObject({ name: "Contact", slug: `hook-empty-${field}` });
|
|
447
|
+
},
|
|
448
|
+
);
|
|
449
|
+
|
|
450
|
+
it("revalidates create-hook output before persistence", async () => {
|
|
451
|
+
const backend = makeBackend({
|
|
452
|
+
auth: createAuth(),
|
|
453
|
+
hooks: {
|
|
454
|
+
onBeforeCreateForm: (data) => ({ ...data, name: "" }),
|
|
455
|
+
},
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
await expect(
|
|
459
|
+
backend
|
|
460
|
+
.forRequest(request("/forms", { identity: admin }))
|
|
461
|
+
.operations.formBuilder.createForm({
|
|
462
|
+
name: "Valid before hook",
|
|
463
|
+
slug: "invalid-after-hook",
|
|
464
|
+
schema: activeSchema,
|
|
465
|
+
}),
|
|
466
|
+
).rejects.toMatchObject({
|
|
467
|
+
statusCode: 400,
|
|
468
|
+
code: "FORM_VALIDATION_FAILED",
|
|
469
|
+
issues: [expect.objectContaining({ path: ["name"] })],
|
|
470
|
+
});
|
|
471
|
+
expect(await backend.adapter.count({ model: "form", where: [] })).toBe(0);
|
|
472
|
+
});
|
|
473
|
+
it("keeps public render and submission explicitly anonymous across HTTP, request, and trusted transports", async () => {
|
|
474
|
+
const events: string[] = [];
|
|
475
|
+
const backend = makeBackend({
|
|
476
|
+
auth: createAuth(),
|
|
477
|
+
hooks: {
|
|
478
|
+
onBeforeGetForm: (slug, context) => {
|
|
479
|
+
events.push(`read:${slug}:${context.identity?.id ?? "anonymous"}`);
|
|
480
|
+
},
|
|
481
|
+
onBeforeSubmission: (slug, data, context) => {
|
|
482
|
+
events.push(`submit:${slug}:${context.identity?.id ?? "anonymous"}`);
|
|
483
|
+
return data;
|
|
484
|
+
},
|
|
485
|
+
onAfterSubmission: (submission, _form, context) => {
|
|
486
|
+
events.push(
|
|
487
|
+
`saved:${submission.id}:${context.identity?.id ?? "anonymous"}`,
|
|
488
|
+
);
|
|
489
|
+
},
|
|
490
|
+
},
|
|
491
|
+
});
|
|
492
|
+
const form = await seedForm(backend);
|
|
493
|
+
|
|
494
|
+
const renderResponse = await backend.handler(request("/forms/contact"));
|
|
495
|
+
expect(renderResponse.status).toBe(200);
|
|
496
|
+
expect(await renderResponse.json()).toMatchObject({
|
|
497
|
+
id: form.id,
|
|
498
|
+
slug: "contact",
|
|
499
|
+
});
|
|
500
|
+
expect(
|
|
501
|
+
await backend
|
|
502
|
+
.forRequest(request("/forms/contact"))
|
|
503
|
+
.operations.formBuilder.getFormBySlug({ slug: "contact" }),
|
|
504
|
+
).toMatchObject({ id: form.id });
|
|
505
|
+
expect(
|
|
506
|
+
await backend.trusted.formBuilder.getFormBySlug({ slug: "contact" }),
|
|
507
|
+
).toMatchObject({ id: form.id });
|
|
508
|
+
|
|
509
|
+
const submitResponse = await backend.handler(
|
|
510
|
+
request("/forms/contact/submit", {
|
|
511
|
+
method: "POST",
|
|
512
|
+
body: { data: { name: "Ada" } },
|
|
513
|
+
}),
|
|
514
|
+
);
|
|
515
|
+
expect(submitResponse.status).toBe(200);
|
|
516
|
+
const submitted = (await submitResponse.json()) as FormSubmission;
|
|
517
|
+
expect(submitted.formId).toBe(form.id);
|
|
518
|
+
expect(
|
|
519
|
+
await backend
|
|
520
|
+
.forRequest(request("/forms/contact/submit"))
|
|
521
|
+
.operations.formBuilder.submitForm({
|
|
522
|
+
slug: "contact",
|
|
523
|
+
data: { name: "Grace" },
|
|
524
|
+
}),
|
|
525
|
+
).toMatchObject({ formId: form.id });
|
|
526
|
+
expect(
|
|
527
|
+
await backend.trusted.formBuilder.submitForm({
|
|
528
|
+
slug: "contact",
|
|
529
|
+
data: { name: "Lin" },
|
|
530
|
+
}),
|
|
531
|
+
).toMatchObject({ formId: form.id });
|
|
532
|
+
expect(events).toHaveLength(9);
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
it("preserves dynamic schema issues across operation and HTTP submission errors", async () => {
|
|
536
|
+
const backend = makeBackend({ auth: createAuth() });
|
|
537
|
+
await seedForm(backend);
|
|
538
|
+
|
|
539
|
+
await expect(
|
|
540
|
+
backend.trusted.formBuilder.submitForm({
|
|
541
|
+
slug: "contact",
|
|
542
|
+
data: {},
|
|
543
|
+
}),
|
|
544
|
+
).rejects.toMatchObject({
|
|
545
|
+
statusCode: 400,
|
|
546
|
+
code: "SUBMISSION_VALIDATION_FAILED",
|
|
547
|
+
issues: [
|
|
548
|
+
expect.objectContaining({
|
|
549
|
+
path: ["name"],
|
|
550
|
+
message: expect.any(String),
|
|
551
|
+
}),
|
|
552
|
+
],
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
const response = await backend.handler(
|
|
556
|
+
request("/forms/contact/submit", {
|
|
557
|
+
method: "POST",
|
|
558
|
+
body: { data: {} },
|
|
559
|
+
}),
|
|
560
|
+
);
|
|
561
|
+
expect(response.status).toBe(400);
|
|
562
|
+
expect(await response.json()).toMatchObject({
|
|
563
|
+
code: "SUBMISSION_VALIDATION_FAILED",
|
|
564
|
+
issues: [
|
|
565
|
+
expect.objectContaining({
|
|
566
|
+
path: ["name"],
|
|
567
|
+
message: expect.any(String),
|
|
568
|
+
}),
|
|
569
|
+
],
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
it("returns 401 for anonymous callers and 403 for authenticated non-owners before lifecycle hooks", async () => {
|
|
574
|
+
const events: string[] = [];
|
|
575
|
+
const backend = makeBackend({
|
|
576
|
+
auth: createAuth(),
|
|
577
|
+
hooks: {
|
|
578
|
+
onBeforeUpdateForm: () => {
|
|
579
|
+
events.push("before");
|
|
580
|
+
},
|
|
581
|
+
onError: () => {
|
|
582
|
+
events.push("error");
|
|
583
|
+
},
|
|
584
|
+
},
|
|
585
|
+
});
|
|
586
|
+
const form = await seedForm(backend);
|
|
587
|
+
|
|
588
|
+
const anonymous = await backend.handler(
|
|
589
|
+
request(`/forms/${form.id}`, {
|
|
590
|
+
method: "PUT",
|
|
591
|
+
body: { name: "Anonymous" },
|
|
592
|
+
}),
|
|
593
|
+
);
|
|
594
|
+
const denied = await backend.handler(
|
|
595
|
+
request(`/forms/${form.id}`, {
|
|
596
|
+
method: "PUT",
|
|
597
|
+
identity: viewer,
|
|
598
|
+
body: { name: "Viewer" },
|
|
599
|
+
}),
|
|
600
|
+
);
|
|
601
|
+
expect(anonymous.status).toBe(401);
|
|
602
|
+
expect(denied.status).toBe(403);
|
|
603
|
+
expect(events).toEqual([]);
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
it("fails closed across every protected HTTP operation", async () => {
|
|
607
|
+
const events: string[] = [];
|
|
608
|
+
const backend = makeBackend({
|
|
609
|
+
auth: createAuth(),
|
|
610
|
+
hooks: {
|
|
611
|
+
onBeforeListForms: () => {
|
|
612
|
+
events.push("list-forms");
|
|
613
|
+
},
|
|
614
|
+
onBeforeGetForm: () => {
|
|
615
|
+
events.push("get-form");
|
|
616
|
+
},
|
|
617
|
+
onBeforeGetFormForUpdate: () => {
|
|
618
|
+
events.push("get-form-for-update");
|
|
619
|
+
},
|
|
620
|
+
onBeforeCreateForm: () => {
|
|
621
|
+
events.push("create-form");
|
|
622
|
+
},
|
|
623
|
+
onBeforeUpdateForm: () => {
|
|
624
|
+
events.push("update-form");
|
|
625
|
+
},
|
|
626
|
+
onBeforeDeleteForm: () => {
|
|
627
|
+
events.push("delete-form");
|
|
628
|
+
},
|
|
629
|
+
onBeforeListSubmissions: () => {
|
|
630
|
+
events.push("list-submissions");
|
|
631
|
+
},
|
|
632
|
+
onBeforeGetSubmission: () => {
|
|
633
|
+
events.push("get-submission");
|
|
634
|
+
},
|
|
635
|
+
onBeforeDeleteSubmission: () => {
|
|
636
|
+
events.push("delete-submission");
|
|
637
|
+
},
|
|
638
|
+
onError: () => {
|
|
639
|
+
events.push("error");
|
|
640
|
+
},
|
|
641
|
+
},
|
|
642
|
+
});
|
|
643
|
+
const form = await seedForm(backend);
|
|
644
|
+
const submission = await seedSubmission(backend, form.id);
|
|
645
|
+
const protectedRequests = [
|
|
646
|
+
() => request("/forms"),
|
|
647
|
+
() => request(`/forms/id/${form.id}`),
|
|
648
|
+
() => request(`/forms/id/${form.id}/edit`),
|
|
649
|
+
() =>
|
|
650
|
+
request("/forms", {
|
|
651
|
+
method: "POST",
|
|
652
|
+
body: {
|
|
653
|
+
name: "Denied",
|
|
654
|
+
slug: "denied",
|
|
655
|
+
schema: activeSchema,
|
|
656
|
+
},
|
|
657
|
+
}),
|
|
658
|
+
() =>
|
|
659
|
+
request(`/forms/${form.id}`, {
|
|
660
|
+
method: "PUT",
|
|
661
|
+
body: { name: "Denied" },
|
|
662
|
+
}),
|
|
663
|
+
() => request(`/forms/${form.id}`, { method: "DELETE" }),
|
|
664
|
+
() => request(`/forms/${form.id}/submissions`),
|
|
665
|
+
() => request(`/forms/${form.id}/submissions/${submission.id}`),
|
|
666
|
+
() =>
|
|
667
|
+
request(`/forms/${form.id}/submissions/${submission.id}`, {
|
|
668
|
+
method: "DELETE",
|
|
669
|
+
}),
|
|
670
|
+
];
|
|
671
|
+
|
|
672
|
+
for (const createRequest of protectedRequests) {
|
|
673
|
+
expect((await backend.handler(createRequest())).status).toBe(401);
|
|
674
|
+
const denied = createRequest();
|
|
675
|
+
denied.headers.set("x-user-id", viewer.id);
|
|
676
|
+
denied.headers.set("x-user-role", viewer.role);
|
|
677
|
+
expect((await backend.handler(denied)).status).toBe(403);
|
|
678
|
+
}
|
|
679
|
+
expect(events).toEqual([]);
|
|
680
|
+
});
|
|
681
|
+
|
|
682
|
+
it("uses server-derived ownership rather than spoofed browser facts", async () => {
|
|
683
|
+
const backend = makeBackend({ auth: createAuth() });
|
|
684
|
+
const form = await seedForm(backend);
|
|
685
|
+
expect(
|
|
686
|
+
authorization.can(
|
|
687
|
+
formBuilderPermissions.form.update({
|
|
688
|
+
formId: form.id,
|
|
689
|
+
ownerId: viewer.id,
|
|
690
|
+
status: "active",
|
|
691
|
+
}),
|
|
692
|
+
viewer,
|
|
693
|
+
),
|
|
694
|
+
).toBe(true);
|
|
695
|
+
|
|
696
|
+
await expect(
|
|
697
|
+
backend
|
|
698
|
+
.forRequest(request(`/forms/${form.id}`, { identity: viewer }))
|
|
699
|
+
.operations.formBuilder.updateForm({
|
|
700
|
+
id: form.id,
|
|
701
|
+
data: { name: "Spoofed" },
|
|
702
|
+
}),
|
|
703
|
+
).rejects.toMatchObject({ statusCode: 403 });
|
|
704
|
+
const unchanged = await backend.adapter.findOne<Form>({
|
|
705
|
+
model: "form",
|
|
706
|
+
where: [{ field: "id", value: form.id }],
|
|
707
|
+
});
|
|
708
|
+
expect(unchanged?.name).toBe("Contact");
|
|
709
|
+
});
|
|
710
|
+
|
|
711
|
+
it("loads editor and submission page data through their exact permissions", async () => {
|
|
712
|
+
const exactPageAuthorization = defineAuthorization({
|
|
713
|
+
identity: z.object({ id: z.string(), role: z.enum(["user", "admin"]) }),
|
|
714
|
+
permissions: [formBuilderPermissions] as const,
|
|
715
|
+
rules: ({ forms }) => [
|
|
716
|
+
forms.form.read.when(() => false),
|
|
717
|
+
forms.form.update.when(
|
|
718
|
+
({ identity, facts }) => identity?.id === facts.ownerId,
|
|
719
|
+
),
|
|
720
|
+
forms.submission.read.when(
|
|
721
|
+
({ identity, facts }) => identity?.id === facts.ownerId,
|
|
722
|
+
),
|
|
723
|
+
],
|
|
724
|
+
});
|
|
725
|
+
const backend = makeBackend({
|
|
726
|
+
auth: createAuth(undefined, exactPageAuthorization),
|
|
727
|
+
});
|
|
728
|
+
const form = await seedForm(backend);
|
|
729
|
+
await seedSubmission(backend, form.id);
|
|
730
|
+
|
|
731
|
+
await expect(
|
|
732
|
+
backend
|
|
733
|
+
.forRequest(request(`/forms/id/${form.id}`, { identity: owner }))
|
|
734
|
+
.operations.formBuilder.getFormById({ id: form.id }),
|
|
735
|
+
).rejects.toMatchObject({ statusCode: 403 });
|
|
736
|
+
await expect(
|
|
737
|
+
backend
|
|
738
|
+
.forRequest(request(`/forms/id/${form.id}/edit`, { identity: owner }))
|
|
739
|
+
.operations.formBuilder.getFormForUpdate({ id: form.id }),
|
|
740
|
+
).resolves.toMatchObject({ id: form.id, createdBy: owner.id });
|
|
741
|
+
const editorResponse = await backend.handler(
|
|
742
|
+
request(`/forms/id/${form.id}/edit`, { identity: owner }),
|
|
743
|
+
);
|
|
744
|
+
expect(editorResponse.status).toBe(200);
|
|
745
|
+
expect(await editorResponse.json()).toMatchObject({ id: form.id });
|
|
746
|
+
await expect(
|
|
747
|
+
backend
|
|
748
|
+
.forRequest(request(`/forms/id/${form.id}/edit`, { identity: viewer }))
|
|
749
|
+
.operations.formBuilder.getFormForUpdate({ id: form.id }),
|
|
750
|
+
).rejects.toMatchObject({ statusCode: 403 });
|
|
751
|
+
const list = await backend
|
|
752
|
+
.forRequest(request(`/forms/${form.id}/submissions`, { identity: owner }))
|
|
753
|
+
.operations.formBuilder.listSubmissions({
|
|
754
|
+
formId: form.id,
|
|
755
|
+
query: { limit: 20, offset: 0 },
|
|
756
|
+
});
|
|
757
|
+
expect(list).toMatchObject({
|
|
758
|
+
form: { id: form.id, createdBy: owner.id },
|
|
759
|
+
total: 1,
|
|
760
|
+
});
|
|
761
|
+
expect(Object.keys(list.form).sort()).toEqual(["createdBy", "id", "name"]);
|
|
762
|
+
const submissionsResponse = await backend.handler(
|
|
763
|
+
request(`/forms/${form.id}/submissions`, { identity: owner }),
|
|
764
|
+
);
|
|
765
|
+
expect(submissionsResponse.status).toBe(200);
|
|
766
|
+
const submissionsBody = await submissionsResponse.json();
|
|
767
|
+
expect(submissionsBody).toMatchObject({
|
|
768
|
+
form: { id: form.id, createdBy: owner.id },
|
|
769
|
+
total: 1,
|
|
770
|
+
});
|
|
771
|
+
expect(Object.keys(submissionsBody.form).sort()).toEqual([
|
|
772
|
+
"createdBy",
|
|
773
|
+
"id",
|
|
774
|
+
"name",
|
|
775
|
+
]);
|
|
776
|
+
await expect(
|
|
777
|
+
backend.trusted.formBuilder.getFormForUpdate({ id: form.id }),
|
|
778
|
+
).resolves.toMatchObject({ id: form.id });
|
|
779
|
+
});
|
|
780
|
+
|
|
781
|
+
it("never exposes record contents from a collection-authorized submission list", async () => {
|
|
782
|
+
const collectionOnlyAuthorization = defineAuthorization({
|
|
783
|
+
identity: z.object({ id: z.string(), role: z.enum(["user", "admin"]) }),
|
|
784
|
+
permissions: [formBuilderPermissions] as const,
|
|
785
|
+
rules: ({ forms }) => [
|
|
786
|
+
forms.submission.read.when(({ facts }) => facts.scope === "collection"),
|
|
787
|
+
],
|
|
788
|
+
});
|
|
789
|
+
const backend = makeBackend({
|
|
790
|
+
auth: createAuth(undefined, collectionOnlyAuthorization),
|
|
791
|
+
});
|
|
792
|
+
const form = await seedForm(backend);
|
|
793
|
+
const submission = await seedSubmission(backend, form.id, {
|
|
794
|
+
data: JSON.stringify({ secret: "never-list-this" }),
|
|
795
|
+
ipAddress: "203.0.113.1",
|
|
796
|
+
userAgent: "sensitive-agent",
|
|
797
|
+
});
|
|
798
|
+
|
|
799
|
+
const requestList = await backend
|
|
800
|
+
.forRequest(request(`/forms/${form.id}/submissions`, { identity: owner }))
|
|
801
|
+
.operations.formBuilder.listSubmissions({
|
|
802
|
+
formId: form.id,
|
|
803
|
+
query: { limit: 20, offset: 0 },
|
|
804
|
+
});
|
|
805
|
+
expect(requestList.items).toEqual([
|
|
806
|
+
{
|
|
807
|
+
id: submission.id,
|
|
808
|
+
formId: form.id,
|
|
809
|
+
submittedAt: submission.submittedAt.toISOString(),
|
|
810
|
+
submittedBy: submission.submittedBy,
|
|
811
|
+
},
|
|
812
|
+
]);
|
|
813
|
+
|
|
814
|
+
const response = await backend.handler(
|
|
815
|
+
request(`/forms/${form.id}/submissions`, { identity: owner }),
|
|
816
|
+
);
|
|
817
|
+
expect(response.status).toBe(200);
|
|
818
|
+
const body = await response.json();
|
|
819
|
+
expect(body.items).toEqual(requestList.items);
|
|
820
|
+
expect(JSON.stringify(body)).not.toContain("never-list-this");
|
|
821
|
+
expect(JSON.stringify(body)).not.toContain("203.0.113.1");
|
|
822
|
+
expect(JSON.stringify(body)).not.toContain("sensitive-agent");
|
|
823
|
+
const trustedList = await backend.trusted.formBuilder.listSubmissions({
|
|
824
|
+
formId: form.id,
|
|
825
|
+
query: { limit: 20, offset: 0 },
|
|
826
|
+
});
|
|
827
|
+
expect(trustedList.items).toEqual(requestList.items);
|
|
828
|
+
|
|
829
|
+
await expect(
|
|
830
|
+
backend
|
|
831
|
+
.forRequest(
|
|
832
|
+
request(`/forms/${form.id}/submissions/${submission.id}`, {
|
|
833
|
+
identity: owner,
|
|
834
|
+
}),
|
|
835
|
+
)
|
|
836
|
+
.operations.formBuilder.getSubmission({
|
|
837
|
+
formId: form.id,
|
|
838
|
+
submissionId: submission.id,
|
|
839
|
+
}),
|
|
840
|
+
).rejects.toMatchObject({ statusCode: 403 });
|
|
841
|
+
const recordResponse = await backend.handler(
|
|
842
|
+
request(`/forms/${form.id}/submissions/${submission.id}`, {
|
|
843
|
+
identity: owner,
|
|
844
|
+
}),
|
|
845
|
+
);
|
|
846
|
+
expect(recordResponse.status).toBe(403);
|
|
847
|
+
});
|
|
848
|
+
|
|
849
|
+
it("allows owners and admins while keeping collection scoping in server execution", async () => {
|
|
850
|
+
const backend = makeBackend({ auth: createAuth() });
|
|
851
|
+
const form = await seedForm(backend);
|
|
852
|
+
const submission = await seedSubmission(backend, form.id);
|
|
853
|
+
|
|
854
|
+
const updated = await backend
|
|
855
|
+
.forRequest(request(`/forms/${form.id}`, { identity: owner }))
|
|
856
|
+
.operations.formBuilder.updateForm({
|
|
857
|
+
id: form.id,
|
|
858
|
+
data: { name: "Owned" },
|
|
859
|
+
});
|
|
860
|
+
expect(updated.name).toBe("Owned");
|
|
861
|
+
await expect(
|
|
862
|
+
backend
|
|
863
|
+
.forRequest(request(`/forms/id/${form.id}`, { identity: owner }))
|
|
864
|
+
.operations.formBuilder.getFormById({ id: form.id }),
|
|
865
|
+
).resolves.toMatchObject({ id: form.id, createdBy: owner.id });
|
|
866
|
+
const requestApi = backend.forRequest(
|
|
867
|
+
request(`/forms/${form.id}/submissions`, { identity: owner }),
|
|
868
|
+
).operations.formBuilder as unknown as {
|
|
869
|
+
listSubmissions(input: {
|
|
870
|
+
formId: string;
|
|
871
|
+
query: { limit: number; offset: number };
|
|
872
|
+
}): Promise<{
|
|
873
|
+
readonly form: { readonly id: string; readonly createdBy?: string };
|
|
874
|
+
readonly items: ReadonlyArray<{ readonly id: string }>;
|
|
875
|
+
}>;
|
|
876
|
+
};
|
|
877
|
+
const list = (await requestApi.listSubmissions({
|
|
878
|
+
formId: form.id,
|
|
879
|
+
query: { limit: 20, offset: 0 },
|
|
880
|
+
})) as {
|
|
881
|
+
readonly form: { readonly id: string; readonly createdBy?: string };
|
|
882
|
+
readonly items: ReadonlyArray<{ readonly id: string }>;
|
|
883
|
+
};
|
|
884
|
+
expect(list.form).toMatchObject({ id: form.id, createdBy: owner.id });
|
|
885
|
+
expect(list.items.map((item) => item.id)).toEqual([submission.id]);
|
|
886
|
+
expect(Object.keys(list.items[0] ?? {}).sort()).toEqual([
|
|
887
|
+
"formId",
|
|
888
|
+
"id",
|
|
889
|
+
"submittedAt",
|
|
890
|
+
"submittedBy",
|
|
891
|
+
]);
|
|
892
|
+
const detail = await backend
|
|
893
|
+
.forRequest(
|
|
894
|
+
request(`/forms/${form.id}/submissions/${submission.id}`, {
|
|
895
|
+
identity: owner,
|
|
896
|
+
}),
|
|
897
|
+
)
|
|
898
|
+
.operations.formBuilder.getSubmission({
|
|
899
|
+
formId: form.id,
|
|
900
|
+
submissionId: submission.id,
|
|
901
|
+
});
|
|
902
|
+
expect(detail).toMatchObject({ id: submission.id, formId: form.id });
|
|
903
|
+
expect("form" in detail).toBe(false);
|
|
904
|
+
await expect(
|
|
905
|
+
backend
|
|
906
|
+
.forRequest(request("/forms", { identity: admin }))
|
|
907
|
+
.operations.formBuilder.createForm({
|
|
908
|
+
name: "Admin form",
|
|
909
|
+
slug: "admin-form",
|
|
910
|
+
schema: activeSchema,
|
|
911
|
+
status: "active",
|
|
912
|
+
}),
|
|
913
|
+
).resolves.toMatchObject({ slug: "admin-form", createdBy: admin.id });
|
|
914
|
+
await expect(
|
|
915
|
+
backend
|
|
916
|
+
.forRequest(request("/forms", { identity: admin }))
|
|
917
|
+
.operations.formBuilder.listForms({ limit: 20, offset: 0 }),
|
|
918
|
+
).resolves.toMatchObject({ total: 2 });
|
|
919
|
+
await expect(
|
|
920
|
+
backend
|
|
921
|
+
.forRequest(
|
|
922
|
+
request(`/forms/${form.id}/submissions/${submission.id}`, {
|
|
923
|
+
identity: owner,
|
|
924
|
+
}),
|
|
925
|
+
)
|
|
926
|
+
.operations.formBuilder.deleteSubmission({
|
|
927
|
+
formId: form.id,
|
|
928
|
+
submissionId: submission.id,
|
|
929
|
+
}),
|
|
930
|
+
).resolves.toEqual({ success: true });
|
|
931
|
+
await expect(
|
|
932
|
+
backend
|
|
933
|
+
.forRequest(request(`/forms/${form.id}`, { identity: owner }))
|
|
934
|
+
.operations.formBuilder.deleteForm({ id: form.id }),
|
|
935
|
+
).resolves.toEqual({ success: true });
|
|
936
|
+
});
|
|
937
|
+
|
|
938
|
+
it("keeps validation and hooks active for trusted calls without resolving identity", async () => {
|
|
939
|
+
const getIdentity = vi.fn(() => {
|
|
940
|
+
throw new Error("trusted must not resolve identity");
|
|
941
|
+
});
|
|
942
|
+
const events: string[] = [];
|
|
943
|
+
const backend = makeBackend({
|
|
944
|
+
auth: createAuth(getIdentity),
|
|
945
|
+
hooks: {
|
|
946
|
+
onBeforeCreateForm: (input, context) => {
|
|
947
|
+
events.push(`before:${context.identity?.id ?? "trusted"}`);
|
|
948
|
+
return { ...input, createdBy: "system-owner" };
|
|
949
|
+
},
|
|
950
|
+
onAfterCreateForm: (_form, context) => {
|
|
951
|
+
events.push(`after:${context.identity?.id ?? "trusted"}`);
|
|
952
|
+
},
|
|
953
|
+
},
|
|
954
|
+
});
|
|
955
|
+
|
|
956
|
+
await expect(
|
|
957
|
+
backend.trusted.formBuilder.createForm({
|
|
958
|
+
name: "",
|
|
959
|
+
slug: "invalid",
|
|
960
|
+
schema: activeSchema,
|
|
961
|
+
status: "active",
|
|
962
|
+
}),
|
|
963
|
+
).rejects.toThrow();
|
|
964
|
+
expect(events).toEqual([]);
|
|
965
|
+
const created = await backend.trusted.formBuilder.createForm({
|
|
966
|
+
name: "Trusted",
|
|
967
|
+
slug: "trusted",
|
|
968
|
+
schema: activeSchema,
|
|
969
|
+
status: "active",
|
|
970
|
+
});
|
|
971
|
+
expect(created.createdBy).toBe("system-owner");
|
|
972
|
+
expect(events).toEqual(["before:trusted", "after:trusted"]);
|
|
973
|
+
expect(getIdentity).not.toHaveBeenCalled();
|
|
974
|
+
});
|
|
975
|
+
|
|
976
|
+
it("fails closed for missing rules and preserves identity/rule failures as errors", async () => {
|
|
977
|
+
const missing = defineAuthorization({
|
|
978
|
+
identity: z.object({ id: z.string(), role: z.enum(["user", "admin"]) }),
|
|
979
|
+
permissions: [formBuilderPermissions] as const,
|
|
980
|
+
rules: ({ forms }) => [forms.form.render.allow()],
|
|
981
|
+
});
|
|
982
|
+
const missingBackend = makeBackend({
|
|
983
|
+
auth: createAuth(undefined, missing),
|
|
984
|
+
});
|
|
985
|
+
const form = await seedForm(missingBackend);
|
|
986
|
+
await expect(
|
|
987
|
+
missingBackend
|
|
988
|
+
.forRequest(request(`/forms/${form.id}`, { identity: owner }))
|
|
989
|
+
.operations.formBuilder.updateForm({
|
|
990
|
+
id: form.id,
|
|
991
|
+
data: { name: "Denied" },
|
|
992
|
+
}),
|
|
993
|
+
).rejects.toMatchObject({ statusCode: 403 });
|
|
994
|
+
|
|
995
|
+
const identityFailure = makeBackend({
|
|
996
|
+
auth: createAuth(() => {
|
|
997
|
+
throw new Error("session unavailable");
|
|
998
|
+
}),
|
|
999
|
+
});
|
|
1000
|
+
const identityForm = await seedForm(identityFailure, { slug: "identity" });
|
|
1001
|
+
await expect(
|
|
1002
|
+
identityFailure
|
|
1003
|
+
.forRequest(request(`/forms/${identityForm.id}`))
|
|
1004
|
+
.operations.formBuilder.updateForm({
|
|
1005
|
+
id: identityForm.id,
|
|
1006
|
+
data: { name: "Nope" },
|
|
1007
|
+
}),
|
|
1008
|
+
).rejects.toThrow("session unavailable");
|
|
1009
|
+
|
|
1010
|
+
const failing = defineAuthorization({
|
|
1011
|
+
identity: z.object({ id: z.string(), role: z.enum(["user", "admin"]) }),
|
|
1012
|
+
permissions: [formBuilderPermissions] as const,
|
|
1013
|
+
rules: ({ forms }) => [
|
|
1014
|
+
forms.form.update.when(() => {
|
|
1015
|
+
throw new Error("policy unavailable");
|
|
1016
|
+
}),
|
|
1017
|
+
],
|
|
1018
|
+
});
|
|
1019
|
+
const ruleFailure = makeBackend({ auth: createAuth(undefined, failing) });
|
|
1020
|
+
const ruleForm = await seedForm(ruleFailure, { slug: "rule" });
|
|
1021
|
+
await expect(
|
|
1022
|
+
ruleFailure
|
|
1023
|
+
.forRequest(request(`/forms/${ruleForm.id}`, { identity: owner }))
|
|
1024
|
+
.operations.formBuilder.updateForm({
|
|
1025
|
+
id: ruleForm.id,
|
|
1026
|
+
data: { name: "Nope" },
|
|
1027
|
+
}),
|
|
1028
|
+
).rejects.toThrow("policy unavailable");
|
|
1029
|
+
|
|
1030
|
+
const factFailureEvents: string[] = [];
|
|
1031
|
+
const factFailure = makeBackend({
|
|
1032
|
+
auth: createAuth(),
|
|
1033
|
+
hooks: {
|
|
1034
|
+
onBeforeUpdateForm: () => {
|
|
1035
|
+
factFailureEvents.push("before");
|
|
1036
|
+
},
|
|
1037
|
+
onError: () => {
|
|
1038
|
+
factFailureEvents.push("error");
|
|
1039
|
+
},
|
|
1040
|
+
},
|
|
1041
|
+
});
|
|
1042
|
+
const factForm = await seedForm(factFailure, { slug: "facts" });
|
|
1043
|
+
vi.spyOn(factFailure.adapter, "findOne").mockRejectedValueOnce(
|
|
1044
|
+
new Error("database unavailable"),
|
|
1045
|
+
);
|
|
1046
|
+
await expect(
|
|
1047
|
+
factFailure
|
|
1048
|
+
.forRequest(request(`/forms/${factForm.id}`, { identity: owner }))
|
|
1049
|
+
.operations.formBuilder.updateForm({
|
|
1050
|
+
id: factForm.id,
|
|
1051
|
+
data: { name: "Nope" },
|
|
1052
|
+
}),
|
|
1053
|
+
).rejects.toThrow("database unavailable");
|
|
1054
|
+
expect(factFailureEvents).toEqual([]);
|
|
1055
|
+
});
|
|
1056
|
+
|
|
1057
|
+
it.each(["update", "delete", "deleteSubmission"] as const)(
|
|
1058
|
+
"rechecks trusted snapshots before %s hooks observe a stale owner",
|
|
1059
|
+
async (operation) => {
|
|
1060
|
+
const events: string[] = [];
|
|
1061
|
+
let backend: ReturnType<typeof makeBackend>;
|
|
1062
|
+
let raced = false;
|
|
1063
|
+
backend = makeBackend({
|
|
1064
|
+
auth: createAuth(async () => {
|
|
1065
|
+
if (!raced) {
|
|
1066
|
+
raced = true;
|
|
1067
|
+
const form = await backend.adapter.findOne<Form>({
|
|
1068
|
+
model: "form",
|
|
1069
|
+
where: [{ field: "slug", value: `race-${operation}` }],
|
|
1070
|
+
});
|
|
1071
|
+
if (form) {
|
|
1072
|
+
await backend.adapter.update({
|
|
1073
|
+
model: "form",
|
|
1074
|
+
where: [{ field: "id", value: form.id }],
|
|
1075
|
+
update: {
|
|
1076
|
+
createdBy: "new-owner",
|
|
1077
|
+
updatedAt: new Date("2026-02-01T00:00:00.000Z"),
|
|
1078
|
+
},
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
return owner;
|
|
1083
|
+
}),
|
|
1084
|
+
hooks: {
|
|
1085
|
+
onBeforeUpdateForm: () => {
|
|
1086
|
+
events.push("update-hook");
|
|
1087
|
+
},
|
|
1088
|
+
onBeforeDeleteForm: () => {
|
|
1089
|
+
events.push("delete-hook");
|
|
1090
|
+
},
|
|
1091
|
+
onBeforeDeleteSubmission: () => {
|
|
1092
|
+
events.push("submission-hook");
|
|
1093
|
+
},
|
|
1094
|
+
},
|
|
1095
|
+
});
|
|
1096
|
+
const form = await seedForm(backend, { slug: `race-${operation}` });
|
|
1097
|
+
const submission = await seedSubmission(backend, form.id);
|
|
1098
|
+
const api = backend.forRequest(request("/race", { identity: owner }))
|
|
1099
|
+
.operations.formBuilder;
|
|
1100
|
+
const result =
|
|
1101
|
+
operation === "update"
|
|
1102
|
+
? api.updateForm({ id: form.id, data: { name: "Stale" } })
|
|
1103
|
+
: operation === "delete"
|
|
1104
|
+
? api.deleteForm({ id: form.id })
|
|
1105
|
+
: api.deleteSubmission({
|
|
1106
|
+
formId: form.id,
|
|
1107
|
+
submissionId: submission.id,
|
|
1108
|
+
});
|
|
1109
|
+
await expect(result).rejects.toMatchObject({ statusCode: 409 });
|
|
1110
|
+
expect(events).toEqual([]);
|
|
1111
|
+
},
|
|
1112
|
+
);
|
|
1113
|
+
|
|
1114
|
+
it.each(["update", "delete", "submit", "deleteSubmission"] as const)(
|
|
1115
|
+
"atomically rejects a %s write-boundary race before domain hooks run",
|
|
1116
|
+
async (operation) => {
|
|
1117
|
+
const events: string[] = [];
|
|
1118
|
+
const backend = makeBackend({
|
|
1119
|
+
auth: createAuth(),
|
|
1120
|
+
hooks: {
|
|
1121
|
+
onBeforeUpdateForm: () => {
|
|
1122
|
+
events.push("update-hook");
|
|
1123
|
+
},
|
|
1124
|
+
onBeforeDeleteForm: () => {
|
|
1125
|
+
events.push("delete-hook");
|
|
1126
|
+
},
|
|
1127
|
+
onBeforeSubmission: () => {
|
|
1128
|
+
events.push("submit-hook");
|
|
1129
|
+
},
|
|
1130
|
+
onBeforeDeleteSubmission: () => {
|
|
1131
|
+
events.push("submission-hook");
|
|
1132
|
+
},
|
|
1133
|
+
},
|
|
1134
|
+
});
|
|
1135
|
+
const form = await seedForm(backend, { slug: `cas-${operation}` });
|
|
1136
|
+
const submission = await seedSubmission(backend, form.id);
|
|
1137
|
+
const transaction = backend.adapter.transaction.bind(backend.adapter);
|
|
1138
|
+
let raced = false;
|
|
1139
|
+
vi.spyOn(backend.adapter, "transaction").mockImplementation(
|
|
1140
|
+
async (callback) =>
|
|
1141
|
+
transaction(async (tx) => {
|
|
1142
|
+
const updateMany = tx.updateMany.bind(tx);
|
|
1143
|
+
vi.spyOn(tx, "updateMany").mockImplementation(async (input) => {
|
|
1144
|
+
if (!raced && input.model === "form") {
|
|
1145
|
+
raced = true;
|
|
1146
|
+
await tx.update<Form>({
|
|
1147
|
+
model: "form",
|
|
1148
|
+
where: [{ field: "id", value: form.id }],
|
|
1149
|
+
update:
|
|
1150
|
+
operation === "submit"
|
|
1151
|
+
? {
|
|
1152
|
+
status: "inactive",
|
|
1153
|
+
updatedAt: new Date("2026-03-01T00:00:00.000Z"),
|
|
1154
|
+
}
|
|
1155
|
+
: {
|
|
1156
|
+
createdBy: viewer.id,
|
|
1157
|
+
updatedAt: new Date("2026-03-01T00:00:00.000Z"),
|
|
1158
|
+
},
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
return updateMany(input);
|
|
1162
|
+
});
|
|
1163
|
+
return callback(tx);
|
|
1164
|
+
}),
|
|
1165
|
+
);
|
|
1166
|
+
|
|
1167
|
+
const api = backend.forRequest(request("/cas", { identity: owner }))
|
|
1168
|
+
.operations.formBuilder;
|
|
1169
|
+
const result =
|
|
1170
|
+
operation === "update"
|
|
1171
|
+
? api.updateForm({ id: form.id, data: { name: "Raced" } })
|
|
1172
|
+
: operation === "delete"
|
|
1173
|
+
? api.deleteForm({ id: form.id })
|
|
1174
|
+
: operation === "submit"
|
|
1175
|
+
? api.submitForm({
|
|
1176
|
+
slug: form.slug,
|
|
1177
|
+
data: { name: "Raced" },
|
|
1178
|
+
})
|
|
1179
|
+
: api.deleteSubmission({
|
|
1180
|
+
formId: form.id,
|
|
1181
|
+
submissionId: submission.id,
|
|
1182
|
+
});
|
|
1183
|
+
|
|
1184
|
+
await expect(result).rejects.toMatchObject({ statusCode: 409 });
|
|
1185
|
+
expect(raced).toBe(true);
|
|
1186
|
+
expect(events).toEqual([]);
|
|
1187
|
+
expect(
|
|
1188
|
+
await backend.adapter.findOne<Form>({
|
|
1189
|
+
model: "form",
|
|
1190
|
+
where: [{ field: "id", value: form.id }],
|
|
1191
|
+
}),
|
|
1192
|
+
).toMatchObject({
|
|
1193
|
+
createdBy: owner.id,
|
|
1194
|
+
status: "active",
|
|
1195
|
+
name: "Contact",
|
|
1196
|
+
});
|
|
1197
|
+
expect(
|
|
1198
|
+
await backend.adapter.count({
|
|
1199
|
+
model: "formSubmission",
|
|
1200
|
+
where: [{ field: "formId", value: form.id }],
|
|
1201
|
+
}),
|
|
1202
|
+
).toBe(1);
|
|
1203
|
+
},
|
|
1204
|
+
);
|
|
1205
|
+
|
|
1206
|
+
it.each(["update", "delete", "submit", "deleteSubmission"] as const)(
|
|
1207
|
+
"fails closed for %s before hooks or claims on a sequential transaction fallback",
|
|
1208
|
+
async (operation) => {
|
|
1209
|
+
const events: string[] = [];
|
|
1210
|
+
const backend = makeBackend({
|
|
1211
|
+
auth: createAuth(),
|
|
1212
|
+
hooks: {
|
|
1213
|
+
onBeforeUpdateForm: () => {
|
|
1214
|
+
events.push("update-hook");
|
|
1215
|
+
},
|
|
1216
|
+
onBeforeDeleteForm: () => {
|
|
1217
|
+
events.push("delete-hook");
|
|
1218
|
+
},
|
|
1219
|
+
onBeforeSubmission: () => {
|
|
1220
|
+
events.push("submit-hook");
|
|
1221
|
+
},
|
|
1222
|
+
onBeforeDeleteSubmission: () => {
|
|
1223
|
+
events.push("submission-hook");
|
|
1224
|
+
},
|
|
1225
|
+
},
|
|
1226
|
+
});
|
|
1227
|
+
const form = await seedForm(backend, { slug: `sequential-${operation}` });
|
|
1228
|
+
const submission = await seedSubmission(backend, form.id);
|
|
1229
|
+
const adapterConfig = backend.adapter.options?.adapterConfig;
|
|
1230
|
+
expect(adapterConfig).toBeDefined();
|
|
1231
|
+
if (!adapterConfig) throw new Error("Missing adapter config");
|
|
1232
|
+
adapterConfig.transaction = false;
|
|
1233
|
+
const api = backend.forRequest(
|
|
1234
|
+
request("/sequential", { identity: owner }),
|
|
1235
|
+
).operations.formBuilder;
|
|
1236
|
+
const result =
|
|
1237
|
+
operation === "update"
|
|
1238
|
+
? api.updateForm({ id: form.id, data: { name: "Unsafe" } })
|
|
1239
|
+
: operation === "delete"
|
|
1240
|
+
? api.deleteForm({ id: form.id })
|
|
1241
|
+
: operation === "submit"
|
|
1242
|
+
? api.submitForm({
|
|
1243
|
+
slug: form.slug,
|
|
1244
|
+
data: { name: "Unsafe" },
|
|
1245
|
+
})
|
|
1246
|
+
: api.deleteSubmission({
|
|
1247
|
+
formId: form.id,
|
|
1248
|
+
submissionId: submission.id,
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1251
|
+
await expect(result).rejects.toMatchObject({
|
|
1252
|
+
statusCode: 500,
|
|
1253
|
+
code: "ATOMIC_TRANSACTION_REQUIRED",
|
|
1254
|
+
});
|
|
1255
|
+
expect(events).toEqual([]);
|
|
1256
|
+
expect(
|
|
1257
|
+
await backend.adapter.findOne<Form>({
|
|
1258
|
+
model: "form",
|
|
1259
|
+
where: [{ field: "id", value: form.id }],
|
|
1260
|
+
}),
|
|
1261
|
+
).toMatchObject({ name: "Contact", createdBy: owner.id });
|
|
1262
|
+
expect(
|
|
1263
|
+
await backend.adapter.count({
|
|
1264
|
+
model: "formSubmission",
|
|
1265
|
+
where: [{ field: "formId", value: form.id }],
|
|
1266
|
+
}),
|
|
1267
|
+
).toBe(1);
|
|
1268
|
+
},
|
|
1269
|
+
);
|
|
1270
|
+
|
|
1271
|
+
it("serializes a public submission hook and a competing status update", async () => {
|
|
1272
|
+
let enteredHook: (() => void) | undefined;
|
|
1273
|
+
let releaseHook: (() => void) | undefined;
|
|
1274
|
+
const entered = new Promise<void>((resolve) => {
|
|
1275
|
+
enteredHook = resolve;
|
|
1276
|
+
});
|
|
1277
|
+
const release = new Promise<void>((resolve) => {
|
|
1278
|
+
releaseHook = resolve;
|
|
1279
|
+
});
|
|
1280
|
+
const backend = makeBackend({
|
|
1281
|
+
auth: createAuth(),
|
|
1282
|
+
hooks: {
|
|
1283
|
+
onBeforeSubmission: async (_slug, data) => {
|
|
1284
|
+
enteredHook?.();
|
|
1285
|
+
await release;
|
|
1286
|
+
return data;
|
|
1287
|
+
},
|
|
1288
|
+
},
|
|
1289
|
+
});
|
|
1290
|
+
const form = await seedForm(backend, { slug: "post-claim-race" });
|
|
1291
|
+
const pending = backend
|
|
1292
|
+
.forRequest(request("/post-claim-race"))
|
|
1293
|
+
.operations.formBuilder.submitForm({
|
|
1294
|
+
slug: form.slug,
|
|
1295
|
+
data: { name: "Raced" },
|
|
1296
|
+
});
|
|
1297
|
+
await entered;
|
|
1298
|
+
const winningUpdate = backend.adapter.update<Form>({
|
|
1299
|
+
model: "form",
|
|
1300
|
+
where: [{ field: "id", value: form.id }],
|
|
1301
|
+
update: {
|
|
1302
|
+
status: "inactive",
|
|
1303
|
+
updatedAt: new Date("2026-04-01T00:00:00.000Z"),
|
|
1304
|
+
},
|
|
1305
|
+
});
|
|
1306
|
+
releaseHook?.();
|
|
1307
|
+
|
|
1308
|
+
await expect(pending).resolves.toMatchObject({ formId: form.id });
|
|
1309
|
+
await winningUpdate;
|
|
1310
|
+
expect(
|
|
1311
|
+
await backend.adapter.findOne<Form>({
|
|
1312
|
+
model: "form",
|
|
1313
|
+
where: [{ field: "id", value: form.id }],
|
|
1314
|
+
}),
|
|
1315
|
+
).toMatchObject({ status: "inactive" });
|
|
1316
|
+
expect(
|
|
1317
|
+
await backend.adapter.count({
|
|
1318
|
+
model: "formSubmission",
|
|
1319
|
+
where: [{ field: "formId", value: form.id }],
|
|
1320
|
+
}),
|
|
1321
|
+
).toBe(1);
|
|
1322
|
+
});
|
|
1323
|
+
|
|
1324
|
+
it("preserves a winning status race and runs no stale-caller hooks or writes", async () => {
|
|
1325
|
+
const events: string[] = [];
|
|
1326
|
+
let backend: ReturnType<typeof makeBackend>;
|
|
1327
|
+
let raced = false;
|
|
1328
|
+
backend = makeBackend({
|
|
1329
|
+
adapter: rawMemoryAdapter,
|
|
1330
|
+
auth: createAuth(async () => {
|
|
1331
|
+
if (!raced) {
|
|
1332
|
+
raced = true;
|
|
1333
|
+
const form = await backend.adapter.findOne<Form>({
|
|
1334
|
+
model: "form",
|
|
1335
|
+
where: [{ field: "slug", value: "memory-status-race" }],
|
|
1336
|
+
});
|
|
1337
|
+
if (form) {
|
|
1338
|
+
await backend.adapter.update<Form>({
|
|
1339
|
+
model: "form",
|
|
1340
|
+
where: [{ field: "id", value: form.id }],
|
|
1341
|
+
update: {
|
|
1342
|
+
status: "inactive",
|
|
1343
|
+
updatedAt: new Date("2026-05-01T00:00:00.000Z"),
|
|
1344
|
+
},
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
return null;
|
|
1349
|
+
}),
|
|
1350
|
+
hooks: {
|
|
1351
|
+
onBeforeSubmission: () => {
|
|
1352
|
+
events.push("before");
|
|
1353
|
+
},
|
|
1354
|
+
onAfterSubmission: () => {
|
|
1355
|
+
events.push("after");
|
|
1356
|
+
},
|
|
1357
|
+
},
|
|
1358
|
+
});
|
|
1359
|
+
const form = await seedForm(backend, { slug: "memory-status-race" });
|
|
1360
|
+
|
|
1361
|
+
await expect(
|
|
1362
|
+
backend
|
|
1363
|
+
.forRequest(request("/memory-status-race"))
|
|
1364
|
+
.operations.formBuilder.submitForm({
|
|
1365
|
+
slug: form.slug,
|
|
1366
|
+
data: { name: "Stale" },
|
|
1367
|
+
}),
|
|
1368
|
+
).rejects.toMatchObject({ statusCode: 409, code: "FORM_STATE_CHANGED" });
|
|
1369
|
+
expect(events).toEqual([]);
|
|
1370
|
+
expect(
|
|
1371
|
+
await backend.adapter.findOne<Form>({
|
|
1372
|
+
model: "form",
|
|
1373
|
+
where: [{ field: "id", value: form.id }],
|
|
1374
|
+
}),
|
|
1375
|
+
).toMatchObject({ status: "inactive" });
|
|
1376
|
+
expect(
|
|
1377
|
+
await backend.adapter.count({
|
|
1378
|
+
model: "formSubmission",
|
|
1379
|
+
where: [{ field: "formId", value: form.id }],
|
|
1380
|
+
}),
|
|
1381
|
+
).toBe(0);
|
|
1382
|
+
});
|
|
1383
|
+
|
|
1384
|
+
it("fails closed on the non-isolating memory adapter before hooks or claims", async () => {
|
|
1385
|
+
const beforeUpdate = vi.fn();
|
|
1386
|
+
const backend = makeBackend({
|
|
1387
|
+
adapter: rawMemoryAdapter,
|
|
1388
|
+
auth: createAuth(),
|
|
1389
|
+
hooks: { onBeforeUpdateForm: beforeUpdate },
|
|
1390
|
+
});
|
|
1391
|
+
const form = await seedForm(backend, { slug: "memory-no-isolation" });
|
|
1392
|
+
|
|
1393
|
+
await expect(
|
|
1394
|
+
backend
|
|
1395
|
+
.forRequest(request("/memory-no-isolation", { identity: owner }))
|
|
1396
|
+
.operations.formBuilder.updateForm({
|
|
1397
|
+
id: form.id,
|
|
1398
|
+
data: { name: "Unsafe" },
|
|
1399
|
+
}),
|
|
1400
|
+
).rejects.toMatchObject({
|
|
1401
|
+
statusCode: 500,
|
|
1402
|
+
code: "ATOMIC_TRANSACTION_REQUIRED",
|
|
1403
|
+
});
|
|
1404
|
+
expect(beforeUpdate).not.toHaveBeenCalled();
|
|
1405
|
+
expect(
|
|
1406
|
+
await backend.adapter.findOne<Form>({
|
|
1407
|
+
model: "form",
|
|
1408
|
+
where: [{ field: "id", value: form.id }],
|
|
1409
|
+
}),
|
|
1410
|
+
).toMatchObject({ name: "Contact", createdBy: owner.id });
|
|
1411
|
+
});
|
|
1412
|
+
|
|
1413
|
+
it.each(["form", "submission"] as const)(
|
|
1414
|
+
"rolls back a %s delete when its conditional target reports no match",
|
|
1415
|
+
async (target) => {
|
|
1416
|
+
const backend = makeBackend({ auth: createAuth() });
|
|
1417
|
+
const form = await seedForm(backend, { slug: `delete-zero-${target}` });
|
|
1418
|
+
const submission = await seedSubmission(backend, form.id);
|
|
1419
|
+
const transaction = backend.adapter.transaction.bind(backend.adapter);
|
|
1420
|
+
vi.spyOn(backend.adapter, "transaction").mockImplementation(
|
|
1421
|
+
async (callback) =>
|
|
1422
|
+
transaction(async (tx) => {
|
|
1423
|
+
const deleteMany = tx.deleteMany.bind(tx);
|
|
1424
|
+
vi.spyOn(tx, "deleteMany").mockImplementation(async (input) => {
|
|
1425
|
+
if (
|
|
1426
|
+
(target === "form" && input.model === "form") ||
|
|
1427
|
+
(target === "submission" && input.model === "formSubmission")
|
|
1428
|
+
) {
|
|
1429
|
+
return 0;
|
|
1430
|
+
}
|
|
1431
|
+
return deleteMany(input);
|
|
1432
|
+
});
|
|
1433
|
+
return callback(tx);
|
|
1434
|
+
}),
|
|
1435
|
+
);
|
|
1436
|
+
|
|
1437
|
+
const api = backend.forRequest(
|
|
1438
|
+
request("/delete-zero", { identity: owner }),
|
|
1439
|
+
).operations.formBuilder;
|
|
1440
|
+
await expect(
|
|
1441
|
+
target === "form"
|
|
1442
|
+
? api.deleteForm({ id: form.id })
|
|
1443
|
+
: api.deleteSubmission({
|
|
1444
|
+
formId: form.id,
|
|
1445
|
+
submissionId: submission.id,
|
|
1446
|
+
}),
|
|
1447
|
+
).rejects.toMatchObject({ statusCode: 409 });
|
|
1448
|
+
expect(
|
|
1449
|
+
await backend.adapter.findOne<Form>({
|
|
1450
|
+
model: "form",
|
|
1451
|
+
where: [{ field: "id", value: form.id }],
|
|
1452
|
+
}),
|
|
1453
|
+
).not.toBeNull();
|
|
1454
|
+
expect(
|
|
1455
|
+
await backend.adapter.findOne<FormSubmission>({
|
|
1456
|
+
model: "formSubmission",
|
|
1457
|
+
where: [{ field: "id", value: submission.id }],
|
|
1458
|
+
}),
|
|
1459
|
+
).not.toBeNull();
|
|
1460
|
+
},
|
|
1461
|
+
);
|
|
1462
|
+
|
|
1463
|
+
it("delivers the captured form to the submission after hook even if the row disappears after commit", async () => {
|
|
1464
|
+
const afterSubmission = vi.fn();
|
|
1465
|
+
const backend = makeBackend({
|
|
1466
|
+
auth: createAuth(),
|
|
1467
|
+
hooks: { onAfterSubmission: afterSubmission },
|
|
1468
|
+
});
|
|
1469
|
+
const form = await seedForm(backend, { slug: "after-snapshot" });
|
|
1470
|
+
const transaction = backend.adapter.transaction.bind(backend.adapter);
|
|
1471
|
+
vi.spyOn(backend.adapter, "transaction").mockImplementation(
|
|
1472
|
+
async (callback) => {
|
|
1473
|
+
const result = await transaction(callback);
|
|
1474
|
+
await backend.adapter.deleteMany({
|
|
1475
|
+
model: "form",
|
|
1476
|
+
where: [{ field: "id", value: form.id }],
|
|
1477
|
+
});
|
|
1478
|
+
return result;
|
|
1479
|
+
},
|
|
1480
|
+
);
|
|
1481
|
+
|
|
1482
|
+
await expect(
|
|
1483
|
+
backend
|
|
1484
|
+
.forRequest(request("/after-snapshot"))
|
|
1485
|
+
.operations.formBuilder.submitForm({
|
|
1486
|
+
slug: form.slug,
|
|
1487
|
+
data: { name: "Captured" },
|
|
1488
|
+
}),
|
|
1489
|
+
).resolves.toMatchObject({ formId: form.id });
|
|
1490
|
+
expect(afterSubmission).toHaveBeenCalledWith(
|
|
1491
|
+
expect.objectContaining({ formId: form.id }),
|
|
1492
|
+
expect.objectContaining({ id: form.id, slug: form.slug }),
|
|
1493
|
+
expect.objectContaining({ formId: form.id, formSlug: form.slug }),
|
|
1494
|
+
);
|
|
1495
|
+
});
|
|
1496
|
+
|
|
1497
|
+
it("rejects a collection-read race before returning submission rows", async () => {
|
|
1498
|
+
const backend = makeBackend({ auth: createAuth() });
|
|
1499
|
+
const form = await seedForm(backend, { slug: "read-race" });
|
|
1500
|
+
await seedSubmission(backend, form.id);
|
|
1501
|
+
const transaction = backend.adapter.transaction.bind(backend.adapter);
|
|
1502
|
+
let raced = false;
|
|
1503
|
+
vi.spyOn(backend.adapter, "transaction").mockImplementation(
|
|
1504
|
+
async (callback) =>
|
|
1505
|
+
transaction(async (tx) => {
|
|
1506
|
+
const findMany = tx.findMany.bind(tx);
|
|
1507
|
+
vi.spyOn(tx, "findMany").mockImplementation(async (input) => {
|
|
1508
|
+
const result = await findMany(input);
|
|
1509
|
+
if (!raced && input.model === "formSubmission") {
|
|
1510
|
+
raced = true;
|
|
1511
|
+
await tx.update<Form>({
|
|
1512
|
+
model: "form",
|
|
1513
|
+
where: [{ field: "id", value: form.id }],
|
|
1514
|
+
update: {
|
|
1515
|
+
createdBy: viewer.id,
|
|
1516
|
+
updatedAt: new Date("2026-03-01T00:00:00.000Z"),
|
|
1517
|
+
},
|
|
1518
|
+
});
|
|
1519
|
+
}
|
|
1520
|
+
return result;
|
|
1521
|
+
});
|
|
1522
|
+
return callback(tx);
|
|
1523
|
+
}),
|
|
1524
|
+
);
|
|
1525
|
+
|
|
1526
|
+
await expect(
|
|
1527
|
+
backend
|
|
1528
|
+
.forRequest(request("/read-race", { identity: owner }))
|
|
1529
|
+
.operations.formBuilder.listSubmissions({
|
|
1530
|
+
formId: form.id,
|
|
1531
|
+
query: { limit: 20, offset: 0 },
|
|
1532
|
+
}),
|
|
1533
|
+
).rejects.toMatchObject({ statusCode: 409 });
|
|
1534
|
+
expect(raced).toBe(true);
|
|
1535
|
+
});
|
|
1536
|
+
|
|
1537
|
+
it("keeps raw SSG/data helpers outside request and trusted operation namespaces", () => {
|
|
1538
|
+
const backend = makeBackend({ auth: createAuth() });
|
|
1539
|
+
const requestApi = backend.forRequest(request("/forms")).operations
|
|
1540
|
+
.formBuilder;
|
|
1541
|
+
expect("prefetchForRoute" in requestApi).toBe(false);
|
|
1542
|
+
expect("getAllForms" in requestApi).toBe(false);
|
|
1543
|
+
expect("prefetchForRoute" in backend.trusted.formBuilder).toBe(false);
|
|
1544
|
+
expect(Object.keys(requestApi).sort()).toEqual(
|
|
1545
|
+
Object.keys(backend.trusted.formBuilder).sort(),
|
|
1546
|
+
);
|
|
1547
|
+
});
|
|
1548
|
+
|
|
1549
|
+
it("hydrates protected route data under permission-aligned SSG keys", async () => {
|
|
1550
|
+
const backend = makeBackend({ auth: createAuth() });
|
|
1551
|
+
const form = await seedForm(backend);
|
|
1552
|
+
const submission = await seedSubmission(backend, form.id, {
|
|
1553
|
+
data: JSON.stringify({ secret: "never-hydrate-this" }),
|
|
1554
|
+
ipAddress: "203.0.113.2",
|
|
1555
|
+
userAgent: "ssg-sensitive-agent",
|
|
1556
|
+
});
|
|
1557
|
+
const queryClient = new QueryClient();
|
|
1558
|
+
|
|
1559
|
+
await backend.raw.formBuilder.prefetchForRoute("editForm", queryClient, {
|
|
1560
|
+
id: form.id,
|
|
1561
|
+
});
|
|
1562
|
+
expect(
|
|
1563
|
+
queryClient.getQueryData(FORM_QUERY_KEYS.formForUpdate(form.id)),
|
|
1564
|
+
).toMatchObject({ id: form.id, schema: activeSchema });
|
|
1565
|
+
|
|
1566
|
+
await backend.raw.formBuilder.prefetchForRoute("submissions", queryClient, {
|
|
1567
|
+
id: form.id,
|
|
1568
|
+
});
|
|
1569
|
+
const data = queryClient.getQueryData<{
|
|
1570
|
+
pages: Array<{
|
|
1571
|
+
form: Record<string, unknown>;
|
|
1572
|
+
items: Array<Record<string, unknown>>;
|
|
1573
|
+
total: number;
|
|
1574
|
+
}>;
|
|
1575
|
+
}>(
|
|
1576
|
+
FORM_QUERY_KEYS.submissionsList({
|
|
1577
|
+
formId: form.id,
|
|
1578
|
+
limit: 20,
|
|
1579
|
+
offset: 0,
|
|
1580
|
+
}),
|
|
1581
|
+
);
|
|
1582
|
+
expect(data?.pages[0]?.total).toBe(1);
|
|
1583
|
+
expect(Object.keys(data?.pages[0]?.form ?? {}).sort()).toEqual([
|
|
1584
|
+
"createdBy",
|
|
1585
|
+
"id",
|
|
1586
|
+
"name",
|
|
1587
|
+
]);
|
|
1588
|
+
expect(data?.pages[0]?.items).toEqual([
|
|
1589
|
+
{
|
|
1590
|
+
id: submission.id,
|
|
1591
|
+
formId: form.id,
|
|
1592
|
+
submittedAt: submission.submittedAt.toISOString(),
|
|
1593
|
+
submittedBy: submission.submittedBy,
|
|
1594
|
+
},
|
|
1595
|
+
]);
|
|
1596
|
+
expect(JSON.stringify(data)).not.toContain("never-hydrate-this");
|
|
1597
|
+
expect(JSON.stringify(data)).not.toContain("203.0.113.2");
|
|
1598
|
+
expect(JSON.stringify(data)).not.toContain("ssg-sensitive-agent");
|
|
1599
|
+
});
|
|
1600
|
+
});
|