@endora-commerce/mod-cms 0.109.0 → 0.111.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 +1 -0
- package/dist/admin/components/AdminCatalogPreviewProvider.d.ts +9 -0
- package/dist/admin/components/AdminCatalogPreviewProvider.js +37 -3
- package/dist/admin/components/FormBlockFields.d.ts +15 -0
- package/dist/admin/components/FormBlockFields.js +23 -0
- package/dist/admin/components/PageBuilderEditor.js +11 -2
- package/dist/admin/components/admin-catalog-preview-map.d.ts +5 -5
- package/dist/admin/components/admin-catalog-preview-map.js +5 -5
- package/dist/admin/components/block-contributions.d.ts +15 -0
- package/dist/admin/components/block-contributions.js +22 -0
- package/dist/admin/index.js +7 -0
- package/dist/admin/pages/BrandPage.js +9 -3
- package/dist/admin/zones/ProductContentEditor.d.ts +27 -0
- package/dist/admin/zones/ProductContentEditor.js +28 -0
- package/dist/backend/index.d.ts +3 -0
- package/dist/backend/index.js +31 -3
- package/dist/backend/plugin.d.ts +8 -0
- package/dist/backend/plugin.js +4 -0
- package/dist/backend/routes.admin.js +3 -4
- package/dist/backend/routes.storefront.js +15 -4
- package/dist/backend/services/asset-embed-resolver.d.ts +18 -10
- package/dist/backend/services/asset-embed-resolver.js +35 -30
- package/dist/backend/services/cms-block-read-port.js +3 -0
- package/dist/backend/services/cms-block-service.js +4 -1
- package/dist/backend/services/cms-cache.d.ts +4 -4
- package/dist/backend/services/cms-cache.js +1 -1
- package/dist/backend/services/cms-content-invalidator.d.ts +9 -1
- package/dist/backend/services/cms-content-invalidator.js +21 -1
- package/dist/backend/services/cms-hook-service.js +6 -1
- package/dist/backend/services/cms-page-read-port.d.ts +6 -0
- package/dist/backend/services/cms-page-read-port.js +22 -0
- package/dist/backend/services/cms-page-service.d.ts +7 -0
- package/dist/backend/services/cms-page-service.js +31 -6
- package/dist/backend/services/cms-template-service.js +4 -1
- package/dist/backend/services/reserved-segment-registry.d.ts +16 -0
- package/dist/backend/services/reserved-segment-registry.js +31 -0
- package/dist/backend/services/storefront-resolver.d.ts +7 -3
- package/dist/backend/services/storefront-resolver.js +8 -12
- package/dist/manifest.d.ts +13 -1
- package/dist/test-support/index.d.ts +20 -0
- package/dist/test-support/index.js +20 -0
- package/docs/cms/brand.md +1 -1
- package/docs/cms/index.md +29 -16
- package/i18n/en.json +30 -24
- package/i18n/pl.json +8 -2
- package/package.json +24 -18
- package/dist/admin/api/cms-client.d.ts.map +0 -1
- package/dist/admin/api/cms-client.js.map +0 -1
- package/dist/admin/components/AdminCatalogPreviewProvider.d.ts.map +0 -1
- package/dist/admin/components/AdminCatalogPreviewProvider.js.map +0 -1
- package/dist/admin/components/AdminCmsAssetProvider.d.ts.map +0 -1
- package/dist/admin/components/AdminCmsAssetProvider.js.map +0 -1
- package/dist/admin/components/BackgroundFields.d.ts.map +0 -1
- package/dist/admin/components/BackgroundFields.js.map +0 -1
- package/dist/admin/components/BrandFontFields.d.ts.map +0 -1
- package/dist/admin/components/BrandFontFields.js.map +0 -1
- package/dist/admin/components/BrandPreview.d.ts.map +0 -1
- package/dist/admin/components/BrandPreview.js.map +0 -1
- package/dist/admin/components/CarouselAddSlideMenu.d.ts.map +0 -1
- package/dist/admin/components/CarouselAddSlideMenu.js.map +0 -1
- package/dist/admin/components/CarouselFields.d.ts.map +0 -1
- package/dist/admin/components/CarouselFields.js.map +0 -1
- package/dist/admin/components/CarouselPreviewNav.d.ts.map +0 -1
- package/dist/admin/components/CarouselPreviewNav.js.map +0 -1
- package/dist/admin/components/ComponentDragHandle.d.ts.map +0 -1
- package/dist/admin/components/ComponentDragHandle.js.map +0 -1
- package/dist/admin/components/ContentSliderActionBarExtras.d.ts.map +0 -1
- package/dist/admin/components/ContentSliderActionBarExtras.js.map +0 -1
- package/dist/admin/components/HeroFields.d.ts.map +0 -1
- package/dist/admin/components/HeroFields.js.map +0 -1
- package/dist/admin/components/HookBlockAttachmentsPanel.d.ts.map +0 -1
- package/dist/admin/components/HookBlockAttachmentsPanel.js.map +0 -1
- package/dist/admin/components/ListingFields.d.ts.map +0 -1
- package/dist/admin/components/ListingFields.js.map +0 -1
- package/dist/admin/components/NewsletterSignupFields.d.ts.map +0 -1
- package/dist/admin/components/NewsletterSignupFields.js.map +0 -1
- package/dist/admin/components/PageBuilderActionBar.d.ts.map +0 -1
- package/dist/admin/components/PageBuilderActionBar.js.map +0 -1
- package/dist/admin/components/PageBuilderDrawer.d.ts.map +0 -1
- package/dist/admin/components/PageBuilderDrawer.js.map +0 -1
- package/dist/admin/components/PageBuilderEditor.d.ts.map +0 -1
- package/dist/admin/components/PageBuilderEditor.js.map +0 -1
- package/dist/admin/components/PageBuilderTranslateAction.d.ts.map +0 -1
- package/dist/admin/components/PageBuilderTranslateAction.js.map +0 -1
- package/dist/admin/components/PageNavigationFields.d.ts.map +0 -1
- package/dist/admin/components/PageNavigationFields.js.map +0 -1
- package/dist/admin/components/PreviewBrandTokens.d.ts.map +0 -1
- package/dist/admin/components/PreviewBrandTokens.js.map +0 -1
- package/dist/admin/components/PuckActionGuard.d.ts.map +0 -1
- package/dist/admin/components/PuckActionGuard.js.map +0 -1
- package/dist/admin/components/RowLayoutPicker.d.ts.map +0 -1
- package/dist/admin/components/RowLayoutPicker.js.map +0 -1
- package/dist/admin/components/SectionBlockFields.d.ts.map +0 -1
- package/dist/admin/components/SectionBlockFields.js.map +0 -1
- package/dist/admin/components/SectionPresetsPanel.d.ts.map +0 -1
- package/dist/admin/components/SectionPresetsPanel.js.map +0 -1
- package/dist/admin/components/SliderPreviewActionBarExtras.d.ts.map +0 -1
- package/dist/admin/components/SliderPreviewActionBarExtras.js.map +0 -1
- package/dist/admin/components/TranslationNotice.d.ts.map +0 -1
- package/dist/admin/components/TranslationNotice.js.map +0 -1
- package/dist/admin/components/admin-catalog-preview-map.d.ts.map +0 -1
- package/dist/admin/components/admin-catalog-preview-map.js.map +0 -1
- package/dist/admin/components/block-contributions.d.ts.map +0 -1
- package/dist/admin/components/block-contributions.js.map +0 -1
- package/dist/admin/components/build-viewports.d.ts.map +0 -1
- package/dist/admin/components/build-viewports.js.map +0 -1
- package/dist/admin/components/cms-template-layout.d.ts.map +0 -1
- package/dist/admin/components/cms-template-layout.js.map +0 -1
- package/dist/admin/components/page-builder-i18n.d.ts.map +0 -1
- package/dist/admin/components/page-builder-i18n.js.map +0 -1
- package/dist/admin/components/puck-safe.d.ts.map +0 -1
- package/dist/admin/components/puck-safe.js.map +0 -1
- package/dist/admin/components/scope-utils.d.ts.map +0 -1
- package/dist/admin/components/scope-utils.js.map +0 -1
- package/dist/admin/editors/BlockEditor.d.ts.map +0 -1
- package/dist/admin/editors/BlockEditor.js.map +0 -1
- package/dist/admin/editors/PageEditor.d.ts.map +0 -1
- package/dist/admin/editors/PageEditor.js.map +0 -1
- package/dist/admin/editors/TemplateEditor.d.ts.map +0 -1
- package/dist/admin/editors/TemplateEditor.js.map +0 -1
- package/dist/admin/index.d.ts.map +0 -1
- package/dist/admin/index.js.map +0 -1
- package/dist/admin/pages/BlocksListPage.d.ts.map +0 -1
- package/dist/admin/pages/BlocksListPage.js.map +0 -1
- package/dist/admin/pages/BrandPage.d.ts.map +0 -1
- package/dist/admin/pages/BrandPage.js.map +0 -1
- package/dist/admin/pages/HooksPage.d.ts.map +0 -1
- package/dist/admin/pages/HooksPage.js.map +0 -1
- package/dist/admin/pages/PagesListPage.d.ts.map +0 -1
- package/dist/admin/pages/PagesListPage.js.map +0 -1
- package/dist/admin/pages/TemplatesListPage.d.ts.map +0 -1
- package/dist/admin/pages/TemplatesListPage.js.map +0 -1
- package/dist/admin/zones/CategoryContentEditor.d.ts.map +0 -1
- package/dist/admin/zones/CategoryContentEditor.js.map +0 -1
- package/dist/admin-ui/index.d.ts.map +0 -1
- package/dist/admin-ui/index.js.map +0 -1
- package/dist/backend/cli/block-names.d.ts.map +0 -1
- package/dist/backend/cli/block-names.js.map +0 -1
- package/dist/backend/commands/translate-page-builder-content.command.d.ts.map +0 -1
- package/dist/backend/commands/translate-page-builder-content.command.js.map +0 -1
- package/dist/backend/entities/cms-block.entity.d.ts.map +0 -1
- package/dist/backend/entities/cms-block.entity.js.map +0 -1
- package/dist/backend/entities/cms-brand-tokens.entity.d.ts.map +0 -1
- package/dist/backend/entities/cms-brand-tokens.entity.js.map +0 -1
- package/dist/backend/entities/cms-hook-block-attachment.entity.d.ts.map +0 -1
- package/dist/backend/entities/cms-hook-block-attachment.entity.js.map +0 -1
- package/dist/backend/entities/cms-hook.entity.d.ts.map +0 -1
- package/dist/backend/entities/cms-hook.entity.js.map +0 -1
- package/dist/backend/entities/cms-page.entity.d.ts.map +0 -1
- package/dist/backend/entities/cms-page.entity.js.map +0 -1
- package/dist/backend/entities/cms-template.entity.d.ts.map +0 -1
- package/dist/backend/entities/cms-template.entity.js.map +0 -1
- package/dist/backend/index.d.ts.map +0 -1
- package/dist/backend/index.js.map +0 -1
- package/dist/backend/plugin.d.ts.map +0 -1
- package/dist/backend/plugin.js.map +0 -1
- package/dist/backend/routes.admin.d.ts.map +0 -1
- package/dist/backend/routes.admin.js.map +0 -1
- package/dist/backend/routes.storefront.d.ts.map +0 -1
- package/dist/backend/routes.storefront.js.map +0 -1
- package/dist/backend/services/anchor-guard.d.ts.map +0 -1
- package/dist/backend/services/anchor-guard.js.map +0 -1
- package/dist/backend/services/asset-embed-resolver.d.ts.map +0 -1
- package/dist/backend/services/asset-embed-resolver.js.map +0 -1
- package/dist/backend/services/asset-references.d.ts.map +0 -1
- package/dist/backend/services/asset-references.js.map +0 -1
- package/dist/backend/services/brand-tokens-service.d.ts.map +0 -1
- package/dist/backend/services/brand-tokens-service.js.map +0 -1
- package/dist/backend/services/channel-language-prefixes.d.ts.map +0 -1
- package/dist/backend/services/channel-language-prefixes.js.map +0 -1
- package/dist/backend/services/cms-block-read-port.d.ts.map +0 -1
- package/dist/backend/services/cms-block-read-port.js.map +0 -1
- package/dist/backend/services/cms-block-seed-port.d.ts.map +0 -1
- package/dist/backend/services/cms-block-seed-port.js.map +0 -1
- package/dist/backend/services/cms-block-service.d.ts.map +0 -1
- package/dist/backend/services/cms-block-service.js.map +0 -1
- package/dist/backend/services/cms-cache.d.ts.map +0 -1
- package/dist/backend/services/cms-cache.js.map +0 -1
- package/dist/backend/services/cms-content-invalidator.d.ts.map +0 -1
- package/dist/backend/services/cms-content-invalidator.js.map +0 -1
- package/dist/backend/services/cms-hook-service.d.ts.map +0 -1
- package/dist/backend/services/cms-hook-service.js.map +0 -1
- package/dist/backend/services/cms-language-reference.d.ts.map +0 -1
- package/dist/backend/services/cms-language-reference.js.map +0 -1
- package/dist/backend/services/cms-page-read-port.d.ts.map +0 -1
- package/dist/backend/services/cms-page-read-port.js.map +0 -1
- package/dist/backend/services/cms-page-service.d.ts.map +0 -1
- package/dist/backend/services/cms-page-service.js.map +0 -1
- package/dist/backend/services/cms-reference-registry.d.ts.map +0 -1
- package/dist/backend/services/cms-reference-registry.js.map +0 -1
- package/dist/backend/services/cms-template-service.d.ts.map +0 -1
- package/dist/backend/services/cms-template-service.js.map +0 -1
- package/dist/backend/services/contact-form/contact-form-mail.d.ts.map +0 -1
- package/dist/backend/services/contact-form/contact-form-mail.js.map +0 -1
- package/dist/backend/services/contact-form/contact-form.service.d.ts.map +0 -1
- package/dist/backend/services/contact-form/contact-form.service.js.map +0 -1
- package/dist/backend/services/contact-form/recipients-validator.d.ts.map +0 -1
- package/dist/backend/services/contact-form/recipients-validator.js.map +0 -1
- package/dist/backend/services/content-tree-walker.d.ts.map +0 -1
- package/dist/backend/services/content-tree-walker.js.map +0 -1
- package/dist/backend/services/page-builder-registry.d.ts.map +0 -1
- package/dist/backend/services/page-builder-registry.js.map +0 -1
- package/dist/backend/services/page-paths.d.ts.map +0 -1
- package/dist/backend/services/page-paths.js.map +0 -1
- package/dist/backend/services/seed-hooks.d.ts.map +0 -1
- package/dist/backend/services/seed-hooks.js.map +0 -1
- package/dist/backend/services/storefront-resolver.d.ts.map +0 -1
- package/dist/backend/services/storefront-resolver.js.map +0 -1
- package/dist/backend/services/translation/capability.d.ts.map +0 -1
- package/dist/backend/services/translation/capability.js.map +0 -1
- package/dist/backend/services/translation/chunk.d.ts.map +0 -1
- package/dist/backend/services/translation/chunk.js.map +0 -1
- package/dist/backend/services/translation/extract.d.ts.map +0 -1
- package/dist/backend/services/translation/extract.js.map +0 -1
- package/dist/backend/services/translation/html-codec.d.ts.map +0 -1
- package/dist/backend/services/translation/html-codec.js.map +0 -1
- package/dist/backend/services/translation/inject.d.ts.map +0 -1
- package/dist/backend/services/translation/inject.js.map +0 -1
- package/dist/backend/services/translation/limits.d.ts.map +0 -1
- package/dist/backend/services/translation/limits.js.map +0 -1
- package/dist/backend/services/translation/max-source-characters-validator.d.ts.map +0 -1
- package/dist/backend/services/translation/max-source-characters-validator.js.map +0 -1
- package/dist/backend/services/translation/page-builder-translation.service.d.ts.map +0 -1
- package/dist/backend/services/translation/page-builder-translation.service.js.map +0 -1
- package/dist/backend/services/translation/placeholders.d.ts.map +0 -1
- package/dist/backend/services/translation/placeholders.js.map +0 -1
- package/dist/backend/services/translation/prompt.d.ts.map +0 -1
- package/dist/backend/services/translation/prompt.js.map +0 -1
- package/dist/backend/services/translation/provider-error-map.d.ts.map +0 -1
- package/dist/backend/services/translation/provider-error-map.js.map +0 -1
- package/dist/backend/services/translation/tiptap-inline-codec.d.ts.map +0 -1
- package/dist/backend/services/translation/tiptap-inline-codec.js.map +0 -1
- package/dist/backend/services/translation/translation.service.d.ts.map +0 -1
- package/dist/backend/services/translation/translation.service.js.map +0 -1
- package/dist/manifest.d.ts.map +0 -1
- package/dist/manifest.js.map +0 -1
- package/dist/migrations/20260425T162418_cms_pages_init.d.ts.map +0 -1
- package/dist/migrations/20260425T162418_cms_pages_init.js.map +0 -1
- package/dist/migrations/20260505T130214_cms_init.d.ts.map +0 -1
- package/dist/migrations/20260505T130214_cms_init.js.map +0 -1
- package/dist/migrations/20260903T101741_cms_namespace_block_names.d.ts.map +0 -1
- package/dist/migrations/20260903T101741_cms_namespace_block_names.js.map +0 -1
- package/dist/migrations/20260912T094733_cms_sales_channel_cms_pages.d.ts.map +0 -1
- package/dist/migrations/20260912T094733_cms_sales_channel_cms_pages.js.map +0 -1
- package/dist/migrations/20260912T125709_cms_page_body_asset_ref_index.d.ts.map +0 -1
- package/dist/migrations/20260912T125709_cms_page_body_asset_ref_index.js.map +0 -1
- package/dist/migrations/20261022T163218_cms_brand_tokens.d.ts.map +0 -1
- package/dist/migrations/20261022T163218_cms_brand_tokens.js.map +0 -1
- package/dist/migrations/20261023T052237_cms_page_tree_and_share.d.ts.map +0 -1
- package/dist/migrations/20261023T052237_cms_page_tree_and_share.js.map +0 -1
- package/dist/migrations/20261027T165458_cms_page_parent_path_in_url.d.ts.map +0 -1
- package/dist/migrations/20261027T165458_cms_page_parent_path_in_url.js.map +0 -1
- package/dist/migrations/20261028T090524_cms_page_breadcrumbs_overlay.d.ts.map +0 -1
- package/dist/migrations/20261028T090524_cms_page_breadcrumbs_overlay.js.map +0 -1
- package/dist/migrations/20261029T131218_cms_page_translations.d.ts.map +0 -1
- package/dist/migrations/20261029T131218_cms_page_translations.js.map +0 -1
- package/dist/migrations/index.d.ts.map +0 -1
- package/dist/migrations/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -20,6 +20,7 @@ A module is not imported by application code. The platform discovers the extensi
|
|
|
20
20
|
| `@endora-commerce/mod-cms/backend` | the composition root the platform calls, with the entities, services, routes and workers it registers |
|
|
21
21
|
| `@endora-commerce/mod-cms/migrations` | the module’s own schema migrations, in the order the platform runs them |
|
|
22
22
|
| `@endora-commerce/mod-cms/tailwind.css` | the Tailwind source declaration for the admin code above |
|
|
23
|
+
| `@endora-commerce/mod-cms/test-support` | development-only — the test doubles, fixtures and volatile tables this module’s own tests need |
|
|
23
24
|
|
|
24
25
|
## Depends on
|
|
25
26
|
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import type { FormBlockData, FormEditorNote } from '@endora-commerce/cms-components/utils/catalog-preview-bridge';
|
|
2
3
|
export { mapAdminProductToCmsSummary, pickAdminLocalizedName } from './admin-catalog-preview-map.js';
|
|
4
|
+
/**
|
|
5
|
+
* Feature 170 (`specs/170-forms-module/` contracts/blocks-and-storefront.md §3, §6, US2-3) — the
|
|
6
|
+
* canvas's read of a `forms.Form` block's form, through the `forms` module's admin preview over
|
|
7
|
+
* HTTP (`cms` gains no dependency on `forms`): the published version, or the working copy of a
|
|
8
|
+
* draft, so the editor sees the form they placed — with a note saying a shopper would not see a
|
|
9
|
+
* draft, that a form is closed, that it is gone, or that the editor may not view forms.
|
|
10
|
+
*/
|
|
11
|
+
export declare function fetchAdminFormRead(formId: string, notes: Readonly<Record<FormEditorNote, string>>): Promise<FormBlockData>;
|
|
3
12
|
export declare function AdminCatalogPreviewProvider({ children }: {
|
|
4
13
|
children: ReactNode;
|
|
5
14
|
}): React.ReactElement;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { CatalogPreviewProvider as CmsCatalogPreviewProvider } from '@endora-commerce/cms-components';
|
|
5
|
-
import { apiClient } from '@endora-commerce/admin-kit/lib';
|
|
5
|
+
import { ApiError, apiClient } from '@endora-commerce/admin-kit/lib';
|
|
6
|
+
import { useTranslation } from '@endora-commerce/admin-kit/i18n';
|
|
6
7
|
import { mapAdminProductToCmsSummary, pickAdminLocalizedName, } from './admin-catalog-preview-map.js';
|
|
7
8
|
export { mapAdminProductToCmsSummary, pickAdminLocalizedName } from './admin-catalog-preview-map.js';
|
|
8
9
|
function buildCategoryTree(categories) {
|
|
@@ -87,7 +88,34 @@ async function fetchAdminBlogPosts(query) {
|
|
|
87
88
|
};
|
|
88
89
|
}));
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Feature 170 (`specs/170-forms-module/` contracts/blocks-and-storefront.md §3, §6, US2-3) — the
|
|
93
|
+
* canvas's read of a `forms.Form` block's form, through the `forms` module's admin preview over
|
|
94
|
+
* HTTP (`cms` gains no dependency on `forms`): the published version, or the working copy of a
|
|
95
|
+
* draft, so the editor sees the form they placed — with a note saying a shopper would not see a
|
|
96
|
+
* draft, that a form is closed, that it is gone, or that the editor may not view forms.
|
|
97
|
+
*/
|
|
98
|
+
export async function fetchAdminFormRead(formId, notes) {
|
|
99
|
+
const path = (source) => `/api/v1/admin/forms/${encodeURIComponent(formId)}/preview?source=${source}`;
|
|
100
|
+
const noted = (code) => ({ code, message: notes[code] });
|
|
101
|
+
try {
|
|
102
|
+
const published = (await apiClient.get(path('published'))).data;
|
|
103
|
+
if (published.status === 'draft') {
|
|
104
|
+
const working = (await apiClient.get(path('working'))).data;
|
|
105
|
+
const { status: _status, ...read } = working;
|
|
106
|
+
return { ...read, editorNote: noted('draft') };
|
|
107
|
+
}
|
|
108
|
+
const { status, ...read } = published;
|
|
109
|
+
return status === 'closed' ? { ...read, editorNote: noted('closed') } : read;
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
if (error instanceof ApiError && (error.status === 403 || error.status === 404)) {
|
|
113
|
+
return { formId, availability: 'unavailable', editorNote: noted(error.status === 403 ? 'forbidden' : 'not_found') };
|
|
114
|
+
}
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function createAdminCatalogPreviewApi(formNotes) {
|
|
91
119
|
return {
|
|
92
120
|
async fetchProductsBySlugs(slugs) {
|
|
93
121
|
if (slugs.length === 0)
|
|
@@ -116,10 +144,16 @@ function createAdminCatalogPreviewApi() {
|
|
|
116
144
|
return buildCategoryTree(res.data);
|
|
117
145
|
},
|
|
118
146
|
fetchBlogPosts: fetchAdminBlogPosts,
|
|
147
|
+
fetchForm: (formId) => fetchAdminFormRead(formId, formNotes),
|
|
119
148
|
};
|
|
120
149
|
}
|
|
121
150
|
export function AdminCatalogPreviewProvider({ children }) {
|
|
122
|
-
const
|
|
151
|
+
const t = useTranslation('cms');
|
|
152
|
+
const draft = t('blocks.form.note.draft');
|
|
153
|
+
const closed = t('blocks.form.note.closed');
|
|
154
|
+
const notFound = t('blocks.form.note.notFound');
|
|
155
|
+
const forbidden = t('blocks.form.note.forbidden');
|
|
156
|
+
const api = useMemo(() => createAdminCatalogPreviewApi({ draft, closed, not_found: notFound, forbidden }), [draft, closed, notFound, forbidden]);
|
|
123
157
|
return _jsx(CmsCatalogPreviewProvider, { api: api, children: children });
|
|
124
158
|
}
|
|
125
159
|
//# sourceMappingURL=AdminCatalogPreviewProvider.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ComponentConfig } from '@puckeditor/core';
|
|
2
|
+
/**
|
|
3
|
+
* `specs/170-forms-module/` contracts/blocks-and-storefront.md §6 (FR-004, US2-2) — the admin's
|
|
4
|
+
* fields of `forms.Form` (declared by `forms`, rendered from `cms-components`): the form is picked
|
|
5
|
+
* from the forms the editor may see, with a shortcut to create one, instead of typed as an id.
|
|
6
|
+
* Every other field — the presets — and the order of the fields are the block's own.
|
|
7
|
+
*
|
|
8
|
+
* `cms` gains no dependency on `forms`: the picker reads `forms`' admin list over HTTP, as the
|
|
9
|
+
* newsletter pickers read the newsletter's, and the block is offered only while `forms` is present.
|
|
10
|
+
*/
|
|
11
|
+
/** The block this file gives its picker to. */
|
|
12
|
+
export declare const FORM_BLOCK_FIELDS_BLOCK = "forms.Form";
|
|
13
|
+
/** `config` with the form picker in `formId`. */
|
|
14
|
+
export declare function withAdminFormBlockFields(config: ComponentConfig): ComponentConfig;
|
|
15
|
+
//# sourceMappingURL=FormBlockFields.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createFormPickerField } from '@endora-commerce/page-builder-admin';
|
|
3
|
+
/**
|
|
4
|
+
* `specs/170-forms-module/` contracts/blocks-and-storefront.md §6 (FR-004, US2-2) — the admin's
|
|
5
|
+
* fields of `forms.Form` (declared by `forms`, rendered from `cms-components`): the form is picked
|
|
6
|
+
* from the forms the editor may see, with a shortcut to create one, instead of typed as an id.
|
|
7
|
+
* Every other field — the presets — and the order of the fields are the block's own.
|
|
8
|
+
*
|
|
9
|
+
* `cms` gains no dependency on `forms`: the picker reads `forms`' admin list over HTTP, as the
|
|
10
|
+
* newsletter pickers read the newsletter's, and the block is offered only while `forms` is present.
|
|
11
|
+
*/
|
|
12
|
+
/** The block this file gives its picker to. */
|
|
13
|
+
export const FORM_BLOCK_FIELDS_BLOCK = 'forms.Form';
|
|
14
|
+
// Stable: a field recreated on every merge loses its input focus.
|
|
15
|
+
const FORM_PICKER_FIELD = createFormPickerField('Form');
|
|
16
|
+
/** `config` with the form picker in `formId`. */
|
|
17
|
+
export function withAdminFormBlockFields(config) {
|
|
18
|
+
const fields = { ...(config.fields ?? {}) };
|
|
19
|
+
if ('formId' in fields)
|
|
20
|
+
fields['formId'] = FORM_PICKER_FIELD;
|
|
21
|
+
return { ...config, fields };
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=FormBlockFields.js.map
|
|
@@ -18,7 +18,7 @@ import { TranslationNotice, useTranslationNotice } from './TranslationNotice.js'
|
|
|
18
18
|
import { useTranslation, useTranslationContext } from '@endora-commerce/admin-kit/i18n';
|
|
19
19
|
import { useBlockContributions } from '@endora-commerce/admin-kit/zones';
|
|
20
20
|
import { cmsClient } from '../api/cms-client.js';
|
|
21
|
-
import { composeDeclaredBlocks, loadBlockEditors, namesToLoad, } from './block-contributions.js';
|
|
21
|
+
import { composeDeclaredBlocks, loadBlockEditors, namesToLoad, withoutWithdrawnBundledBlocks, } from './block-contributions.js';
|
|
22
22
|
import { PageBuilderColorPaletteProvider, createCategorySlugField, createCategorySlugsField, createProductSlugField, createProductSlugsField, createImageAssetField, createImageSourceField, createImageUrlField, createSlideImageField, createVideoAssetField, createButtonSpecField, createLinkField, PageBuilderHeaderActions, PageBuilderHeaderShell, PageBuilderTemplateActions, emptyPageBuilderData, isEmptyPageBuilderData, PageBuilderOverlayBridge, } from '@endora-commerce/page-builder-admin';
|
|
23
23
|
import { AdminCatalogPreviewProvider } from './AdminCatalogPreviewProvider.js';
|
|
24
24
|
import { createAdminBackgroundField, withAdminSectionAssetInput } from './BackgroundFields.js';
|
|
@@ -28,6 +28,7 @@ import { CAROUSEL_BLOCKS_WITH_ADMIN_FIELDS, withAdminCarouselFields } from './Ca
|
|
|
28
28
|
import { LISTING_BLOCKS_WITH_ADMIN_FIELDS, withAdminListingFields } from './ListingFields.js';
|
|
29
29
|
import { PAGE_NAVIGATION_BLOCKS_WITH_ADMIN_FIELDS, withAdminPageNavigationFields } from './PageNavigationFields.js';
|
|
30
30
|
import { NEWSLETTER_SIGNUP_FIELDS_BLOCK, withAdminNewsletterSignupFields } from './NewsletterSignupFields.js';
|
|
31
|
+
import { FORM_BLOCK_FIELDS_BLOCK, withAdminFormBlockFields } from './FormBlockFields.js';
|
|
31
32
|
import { buildViewports } from './build-viewports.js';
|
|
32
33
|
import { applyRowLayoutPreset, findRowById, replaceRowInData, wrapRowInContentSliderSlide, } from '@endora-commerce/cms-components/editor/row-layout-presets';
|
|
33
34
|
import { isContentSliderSlidesZone, toPuckItemArray } from '@endora-commerce/page-builder-core/editor';
|
|
@@ -150,8 +151,10 @@ function brandPaletteColors(tokens) {
|
|
|
150
151
|
}
|
|
151
152
|
function mergeConfig(descriptor, extensionTitle, blockOptions, context, sectionTitle, contributed, previewSentence) {
|
|
152
153
|
const base = defaultPageBuilderConfig;
|
|
154
|
+
// Feature 170 (US10-1) — a bundled block whose owner is absent is withdrawn, so a stored one
|
|
155
|
+
// shows the missing-block note.
|
|
153
156
|
const bundled = {
|
|
154
|
-
...(base.components ?? {}),
|
|
157
|
+
...withoutWithdrawnBundledBlocks((base.components ?? {}), descriptor),
|
|
155
158
|
};
|
|
156
159
|
// Replace InsertBlock's free-text "Block code" field with a dropdown of the
|
|
157
160
|
// available CMS blocks, so authors pick from a list instead of having to know
|
|
@@ -222,6 +225,12 @@ function mergeConfig(descriptor, extensionTitle, blockOptions, context, sectionT
|
|
|
222
225
|
if (cfg)
|
|
223
226
|
bundled[name] = withAdminNewsletterSignupFields(cfg);
|
|
224
227
|
}
|
|
228
|
+
// Feature 170 — `forms.Form`'s form from the forms the editor may see.
|
|
229
|
+
for (const name of [FORM_BLOCK_FIELDS_BLOCK]) {
|
|
230
|
+
const cfg = bundled[name];
|
|
231
|
+
if (cfg)
|
|
232
|
+
bundled[name] = withAdminFormBlockFields(cfg);
|
|
233
|
+
}
|
|
225
234
|
const productCard = bundled['catalog.ProductCard'];
|
|
226
235
|
if (productCard) {
|
|
227
236
|
bundled['catalog.ProductCard'] = {
|
|
@@ -3,16 +3,16 @@ export declare function pickAdminLocalizedName(name: Record<string, string> | st
|
|
|
3
3
|
/**
|
|
4
4
|
* A product of the admin catalogue API as a preview card's product. Feature
|
|
5
5
|
* 163, T196: the card's summary is derived from the description by the rule
|
|
6
|
-
* the storefront's listing uses (`productSummaryText`),
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* the storefront's listing uses (`productSummaryText`), so a listing's "text
|
|
7
|
+
* under the product name" shows the same line in the editor as on the page.
|
|
8
|
+
* Feature 174 (FR-031): the editor has no channel, so both are the Global strings.
|
|
9
9
|
*/
|
|
10
10
|
export declare function mapAdminProductToCmsSummary(product: {
|
|
11
11
|
id: string;
|
|
12
12
|
slug: string;
|
|
13
|
-
name:
|
|
13
|
+
name: string;
|
|
14
14
|
sku: string;
|
|
15
|
-
description?:
|
|
15
|
+
description?: string | null;
|
|
16
16
|
}): {
|
|
17
17
|
id: string;
|
|
18
18
|
slug: string;
|
|
@@ -8,21 +8,21 @@ export function pickAdminLocalizedName(name, fallback) {
|
|
|
8
8
|
/**
|
|
9
9
|
* A product of the admin catalogue API as a preview card's product. Feature
|
|
10
10
|
* 163, T196: the card's summary is derived from the description by the rule
|
|
11
|
-
* the storefront's listing uses (`productSummaryText`),
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* the storefront's listing uses (`productSummaryText`), so a listing's "text
|
|
12
|
+
* under the product name" shows the same line in the editor as on the page.
|
|
13
|
+
* Feature 174 (FR-031): the editor has no channel, so both are the Global strings.
|
|
14
14
|
*/
|
|
15
15
|
export function mapAdminProductToCmsSummary(product) {
|
|
16
16
|
const description = product.description;
|
|
17
17
|
return {
|
|
18
18
|
id: product.id,
|
|
19
19
|
slug: product.slug,
|
|
20
|
-
name:
|
|
20
|
+
name: product.name || product.slug,
|
|
21
21
|
sku: product.sku,
|
|
22
22
|
primaryAssetUrl: null,
|
|
23
23
|
price: null,
|
|
24
24
|
stockLevel: null,
|
|
25
|
-
summary: description === null || description === undefined ? null : productSummaryText(
|
|
25
|
+
summary: description === null || description === undefined ? null : productSummaryText(description),
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
//# sourceMappingURL=admin-catalog-preview-map.js.map
|
|
@@ -32,6 +32,21 @@ import { type PageBuilderBlockEditorConfig } from '@endora-commerce/page-builder
|
|
|
32
32
|
export type DeclaredBlock = CmsPageBuilderDescriptor['components'][number];
|
|
33
33
|
/** Where an ignored or failed contribution is said; the editor logs it. */
|
|
34
34
|
export type BlockContributionReport = (message: string) => void;
|
|
35
|
+
/**
|
|
36
|
+
* The bundled renderers whose owner is present (`specs/170-forms-module/` US10-1).
|
|
37
|
+
*
|
|
38
|
+
* This bundle renders a few blocks other modules own — `forms.Form`, `newsletter.Signup`,
|
|
39
|
+
* `catalog.*`, `blog.*` — and a renderer being bundled says nothing about its owner being on. The
|
|
40
|
+
* served descriptor is the presence answer: the registry leaves out every block of an absent
|
|
41
|
+
* owner, so a bundled block of a module other than `cms` the descriptor does not declare is
|
|
42
|
+
* withdrawn here, and a stored one degrades to the missing-block note through
|
|
43
|
+
* `withMissingBlockPlaceholders`, like any absent owner's. Every context's entries count, not only
|
|
44
|
+
* this editor's — the context filter is a separate step. Before the descriptor is read
|
|
45
|
+
* (`null`) nothing is withdrawn.
|
|
46
|
+
*/
|
|
47
|
+
export declare function withoutWithdrawnBundledBlocks<T>(bundled: Readonly<Record<string, T>>, descriptor: {
|
|
48
|
+
readonly components: readonly Pick<DeclaredBlock, 'name'>[];
|
|
49
|
+
} | null): Readonly<Record<string, T>>;
|
|
35
50
|
/** The declared names the bundle does not render — the ones worth a factory. */
|
|
36
51
|
export declare function namesToLoad(declared: readonly DeclaredBlock[], bundled: Readonly<Record<string, unknown>>): ReadonlySet<string>;
|
|
37
52
|
export interface LoadedBlockEditors {
|
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
import { makeMissingComponentConfig } from '@endora-commerce/cms-components';
|
|
2
|
+
import { ownerOf } from '@endora-commerce/page-builder-core';
|
|
2
3
|
import { editorConfigFromDescriptor, neutralBlockPreview, withBlockBoundary, withContributedBlocks, } from '@endora-commerce/page-builder-core/contributions';
|
|
4
|
+
/**
|
|
5
|
+
* The bundled renderers whose owner is present (`specs/170-forms-module/` US10-1).
|
|
6
|
+
*
|
|
7
|
+
* This bundle renders a few blocks other modules own — `forms.Form`, `newsletter.Signup`,
|
|
8
|
+
* `catalog.*`, `blog.*` — and a renderer being bundled says nothing about its owner being on. The
|
|
9
|
+
* served descriptor is the presence answer: the registry leaves out every block of an absent
|
|
10
|
+
* owner, so a bundled block of a module other than `cms` the descriptor does not declare is
|
|
11
|
+
* withdrawn here, and a stored one degrades to the missing-block note through
|
|
12
|
+
* `withMissingBlockPlaceholders`, like any absent owner's. Every context's entries count, not only
|
|
13
|
+
* this editor's — the context filter is a separate step. Before the descriptor is read
|
|
14
|
+
* (`null`) nothing is withdrawn.
|
|
15
|
+
*/
|
|
16
|
+
export function withoutWithdrawnBundledBlocks(bundled, descriptor) {
|
|
17
|
+
if (descriptor === null)
|
|
18
|
+
return bundled;
|
|
19
|
+
const declared = new Set(descriptor.components.map((entry) => entry.name));
|
|
20
|
+
return Object.fromEntries(Object.entries(bundled).filter(([name]) => {
|
|
21
|
+
const owner = ownerOf(name);
|
|
22
|
+
return owner === null || owner === 'cms' || declared.has(name);
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
3
25
|
/** The declared names the bundle does not render — the ones worth a factory. */
|
|
4
26
|
export function namesToLoad(declared, bundled) {
|
|
5
27
|
return new Set(declared.map((entry) => entry.name).filter((name) => !Object.hasOwn(bundled, name)));
|
package/dist/admin/index.js
CHANGED
|
@@ -214,6 +214,13 @@ export const contributions = {
|
|
|
214
214
|
weight: 100,
|
|
215
215
|
requiredPermission: READ_PERMISSION,
|
|
216
216
|
}),
|
|
217
|
+
// Feature 172 — the same canvas on the product content screen, under the
|
|
218
|
+
// same read code: seeing a product's content document is a read, and the
|
|
219
|
+
// save is `catalog`'s, behind its own write code.
|
|
220
|
+
zoneComponent('product.content.editor', () => import('./zones/ProductContentEditor.js'), {
|
|
221
|
+
weight: 100,
|
|
222
|
+
requiredPermission: READ_PERMISSION,
|
|
223
|
+
}),
|
|
217
224
|
],
|
|
218
225
|
};
|
|
219
226
|
//# sourceMappingURL=index.js.map
|
|
@@ -3,7 +3,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
3
3
|
import { useNavigate } from 'react-router-dom';
|
|
4
4
|
import { BRAND_SCHEMES, BRAND_SPACE_TOKENS, BRAND_TYPE_TOKENS, assessBrandContrast, cmsBrandTokensSchema, } from '@endora-commerce/contracts';
|
|
5
5
|
import { Alert, AlertDescription, AlertTitle, Badge, Button, Card, CardContent, Checkbox, ColorPicker, Input, Label, PageHeader, SaveButtonGroup, Section, Select, } from '@endora-commerce/admin-kit/ui';
|
|
6
|
-
import { AssetFieldPicker, SalesChannelPicker } from '@endora-commerce/admin-kit/components';
|
|
6
|
+
import { AssetFieldPicker, SalesChannelPicker, useConfirmDialog } from '@endora-commerce/admin-kit/components';
|
|
7
7
|
import { ApiError, useAuth } from '@endora-commerce/admin-kit/lib';
|
|
8
8
|
import { useTranslation } from '@endora-commerce/admin-kit/i18n';
|
|
9
9
|
import { cmsClient } from '../api/cms-client.js';
|
|
@@ -113,6 +113,7 @@ function BrandCard(props) {
|
|
|
113
113
|
*/
|
|
114
114
|
export function BrandPage() {
|
|
115
115
|
const t = useTranslation('cms');
|
|
116
|
+
const { confirm, confirmDialog } = useConfirmDialog();
|
|
116
117
|
const navigate = useNavigate();
|
|
117
118
|
const { hasPermission } = useAuth();
|
|
118
119
|
const canEdit = hasPermission(BRAND_PERMISSION);
|
|
@@ -208,7 +209,12 @@ export function BrandPage() {
|
|
|
208
209
|
setDraft(structuredClone(read.effective));
|
|
209
210
|
return;
|
|
210
211
|
}
|
|
211
|
-
|
|
212
|
+
const ok = await confirm({
|
|
213
|
+
message: t('brand.scope.resetConfirm'),
|
|
214
|
+
confirmLabel: t('brand.scope.reset'),
|
|
215
|
+
destructive: true,
|
|
216
|
+
});
|
|
217
|
+
if (!ok)
|
|
212
218
|
return;
|
|
213
219
|
setFeedback(null);
|
|
214
220
|
setSaving(true);
|
|
@@ -244,7 +250,7 @@ export function BrandPage() {
|
|
|
244
250
|
}, clearable: true, placeholder: t('brand.scope.allChannels'), emptyMessage: t('brand.scope.noChannels'), ariaLabel: t('brand.scope.channelLabel') }), _jsx("p", { className: "text-xs text-muted-foreground", children: t('brand.scope.channelHint') })] }), _jsx(ScopeState, { channelId: channelId, loading: loading, hasOverride: hasOverride, overriding: overriding, canEdit: canEdit, busy: saving, onOverride: startOverride, onReset: () => void resetToGlobal(), t: t })] }) }) }), _jsx("p", { role: "status", "aria-live": "polite", className: "text-sm text-muted-foreground", children: loading ? t('brand.loading') : '' }), loadError ? (_jsxs(Alert, { variant: "destructive", children: [_jsx(AlertTitle, { children: t('brand.loadFailed') }), _jsxs(AlertDescription, { className: "space-y-2", children: [_jsx("p", { children: loadError }), _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => void load(channelId), children: t('brand.retry') })] })] })) : null, draft ? (_jsxs("div", { className: "grid gap-4 lg:grid-cols-12", children: [_jsxs("div", { className: "space-y-4 lg:col-span-8", children: [_jsxs(BrandCard, { title: t('brand.section.colors'), children: [_jsxs("fieldset", { className: "space-y-3", children: [_jsx("legend", { className: "text-sm font-semibold", children: t('brand.colors.palette') }), _jsx("div", { className: "grid gap-3 sm:grid-cols-2 xl:grid-cols-3", children: PALETTE_ROLES.map((role) => (_jsx(ColorField, { label: t(`brand.colors.${role}`), value: draft.colors[role], disabled: disabled, onChange: (hex) => edit((d) => void (d.colors[role] = hex)) }, role))) })] }), _jsxs("fieldset", { className: "space-y-3", children: [_jsx("legend", { className: "text-sm font-semibold", children: t('brand.gradient.title') }), _jsxs("div", { className: "grid gap-3 sm:grid-cols-3", children: [_jsx(ColorField, { label: t('brand.gradient.from'), value: draft.accentGradient.from, disabled: disabled, onChange: (hex) => edit((d) => void (d.accentGradient.from = hex)) }), _jsx(ColorField, { label: t('brand.gradient.to'), value: draft.accentGradient.to, disabled: disabled, onChange: (hex) => edit((d) => void (d.accentGradient.to = hex)) }), _jsx(NumberField, { id: "brand-gradient-angle", label: t('brand.gradient.angle'), value: draft.accentGradient.angle, min: 0, max: 360, disabled: disabled, onChange: (value) => edit((d) => void (d.accentGradient.angle = value)) })] })] }), _jsxs("fieldset", { className: "space-y-3", children: [_jsx("legend", { className: "text-sm font-semibold", children: t('brand.colors.neutral') }), _jsx("div", { className: "grid gap-3 sm:grid-cols-3 xl:grid-cols-5", children: NEUTRAL_STEPS.map((step) => (_jsx(ColorField, { label: t('brand.colors.neutralStep', { step }), value: draft.colors.neutral[step], disabled: disabled, onChange: (hex) => edit((d) => void (d.colors.neutral[step] = hex)) }, step))) })] })] }), _jsx(BrandCard, { title: t('brand.section.schemes'), description: t('brand.schemes.hint'), children: BRAND_SCHEMES.map((scheme) => (_jsx(SchemeFields, { scheme: scheme, tokens: draft, disabled: disabled, edit: edit, t: t }, scheme))) }), _jsxs(BrandCard, { title: t('brand.section.typography'), children: [_jsxs("div", { className: "grid gap-3 xl:grid-cols-2", children: [_jsx(BrandFontFields, { idPrefix: "brand-font-heading", legend: t('brand.fonts.heading'), value: draft.fonts.heading, disabled: disabled, onChange: (next) => edit((d) => void (d.fonts.heading = next)) }), _jsx(BrandFontFields, { idPrefix: "brand-font-body", legend: t('brand.fonts.body'), value: draft.fonts.body, disabled: disabled, onChange: (next) => edit((d) => void (d.fonts.body = next)) })] }), _jsx(TypeScaleTable, { tokens: draft, disabled: disabled, edit: edit, t: t })] }), _jsx(BrandCard, { title: t('brand.section.buttons'), children: _jsxs("div", { className: "grid gap-3 sm:grid-cols-2 xl:grid-cols-3", children: [_jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { htmlFor: "brand-button-radius", children: t('brand.buttons.radius') }), _jsxs(Select, { id: "brand-button-radius", value: draft.buttons.radius, disabled: disabled, onChange: (e) => edit((d) => void (d.buttons.radius = e.target.value)), children: [_jsx("option", { value: "square", children: t('brand.buttons.radius.square') }), _jsx("option", { value: "rounded", children: t('brand.buttons.radius.rounded') }), _jsx("option", { value: "pill", children: t('brand.buttons.radius.pill') })] })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { htmlFor: "brand-button-weight", children: t('brand.buttons.fontWeight') }), _jsx(Select, { id: "brand-button-weight", value: String(draft.buttons.fontWeight), disabled: disabled, onChange: (e) => edit((d) => void (d.buttons.fontWeight = Number(e.target.value))), children: BUTTON_WEIGHTS.map((weight) => (_jsx("option", { value: weight, children: weight }, weight))) })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { htmlFor: "brand-button-transform", children: t('brand.buttons.textTransform') }), _jsxs(Select, { id: "brand-button-transform", value: draft.buttons.textTransform, disabled: disabled, onChange: (e) => edit((d) => void (d.buttons.textTransform = e.target.value)), children: [_jsx("option", { value: "none", children: t('brand.buttons.textTransform.none') }), _jsx("option", { value: "uppercase", children: t('brand.buttons.textTransform.uppercase') })] })] }), ['small', 'medium', 'large'].map((size) => (_jsx(NumberField, { id: `brand-button-height-${size}`, label: t(`brand.buttons.height${size[0].toUpperCase()}${size.slice(1)}`), value: draft.buttons.heights[size], min: 28, max: 72, disabled: disabled, onChange: (value) => edit((d) => void (d.buttons.heights[size] = value)) }, size)))] }) }), _jsx(BrandCard, { title: t('brand.section.spacing'), description: t('brand.spacing.hint'), children: _jsxs("table", { className: "w-full max-w-xl text-sm", children: [_jsx("thead", { children: _jsxs("tr", { className: "text-left text-muted-foreground", children: [_jsx("th", { scope: "col", className: "pb-2 font-medium", children: t('brand.spacing.step') }), _jsx("th", { scope: "col", className: "pb-2 font-medium", children: t('brand.spacing.mobilePx') }), _jsx("th", { scope: "col", className: "pb-2 font-medium", children: t('brand.spacing.desktopPx') })] }) }), _jsx("tbody", { children: BRAND_SPACE_TOKENS.map((step) => (_jsxs("tr", { children: [_jsx("th", { scope: "row", className: "py-1 pr-3 text-left font-medium", children: t(`brand.space.${step}`) }), ['mobilePx', 'desktopPx'].map((tier) => (_jsx("td", { className: "py-1 pr-3", children: _jsx(NumberField, { id: `brand-space-${step}-${tier}`, label: t('brand.typeScale.cellLabel', {
|
|
245
251
|
role: t(`brand.space.${step}`),
|
|
246
252
|
field: t(`brand.spacing.${tier}`),
|
|
247
|
-
}), labelHidden: true, value: draft.spacing[step][tier], min: 0, max: 320, disabled: disabled, onChange: (value) => edit((d) => void (d.spacing[step][tier] = value)) }) }, tier)))] }, step))) })] }) }), _jsxs(BrandCard, { title: t('brand.section.layout'), children: [_jsx("div", { className: "grid gap-3 sm:grid-cols-2", children: ['containerMaxPx', 'widePx', 'gutterMobilePx', 'gutterDesktopPx'].map((key) => (_jsx(NumberField, { id: `brand-layout-${key}`, label: t(`brand.layout.${key}`), value: draft.layout[key], min: key.startsWith('gutter') ? 0 : 320, max: key.startsWith('gutter') ? 160 : 3840, disabled: disabled, onChange: (value) => edit((d) => void (d.layout[key] = value)) }, key))) }), _jsx("p", { className: "text-sm text-muted-foreground", children: t('brand.layout.scaleHint') }), _jsx("div", { className: "grid gap-3 sm:grid-cols-2", children: ['tablet', 'smallDesktop'].map((tier) => (_jsx(FactorField, { id: `brand-tier-scale-${tier}`, label: t(tier === 'tablet' ? 'brand.layout.tabletScale' : 'brand.layout.smallDesktopScale'), value: draft.tierScale?.[tier], disabled: disabled, onChange: (value) => edit((d) => setTierScale(d, tier, value)) }, tier))) }), _jsx("p", { className: "text-sm text-muted-foreground", children: t('brand.layout.tierHint') }), _jsxs("div", { className: "space-y-2", children: [_jsxs("label", { className: "flex items-center gap-2 text-sm", children: [_jsx(Checkbox, { id: "brand-tier-scale-fluidDesktop", checked: draft.tierScale?.fluidDesktop === true, disabled: disabled, onChange: (event) => edit((d) => setTierScale(d, 'fluidDesktop', event.target.checked ? true : undefined)) }), t('brand.layout.fluidDesktop')] }), draft.tierScale?.fluidDesktop === true ? (_jsx(FactorField, { id: "brand-tier-scale-fluidUntilPx", label: t('brand.layout.fluidUntilPx'), value: draft.tierScale?.fluidUntilPx, min: 1025, max: 3840, step: 1, disabled: disabled, onChange: (value) => edit((d) => setTierScale(d, 'fluidUntilPx', value)) })) : null, _jsxs("label", { className: "flex items-center gap-2 text-sm", children: [_jsx(Checkbox, { id: "brand-tier-scale-buttons", checked: draft.tierScale?.buttons === true, disabled: disabled, onChange: (event) => edit((d) => setTierScale(d, 'buttons', event.target.checked ? true : undefined)) }), t('brand.layout.scaleButtons')] })] })] })] }), _jsx("section", { "aria-label": t('brand.preview.title'), className: "lg:col-span-4", children: _jsxs("div", { className: "space-y-4 lg:sticky lg:top-4", children: [findings.length > 0 ? (_jsxs(Alert, { variant: "warning", children: [_jsx(AlertTitle, { children: t('brand.contrast.title') }), _jsxs(AlertDescription, { className: "space-y-2", children: [_jsx("p", { children: t('brand.contrast.description') }), _jsx("ul", { className: "list-disc space-y-1 pl-5", children: findings.map((finding) => (_jsx("li", { children: describeFinding(finding, t) }, finding.pair))) })] })] })) : null, _jsx(Card, { children: _jsx(CardContent, { className: "pt-6", children: _jsxs(Section, { title: t('brand.preview.title'), children: [_jsx("p", { className: "text-xs text-muted-foreground", children: t('brand.preview.hint') }), _jsx(BrandPreview, { tokens: draft })] }) }) })] }) })] })) : null] }));
|
|
253
|
+
}), labelHidden: true, value: draft.spacing[step][tier], min: 0, max: 320, disabled: disabled, onChange: (value) => edit((d) => void (d.spacing[step][tier] = value)) }) }, tier)))] }, step))) })] }) }), _jsxs(BrandCard, { title: t('brand.section.layout'), children: [_jsx("div", { className: "grid gap-3 sm:grid-cols-2", children: ['containerMaxPx', 'widePx', 'gutterMobilePx', 'gutterDesktopPx'].map((key) => (_jsx(NumberField, { id: `brand-layout-${key}`, label: t(`brand.layout.${key}`), value: draft.layout[key], min: key.startsWith('gutter') ? 0 : 320, max: key.startsWith('gutter') ? 160 : 3840, disabled: disabled, onChange: (value) => edit((d) => void (d.layout[key] = value)) }, key))) }), _jsx("p", { className: "text-sm text-muted-foreground", children: t('brand.layout.scaleHint') }), _jsx("div", { className: "grid gap-3 sm:grid-cols-2", children: ['tablet', 'smallDesktop'].map((tier) => (_jsx(FactorField, { id: `brand-tier-scale-${tier}`, label: t(tier === 'tablet' ? 'brand.layout.tabletScale' : 'brand.layout.smallDesktopScale'), value: draft.tierScale?.[tier], disabled: disabled, onChange: (value) => edit((d) => setTierScale(d, tier, value)) }, tier))) }), _jsx("p", { className: "text-sm text-muted-foreground", children: t('brand.layout.tierHint') }), _jsxs("div", { className: "space-y-2", children: [_jsxs("label", { className: "flex items-center gap-2 text-sm", children: [_jsx(Checkbox, { id: "brand-tier-scale-fluidDesktop", checked: draft.tierScale?.fluidDesktop === true, disabled: disabled, onChange: (event) => edit((d) => setTierScale(d, 'fluidDesktop', event.target.checked ? true : undefined)) }), t('brand.layout.fluidDesktop')] }), draft.tierScale?.fluidDesktop === true ? (_jsx(FactorField, { id: "brand-tier-scale-fluidUntilPx", label: t('brand.layout.fluidUntilPx'), value: draft.tierScale?.fluidUntilPx, min: 1025, max: 3840, step: 1, disabled: disabled, onChange: (value) => edit((d) => setTierScale(d, 'fluidUntilPx', value)) })) : null, _jsxs("label", { className: "flex items-center gap-2 text-sm", children: [_jsx(Checkbox, { id: "brand-tier-scale-buttons", checked: draft.tierScale?.buttons === true, disabled: disabled, onChange: (event) => edit((d) => setTierScale(d, 'buttons', event.target.checked ? true : undefined)) }), t('brand.layout.scaleButtons')] })] })] })] }), _jsx("section", { "aria-label": t('brand.preview.title'), className: "lg:col-span-4", children: _jsxs("div", { className: "space-y-4 lg:sticky lg:top-4", children: [findings.length > 0 ? (_jsxs(Alert, { variant: "warning", children: [_jsx(AlertTitle, { children: t('brand.contrast.title') }), _jsxs(AlertDescription, { className: "space-y-2", children: [_jsx("p", { children: t('brand.contrast.description') }), _jsx("ul", { className: "list-disc space-y-1 pl-5", children: findings.map((finding) => (_jsx("li", { children: describeFinding(finding, t) }, finding.pair))) })] })] })) : null, _jsx(Card, { children: _jsx(CardContent, { className: "pt-6", children: _jsxs(Section, { title: t('brand.preview.title'), children: [_jsx("p", { className: "text-xs text-muted-foreground", children: t('brand.preview.hint') }), _jsx(BrandPreview, { tokens: draft })] }) }) })] }) })] })) : null, confirmDialog] }));
|
|
248
254
|
}
|
|
249
255
|
function FeedbackAlert({ feedback, t }) {
|
|
250
256
|
switch (feedback.kind) {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { AdminZoneProps } from '@endora-commerce/contracts';
|
|
3
|
+
/**
|
|
4
|
+
* The Page Builder canvas on `catalog`'s product content screen (feature 172,
|
|
5
|
+
* `specs/172-product-content-attributes/` contracts/admin-surfaces.md §2) — the
|
|
6
|
+
* twin of `CategoryContentEditor`, for one product × content attribute in
|
|
7
|
+
* one language.
|
|
8
|
+
*
|
|
9
|
+
* `catalog` owns the document, its storage and its save, and no editor; it
|
|
10
|
+
* mounts `product.content.editor` and this module contributes the canvas. The
|
|
11
|
+
* direction is the category one, for the same reason: `catalog` cannot be
|
|
12
|
+
* switched off and this module can, so `catalog` may neither declare this
|
|
13
|
+
* module nor import it, while a contribution is filtered by this module's own
|
|
14
|
+
* presence and permission before its chunk is fetched.
|
|
15
|
+
*
|
|
16
|
+
* The full block palette (OR-3): no `context` restricts it. The zone knows its
|
|
17
|
+
* language, so the canvas offers Translate (feature 151); its result reaches
|
|
18
|
+
* storage only through the host's save. **It never saves.**
|
|
19
|
+
*/
|
|
20
|
+
export type ProductContentEditorProps = AdminZoneProps<'product.content.editor'>;
|
|
21
|
+
export declare function ProductContentEditor({ productId, attributeKey, language, data, onChange, }: ProductContentEditorProps): ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* The zone renderer loads a contribution through a dynamic-import factory and
|
|
24
|
+
* reads its default export (feature 091, FR-013).
|
|
25
|
+
*/
|
|
26
|
+
export default ProductContentEditor;
|
|
27
|
+
//# sourceMappingURL=ProductContentEditor.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useState } from 'react';
|
|
3
|
+
import { PageBuilderEditor } from '../components/PageBuilderEditor.js';
|
|
4
|
+
/** A stored document, or the empty one the canvas opens on. */
|
|
5
|
+
function toDocument(data) {
|
|
6
|
+
if (data && typeof data === 'object' && !Array.isArray(data))
|
|
7
|
+
return data;
|
|
8
|
+
return { root: { props: {} }, content: [] };
|
|
9
|
+
}
|
|
10
|
+
export function ProductContentEditor({ productId, attributeKey, language, data, onChange, }) {
|
|
11
|
+
const [document, setDocument] = useState(() => toDocument(data));
|
|
12
|
+
// Stable for as long as the host's callback is: the canvas keys its own
|
|
13
|
+
// change handler on this identity.
|
|
14
|
+
const handleChange = useCallback((next) => {
|
|
15
|
+
setDocument(next);
|
|
16
|
+
onChange(next);
|
|
17
|
+
}, [onChange]);
|
|
18
|
+
return (_jsx(PageBuilderEditor, { data: document, onChange: handleChange,
|
|
19
|
+
// Puck seeds from `data` on mount only, so the key is what re-seeds the
|
|
20
|
+
// canvas for another product, attribute or language.
|
|
21
|
+
contentKey: `product:${productId}:${attributeKey}:${language}`, activeLanguage: language, resource: { type: 'catalog_product_content', id: productId } }));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The zone renderer loads a contribution through a dynamic-import factory and
|
|
25
|
+
* reads its default export (feature 091, FR-013).
|
|
26
|
+
*/
|
|
27
|
+
export default ProductContentEditor;
|
|
28
|
+
//# sourceMappingURL=ProductContentEditor.js.map
|
package/dist/backend/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { type AssetReferenceRegistryPort, type ModuleManifest } from '@endora-co
|
|
|
6
6
|
import type { FetchLike } from '@endora-commerce/llm-client';
|
|
7
7
|
import { ContactFormService } from './services/contact-form/contact-form.service.js';
|
|
8
8
|
import { type ModuleContext } from '@endora-commerce/platform/kernel';
|
|
9
|
+
import { CmsReservedSegmentRegistry } from './services/reserved-segment-registry.js';
|
|
9
10
|
import type { RequireAdminFactory } from '@endora-commerce/platform/kernel';
|
|
10
11
|
import type { CommandBus } from '@endora-commerce/platform/commands';
|
|
11
12
|
import type { EventBus } from '@endora-commerce/platform/events';
|
|
@@ -140,6 +141,8 @@ export interface CmsCradle {
|
|
|
140
141
|
}>;
|
|
141
142
|
readonly cms: CmsResult;
|
|
142
143
|
readonly cmsReferenceRegistry: CmsResult['handle']['referenceRegistry'];
|
|
144
|
+
/** Feature 171 — first segments other modules serve, per channel. */
|
|
145
|
+
readonly cmsReservedSegmentRegistry: CmsReservedSegmentRegistry;
|
|
143
146
|
/**
|
|
144
147
|
* Feature 151 — the `fetch` the Page Builder translation calls its model
|
|
145
148
|
* provider with. `undefined` (the platform's `fetch`) everywhere but a test
|
package/dist/backend/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { CMS_CONTENT_CHANGED_EVENT, cmsColorPaletteSchema, } from '@endora-commerce/contracts';
|
|
2
|
+
import { ASSET_CHANGED_EVENT, CMS_CONTENT_CHANGED_EVENT, cmsColorPaletteSchema, } from '@endora-commerce/contracts';
|
|
3
3
|
import { CMS_PAGE_BUILDER_SETTING_CODES, CMS_SETTING_CODES } from '../manifest.js';
|
|
4
4
|
import { resolveTranslationConfig } from './services/translation/capability.js';
|
|
5
5
|
import { createMaxSourceCharactersValidator } from './services/translation/max-source-characters-validator.js';
|
|
@@ -11,6 +11,7 @@ import { CmsBlockSeedService } from './services/cms-block-seed-port.js';
|
|
|
11
11
|
import { storefrontTagsFor } from './services/cms-content-invalidator.js';
|
|
12
12
|
import { CmsPageReadService } from './services/cms-page-read-port.js';
|
|
13
13
|
import { lazyPort } from '@endora-commerce/platform/kernel';
|
|
14
|
+
import { CmsReservedSegmentRegistry } from './services/reserved-segment-registry.js';
|
|
14
15
|
import { effectiveState } from '@endora-commerce/platform/kernel';
|
|
15
16
|
import { rethrowIfModuleDisabled } from '@endora-commerce/platform/kernel';
|
|
16
17
|
import { channelLanguagePrefixes } from './services/channel-language-prefixes.js';
|
|
@@ -94,7 +95,7 @@ export function registerModule(ctx) {
|
|
|
94
95
|
* container composed.
|
|
95
96
|
*/
|
|
96
97
|
cmsAssetResolver: ctx
|
|
97
|
-
.asFunction(() => createAssetEmbedResolver(lazyPort(ctx, '
|
|
98
|
+
.asFunction(() => createAssetEmbedResolver(lazyPort(ctx, 'assetReadPort')))
|
|
98
99
|
.singleton(),
|
|
99
100
|
/**
|
|
100
101
|
* The storefront keeps every CMS read in its Data Cache for 60 s, tagged
|
|
@@ -254,6 +255,8 @@ export function registerModule(ctx) {
|
|
|
254
255
|
// Feature 167 (FR-040) — every channel's language prefixes and split aliases,
|
|
255
256
|
// asked per save through the kernel's channel port, so a language added to a
|
|
256
257
|
// channel reserves its prefix at once.
|
|
258
|
+
// Feature 171 — segments another module serves in the page's channels.
|
|
259
|
+
result.handle.setClaimedSegmentsResolver((salesChannelIds) => ctx.cradle().cmsReservedSegmentRegistry.claimedIn(salesChannelIds));
|
|
257
260
|
result.handle.setLanguagePrefixesResolver(async () => channelLanguagePrefixes(await lazyPort(ctx, 'salesChannelResolutionPort').listAll()));
|
|
258
261
|
result.handle.setReservedSlugSegmentsResolver(async () => {
|
|
259
262
|
const { settingsReadPort } = ctx.cradle();
|
|
@@ -264,7 +267,7 @@ export function registerModule(ctx) {
|
|
|
264
267
|
// caring where in a composition that happens. The `undefined` branch
|
|
265
268
|
// that used to stand here went with the contribution point (T118c):
|
|
266
269
|
// there is no composition in which the name is unset any more.
|
|
267
|
-
result.handle.setAssetResolver(async (
|
|
270
|
+
result.handle.setAssetResolver(async (assetIds) => ctx.cradle().cmsAssetResolver(assetIds));
|
|
268
271
|
/**
|
|
269
272
|
* Feature 163 (FR-033) — the default sharing image, read for the
|
|
270
273
|
* **request's** channel the storefront route resolved (Constitution
|
|
@@ -305,6 +308,13 @@ export function registerModule(ctx) {
|
|
|
305
308
|
cmsReferenceRegistry: ctx
|
|
306
309
|
.asFunction(({ cms }) => cms.handle.referenceRegistry)
|
|
307
310
|
.singleton(),
|
|
311
|
+
/**
|
|
312
|
+
* Feature 171 (research R5) — first segments other modules serve on the
|
|
313
|
+
* storefront, per channel (the blog's prefixes). An ungated contribution
|
|
314
|
+
* registry like the one above: a module pushes a contributor from a boot
|
|
315
|
+
* hook, and a switched-off contributor claims nothing.
|
|
316
|
+
*/
|
|
317
|
+
cmsReservedSegmentRegistry: ctx.asFunction(() => new CmsReservedSegmentRegistry()).singleton(),
|
|
308
318
|
});
|
|
309
319
|
/**
|
|
310
320
|
* Feature 075, Phase P — the page read model.
|
|
@@ -420,6 +430,24 @@ export function registerModule(ctx) {
|
|
|
420
430
|
const change = payload;
|
|
421
431
|
return ctx.cradle().cmsStorefrontRevalidator.revalidate(storefrontTagsFor(change));
|
|
422
432
|
});
|
|
433
|
+
/**
|
|
434
|
+
* Issue #363 — an asset was written that a cached page, block or hook may
|
|
435
|
+
* embed. Every resolved answer carries its assets' URLs, and since feature 156
|
|
436
|
+
* each URL carries `?v=<contentVersion>`, cached as immutable: a page left in
|
|
437
|
+
* the cache after a replace kept serving the previous marker for up to five
|
|
438
|
+
* minutes, and a browser or CDN holding the old response kept the old image.
|
|
439
|
+
*
|
|
440
|
+
* An event and not a call, so this module holds nothing of `assets_library`
|
|
441
|
+
* for it: an absent or switched-off library announces nothing and nothing
|
|
442
|
+
* here waits for it. `ctx.subscribe` stops the handler with this module — a
|
|
443
|
+
* switched-off `cms` serves no page to refresh. The library dispatches the
|
|
444
|
+
* event in a bus scope and awaits it, so the asset write answers once both
|
|
445
|
+
* caches are dropped.
|
|
446
|
+
*/
|
|
447
|
+
ctx.subscribe(ASSET_CHANGED_EVENT, (payload) => {
|
|
448
|
+
const event = payload;
|
|
449
|
+
return ctx.cradle().cms.handle.assetsChanged(event.assetIds);
|
|
450
|
+
});
|
|
423
451
|
ctx.routes(async (app) => {
|
|
424
452
|
const cradle = ctx.cradle();
|
|
425
453
|
// The route registrar is where `app.log` exists, so the revalidator picks
|
package/dist/backend/plugin.d.ts
CHANGED
|
@@ -88,6 +88,12 @@ export interface CmsModuleHandle {
|
|
|
88
88
|
brandTokensService: CmsBrandTokensService;
|
|
89
89
|
/** Storefront read-through cache — `undefined` when no Redis was wired. */
|
|
90
90
|
cache: CmsCache | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Issue #363 — an asset a cached answer may embed was written: drop every
|
|
93
|
+
* cached answer, then publish the change so the storefront's Data Cache goes
|
|
94
|
+
* too. `registerModule` calls it from its `ASSET_CHANGED_EVENT` subscription.
|
|
95
|
+
*/
|
|
96
|
+
assetsChanged: (assetIds: readonly string[]) => Promise<void>;
|
|
91
97
|
/** Idempotent reconciler — called by composition before HTTP starts. */
|
|
92
98
|
reconcile: () => Promise<{
|
|
93
99
|
inserted: number;
|
|
@@ -108,6 +114,8 @@ export interface CmsModuleHandle {
|
|
|
108
114
|
setReservedSlugSegmentsResolver: (resolver: ReservedSlugSegmentsResolver) => void;
|
|
109
115
|
/** Feature 167 — the channels' storefront language prefixes → channel codes. */
|
|
110
116
|
setLanguagePrefixesResolver: (resolver: () => Promise<ReadonlyMap<string, readonly string[]>>) => void;
|
|
117
|
+
/** Feature 171 — first segments other modules serve in the given channels → the claiming module. */
|
|
118
|
+
setClaimedSegmentsResolver: (resolver: (salesChannelIds: readonly string[]) => Promise<ReadonlyMap<string, string>>) => void;
|
|
111
119
|
getColorPaletteWriter: () => ColorPaletteWriter | null;
|
|
112
120
|
setAssetResolver: (resolver: CmsAssetResolver | null) => void;
|
|
113
121
|
/** Feature 163 — the default sharing image, read per request for the request's channel. */
|
package/dist/backend/plugin.js
CHANGED
|
@@ -71,6 +71,7 @@ export function cmsModule(options) {
|
|
|
71
71
|
translation,
|
|
72
72
|
brandTokensService,
|
|
73
73
|
cache,
|
|
74
|
+
assetsChanged: (assetIds) => invalidator.assetsChanged(assetIds),
|
|
74
75
|
reconcile: () => reconcileSeededHooks(options.emFactory),
|
|
75
76
|
setPageBuilderBreakpointsResolver: (resolver) => {
|
|
76
77
|
pageBuilderRegistry.setBreakpointsResolver(resolver);
|
|
@@ -84,6 +85,9 @@ export function cmsModule(options) {
|
|
|
84
85
|
setReservedSlugSegmentsResolver: (resolver) => {
|
|
85
86
|
pageService.setReservedSegmentsResolver(resolver);
|
|
86
87
|
},
|
|
88
|
+
setClaimedSegmentsResolver: (resolver) => {
|
|
89
|
+
pageService.setClaimedSegmentsResolver(resolver);
|
|
90
|
+
},
|
|
87
91
|
setLanguagePrefixesResolver: (resolver) => {
|
|
88
92
|
pageService.setLanguagePrefixesResolver(resolver);
|
|
89
93
|
},
|
|
@@ -202,10 +202,9 @@ export async function registerCmsAdminRoutes(app, deps) {
|
|
|
202
202
|
return reply.code(201).send({ data: attachments });
|
|
203
203
|
});
|
|
204
204
|
app.patch('/api/v1/admin/cms/hooks/:id/attachments/:blockId', { preHandler: requireWrite }, async (request) => {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
});
|
|
205
|
+
// The block id is the path's, and a malformed one names no attachment: the
|
|
206
|
+
// service answers it as an unknown one rather than the schema's `400` (#781).
|
|
207
|
+
const body = cmsHookAttachmentRequestSchema.pick({ position: true }).parse(request.body ?? {});
|
|
209
208
|
return {
|
|
210
209
|
data: await deps.hookService.reorderAttachment(request.params.id, request.params.blockId, body.position),
|
|
211
210
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ERROR_CODES, contactFormSubmissionSchema } from '@endora-commerce/contracts';
|
|
1
|
+
import { ERROR_CODES, contactFormSubmissionSchema, requestScopeLanguage } from '@endora-commerce/contracts';
|
|
2
2
|
import { HttpError } from '@endora-commerce/platform/http';
|
|
3
3
|
import { getResolvedChannel } from '@endora-commerce/platform/kernel';
|
|
4
4
|
/**
|
|
@@ -17,6 +17,17 @@ function resolvedChannel(request) {
|
|
|
17
17
|
prefixDefaultLanguage: ch.prefixDefaultLanguage,
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Issue #1011 — the content language `Accept-Language` asks for, as the request's
|
|
22
|
+
* channel offers it: q-weighted, matched exactly then by base language (`pl` is the
|
|
23
|
+
* channel's `pl-PL`), else the channel's default (as the catalogue resolves it since
|
|
24
|
+
* #397). No header, no language: the lookup then falls back as it always has. An
|
|
25
|
+
* explicit `?language=` is read before this and wins.
|
|
26
|
+
*/
|
|
27
|
+
function headerLanguage(request) {
|
|
28
|
+
const header = readHeader(request.headers['accept-language']);
|
|
29
|
+
return header ? requestScopeLanguage(getResolvedChannel(request), header) : undefined;
|
|
30
|
+
}
|
|
20
31
|
export async function registerCmsStorefrontRoutes(app, deps) {
|
|
21
32
|
/**
|
|
22
33
|
* Feature 163 — the brand tokens every storefront page is styled from
|
|
@@ -46,7 +57,7 @@ export async function registerCmsStorefrontRoutes(app, deps) {
|
|
|
46
57
|
const page = await deps.storefrontResolver.resolvePageBySlug({
|
|
47
58
|
slug,
|
|
48
59
|
resolvedChannel: resolvedChannel(request),
|
|
49
|
-
language: query['language'] ??
|
|
60
|
+
language: query['language'] ?? headerLanguage(request),
|
|
50
61
|
});
|
|
51
62
|
if (!page) {
|
|
52
63
|
throw new HttpError(404, ERROR_CODES.CMS_PAGE_NOT_FOUND, 'CMS Page not found.');
|
|
@@ -85,7 +96,7 @@ export async function registerCmsStorefrontRoutes(app, deps) {
|
|
|
85
96
|
const block = await deps.storefrontResolver.resolveBlockByCode({
|
|
86
97
|
code,
|
|
87
98
|
resolvedChannel: resolvedChannel(request),
|
|
88
|
-
language: query['language'] ??
|
|
99
|
+
language: query['language'] ?? headerLanguage(request),
|
|
89
100
|
});
|
|
90
101
|
if (!block) {
|
|
91
102
|
throw new HttpError(404, ERROR_CODES.CMS_BLOCK_NOT_FOUND, 'CMS Block not found.');
|
|
@@ -101,7 +112,7 @@ export async function registerCmsStorefrontRoutes(app, deps) {
|
|
|
101
112
|
const hook = await deps.storefrontResolver.resolveHookByCode({
|
|
102
113
|
code,
|
|
103
114
|
resolvedChannel: resolvedChannel(request),
|
|
104
|
-
language: query['language'] ??
|
|
115
|
+
language: query['language'] ?? headerLanguage(request),
|
|
105
116
|
});
|
|
106
117
|
if (!hook) {
|
|
107
118
|
throw new HttpError(404, ERROR_CODES.CMS_HOOK_NOT_FOUND, 'CMS Hook not found.');
|