@endora-commerce/mod-catalog 0.109.0 → 0.110.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/dist/admin/components/CopyToChannelsDialog.d.ts +37 -0
- package/dist/admin/components/CopyToChannelsDialog.d.ts.map +1 -0
- package/dist/admin/components/CopyToChannelsDialog.js +83 -0
- package/dist/admin/components/CopyToChannelsDialog.js.map +1 -0
- package/dist/admin/components/PackagingUnitsEditor.d.ts +13 -4
- package/dist/admin/components/PackagingUnitsEditor.d.ts.map +1 -1
- package/dist/admin/components/PackagingUnitsEditor.js +20 -85
- package/dist/admin/components/PackagingUnitsEditor.js.map +1 -1
- package/dist/admin/components/ProductAttachmentsSection.d.ts +1 -3
- package/dist/admin/components/ProductAttachmentsSection.d.ts.map +1 -1
- package/dist/admin/components/ProductAttachmentsSection.js +59 -98
- package/dist/admin/components/ProductAttachmentsSection.js.map +1 -1
- package/dist/admin/components/ProductAttributesTab.d.ts +1 -11
- package/dist/admin/components/ProductAttributesTab.d.ts.map +1 -1
- package/dist/admin/components/ProductAttributesTab.js +128 -119
- package/dist/admin/components/ProductAttributesTab.js.map +1 -1
- package/dist/admin/components/ProductContentCard.d.ts +41 -0
- package/dist/admin/components/ProductContentCard.d.ts.map +1 -0
- package/dist/admin/components/ProductContentCard.js +28 -0
- package/dist/admin/components/ProductContentCard.js.map +1 -0
- package/dist/admin/components/ProductGallerySection.d.ts +2 -13
- package/dist/admin/components/ProductGallerySection.d.ts.map +1 -1
- package/dist/admin/components/ProductGallerySection.js +98 -354
- package/dist/admin/components/ProductGallerySection.js.map +1 -1
- package/dist/admin/components/ProductOrderRulesCard.d.ts +11 -15
- package/dist/admin/components/ProductOrderRulesCard.d.ts.map +1 -1
- package/dist/admin/components/ProductOrderRulesCard.js +15 -268
- package/dist/admin/components/ProductOrderRulesCard.js.map +1 -1
- package/dist/admin/components/ProductScopeBar.d.ts +28 -0
- package/dist/admin/components/ProductScopeBar.d.ts.map +1 -0
- package/dist/admin/components/ProductScopeBar.js +70 -0
- package/dist/admin/components/ProductScopeBar.js.map +1 -0
- package/dist/admin/components/ProductScopeOverview.d.ts +13 -1
- package/dist/admin/components/ProductScopeOverview.d.ts.map +1 -1
- package/dist/admin/components/ProductScopeOverview.js +51 -36
- package/dist/admin/components/ProductScopeOverview.js.map +1 -1
- package/dist/admin/components/ProductUrlRedirects.d.ts +15 -0
- package/dist/admin/components/ProductUrlRedirects.d.ts.map +1 -0
- package/dist/admin/components/ProductUrlRedirects.js +70 -0
- package/dist/admin/components/ProductUrlRedirects.js.map +1 -0
- package/dist/admin/components/editor/DetailsTab.d.ts +30 -0
- package/dist/admin/components/editor/DetailsTab.d.ts.map +1 -0
- package/dist/admin/components/editor/DetailsTab.js +59 -0
- package/dist/admin/components/editor/DetailsTab.js.map +1 -0
- package/dist/admin/components/editor/ImmediateBadge.d.ts +21 -0
- package/dist/admin/components/editor/ImmediateBadge.d.ts.map +1 -0
- package/dist/admin/components/editor/ImmediateBadge.js +21 -0
- package/dist/admin/components/editor/ImmediateBadge.js.map +1 -0
- package/dist/admin/components/editor/confirm-removal.d.ts +13 -0
- package/dist/admin/components/editor/confirm-removal.d.ts.map +1 -0
- package/dist/admin/components/editor/confirm-removal.js +33 -0
- package/dist/admin/components/editor/confirm-removal.js.map +1 -0
- package/dist/admin/components/editor/editor-context.d.ts +53 -0
- package/dist/admin/components/editor/editor-context.d.ts.map +1 -0
- package/dist/admin/components/editor/editor-context.js +88 -0
- package/dist/admin/components/editor/editor-context.js.map +1 -0
- package/dist/admin/components/editor/scoped-controls.d.ts +46 -0
- package/dist/admin/components/editor/scoped-controls.d.ts.map +1 -0
- package/dist/admin/components/editor/scoped-controls.js +64 -0
- package/dist/admin/components/editor/scoped-controls.js.map +1 -0
- package/dist/admin/index.d.ts +1 -1
- package/dist/admin/index.d.ts.map +1 -1
- package/dist/admin/index.js +11 -0
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/lib/attribute-scope.d.ts +17 -14
- package/dist/admin/lib/attribute-scope.d.ts.map +1 -1
- package/dist/admin/lib/attribute-scope.js +12 -9
- package/dist/admin/lib/attribute-scope.js.map +1 -1
- package/dist/admin/lib/editor-scope.d.ts +35 -0
- package/dist/admin/lib/editor-scope.d.ts.map +1 -0
- package/dist/admin/lib/editor-scope.js +114 -0
- package/dist/admin/lib/editor-scope.js.map +1 -0
- package/dist/admin/lib/order-minimum-input.d.ts +13 -0
- package/dist/admin/lib/order-minimum-input.d.ts.map +1 -0
- package/dist/admin/lib/order-minimum-input.js +16 -0
- package/dist/admin/lib/order-minimum-input.js.map +1 -0
- package/dist/admin/lib/product-labels.d.ts +0 -2
- package/dist/admin/lib/product-labels.d.ts.map +1 -1
- package/dist/admin/lib/product-labels.js +1 -5
- package/dist/admin/lib/product-labels.js.map +1 -1
- package/dist/admin/lib/product-scopes-api.d.ts +5 -22
- package/dist/admin/lib/product-scopes-api.d.ts.map +1 -1
- package/dist/admin/lib/product-scopes-api.js +1 -45
- package/dist/admin/lib/product-scopes-api.js.map +1 -1
- package/dist/admin/lib/product-url-keys-api.d.ts +4 -27
- package/dist/admin/lib/product-url-keys-api.d.ts.map +1 -1
- package/dist/admin/lib/product-url-keys-api.js +0 -49
- package/dist/admin/lib/product-url-keys-api.js.map +1 -1
- package/dist/admin/lib/scope-overview.d.ts +13 -14
- package/dist/admin/lib/scope-overview.d.ts.map +1 -1
- package/dist/admin/lib/scope-overview.js +36 -31
- package/dist/admin/lib/scope-overview.js.map +1 -1
- package/dist/admin/lib/scoped-editor-store.d.ts +81 -0
- package/dist/admin/lib/scoped-editor-store.d.ts.map +1 -0
- package/dist/admin/lib/scoped-editor-store.js +198 -0
- package/dist/admin/lib/scoped-editor-store.js.map +1 -0
- package/dist/admin/lib/scoped-values-api.d.ts +14 -0
- package/dist/admin/lib/scoped-values-api.d.ts.map +1 -0
- package/dist/admin/lib/scoped-values-api.js +55 -0
- package/dist/admin/lib/scoped-values-api.js.map +1 -0
- package/dist/admin/pages/AttributesManager.d.ts.map +1 -1
- package/dist/admin/pages/AttributesManager.js +119 -38
- package/dist/admin/pages/AttributesManager.js.map +1 -1
- package/dist/admin/pages/ProductContentPage.d.ts +27 -0
- package/dist/admin/pages/ProductContentPage.d.ts.map +1 -0
- package/dist/admin/pages/ProductContentPage.js +161 -0
- package/dist/admin/pages/ProductContentPage.js.map +1 -0
- package/dist/admin/pages/ProductCreateForm.d.ts +3 -0
- package/dist/admin/pages/ProductCreateForm.d.ts.map +1 -0
- package/dist/admin/pages/ProductCreateForm.js +87 -0
- package/dist/admin/pages/ProductCreateForm.js.map +1 -0
- package/dist/admin/pages/ProductEditor.d.ts.map +1 -1
- package/dist/admin/pages/ProductEditor.js +840 -457
- package/dist/admin/pages/ProductEditor.js.map +1 -1
- package/dist/admin/pages/ProductsList.d.ts.map +1 -1
- package/dist/admin/pages/ProductsList.js +9 -19
- package/dist/admin/pages/ProductsList.js.map +1 -1
- package/dist/backend/admin-search-provider.d.ts +2 -1
- package/dist/backend/admin-search-provider.d.ts.map +1 -1
- package/dist/backend/admin-search-provider.js +1 -1
- package/dist/backend/admin-search-provider.js.map +1 -1
- package/dist/backend/commands/attribute-commands.d.ts +4 -3
- package/dist/backend/commands/attribute-commands.d.ts.map +1 -1
- package/dist/backend/commands/attribute-commands.js +82 -21
- package/dist/backend/commands/attribute-commands.js.map +1 -1
- package/dist/backend/commands/product-content-commands.d.ts +31 -0
- package/dist/backend/commands/product-content-commands.d.ts.map +1 -0
- package/dist/backend/commands/product-content-commands.js +70 -0
- package/dist/backend/commands/product-content-commands.js.map +1 -0
- package/dist/backend/commands/scoped-values.commands.d.ts +95 -0
- package/dist/backend/commands/scoped-values.commands.d.ts.map +1 -0
- package/dist/backend/commands/scoped-values.commands.js +235 -0
- package/dist/backend/commands/scoped-values.commands.js.map +1 -0
- package/dist/backend/demo/reset.d.ts.map +1 -1
- package/dist/backend/demo/reset.js +2 -1
- package/dist/backend/demo/reset.js.map +1 -1
- package/dist/backend/demo/rows.d.ts +18 -0
- package/dist/backend/demo/rows.d.ts.map +1 -1
- package/dist/backend/demo/rows.js +18 -0
- package/dist/backend/demo/rows.js.map +1 -1
- package/dist/backend/demo/seed.d.ts +2 -1
- package/dist/backend/demo/seed.d.ts.map +1 -1
- package/dist/backend/demo/seed.js +20 -6
- package/dist/backend/demo/seed.js.map +1 -1
- package/dist/backend/entities/gallery-item-scope-override.entity.d.ts +30 -0
- package/dist/backend/entities/gallery-item-scope-override.entity.d.ts.map +1 -0
- package/dist/backend/entities/gallery-item-scope-override.entity.js +80 -0
- package/dist/backend/entities/gallery-item-scope-override.entity.js.map +1 -0
- package/dist/backend/entities/gallery-item.entity.d.ts +7 -6
- package/dist/backend/entities/gallery-item.entity.d.ts.map +1 -1
- package/dist/backend/entities/gallery-item.entity.js +11 -6
- package/dist/backend/entities/gallery-item.entity.js.map +1 -1
- package/dist/backend/entities/gallery-role-scope-override.entity.d.ts +28 -0
- package/dist/backend/entities/gallery-role-scope-override.entity.d.ts.map +1 -0
- package/dist/backend/entities/gallery-role-scope-override.entity.js +75 -0
- package/dist/backend/entities/gallery-role-scope-override.entity.js.map +1 -0
- package/dist/backend/entities/product-attachment-scope-override.entity.d.ts +30 -0
- package/dist/backend/entities/product-attachment-scope-override.entity.d.ts.map +1 -0
- package/dist/backend/entities/product-attachment-scope-override.entity.js +80 -0
- package/dist/backend/entities/product-attachment-scope-override.entity.js.map +1 -0
- package/dist/backend/entities/product-attachment.entity.d.ts +4 -6
- package/dist/backend/entities/product-attachment.entity.d.ts.map +1 -1
- package/dist/backend/entities/product-attachment.entity.js +6 -12
- package/dist/backend/entities/product-attachment.entity.js.map +1 -1
- package/dist/backend/entities/product-attribute.entity.d.ts +5 -9
- package/dist/backend/entities/product-attribute.entity.d.ts.map +1 -1
- package/dist/backend/entities/product-attribute.entity.js +5 -13
- package/dist/backend/entities/product-attribute.entity.js.map +1 -1
- package/dist/backend/entities/product-channel-scope.entity.d.ts +7 -2
- package/dist/backend/entities/product-channel-scope.entity.d.ts.map +1 -1
- package/dist/backend/entities/product-channel-scope.entity.js +10 -1
- package/dist/backend/entities/product-channel-scope.entity.js.map +1 -1
- package/dist/backend/entities/product-content-value.entity.d.ts +39 -0
- package/dist/backend/entities/product-content-value.entity.d.ts.map +1 -0
- package/dist/backend/entities/product-content-value.entity.js +81 -0
- package/dist/backend/entities/product-content-value.entity.js.map +1 -0
- package/dist/backend/entities/product-packaging-unit-scope-override.entity.d.ts +30 -0
- package/dist/backend/entities/product-packaging-unit-scope-override.entity.d.ts.map +1 -0
- package/dist/backend/entities/product-packaging-unit-scope-override.entity.js +80 -0
- package/dist/backend/entities/product-packaging-unit-scope-override.entity.js.map +1 -0
- package/dist/backend/entities/product-packaging-unit.entity.d.ts +1 -7
- package/dist/backend/entities/product-packaging-unit.entity.d.ts.map +1 -1
- package/dist/backend/entities/product-packaging-unit.entity.js +0 -10
- package/dist/backend/entities/product-packaging-unit.entity.js.map +1 -1
- package/dist/backend/entities/product-url-key.entity.d.ts +14 -19
- package/dist/backend/entities/product-url-key.entity.d.ts.map +1 -1
- package/dist/backend/entities/product-url-key.entity.js +17 -22
- package/dist/backend/entities/product-url-key.entity.js.map +1 -1
- package/dist/backend/entities/product-url-redirect.entity.d.ts +8 -13
- package/dist/backend/entities/product-url-redirect.entity.d.ts.map +1 -1
- package/dist/backend/entities/product-url-redirect.entity.js +13 -14
- package/dist/backend/entities/product-url-redirect.entity.js.map +1 -1
- package/dist/backend/entities/product-variant.entity.d.ts +8 -1
- package/dist/backend/entities/product-variant.entity.d.ts.map +1 -1
- package/dist/backend/entities/product-variant.entity.js +13 -2
- package/dist/backend/entities/product-variant.entity.js.map +1 -1
- package/dist/backend/entities/product.entity.d.ts +31 -14
- package/dist/backend/entities/product.entity.d.ts.map +1 -1
- package/dist/backend/entities/product.entity.js +41 -34
- package/dist/backend/entities/product.entity.js.map +1 -1
- package/dist/backend/index.d.ts +8 -3
- package/dist/backend/index.d.ts.map +1 -1
- package/dist/backend/index.js +136 -49
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/plugin.d.ts +36 -6
- package/dist/backend/plugin.d.ts.map +1 -1
- package/dist/backend/plugin.js +36 -13
- package/dist/backend/plugin.js.map +1 -1
- package/dist/backend/prompt-tools.d.ts +3 -2
- package/dist/backend/prompt-tools.d.ts.map +1 -1
- package/dist/backend/prompt-tools.js +18 -7
- package/dist/backend/prompt-tools.js.map +1 -1
- package/dist/backend/routes.admin.d.ts +15 -16
- package/dist/backend/routes.admin.d.ts.map +1 -1
- package/dist/backend/routes.admin.js +110 -99
- package/dist/backend/routes.admin.js.map +1 -1
- package/dist/backend/routes.api-key.d.ts.map +1 -1
- package/dist/backend/routes.api-key.js +4 -2
- package/dist/backend/routes.api-key.js.map +1 -1
- package/dist/backend/routes.public.d.ts +8 -1
- package/dist/backend/routes.public.d.ts.map +1 -1
- package/dist/backend/routes.public.js +60 -8
- package/dist/backend/routes.public.js.map +1 -1
- package/dist/backend/services/asset-references.d.ts +12 -1
- package/dist/backend/services/asset-references.d.ts.map +1 -1
- package/dist/backend/services/asset-references.js +42 -2
- package/dist/backend/services/asset-references.js.map +1 -1
- package/dist/backend/services/attachment-packaging-scopes.d.ts +38 -20
- package/dist/backend/services/attachment-packaging-scopes.d.ts.map +1 -1
- package/dist/backend/services/attachment-packaging-scopes.js +58 -75
- package/dist/backend/services/attachment-packaging-scopes.js.map +1 -1
- package/dist/backend/services/attachment.service.d.ts +4 -8
- package/dist/backend/services/attachment.service.d.ts.map +1 -1
- package/dist/backend/services/attachment.service.js +35 -49
- package/dist/backend/services/attachment.service.js.map +1 -1
- package/dist/backend/services/attribute-filter-match.d.ts +14 -0
- package/dist/backend/services/attribute-filter-match.d.ts.map +1 -0
- package/dist/backend/services/attribute-filter-match.js +19 -0
- package/dist/backend/services/attribute-filter-match.js.map +1 -0
- package/dist/backend/services/attribute-scope-preview.d.ts +17 -7
- package/dist/backend/services/attribute-scope-preview.d.ts.map +1 -1
- package/dist/backend/services/attribute-scope-preview.js +30 -20
- package/dist/backend/services/attribute-scope-preview.js.map +1 -1
- package/dist/backend/services/attribute-set.service.d.ts +10 -1
- package/dist/backend/services/attribute-set.service.d.ts.map +1 -1
- package/dist/backend/services/attribute-set.service.js +30 -4
- package/dist/backend/services/attribute-set.service.js.map +1 -1
- package/dist/backend/services/attribute-type-mapping.d.ts +2 -2
- package/dist/backend/services/attribute-type-mapping.d.ts.map +1 -1
- package/dist/backend/services/attribute-type-mapping.js +6 -0
- package/dist/backend/services/attribute-type-mapping.js.map +1 -1
- package/dist/backend/services/attribute-usage.d.ts +31 -0
- package/dist/backend/services/attribute-usage.d.ts.map +1 -0
- package/dist/backend/services/attribute-usage.js +29 -0
- package/dist/backend/services/attribute-usage.js.map +1 -0
- package/dist/backend/services/bulk-operation.service.d.ts.map +1 -1
- package/dist/backend/services/bulk-operation.service.js +12 -6
- package/dist/backend/services/bulk-operation.service.js.map +1 -1
- package/dist/backend/services/bundle.service.d.ts.map +1 -1
- package/dist/backend/services/bundle.service.js +19 -1
- package/dist/backend/services/bundle.service.js.map +1 -1
- package/dist/backend/services/catalog-admin-search.service.d.ts +3 -2
- package/dist/backend/services/catalog-admin-search.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-admin-search.service.js +6 -6
- package/dist/backend/services/catalog-admin-search.service.js.map +1 -1
- package/dist/backend/services/catalog-admin.service.d.ts +63 -12
- package/dist/backend/services/catalog-admin.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-admin.service.js +352 -189
- package/dist/backend/services/catalog-admin.service.js.map +1 -1
- package/dist/backend/services/catalog-attribute-read.service.d.ts +14 -0
- package/dist/backend/services/catalog-attribute-read.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-attribute-read.service.js +7 -19
- package/dist/backend/services/catalog-attribute-read.service.js.map +1 -1
- package/dist/backend/services/catalog-bulk-import.service.d.ts +52 -5
- package/dist/backend/services/catalog-bulk-import.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-bulk-import.service.js +190 -142
- package/dist/backend/services/catalog-bulk-import.service.js.map +1 -1
- package/dist/backend/services/catalog-bulk-update.service.d.ts +5 -3
- package/dist/backend/services/catalog-bulk-update.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-bulk-update.service.js +21 -8
- package/dist/backend/services/catalog-bulk-update.service.js.map +1 -1
- package/dist/backend/services/catalog-product-read.service.d.ts +11 -1
- package/dist/backend/services/catalog-product-read.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-product-read.service.js +37 -17
- package/dist/backend/services/catalog-product-read.service.js.map +1 -1
- package/dist/backend/services/catalog-query.service.d.ts +39 -8
- package/dist/backend/services/catalog-query.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-query.service.js +154 -116
- package/dist/backend/services/catalog-query.service.js.map +1 -1
- package/dist/backend/services/catalog-quick-search.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-quick-search.service.js +5 -5
- package/dist/backend/services/catalog-quick-search.service.js.map +1 -1
- package/dist/backend/services/catalog-write-ports.d.ts +14 -16
- package/dist/backend/services/catalog-write-ports.d.ts.map +1 -1
- package/dist/backend/services/catalog-write-ports.js +11 -70
- package/dist/backend/services/catalog-write-ports.js.map +1 -1
- package/dist/backend/services/category-admin.service.d.ts.map +1 -1
- package/dist/backend/services/category-admin.service.js +9 -1
- package/dist/backend/services/category-admin.service.js.map +1 -1
- package/dist/backend/services/content-attribute-rules.d.ts +49 -0
- package/dist/backend/services/content-attribute-rules.d.ts.map +1 -0
- package/dist/backend/services/content-attribute-rules.js +89 -0
- package/dist/backend/services/content-attribute-rules.js.map +1 -0
- package/dist/backend/services/effective-value.sql.d.ts +24 -38
- package/dist/backend/services/effective-value.sql.d.ts.map +1 -1
- package/dist/backend/services/effective-value.sql.js +37 -87
- package/dist/backend/services/effective-value.sql.js.map +1 -1
- package/dist/backend/services/gallery-scopes.d.ts +45 -22
- package/dist/backend/services/gallery-scopes.d.ts.map +1 -1
- package/dist/backend/services/gallery-scopes.js +116 -109
- package/dist/backend/services/gallery-scopes.js.map +1 -1
- package/dist/backend/services/gallery.service.d.ts +13 -27
- package/dist/backend/services/gallery.service.d.ts.map +1 -1
- package/dist/backend/services/gallery.service.js +75 -199
- package/dist/backend/services/gallery.service.js.map +1 -1
- package/dist/backend/services/grouped.service.d.ts.map +1 -1
- package/dist/backend/services/grouped.service.js +13 -1
- package/dist/backend/services/grouped.service.js.map +1 -1
- package/dist/backend/services/packaging-unit.service.d.ts.map +1 -1
- package/dist/backend/services/packaging-unit.service.js +7 -12
- package/dist/backend/services/packaging-unit.service.js.map +1 -1
- package/dist/backend/services/page-builder-content.d.ts +64 -0
- package/dist/backend/services/page-builder-content.d.ts.map +1 -0
- package/dist/backend/services/page-builder-content.js +113 -0
- package/dist/backend/services/page-builder-content.js.map +1 -0
- package/dist/backend/services/primary-asset-url.d.ts +6 -1
- package/dist/backend/services/primary-asset-url.d.ts.map +1 -1
- package/dist/backend/services/primary-asset-url.js +9 -4
- package/dist/backend/services/primary-asset-url.js.map +1 -1
- package/dist/backend/services/product-availability.service.d.ts +16 -3
- package/dist/backend/services/product-availability.service.d.ts.map +1 -1
- package/dist/backend/services/product-availability.service.js +58 -21
- package/dist/backend/services/product-availability.service.js.map +1 -1
- package/dist/backend/services/product-content.service.d.ts +62 -0
- package/dist/backend/services/product-content.service.d.ts.map +1 -0
- package/dist/backend/services/product-content.service.js +122 -0
- package/dist/backend/services/product-content.service.js.map +1 -0
- package/dist/backend/services/product-editor-preferences.service.d.ts +6 -0
- package/dist/backend/services/product-editor-preferences.service.d.ts.map +1 -1
- package/dist/backend/services/product-editor-preferences.service.js +12 -0
- package/dist/backend/services/product-editor-preferences.service.js.map +1 -1
- package/dist/backend/services/product-global-field-rules.d.ts +39 -0
- package/dist/backend/services/product-global-field-rules.d.ts.map +1 -0
- package/dist/backend/services/product-global-field-rules.js +84 -0
- package/dist/backend/services/product-global-field-rules.js.map +1 -0
- package/dist/backend/services/product-link.service.d.ts.map +1 -1
- package/dist/backend/services/product-link.service.js +14 -16
- package/dist/backend/services/product-link.service.js.map +1 -1
- package/dist/backend/services/product-list-view-service.d.ts.map +1 -1
- package/dist/backend/services/product-list-view-service.js +5 -8
- package/dist/backend/services/product-list-view-service.js.map +1 -1
- package/dist/backend/services/product-page-revalidation.d.ts +9 -0
- package/dist/backend/services/product-page-revalidation.d.ts.map +1 -1
- package/dist/backend/services/product-page-revalidation.js +19 -0
- package/dist/backend/services/product-page-revalidation.js.map +1 -1
- package/dist/backend/services/product-scopes.service.d.ts +15 -6
- package/dist/backend/services/product-scopes.service.d.ts.map +1 -1
- package/dist/backend/services/product-scopes.service.js +87 -33
- package/dist/backend/services/product-scopes.service.js.map +1 -1
- package/dist/backend/services/product-value-resolver.service.d.ts +2 -2
- package/dist/backend/services/product-value-resolver.service.d.ts.map +1 -1
- package/dist/backend/services/product-value-resolver.service.js +4 -7
- package/dist/backend/services/product-value-resolver.service.js.map +1 -1
- package/dist/backend/services/publication-window-sweep.d.ts +61 -7
- package/dist/backend/services/publication-window-sweep.d.ts.map +1 -1
- package/dist/backend/services/publication-window-sweep.js +106 -19
- package/dist/backend/services/publication-window-sweep.js.map +1 -1
- package/dist/backend/services/scheduled-work-probe.d.ts +34 -0
- package/dist/backend/services/scheduled-work-probe.d.ts.map +1 -0
- package/dist/backend/services/scheduled-work-probe.js +30 -0
- package/dist/backend/services/scheduled-work-probe.js.map +1 -0
- package/dist/backend/services/scope-completeness.d.ts +11 -11
- package/dist/backend/services/scope-completeness.d.ts.map +1 -1
- package/dist/backend/services/scope-completeness.js +26 -33
- package/dist/backend/services/scope-completeness.js.map +1 -1
- package/dist/backend/services/scope-overview.service.d.ts +24 -24
- package/dist/backend/services/scope-overview.service.d.ts.map +1 -1
- package/dist/backend/services/scope-overview.service.js +33 -76
- package/dist/backend/services/scope-overview.service.js.map +1 -1
- package/dist/backend/services/scoped-store-adapters.d.ts +58 -0
- package/dist/backend/services/scoped-store-adapters.d.ts.map +1 -0
- package/dist/backend/services/scoped-store-adapters.js +92 -0
- package/dist/backend/services/scoped-store-adapters.js.map +1 -0
- package/dist/backend/services/scoped-values-global-only.d.ts +36 -0
- package/dist/backend/services/scoped-values-global-only.d.ts.map +1 -0
- package/dist/backend/services/scoped-values-global-only.js +92 -0
- package/dist/backend/services/scoped-values-global-only.js.map +1 -0
- package/dist/backend/services/scoped-values-import.d.ts +86 -0
- package/dist/backend/services/scoped-values-import.d.ts.map +1 -0
- package/dist/backend/services/scoped-values-import.js +320 -0
- package/dist/backend/services/scoped-values-import.js.map +1 -0
- package/dist/backend/services/scoped-values-read.service.d.ts +56 -0
- package/dist/backend/services/scoped-values-read.service.d.ts.map +1 -0
- package/dist/backend/services/scoped-values-read.service.js +289 -0
- package/dist/backend/services/scoped-values-read.service.js.map +1 -0
- package/dist/backend/services/scoped-values-save.service.d.ts +79 -0
- package/dist/backend/services/scoped-values-save.service.d.ts.map +1 -0
- package/dist/backend/services/scoped-values-save.service.js +675 -0
- package/dist/backend/services/scoped-values-save.service.js.map +1 -0
- package/dist/backend/services/scoped-values-state.d.ts +94 -0
- package/dist/backend/services/scoped-values-state.d.ts.map +1 -0
- package/dist/backend/services/scoped-values-state.js +159 -0
- package/dist/backend/services/scoped-values-state.js.map +1 -0
- package/dist/backend/services/scoped-values.service.d.ts +36 -0
- package/dist/backend/services/scoped-values.service.d.ts.map +1 -0
- package/dist/backend/services/scoped-values.service.js +92 -0
- package/dist/backend/services/scoped-values.service.js.map +1 -0
- package/dist/backend/services/storefront-value-overrides.d.ts +7 -8
- package/dist/backend/services/storefront-value-overrides.d.ts.map +1 -1
- package/dist/backend/services/storefront-value-overrides.js +11 -14
- package/dist/backend/services/storefront-value-overrides.js.map +1 -1
- package/dist/backend/services/url-key-resolution.service.d.ts +12 -18
- package/dist/backend/services/url-key-resolution.service.d.ts.map +1 -1
- package/dist/backend/services/url-key-resolution.service.js +43 -43
- package/dist/backend/services/url-key-resolution.service.js.map +1 -1
- package/dist/backend/services/url-key.service.d.ts +87 -135
- package/dist/backend/services/url-key.service.d.ts.map +1 -1
- package/dist/backend/services/url-key.service.js +447 -619
- package/dist/backend/services/url-key.service.js.map +1 -1
- package/dist/manifest.d.ts +7 -1
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +34 -0
- package/dist/manifest.js.map +1 -1
- package/dist/migrations/20261030T113855_catalog_scope_model_texts.d.ts +36 -0
- package/dist/migrations/20261030T113855_catalog_scope_model_texts.d.ts.map +1 -0
- package/dist/migrations/20261030T113855_catalog_scope_model_texts.js +225 -0
- package/dist/migrations/20261030T113855_catalog_scope_model_texts.js.map +1 -0
- package/dist/migrations/20261030T113859_catalog_scope_model_order_rules.d.ts +18 -0
- package/dist/migrations/20261030T113859_catalog_scope_model_order_rules.d.ts.map +1 -0
- package/dist/migrations/20261030T113859_catalog_scope_model_order_rules.js +39 -0
- package/dist/migrations/20261030T113859_catalog_scope_model_order_rules.js.map +1 -0
- package/dist/migrations/20261030T113904_catalog_scope_model_url_keys.d.ts +6 -0
- package/dist/migrations/20261030T113904_catalog_scope_model_url_keys.d.ts.map +1 -0
- package/dist/migrations/20261030T113904_catalog_scope_model_url_keys.js +119 -0
- package/dist/migrations/20261030T113904_catalog_scope_model_url_keys.js.map +1 -0
- package/dist/migrations/20261030T113908_catalog_scope_model_media.d.ts +6 -0
- package/dist/migrations/20261030T113908_catalog_scope_model_media.d.ts.map +1 -0
- package/dist/migrations/20261030T113908_catalog_scope_model_media.js +185 -0
- package/dist/migrations/20261030T113908_catalog_scope_model_media.js.map +1 -0
- package/dist/migrations/20261104T121504_catalog_product_content_values.d.ts +36 -0
- package/dist/migrations/20261104T121504_catalog_product_content_values.d.ts.map +1 -0
- package/dist/migrations/20261104T121504_catalog_product_content_values.js +53 -0
- package/dist/migrations/20261104T121504_catalog_product_content_values.js.map +1 -0
- package/dist/migrations/20261107T093126_catalog_sku_unique_among_live.d.ts +33 -0
- package/dist/migrations/20261107T093126_catalog_sku_unique_among_live.d.ts.map +1 -0
- package/dist/migrations/20261107T093126_catalog_sku_unique_among_live.js +58 -0
- package/dist/migrations/20261107T093126_catalog_sku_unique_among_live.js.map +1 -0
- package/dist/migrations/20261107T120008_catalog_product_created_at_milliseconds.d.ts +36 -0
- package/dist/migrations/20261107T120008_catalog_product_created_at_milliseconds.d.ts.map +1 -0
- package/dist/migrations/20261107T120008_catalog_product_created_at_milliseconds.js +40 -0
- package/dist/migrations/20261107T120008_catalog_product_created_at_milliseconds.js.map +1 -0
- package/dist/migrations/index.d.ts +8 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +15 -1
- package/dist/migrations/index.js.map +1 -1
- package/docs/catalog/attachments.md +53 -43
- package/docs/catalog/attribute-sets.md +2 -2
- package/docs/catalog/attributes.md +68 -8
- package/docs/catalog/category-content.md +3 -0
- package/docs/catalog/composite-products.md +2 -2
- package/docs/catalog/editing-a-product-at-a-scope.md +95 -0
- package/docs/catalog/gallery-and-labels.md +61 -60
- package/docs/catalog/packaging-units.md +43 -34
- package/docs/catalog/per-channel-per-language-overrides.md +83 -410
- package/docs/catalog/product-content.md +180 -0
- package/docs/catalog/product-links.md +2 -2
- package/docs/catalog/url-keys-and-redirects.md +79 -79
- package/docs/catalog.md +68 -14
- package/i18n/en.json +270 -270
- package/i18n/pl.json +272 -272
- package/package.json +11 -11
- package/dist/admin/components/AttachmentScopesDialog.d.ts +0 -22
- package/dist/admin/components/AttachmentScopesDialog.d.ts.map +0 -1
- package/dist/admin/components/AttachmentScopesDialog.js +0 -70
- package/dist/admin/components/AttachmentScopesDialog.js.map +0 -1
- package/dist/admin/components/ProductScopeControls.d.ts +0 -31
- package/dist/admin/components/ProductScopeControls.d.ts.map +0 -1
- package/dist/admin/components/ProductScopeControls.js +0 -243
- package/dist/admin/components/ProductScopeControls.js.map +0 -1
- package/dist/admin/components/ProductScopeEditor.d.ts +0 -88
- package/dist/admin/components/ProductScopeEditor.d.ts.map +0 -1
- package/dist/admin/components/ProductScopeEditor.js +0 -396
- package/dist/admin/components/ProductScopeEditor.js.map +0 -1
- package/dist/admin/components/ProductUrlKeysPanel.d.ts +0 -17
- package/dist/admin/components/ProductUrlKeysPanel.d.ts.map +0 -1
- package/dist/admin/components/ProductUrlKeysPanel.js +0 -215
- package/dist/admin/components/ProductUrlKeysPanel.js.map +0 -1
- package/dist/admin/components/ScopedDialogParts.d.ts +0 -23
- package/dist/admin/components/ScopedDialogParts.d.ts.map +0 -1
- package/dist/admin/components/ScopedDialogParts.js +0 -16
- package/dist/admin/components/ScopedDialogParts.js.map +0 -1
- package/dist/admin/lib/media-scopes.d.ts +0 -41
- package/dist/admin/lib/media-scopes.d.ts.map +0 -1
- package/dist/admin/lib/media-scopes.js +0 -66
- package/dist/admin/lib/media-scopes.js.map +0 -1
- package/dist/admin/lib/product-scope-drafts.d.ts +0 -77
- package/dist/admin/lib/product-scope-drafts.d.ts.map +0 -1
- package/dist/admin/lib/product-scope-drafts.js +0 -133
- package/dist/admin/lib/product-scope-drafts.js.map +0 -1
- package/dist/backend/entities/gallery-item-channel-hidden.entity.d.ts +0 -14
- package/dist/backend/entities/gallery-item-channel-hidden.entity.d.ts.map +0 -1
- package/dist/backend/entities/gallery-item-channel-hidden.entity.js +0 -42
- package/dist/backend/entities/gallery-item-channel-hidden.entity.js.map +0 -1
- package/dist/backend/entities/gallery-item-channel-label.entity.d.ts +0 -18
- package/dist/backend/entities/gallery-item-channel-label.entity.d.ts.map +0 -1
- package/dist/backend/entities/gallery-item-channel-label.entity.js +0 -49
- package/dist/backend/entities/gallery-item-channel-label.entity.js.map +0 -1
- package/dist/backend/entities/product-attachment-channel-hidden.entity.d.ts +0 -13
- package/dist/backend/entities/product-attachment-channel-hidden.entity.d.ts.map +0 -1
- package/dist/backend/entities/product-attachment-channel-hidden.entity.js +0 -41
- package/dist/backend/entities/product-attachment-channel-hidden.entity.js.map +0 -1
- package/dist/backend/services/product-overrides.service.d.ts +0 -84
- package/dist/backend/services/product-overrides.service.d.ts.map +0 -1
- package/dist/backend/services/product-overrides.service.js +0 -211
- package/dist/backend/services/product-overrides.service.js.map +0 -1
- package/dist/backend/services/product-scope-context.service.d.ts +0 -36
- package/dist/backend/services/product-scope-context.service.d.ts.map +0 -1
- package/dist/backend/services/product-scope-context.service.js +0 -107
- package/dist/backend/services/product-scope-context.service.js.map +0 -1
|
@@ -3,12 +3,13 @@ import { LockMode, UniqueConstraintViolationException } from '@mikro-orm/core';
|
|
|
3
3
|
import { ERROR_CODES, isOrderMinimumEligibleType, isValidOrderMinimum, PRICE_FIELDS_REFUSED_ON_PRODUCTS,
|
|
4
4
|
// Aliased: the private method below keeps the name, so the shared function
|
|
5
5
|
// needs one the class body cannot shadow.
|
|
6
|
-
slugify as slugifyText, uuidSchema, } from '@endora-commerce/contracts';
|
|
6
|
+
slugify as slugifyText, uuidSchema, isUuidShape, } from '@endora-commerce/contracts';
|
|
7
7
|
import { HttpError } from '@endora-commerce/platform/http';
|
|
8
8
|
import { Category } from '../entities/category.entity.js';
|
|
9
9
|
import { Product } from '../entities/product.entity.js';
|
|
10
10
|
import { ProductUrlRedirect } from '../entities/product-url-redirect.entity.js';
|
|
11
|
-
import {
|
|
11
|
+
import { allocateFreeSlug } from './url-key.service.js';
|
|
12
|
+
import { bumpScopeVersion } from './scoped-values-state.js';
|
|
12
13
|
import { ProductVariant } from '../entities/product-variant.entity.js';
|
|
13
14
|
import { ProductChannelScope } from '../entities/product-channel-scope.entity.js';
|
|
14
15
|
import { ProductChannelLanguageScope } from '../entities/product-channel-language-scope.entity.js';
|
|
@@ -17,6 +18,9 @@ import { toChannelRecord, toLanguageRecord } from './product-scopes.service.js';
|
|
|
17
18
|
import { assertVirtualDownloadFields, ProductTypeValidationError, } from './product-type-validations.js';
|
|
18
19
|
import { createAttributeCommand, createAttributeOptionCommand, deleteAttributeCommand, deleteAttributeOptionCommand, updateAttributeCommand, updateAttributeOptionCommand, } from '../commands/attribute-commands.js';
|
|
19
20
|
import { requireLinkableAsset } from './linkable-asset.js';
|
|
21
|
+
import { attributeSetExists, findSkuHolder, missingCategoryIds, missingRequiredAttributeKeys, PRODUCT_SKU_MAX, reconcileProductCategories, } from './product-global-field-rules.js';
|
|
22
|
+
import { assertNoContentAttributeValues } from './content-attribute-rules.js';
|
|
23
|
+
import { readAttributeUsage } from './attribute-usage.js';
|
|
20
24
|
// Feature 061 — the API-form mapping helpers moved next to the R7 map; the
|
|
21
25
|
// re-exports keep the long-standing import site (routes, tests) stable.
|
|
22
26
|
export { dbToApiAttributeType, resolveAttributeApiType } from './attribute-type-mapping.js';
|
|
@@ -46,10 +50,13 @@ export function refusePriceFields(fields, pathPrefix = '') {
|
|
|
46
50
|
* identifier, derived or otherwise.
|
|
47
51
|
*/
|
|
48
52
|
const SKU_MAX_LENGTH = 255;
|
|
53
|
+
/** Issue #241 — value equality for a product field the update compares before it writes. */
|
|
54
|
+
function sameValue(a, b) {
|
|
55
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
56
|
+
}
|
|
49
57
|
export class CatalogAdminService {
|
|
50
58
|
emFactory;
|
|
51
59
|
events;
|
|
52
|
-
auditLog;
|
|
53
60
|
salesChannelMembership;
|
|
54
61
|
commandBus;
|
|
55
62
|
attributeRead;
|
|
@@ -57,7 +64,14 @@ export class CatalogAdminService {
|
|
|
57
64
|
copyWarehouseThresholds;
|
|
58
65
|
completenessGate;
|
|
59
66
|
assets;
|
|
60
|
-
|
|
67
|
+
copySeoProductMeta;
|
|
68
|
+
constructor(emFactory, events,
|
|
69
|
+
/**
|
|
70
|
+
* Unread since issue #241: the last write it recorded by hand, the bulk edit's
|
|
71
|
+
* `product.update`, now runs the Command. Kept so the positional signature the
|
|
72
|
+
* composition and the fixtures construct this service with does not move.
|
|
73
|
+
*/
|
|
74
|
+
_auditLog,
|
|
61
75
|
/**
|
|
62
76
|
* Feature 005 / T027 — when injected, every newly-created Product
|
|
63
77
|
* that does not declare explicit channel membership lands in the
|
|
@@ -104,10 +118,11 @@ export class CatalogAdminService {
|
|
|
104
118
|
* constructing the service; a create that names a file without it fails
|
|
105
119
|
* closed ({@link CatalogAdminService.#requireAssets}).
|
|
106
120
|
*/
|
|
107
|
-
assets
|
|
121
|
+
assets,
|
|
122
|
+
/** Feature 174 (FR-119) — `seo`'s metadata copy for a duplicate, presence-decided by the wiring. */
|
|
123
|
+
copySeoProductMeta) {
|
|
108
124
|
this.emFactory = emFactory;
|
|
109
125
|
this.events = events;
|
|
110
|
-
this.auditLog = auditLog;
|
|
111
126
|
this.salesChannelMembership = salesChannelMembership;
|
|
112
127
|
this.commandBus = commandBus;
|
|
113
128
|
this.attributeRead = attributeRead;
|
|
@@ -115,6 +130,7 @@ export class CatalogAdminService {
|
|
|
115
130
|
this.copyWarehouseThresholds = copyWarehouseThresholds;
|
|
116
131
|
this.completenessGate = completenessGate;
|
|
117
132
|
this.assets = assets;
|
|
133
|
+
this.copySeoProductMeta = copySeoProductMeta;
|
|
118
134
|
}
|
|
119
135
|
#requireAssets() {
|
|
120
136
|
if (!this.assets) {
|
|
@@ -126,6 +142,16 @@ export class CatalogAdminService {
|
|
|
126
142
|
async completenessMode() {
|
|
127
143
|
return this.completenessGate?.mode();
|
|
128
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Feature 172 (FR-014) — the early refusal of a content attribute's key on a
|
|
147
|
+
* product write, before any row is read or a transaction opened. Reads the
|
|
148
|
+
* attribute model only when the write carries attribute values at all.
|
|
149
|
+
*/
|
|
150
|
+
async #refuseContentAttributeValues(attributeValues) {
|
|
151
|
+
if (!attributeValues || Object.keys(attributeValues).length === 0)
|
|
152
|
+
return;
|
|
153
|
+
assertNoContentAttributeValues(attributeValues, await this.#requireAttributeRead().listAll());
|
|
154
|
+
}
|
|
129
155
|
#requireAttributeRead() {
|
|
130
156
|
if (!this.attributeRead) {
|
|
131
157
|
throw new Error('CatalogAdminService: CatalogAttributeReadService is not wired — attribute reads are unavailable.');
|
|
@@ -196,6 +222,9 @@ export class CatalogAdminService {
|
|
|
196
222
|
*/
|
|
197
223
|
async createProduct(req, _auditCtx) {
|
|
198
224
|
refusePriceFields(req.attributeValues, 'attributeValues.');
|
|
225
|
+
// Feature 172 (FR-014) — refused before the Command opens a transaction;
|
|
226
|
+
// the set guard inside it refuses the same keys again for every other path.
|
|
227
|
+
await this.#refuseContentAttributeValues(req.attributeValues);
|
|
199
228
|
// Feature 002 (T047): cross-field validation for virtual download
|
|
200
229
|
// fields. Zod's .refine() catches most cases at the boundary; the
|
|
201
230
|
// service-level guard is the belt-and-braces backstop for any
|
|
@@ -252,7 +281,7 @@ export class CatalogAdminService {
|
|
|
252
281
|
// to be allocated against the live table. Without this, two products
|
|
253
282
|
// sharing a name collided on the slug index and the catch above
|
|
254
283
|
// mislabelled the failure `SKU_ALREADY_EXISTS`.
|
|
255
|
-
const slug = await this.allocateUniqueSlug(em,
|
|
284
|
+
const slug = await this.allocateUniqueSlug(em, req.name || req.sku);
|
|
256
285
|
const product = em.create(Product, {
|
|
257
286
|
id: productId,
|
|
258
287
|
sku: req.sku,
|
|
@@ -300,7 +329,7 @@ export class CatalogAdminService {
|
|
|
300
329
|
result: product,
|
|
301
330
|
after: {
|
|
302
331
|
sku: product.sku,
|
|
303
|
-
name:
|
|
332
|
+
name: product.name,
|
|
304
333
|
status: product.status,
|
|
305
334
|
visibility: product.visibility,
|
|
306
335
|
stockMode: product.stockMode,
|
|
@@ -321,26 +350,19 @@ export class CatalogAdminService {
|
|
|
321
350
|
}),
|
|
322
351
|
};
|
|
323
352
|
}
|
|
324
|
-
|
|
353
|
+
/**
|
|
354
|
+
* The unaudited product update: the write, its flush and `product.updated.v1`,
|
|
355
|
+
* with no Command and no audit entry. Only the bus-less fallback of
|
|
356
|
+
* {@link updateProductAudited} and fixtures reach it; every operator, API-key and
|
|
357
|
+
* bulk write runs the `product.update` Command (issue #241, Principle XIII).
|
|
358
|
+
*/
|
|
359
|
+
async updateProduct(id, req, gate) {
|
|
325
360
|
const em = this.emFactory();
|
|
326
361
|
const r = await this.#applyProductUpdate(em, id, req, gate);
|
|
327
362
|
await em.flush();
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
...(auditCtx.impersonatedCustomerAccountId !== undefined
|
|
332
|
-
? { impersonatedCustomerAccountId: auditCtx.impersonatedCustomerAccountId }
|
|
333
|
-
: {}),
|
|
334
|
-
action: 'product.update',
|
|
335
|
-
objectType: 'product',
|
|
336
|
-
objectId: r.product.id,
|
|
337
|
-
stateBefore: r.stateBefore,
|
|
338
|
-
stateAfter: { ...r.stateAfter, changedFields: r.changedFields },
|
|
339
|
-
...(auditCtx.ipAddress !== undefined ? { ipAddress: auditCtx.ipAddress } : {}),
|
|
340
|
-
...(auditCtx.userAgent !== undefined ? { userAgent: auditCtx.userAgent } : {}),
|
|
341
|
-
...(auditCtx.requestId !== undefined ? { requestId: auditCtx.requestId } : {}),
|
|
342
|
-
});
|
|
343
|
-
}
|
|
363
|
+
// Issue #241 — a write that changed nothing announces nothing.
|
|
364
|
+
if (r.changedFields.length === 0)
|
|
365
|
+
return r.product;
|
|
344
366
|
// Feature 163 (FR-010) — a status write never archives, so this write has
|
|
345
367
|
// one announcement; `product.archived.v1` belongs to the Archive action.
|
|
346
368
|
this.events.emit('product.updated.v1', {
|
|
@@ -383,12 +405,23 @@ export class CatalogAdminService {
|
|
|
383
405
|
}
|
|
384
406
|
/**
|
|
385
407
|
* Feature 054 — admin single-update path, audited co-transactionally via the
|
|
386
|
-
* Command Bus (one audit row + the event on commit, none on rollback
|
|
387
|
-
* back to the
|
|
408
|
+
* Command Bus (one audit row + the event on commit, none on rollback; none either
|
|
409
|
+
* when nothing changed, issue #241). Falls back to the unaudited `updateProduct`
|
|
410
|
+
* when no bus is injected (bus-less tests).
|
|
388
411
|
*/
|
|
412
|
+
/**
|
|
413
|
+
* Whether product writes run through the Command Bus, and so are audited. A bulk
|
|
414
|
+
* edit refuses to run when they do not (issue #241): its per-product writes would
|
|
415
|
+
* fall back to the unaudited `updateProduct`.
|
|
416
|
+
*/
|
|
417
|
+
hasCommandBus() {
|
|
418
|
+
return this.commandBus !== undefined;
|
|
419
|
+
}
|
|
389
420
|
async updateProductAudited(id, req, gate) {
|
|
421
|
+
// Feature 172 (FR-014) — before the transaction, as on create.
|
|
422
|
+
await this.#refuseContentAttributeValues(req.attributeValues);
|
|
390
423
|
if (!this.commandBus)
|
|
391
|
-
return this.updateProduct(id, req,
|
|
424
|
+
return this.updateProduct(id, req, gate);
|
|
392
425
|
return this.commandBus.run(this.#updateProductCommand(id, req, gate));
|
|
393
426
|
}
|
|
394
427
|
#updateProductCommand(id, req, gate) {
|
|
@@ -400,21 +433,27 @@ export class CatalogAdminService {
|
|
|
400
433
|
run: async ({ em }) => {
|
|
401
434
|
const r = await this.#applyProductUpdate(em, id, req, gate);
|
|
402
435
|
changedFields = r.changedFields;
|
|
436
|
+
// Issue #241 — a write that changed nothing records no entry and announces
|
|
437
|
+
// nothing. The editor's version bump still commits, as on a no-op scope write.
|
|
438
|
+
if (changedFields.length === 0)
|
|
439
|
+
return { result: r.product, skipAudit: true };
|
|
403
440
|
return {
|
|
404
441
|
result: r.product,
|
|
405
442
|
before: r.stateBefore,
|
|
406
443
|
after: { ...r.stateAfter, changedFields, ...(gate?.apiKeyId ? { apiKeyId: gate.apiKeyId } : {}) },
|
|
407
444
|
};
|
|
408
445
|
},
|
|
409
|
-
event: (product) =>
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
446
|
+
event: (product) => changedFields.length === 0
|
|
447
|
+
? undefined
|
|
448
|
+
: {
|
|
449
|
+
eventName: 'product.updated.v1',
|
|
450
|
+
payload: {
|
|
451
|
+
eventId: randomUUID(),
|
|
452
|
+
occurredAt: new Date().toISOString(),
|
|
453
|
+
productId: product.id,
|
|
454
|
+
changedFields,
|
|
455
|
+
},
|
|
416
456
|
},
|
|
417
|
-
}),
|
|
418
457
|
};
|
|
419
458
|
}
|
|
420
459
|
/**
|
|
@@ -423,16 +462,37 @@ export class CatalogAdminService {
|
|
|
423
462
|
*/
|
|
424
463
|
async #applyProductUpdate(em, id, req, gate) {
|
|
425
464
|
refusePriceFields(req.attributeValues, 'attributeValues.');
|
|
465
|
+
if (!isUuidShape(id)) {
|
|
466
|
+
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
|
|
467
|
+
}
|
|
426
468
|
const product = await em.findOne(Product, { id });
|
|
427
469
|
if (!product) {
|
|
428
470
|
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
|
|
429
471
|
}
|
|
430
472
|
// Feature 155 (FR-001, D5) — refused before anything on the row changes.
|
|
431
473
|
assertOrderMinimumAllowed(product.type, req.minOrderQuantity);
|
|
474
|
+
// Feature 174 (C2/C3 code review 1) — the existence rules the scoped save holds for the same
|
|
475
|
+
// Global-only fields (`product-global-field-rules.ts`), checked before anything is written:
|
|
476
|
+
// an unknown attribute set or an unknown or deleted category used to reach the foreign key
|
|
477
|
+
// (a 500), and a deleted category was linked silently.
|
|
478
|
+
if (req.attributeSetId !== undefined &&
|
|
479
|
+
req.attributeSetId !== product.attributeSetId &&
|
|
480
|
+
!(await attributeSetExists(em, req.attributeSetId))) {
|
|
481
|
+
throw new HttpError(400, ERROR_CODES.VALIDATION_FAILED, 'unknown_attribute_set');
|
|
482
|
+
}
|
|
483
|
+
if (req.categoryIds !== undefined) {
|
|
484
|
+
const missing = await missingCategoryIds(em, req.categoryIds);
|
|
485
|
+
if (missing.length > 0) {
|
|
486
|
+
throw new HttpError(400, ERROR_CODES.VALIDATION_FAILED, `unknown_category_ids: ${missing.join(', ')}`);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
// Feature 174 (R7, contract §6) — a product-row write is Save-overwritable: it moves the
|
|
490
|
+
// editor's version, and a `version` the caller sends is compared first (stale → 409).
|
|
491
|
+
await bumpScopeVersion(em, id, req.version);
|
|
432
492
|
const stateBefore = {
|
|
433
493
|
sku: product.sku,
|
|
434
|
-
name:
|
|
435
|
-
description:
|
|
494
|
+
name: product.name,
|
|
495
|
+
description: product.description,
|
|
436
496
|
stockMode: product.stockMode,
|
|
437
497
|
visibility: product.visibility,
|
|
438
498
|
status: product.status,
|
|
@@ -459,34 +519,34 @@ export class CatalogAdminService {
|
|
|
459
519
|
// create contract enforces. This guard used to read 160 while the
|
|
460
520
|
// column held 64, so a 100-character rename passed validation and then
|
|
461
521
|
// failed at the database; all three now agree.
|
|
462
|
-
if (trimmed.length === 0 || trimmed.length >
|
|
522
|
+
if (trimmed.length === 0 || trimmed.length > PRODUCT_SKU_MAX) {
|
|
463
523
|
throw new HttpError(400, ERROR_CODES.VALIDATION_FAILED, 'invalid_sku');
|
|
464
524
|
}
|
|
465
|
-
const conflict = await em.findOne(Product, { sku: trimmed });
|
|
466
|
-
if (conflict && conflict.id !== product.id) {
|
|
467
|
-
throw new HttpError(400, ERROR_CODES.VALIDATION_FAILED, `sku_in_use { conflictingProductId: ${conflict.id}, conflictingSku: ${trimmed} }`);
|
|
468
|
-
}
|
|
469
525
|
// Feature 025 — SKUs share a global namespace with variants (see createVariant).
|
|
470
|
-
const
|
|
471
|
-
if (
|
|
472
|
-
throw new HttpError(400, ERROR_CODES.VALIDATION_FAILED,
|
|
526
|
+
const holder = await findSkuHolder(em, product.id, trimmed);
|
|
527
|
+
if (holder) {
|
|
528
|
+
throw new HttpError(400, ERROR_CODES.VALIDATION_FAILED, 'productId' in holder
|
|
529
|
+
? `sku_in_use { conflictingProductId: ${holder.productId}, conflictingSku: ${trimmed} }`
|
|
530
|
+
: `sku_in_use { conflictingVariantId: ${holder.variantId}, conflictingSku: ${trimmed} }`);
|
|
473
531
|
}
|
|
474
532
|
product.sku = trimmed;
|
|
475
533
|
changedFields.push('sku');
|
|
476
534
|
}
|
|
477
|
-
|
|
535
|
+
// Issue #241 — a field is changed only when its value moves: a write that
|
|
536
|
+
// restates what is stored records no audit entry and announces nothing.
|
|
537
|
+
if (req.name && req.name !== product.name) {
|
|
478
538
|
product.name = req.name;
|
|
479
539
|
changedFields.push('name');
|
|
480
540
|
}
|
|
481
|
-
if (req.description) {
|
|
541
|
+
if (req.description && req.description !== product.description) {
|
|
482
542
|
product.description = req.description;
|
|
483
543
|
changedFields.push('description');
|
|
484
544
|
}
|
|
485
|
-
if (req.stockMode !== undefined) {
|
|
545
|
+
if (req.stockMode !== undefined && req.stockMode !== (product.stockMode ?? null)) {
|
|
486
546
|
product.stockMode = req.stockMode;
|
|
487
547
|
changedFields.push('stockMode');
|
|
488
548
|
}
|
|
489
|
-
if (req.visibility) {
|
|
549
|
+
if (req.visibility && req.visibility !== product.visibility) {
|
|
490
550
|
product.visibility = req.visibility;
|
|
491
551
|
changedFields.push('visibility');
|
|
492
552
|
}
|
|
@@ -518,8 +578,12 @@ export class CatalogAdminService {
|
|
|
518
578
|
// the set; we validate the incoming patch only since the existing
|
|
519
579
|
// values were already validated at their time of write.
|
|
520
580
|
await this.assertAttributeValueKeysAllowed(em, product.attributeSetId, req.attributeValues, new Set(Object.keys(product.attributeValues ?? {})));
|
|
521
|
-
|
|
522
|
-
|
|
581
|
+
const current = product.attributeValues ?? {};
|
|
582
|
+
const patch = req.attributeValues;
|
|
583
|
+
if (Object.keys(patch).some((key) => !sameValue(current[key], patch[key]))) {
|
|
584
|
+
product.attributeValues = { ...current, ...patch };
|
|
585
|
+
changedFields.push('attributeValues');
|
|
586
|
+
}
|
|
523
587
|
}
|
|
524
588
|
// Feature 012 / FR-013 — refuse the save if any required attribute
|
|
525
589
|
// in the assigned set is left without a value. The merged map is
|
|
@@ -530,7 +594,7 @@ export class CatalogAdminService {
|
|
|
530
594
|
req.attributeSetId !== undefined)) {
|
|
531
595
|
await this.assertRequiredAttributesPresent(em, product.attributeSetId, product.attributeValues ?? {});
|
|
532
596
|
}
|
|
533
|
-
if (req.allowedOrganizationIds) {
|
|
597
|
+
if (req.allowedOrganizationIds && !sameValue(req.allowedOrganizationIds, product.allowedOrganizationIds)) {
|
|
534
598
|
product.allowedOrganizationIds = req.allowedOrganizationIds;
|
|
535
599
|
changedFields.push('allowedOrganizationIds');
|
|
536
600
|
}
|
|
@@ -546,36 +610,37 @@ export class CatalogAdminService {
|
|
|
546
610
|
}
|
|
547
611
|
}
|
|
548
612
|
// Feature 010 — per-product stock-management flags.
|
|
549
|
-
if (req.manageStock !== undefined) {
|
|
613
|
+
if (req.manageStock !== undefined && req.manageStock !== product.manageStock) {
|
|
550
614
|
product.manageStock = req.manageStock;
|
|
551
615
|
changedFields.push('manageStock');
|
|
552
616
|
}
|
|
553
|
-
if (req.backorderEnabled !== undefined) {
|
|
617
|
+
if (req.backorderEnabled !== undefined && req.backorderEnabled !== product.backorderEnabled) {
|
|
554
618
|
product.backorderEnabled = req.backorderEnabled;
|
|
555
619
|
changedFields.push('backorderEnabled');
|
|
556
620
|
}
|
|
557
|
-
if (req.lowStockThreshold !== undefined) {
|
|
621
|
+
if (req.lowStockThreshold !== undefined && req.lowStockThreshold !== (product.lowStockThreshold ?? null)) {
|
|
558
622
|
product.lowStockThreshold = req.lowStockThreshold;
|
|
559
623
|
changedFields.push('lowStockThreshold');
|
|
560
624
|
}
|
|
561
|
-
if (req.lowStockThresholdMode !== undefined) {
|
|
625
|
+
if (req.lowStockThresholdMode !== undefined && req.lowStockThresholdMode !== product.lowStockThresholdMode) {
|
|
562
626
|
product.lowStockThresholdMode = req.lowStockThresholdMode;
|
|
563
627
|
changedFields.push('lowStockThresholdMode');
|
|
564
628
|
}
|
|
565
|
-
if (req.fulfilmentStrategy !== undefined) {
|
|
629
|
+
if (req.fulfilmentStrategy !== undefined && req.fulfilmentStrategy !== (product.fulfilmentStrategy ?? null)) {
|
|
566
630
|
product.fulfilmentStrategy = req.fulfilmentStrategy;
|
|
567
631
|
changedFields.push('fulfilmentStrategy');
|
|
568
632
|
}
|
|
569
|
-
if (req.fulfilmentStrategyWarehouseOrder !== undefined
|
|
633
|
+
if (req.fulfilmentStrategyWarehouseOrder !== undefined &&
|
|
634
|
+
!sameValue(req.fulfilmentStrategyWarehouseOrder, product.fulfilmentStrategyWarehouseOrder ?? null)) {
|
|
570
635
|
product.fulfilmentStrategyWarehouseOrder = req.fulfilmentStrategyWarehouseOrder;
|
|
571
636
|
changedFields.push('fulfilmentStrategyWarehouseOrder');
|
|
572
637
|
}
|
|
573
638
|
// Feature 155 (FR-001, FR-003, D5) — the pieces minimum and the returnable flag.
|
|
574
|
-
if (req.minOrderQuantity !== undefined) {
|
|
639
|
+
if (req.minOrderQuantity !== undefined && req.minOrderQuantity !== (product.minOrderQuantity ?? null)) {
|
|
575
640
|
product.minOrderQuantity = req.minOrderQuantity;
|
|
576
641
|
changedFields.push('minOrderQuantity');
|
|
577
642
|
}
|
|
578
|
-
if (req.returnable !== undefined) {
|
|
643
|
+
if (req.returnable !== undefined && req.returnable !== product.returnable) {
|
|
579
644
|
product.returnable = req.returnable;
|
|
580
645
|
changedFields.push('returnable');
|
|
581
646
|
}
|
|
@@ -604,8 +669,8 @@ export class CatalogAdminService {
|
|
|
604
669
|
}
|
|
605
670
|
}
|
|
606
671
|
const stateAfter = {
|
|
607
|
-
name:
|
|
608
|
-
description:
|
|
672
|
+
name: product.name,
|
|
673
|
+
description: product.description,
|
|
609
674
|
stockMode: product.stockMode,
|
|
610
675
|
visibility: product.visibility,
|
|
611
676
|
status: product.status,
|
|
@@ -632,32 +697,14 @@ export class CatalogAdminService {
|
|
|
632
697
|
* in the request into a constraint violation.
|
|
633
698
|
*/
|
|
634
699
|
async #reconcileProductCategories(em, productId, categoryIds) {
|
|
635
|
-
|
|
636
|
-
const txCtx = em.getTransactionContext();
|
|
637
|
-
const currentRows = (await conn.execute(`select category_id from product_categories where product_id = ?`, [productId], 'all', txCtx));
|
|
638
|
-
const current = new Set(currentRows.map((r) => r.category_id));
|
|
639
|
-
const target = new Set(categoryIds);
|
|
640
|
-
const toAdd = [...target].filter((id) => !current.has(id));
|
|
641
|
-
const toRemove = [...current].filter((id) => !target.has(id));
|
|
642
|
-
if (toRemove.length > 0) {
|
|
643
|
-
const placeholders = toRemove.map(() => '?').join(',');
|
|
644
|
-
await conn.execute(`delete from product_categories where product_id = ? and category_id in (${placeholders})`, [productId, ...toRemove], 'run', txCtx);
|
|
645
|
-
}
|
|
646
|
-
if (toAdd.length > 0) {
|
|
647
|
-
const placeholders = toAdd.map(() => '(?,?)').join(',');
|
|
648
|
-
const params = [];
|
|
649
|
-
for (const cid of toAdd) {
|
|
650
|
-
params.push(productId, cid);
|
|
651
|
-
}
|
|
652
|
-
await conn.execute(`insert into product_categories (product_id, category_id) values ${placeholders}`, params, 'run', txCtx);
|
|
653
|
-
}
|
|
654
|
-
return toAdd.length > 0 || toRemove.length > 0;
|
|
700
|
+
return reconcileProductCategories(em, productId, categoryIds);
|
|
655
701
|
}
|
|
656
702
|
/**
|
|
657
703
|
* Duplicate an existing Product: copies the core row plus bridge tables
|
|
658
704
|
* (categories, sales-channel memberships, gallery items + labels,
|
|
659
|
-
* attachments, related/up-sell/cross-sell links, grouped
|
|
660
|
-
* bundle slots + options, variants)
|
|
705
|
+
* attachments, packaging units, related/up-sell/cross-sell links, grouped
|
|
706
|
+
* children, bundle slots + options, variants) and, since feature 174
|
|
707
|
+
* (FR-119), every scoped value at Global, Channel and Channel × language.
|
|
661
708
|
*
|
|
662
709
|
* The duplicated row gets a fresh UUID; the SKU is derived from the
|
|
663
710
|
* source by appending `-copy`, then `-copy-2`, `-copy-3`, … until a
|
|
@@ -687,13 +734,19 @@ export class CatalogAdminService {
|
|
|
687
734
|
}
|
|
688
735
|
async duplicateProduct(id) {
|
|
689
736
|
const em = this.emFactory();
|
|
737
|
+
if (!isUuidShape(id)) {
|
|
738
|
+
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
|
|
739
|
+
}
|
|
690
740
|
const source = await em.findOne(Product, { id });
|
|
691
741
|
if (!source) {
|
|
692
742
|
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
|
|
693
743
|
}
|
|
694
|
-
//
|
|
695
|
-
//
|
|
696
|
-
//
|
|
744
|
+
// Feature 174 (FR-119, T151) — the copy is ONE Command: the product row, every catalog-owned
|
|
745
|
+
// bridge and every scoped value at Global, Channel and Channel × language, empty overrides and
|
|
746
|
+
// inherit states included, commit or roll back together with the one audit entry. What other
|
|
747
|
+
// modules own runs through their own audited Commands after it (the channel memberships, the
|
|
748
|
+
// warehouse thresholds): a Command cannot nest inside another's transaction. URL keys are never
|
|
749
|
+
// copied beyond the fresh Global key, and status is reset at every scope (163 Q1-d).
|
|
697
750
|
const dupId = randomUUID();
|
|
698
751
|
const dup = await this.#auditedWrite('product.duplicate', 'product', dupId, async (cem) => {
|
|
699
752
|
// Inside the Command's transaction (Phase 16 review): the slug's URL-key lock is
|
|
@@ -707,8 +760,8 @@ export class CatalogAdminService {
|
|
|
707
760
|
type: source.type,
|
|
708
761
|
status: 'inactive',
|
|
709
762
|
archivedAt: null,
|
|
710
|
-
name: this.
|
|
711
|
-
description:
|
|
763
|
+
name: this.suffixCopyName(source.name),
|
|
764
|
+
description: source.description,
|
|
712
765
|
stockMode: source.stockMode ?? null,
|
|
713
766
|
visibility: source.visibility,
|
|
714
767
|
attributeValues: { ...source.attributeValues },
|
|
@@ -737,17 +790,37 @@ export class CatalogAdminService {
|
|
|
737
790
|
],
|
|
738
791
|
}
|
|
739
792
|
: {}),
|
|
793
|
+
// Feature 174 (FR-119) — the Global order rules and publication window.
|
|
794
|
+
minOrderQuantity: source.minOrderQuantity ?? null,
|
|
795
|
+
returnable: source.returnable,
|
|
796
|
+
publishFrom: source.publishFrom ?? null,
|
|
797
|
+
publishUntil: source.publishUntil ?? null,
|
|
740
798
|
});
|
|
741
799
|
await cem.flush();
|
|
800
|
+
const copied = await this.#copyCatalogRows(cem, source, dupId);
|
|
801
|
+
const seo = this.copySeoProductMeta
|
|
802
|
+
? await this.copySeoProductMeta(cem, { sourceProductId: source.id, targetProductId: dupId })
|
|
803
|
+
: 'not-present';
|
|
804
|
+
// Feature 172 (FR-060, research R-16) — the product's Page Builder content
|
|
805
|
+
// is copied in this transaction, atomic with the row it belongs to. The
|
|
806
|
+
// audit row counts the attributes, never the documents.
|
|
807
|
+
const copiedContent = (await cem.execute(`insert into product_content_values
|
|
808
|
+
(id, product_id, product_attribute_id, content, summary, created_at, updated_at)
|
|
809
|
+
select gen_random_uuid(), ?, product_attribute_id, content, summary, now(), now()
|
|
810
|
+
from product_content_values where product_id = ?
|
|
811
|
+
returning id`, [dupId, source.id]));
|
|
742
812
|
return {
|
|
743
813
|
result: created,
|
|
744
814
|
before: null,
|
|
745
|
-
after: {
|
|
815
|
+
after: {
|
|
816
|
+
sku: newSku,
|
|
817
|
+
slug: newSlug,
|
|
818
|
+
sourceProductId: id,
|
|
819
|
+
copied: { ...copied, seoScopes: seo === 'not-present' ? null : seo.copied },
|
|
820
|
+
contentAttributeCount: copiedContent.length,
|
|
821
|
+
},
|
|
746
822
|
};
|
|
747
823
|
});
|
|
748
|
-
// product_categories (bridge)
|
|
749
|
-
await em.execute(`insert into "product_categories" ("product_id", "category_id")
|
|
750
|
-
select ?, "category_id" from "product_categories" where "product_id" = ?`, [dup.id, source.id]);
|
|
751
824
|
// The channel assortment, through the kernel's membership service (issue
|
|
752
825
|
// #185). This was an `insert … select` against the bridge table, which is
|
|
753
826
|
// Principle XII's accessor clause and Principle XIII in one statement: the
|
|
@@ -757,46 +830,124 @@ export class CatalogAdminService {
|
|
|
757
830
|
if (this.salesChannelMembership) {
|
|
758
831
|
await this.salesChannelMembership.copyMemberships('product', source.id, dup.id);
|
|
759
832
|
}
|
|
760
|
-
//
|
|
761
|
-
//
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
values (?, ?, ?, ?, now(), now())`, [newId, dup.id, row.asset_id, row.position]);
|
|
772
|
-
}
|
|
773
|
-
const labelRows = (await em.execute(`select "gallery_item_id", "label" from "gallery_item_labels"
|
|
774
|
-
where "product_id" = ?`, [source.id]));
|
|
775
|
-
for (const lbl of labelRows) {
|
|
776
|
-
const mapped = idMap.get(lbl.gallery_item_id);
|
|
777
|
-
if (!mapped)
|
|
778
|
-
continue;
|
|
779
|
-
await em.execute(`insert into "gallery_item_labels"
|
|
780
|
-
("gallery_item_id", "product_id", "label") values (?, ?, ?)`, [mapped, dup.id, lbl.label]);
|
|
781
|
-
}
|
|
833
|
+
// Per-(product, warehouse) low-stock thresholds, so the duplicate inherits
|
|
834
|
+
// the source's alerting profile. `inventory`'s rows and `inventory`'s
|
|
835
|
+
// Command since issue #185 — this used to be an `insert … select` into that
|
|
836
|
+
// module's table from here, which kept writing while an operator had the
|
|
837
|
+
// module switched off. No `catch` around it: the wiring decides presence in
|
|
838
|
+
// front of the gate and the degrade arrives as `'not-present'`.
|
|
839
|
+
if (this.copyWarehouseThresholds) {
|
|
840
|
+
await this.copyWarehouseThresholds({
|
|
841
|
+
sourceProductId: source.id,
|
|
842
|
+
targetProductId: dup.id,
|
|
843
|
+
});
|
|
782
844
|
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
845
|
+
this.events.emit('product.created.v1', {
|
|
846
|
+
eventId: randomUUID(),
|
|
847
|
+
occurredAt: new Date().toISOString(),
|
|
848
|
+
productId: dup.id,
|
|
849
|
+
sku: dup.sku,
|
|
850
|
+
});
|
|
851
|
+
return dup;
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Feature 174 (FR-119, T151) — every catalog-owned row of `source` copied onto `targetId`, on the
|
|
855
|
+
* Command's em: the bridges (categories, gallery with its Global roles, attachments, packaging
|
|
856
|
+
* units, links, grouped children, bundle slots, variants) and every scoped value at Channel and
|
|
857
|
+
* Channel × language — value overrides (texts and attributes), channel scope rows, gallery item,
|
|
858
|
+
* gallery role, attachment and packaging-unit overrides — verbatim, so a deliberately empty
|
|
859
|
+
* override stays empty and a scope holding nothing still inherits. Child-row overrides are
|
|
860
|
+
* re-pointed through an old → new id map passed as one JSON parameter.
|
|
861
|
+
*
|
|
862
|
+
* Not copied: URL keys and redirects (unique per channel; the copy has its fresh Global key),
|
|
863
|
+
* status at Channel and Channel × language (the copy starts `inactive` everywhere, 163 Q1-d).
|
|
864
|
+
* Orphaned rows (a scope the source no longer sells on) are copied like the rest: they keep
|
|
865
|
+
* what the source keeps, and come back to life in the same way when the scope does.
|
|
866
|
+
*/
|
|
867
|
+
async #copyCatalogRows(em, source, targetId) {
|
|
868
|
+
const count = async (sql, params) => (await em.execute(sql, params)).length;
|
|
869
|
+
const idMap = async (table) => {
|
|
870
|
+
const rows = (await em.execute(`select "id" from "${table}" where "product_id" = ?`, [source.id]));
|
|
871
|
+
return Object.fromEntries(rows.map((row) => [row.id, randomUUID()]));
|
|
872
|
+
};
|
|
873
|
+
const remap = (column) => `(?::jsonb ->> o."${column}"::text)::uuid`;
|
|
874
|
+
// product_categories (bridge)
|
|
875
|
+
await em.execute(`insert into "product_categories" ("product_id", "category_id")
|
|
876
|
+
select ?, "category_id" from "product_categories" where "product_id" = ?`, [targetId, source.id]);
|
|
877
|
+
// Texts and attributes at C and C×L.
|
|
878
|
+
const valueOverrides = await count(`insert into "product_value_overrides"
|
|
879
|
+
("id", "product_id", "attribute_key", "channel_id", "language_code", "value", "created_at", "updated_at")
|
|
880
|
+
select gen_random_uuid(), ?, o."attribute_key", o."channel_id", o."language_code", o."value", now(), now()
|
|
881
|
+
from "product_value_overrides" o where o."product_id" = ?
|
|
882
|
+
returning "id"`, [targetId, source.id]);
|
|
883
|
+
// Window, audience, MOQ and returnable at C; status inherits (the copy is reviewed first).
|
|
884
|
+
const channelScopes = await count(`insert into "product_channel_scopes"
|
|
885
|
+
("product_id", "sales_channel_id", "status", "window_overridden", "publish_from", "publish_until",
|
|
886
|
+
"visibility", "allowed_organization_ids", "min_order_quantity_overridden", "min_order_quantity",
|
|
887
|
+
"returnable", "created_at", "updated_at")
|
|
888
|
+
select ?, o."sales_channel_id", null, o."window_overridden", o."publish_from", o."publish_until",
|
|
889
|
+
o."visibility", o."allowed_organization_ids", o."min_order_quantity_overridden",
|
|
890
|
+
o."min_order_quantity", o."returnable", now(), now()
|
|
891
|
+
from "product_channel_scopes" o where o."product_id" = ?
|
|
892
|
+
returning "product_id"`, [targetId, source.id]);
|
|
893
|
+
// Gallery: the items with their Global alt text and hidden flag, the Global roles, the overrides.
|
|
894
|
+
const items = await idMap('gallery_items');
|
|
895
|
+
const itemsJson = JSON.stringify(items);
|
|
896
|
+
const galleryItems = await count(`insert into "gallery_items" ("id", "product_id", "asset_id", "position", "alt_text", "hidden", "created_at", "updated_at")
|
|
897
|
+
select ${remap('id')}, ?, o."asset_id", o."position", o."alt_text", o."hidden", now(), now()
|
|
898
|
+
from "gallery_items" o where o."product_id" = ?
|
|
899
|
+
returning "id"`, [itemsJson, targetId, source.id]);
|
|
900
|
+
const galleryRoles = await count(`insert into "gallery_item_labels" ("gallery_item_id", "product_id", "label")
|
|
901
|
+
select ${remap('gallery_item_id')}, ?, o."label"
|
|
902
|
+
from "gallery_item_labels" o where o."product_id" = ?
|
|
903
|
+
returning "label"`, [itemsJson, targetId, source.id]);
|
|
904
|
+
const galleryItemOverrides = await count(`insert into "gallery_item_scope_overrides"
|
|
905
|
+
("id", "gallery_item_id", "product_id", "sales_channel_id", "language_code", "field", "value", "created_at", "updated_at")
|
|
906
|
+
select gen_random_uuid(), ${remap('gallery_item_id')}, ?, o."sales_channel_id", o."language_code", o."field", o."value", now(), now()
|
|
907
|
+
from "gallery_item_scope_overrides" o where o."product_id" = ?
|
|
908
|
+
returning "id"`, [itemsJson, targetId, source.id]);
|
|
909
|
+
// An empty role (no holder) keeps its `null`: `->>` of a null key is null.
|
|
910
|
+
const galleryRoleOverrides = await count(`insert into "gallery_role_scope_overrides"
|
|
911
|
+
("id", "product_id", "sales_channel_id", "language_code", "label", "gallery_item_id", "created_at", "updated_at")
|
|
912
|
+
select gen_random_uuid(), ?, o."sales_channel_id", o."language_code", o."label", ${remap('gallery_item_id')}, now(), now()
|
|
913
|
+
from "gallery_role_scope_overrides" o where o."product_id" = ?
|
|
914
|
+
returning "id"`, [targetId, itemsJson, source.id]);
|
|
915
|
+
// Attachments with their Global hidden flag, then their overrides.
|
|
916
|
+
const attachmentIds = JSON.stringify(await idMap('product_attachments'));
|
|
917
|
+
const attachments = await count(`insert into "product_attachments"
|
|
918
|
+
("id", "product_id", "asset_id", "attachment_type_id", "name", "description", "position", "hidden", "created_at", "updated_at")
|
|
919
|
+
select ${remap('id')}, ?, o."asset_id", o."attachment_type_id", o."name", o."description", o."position", o."hidden", now(), now()
|
|
920
|
+
from "product_attachments" o where o."product_id" = ?
|
|
921
|
+
returning "id"`, [attachmentIds, targetId, source.id]);
|
|
922
|
+
const attachmentOverrides = await count(`insert into "product_attachment_scope_overrides"
|
|
923
|
+
("id", "attachment_id", "product_id", "sales_channel_id", "language_code", "field", "value", "created_at", "updated_at")
|
|
924
|
+
select gen_random_uuid(), ${remap('attachment_id')}, ?, o."sales_channel_id", o."language_code", o."field", o."value", now(), now()
|
|
925
|
+
from "product_attachment_scope_overrides" o where o."product_id" = ?
|
|
926
|
+
returning "id"`, [attachmentIds, targetId, source.id]);
|
|
927
|
+
// Packaging units, then their name overrides.
|
|
928
|
+
const unitIds = JSON.stringify(await idMap('product_packaging_units'));
|
|
929
|
+
const packagingUnits = await count(`insert into "product_packaging_units"
|
|
930
|
+
("id", "product_id", "name", "base_quantity", "position", "is_default", "min_order_units", "created_at", "updated_at")
|
|
931
|
+
select ${remap('id')}, ?, o."name", o."base_quantity", o."position", o."is_default", o."min_order_units", now(), now()
|
|
932
|
+
from "product_packaging_units" o where o."product_id" = ?
|
|
933
|
+
returning "id"`, [unitIds, targetId, source.id]);
|
|
934
|
+
const packagingUnitOverrides = await count(`insert into "product_packaging_unit_scope_overrides"
|
|
935
|
+
("id", "packaging_unit_id", "product_id", "sales_channel_id", "language_code", "field", "value", "created_at", "updated_at")
|
|
936
|
+
select gen_random_uuid(), ${remap('packaging_unit_id')}, ?, o."sales_channel_id", o."language_code", o."field", o."value", now(), now()
|
|
937
|
+
from "product_packaging_unit_scope_overrides" o where o."product_id" = ?
|
|
938
|
+
returning "id"`, [unitIds, targetId, source.id]);
|
|
788
939
|
// product_links (only outgoing links are copied — incoming links from
|
|
789
940
|
// other products toward the source product stay attached to the source)
|
|
790
941
|
await em.execute(`insert into "product_links"
|
|
791
942
|
("id", "source_product_id", "target_product_id", "kind", "position", "created_at", "updated_at")
|
|
792
943
|
select gen_random_uuid(), ?, "target_product_id", "kind", "position", now(), now()
|
|
793
|
-
from "product_links" where "source_product_id" = ?`, [
|
|
944
|
+
from "product_links" where "source_product_id" = ?`, [targetId, source.id]);
|
|
794
945
|
// grouped_items (children of a grouped product)
|
|
795
946
|
if (source.type === 'grouped') {
|
|
796
947
|
await em.execute(`insert into "grouped_items"
|
|
797
948
|
("id", "parent_product_id", "child_product_id", "quantity", "position", "created_at", "updated_at")
|
|
798
949
|
select gen_random_uuid(), ?, "child_product_id", "quantity", "position", now(), now()
|
|
799
|
-
from "grouped_items" where "parent_product_id" = ?`, [
|
|
950
|
+
from "grouped_items" where "parent_product_id" = ?`, [targetId, source.id]);
|
|
800
951
|
}
|
|
801
952
|
// bundle_slots + bundle_slot_options
|
|
802
953
|
if (source.type === 'bundle') {
|
|
@@ -808,7 +959,7 @@ export class CatalogAdminService {
|
|
|
808
959
|
("id", "parent_product_id", "name", "min_quantity", "max_quantity", "position", "created_at", "updated_at")
|
|
809
960
|
values (?, ?, ?::jsonb, ?, ?, ?, now(), now())`, [
|
|
810
961
|
newSlotId,
|
|
811
|
-
|
|
962
|
+
targetId,
|
|
812
963
|
JSON.stringify(slot.name),
|
|
813
964
|
slot.min_quantity,
|
|
814
965
|
slot.max_quantity,
|
|
@@ -820,18 +971,6 @@ export class CatalogAdminService {
|
|
|
820
971
|
from "bundle_slot_options" where "slot_id" = ?`, [newSlotId, slot.id]);
|
|
821
972
|
}
|
|
822
973
|
}
|
|
823
|
-
// Per-(product, warehouse) low-stock thresholds, so the duplicate inherits
|
|
824
|
-
// the source's alerting profile. `inventory`'s rows and `inventory`'s
|
|
825
|
-
// Command since issue #185 — this used to be an `insert … select` into that
|
|
826
|
-
// module's table from here, which kept writing while an operator had the
|
|
827
|
-
// module switched off. No `catch` around it: the wiring decides presence in
|
|
828
|
-
// front of the gate and the degrade arrives as `'not-present'`.
|
|
829
|
-
if (this.copyWarehouseThresholds) {
|
|
830
|
-
await this.copyWarehouseThresholds({
|
|
831
|
-
sourceProductId: source.id,
|
|
832
|
-
targetProductId: dup.id,
|
|
833
|
-
});
|
|
834
|
-
}
|
|
835
974
|
// product_variants (configurable products) — each variant has its own
|
|
836
975
|
// unique SKU; we allocate copies the same way as the parent SKU.
|
|
837
976
|
if (source.type === 'configurable') {
|
|
@@ -839,7 +978,7 @@ export class CatalogAdminService {
|
|
|
839
978
|
for (const v of variants) {
|
|
840
979
|
const variantSku = await this.allocateCopySku(em, v.sku);
|
|
841
980
|
const newVariant = em.create(ProductVariant, {
|
|
842
|
-
parentProductId:
|
|
981
|
+
parentProductId: targetId,
|
|
843
982
|
sku: variantSku,
|
|
844
983
|
variantAttributeValues: { ...v.variantAttributeValues },
|
|
845
984
|
...(v.stockLevel != null ? { stockLevel: v.stockLevel } : {}),
|
|
@@ -848,13 +987,18 @@ export class CatalogAdminService {
|
|
|
848
987
|
}
|
|
849
988
|
await em.flush();
|
|
850
989
|
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
990
|
+
return {
|
|
991
|
+
valueOverrides,
|
|
992
|
+
channelScopes,
|
|
993
|
+
galleryItems,
|
|
994
|
+
galleryItemOverrides,
|
|
995
|
+
galleryRoles,
|
|
996
|
+
galleryRoleOverrides,
|
|
997
|
+
attachments,
|
|
998
|
+
attachmentOverrides,
|
|
999
|
+
packagingUnits,
|
|
1000
|
+
packagingUnitOverrides,
|
|
1001
|
+
};
|
|
858
1002
|
}
|
|
859
1003
|
/**
|
|
860
1004
|
* Find a free SKU derived from `baseSku` by appending `-copy`,
|
|
@@ -872,10 +1016,11 @@ export class CatalogAdminService {
|
|
|
872
1016
|
const suffix = i === 0 ? '-copy' : `-copy-${i + 1}`;
|
|
873
1017
|
const base = baseSku.slice(0, SKU_MAX_LENGTH - suffix.length);
|
|
874
1018
|
const candidate = `${base}${suffix}`;
|
|
875
|
-
|
|
1019
|
+
// Issue #693 — a deleted product or variant does not hold its SKU.
|
|
1020
|
+
const productHit = await em.findOne(Product, { sku: candidate, deletedAt: null });
|
|
876
1021
|
if (productHit)
|
|
877
1022
|
continue;
|
|
878
|
-
const variantHit = await em.findOne(ProductVariant, { sku: candidate });
|
|
1023
|
+
const variantHit = await em.findOne(ProductVariant, { sku: candidate, deletedAt: null });
|
|
879
1024
|
if (variantHit)
|
|
880
1025
|
continue;
|
|
881
1026
|
return candidate;
|
|
@@ -910,37 +1055,19 @@ export class CatalogAdminService {
|
|
|
910
1055
|
*/
|
|
911
1056
|
async allocateUniqueSlug(em, source) {
|
|
912
1057
|
const root = this.slugify(source);
|
|
913
|
-
const
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
}
|
|
919
|
-
if (probes.length > 0) {
|
|
920
|
-
await lockUrlKeys(em, probes);
|
|
921
|
-
for (const candidate of probes) {
|
|
922
|
-
if (await isUrlKeyFree(em, candidate))
|
|
923
|
-
return candidate;
|
|
924
|
-
}
|
|
925
|
-
}
|
|
1058
|
+
const candidates = Array.from({ length: 1000 }, (_, i) => (i === 0 ? root : this.slugify(`${root}-${i + 1}`)));
|
|
1059
|
+
// Feature 174 (T039) — the URL-key service's allocation: probe, lock in sorted order, re-check.
|
|
1060
|
+
const slug = await allocateFreeSlug(em, candidates, SLUG_CANDIDATE_LOCKS);
|
|
1061
|
+
if (slug !== null)
|
|
1062
|
+
return slug;
|
|
926
1063
|
throw new HttpError(409, ERROR_CODES.VALIDATION_FAILED, `Could not allocate a unique slug derived from "${source}".`);
|
|
927
1064
|
}
|
|
928
1065
|
/**
|
|
929
|
-
*
|
|
930
|
-
*
|
|
931
|
-
* left untouched.
|
|
1066
|
+
* Feature 174 — the copy's Global name with a "(copy)" suffix, so the duplicate is obviously a
|
|
1067
|
+
* clone in lists. Its Channel and Channel × language names are copied verbatim (FR-119).
|
|
932
1068
|
*/
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
for (const [locale, value] of Object.entries(name)) {
|
|
936
|
-
if (!value || value.trim() === '') {
|
|
937
|
-
out[locale] = value;
|
|
938
|
-
}
|
|
939
|
-
else {
|
|
940
|
-
out[locale] = `${value} (copy)`.slice(0, 255);
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
return out;
|
|
1069
|
+
suffixCopyName(name) {
|
|
1070
|
+
return name.trim() === '' ? name : `${name} (copy)`.slice(0, 255);
|
|
944
1071
|
}
|
|
945
1072
|
/**
|
|
946
1073
|
* Feature 163 (FR-019, research R30.3) — Archive one product: the `product.archive`
|
|
@@ -990,6 +1117,9 @@ export class CatalogAdminService {
|
|
|
990
1117
|
// Checkpoint C code review (C-W1) — the row lock serialises a single and a bulk
|
|
991
1118
|
// Archive of one product: the second reads the first's `archivedAt` and is the
|
|
992
1119
|
// no-op, so the transition is audited and announced once.
|
|
1120
|
+
if (!isUuidShape(id)) {
|
|
1121
|
+
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
|
|
1122
|
+
}
|
|
993
1123
|
const product = await em.findOne(Product, { id, deletedAt: null }, { lockMode: LockMode.PESSIMISTIC_WRITE });
|
|
994
1124
|
if (!product) {
|
|
995
1125
|
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
|
|
@@ -1052,6 +1182,9 @@ export class CatalogAdminService {
|
|
|
1052
1182
|
objectType: 'product',
|
|
1053
1183
|
objectId: id,
|
|
1054
1184
|
run: async ({ em }) => {
|
|
1185
|
+
if (!isUuidShape(id)) {
|
|
1186
|
+
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
|
|
1187
|
+
}
|
|
1055
1188
|
const product = await em.findOne(Product, { id, deletedAt: null });
|
|
1056
1189
|
if (!product) {
|
|
1057
1190
|
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
|
|
@@ -1060,7 +1193,7 @@ export class CatalogAdminService {
|
|
|
1060
1193
|
const stateBefore = {
|
|
1061
1194
|
status: product.status,
|
|
1062
1195
|
sku: product.sku,
|
|
1063
|
-
name:
|
|
1196
|
+
name: product.name,
|
|
1064
1197
|
deletedAt: product.deletedAt ?? null,
|
|
1065
1198
|
};
|
|
1066
1199
|
// Feature 163 (FR-072) — a deleted product's old URL keys stop redirecting.
|
|
@@ -1072,6 +1205,9 @@ export class CatalogAdminService {
|
|
|
1072
1205
|
if (urlRedirects.length > 0)
|
|
1073
1206
|
await em.nativeDelete(ProductUrlRedirect, { productId: id });
|
|
1074
1207
|
product.deletedAt = new Date();
|
|
1208
|
+
// Issue #693 — the variants are deleted with their product, at the same instant, so
|
|
1209
|
+
// their SKUs are freed with the product's: uniqueness holds among live rows only.
|
|
1210
|
+
await em.nativeUpdate(ProductVariant, { parentProductId: id, deletedAt: null }, { deletedAt: product.deletedAt });
|
|
1075
1211
|
await em.flush();
|
|
1076
1212
|
return {
|
|
1077
1213
|
result: { id: product.id, formerUrlKeys: urlRedirects.map((row) => row.key) },
|
|
@@ -1320,6 +1456,9 @@ export class CatalogAdminService {
|
|
|
1320
1456
|
}
|
|
1321
1457
|
async getProductById(id) {
|
|
1322
1458
|
const em = this.emFactory();
|
|
1459
|
+
if (!isUuidShape(id)) {
|
|
1460
|
+
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
|
|
1461
|
+
}
|
|
1323
1462
|
const product = await em.findOne(Product, { id, deletedAt: null });
|
|
1324
1463
|
if (!product) {
|
|
1325
1464
|
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
|
|
@@ -1496,6 +1635,19 @@ export class CatalogAdminService {
|
|
|
1496
1635
|
}
|
|
1497
1636
|
return view;
|
|
1498
1637
|
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Feature 172 (FR-007 – FR-009, research R-21) — what deleting the attribute
|
|
1640
|
+
* would meet, for the attributes screen's confirmation dialog. The same query
|
|
1641
|
+
* the delete Command's guard runs, so the dialog and the refusal agree.
|
|
1642
|
+
*/
|
|
1643
|
+
async getAttributeUsage(idOrKey) {
|
|
1644
|
+
const attr = await this.getAttributeByIdOrKey(idOrKey);
|
|
1645
|
+
return readAttributeUsage(this.emFactory(), {
|
|
1646
|
+
definitionId: attr.customFieldDefinitionId,
|
|
1647
|
+
extensionId: attr.id,
|
|
1648
|
+
key: attr.key,
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1499
1651
|
/**
|
|
1500
1652
|
* Feature 012 — delete an attribute. Refused while any Attribute Set or
|
|
1501
1653
|
* product still references it (FR-006). The structured error names the
|
|
@@ -1527,15 +1679,20 @@ export class CatalogAdminService {
|
|
|
1527
1679
|
}
|
|
1528
1680
|
async createVariant(parentProductId, req) {
|
|
1529
1681
|
const em = this.emFactory();
|
|
1530
|
-
|
|
1682
|
+
if (!isUuidShape(parentProductId)) {
|
|
1683
|
+
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, `Product ${parentProductId} not found.`);
|
|
1684
|
+
}
|
|
1685
|
+
// A deleted parent answers as an unknown one (#869).
|
|
1686
|
+
const parent = await em.findOne(Product, { id: parentProductId, deletedAt: null });
|
|
1531
1687
|
if (!parent) {
|
|
1532
1688
|
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, `Product ${parentProductId} not found.`);
|
|
1533
1689
|
}
|
|
1534
1690
|
if (parent.type !== 'configurable') {
|
|
1535
1691
|
throw new HttpError(400, ERROR_CODES.VALIDATION_FAILED, `Variants can only be added to configurable Products; this Product is ${parent.type}.`);
|
|
1536
1692
|
}
|
|
1537
|
-
// SKU uniqueness MUST hold across both products and variants
|
|
1538
|
-
|
|
1693
|
+
// SKU uniqueness MUST hold across both products and variants — among live
|
|
1694
|
+
// rows: a deleted product does not hold its SKU (issue #693).
|
|
1695
|
+
const existingProduct = await em.findOne(Product, { sku: req.sku, deletedAt: null });
|
|
1539
1696
|
if (existingProduct) {
|
|
1540
1697
|
throw new HttpError(409, ERROR_CODES.SKU_ALREADY_EXISTS, `SKU "${req.sku}" already taken by an existing Product.`);
|
|
1541
1698
|
}
|
|
@@ -1569,6 +1726,9 @@ export class CatalogAdminService {
|
|
|
1569
1726
|
}
|
|
1570
1727
|
async updateVariant(parentProductId, variantId, req) {
|
|
1571
1728
|
const variant = await this.#auditedWrite('product_variant.update', 'product_variant', variantId, async (em) => {
|
|
1729
|
+
if (!isUuidShape(variantId) || !isUuidShape(parentProductId)) {
|
|
1730
|
+
throw new HttpError(404, ERROR_CODES.NOT_FOUND, `Variant ${variantId} not found under Product ${parentProductId}.`);
|
|
1731
|
+
}
|
|
1572
1732
|
const v = await em.findOne(ProductVariant, { id: variantId, parentProductId });
|
|
1573
1733
|
if (!v) {
|
|
1574
1734
|
throw new HttpError(404, ERROR_CODES.NOT_FOUND, `Variant ${variantId} not found under Product ${parentProductId}.`);
|
|
@@ -1600,6 +1760,9 @@ export class CatalogAdminService {
|
|
|
1600
1760
|
}
|
|
1601
1761
|
async deleteVariant(parentProductId, variantId) {
|
|
1602
1762
|
await this.#auditedWrite('product_variant.delete', 'product_variant', variantId, async (em) => {
|
|
1763
|
+
if (!isUuidShape(variantId) || !isUuidShape(parentProductId)) {
|
|
1764
|
+
throw new HttpError(404, ERROR_CODES.NOT_FOUND, `Variant ${variantId} not found under Product ${parentProductId}.`);
|
|
1765
|
+
}
|
|
1603
1766
|
const variant = await em.findOne(ProductVariant, { id: variantId, parentProductId });
|
|
1604
1767
|
if (!variant) {
|
|
1605
1768
|
// DELETE is idempotent — but we still 404 here so admins notice
|
|
@@ -1638,6 +1801,13 @@ export class CatalogAdminService {
|
|
|
1638
1801
|
const keys = Object.keys(attributeValues);
|
|
1639
1802
|
if (keys.length === 0)
|
|
1640
1803
|
return;
|
|
1804
|
+
const views = await this.#requireAttributeRead().listAll();
|
|
1805
|
+
// Feature 172 (FR-014, research R-7) — a Page Builder content attribute's
|
|
1806
|
+
// key is refused **before** the `existingKeys` exemption below: whether it
|
|
1807
|
+
// is new to this save or resent as "already stored", its value is a
|
|
1808
|
+
// document authored on the product content screen, never an attribute
|
|
1809
|
+
// value. This is the one guard every product write crosses.
|
|
1810
|
+
assertNoContentAttributeValues(attributeValues, views);
|
|
1641
1811
|
// Feature 061 — set membership is keyed by definition id; the key lives on
|
|
1642
1812
|
// the definition, resolved through the composed view (Principle I).
|
|
1643
1813
|
//
|
|
@@ -1648,7 +1818,6 @@ export class CatalogAdminService {
|
|
|
1648
1818
|
const rows = (await em.execute(`select custom_field_definition_id
|
|
1649
1819
|
from attribute_set_attributes
|
|
1650
1820
|
where attribute_set_id = ?`, [attributeSetId]));
|
|
1651
|
-
const views = await this.#requireAttributeRead().listAll();
|
|
1652
1821
|
const keyByDefinitionId = new Map(views.map((v) => [v.customFieldDefinitionId, v.key]));
|
|
1653
1822
|
const allowed = new Set(rows
|
|
1654
1823
|
.map((r) => keyByDefinitionId.get(r.custom_field_definition_id))
|
|
@@ -1676,14 +1845,9 @@ export class CatalogAdminService {
|
|
|
1676
1845
|
where attribute_set_id = ?`, [attributeSetId]));
|
|
1677
1846
|
const views = await this.#requireAttributeRead().listAll();
|
|
1678
1847
|
const viewByDefinitionId = new Map(views.map((v) => [v.customFieldDefinitionId, v]));
|
|
1679
|
-
const missing = rows
|
|
1848
|
+
const missing = missingRequiredAttributeKeys(rows
|
|
1680
1849
|
.map((r) => viewByDefinitionId.get(r.custom_field_definition_id))
|
|
1681
|
-
.filter((v) => v !== undefined
|
|
1682
|
-
.map((v) => v.key)
|
|
1683
|
-
.filter((k) => {
|
|
1684
|
-
const v = mergedAttributeValues[k];
|
|
1685
|
-
return v === undefined || v === null || v === '';
|
|
1686
|
-
});
|
|
1850
|
+
.filter((v) => v !== undefined), mergedAttributeValues);
|
|
1687
1851
|
if (missing.length > 0) {
|
|
1688
1852
|
throw new HttpError(400, ERROR_CODES.VALIDATION_FAILED, `missing_required_attribute_values: ${missing.join(', ')}`);
|
|
1689
1853
|
}
|
|
@@ -1696,6 +1860,9 @@ export class CatalogAdminService {
|
|
|
1696
1860
|
*/
|
|
1697
1861
|
async previewAttributeSetSwap(productId, targetSetId) {
|
|
1698
1862
|
const em = this.emFactory();
|
|
1863
|
+
if (!isUuidShape(productId)) {
|
|
1864
|
+
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
|
|
1865
|
+
}
|
|
1699
1866
|
const product = await em.findOne(Product, { id: productId });
|
|
1700
1867
|
if (!product) {
|
|
1701
1868
|
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
|
|
@@ -1777,10 +1944,6 @@ export class CatalogAdminService {
|
|
|
1777
1944
|
slugify(value) {
|
|
1778
1945
|
return slugifyText(value, { maxLength: 160 });
|
|
1779
1946
|
}
|
|
1780
|
-
anyValue(blob) {
|
|
1781
|
-
const key = Object.keys(blob)[0];
|
|
1782
|
-
return key ? (blob[key] ?? '') : '';
|
|
1783
|
-
}
|
|
1784
1947
|
}
|
|
1785
1948
|
/**
|
|
1786
1949
|
* Feature 155 (FR-001, threat F5, D5) — a pieces minimum is an integer in
|