@questpie/admin 1.1.1 → 3.0.0
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 +256 -488
- package/dist/augmentation.d.mts +414 -0
- package/dist/client/blocks/block-renderer.d.mts +45 -0
- package/dist/client/blocks/block-renderer.mjs +105 -0
- package/dist/client/blocks/index.d.mts +2 -0
- package/dist/client/blocks/types.d.mts +68 -0
- package/dist/client/blocks/types.mjs +19 -0
- package/dist/client/builder/admin-types.d.mts +40 -0
- package/dist/client/builder/admin.d.mts +110 -0
- package/dist/client/builder/admin.mjs +151 -0
- package/dist/client/builder/field/field.d.mts +51 -0
- package/dist/client/builder/field/field.mjs +37 -0
- package/dist/client/builder/index.d.mts +31 -0
- package/dist/client/builder/page/page.d.mts +24 -0
- package/dist/client/builder/page/page.mjs +31 -0
- package/dist/client/builder/registry.d.mts +50 -0
- package/dist/client/builder/types/action-registry.mjs +276 -0
- package/dist/client/builder/types/action-types.d.mts +226 -0
- package/dist/client/builder/types/collection-types.mjs +10 -0
- package/dist/client/builder/types/common.d.mts +46 -0
- package/dist/client/builder/types/field-types.d.mts +592 -0
- package/dist/client/builder/types/field-types.mjs +18 -0
- package/dist/client/builder/types/ui-config.d.mts +158 -0
- package/dist/client/builder/types/widget-types.d.mts +562 -0
- package/dist/client/builder/validation.d.mts +33 -0
- package/dist/client/builder/validation.mjs +227 -0
- package/dist/client/builder/view/view.d.mts +49 -0
- package/dist/client/builder/view/view.mjs +27 -0
- package/dist/client/builder/widget/widget.d.mts +27 -0
- package/dist/client/builder/widget/widget.mjs +21 -0
- package/dist/client/components/actions/action-button.mjs +245 -0
- package/dist/client/components/actions/action-dialog.mjs +559 -0
- package/dist/client/components/actions/confirmation-dialog.mjs +201 -0
- package/dist/client/components/actions/header-actions.mjs +210 -0
- package/dist/client/components/admin-link.d.mts +66 -0
- package/dist/client/components/admin-link.mjs +171 -0
- package/dist/client/components/auth/auth-guard.d.mts +50 -0
- package/dist/client/components/auth/auth-guard.mjs +60 -0
- package/dist/client/components/auth/auth-loading.d.mts +35 -0
- package/dist/client/components/auth/auth-loading.mjs +55 -0
- package/dist/client/components/blocks/block-canvas.mjs +159 -0
- package/dist/client/components/blocks/block-editor-context.mjs +125 -0
- package/dist/client/components/blocks/block-editor-layout.mjs +199 -0
- package/dist/client/components/blocks/block-editor-provider.mjs +235 -0
- package/dist/client/components/blocks/block-fields-renderer.mjs +240 -0
- package/dist/client/components/blocks/block-insert-button.mjs +189 -0
- package/dist/client/components/blocks/block-item-menu.mjs +363 -0
- package/dist/client/components/blocks/block-item.mjs +434 -0
- package/dist/client/components/blocks/block-library-sidebar.mjs +285 -0
- package/dist/client/components/blocks/block-tree.mjs +103 -0
- package/dist/client/components/blocks/block-type-icon.mjs +95 -0
- package/dist/client/components/blocks/utils/tree-utils.mjs +185 -0
- package/dist/client/components/component-renderer.d.mts +114 -0
- package/dist/client/components/component-renderer.mjs +258 -0
- package/dist/client/components/error-boundary.mjs +144 -0
- package/dist/client/components/fields/array-field.mjs +506 -0
- package/dist/client/components/fields/asset-preview-field.mjs +159 -0
- package/dist/client/components/fields/blocks-field/blocks-field.mjs +209 -0
- package/dist/client/components/fields/boolean-field.mjs +77 -0
- package/dist/client/components/fields/date-field.mjs +76 -0
- package/dist/client/components/fields/datetime-field.mjs +74 -0
- package/dist/client/components/fields/email-field.mjs +67 -0
- package/dist/client/components/fields/field-utils.mjs +64 -0
- package/dist/client/components/fields/field-wrapper.mjs +124 -0
- package/dist/client/components/fields/json-field.mjs +461 -0
- package/dist/client/components/fields/locale-badge.mjs +25 -0
- package/dist/client/components/fields/number-field.mjs +73 -0
- package/dist/client/components/fields/object-array-field.mjs +707 -0
- package/dist/client/components/fields/object-field.mjs +686 -0
- package/dist/client/components/fields/relation/displays/cards-display.mjs +254 -0
- package/dist/client/components/fields/relation/displays/chips-display.mjs +173 -0
- package/dist/client/components/fields/relation/displays/grid-display.mjs +209 -0
- package/dist/client/components/fields/relation/displays/list-display.mjs +247 -0
- package/dist/client/components/fields/relation/displays/table-display.mjs +309 -0
- package/dist/client/components/fields/relation/displays/types.mjs +72 -0
- package/dist/client/components/fields/relation/relation-items-display.mjs +143 -0
- package/dist/client/components/fields/relation-field.mjs +161 -0
- package/dist/client/components/fields/relation-picker.mjs +296 -0
- package/dist/client/components/fields/relation-select.mjs +232 -0
- package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +105 -0
- package/dist/client/components/fields/rich-text-editor/extensions.mjs +144 -0
- package/dist/client/components/fields/rich-text-editor/image-popover.mjs +221 -0
- package/dist/client/components/fields/rich-text-editor/index.mjs +520 -0
- package/dist/client/components/fields/rich-text-editor/link-popover.mjs +85 -0
- package/dist/client/components/fields/rich-text-editor/presets.mjs +123 -0
- package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +188 -0
- package/dist/client/components/fields/rich-text-editor/table-controls.mjs +433 -0
- package/dist/client/components/fields/rich-text-editor/toolbar.mjs +541 -0
- package/dist/client/components/fields/rich-text-editor/types.mjs +30 -0
- package/dist/client/components/fields/rich-text-editor/utils.mjs +50 -0
- package/dist/client/components/fields/rich-text-field.mjs +64 -0
- package/dist/client/components/fields/select-field.mjs +88 -0
- package/dist/client/components/fields/text-field.mjs +72 -0
- package/dist/client/components/fields/textarea-field.mjs +71 -0
- package/dist/client/components/fields/time-field.mjs +67 -0
- package/dist/client/components/fields/upload-field.mjs +621 -0
- package/dist/client/components/filter-builder/columns-tab.mjs +325 -0
- package/dist/client/components/filter-builder/filter-builder-sheet.mjs +456 -0
- package/dist/client/components/filter-builder/filters-tab.mjs +663 -0
- package/dist/client/components/filter-builder/saved-views-tab.mjs +278 -0
- package/dist/client/components/history-sidebar.mjs +496 -0
- package/dist/client/components/layout/field-layout-renderer.mjs +301 -0
- package/dist/client/components/locale-switcher.mjs +251 -0
- package/dist/client/components/media/media-grid.mjs +314 -0
- package/dist/client/components/media/media-picker-dialog.mjs +563 -0
- package/dist/client/components/preview/live-preview-mode.mjs +503 -0
- package/dist/client/components/preview/preview-pane.mjs +388 -0
- package/dist/client/components/primitives/asset-preview.mjs +771 -0
- package/dist/client/components/primitives/checkbox-input.mjs +59 -0
- package/dist/client/components/primitives/date-input.mjs +461 -0
- package/dist/client/components/primitives/dropzone.mjs +368 -0
- package/dist/client/components/primitives/number-input.mjs +117 -0
- package/dist/client/components/primitives/select-multi.mjs +590 -0
- package/dist/client/components/primitives/select-single.mjs +473 -0
- package/dist/client/components/primitives/text-input.mjs +45 -0
- package/dist/client/components/primitives/textarea-input.mjs +43 -0
- package/dist/client/components/primitives/time-input.mjs +145 -0
- package/dist/client/components/primitives/toggle-input.mjs +51 -0
- package/dist/client/components/primitives/types.mjs +12 -0
- package/dist/client/components/sheets/resource-sheet.mjs +86 -0
- package/dist/client/components/ui/accordion.mjs +169 -0
- package/dist/client/components/ui/alert.mjs +85 -0
- package/dist/client/components/ui/badge.mjs +76 -0
- package/dist/client/components/ui/button.mjs +84 -0
- package/dist/client/components/ui/card.mjs +206 -0
- package/dist/client/components/ui/checkbox.mjs +82 -0
- package/dist/client/components/ui/command.mjs +239 -0
- package/dist/client/components/ui/dialog.mjs +296 -0
- package/dist/client/components/ui/drawer.mjs +278 -0
- package/dist/client/components/ui/dropdown-menu.mjs +315 -0
- package/dist/client/components/ui/empty-state.mjs +99 -0
- package/dist/client/components/ui/field.mjs +354 -0
- package/dist/client/components/ui/input-group.mjs +201 -0
- package/dist/client/components/ui/input.mjs +46 -0
- package/dist/client/components/ui/kbd.mjs +53 -0
- package/dist/client/components/ui/label.mjs +45 -0
- package/dist/client/components/ui/popover.mjs +176 -0
- package/dist/client/components/ui/responsive-dialog.mjs +308 -0
- package/dist/client/components/ui/search-input.mjs +139 -0
- package/dist/client/components/ui/select.mjs +325 -0
- package/dist/client/components/ui/separator.mjs +47 -0
- package/dist/client/components/ui/sheet.mjs +280 -0
- package/dist/client/components/ui/sidebar.mjs +774 -0
- package/dist/client/components/ui/skeleton.mjs +40 -0
- package/dist/client/components/ui/sonner.d.mts +13 -0
- package/dist/client/components/ui/sonner.mjs +85 -0
- package/dist/client/components/ui/spinner.mjs +52 -0
- package/dist/client/components/ui/switch.mjs +58 -0
- package/dist/client/components/ui/table.mjs +276 -0
- package/dist/client/components/ui/tabs.mjs +160 -0
- package/dist/client/components/ui/textarea.mjs +40 -0
- package/dist/client/components/ui/toolbar.mjs +136 -0
- package/dist/client/components/ui/tooltip.mjs +146 -0
- package/dist/client/components/widgets/chart-widget.mjs +582 -0
- package/dist/client/components/widgets/progress-widget.mjs +200 -0
- package/dist/client/components/widgets/quick-actions-widget.mjs +209 -0
- package/dist/client/components/widgets/recent-items-widget.mjs +196 -0
- package/dist/client/components/widgets/stats-widget.mjs +261 -0
- package/dist/client/components/widgets/table-widget.mjs +273 -0
- package/dist/client/components/widgets/timeline-widget.mjs +279 -0
- package/dist/client/components/widgets/value-widget.mjs +312 -0
- package/dist/client/components/widgets/widget-skeletons.mjs +427 -0
- package/dist/client/contexts/breadcrumb-context.mjs +60 -0
- package/dist/client/contexts/focus-context.d.mts +87 -0
- package/dist/client/contexts/focus-context.mjs +250 -0
- package/dist/client/hooks/typed-hooks.d.mts +110 -0
- package/dist/client/hooks/typed-hooks.mjs +888 -0
- package/dist/client/hooks/use-action.mjs +329 -0
- package/dist/client/hooks/use-admin-config.mjs +69 -0
- package/dist/client/hooks/use-admin-preferences.mjs +171 -0
- package/dist/client/hooks/use-admin-routes.mjs +130 -0
- package/dist/client/hooks/use-audit-history.mjs +157 -0
- package/dist/client/hooks/use-auth.d.mts +97 -0
- package/dist/{use-auth-BoLmWtmU.mjs → client/hooks/use-auth.mjs} +9 -10
- package/dist/client/hooks/use-collection-fields.mjs +71 -0
- package/dist/client/hooks/use-collection-meta.mjs +153 -0
- package/dist/client/hooks/use-collection-schema.mjs +90 -0
- package/dist/client/hooks/use-collection-validation.mjs +88 -0
- package/dist/client/hooks/use-collection.d.mts +96 -0
- package/dist/client/hooks/use-collection.mjs +673 -0
- package/dist/client/hooks/use-current-user.d.mts +60 -0
- package/dist/client/hooks/use-current-user.mjs +79 -0
- package/dist/client/hooks/use-field-hooks.mjs +199 -0
- package/dist/client/hooks/use-field-options.d.mts +57 -0
- package/dist/client/hooks/use-field-options.mjs +269 -0
- package/dist/client/hooks/use-global-fields.mjs +58 -0
- package/dist/client/hooks/use-global-meta.mjs +105 -0
- package/dist/client/hooks/use-global-schema.mjs +53 -0
- package/dist/client/hooks/use-global.d.mts +51 -0
- package/dist/client/hooks/use-global.mjs +284 -0
- package/dist/client/hooks/use-locks.mjs +452 -0
- package/dist/client/hooks/use-media-query.d.mts +22 -0
- package/dist/client/hooks/use-media-query.mjs +81 -0
- package/dist/client/hooks/use-prefill-params.mjs +47 -0
- package/dist/client/hooks/use-questpie-query-options.mjs +50 -0
- package/dist/client/hooks/use-reactive-fields.d.mts +78 -0
- package/dist/client/hooks/use-reactive-fields.mjs +201 -0
- package/dist/client/hooks/use-realtime-highlight.mjs +158 -0
- package/dist/client/hooks/use-saved-views.mjs +140 -0
- package/dist/client/hooks/use-search-param-toggle.d.mts +12 -0
- package/dist/client/hooks/use-search-param-toggle.mjs +115 -0
- package/dist/client/hooks/use-search.mjs +258 -0
- package/dist/client/hooks/use-server-actions.mjs +191 -0
- package/dist/client/hooks/use-server-validation.mjs +291 -0
- package/dist/client/hooks/use-server-widget-data.d.mts +25 -0
- package/dist/client/hooks/use-server-widget-data.mjs +65 -0
- package/dist/client/hooks/use-setup-status.d.mts +38 -0
- package/dist/client/hooks/use-setup-status.mjs +62 -0
- package/dist/client/hooks/use-sidebar-search-param.d.mts +9 -0
- package/dist/client/hooks/use-sidebar-search-param.mjs +104 -0
- package/dist/client/hooks/use-transition-stage.mjs +125 -0
- package/dist/client/hooks/use-upload-collection.mjs +31 -0
- package/dist/client/hooks/use-upload.mjs +209 -0
- package/dist/client/hooks/use-validation-error-map.mjs +57 -0
- package/dist/client/hooks/use-view-state.mjs +479 -0
- package/dist/client/i18n/hooks.mjs +284 -0
- package/dist/client/i18n/intl-cache.mjs +64 -0
- package/dist/client/i18n/messages.mjs +6 -0
- package/dist/client/i18n/simple.d.mts +21 -0
- package/dist/client/i18n/simple.mjs +156 -0
- package/dist/client/i18n/types.d.mts +109 -0
- package/dist/client/lib/cookies.mjs +9 -0
- package/dist/client/lib/events.mjs +5 -0
- package/dist/client/lib/render-profiler.mjs +51 -0
- package/dist/client/lib/utils.mjs +23 -0
- package/dist/client/preview/block-scope-context.d.mts +73 -0
- package/dist/client/preview/block-scope-context.mjs +116 -0
- package/dist/client/preview/index.d.mts +5 -0
- package/dist/client/preview/preview-banner.d.mts +45 -0
- package/dist/client/preview/preview-banner.mjs +134 -0
- package/dist/client/preview/preview-field.d.mts +107 -0
- package/dist/client/preview/preview-field.mjs +227 -0
- package/dist/client/preview/types.d.mts +114 -0
- package/dist/client/preview/types.mjs +20 -0
- package/dist/client/preview/use-collection-preview.d.mts +70 -0
- package/dist/client/preview/use-collection-preview.mjs +163 -0
- package/dist/client/runtime/content-locales-provider.d.mts +1 -0
- package/dist/client/runtime/content-locales-provider.mjs +136 -0
- package/dist/client/runtime/index.d.mts +5 -0
- package/dist/client/runtime/index.mjs +6 -0
- package/dist/client/runtime/locale-scope.d.mts +2 -0
- package/dist/client/runtime/locale-scope.mjs +108 -0
- package/dist/client/runtime/provider.d.mts +203 -0
- package/dist/client/runtime/provider.mjs +393 -0
- package/dist/client/runtime/routes.d.mts +49 -0
- package/dist/client/runtime/routes.mjs +91 -0
- package/dist/client/runtime/translations-provider.mjs +242 -0
- package/dist/client/scope/index.d.mts +3 -0
- package/dist/client/scope/picker.d.mts +53 -0
- package/dist/client/scope/picker.mjs +395 -0
- package/dist/client/scope/provider.d.mts +103 -0
- package/dist/client/scope/provider.mjs +167 -0
- package/dist/client/scope/types.d.mts +111 -0
- package/dist/client/styles/index.css +344 -188
- package/dist/client/utils/auto-expand-fields.mjs +83 -0
- package/dist/client/utils/build-field-definitions-from-schema.mjs +259 -0
- package/dist/client/utils/dependency-tracker.mjs +61 -0
- package/dist/client/utils/detect-relations.mjs +45 -0
- package/dist/client/utils/locale-to-flag.d.mts +119 -0
- package/dist/client/utils/locale-to-flag.mjs +129 -0
- package/dist/client/utils/routes.mjs +195 -0
- package/dist/client/views/auth/accept-invite-form.d.mts +72 -0
- package/dist/client/views/auth/accept-invite-form.mjs +473 -0
- package/dist/client/views/auth/auth-layout.d.mts +43 -0
- package/dist/client/views/auth/auth-layout.mjs +116 -0
- package/dist/client/views/auth/forgot-password-form.d.mts +58 -0
- package/dist/client/views/auth/forgot-password-form.mjs +386 -0
- package/dist/client/views/auth/invite-form.mjs +497 -0
- package/dist/client/views/auth/login-form.d.mts +75 -0
- package/dist/client/views/auth/login-form.mjs +387 -0
- package/dist/client/views/auth/reset-password-form.d.mts +65 -0
- package/dist/client/views/auth/reset-password-form.mjs +515 -0
- package/dist/client/views/auth/setup-form.d.mts +60 -0
- package/dist/client/views/auth/setup-form.mjs +526 -0
- package/dist/client/views/collection/auto-form-fields.mjs +873 -0
- package/dist/client/views/collection/bulk-action-toolbar.mjs +480 -0
- package/dist/client/views/collection/cells/complex-cells.mjs +746 -0
- package/dist/client/views/collection/cells/primitive-cells.mjs +395 -0
- package/dist/client/views/collection/cells/relation-cells.mjs +260 -0
- package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +509 -0
- package/dist/client/views/collection/cells/shared/cell-helpers.mjs +125 -0
- package/dist/client/views/collection/cells/shared/relation-chip.mjs +121 -0
- package/dist/client/views/collection/cells/upload-cells.mjs +28 -0
- package/dist/client/views/collection/columns/build-columns.mjs +195 -0
- package/dist/client/views/collection/columns/column-defaults.mjs +123 -0
- package/dist/client/views/collection/field-context.mjs +126 -0
- package/dist/client/views/collection/field-renderer.mjs +368 -0
- package/dist/client/views/collection/form-view.mjs +1566 -0
- package/dist/client/views/collection/table-view.mjs +832 -0
- package/dist/client/views/collection/view-skeletons.mjs +215 -0
- package/dist/client/views/common/global-search.mjs +700 -0
- package/dist/client/views/dashboard/dashboard-grid.mjs +881 -0
- package/dist/client/views/dashboard/dashboard-widget.mjs +265 -0
- package/dist/client/views/dashboard/widget-card.mjs +372 -0
- package/dist/client/views/globals/global-form-view.mjs +1306 -0
- package/dist/client/views/layout/admin-layout-provider.d.mts +137 -0
- package/dist/client/views/layout/admin-layout-provider.mjs +193 -0
- package/dist/client/views/layout/admin-layout.d.mts +133 -0
- package/dist/client/views/layout/admin-layout.mjs +302 -0
- package/dist/client/views/layout/admin-router.d.mts +93 -0
- package/dist/client/views/layout/admin-router.mjs +1254 -0
- package/dist/client/views/layout/admin-sidebar.d.mts +99 -0
- package/dist/client/views/layout/admin-sidebar.mjs +1379 -0
- package/dist/client/views/layout/admin-topbar.mjs +236 -0
- package/dist/client/views/pages/accept-invite-page.d.mts +66 -0
- package/dist/client/views/pages/accept-invite-page.mjs +349 -0
- package/dist/client/views/pages/dashboard-page.d.mts +43 -0
- package/dist/client/views/pages/dashboard-page.mjs +84 -0
- package/dist/client/views/pages/forgot-password-page.d.mts +56 -0
- package/dist/client/views/pages/forgot-password-page.mjs +152 -0
- package/dist/client/views/pages/invite-page.d.mts +70 -0
- package/dist/client/views/pages/invite-page.mjs +161 -0
- package/dist/client/views/pages/login-page.d.mts +69 -0
- package/dist/client/views/pages/login-page.mjs +193 -0
- package/dist/client/views/pages/reset-password-page.d.mts +63 -0
- package/dist/client/views/pages/reset-password-page.mjs +257 -0
- package/dist/client/views/pages/setup-page.d.mts +61 -0
- package/dist/client/views/pages/setup-page.mjs +156 -0
- package/dist/client-module.d.mts +3 -0
- package/dist/client-module.mjs +3 -0
- package/dist/client.d.mts +99 -3
- package/dist/client.mjs +52 -12
- package/dist/components/rich-text/index.d.mts +1 -0
- package/dist/components/rich-text/rich-text-renderer.d.mts +103 -0
- package/dist/components/rich-text/rich-text-renderer.mjs +237 -0
- package/dist/index.d.mts +59 -3
- package/dist/index.mjs +52 -12
- package/dist/plugin.d.mts +2 -0
- package/dist/plugin.mjs +3 -0
- package/dist/server/adapters/nextjs.d.mts +120 -0
- package/dist/server/adapters/nextjs.mjs +110 -0
- package/dist/server/adapters/tanstack.d.mts +132 -0
- package/dist/server/adapters/tanstack.mjs +89 -0
- package/dist/server/augmentation/actions.d.mts +279 -0
- package/dist/server/augmentation/common.d.mts +76 -0
- package/dist/server/augmentation/dashboard.d.mts +547 -0
- package/dist/server/augmentation/form-layout.d.mts +303 -0
- package/dist/server/augmentation/index.d.mts +44 -0
- package/dist/server/augmentation/index.mjs +10 -0
- package/dist/server/augmentation/sidebar.d.mts +181 -0
- package/dist/server/augmentation/views.d.mts +237 -0
- package/dist/server/augmentation.d.mts +7 -0
- package/dist/server/block/index.d.mts +4 -0
- package/dist/server/codegen/admin-client-template.mjs +93 -0
- package/dist/server/codegen/projection-validator.mjs +67 -0
- package/dist/server/fields/blocks.d.mts +71 -0
- package/dist/server/fields/blocks.mjs +151 -0
- package/dist/server/fields/index.d.mts +15 -0
- package/dist/server/fields/index.mjs +15 -0
- package/dist/server/fields/rich-text.d.mts +68 -0
- package/dist/server/fields/rich-text.mjs +147 -0
- package/dist/server/i18n/index.mjs +43 -0
- package/dist/server/i18n/messages/cs.mjs +461 -0
- package/dist/server/i18n/messages/de.mjs +461 -0
- package/dist/server/i18n/messages/en.mjs +707 -0
- package/dist/server/i18n/messages/es.mjs +461 -0
- package/dist/server/i18n/messages/fr.mjs +461 -0
- package/dist/server/i18n/messages/index.mjs +23 -0
- package/dist/server/i18n/messages/pl.mjs +461 -0
- package/dist/server/i18n/messages/pt.mjs +464 -0
- package/dist/server/i18n/messages/sk.mjs +689 -0
- package/dist/server/modules/admin/.generated/module.d.mts +52 -0
- package/dist/server/modules/admin/.generated/module.mjs +78 -0
- package/dist/server/modules/admin/.generated/registries.d.mts +22 -0
- package/dist/server/modules/admin/auth-helpers.d.mts +142 -0
- package/dist/server/modules/admin/auth-helpers.mjs +107 -0
- package/dist/server/modules/admin/block/block-builder.d.mts +383 -0
- package/dist/server/modules/admin/block/block-builder.mjs +315 -0
- package/dist/server/modules/admin/block/index.d.mts +3 -0
- package/dist/server/modules/admin/block/introspection.d.mts +89 -0
- package/dist/server/modules/admin/block/introspection.mjs +100 -0
- package/dist/server/modules/admin/block/prefetch.d.mts +78 -0
- package/dist/server/modules/admin/block/prefetch.mjs +241 -0
- package/dist/server/modules/admin/client/.generated/module.d.mts +94 -0
- package/dist/server/modules/admin/client/.generated/module.mjs +91 -0
- package/dist/server/modules/admin/client/components/badge.d.mts +1 -0
- package/dist/server/modules/admin/client/components/icon.d.mts +1 -0
- package/dist/server/modules/admin/client/fields/array.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/array.mjs +12 -0
- package/dist/server/modules/admin/client/fields/assetPreview.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/assetPreview.mjs +18 -0
- package/dist/server/modules/admin/client/fields/blocks.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/blocks.mjs +12 -0
- package/dist/server/modules/admin/client/fields/boolean.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/boolean.mjs +12 -0
- package/dist/server/modules/admin/client/fields/date.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/date.mjs +12 -0
- package/dist/server/modules/admin/client/fields/datetime.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/datetime.mjs +12 -0
- package/dist/server/modules/admin/client/fields/email.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/email.mjs +12 -0
- package/dist/server/modules/admin/client/fields/json.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/json.mjs +11 -0
- package/dist/server/modules/admin/client/fields/number.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/number.mjs +12 -0
- package/dist/server/modules/admin/client/fields/object.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/object.mjs +12 -0
- package/dist/server/modules/admin/client/fields/relation.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/relation.mjs +12 -0
- package/dist/server/modules/admin/client/fields/richText.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/richText.mjs +11 -0
- package/dist/server/modules/admin/client/fields/select.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/select.mjs +12 -0
- package/dist/server/modules/admin/client/fields/text.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/text.mjs +12 -0
- package/dist/server/modules/admin/client/fields/textarea.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/textarea.mjs +12 -0
- package/dist/server/modules/admin/client/fields/time.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/time.mjs +12 -0
- package/dist/server/modules/admin/client/fields/upload.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/upload.mjs +12 -0
- package/dist/server/modules/admin/client/fields/url.d.mts +6 -0
- package/dist/server/modules/admin/client/fields/url.mjs +12 -0
- package/dist/server/modules/admin/client/index.d.mts +1 -0
- package/dist/server/modules/admin/client/pages/dashboard.d.mts +6 -0
- package/dist/server/modules/admin/client/pages/dashboard.mjs +11 -0
- package/dist/server/modules/admin/client/pages/forgotPassword.d.mts +6 -0
- package/dist/server/modules/admin/client/pages/forgotPassword.mjs +11 -0
- package/dist/server/modules/admin/client/pages/login.d.mts +6 -0
- package/dist/server/modules/admin/client/pages/login.mjs +11 -0
- package/dist/server/modules/admin/client/pages/resetPassword.d.mts +6 -0
- package/dist/server/modules/admin/client/pages/resetPassword.mjs +11 -0
- package/dist/server/modules/admin/client/pages/setup.d.mts +6 -0
- package/dist/server/modules/admin/client/pages/setup.mjs +11 -0
- package/dist/server/modules/admin/client/views/collection-form.mjs +10 -0
- package/dist/server/modules/admin/client/views/collection-table.mjs +10 -0
- package/dist/server/modules/admin/client/views/global-form.mjs +10 -0
- package/dist/server/modules/admin/client/widgets/chart.d.mts +6 -0
- package/dist/server/modules/admin/client/widgets/chart.mjs +7 -0
- package/dist/server/modules/admin/client/widgets/progress.d.mts +6 -0
- package/dist/server/modules/admin/client/widgets/progress.mjs +7 -0
- package/dist/server/modules/admin/client/widgets/quickActions.d.mts +6 -0
- package/dist/server/modules/admin/client/widgets/quickActions.mjs +7 -0
- package/dist/server/modules/admin/client/widgets/recentItems.d.mts +6 -0
- package/dist/server/modules/admin/client/widgets/recentItems.mjs +7 -0
- package/dist/server/modules/admin/client/widgets/stats.d.mts +6 -0
- package/dist/server/modules/admin/client/widgets/stats.mjs +7 -0
- package/dist/server/modules/admin/client/widgets/table.d.mts +6 -0
- package/dist/server/modules/admin/client/widgets/table.mjs +7 -0
- package/dist/server/modules/admin/client/widgets/timeline.d.mts +6 -0
- package/dist/server/modules/admin/client/widgets/timeline.mjs +7 -0
- package/dist/server/modules/admin/client/widgets/value.d.mts +6 -0
- package/dist/server/modules/admin/client/widgets/value.mjs +7 -0
- package/dist/server/modules/admin/collections/account.d.mts +77 -0
- package/dist/server/modules/admin/collections/account.mjs +23 -0
- package/dist/server/modules/admin/collections/admin-locks.d.mts +90 -0
- package/dist/server/modules/admin/collections/admin-locks.mjs +16 -0
- package/dist/server/modules/admin/collections/admin-preferences.d.mts +69 -0
- package/dist/server/modules/admin/collections/admin-preferences.mjs +16 -0
- package/dist/server/modules/admin/collections/admin-saved-views.d.mts +83 -0
- package/dist/server/modules/admin/collections/admin-saved-views.mjs +16 -0
- package/dist/server/modules/admin/collections/apikey.d.mts +99 -0
- package/dist/server/modules/admin/collections/apikey.mjs +15 -0
- package/dist/server/modules/admin/collections/assets.d.mts +72 -0
- package/dist/server/modules/admin/collections/assets.mjs +71 -0
- package/dist/server/modules/admin/collections/session.d.mts +69 -0
- package/dist/server/modules/admin/collections/session.mjs +15 -0
- package/dist/server/modules/admin/collections/user.d.mts +85 -0
- package/dist/server/modules/admin/collections/user.mjs +204 -0
- package/dist/server/modules/admin/collections/verification.d.mts +63 -0
- package/dist/server/modules/admin/collections/verification.mjs +15 -0
- package/dist/server/modules/admin/components/badge.d.mts +10 -0
- package/dist/server/modules/admin/components/badge.mjs +10 -0
- package/dist/server/modules/admin/components/icon.d.mts +9 -0
- package/dist/server/modules/admin/components/icon.mjs +11 -0
- package/dist/server/modules/admin/config/admin.mjs +34 -0
- package/dist/server/modules/admin/dto/admin-config.dto.mjs +102 -0
- package/dist/server/modules/admin/factories.mjs +172 -0
- package/dist/server/modules/admin/index.d.mts +1093 -0
- package/dist/server/modules/admin/index.mjs +26 -0
- package/dist/server/modules/admin/modules.mjs +11 -0
- package/dist/server/modules/admin/plugin.mjs +13 -0
- package/dist/server/modules/admin/routes/admin-config.d.mts +28 -0
- package/dist/server/modules/admin/routes/admin-config.mjs +552 -0
- package/dist/server/modules/admin/routes/execute-action.d.mts +92 -0
- package/dist/server/modules/admin/routes/execute-action.mjs +433 -0
- package/dist/server/modules/admin/routes/locales.d.mts +18 -0
- package/dist/server/modules/admin/routes/locales.mjs +69 -0
- package/dist/server/modules/admin/routes/preview.d.mts +80 -0
- package/dist/server/modules/admin/routes/preview.mjs +230 -0
- package/dist/server/modules/admin/routes/reactive.d.mts +74 -0
- package/dist/server/modules/admin/routes/reactive.mjs +350 -0
- package/dist/server/modules/admin/routes/route-helpers.d.mts +23 -0
- package/dist/server/modules/admin/routes/route-helpers.mjs +76 -0
- package/dist/server/modules/admin/routes/setup.d.mts +63 -0
- package/dist/server/modules/admin/routes/setup.mjs +114 -0
- package/dist/server/modules/admin/routes/translations.d.mts +26 -0
- package/dist/server/modules/admin/routes/translations.mjs +114 -0
- package/dist/server/modules/admin/routes/widget-data.d.mts +32 -0
- package/dist/server/modules/admin/routes/widget-data.mjs +62 -0
- package/dist/server/modules/admin/views/form.d.mts +8 -0
- package/dist/server/modules/admin/views/form.mjs +7 -0
- package/dist/server/modules/admin/views/global-form.d.mts +8 -0
- package/dist/server/modules/admin/views/global-form.mjs +7 -0
- package/dist/server/modules/admin/views/table.d.mts +8 -0
- package/dist/server/modules/admin/views/table.mjs +7 -0
- package/dist/server/modules/admin-preferences/collections/admin-preferences.mjs +37 -0
- package/dist/server/modules/admin-preferences/collections/locks.collection.mjs +55 -0
- package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +99 -0
- package/dist/server/modules/admin-preferences/collections/saved-views.mjs +38 -0
- package/dist/server/modules/audit/.generated/module.d.mts +60 -0
- package/dist/server/modules/audit/.generated/module.mjs +30 -0
- package/dist/server/modules/audit/collections/audit-log.d.mts +214 -0
- package/dist/server/modules/audit/collections/audit-log.mjs +107 -0
- package/dist/server/modules/audit/config/admin.mjs +21 -0
- package/dist/server/modules/audit/config/app.mjs +262 -0
- package/dist/server/modules/audit/index.d.mts +2 -0
- package/dist/server/modules/audit/jobs/audit-cleanup.d.mts +13 -0
- package/dist/server/modules/audit/jobs/audit-cleanup.mjs +28 -0
- package/dist/server/plugin.d.mts +26 -0
- package/dist/server/plugin.mjs +385 -0
- package/dist/server/proxy-factories.d.mts +85 -0
- package/dist/server/proxy-factories.mjs +302 -0
- package/dist/server/registry-helpers.d.mts +83 -0
- package/dist/server/registry-helpers.mjs +104 -0
- package/dist/server.d.mts +33 -250
- package/dist/server.mjs +22 -832
- package/dist/shared/preview-utils.d.mts +53 -0
- package/dist/{preview-utils-BKQ9-TMa.mjs → shared/preview-utils.mjs} +2 -3
- package/dist/{saved-views.types-BMsz5mCy.d.mts → shared/types/saved-views.types.d.mts} +7 -2
- package/dist/shared.d.mts +3 -57
- package/dist/shared.mjs +1 -1
- package/package.json +56 -51
- package/skills/questpie-admin/SKILL.md +397 -0
- package/skills/questpie-admin/blocks/SKILL.md +305 -0
- package/skills/questpie-admin/custom-ui/SKILL.md +307 -0
- package/skills/questpie-admin/views/SKILL.md +442 -0
- package/dist/auth-layout-M8K8_q5R.mjs +0 -181
- package/dist/auth-layout-M8K8_q5R.mjs.map +0 -1
- package/dist/bulk-upload-dialog-D7w7W1Hl.mjs +0 -273
- package/dist/bulk-upload-dialog-D7w7W1Hl.mjs.map +0 -1
- package/dist/card-BKHjBQfw.mjs +0 -58
- package/dist/card-BKHjBQfw.mjs.map +0 -1
- package/dist/client-D1DqawtP.d.mts +0 -13403
- package/dist/client-D1DqawtP.d.mts.map +0 -1
- package/dist/client-njX1rZmi.mjs +0 -22612
- package/dist/client-njX1rZmi.mjs.map +0 -1
- package/dist/content-locales-provider-BXvuIgfg.mjs +0 -1650
- package/dist/content-locales-provider-BXvuIgfg.mjs.map +0 -1
- package/dist/dashboard-page-B4PGEdc2.mjs +0 -2500
- package/dist/dashboard-page-B4PGEdc2.mjs.map +0 -1
- package/dist/dashboard-page-mCY0pgZv.mjs +0 -3
- package/dist/dropzone-Do3awXKd.mjs +0 -634
- package/dist/dropzone-Do3awXKd.mjs.map +0 -1
- package/dist/forgot-password-page-Bcp-An4Y.mjs +0 -221
- package/dist/forgot-password-page-Bcp-An4Y.mjs.map +0 -1
- package/dist/forgot-password-page-CEwsdLwn.mjs +0 -3
- package/dist/index-B4H3amCD.d.mts +0 -2753
- package/dist/index-B4H3amCD.d.mts.map +0 -1
- package/dist/login-page-BUnpCbCa.mjs +0 -3
- package/dist/login-page-CP4gA-dl.mjs +0 -298
- package/dist/login-page-CP4gA-dl.mjs.map +0 -1
- package/dist/preview-utils-BKQ9-TMa.mjs.map +0 -1
- package/dist/reset-password-page-BqfDmLxA.mjs +0 -281
- package/dist/reset-password-page-BqfDmLxA.mjs.map +0 -1
- package/dist/reset-password-page-CufHz3h3.mjs +0 -3
- package/dist/runtime-6VZM878K.mjs +0 -69
- package/dist/runtime-6VZM878K.mjs.map +0 -1
- package/dist/saved-views.types-BMsz5mCy.d.mts.map +0 -1
- package/dist/server.d.mts.map +0 -1
- package/dist/server.mjs.map +0 -1
- package/dist/setup-page-BNNzt_Z6.mjs +0 -3
- package/dist/setup-page-YAP_fzqh.mjs +0 -264
- package/dist/setup-page-YAP_fzqh.mjs.map +0 -1
- package/dist/shared.d.mts.map +0 -1
- package/dist/use-auth-BoLmWtmU.mjs.map +0 -1
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { AdminBlockConfig, FieldLayoutItem } from "../../../augmentation/form-layout.mjs";
|
|
2
|
+
import { AdminConfigContext } from "../../../augmentation/views.mjs";
|
|
3
|
+
import "../../../augmentation.mjs";
|
|
4
|
+
import { adminFields } from "../../../fields/index.mjs";
|
|
5
|
+
import { AppContext, BuiltinFields, Field, FieldBuilderProxy, FieldSchema, FieldState } from "questpie";
|
|
6
|
+
|
|
7
|
+
//#region src/server/modules/admin/block/block-builder.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Combined field types available in block field definitions.
|
|
11
|
+
* Includes all built-in questpie fields plus admin-specific fields (richText, blocks).
|
|
12
|
+
*/
|
|
13
|
+
type AdminBlockFields = BuiltinFields & typeof adminFields;
|
|
14
|
+
/**
|
|
15
|
+
* Block prefetch context.
|
|
16
|
+
* Provided to prefetch functions to fetch related data.
|
|
17
|
+
*
|
|
18
|
+
* Use `typedApp<App>(ctx.app)` for typed access.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* .prefetch(async ({ values, ctx }) => {
|
|
23
|
+
* const app = typedApp<App>(ctx.app);
|
|
24
|
+
* const res = await app.collections.posts.find({ limit: 5 });
|
|
25
|
+
* return { posts: res.docs };
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
type BlockPrefetchContext = AppContext & {
|
|
30
|
+
/** App instance — populated at runtime by extractAppServices */
|
|
31
|
+
app: unknown;
|
|
32
|
+
/** Database handle — populated at runtime by extractAppServices */
|
|
33
|
+
db: unknown;
|
|
34
|
+
/** Collection APIs — populated at runtime by extractAppServices */
|
|
35
|
+
collections: Record<string, any>;
|
|
36
|
+
/** Global APIs — populated at runtime by extractAppServices */
|
|
37
|
+
globals: Record<string, any>;
|
|
38
|
+
/** Block instance ID */
|
|
39
|
+
blockId: string;
|
|
40
|
+
/** Block type name */
|
|
41
|
+
blockType: string;
|
|
42
|
+
/** Current locale */
|
|
43
|
+
locale?: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Block prefetch function.
|
|
47
|
+
* Runs during CRUD read to fetch related data for the block.
|
|
48
|
+
* The returned data is attached to `_data[blockId]` in the response.
|
|
49
|
+
*/
|
|
50
|
+
type BlockPrefetchFn<TValues = Record<string, unknown>> = (params: {
|
|
51
|
+
/** Block field values */
|
|
52
|
+
values: TValues;
|
|
53
|
+
/** Prefetch context */
|
|
54
|
+
ctx: BlockPrefetchContext;
|
|
55
|
+
}) => Promise<Record<string, unknown>> | Record<string, unknown>;
|
|
56
|
+
/**
|
|
57
|
+
* Expanded record from expansion of relation/upload fields.
|
|
58
|
+
* Contains at minimum an `id` field plus any other fields from the referenced record.
|
|
59
|
+
*/
|
|
60
|
+
type ExpandedRecord = Record<string, unknown> & {
|
|
61
|
+
id: string;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Options for a single relation inside a block prefetch `with` clause.
|
|
65
|
+
* Same syntax as find's `with`, but only nested `with` is supported —
|
|
66
|
+
* query options (where, orderBy, limit, etc.) don't apply to block field expansion.
|
|
67
|
+
*
|
|
68
|
+
* Nested `with` is passed through to the collection's `find` call,
|
|
69
|
+
* reusing the existing relation resolution machinery.
|
|
70
|
+
*/
|
|
71
|
+
type BlockPrefetchWithOptions = {
|
|
72
|
+
with?: Record<string, true | BlockPrefetchWithOptions>;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Block prefetch `with` clause.
|
|
76
|
+
* Same object syntax as `with` in find operations.
|
|
77
|
+
*
|
|
78
|
+
* Each key is a relation/upload field name. Value can be:
|
|
79
|
+
* - `true` — expand the field to a full record
|
|
80
|
+
* - `{ with: { ... } }` — expand with nested relation loading
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* // Simple expansion
|
|
85
|
+
* .prefetch({ with: { backgroundImage: true } })
|
|
86
|
+
*
|
|
87
|
+
* // Nested expansion (e.g., expand author and their avatar)
|
|
88
|
+
* .prefetch({ with: { author: { with: { avatar: true } } } })
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
type BlockPrefetchWith<TFields = Record<string, unknown>> = { [K in keyof TFields]?: true | BlockPrefetchWithOptions };
|
|
92
|
+
/**
|
|
93
|
+
* Compute the expanded data type from a `with` config object.
|
|
94
|
+
* Each key that is `true` or `{ with: ... }` produces `ExpandedRecord | null`.
|
|
95
|
+
*/
|
|
96
|
+
type ExpandWithResult<TWith> = { [K in keyof TWith as TWith[K] extends false | undefined ? never : K]: ExpandedRecord | null };
|
|
97
|
+
/**
|
|
98
|
+
* Block builder state.
|
|
99
|
+
*/
|
|
100
|
+
interface BlockBuilderState<TName extends string = string, TFields extends Record<string, Field<FieldState>> = Record<string, Field<FieldState>>> {
|
|
101
|
+
/** Block type name */
|
|
102
|
+
name: TName;
|
|
103
|
+
/** Admin configuration (label, icon, description, category, etc.) */
|
|
104
|
+
admin?: AdminBlockConfig;
|
|
105
|
+
/** Field definitions */
|
|
106
|
+
fields?: TFields;
|
|
107
|
+
/** Allow child blocks */
|
|
108
|
+
allowChildren?: boolean;
|
|
109
|
+
/** Maximum number of child blocks */
|
|
110
|
+
maxChildren?: number;
|
|
111
|
+
/** Prefetch function (Shape 1: pure function) */
|
|
112
|
+
prefetch?: BlockPrefetchFn<any>;
|
|
113
|
+
/** Relation fields to expand via `.prefetch({ with: { ... } })` */
|
|
114
|
+
prefetchWith?: BlockPrefetchWith;
|
|
115
|
+
/** Loader function for `.prefetch({ with, loader })` (Shape 3) */
|
|
116
|
+
_prefetchLoader?: (params: {
|
|
117
|
+
values: any;
|
|
118
|
+
expanded: Record<string, unknown>;
|
|
119
|
+
ctx: BlockPrefetchContext;
|
|
120
|
+
}) => Promise<Record<string, unknown>> | Record<string, unknown>;
|
|
121
|
+
/** Type-level marker for prefetch data type (not used at runtime) */
|
|
122
|
+
"~prefetchData"?: unknown;
|
|
123
|
+
/** Form layout for block fields (sections, tabs, grid) */
|
|
124
|
+
form?: {
|
|
125
|
+
fields: FieldLayoutItem[];
|
|
126
|
+
};
|
|
127
|
+
/** Optional registered component names from Questpie builder registry */
|
|
128
|
+
"~components"?: string[];
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Block definition - the built block ready for registration.
|
|
132
|
+
*/
|
|
133
|
+
interface BlockDefinition<TState extends BlockBuilderState = BlockBuilderState> {
|
|
134
|
+
/** Block type name */
|
|
135
|
+
readonly name: TState["name"];
|
|
136
|
+
/** Full state */
|
|
137
|
+
readonly state: TState;
|
|
138
|
+
/** Get field metadata for introspection */
|
|
139
|
+
getFieldMetadata(): Record<string, FieldSchema>;
|
|
140
|
+
/** Execute prefetch if defined */
|
|
141
|
+
executePrefetch(values: Record<string, unknown>, ctx: BlockPrefetchContext): Promise<Record<string, unknown>>;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Builder class for defining block types.
|
|
145
|
+
*
|
|
146
|
+
* @template TState - Block builder state
|
|
147
|
+
* @template TFieldMap - Field type map for typed field proxy (from builder's registered fields)
|
|
148
|
+
* @template TData - Prefetch data type (set by .prefetch(), preserved through chain)
|
|
149
|
+
*/
|
|
150
|
+
declare class BlockBuilder<TState extends BlockBuilderState = BlockBuilderState, TFieldMap extends Record<string, any> = AdminBlockFields, TData = Record<string, unknown>> {
|
|
151
|
+
private _state;
|
|
152
|
+
/**
|
|
153
|
+
* Runtime field factories map. When provided (by codegen-generated factories),
|
|
154
|
+
* includes both builtin fields AND module-contributed fields with extension
|
|
155
|
+
* methods (e.g. `.admin()`, `.form()`). Falls back to raw builtinFields +
|
|
156
|
+
* adminFields when not provided (direct BlockBuilder usage).
|
|
157
|
+
*/
|
|
158
|
+
private _fieldDefs?;
|
|
159
|
+
constructor(state: TState);
|
|
160
|
+
/**
|
|
161
|
+
* Create a new BlockBuilder with optional pre-wrapped field defs.
|
|
162
|
+
*
|
|
163
|
+
* Mirrors CollectionBuilder.create() — codegen-generated factory functions
|
|
164
|
+
* pass the merged+wrapped field map so that field extension methods
|
|
165
|
+
* (`.admin()`, `.form()`) are available inside `.fields()` callbacks.
|
|
166
|
+
*/
|
|
167
|
+
static create<TName extends string, TFieldTypes extends Record<string, any> = AdminBlockFields>(name: TName, fieldDefs?: Record<string, any>): BlockBuilder<{
|
|
168
|
+
name: TName;
|
|
169
|
+
}, TFieldTypes>;
|
|
170
|
+
/** Create a child builder that inherits _fieldDefs. */
|
|
171
|
+
private _child;
|
|
172
|
+
/**
|
|
173
|
+
* Set admin metadata for the block.
|
|
174
|
+
* Follows the same pattern as collection .admin() method.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* block("hero")
|
|
179
|
+
* .admin(({ c }) => ({
|
|
180
|
+
* label: { en: "Hero Section", sk: "Hero sekcia" },
|
|
181
|
+
* icon: c.icon("ph:image"),
|
|
182
|
+
* description: { en: "Full-width hero with background image" },
|
|
183
|
+
* category: {
|
|
184
|
+
* label: { en: "Sections", sk: "Sekcie" },
|
|
185
|
+
* icon: c.icon("ph:layout"),
|
|
186
|
+
* order: 1,
|
|
187
|
+
* },
|
|
188
|
+
* order: 1,
|
|
189
|
+
* hidden: false,
|
|
190
|
+
* }))
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
admin(configOrFn: AdminBlockConfig | ((ctx: AdminConfigContext) => AdminBlockConfig)): BlockBuilder<TState & {
|
|
194
|
+
admin: AdminBlockConfig;
|
|
195
|
+
}, TFieldMap, TData>;
|
|
196
|
+
/**
|
|
197
|
+
* Define fields for the block.
|
|
198
|
+
* Uses the same field builder as collections.
|
|
199
|
+
*
|
|
200
|
+
* Uses destructured context object syntax: `({ f }) =>` (not positional `(f) =>`).
|
|
201
|
+
* This is consistent with collection/global `.fields()` and allows future
|
|
202
|
+
* extension of the context without breaking changes.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```ts
|
|
206
|
+
* block("hero").fields(({ f }) => ({
|
|
207
|
+
* title: f.text({ required: true }),
|
|
208
|
+
* subtitle: f.text(),
|
|
209
|
+
* image: f.upload({ accept: "image/*" }),
|
|
210
|
+
* }))
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
fields<TNewFields extends Record<string, Field<FieldState>>>(factory: (ctx: {
|
|
214
|
+
f: FieldBuilderProxy<TFieldMap>;
|
|
215
|
+
}) => TNewFields): BlockBuilder<Omit<TState, "fields"> & {
|
|
216
|
+
fields: TNewFields;
|
|
217
|
+
}, TFieldMap, TData>;
|
|
218
|
+
/**
|
|
219
|
+
* Define form layout for block fields.
|
|
220
|
+
* Supports sections, tabs, and grid layouts — same as collection .form().
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* block("pricing")
|
|
225
|
+
* .fields(({ f }) => ({
|
|
226
|
+
* title: f.text().required(),
|
|
227
|
+
* price: f.number().required(),
|
|
228
|
+
* currency: f.select([...]),
|
|
229
|
+
* description: f.textarea(),
|
|
230
|
+
* }))
|
|
231
|
+
* .form(({ f }) => ({
|
|
232
|
+
* fields: [
|
|
233
|
+
* { type: "section", label: "Basic", fields: [f.title, f.description] },
|
|
234
|
+
* { type: "section", label: "Pricing", layout: "grid", fields: [f.price, f.currency] },
|
|
235
|
+
* ],
|
|
236
|
+
* }))
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
form(configFn: (ctx: {
|
|
240
|
+
f: Record<string, string>;
|
|
241
|
+
}) => {
|
|
242
|
+
fields: FieldLayoutItem[];
|
|
243
|
+
}): BlockBuilder<TState & {
|
|
244
|
+
form: {
|
|
245
|
+
fields: FieldLayoutItem[];
|
|
246
|
+
};
|
|
247
|
+
}, TFieldMap, TData>;
|
|
248
|
+
/**
|
|
249
|
+
* Allow child blocks (for layout blocks).
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```ts
|
|
253
|
+
* block("columns").allowChildren()
|
|
254
|
+
* block("columns").allowChildren(4) // max 4 children
|
|
255
|
+
* ```
|
|
256
|
+
*/
|
|
257
|
+
allowChildren(maxChildren?: number): BlockBuilder<TState & {
|
|
258
|
+
allowChildren: true;
|
|
259
|
+
maxChildren?: number;
|
|
260
|
+
}, TFieldMap, TData>;
|
|
261
|
+
/**
|
|
262
|
+
* Add prefetch configuration for server-side data fetching.
|
|
263
|
+
* Runs during CRUD read to fetch related data for the block.
|
|
264
|
+
*
|
|
265
|
+
* Supports three shapes:
|
|
266
|
+
*
|
|
267
|
+
* **Shape 1: Pure function** — return data directly, `TData` inferred from return type.
|
|
268
|
+
* ```ts
|
|
269
|
+
* .prefetch(async ({ values, ctx }) => {
|
|
270
|
+
* return { services: res.docs };
|
|
271
|
+
* })
|
|
272
|
+
* ```
|
|
273
|
+
*
|
|
274
|
+
* **Shape 2: Expand relation/upload fields** — same `with` syntax as find operations.
|
|
275
|
+
* ```ts
|
|
276
|
+
* .prefetch({ with: { backgroundImage: true } })
|
|
277
|
+
*
|
|
278
|
+
* // Nested expansion (passes through to collection find's `with`)
|
|
279
|
+
* .prefetch({ with: { author: { with: { avatar: true } } } })
|
|
280
|
+
* ```
|
|
281
|
+
*
|
|
282
|
+
* **Shape 3: Expand + custom loader** — expand fields, then run a loader with the expanded data.
|
|
283
|
+
* ```ts
|
|
284
|
+
* .prefetch({
|
|
285
|
+
* with: { backgroundImage: true },
|
|
286
|
+
* loader: async ({ values, expanded, ctx }) => {
|
|
287
|
+
* return { analytics: await getStats() };
|
|
288
|
+
* },
|
|
289
|
+
* })
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
prefetch<TNewData extends Record<string, unknown>>(fn: (params: {
|
|
293
|
+
values: InferBlockValues<TState>;
|
|
294
|
+
ctx: BlockPrefetchContext;
|
|
295
|
+
}) => Promise<TNewData> | TNewData): BlockBuilder<Omit<TState, "prefetch" | "~prefetchData"> & {
|
|
296
|
+
prefetch: typeof fn;
|
|
297
|
+
"~prefetchData": TNewData;
|
|
298
|
+
}, TFieldMap, TNewData>;
|
|
299
|
+
prefetch<const TWith extends BlockPrefetchWith<InferBlockValues<TState>>, TLoaderData extends Record<string, unknown> = {}>(config: {
|
|
300
|
+
with: TWith;
|
|
301
|
+
loader?: (params: {
|
|
302
|
+
values: InferBlockValues<TState>;
|
|
303
|
+
expanded: ExpandWithResult<TWith>;
|
|
304
|
+
ctx: BlockPrefetchContext;
|
|
305
|
+
}) => Promise<TLoaderData> | TLoaderData;
|
|
306
|
+
}): BlockBuilder<Omit<TState, "prefetch" | "prefetchWith" | "_prefetchLoader" | "~prefetchData"> & {
|
|
307
|
+
prefetchWith: TWith;
|
|
308
|
+
"~prefetchData": ExpandWithResult<TWith> & TLoaderData;
|
|
309
|
+
}, TFieldMap, ExpandWithResult<TWith> & TLoaderData>;
|
|
310
|
+
/**
|
|
311
|
+
* Build the block definition.
|
|
312
|
+
* Called automatically when registering with .blocks().
|
|
313
|
+
*/
|
|
314
|
+
build(): BlockDefinition<TState>;
|
|
315
|
+
/**
|
|
316
|
+
* Get the current state (for internal use).
|
|
317
|
+
*/
|
|
318
|
+
get state(): TState;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Create a new server-side block builder.
|
|
322
|
+
*
|
|
323
|
+
* Defines block types with fields, validation, and prefetch logic.
|
|
324
|
+
* Blocks are server-only - the frontend handles rendering independently.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```ts
|
|
328
|
+
* import { block } from "@questpie/admin/server";
|
|
329
|
+
*
|
|
330
|
+
* const heroBlock = block("hero")
|
|
331
|
+
* .admin(({ c }) => ({
|
|
332
|
+
* label: { en: "Hero Section" },
|
|
333
|
+
* icon: c.icon("ph:image"),
|
|
334
|
+
* category: {
|
|
335
|
+
* label: { en: "Layout" },
|
|
336
|
+
* },
|
|
337
|
+
* }))
|
|
338
|
+
* .fields(({ f }) => ({
|
|
339
|
+
* title: f.text({ required: true }),
|
|
340
|
+
* subtitle: f.text(),
|
|
341
|
+
* }));
|
|
342
|
+
*
|
|
343
|
+
* // Register blocks on QUESTPIE
|
|
344
|
+
* const app = runtimeConfig({
|
|
345
|
+
* modules: [adminModule],
|
|
346
|
+
* blocks: { hero: heroBlock },
|
|
347
|
+
* .build({ ... });
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
declare function block<TName extends string>(name: TName): BlockBuilder<{
|
|
351
|
+
name: TName;
|
|
352
|
+
}>;
|
|
353
|
+
/**
|
|
354
|
+
* Extract field values type from block state.
|
|
355
|
+
* Infers value type per-field to produce heterogeneous types
|
|
356
|
+
* (e.g., { title: string, count: number, showPrices: boolean }).
|
|
357
|
+
*/
|
|
358
|
+
type InferBlockValues<TState extends BlockBuilderState> = TState["fields"] extends Record<string, any> ? { [K in keyof TState["fields"]]: TState["fields"][K] extends {
|
|
359
|
+
readonly _: infer TS extends FieldState;
|
|
360
|
+
} ? TS["data"] : unknown } : Record<string, unknown>;
|
|
361
|
+
/**
|
|
362
|
+
* Extract prefetch data type from a block builder or block state.
|
|
363
|
+
* Infers the `data` type based on `.prefetch()` configuration:
|
|
364
|
+
* - Shape 1 (function): return type of the prefetch function
|
|
365
|
+
* - Shape 2 (`{ with }` ): expanded fields as `{ [field]: ExpandedRecord | null }`
|
|
366
|
+
* - Shape 3 (`{ with, loader }`): expanded fields merged with loader return type
|
|
367
|
+
* - No prefetch: `Record<string, unknown>`
|
|
368
|
+
*
|
|
369
|
+
* Accepts either a `BlockBuilder` instance or a `BlockBuilderState`.
|
|
370
|
+
* Prefer passing the builder — state-level extraction may fail when
|
|
371
|
+
* `as any` casts are present in the builder chain.
|
|
372
|
+
*/
|
|
373
|
+
type InferBlockData<T> = T extends BlockBuilder<any, any, infer TData> ? TData : T extends BlockBuilderState ? T["~prefetchData"] extends Record<string, unknown> ? T["~prefetchData"] : Record<string, unknown> : Record<string, unknown>;
|
|
374
|
+
/**
|
|
375
|
+
* Any block builder (for generic usage).
|
|
376
|
+
*/
|
|
377
|
+
type AnyBlockBuilder = BlockBuilder<BlockBuilderState, any, any>;
|
|
378
|
+
/**
|
|
379
|
+
* Any block definition (for generic usage).
|
|
380
|
+
*/
|
|
381
|
+
type AnyBlockDefinition = BlockDefinition<BlockBuilderState>;
|
|
382
|
+
//#endregion
|
|
383
|
+
export { AnyBlockBuilder, AnyBlockDefinition, BlockBuilder, BlockBuilderState, BlockDefinition, BlockPrefetchContext, BlockPrefetchFn, BlockPrefetchWith, BlockPrefetchWithOptions, ExpandWithResult, ExpandedRecord, InferBlockData, InferBlockValues, block };
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { adminFields } from "../../../fields/index.mjs";
|
|
2
|
+
import { builtinFields, createFieldNameProxy, createFieldsCallbackContext } from "questpie";
|
|
3
|
+
|
|
4
|
+
//#region src/server/modules/admin/block/block-builder.ts
|
|
5
|
+
/**
|
|
6
|
+
* Block Builder
|
|
7
|
+
*
|
|
8
|
+
* Defines block types for the visual block editor.
|
|
9
|
+
* Blocks are registered on the app builder and can be used in blocks fields.
|
|
10
|
+
*
|
|
11
|
+
* Each block has:
|
|
12
|
+
* - Admin metadata (label, description, icon, category) via .admin()
|
|
13
|
+
* - Fields (using the same field system as collections)
|
|
14
|
+
* - Optional prefetch function (runs on CRUD read to fetch related data)
|
|
15
|
+
* - Optional children configuration (for nested blocks)
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { block } from "@questpie/admin/server";
|
|
20
|
+
*
|
|
21
|
+
* const heroBlock = block("hero")
|
|
22
|
+
* .admin(({ c }) => ({
|
|
23
|
+
* label: { en: "Hero Section", sk: "Hero sekcia" },
|
|
24
|
+
* icon: c.icon("ph:image"),
|
|
25
|
+
* category: {
|
|
26
|
+
* label: { en: "Sections", sk: "Sekcie" },
|
|
27
|
+
* icon: c.icon("ph:layout"),
|
|
28
|
+
* },
|
|
29
|
+
* }))
|
|
30
|
+
* .fields(({ f }) => ({
|
|
31
|
+
* title: f.text({ required: true }),
|
|
32
|
+
* subtitle: f.text(),
|
|
33
|
+
* backgroundImage: f.upload({ accept: "image/*" }),
|
|
34
|
+
* }))
|
|
35
|
+
* .prefetch({ with: { backgroundImage: true } });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* Create a component proxy for type-safe icon and UI element references.
|
|
40
|
+
* Used in .admin() config functions.
|
|
41
|
+
*/
|
|
42
|
+
function createComponentProxy(registeredComponentNames = []) {
|
|
43
|
+
const registered = new Set(registeredComponentNames);
|
|
44
|
+
const hasRegistry = registered.size > 0;
|
|
45
|
+
return new Proxy({}, {
|
|
46
|
+
get: (_target, prop) => {
|
|
47
|
+
if (typeof prop !== "string") return;
|
|
48
|
+
if (prop === "then") return;
|
|
49
|
+
if (hasRegistry && !registered.has(prop)) throw new Error(`Unknown component "${prop}" for block admin config. Available components: ${[...registered].sort().join(", ")}`);
|
|
50
|
+
return (props) => {
|
|
51
|
+
if (prop === "icon" && typeof props === "string") return {
|
|
52
|
+
type: "icon",
|
|
53
|
+
props: { name: props }
|
|
54
|
+
};
|
|
55
|
+
if (typeof props === "object" && props !== null) return {
|
|
56
|
+
type: prop,
|
|
57
|
+
props
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
type: prop,
|
|
61
|
+
props: { value: props }
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
has: (_target, prop) => {
|
|
66
|
+
if (typeof prop !== "string") return false;
|
|
67
|
+
return hasRegistry ? registered.has(prop) : true;
|
|
68
|
+
},
|
|
69
|
+
ownKeys: () => hasRegistry ? [...registered] : [],
|
|
70
|
+
getOwnPropertyDescriptor: (_target, prop) => {
|
|
71
|
+
if (typeof prop !== "string") return;
|
|
72
|
+
if (hasRegistry && !registered.has(prop)) return;
|
|
73
|
+
return {
|
|
74
|
+
configurable: true,
|
|
75
|
+
enumerable: hasRegistry,
|
|
76
|
+
writable: false,
|
|
77
|
+
value: (props) => {
|
|
78
|
+
if (prop === "icon" && typeof props === "string") return {
|
|
79
|
+
type: "icon",
|
|
80
|
+
props: { name: props }
|
|
81
|
+
};
|
|
82
|
+
if (typeof props === "object" && props !== null) return {
|
|
83
|
+
type: prop,
|
|
84
|
+
props
|
|
85
|
+
};
|
|
86
|
+
return {
|
|
87
|
+
type: prop,
|
|
88
|
+
props: { value: props }
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Builder class for defining block types.
|
|
97
|
+
*
|
|
98
|
+
* @template TState - Block builder state
|
|
99
|
+
* @template TFieldMap - Field type map for typed field proxy (from builder's registered fields)
|
|
100
|
+
* @template TData - Prefetch data type (set by .prefetch(), preserved through chain)
|
|
101
|
+
*/
|
|
102
|
+
var BlockBuilder = class BlockBuilder {
|
|
103
|
+
_state;
|
|
104
|
+
/**
|
|
105
|
+
* Runtime field factories map. When provided (by codegen-generated factories),
|
|
106
|
+
* includes both builtin fields AND module-contributed fields with extension
|
|
107
|
+
* methods (e.g. `.admin()`, `.form()`). Falls back to raw builtinFields +
|
|
108
|
+
* adminFields when not provided (direct BlockBuilder usage).
|
|
109
|
+
*/
|
|
110
|
+
_fieldDefs;
|
|
111
|
+
constructor(state) {
|
|
112
|
+
this._state = state;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Create a new BlockBuilder with optional pre-wrapped field defs.
|
|
116
|
+
*
|
|
117
|
+
* Mirrors CollectionBuilder.create() — codegen-generated factory functions
|
|
118
|
+
* pass the merged+wrapped field map so that field extension methods
|
|
119
|
+
* (`.admin()`, `.form()`) are available inside `.fields()` callbacks.
|
|
120
|
+
*/
|
|
121
|
+
static create(name, fieldDefs) {
|
|
122
|
+
const builder = new BlockBuilder({ name });
|
|
123
|
+
if (fieldDefs) builder._fieldDefs = fieldDefs;
|
|
124
|
+
return builder;
|
|
125
|
+
}
|
|
126
|
+
/** Create a child builder that inherits _fieldDefs. */
|
|
127
|
+
_child(state) {
|
|
128
|
+
const child = new BlockBuilder(state);
|
|
129
|
+
child._fieldDefs = this._fieldDefs;
|
|
130
|
+
return child;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Set admin metadata for the block.
|
|
134
|
+
* Follows the same pattern as collection .admin() method.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* block("hero")
|
|
139
|
+
* .admin(({ c }) => ({
|
|
140
|
+
* label: { en: "Hero Section", sk: "Hero sekcia" },
|
|
141
|
+
* icon: c.icon("ph:image"),
|
|
142
|
+
* description: { en: "Full-width hero with background image" },
|
|
143
|
+
* category: {
|
|
144
|
+
* label: { en: "Sections", sk: "Sekcie" },
|
|
145
|
+
* icon: c.icon("ph:layout"),
|
|
146
|
+
* order: 1,
|
|
147
|
+
* },
|
|
148
|
+
* order: 1,
|
|
149
|
+
* hidden: false,
|
|
150
|
+
* }))
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
admin(configOrFn) {
|
|
154
|
+
const registeredComponents = this._state["~components"] ?? [];
|
|
155
|
+
const config = typeof configOrFn === "function" ? configOrFn({ c: createComponentProxy(registeredComponents) }) : configOrFn;
|
|
156
|
+
return this._child({
|
|
157
|
+
...this._state,
|
|
158
|
+
admin: config
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Define fields for the block.
|
|
163
|
+
* Uses the same field builder as collections.
|
|
164
|
+
*
|
|
165
|
+
* Uses destructured context object syntax: `({ f }) =>` (not positional `(f) =>`).
|
|
166
|
+
* This is consistent with collection/global `.fields()` and allows future
|
|
167
|
+
* extension of the context without breaking changes.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* block("hero").fields(({ f }) => ({
|
|
172
|
+
* title: f.text({ required: true }),
|
|
173
|
+
* subtitle: f.text(),
|
|
174
|
+
* image: f.upload({ accept: "image/*" }),
|
|
175
|
+
* }))
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
fields(factory) {
|
|
179
|
+
const resolvedFields = factory(createFieldsCallbackContext(this._fieldDefs ?? {
|
|
180
|
+
...builtinFields,
|
|
181
|
+
...adminFields
|
|
182
|
+
}));
|
|
183
|
+
const child = new BlockBuilder({
|
|
184
|
+
...this._state,
|
|
185
|
+
fields: resolvedFields
|
|
186
|
+
});
|
|
187
|
+
child._fieldDefs = this._fieldDefs;
|
|
188
|
+
return child;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Define form layout for block fields.
|
|
192
|
+
* Supports sections, tabs, and grid layouts — same as collection .form().
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```ts
|
|
196
|
+
* block("pricing")
|
|
197
|
+
* .fields(({ f }) => ({
|
|
198
|
+
* title: f.text().required(),
|
|
199
|
+
* price: f.number().required(),
|
|
200
|
+
* currency: f.select([...]),
|
|
201
|
+
* description: f.textarea(),
|
|
202
|
+
* }))
|
|
203
|
+
* .form(({ f }) => ({
|
|
204
|
+
* fields: [
|
|
205
|
+
* { type: "section", label: "Basic", fields: [f.title, f.description] },
|
|
206
|
+
* { type: "section", label: "Pricing", layout: "grid", fields: [f.price, f.currency] },
|
|
207
|
+
* ],
|
|
208
|
+
* }))
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
form(configFn) {
|
|
212
|
+
const resolved = configFn({ f: createFieldNameProxy() });
|
|
213
|
+
return this._child({
|
|
214
|
+
...this._state,
|
|
215
|
+
form: resolved
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Allow child blocks (for layout blocks).
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* block("columns").allowChildren()
|
|
224
|
+
* block("columns").allowChildren(4) // max 4 children
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
allowChildren(maxChildren) {
|
|
228
|
+
return this._child({
|
|
229
|
+
...this._state,
|
|
230
|
+
allowChildren: true,
|
|
231
|
+
maxChildren
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
prefetch(fnOrConfig) {
|
|
235
|
+
if (typeof fnOrConfig === "function") return this._child({
|
|
236
|
+
...this._state,
|
|
237
|
+
prefetch: fnOrConfig
|
|
238
|
+
});
|
|
239
|
+
const { with: withFields, loader } = fnOrConfig;
|
|
240
|
+
return this._child({
|
|
241
|
+
...this._state,
|
|
242
|
+
prefetchWith: withFields,
|
|
243
|
+
_prefetchLoader: loader
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Build the block definition.
|
|
248
|
+
* Called automatically when registering with .blocks().
|
|
249
|
+
*/
|
|
250
|
+
build() {
|
|
251
|
+
const state = this._state;
|
|
252
|
+
return {
|
|
253
|
+
name: state.name,
|
|
254
|
+
state,
|
|
255
|
+
getFieldMetadata() {
|
|
256
|
+
if (!state.fields) return {};
|
|
257
|
+
const fields = {};
|
|
258
|
+
for (const [name, fieldDef] of Object.entries(state.fields)) fields[name] = {
|
|
259
|
+
name,
|
|
260
|
+
metadata: fieldDef.getMetadata()
|
|
261
|
+
};
|
|
262
|
+
return fields;
|
|
263
|
+
},
|
|
264
|
+
async executePrefetch(values, ctx) {
|
|
265
|
+
if (!state.prefetch) return {};
|
|
266
|
+
return state.prefetch({
|
|
267
|
+
values,
|
|
268
|
+
ctx
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Get the current state (for internal use).
|
|
275
|
+
*/
|
|
276
|
+
get state() {
|
|
277
|
+
return this._state;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Create a new server-side block builder.
|
|
282
|
+
*
|
|
283
|
+
* Defines block types with fields, validation, and prefetch logic.
|
|
284
|
+
* Blocks are server-only - the frontend handles rendering independently.
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```ts
|
|
288
|
+
* import { block } from "@questpie/admin/server";
|
|
289
|
+
*
|
|
290
|
+
* const heroBlock = block("hero")
|
|
291
|
+
* .admin(({ c }) => ({
|
|
292
|
+
* label: { en: "Hero Section" },
|
|
293
|
+
* icon: c.icon("ph:image"),
|
|
294
|
+
* category: {
|
|
295
|
+
* label: { en: "Layout" },
|
|
296
|
+
* },
|
|
297
|
+
* }))
|
|
298
|
+
* .fields(({ f }) => ({
|
|
299
|
+
* title: f.text({ required: true }),
|
|
300
|
+
* subtitle: f.text(),
|
|
301
|
+
* }));
|
|
302
|
+
*
|
|
303
|
+
* // Register blocks on QUESTPIE
|
|
304
|
+
* const app = runtimeConfig({
|
|
305
|
+
* modules: [adminModule],
|
|
306
|
+
* blocks: { hero: heroBlock },
|
|
307
|
+
* .build({ ... });
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
function block(name) {
|
|
311
|
+
return new BlockBuilder({ name });
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
//#endregion
|
|
315
|
+
export { BlockBuilder, block };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { AnyBlockBuilder, AnyBlockDefinition, BlockBuilder, BlockBuilderState, BlockDefinition, BlockPrefetchContext, BlockPrefetchFn, BlockPrefetchWith, BlockPrefetchWithOptions, ExpandWithResult, ExpandedRecord, InferBlockData, InferBlockValues, block } from "./block-builder.mjs";
|
|
2
|
+
import { BlockSchema, getBlocksByCategory, introspectBlock, introspectBlocks } from "./introspection.mjs";
|
|
3
|
+
import { BlocksPrefetchContext, createBlocksPrefetchHook, processBlocksDocument, processDocumentBlocksPrefetch } from "./prefetch.mjs";
|