@endora-commerce/mod-catalog 0.108.0 → 0.109.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/AttachmentScopesDialog.d.ts +22 -0
- package/dist/admin/components/AttachmentScopesDialog.d.ts.map +1 -0
- package/dist/admin/components/AttachmentScopesDialog.js +70 -0
- package/dist/admin/components/AttachmentScopesDialog.js.map +1 -0
- package/dist/admin/components/PackagingUnitsEditor.d.ts +7 -1
- package/dist/admin/components/PackagingUnitsEditor.d.ts.map +1 -1
- package/dist/admin/components/PackagingUnitsEditor.js +82 -11
- package/dist/admin/components/PackagingUnitsEditor.js.map +1 -1
- package/dist/admin/components/ProductAttachmentsSection.d.ts +5 -0
- package/dist/admin/components/ProductAttachmentsSection.d.ts.map +1 -0
- package/dist/admin/components/ProductAttachmentsSection.js +137 -0
- package/dist/admin/components/ProductAttachmentsSection.js.map +1 -0
- package/dist/admin/components/ProductGallerySection.d.ts +14 -0
- package/dist/admin/components/ProductGallerySection.d.ts.map +1 -0
- package/dist/admin/components/ProductGallerySection.js +385 -0
- package/dist/admin/components/ProductGallerySection.js.map +1 -0
- package/dist/admin/components/ProductOrderRulesCard.d.ts.map +1 -1
- package/dist/admin/components/ProductOrderRulesCard.js +134 -6
- package/dist/admin/components/ProductOrderRulesCard.js.map +1 -1
- package/dist/admin/components/ProductScopeControls.d.ts +31 -0
- package/dist/admin/components/ProductScopeControls.d.ts.map +1 -0
- package/dist/admin/components/ProductScopeControls.js +243 -0
- package/dist/admin/components/ProductScopeControls.js.map +1 -0
- package/dist/admin/components/ProductScopeEditor.d.ts +12 -18
- package/dist/admin/components/ProductScopeEditor.d.ts.map +1 -1
- package/dist/admin/components/ProductScopeEditor.js +5 -4
- package/dist/admin/components/ProductScopeEditor.js.map +1 -1
- package/dist/admin/components/ProductScopeOverview.d.ts +26 -0
- package/dist/admin/components/ProductScopeOverview.d.ts.map +1 -0
- package/dist/admin/components/ProductScopeOverview.js +207 -0
- package/dist/admin/components/ProductScopeOverview.js.map +1 -0
- package/dist/admin/components/ProductStatusPills.d.ts +17 -0
- package/dist/admin/components/ProductStatusPills.d.ts.map +1 -0
- package/dist/admin/components/ProductStatusPills.js +23 -0
- package/dist/admin/components/ProductStatusPills.js.map +1 -0
- package/dist/admin/components/ProductUrlKeysPanel.d.ts +17 -0
- package/dist/admin/components/ProductUrlKeysPanel.d.ts.map +1 -0
- package/dist/admin/components/ProductUrlKeysPanel.js +215 -0
- package/dist/admin/components/ProductUrlKeysPanel.js.map +1 -0
- package/dist/admin/components/ProductsBulkEditDialog.d.ts +30 -0
- package/dist/admin/components/ProductsBulkEditDialog.d.ts.map +1 -1
- package/dist/admin/components/ProductsBulkEditDialog.js +288 -133
- package/dist/admin/components/ProductsBulkEditDialog.js.map +1 -1
- package/dist/admin/components/ScopedDialogParts.d.ts +23 -0
- package/dist/admin/components/ScopedDialogParts.d.ts.map +1 -0
- package/dist/admin/components/ScopedDialogParts.js +16 -0
- package/dist/admin/components/ScopedDialogParts.js.map +1 -0
- package/dist/admin/index.d.ts +2 -2
- package/dist/admin/index.d.ts.map +1 -1
- package/dist/admin/index.js +9 -0
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/lib/attribute-scope.d.ts +20 -0
- package/dist/admin/lib/attribute-scope.d.ts.map +1 -0
- package/dist/admin/lib/attribute-scope.js +18 -0
- package/dist/admin/lib/attribute-scope.js.map +1 -0
- package/dist/admin/lib/bulk-operation-log-text.d.ts +9 -0
- package/dist/admin/lib/bulk-operation-log-text.d.ts.map +1 -0
- package/dist/admin/lib/bulk-operation-log-text.js +13 -0
- package/dist/admin/lib/bulk-operation-log-text.js.map +1 -0
- package/dist/admin/lib/media-scopes.d.ts +41 -0
- package/dist/admin/lib/media-scopes.d.ts.map +1 -0
- package/dist/admin/lib/media-scopes.js +66 -0
- package/dist/admin/lib/media-scopes.js.map +1 -0
- package/dist/admin/lib/product-labels.d.ts +14 -0
- package/dist/admin/lib/product-labels.d.ts.map +1 -0
- package/dist/admin/lib/product-labels.js +27 -0
- package/dist/admin/lib/product-labels.js.map +1 -0
- package/dist/admin/lib/product-scope-drafts.d.ts +77 -0
- package/dist/admin/lib/product-scope-drafts.d.ts.map +1 -0
- package/dist/admin/lib/product-scope-drafts.js +133 -0
- package/dist/admin/lib/product-scope-drafts.js.map +1 -0
- package/dist/admin/lib/product-scopes-api.d.ts +40 -0
- package/dist/admin/lib/product-scopes-api.d.ts.map +1 -0
- package/dist/admin/lib/product-scopes-api.js +101 -0
- package/dist/admin/lib/product-scopes-api.js.map +1 -0
- package/dist/admin/lib/product-url-keys-api.d.ts +46 -0
- package/dist/admin/lib/product-url-keys-api.d.ts.map +1 -0
- package/dist/admin/lib/product-url-keys-api.js +110 -0
- package/dist/admin/lib/product-url-keys-api.js.map +1 -0
- package/dist/admin/lib/resolve-product-selection.d.ts +29 -1
- package/dist/admin/lib/resolve-product-selection.d.ts.map +1 -1
- package/dist/admin/lib/resolve-product-selection.js +42 -6
- package/dist/admin/lib/resolve-product-selection.js.map +1 -1
- package/dist/admin/lib/scope-overview.d.ts +74 -0
- package/dist/admin/lib/scope-overview.d.ts.map +1 -0
- package/dist/admin/lib/scope-overview.js +173 -0
- package/dist/admin/lib/scope-overview.js.map +1 -0
- package/dist/admin/pages/AttributesManager.d.ts.map +1 -1
- package/dist/admin/pages/AttributesManager.js +84 -7
- package/dist/admin/pages/AttributesManager.js.map +1 -1
- package/dist/admin/pages/BulkOperationDetailPage.d.ts.map +1 -1
- package/dist/admin/pages/BulkOperationDetailPage.js +4 -19
- package/dist/admin/pages/BulkOperationDetailPage.js.map +1 -1
- package/dist/admin/pages/ProductEditor.d.ts +0 -4
- package/dist/admin/pages/ProductEditor.d.ts.map +1 -1
- package/dist/admin/pages/ProductEditor.js +214 -346
- package/dist/admin/pages/ProductEditor.js.map +1 -1
- package/dist/admin/pages/ProductsList.d.ts +12 -0
- package/dist/admin/pages/ProductsList.d.ts.map +1 -1
- package/dist/admin/pages/ProductsList.js +105 -38
- package/dist/admin/pages/ProductsList.js.map +1 -1
- package/dist/backend/admin-search-provider.d.ts +1 -1
- package/dist/backend/admin-search-provider.d.ts.map +1 -1
- package/dist/backend/admin-search-provider.js +1 -2
- package/dist/backend/admin-search-provider.js.map +1 -1
- package/dist/backend/demo/rows.d.ts +7 -0
- package/dist/backend/demo/rows.d.ts.map +1 -1
- package/dist/backend/demo/rows.js +17 -12
- package/dist/backend/demo/rows.js.map +1 -1
- package/dist/backend/demo/seed.js +2 -2
- package/dist/backend/demo/seed.js.map +1 -1
- package/dist/backend/entities/bulk-operation.entity.d.ts +10 -0
- package/dist/backend/entities/bulk-operation.entity.d.ts.map +1 -1
- package/dist/backend/entities/bulk-operation.entity.js.map +1 -1
- package/dist/backend/entities/gallery-item-channel-hidden.entity.d.ts +14 -0
- package/dist/backend/entities/gallery-item-channel-hidden.entity.d.ts.map +1 -0
- package/dist/backend/entities/gallery-item-channel-hidden.entity.js +42 -0
- package/dist/backend/entities/gallery-item-channel-hidden.entity.js.map +1 -0
- package/dist/backend/entities/gallery-item-channel-label.entity.d.ts +18 -0
- package/dist/backend/entities/gallery-item-channel-label.entity.d.ts.map +1 -0
- package/dist/backend/entities/gallery-item-channel-label.entity.js +49 -0
- package/dist/backend/entities/gallery-item-channel-label.entity.js.map +1 -0
- package/dist/backend/entities/gallery-item.entity.d.ts +8 -1
- package/dist/backend/entities/gallery-item.entity.d.ts.map +1 -1
- package/dist/backend/entities/gallery-item.entity.js +11 -0
- package/dist/backend/entities/gallery-item.entity.js.map +1 -1
- package/dist/backend/entities/product-attachment-channel-hidden.entity.d.ts +13 -0
- package/dist/backend/entities/product-attachment-channel-hidden.entity.d.ts.map +1 -0
- package/dist/backend/entities/product-attachment-channel-hidden.entity.js +41 -0
- package/dist/backend/entities/product-attachment-channel-hidden.entity.js.map +1 -0
- package/dist/backend/entities/product-attachment.entity.d.ts +8 -1
- package/dist/backend/entities/product-attachment.entity.d.ts.map +1 -1
- package/dist/backend/entities/product-attachment.entity.js +15 -0
- package/dist/backend/entities/product-attachment.entity.js.map +1 -1
- package/dist/backend/entities/product-channel-language-scope.entity.d.ts +23 -0
- package/dist/backend/entities/product-channel-language-scope.entity.d.ts.map +1 -0
- package/dist/backend/entities/product-channel-language-scope.entity.js +61 -0
- package/dist/backend/entities/product-channel-language-scope.entity.js.map +1 -0
- package/dist/backend/entities/product-channel-scope.entity.d.ts +42 -0
- package/dist/backend/entities/product-channel-scope.entity.d.ts.map +1 -0
- package/dist/backend/entities/product-channel-scope.entity.js +104 -0
- package/dist/backend/entities/product-channel-scope.entity.js.map +1 -0
- package/dist/backend/entities/product-packaging-unit.entity.d.ts +7 -1
- package/dist/backend/entities/product-packaging-unit.entity.d.ts.map +1 -1
- package/dist/backend/entities/product-packaging-unit.entity.js +10 -0
- package/dist/backend/entities/product-packaging-unit.entity.js.map +1 -1
- package/dist/backend/entities/product-url-key.entity.d.ts +32 -0
- package/dist/backend/entities/product-url-key.entity.d.ts.map +1 -0
- package/dist/backend/entities/product-url-key.entity.js +75 -0
- package/dist/backend/entities/product-url-key.entity.js.map +1 -0
- package/dist/backend/entities/product-url-redirect.entity.d.ts +23 -0
- package/dist/backend/entities/product-url-redirect.entity.d.ts.map +1 -0
- package/dist/backend/entities/product-url-redirect.entity.js +58 -0
- package/dist/backend/entities/product-url-redirect.entity.js.map +1 -0
- package/dist/backend/entities/product.entity.d.ts +17 -2
- package/dist/backend/entities/product.entity.d.ts.map +1 -1
- package/dist/backend/entities/product.entity.js +24 -1
- package/dist/backend/entities/product.entity.js.map +1 -1
- package/dist/backend/index.d.ts +24 -2
- package/dist/backend/index.d.ts.map +1 -1
- package/dist/backend/index.js +206 -11
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/plugin.d.ts +44 -3
- package/dist/backend/plugin.d.ts.map +1 -1
- package/dist/backend/plugin.js +67 -9
- package/dist/backend/plugin.js.map +1 -1
- package/dist/backend/prompt-tools.d.ts +10 -0
- package/dist/backend/prompt-tools.d.ts.map +1 -1
- package/dist/backend/prompt-tools.js +108 -4
- package/dist/backend/prompt-tools.js.map +1 -1
- package/dist/backend/routes.admin.d.ts +29 -0
- package/dist/backend/routes.admin.d.ts.map +1 -1
- package/dist/backend/routes.admin.js +123 -54
- package/dist/backend/routes.admin.js.map +1 -1
- package/dist/backend/routes.admin.url-keys.d.ts +23 -0
- package/dist/backend/routes.admin.url-keys.d.ts.map +1 -0
- package/dist/backend/routes.admin.url-keys.js +14 -0
- package/dist/backend/routes.admin.url-keys.js.map +1 -0
- package/dist/backend/routes.api-key.d.ts.map +1 -1
- package/dist/backend/routes.api-key.js +14 -1
- package/dist/backend/routes.api-key.js.map +1 -1
- package/dist/backend/routes.external.d.ts.map +1 -1
- package/dist/backend/routes.external.js +6 -1
- package/dist/backend/routes.external.js.map +1 -1
- package/dist/backend/routes.public.d.ts +24 -7
- package/dist/backend/routes.public.d.ts.map +1 -1
- package/dist/backend/routes.public.js +55 -26
- package/dist/backend/routes.public.js.map +1 -1
- package/dist/backend/routes.public.url-keys.d.ts +26 -0
- package/dist/backend/routes.public.url-keys.d.ts.map +1 -0
- package/dist/backend/routes.public.url-keys.js +17 -0
- package/dist/backend/routes.public.url-keys.js.map +1 -0
- package/dist/backend/services/asset-references.js +43 -30
- package/dist/backend/services/asset-references.js.map +1 -1
- package/dist/backend/services/attachment-packaging-scopes.d.ts +43 -0
- package/dist/backend/services/attachment-packaging-scopes.d.ts.map +1 -0
- package/dist/backend/services/attachment-packaging-scopes.js +115 -0
- package/dist/backend/services/attachment-packaging-scopes.js.map +1 -0
- package/dist/backend/services/attachment.service.d.ts +12 -1
- package/dist/backend/services/attachment.service.d.ts.map +1 -1
- package/dist/backend/services/attachment.service.js +119 -21
- package/dist/backend/services/attachment.service.js.map +1 -1
- package/dist/backend/services/attribute-scope-preview.d.ts +38 -0
- package/dist/backend/services/attribute-scope-preview.d.ts.map +1 -0
- package/dist/backend/services/attribute-scope-preview.js +66 -0
- package/dist/backend/services/attribute-scope-preview.js.map +1 -0
- package/dist/backend/services/bulk-operation.service.d.ts +36 -0
- package/dist/backend/services/bulk-operation.service.d.ts.map +1 -1
- package/dist/backend/services/bulk-operation.service.js +203 -36
- package/dist/backend/services/bulk-operation.service.js.map +1 -1
- package/dist/backend/services/bundle.service.d.ts +9 -1
- package/dist/backend/services/bundle.service.d.ts.map +1 -1
- package/dist/backend/services/bundle.service.js +12 -2
- package/dist/backend/services/bundle.service.js.map +1 -1
- package/dist/backend/services/catalog-admin-search.service.d.ts +1 -1
- package/dist/backend/services/catalog-admin-search.service.js +1 -1
- package/dist/backend/services/catalog-admin.service.d.ts +111 -18
- package/dist/backend/services/catalog-admin.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-admin.service.js +298 -142
- package/dist/backend/services/catalog-admin.service.js.map +1 -1
- package/dist/backend/services/catalog-bulk-import.service.d.ts +24 -2
- package/dist/backend/services/catalog-bulk-import.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-bulk-import.service.js +132 -6
- package/dist/backend/services/catalog-bulk-import.service.js.map +1 -1
- package/dist/backend/services/catalog-bulk-update.service.d.ts +32 -4
- package/dist/backend/services/catalog-bulk-update.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-bulk-update.service.js +107 -11
- package/dist/backend/services/catalog-bulk-update.service.js.map +1 -1
- package/dist/backend/services/catalog-org-price-decorator.d.ts +12 -25
- package/dist/backend/services/catalog-org-price-decorator.d.ts.map +1 -1
- package/dist/backend/services/catalog-org-price-decorator.js +48 -13
- package/dist/backend/services/catalog-org-price-decorator.js.map +1 -1
- package/dist/backend/services/catalog-product-filter.service.d.ts +16 -2
- package/dist/backend/services/catalog-product-filter.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-product-filter.service.js +80 -3
- package/dist/backend/services/catalog-product-filter.service.js.map +1 -1
- package/dist/backend/services/catalog-product-read.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-product-read.service.js +5 -8
- package/dist/backend/services/catalog-product-read.service.js.map +1 -1
- package/dist/backend/services/catalog-query.service.d.ts +135 -38
- package/dist/backend/services/catalog-query.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-query.service.js +683 -354
- package/dist/backend/services/catalog-query.service.js.map +1 -1
- package/dist/backend/services/catalog-quick-search.service.d.ts +18 -2
- package/dist/backend/services/catalog-quick-search.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-quick-search.service.js +52 -20
- package/dist/backend/services/catalog-quick-search.service.js.map +1 -1
- package/dist/backend/services/catalog-write-ports.d.ts +18 -1
- package/dist/backend/services/catalog-write-ports.d.ts.map +1 -1
- package/dist/backend/services/catalog-write-ports.js +77 -0
- package/dist/backend/services/catalog-write-ports.js.map +1 -1
- package/dist/backend/services/category-admin.service.d.ts +12 -1
- package/dist/backend/services/category-admin.service.d.ts.map +1 -1
- package/dist/backend/services/category-admin.service.js +23 -2
- package/dist/backend/services/category-admin.service.js.map +1 -1
- package/dist/backend/services/channel-url-facts.d.ts +17 -0
- package/dist/backend/services/channel-url-facts.d.ts.map +1 -0
- package/dist/backend/services/channel-url-facts.js +20 -0
- package/dist/backend/services/channel-url-facts.js.map +1 -0
- package/dist/backend/services/effective-value.sql.d.ts +56 -0
- package/dist/backend/services/effective-value.sql.d.ts.map +1 -0
- package/dist/backend/services/effective-value.sql.js +111 -0
- package/dist/backend/services/effective-value.sql.js.map +1 -0
- package/dist/backend/services/gallery-scopes.d.ts +40 -0
- package/dist/backend/services/gallery-scopes.d.ts.map +1 -0
- package/dist/backend/services/gallery-scopes.js +151 -0
- package/dist/backend/services/gallery-scopes.js.map +1 -0
- package/dist/backend/services/gallery.service.d.ts +46 -4
- package/dist/backend/services/gallery.service.d.ts.map +1 -1
- package/dist/backend/services/gallery.service.js +308 -46
- package/dist/backend/services/gallery.service.js.map +1 -1
- package/dist/backend/services/linkable-asset.d.ts +21 -0
- package/dist/backend/services/linkable-asset.d.ts.map +1 -0
- package/dist/backend/services/linkable-asset.js +31 -0
- package/dist/backend/services/linkable-asset.js.map +1 -0
- package/dist/backend/services/packaging-unit.service.d.ts.map +1 -1
- package/dist/backend/services/packaging-unit.service.js +76 -45
- package/dist/backend/services/packaging-unit.service.js.map +1 -1
- package/dist/backend/services/primary-asset-url.d.ts +7 -1
- package/dist/backend/services/primary-asset-url.d.ts.map +1 -1
- package/dist/backend/services/primary-asset-url.js +45 -14
- package/dist/backend/services/primary-asset-url.js.map +1 -1
- package/dist/backend/services/product-availability.service.d.ts +79 -0
- package/dist/backend/services/product-availability.service.d.ts.map +1 -0
- package/dist/backend/services/product-availability.service.js +223 -0
- package/dist/backend/services/product-availability.service.js.map +1 -0
- package/dist/backend/services/product-availability.sql.d.ts +71 -0
- package/dist/backend/services/product-availability.sql.d.ts.map +1 -0
- package/dist/backend/services/product-availability.sql.js +77 -0
- package/dist/backend/services/product-availability.sql.js.map +1 -0
- package/dist/backend/services/product-link.service.d.ts +10 -9
- package/dist/backend/services/product-link.service.d.ts.map +1 -1
- package/dist/backend/services/product-link.service.js +32 -22
- package/dist/backend/services/product-link.service.js.map +1 -1
- package/dist/backend/services/product-overrides.service.d.ts +9 -2
- package/dist/backend/services/product-overrides.service.d.ts.map +1 -1
- package/dist/backend/services/product-overrides.service.js +13 -6
- package/dist/backend/services/product-overrides.service.js.map +1 -1
- package/dist/backend/services/product-page-revalidation.d.ts +51 -0
- package/dist/backend/services/product-page-revalidation.d.ts.map +1 -0
- package/dist/backend/services/product-page-revalidation.js +146 -0
- package/dist/backend/services/product-page-revalidation.js.map +1 -0
- package/dist/backend/services/product-scope-context.service.d.ts.map +1 -1
- package/dist/backend/services/product-scope-context.service.js +3 -2
- package/dist/backend/services/product-scope-context.service.js.map +1 -1
- package/dist/backend/services/product-scopes.service.d.ts +212 -0
- package/dist/backend/services/product-scopes.service.d.ts.map +1 -0
- package/dist/backend/services/product-scopes.service.js +638 -0
- package/dist/backend/services/product-scopes.service.js.map +1 -0
- package/dist/backend/services/product-summary-text.d.ts +8 -0
- package/dist/backend/services/product-summary-text.d.ts.map +1 -0
- package/dist/backend/services/product-summary-text.js +8 -0
- package/dist/backend/services/product-summary-text.js.map +1 -0
- package/dist/backend/services/publication-window-sweep.d.ts +77 -0
- package/dist/backend/services/publication-window-sweep.d.ts.map +1 -0
- package/dist/backend/services/publication-window-sweep.js +117 -0
- package/dist/backend/services/publication-window-sweep.js.map +1 -0
- package/dist/backend/services/scope-completeness.d.ts +107 -0
- package/dist/backend/services/scope-completeness.d.ts.map +1 -0
- package/dist/backend/services/scope-completeness.js +180 -0
- package/dist/backend/services/scope-completeness.js.map +1 -0
- package/dist/backend/services/scope-overview.service.d.ts +112 -0
- package/dist/backend/services/scope-overview.service.d.ts.map +1 -0
- package/dist/backend/services/scope-overview.service.js +372 -0
- package/dist/backend/services/scope-overview.service.js.map +1 -0
- package/dist/backend/services/sql-id-arrays.d.ts +16 -0
- package/dist/backend/services/sql-id-arrays.d.ts.map +1 -0
- package/dist/backend/services/sql-id-arrays.js +24 -0
- package/dist/backend/services/sql-id-arrays.js.map +1 -0
- package/dist/backend/services/url-key-resolution.service.d.ts +76 -0
- package/dist/backend/services/url-key-resolution.service.d.ts.map +1 -0
- package/dist/backend/services/url-key-resolution.service.js +179 -0
- package/dist/backend/services/url-key-resolution.service.js.map +1 -0
- package/dist/backend/services/url-key.service.d.ts +171 -0
- package/dist/backend/services/url-key.service.d.ts.map +1 -0
- package/dist/backend/services/url-key.service.js +738 -0
- package/dist/backend/services/url-key.service.js.map +1 -0
- package/dist/manifest.d.ts +3 -1
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +170 -10
- package/dist/manifest.js.map +1 -1
- package/dist/migrations/20261022T035133_catalog_product_scopes.d.ts +28 -0
- package/dist/migrations/20261022T035133_catalog_product_scopes.d.ts.map +1 -0
- package/dist/migrations/20261022T035133_catalog_product_scopes.js +92 -0
- package/dist/migrations/20261022T035133_catalog_product_scopes.js.map +1 -0
- package/dist/migrations/20261022T054223_catalog_product_url_keys.d.ts +32 -0
- package/dist/migrations/20261022T054223_catalog_product_url_keys.d.ts.map +1 -0
- package/dist/migrations/20261022T054223_catalog_product_url_keys.js +81 -0
- package/dist/migrations/20261022T054223_catalog_product_url_keys.js.map +1 -0
- package/dist/migrations/20261025T222634_catalog_product_status_drop_draft.d.ts +34 -0
- package/dist/migrations/20261025T222634_catalog_product_status_drop_draft.d.ts.map +1 -0
- package/dist/migrations/20261025T222634_catalog_product_status_drop_draft.js +57 -0
- package/dist/migrations/20261025T222634_catalog_product_status_drop_draft.js.map +1 -0
- package/dist/migrations/20261026T033453_catalog_product_media_scopes.d.ts +26 -0
- package/dist/migrations/20261026T033453_catalog_product_media_scopes.d.ts.map +1 -0
- package/dist/migrations/20261026T033453_catalog_product_media_scopes.js +54 -0
- package/dist/migrations/20261026T033453_catalog_product_media_scopes.js.map +1 -0
- package/dist/migrations/20261026T084533_catalog_attachment_packaging_translations.d.ts +27 -0
- package/dist/migrations/20261026T084533_catalog_attachment_packaging_translations.d.ts.map +1 -0
- package/dist/migrations/20261026T084533_catalog_attachment_packaging_translations.js +45 -0
- package/dist/migrations/20261026T084533_catalog_attachment_packaging_translations.js.map +1 -0
- package/dist/migrations/index.d.ts +6 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +11 -1
- package/dist/migrations/index.js.map +1 -1
- package/docs/catalog/attachments.md +46 -4
- package/docs/catalog/gallery-and-labels.md +63 -4
- package/docs/catalog/packaging-units.md +42 -5
- package/docs/catalog/per-channel-per-language-overrides.md +166 -8
- package/docs/catalog/url-keys-and-redirects.md +142 -0
- package/docs/catalog.md +182 -15
- package/i18n/en.json +903 -49
- package/i18n/pl.json +902 -48
- package/package.json +10 -10
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
import { randomUUID } from 'crypto';
|
|
2
|
-
import { UniqueConstraintViolationException } from '@mikro-orm/core';
|
|
2
|
+
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, } from '@endora-commerce/contracts';
|
|
6
|
+
slugify as slugifyText, uuidSchema, } 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
|
+
import { ProductUrlRedirect } from '../entities/product-url-redirect.entity.js';
|
|
11
|
+
import { isUrlKeyFree, lockUrlKeys } from './url-key.service.js';
|
|
10
12
|
import { ProductVariant } from '../entities/product-variant.entity.js';
|
|
13
|
+
import { ProductChannelScope } from '../entities/product-channel-scope.entity.js';
|
|
14
|
+
import { ProductChannelLanguageScope } from '../entities/product-channel-language-scope.entity.js';
|
|
15
|
+
import { globalScopeFields } from './product-availability.service.js';
|
|
16
|
+
import { toChannelRecord, toLanguageRecord } from './product-scopes.service.js';
|
|
11
17
|
import { assertVirtualDownloadFields, ProductTypeValidationError, } from './product-type-validations.js';
|
|
12
18
|
import { createAttributeCommand, createAttributeOptionCommand, deleteAttributeCommand, deleteAttributeOptionCommand, updateAttributeCommand, updateAttributeOptionCommand, } from '../commands/attribute-commands.js';
|
|
19
|
+
import { requireLinkableAsset } from './linkable-asset.js';
|
|
13
20
|
// Feature 061 — the API-form mapping helpers moved next to the R7 map; the
|
|
14
21
|
// re-exports keep the long-standing import site (routes, tests) stable.
|
|
15
22
|
export { dbToApiAttributeType, resolveAttributeApiType } from './attribute-type-mapping.js';
|
|
23
|
+
/**
|
|
24
|
+
* How many free-looking slug candidates `allocateUniqueSlug` locks at once (Phase 16
|
|
25
|
+
* review): enough that a concurrent writer winning one does not fail the allocation.
|
|
26
|
+
*/
|
|
27
|
+
const SLUG_CANDIDATE_LOCKS = 3;
|
|
16
28
|
/**
|
|
17
29
|
* Feature 160 (FR-043) — a product has no price of its own: a price is a row of
|
|
18
30
|
* a price book (D-287 §5.8). The old *default price* keys of `attributeValues`
|
|
@@ -34,11 +46,6 @@ export function refusePriceFields(fields, pathPrefix = '') {
|
|
|
34
46
|
* identifier, derived or otherwise.
|
|
35
47
|
*/
|
|
36
48
|
const SKU_MAX_LENGTH = 255;
|
|
37
|
-
/**
|
|
38
|
-
* Catalog write-path service (admin write surface).
|
|
39
|
-
* Every mutation emits a typed event on the shared bus so the search indexer
|
|
40
|
-
* (T067) and webhook bridge (Phase 2 T037) can react.
|
|
41
|
-
*/
|
|
42
49
|
export class CatalogAdminService {
|
|
43
50
|
emFactory;
|
|
44
51
|
events;
|
|
@@ -48,6 +55,8 @@ export class CatalogAdminService {
|
|
|
48
55
|
attributeRead;
|
|
49
56
|
customFields;
|
|
50
57
|
copyWarehouseThresholds;
|
|
58
|
+
completenessGate;
|
|
59
|
+
assets;
|
|
51
60
|
constructor(emFactory, events, auditLog,
|
|
52
61
|
/**
|
|
53
62
|
* Feature 005 / T027 — when injected, every newly-created Product
|
|
@@ -81,7 +90,21 @@ export class CatalogAdminService {
|
|
|
81
90
|
* keep constructing this service, and a duplicate with no thresholds copied
|
|
82
91
|
* is the module's declared degrade rather than a failure.
|
|
83
92
|
*/
|
|
84
|
-
copyWarehouseThresholds
|
|
93
|
+
copyWarehouseThresholds,
|
|
94
|
+
/**
|
|
95
|
+
* Feature 163 (FR-060, FR-061) — the completeness gate for an operator's change of
|
|
96
|
+
* the global status. Composed into the admin routes' instance only; it runs only
|
|
97
|
+
* when a call passes a mode ({@link ProductUpdateGate}), so the integration ports
|
|
98
|
+
* and the API-key upsert, which never do, are never gated (A-6).
|
|
99
|
+
*/
|
|
100
|
+
completenessGate,
|
|
101
|
+
/**
|
|
102
|
+
* Feature 166 (FR-006) — `assets_library`'s read port, asked before a
|
|
103
|
+
* download file is linked. Optional so fixtures without the library keep
|
|
104
|
+
* constructing the service; a create that names a file without it fails
|
|
105
|
+
* closed ({@link CatalogAdminService.#requireAssets}).
|
|
106
|
+
*/
|
|
107
|
+
assets) {
|
|
85
108
|
this.emFactory = emFactory;
|
|
86
109
|
this.events = events;
|
|
87
110
|
this.auditLog = auditLog;
|
|
@@ -90,6 +113,18 @@ export class CatalogAdminService {
|
|
|
90
113
|
this.attributeRead = attributeRead;
|
|
91
114
|
this.customFields = customFields;
|
|
92
115
|
this.copyWarehouseThresholds = copyWarehouseThresholds;
|
|
116
|
+
this.completenessGate = completenessGate;
|
|
117
|
+
this.assets = assets;
|
|
118
|
+
}
|
|
119
|
+
#requireAssets() {
|
|
120
|
+
if (!this.assets) {
|
|
121
|
+
throw new Error('CatalogAdminService: the asset read port is not wired — a download file cannot be linked.');
|
|
122
|
+
}
|
|
123
|
+
return this.assets;
|
|
124
|
+
}
|
|
125
|
+
/** The gate's mode for an operator's write, read once per request; `undefined` where no gate is composed. */
|
|
126
|
+
async completenessMode() {
|
|
127
|
+
return this.completenessGate?.mode();
|
|
93
128
|
}
|
|
94
129
|
#requireAttributeRead() {
|
|
95
130
|
if (!this.attributeRead) {
|
|
@@ -181,6 +216,10 @@ export class CatalogAdminService {
|
|
|
181
216
|
// Feature 155 (FR-001, D5) — the range and the type rule hold for every
|
|
182
217
|
// caller, not only for the ones a route schema stands in front of.
|
|
183
218
|
assertOrderMinimumAllowed(req.type, req.minOrderQuantity);
|
|
219
|
+
// Feature 166 (FR-006) — a download file the caller may not see answers
|
|
220
|
+
// as a missing one, and is never linked.
|
|
221
|
+
if (req.downloadAssetId)
|
|
222
|
+
await requireLinkableAsset(this.#requireAssets(), req.downloadAssetId);
|
|
184
223
|
// The id is allocated up front so the Command can name its audit target
|
|
185
224
|
// before the row exists (same shape as `duplicateProduct`).
|
|
186
225
|
const productId = randomUUID();
|
|
@@ -219,7 +258,8 @@ export class CatalogAdminService {
|
|
|
219
258
|
sku: req.sku,
|
|
220
259
|
slug,
|
|
221
260
|
type: req.type,
|
|
222
|
-
|
|
261
|
+
// Feature 163 (Q1-d) — a product starts switched off.
|
|
262
|
+
status: req.status ?? 'inactive',
|
|
223
263
|
name: req.name,
|
|
224
264
|
description: req.description,
|
|
225
265
|
stockMode: req.stockMode ?? null,
|
|
@@ -281,9 +321,9 @@ export class CatalogAdminService {
|
|
|
281
321
|
}),
|
|
282
322
|
};
|
|
283
323
|
}
|
|
284
|
-
async updateProduct(id, req, auditCtx) {
|
|
324
|
+
async updateProduct(id, req, auditCtx, gate) {
|
|
285
325
|
const em = this.emFactory();
|
|
286
|
-
const r = await this.#applyProductUpdate(em, id, req);
|
|
326
|
+
const r = await this.#applyProductUpdate(em, id, req, gate);
|
|
287
327
|
await em.flush();
|
|
288
328
|
if (this.auditLog && auditCtx) {
|
|
289
329
|
await this.auditLog.record({
|
|
@@ -301,44 +341,38 @@ export class CatalogAdminService {
|
|
|
301
341
|
...(auditCtx.requestId !== undefined ? { requestId: auditCtx.requestId } : {}),
|
|
302
342
|
});
|
|
303
343
|
}
|
|
304
|
-
|
|
344
|
+
// Feature 163 (FR-010) — a status write never archives, so this write has
|
|
345
|
+
// one announcement; `product.archived.v1` belongs to the Archive action.
|
|
346
|
+
this.events.emit('product.updated.v1', {
|
|
305
347
|
eventId: randomUUID(),
|
|
306
348
|
occurredAt: new Date().toISOString(),
|
|
307
349
|
productId: r.product.id,
|
|
308
350
|
changedFields: r.changedFields,
|
|
309
351
|
});
|
|
310
|
-
if (r.archived) {
|
|
311
|
-
// Two announcements of one write, in one event scope: outside a scope the
|
|
312
|
-
// bus starts each emit's subscribers at once and waits for none, so the
|
|
313
|
-
// two ran side by side and a subscriber could be handed
|
|
314
|
-
// `product.archived.v1` first. A scope dispatches in order and waits, so
|
|
315
|
-
// every subscriber sees "updated, then archived" — the order the audited
|
|
316
|
-
// path already had — and the search indexer's removal has finished
|
|
317
|
-
// before this returns, which is what keeps a reactivation that follows
|
|
318
|
-
// from being undone by a removal still on its way.
|
|
319
|
-
await this.events.run(async () => {
|
|
320
|
-
announceUpdated();
|
|
321
|
-
this.#emitArchived(r.product.id);
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
announceUpdated();
|
|
326
|
-
}
|
|
327
352
|
return r.product;
|
|
328
353
|
}
|
|
354
|
+
/** The completeness gate for `product`'s global status going to `status` (FR-060). */
|
|
355
|
+
async #gateGlobalStatus(em, product, status, mode) {
|
|
356
|
+
const gate = this.completenessGate;
|
|
357
|
+
const [channelRows, languageRows, channels] = await Promise.all([
|
|
358
|
+
em.find(ProductChannelScope, { productId: product.id }),
|
|
359
|
+
em.find(ProductChannelLanguageScope, { productId: product.id }),
|
|
360
|
+
gate.memberChannels(product.id),
|
|
361
|
+
]);
|
|
362
|
+
const before = {
|
|
363
|
+
global: globalScopeFields(product),
|
|
364
|
+
channelRows: channelRows.map(toChannelRecord),
|
|
365
|
+
languageRows: languageRows.map(toLanguageRecord),
|
|
366
|
+
};
|
|
367
|
+
const after = { ...before, global: { ...before.global, status } };
|
|
368
|
+
return gate.enforce(em, product, before, after, channels, mode);
|
|
369
|
+
}
|
|
329
370
|
/**
|
|
330
|
-
* `product.archived.v1` — the product
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
* only by `archiveProduct`, which nothing calls: archiving has been "update
|
|
336
|
-
* with `status: 'inactive'`" since feature 022, so the event the search
|
|
337
|
-
* indexer subscribes to and outbound webhooks are offered was announced by
|
|
338
|
-
* no path an operator, an importer or a PIM sync can take.
|
|
339
|
-
*
|
|
340
|
-
* Once per transition: a product that is already inactive is not archived
|
|
341
|
-
* again by a further edit, nor by a write naming the same status.
|
|
371
|
+
* `product.archived.v1` — the product was archived by the Archive action
|
|
372
|
+
* (feature 163, FR-019). Emitted by {@link archiveProduct} alone, after the
|
|
373
|
+
* write has committed and after its `product.updated.v1` `['archivedAt']`,
|
|
374
|
+
* inside the event scope that method opens. Once per transition: archiving an
|
|
375
|
+
* archived product announces nothing.
|
|
342
376
|
*/
|
|
343
377
|
#emitArchived(productId) {
|
|
344
378
|
this.events.emit('product.archived.v1', {
|
|
@@ -352,42 +386,24 @@ export class CatalogAdminService {
|
|
|
352
386
|
* Command Bus (one audit row + the event on commit, none on rollback). Falls
|
|
353
387
|
* back to the legacy `updateProduct` when no bus is injected (bus-less tests).
|
|
354
388
|
*/
|
|
355
|
-
async updateProductAudited(id, req) {
|
|
389
|
+
async updateProductAudited(id, req, gate) {
|
|
356
390
|
if (!this.commandBus)
|
|
357
|
-
return this.updateProduct(id, req);
|
|
358
|
-
|
|
359
|
-
const outcome = { archived: false };
|
|
360
|
-
// A Command declares one event, and archiving is a second announcement of
|
|
361
|
-
// the same write. The Command Bus opens its own event scope, which ends —
|
|
362
|
-
// dispatching `product.updated.v1` and waiting for its subscribers — once
|
|
363
|
-
// the write has committed; `product.archived.v1` is emitted after that,
|
|
364
|
-
// into the scope opened here, so it is dispatched second and waited for as
|
|
365
|
-
// well. Emitted outside any scope it was started and not waited for: this
|
|
366
|
-
// method returned while the search indexer's removal was still on its way,
|
|
367
|
-
// and a reactivation that followed could be undone by it.
|
|
368
|
-
return this.events.run(async () => {
|
|
369
|
-
const product = await commandBus.run(this.#updateProductCommand(id, req, outcome));
|
|
370
|
-
if (outcome.archived)
|
|
371
|
-
this.#emitArchived(product.id);
|
|
372
|
-
return product;
|
|
373
|
-
});
|
|
391
|
+
return this.updateProduct(id, req, undefined, gate);
|
|
392
|
+
return this.commandBus.run(this.#updateProductCommand(id, req, gate));
|
|
374
393
|
}
|
|
375
|
-
#updateProductCommand(id, req,
|
|
376
|
-
/** Written by `run`: whether this write moved the product to `inactive`. */
|
|
377
|
-
outcome) {
|
|
394
|
+
#updateProductCommand(id, req, gate) {
|
|
378
395
|
let changedFields = [];
|
|
379
396
|
return {
|
|
380
397
|
action: 'product.update',
|
|
381
398
|
objectType: 'product',
|
|
382
399
|
objectId: id,
|
|
383
400
|
run: async ({ em }) => {
|
|
384
|
-
const r = await this.#applyProductUpdate(em, id, req);
|
|
401
|
+
const r = await this.#applyProductUpdate(em, id, req, gate);
|
|
385
402
|
changedFields = r.changedFields;
|
|
386
|
-
outcome.archived = r.archived;
|
|
387
403
|
return {
|
|
388
404
|
result: r.product,
|
|
389
405
|
before: r.stateBefore,
|
|
390
|
-
after: { ...r.stateAfter, changedFields },
|
|
406
|
+
after: { ...r.stateAfter, changedFields, ...(gate?.apiKeyId ? { apiKeyId: gate.apiKeyId } : {}) },
|
|
391
407
|
};
|
|
392
408
|
},
|
|
393
409
|
event: (product) => ({
|
|
@@ -405,7 +421,7 @@ export class CatalogAdminService {
|
|
|
405
421
|
* Pure product-update write on the given em — no flush, no audit, no event.
|
|
406
422
|
* Shared by the legacy `updateProduct` and the audited Command path.
|
|
407
423
|
*/
|
|
408
|
-
async #applyProductUpdate(em, id, req) {
|
|
424
|
+
async #applyProductUpdate(em, id, req, gate) {
|
|
409
425
|
refusePriceFields(req.attributeValues, 'attributeValues.');
|
|
410
426
|
const product = await em.findOne(Product, { id });
|
|
411
427
|
if (!product) {
|
|
@@ -427,9 +443,11 @@ export class CatalogAdminService {
|
|
|
427
443
|
// whether or not this write touched it.
|
|
428
444
|
minOrderQuantity: product.minOrderQuantity ?? null,
|
|
429
445
|
returnable: product.returnable,
|
|
446
|
+
// Feature 163 (FR-023) — the global publication window.
|
|
447
|
+
publishFrom: product.publishFrom?.toISOString() ?? null,
|
|
448
|
+
publishUntil: product.publishUntil?.toISOString() ?? null,
|
|
430
449
|
};
|
|
431
450
|
const changedFields = [];
|
|
432
|
-
let archived = false;
|
|
433
451
|
// Feature 012 / FR-016 — SKU is mutable. Refused with 400 sku_in_use
|
|
434
452
|
// when the new SKU collides with another product. The internal UUID
|
|
435
453
|
// (product.id) is the canonical reference; snapshot tables keep the
|
|
@@ -472,17 +490,19 @@ export class CatalogAdminService {
|
|
|
472
490
|
product.visibility = req.visibility;
|
|
473
491
|
changedFields.push('visibility');
|
|
474
492
|
}
|
|
475
|
-
// Feature 022
|
|
476
|
-
//
|
|
493
|
+
// Feature 022 — status field. Feature 163 (FR-010, FR-019, O-5): a status
|
|
494
|
+
// write never sets or clears `archivedAt` — `inactive` is plain off and
|
|
495
|
+
// `active` does not restore. Archiving is the Archive / Restore action.
|
|
477
496
|
if (req.status !== undefined && req.status !== product.status) {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
497
|
+
// Feature 163 (FR-060, US6 #3) — a change of the global switch runs the
|
|
498
|
+
// completeness gate over every pair it turns on, before the row changes: in
|
|
499
|
+
// `refuse` one failing pair refuses the whole write (N3). It reads status
|
|
500
|
+
// only, so an archived product set `active` is gated too.
|
|
501
|
+
if (gate?.completeness && this.completenessGate) {
|
|
502
|
+
const warnings = await this.#gateGlobalStatus(em, product, req.status, gate.completeness);
|
|
503
|
+
gate.warnings?.push(...warnings);
|
|
485
504
|
}
|
|
505
|
+
product.status = req.status;
|
|
486
506
|
changedFields.push('status');
|
|
487
507
|
}
|
|
488
508
|
// Feature 002 (T034) — attribute_set_id swap. Persist BEFORE
|
|
@@ -559,6 +579,30 @@ export class CatalogAdminService {
|
|
|
559
579
|
product.returnable = req.returnable;
|
|
560
580
|
changedFields.push('returnable');
|
|
561
581
|
}
|
|
582
|
+
// Feature 163 (FR-023) — the global publication window, written as a pair:
|
|
583
|
+
// an omitted bound keeps its stored value, and the pair that results must
|
|
584
|
+
// start before it ends. It never touches a channel's window (FR-013).
|
|
585
|
+
if (req.publishFrom !== undefined || req.publishUntil !== undefined) {
|
|
586
|
+
const from = req.publishFrom === undefined
|
|
587
|
+
? (product.publishFrom ?? null)
|
|
588
|
+
: req.publishFrom === null
|
|
589
|
+
? null
|
|
590
|
+
: new Date(req.publishFrom);
|
|
591
|
+
const until = req.publishUntil === undefined
|
|
592
|
+
? (product.publishUntil ?? null)
|
|
593
|
+
: req.publishUntil === null
|
|
594
|
+
? null
|
|
595
|
+
: new Date(req.publishUntil);
|
|
596
|
+
if (from !== null && until !== null && from.getTime() >= until.getTime()) {
|
|
597
|
+
throw new HttpError(422, ERROR_CODES.VALIDATION_FAILED, 'The publication window must start before it ends.', { field: 'window' });
|
|
598
|
+
}
|
|
599
|
+
if ((from?.getTime() ?? null) !== (product.publishFrom?.getTime() ?? null) ||
|
|
600
|
+
(until?.getTime() ?? null) !== (product.publishUntil?.getTime() ?? null)) {
|
|
601
|
+
product.publishFrom = from;
|
|
602
|
+
product.publishUntil = until;
|
|
603
|
+
changedFields.push('publicationWindow');
|
|
604
|
+
}
|
|
605
|
+
}
|
|
562
606
|
const stateAfter = {
|
|
563
607
|
name: { ...product.name },
|
|
564
608
|
description: { ...product.description },
|
|
@@ -570,8 +614,10 @@ export class CatalogAdminService {
|
|
|
570
614
|
allowedOrganizationIds: [...product.allowedOrganizationIds],
|
|
571
615
|
minOrderQuantity: product.minOrderQuantity ?? null,
|
|
572
616
|
returnable: product.returnable,
|
|
617
|
+
publishFrom: product.publishFrom?.toISOString() ?? null,
|
|
618
|
+
publishUntil: product.publishUntil?.toISOString() ?? null,
|
|
573
619
|
};
|
|
574
|
-
return { product, stateBefore, stateAfter, changedFields
|
|
620
|
+
return { product, stateBefore, stateAfter, changedFields };
|
|
575
621
|
}
|
|
576
622
|
/**
|
|
577
623
|
* Makes `product_categories` hold exactly `categoryIds` for one product, on
|
|
@@ -615,8 +661,9 @@ export class CatalogAdminService {
|
|
|
615
661
|
*
|
|
616
662
|
* The duplicated row gets a fresh UUID; the SKU is derived from the
|
|
617
663
|
* source by appending `-copy`, then `-copy-2`, `-copy-3`, … until a
|
|
618
|
-
* free slot is found. Status is reset to `'
|
|
619
|
-
* is cleared so the operator can review before
|
|
664
|
+
* free slot is found. Status is reset to `'inactive'` and `archivedAt`
|
|
665
|
+
* is cleared (feature 163, Q1-d) so the operator can review before
|
|
666
|
+
* switching it on — also when the source is archived and `active`.
|
|
620
667
|
*
|
|
621
668
|
* Variants have their own globally-unique SKUs; each is suffixed in
|
|
622
669
|
* the same way against the variant SKU space.
|
|
@@ -630,10 +677,13 @@ export class CatalogAdminService {
|
|
|
630
677
|
if (this.commandBus) {
|
|
631
678
|
return this.commandBus.run({ action, objectType, objectId, run: ({ em }) => write(em) });
|
|
632
679
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
680
|
+
// Unaudited without a Command Bus, but still one transaction: the URL-key
|
|
681
|
+
// advisory locks a write takes (`allocateUniqueSlug`) hold only inside one.
|
|
682
|
+
return this.emFactory().transactional(async (em) => {
|
|
683
|
+
const w = await write(em);
|
|
684
|
+
await em.flush();
|
|
685
|
+
return w.result;
|
|
686
|
+
});
|
|
637
687
|
}
|
|
638
688
|
async duplicateProduct(id) {
|
|
639
689
|
const em = this.emFactory();
|
|
@@ -641,19 +691,22 @@ export class CatalogAdminService {
|
|
|
641
691
|
if (!source) {
|
|
642
692
|
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
|
|
643
693
|
}
|
|
644
|
-
const newSku = await this.allocateCopySku(em, source.sku);
|
|
645
|
-
const newSlug = await this.allocateCopySlug(em, source.slug);
|
|
646
694
|
// The dup product row + its audit are co-transactional; the bridge copies
|
|
647
695
|
// run AFTER on this em (matches the pre-054 two-step) — the dup FK target
|
|
648
696
|
// exists once committed, and a partially-copied dup is no worse than today.
|
|
649
697
|
const dupId = randomUUID();
|
|
650
698
|
const dup = await this.#auditedWrite('product.duplicate', 'product', dupId, async (cem) => {
|
|
699
|
+
// Inside the Command's transaction (Phase 16 review): the slug's URL-key lock is
|
|
700
|
+
// a transaction lock, so on a bare em it was released before the insert.
|
|
701
|
+
const newSku = await this.allocateCopySku(cem, source.sku);
|
|
702
|
+
const newSlug = await this.allocateCopySlug(cem, source.slug);
|
|
651
703
|
const created = cem.create(Product, {
|
|
652
704
|
id: dupId,
|
|
653
705
|
sku: newSku,
|
|
654
706
|
slug: newSlug,
|
|
655
707
|
type: source.type,
|
|
656
|
-
status: '
|
|
708
|
+
status: 'inactive',
|
|
709
|
+
archivedAt: null,
|
|
657
710
|
name: this.suffixCopyNames(source.name),
|
|
658
711
|
description: { ...source.description },
|
|
659
712
|
stockMode: source.stockMode ?? null,
|
|
@@ -840,14 +893,35 @@ export class CatalogAdminService {
|
|
|
840
893
|
* Feature 068 — used by the create path as well as the duplication path; a
|
|
841
894
|
* name collision on create used to reach the database and be reported as a
|
|
842
895
|
* SKU conflict.
|
|
896
|
+
*
|
|
897
|
+
* Feature 163 (A-11) — a new product's slug is its key in every language, so
|
|
898
|
+
* "free" means free as a URL key: no product's global key, and no live
|
|
899
|
+
* product's current or redirecting key in any language.
|
|
900
|
+
*
|
|
901
|
+
* Must run inside the caller's transaction (the Command's): the decisive check is
|
|
902
|
+
* made under the candidates' URL-key locks, which are transaction locks. The first
|
|
903
|
+
* {@link SLUG_CANDIDATE_LOCKS} candidates that look free without a lock are locked
|
|
904
|
+
* together, **once and in sorted order** — the order every key writer locks in, so
|
|
905
|
+
* the two cannot deadlock — and re-checked under the locks in index order; the first
|
|
906
|
+
* still free wins. A held lock is never released before the transaction ends, so
|
|
907
|
+
* locking candidates one at a time after a lost race would acquire them out of
|
|
908
|
+
* sorted order (`root-10` sorts before `root-9`). Losing every candidate of the set
|
|
909
|
+
* to concurrent writers is refused like an exhausted search.
|
|
843
910
|
*/
|
|
844
911
|
async allocateUniqueSlug(em, source) {
|
|
845
912
|
const root = this.slugify(source);
|
|
846
|
-
|
|
913
|
+
const probes = [];
|
|
914
|
+
for (let i = 0; i < 1000 && probes.length < SLUG_CANDIDATE_LOCKS; i += 1) {
|
|
847
915
|
const candidate = i === 0 ? root : this.slugify(`${root}-${i + 1}`);
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
916
|
+
if (!probes.includes(candidate) && (await isUrlKeyFree(em, candidate)))
|
|
917
|
+
probes.push(candidate);
|
|
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
|
+
}
|
|
851
925
|
}
|
|
852
926
|
throw new HttpError(409, ERROR_CODES.VALIDATION_FAILED, `Could not allocate a unique slug derived from "${source}".`);
|
|
853
927
|
}
|
|
@@ -869,12 +943,84 @@ export class CatalogAdminService {
|
|
|
869
943
|
return out;
|
|
870
944
|
}
|
|
871
945
|
/**
|
|
872
|
-
*
|
|
873
|
-
*
|
|
874
|
-
* `product.
|
|
946
|
+
* Feature 163 (FR-019, research R30.3) — Archive one product: the `product.archive`
|
|
947
|
+
* Command sets `archivedAt` and touches no status at any scope, and no
|
|
948
|
+
* completeness gate runs. Announces `product.updated.v1` `['archivedAt']`, then
|
|
949
|
+
* `product.archived.v1`, both after commit and in that order (one event scope,
|
|
950
|
+
* dispatched in order and waited for — the search indexer's removal has finished
|
|
951
|
+
* before this returns). Archiving an archived product is a no-op: no audit row,
|
|
952
|
+
* no event, `changed: false`.
|
|
953
|
+
*
|
|
954
|
+
* 404 `PRODUCT_NOT_FOUND` for an unknown, soft-deleted or non-UUID id.
|
|
875
955
|
*/
|
|
876
|
-
async archiveProduct(id
|
|
877
|
-
|
|
956
|
+
async archiveProduct(id) {
|
|
957
|
+
return this.#setArchived(id, true);
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* Feature 163 (FR-019) — Restore one product: the `product.restore` Command clears
|
|
961
|
+
* `archivedAt`, announces `product.updated.v1` `['archivedAt']`, and leaves the
|
|
962
|
+
* status where it is (an `inactive` product stays off). No-op on a product that is
|
|
963
|
+
* not archived.
|
|
964
|
+
*/
|
|
965
|
+
async restoreProduct(id) {
|
|
966
|
+
return this.#setArchived(id, false);
|
|
967
|
+
}
|
|
968
|
+
async #setArchived(id, archive) {
|
|
969
|
+
// A non-UUID id would reach PostgreSQL as an invalid `uuid` literal.
|
|
970
|
+
if (!uuidSchema.safeParse(id).success) {
|
|
971
|
+
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
|
|
972
|
+
}
|
|
973
|
+
const outcome = { changed: false };
|
|
974
|
+
// The Command declares `product.updated.v1`; the Command Bus dispatches it
|
|
975
|
+
// when its own scope ends, after commit. `product.archived.v1` is emitted
|
|
976
|
+
// after that, into the scope opened here, so it is dispatched second.
|
|
977
|
+
return this.events.run(async () => {
|
|
978
|
+
const product = await this.#runCommand(this.#archiveCommand(id, archive, outcome));
|
|
979
|
+
if (outcome.changed && archive)
|
|
980
|
+
this.#emitArchived(product.id);
|
|
981
|
+
return { product, changed: outcome.changed };
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
#archiveCommand(id, archive, outcome) {
|
|
985
|
+
return {
|
|
986
|
+
action: archive ? 'product.archive' : 'product.restore',
|
|
987
|
+
objectType: 'product',
|
|
988
|
+
objectId: id,
|
|
989
|
+
run: async ({ em }) => {
|
|
990
|
+
// Checkpoint C code review (C-W1) — the row lock serialises a single and a bulk
|
|
991
|
+
// Archive of one product: the second reads the first's `archivedAt` and is the
|
|
992
|
+
// no-op, so the transition is audited and announced once.
|
|
993
|
+
const product = await em.findOne(Product, { id, deletedAt: null }, { lockMode: LockMode.PESSIMISTIC_WRITE });
|
|
994
|
+
if (!product) {
|
|
995
|
+
throw new HttpError(404, ERROR_CODES.PRODUCT_NOT_FOUND, 'Product not found.');
|
|
996
|
+
}
|
|
997
|
+
const before = product.archivedAt ?? null;
|
|
998
|
+
if ((before !== null) === archive) {
|
|
999
|
+
outcome.changed = false;
|
|
1000
|
+
return { result: product, skipAudit: true };
|
|
1001
|
+
}
|
|
1002
|
+
product.archivedAt = archive ? new Date() : null;
|
|
1003
|
+
em.persist(product);
|
|
1004
|
+
await em.flush();
|
|
1005
|
+
outcome.changed = true;
|
|
1006
|
+
return {
|
|
1007
|
+
result: product,
|
|
1008
|
+
before: { archivedAt: before?.toISOString() ?? null },
|
|
1009
|
+
after: { archivedAt: product.archivedAt?.toISOString() ?? null },
|
|
1010
|
+
};
|
|
1011
|
+
},
|
|
1012
|
+
event: (product) => outcome.changed
|
|
1013
|
+
? {
|
|
1014
|
+
eventName: 'product.updated.v1',
|
|
1015
|
+
payload: {
|
|
1016
|
+
eventId: randomUUID(),
|
|
1017
|
+
occurredAt: new Date().toISOString(),
|
|
1018
|
+
productId: product.id,
|
|
1019
|
+
changedFields: ['archivedAt'],
|
|
1020
|
+
},
|
|
1021
|
+
}
|
|
1022
|
+
: undefined,
|
|
1023
|
+
};
|
|
878
1024
|
}
|
|
879
1025
|
async assertProductDeletable(em, productId) {
|
|
880
1026
|
// `em.execute`, not `em.getKnex()`: the caller is `product.delete`'s Command
|
|
@@ -917,11 +1063,19 @@ export class CatalogAdminService {
|
|
|
917
1063
|
name: { ...product.name },
|
|
918
1064
|
deletedAt: product.deletedAt ?? null,
|
|
919
1065
|
};
|
|
1066
|
+
// Feature 163 (FR-072) — a deleted product's old URL keys stop redirecting.
|
|
1067
|
+
const urlRedirects = (await em.find(ProductUrlRedirect, { productId: id })).map((row) => ({
|
|
1068
|
+
id: row.id,
|
|
1069
|
+
languageCode: row.languageCode ?? null,
|
|
1070
|
+
key: row.key,
|
|
1071
|
+
}));
|
|
1072
|
+
if (urlRedirects.length > 0)
|
|
1073
|
+
await em.nativeDelete(ProductUrlRedirect, { productId: id });
|
|
920
1074
|
product.deletedAt = new Date();
|
|
921
1075
|
await em.flush();
|
|
922
1076
|
return {
|
|
923
|
-
result: { id: product.id },
|
|
924
|
-
before: stateBefore,
|
|
1077
|
+
result: { id: product.id, formerUrlKeys: urlRedirects.map((row) => row.key) },
|
|
1078
|
+
before: { ...stateBefore, urlRedirects },
|
|
925
1079
|
after: {
|
|
926
1080
|
...stateBefore,
|
|
927
1081
|
deletedAt: product.deletedAt?.toISOString() ?? null,
|
|
@@ -934,6 +1088,7 @@ export class CatalogAdminService {
|
|
|
934
1088
|
eventId: randomUUID(),
|
|
935
1089
|
occurredAt: new Date().toISOString(),
|
|
936
1090
|
productId: result.id,
|
|
1091
|
+
formerUrlKeys: result.formerUrlKeys,
|
|
937
1092
|
},
|
|
938
1093
|
}),
|
|
939
1094
|
};
|
|
@@ -1004,16 +1159,16 @@ export class CatalogAdminService {
|
|
|
1004
1159
|
const em = this.emFactory();
|
|
1005
1160
|
const page = Math.max(0, options.page ?? 0);
|
|
1006
1161
|
const pageSize = Math.min(Math.max(1, options.pageSize ?? 20), 500);
|
|
1007
|
-
|
|
1008
|
-
//
|
|
1009
|
-
//
|
|
1162
|
+
const archivedMode = options.archived ?? 'exclude';
|
|
1163
|
+
// Feature 163 (R30.4) — the status and the archived mode are two independent
|
|
1164
|
+
// filters: `status` reads the status column, `archived` reads `archived_at`.
|
|
1010
1165
|
const where = { deletedAt: null };
|
|
1011
|
-
if (options.status)
|
|
1166
|
+
if (options.status)
|
|
1012
1167
|
where['status'] = options.status;
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1168
|
+
if (archivedMode === 'exclude')
|
|
1169
|
+
where['archivedAt'] = null;
|
|
1170
|
+
else if (archivedMode === 'only')
|
|
1171
|
+
where['archivedAt'] = { $ne: null };
|
|
1017
1172
|
if (options.type) {
|
|
1018
1173
|
where['type'] = options.type;
|
|
1019
1174
|
}
|
|
@@ -1021,23 +1176,7 @@ export class CatalogAdminService {
|
|
|
1021
1176
|
? await this.productIdsInCategoryTree(em, options.categorySlug.trim())
|
|
1022
1177
|
: null;
|
|
1023
1178
|
if (categoryProductIds && categoryProductIds.size === 0) {
|
|
1024
|
-
|
|
1025
|
-
// connection, so the status badges would be counted from outside a
|
|
1026
|
-
// transaction the caller holds open while `em.find` above answers from
|
|
1027
|
-
// inside it — one screen, two views of `products` (issue #207).
|
|
1028
|
-
const countRowsEmpty = (await em.execute(`select status, count(*) as count from products where deleted_at is null group by status`));
|
|
1029
|
-
const countsEmpty = { all: 0, active: 0, draft: 0, inactive: 0 };
|
|
1030
|
-
for (const row of countRowsEmpty) {
|
|
1031
|
-
const n = Number(row.count) || 0;
|
|
1032
|
-
countsEmpty.all += n;
|
|
1033
|
-
if (row.status === 'active')
|
|
1034
|
-
countsEmpty.active = n;
|
|
1035
|
-
else if (row.status === 'draft')
|
|
1036
|
-
countsEmpty.draft = n;
|
|
1037
|
-
else if (row.status === 'inactive')
|
|
1038
|
-
countsEmpty.inactive = n;
|
|
1039
|
-
}
|
|
1040
|
-
return { items: [], page, pageSize, total: 0, counts: countsEmpty };
|
|
1179
|
+
return { items: [], page, pageSize, total: 0, counts: await this.#productListCounts(em) };
|
|
1041
1180
|
}
|
|
1042
1181
|
if (categoryProductIds) {
|
|
1043
1182
|
where['id'] = { $in: [...categoryProductIds] };
|
|
@@ -1052,8 +1191,10 @@ export class CatalogAdminService {
|
|
|
1052
1191
|
qb.whereNull('deleted_at');
|
|
1053
1192
|
if (options.status)
|
|
1054
1193
|
qb.where('status', options.status);
|
|
1055
|
-
|
|
1056
|
-
qb.
|
|
1194
|
+
if (archivedMode === 'exclude')
|
|
1195
|
+
qb.whereNull('archived_at');
|
|
1196
|
+
else if (archivedMode === 'only')
|
|
1197
|
+
qb.whereNotNull('archived_at');
|
|
1057
1198
|
if (options.type)
|
|
1058
1199
|
qb.where('type', options.type);
|
|
1059
1200
|
if (categoryProductIds)
|
|
@@ -1098,24 +1239,37 @@ export class CatalogAdminService {
|
|
|
1098
1239
|
limit: pageSize,
|
|
1099
1240
|
});
|
|
1100
1241
|
}
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1242
|
+
return { items, page, pageSize, total, counts: await this.#productListCounts(em) };
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* The admin list's tab badges, across the *full* product set whatever tab is
|
|
1246
|
+
* active, so they stay honest (feature 163, R30.4): `all`, `active` and
|
|
1247
|
+
* `inactive` over non-archived, non-deleted rows; `archived` over archived,
|
|
1248
|
+
* non-deleted rows of either status.
|
|
1249
|
+
*
|
|
1250
|
+
* `em.execute`, not `em.getKnex()`: a knex handle takes its own pooled
|
|
1251
|
+
* connection, so the badges would be counted from outside a transaction the
|
|
1252
|
+
* caller holds open while the page above answers from inside it — one screen,
|
|
1253
|
+
* two views of `products` (issue #207).
|
|
1254
|
+
*/
|
|
1255
|
+
async #productListCounts(em) {
|
|
1256
|
+
const rows = (await em.execute(`select status, (archived_at is not null) as archived, count(*) as count
|
|
1257
|
+
from products where deleted_at is null
|
|
1258
|
+
group by status, (archived_at is not null)`));
|
|
1259
|
+
const counts = { all: 0, active: 0, inactive: 0, archived: 0 };
|
|
1260
|
+
for (const row of rows) {
|
|
1109
1261
|
const n = Number(row.count) || 0;
|
|
1262
|
+
if (row.archived) {
|
|
1263
|
+
counts.archived += n;
|
|
1264
|
+
continue;
|
|
1265
|
+
}
|
|
1110
1266
|
counts.all += n;
|
|
1111
1267
|
if (row.status === 'active')
|
|
1112
|
-
counts.active
|
|
1113
|
-
else if (row.status === 'draft')
|
|
1114
|
-
counts.draft = n;
|
|
1268
|
+
counts.active += n;
|
|
1115
1269
|
else if (row.status === 'inactive')
|
|
1116
|
-
counts.inactive
|
|
1270
|
+
counts.inactive += n;
|
|
1117
1271
|
}
|
|
1118
|
-
return
|
|
1272
|
+
return counts;
|
|
1119
1273
|
}
|
|
1120
1274
|
/**
|
|
1121
1275
|
* Feature 033 — return all product ids matching list filters (no pagination).
|
|
@@ -1126,16 +1280,18 @@ export class CatalogAdminService {
|
|
|
1126
1280
|
const em = this.emFactory();
|
|
1127
1281
|
const trimmedQ = options.q?.trim();
|
|
1128
1282
|
const knex = em.getKnex();
|
|
1283
|
+
const archivedMode = options.archived ?? 'exclude';
|
|
1129
1284
|
const applyListFilters = (qb) => {
|
|
1130
|
-
// Mirror listProducts: soft-deleted rows are never selectable
|
|
1131
|
-
//
|
|
1285
|
+
// Mirror listProducts: soft-deleted rows are never selectable; the status
|
|
1286
|
+
// and the archived mode are independent filters (feature 163, R30.4).
|
|
1132
1287
|
qb.whereNull('deleted_at');
|
|
1133
1288
|
if (options.status) {
|
|
1134
1289
|
qb.where('status', options.status);
|
|
1135
1290
|
}
|
|
1136
|
-
|
|
1137
|
-
qb.
|
|
1138
|
-
|
|
1291
|
+
if (archivedMode === 'exclude')
|
|
1292
|
+
qb.whereNull('archived_at');
|
|
1293
|
+
else if (archivedMode === 'only')
|
|
1294
|
+
qb.whereNotNull('archived_at');
|
|
1139
1295
|
if (options.type) {
|
|
1140
1296
|
qb.where('type', options.type);
|
|
1141
1297
|
}
|