@open-mercato/core 0.9.1-develop.7473.1.de5b22888f → 0.9.1-develop.7475.1.28ca93ed97
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/.turbo/turbo-build.log +2 -2
- package/dist/generated/entities/catalog_price_history_entry/index.js +53 -0
- package/dist/generated/entities/catalog_price_history_entry/index.js.map +7 -0
- package/dist/generated/entities/customer_group_terms/index.js +2 -0
- package/dist/generated/entities/customer_group_terms/index.js.map +2 -2
- package/dist/generated/entities/ecommerce_store/index.js +33 -0
- package/dist/generated/entities/ecommerce_store/index.js.map +7 -0
- package/dist/generated/entities/ecommerce_store_channel_binding/index.js +29 -0
- package/dist/generated/entities/ecommerce_store_channel_binding/index.js.map +7 -0
- package/dist/generated/entities/ecommerce_store_domain_binding/index.js +23 -0
- package/dist/generated/entities/ecommerce_store_domain_binding/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +8 -1
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +72 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/helpers/integration/customerGroupsFixtures.js.map +2 -2
- package/dist/modules/catalog/acl.js +8 -1
- package/dist/modules/catalog/acl.js.map +2 -2
- package/dist/modules/catalog/api/config/omnibus/route.js +184 -0
- package/dist/modules/catalog/api/config/omnibus/route.js.map +7 -0
- package/dist/modules/catalog/api/prices/history/route.js +131 -0
- package/dist/modules/catalog/api/prices/history/route.js.map +7 -0
- package/dist/modules/catalog/api/prices/omnibus-preview/route.js +184 -0
- package/dist/modules/catalog/api/prices/omnibus-preview/route.js.map +7 -0
- package/dist/modules/catalog/api/products/route.js +54 -245
- package/dist/modules/catalog/api/products/route.js.map +3 -3
- package/dist/modules/catalog/api/tags/route.js +6 -0
- package/dist/modules/catalog/api/tags/route.js.map +2 -2
- package/dist/modules/catalog/backend/config/catalog/page.js +3 -1
- package/dist/modules/catalog/backend/config/catalog/page.js.map +2 -2
- package/dist/modules/catalog/cli.js +80 -2
- package/dist/modules/catalog/cli.js.map +2 -2
- package/dist/modules/catalog/commands/categories.js +51 -2
- package/dist/modules/catalog/commands/categories.js.map +2 -2
- package/dist/modules/catalog/commands/prices.js +43 -1
- package/dist/modules/catalog/commands/prices.js.map +2 -2
- package/dist/modules/catalog/commands/products.js +71 -0
- package/dist/modules/catalog/commands/products.js.map +2 -2
- package/dist/modules/catalog/commands/variants.js +7 -0
- package/dist/modules/catalog/commands/variants.js.map +2 -2
- package/dist/modules/catalog/components/OmnibusSettings.js +703 -0
- package/dist/modules/catalog/components/OmnibusSettings.js.map +7 -0
- package/dist/modules/catalog/components/PriceEditorOmnibusRow.js +152 -0
- package/dist/modules/catalog/components/PriceEditorOmnibusRow.js.map +7 -0
- package/dist/modules/catalog/components/lookupSources.js +31 -0
- package/dist/modules/catalog/components/lookupSources.js.map +7 -0
- package/dist/modules/catalog/components/prices/PriceScopeSelectors.js +8 -2
- package/dist/modules/catalog/components/prices/PriceScopeSelectors.js.map +2 -2
- package/dist/modules/catalog/components/products/VariantBuilder.js +11 -1
- package/dist/modules/catalog/components/products/VariantBuilder.js.map +2 -2
- package/dist/modules/catalog/data/entities.js +122 -1
- package/dist/modules/catalog/data/entities.js.map +2 -2
- package/dist/modules/catalog/data/validators.js +78 -0
- package/dist/modules/catalog/data/validators.js.map +2 -2
- package/dist/modules/catalog/di.js +18 -0
- package/dist/modules/catalog/di.js.map +2 -2
- package/dist/modules/catalog/lib/omnibus.js +285 -0
- package/dist/modules/catalog/lib/omnibus.js.map +7 -0
- package/dist/modules/catalog/lib/omnibusBackfill.js +146 -0
- package/dist/modules/catalog/lib/omnibusBackfill.js.map +7 -0
- package/dist/modules/catalog/lib/omnibusCache.js +89 -0
- package/dist/modules/catalog/lib/omnibusCache.js.map +7 -0
- package/dist/modules/catalog/lib/omnibusConfig.js +64 -0
- package/dist/modules/catalog/lib/omnibusConfig.js.map +7 -0
- package/dist/modules/catalog/lib/omnibusHistoryQueries.js +191 -0
- package/dist/modules/catalog/lib/omnibusHistoryQueries.js.map +7 -0
- package/dist/modules/catalog/lib/omnibusPresentedEntry.js +73 -0
- package/dist/modules/catalog/lib/omnibusPresentedEntry.js.map +7 -0
- package/dist/modules/catalog/lib/omnibusProductListEnrichment.js +94 -0
- package/dist/modules/catalog/lib/omnibusProductListEnrichment.js.map +7 -0
- package/dist/modules/catalog/lib/omnibusTypes.js +115 -0
- package/dist/modules/catalog/lib/omnibusTypes.js.map +7 -0
- package/dist/modules/catalog/lib/optionSchemaTranslations.js +55 -0
- package/dist/modules/catalog/lib/optionSchemaTranslations.js.map +7 -0
- package/dist/modules/catalog/lib/priceHistoryQuery.js +103 -0
- package/dist/modules/catalog/lib/priceHistoryQuery.js.map +7 -0
- package/dist/modules/catalog/lib/pricing.js +26 -2
- package/dist/modules/catalog/lib/pricing.js.map +2 -2
- package/dist/modules/catalog/lib/productFilters.js +273 -0
- package/dist/modules/catalog/lib/productFilters.js.map +7 -0
- package/dist/modules/catalog/lib/productScopeKeys.js +105 -0
- package/dist/modules/catalog/lib/productScopeKeys.js.map +7 -0
- package/dist/modules/catalog/lib/productScopeReindex.js +73 -0
- package/dist/modules/catalog/lib/productScopeReindex.js.map +7 -0
- package/dist/modules/catalog/migrations/Migration20261005105352_catalog.js +39 -0
- package/dist/modules/catalog/migrations/Migration20261005105352_catalog.js.map +7 -0
- package/dist/modules/catalog/migrations/Migration20261005150824_catalog.js +39 -0
- package/dist/modules/catalog/migrations/Migration20261005150824_catalog.js.map +7 -0
- package/dist/modules/catalog/services/catalogOmnibusService.js +480 -0
- package/dist/modules/catalog/services/catalogOmnibusService.js.map +7 -0
- package/dist/modules/catalog/setup.js +3 -1
- package/dist/modules/catalog/setup.js.map +2 -2
- package/dist/modules/catalog/subscribers/product-scope-keys-category-deleted.js +16 -0
- package/dist/modules/catalog/subscribers/product-scope-keys-category-deleted.js.map +7 -0
- package/dist/modules/catalog/subscribers/product-scope-keys-category-updated.js +17 -0
- package/dist/modules/catalog/subscribers/product-scope-keys-category-updated.js.map +7 -0
- package/dist/modules/catalog/translations.js +10 -0
- package/dist/modules/catalog/translations.js.map +2 -2
- package/dist/modules/configs/lib/upgrade-actions.js +28 -0
- package/dist/modules/configs/lib/upgrade-actions.js.map +2 -2
- package/dist/modules/customer_groups/api/customer-groups/[id]/terms/route.js +5 -0
- package/dist/modules/customer_groups/api/customer-groups/[id]/terms/route.js.map +2 -2
- package/dist/modules/customer_groups/components/CustomerGroupTermsSection.js +111 -3
- package/dist/modules/customer_groups/components/CustomerGroupTermsSection.js.map +2 -2
- package/dist/modules/customer_groups/components/customerGroupAssortmentScope.js +43 -0
- package/dist/modules/customer_groups/components/customerGroupAssortmentScope.js.map +7 -0
- package/dist/modules/customer_groups/data/entities.js +3 -0
- package/dist/modules/customer_groups/data/entities.js.map +2 -2
- package/dist/modules/customer_groups/data/validators.js +9 -0
- package/dist/modules/customer_groups/data/validators.js.map +2 -2
- package/dist/modules/customer_groups/migrations/Migration20261005110250_customer_groups.js +17 -0
- package/dist/modules/customer_groups/migrations/Migration20261005110250_customer_groups.js.map +7 -0
- package/dist/modules/customer_groups/services/customerGroupsService.js +62 -15
- package/dist/modules/customer_groups/services/customerGroupsService.js.map +2 -2
- package/dist/modules/ecommerce/acl.js +13 -0
- package/dist/modules/ecommerce/acl.js.map +7 -0
- package/dist/modules/ecommerce/api/domain-mappings/route.js +72 -0
- package/dist/modules/ecommerce/api/domain-mappings/route.js.map +7 -0
- package/dist/modules/ecommerce/api/openapi.js +27 -0
- package/dist/modules/ecommerce/api/openapi.js.map +7 -0
- package/dist/modules/ecommerce/api/store-channel-bindings/[id]/assortment-count/route.js +109 -0
- package/dist/modules/ecommerce/api/store-channel-bindings/[id]/assortment-count/route.js.map +7 -0
- package/dist/modules/ecommerce/api/store-channel-bindings/crud.js +265 -0
- package/dist/modules/ecommerce/api/store-channel-bindings/crud.js.map +7 -0
- package/dist/modules/ecommerce/api/store-channel-bindings/route.js +67 -0
- package/dist/modules/ecommerce/api/store-channel-bindings/route.js.map +7 -0
- package/dist/modules/ecommerce/api/store-domain-bindings/crud.js +296 -0
- package/dist/modules/ecommerce/api/store-domain-bindings/crud.js.map +7 -0
- package/dist/modules/ecommerce/api/store-domain-bindings/route.js +73 -0
- package/dist/modules/ecommerce/api/store-domain-bindings/route.js.map +7 -0
- package/dist/modules/ecommerce/api/storefront/categories/[slug]/route.js +87 -0
- package/dist/modules/ecommerce/api/storefront/categories/[slug]/route.js.map +7 -0
- package/dist/modules/ecommerce/api/storefront/categories/openapiSchemas.js +50 -0
- package/dist/modules/ecommerce/api/storefront/categories/openapiSchemas.js.map +7 -0
- package/dist/modules/ecommerce/api/storefront/categories/route.js +75 -0
- package/dist/modules/ecommerce/api/storefront/categories/route.js.map +7 -0
- package/dist/modules/ecommerce/api/storefront/context/route.js +163 -0
- package/dist/modules/ecommerce/api/storefront/context/route.js.map +7 -0
- package/dist/modules/ecommerce/api/storefront/products/[idOrHandle]/route.js +87 -0
- package/dist/modules/ecommerce/api/storefront/products/[idOrHandle]/route.js.map +7 -0
- package/dist/modules/ecommerce/api/storefront/products/openapiSchemas.js +177 -0
- package/dist/modules/ecommerce/api/storefront/products/openapiSchemas.js.map +7 -0
- package/dist/modules/ecommerce/api/storefront/products/route.js +78 -0
- package/dist/modules/ecommerce/api/storefront/products/route.js.map +7 -0
- package/dist/modules/ecommerce/api/storefront/search/suggest/openapiSchemas.js +25 -0
- package/dist/modules/ecommerce/api/storefront/search/suggest/openapiSchemas.js.map +7 -0
- package/dist/modules/ecommerce/api/storefront/search/suggest/route.js +75 -0
- package/dist/modules/ecommerce/api/storefront/search/suggest/route.js.map +7 -0
- package/dist/modules/ecommerce/api/storefront/storefrontRouteSupport.js +58 -0
- package/dist/modules/ecommerce/api/storefront/storefrontRouteSupport.js.map +7 -0
- package/dist/modules/ecommerce/api/stores/[id]/branding/route.js +183 -0
- package/dist/modules/ecommerce/api/stores/[id]/branding/route.js.map +7 -0
- package/dist/modules/ecommerce/api/stores/[id]/preview-branding/route.js +92 -0
- package/dist/modules/ecommerce/api/stores/[id]/preview-branding/route.js.map +7 -0
- package/dist/modules/ecommerce/api/stores/crud.js +401 -0
- package/dist/modules/ecommerce/api/stores/crud.js.map +7 -0
- package/dist/modules/ecommerce/api/stores/route.js +64 -0
- package/dist/modules/ecommerce/api/stores/route.js.map +7 -0
- package/dist/modules/ecommerce/backend/config/ecommerce/[id]/page.js +9 -0
- package/dist/modules/ecommerce/backend/config/ecommerce/[id]/page.js.map +7 -0
- package/dist/modules/ecommerce/backend/config/ecommerce/[id]/page.meta.js +16 -0
- package/dist/modules/ecommerce/backend/config/ecommerce/[id]/page.meta.js.map +7 -0
- package/dist/modules/ecommerce/backend/config/ecommerce/page.js +9 -0
- package/dist/modules/ecommerce/backend/config/ecommerce/page.js.map +7 -0
- package/dist/modules/ecommerce/backend/config/ecommerce/page.meta.js +16 -0
- package/dist/modules/ecommerce/backend/config/ecommerce/page.meta.js.map +7 -0
- package/dist/modules/ecommerce/commands/stores.js +110 -0
- package/dist/modules/ecommerce/commands/stores.js.map +7 -0
- package/dist/modules/ecommerce/components/ChannelAssortmentCount.js +90 -0
- package/dist/modules/ecommerce/components/ChannelAssortmentCount.js.map +7 -0
- package/dist/modules/ecommerce/components/ChannelBindingFormSections.js +33 -0
- package/dist/modules/ecommerce/components/ChannelBindingFormSections.js.map +7 -0
- package/dist/modules/ecommerce/components/ChannelLookupPicker.js +11 -0
- package/dist/modules/ecommerce/components/ChannelLookupPicker.js.map +7 -0
- package/dist/modules/ecommerce/components/DomainStatusWarning.js +24 -0
- package/dist/modules/ecommerce/components/DomainStatusWarning.js.map +7 -0
- package/dist/modules/ecommerce/components/StoreAvailabilityDefaultsSection.js +190 -0
- package/dist/modules/ecommerce/components/StoreAvailabilityDefaultsSection.js.map +7 -0
- package/dist/modules/ecommerce/components/StoreBrandingControls.js +67 -0
- package/dist/modules/ecommerce/components/StoreBrandingControls.js.map +7 -0
- package/dist/modules/ecommerce/components/StoreBrandingPreview.js +69 -0
- package/dist/modules/ecommerce/components/StoreBrandingPreview.js.map +7 -0
- package/dist/modules/ecommerce/components/StoreBrandingTab.js +218 -0
- package/dist/modules/ecommerce/components/StoreBrandingTab.js.map +7 -0
- package/dist/modules/ecommerce/components/StoreChannelBindingDialog.js +270 -0
- package/dist/modules/ecommerce/components/StoreChannelBindingDialog.js.map +7 -0
- package/dist/modules/ecommerce/components/StoreChannelsTab.js +313 -0
- package/dist/modules/ecommerce/components/StoreChannelsTab.js.map +7 -0
- package/dist/modules/ecommerce/components/StoreCreateDialog.js +164 -0
- package/dist/modules/ecommerce/components/StoreCreateDialog.js.map +7 -0
- package/dist/modules/ecommerce/components/StoreDomainBindingDialog.js +162 -0
- package/dist/modules/ecommerce/components/StoreDomainBindingDialog.js.map +7 -0
- package/dist/modules/ecommerce/components/StoreDomainsTab.js +357 -0
- package/dist/modules/ecommerce/components/StoreDomainsTab.js.map +7 -0
- package/dist/modules/ecommerce/components/StoreEditPage.js +155 -0
- package/dist/modules/ecommerce/components/StoreEditPage.js.map +7 -0
- package/dist/modules/ecommerce/components/StoreGeneralTab.js +167 -0
- package/dist/modules/ecommerce/components/StoreGeneralTab.js.map +7 -0
- package/dist/modules/ecommerce/components/StoreListPage.js +290 -0
- package/dist/modules/ecommerce/components/StoreListPage.js.map +7 -0
- package/dist/modules/ecommerce/components/StoreSeoTab.js +132 -0
- package/dist/modules/ecommerce/components/StoreSeoTab.js.map +7 -0
- package/dist/modules/ecommerce/components/StoreStatusBadge.js +20 -0
- package/dist/modules/ecommerce/components/StoreStatusBadge.js.map +7 -0
- package/dist/modules/ecommerce/components/channelLookups.js +28 -0
- package/dist/modules/ecommerce/components/channelLookups.js.map +7 -0
- package/dist/modules/ecommerce/components/storeAdmin.js +41 -0
- package/dist/modules/ecommerce/components/storeAdmin.js.map +7 -0
- package/dist/modules/ecommerce/components/storeBrandingForm.js +197 -0
- package/dist/modules/ecommerce/components/storeBrandingForm.js.map +7 -0
- package/dist/modules/ecommerce/components/storeChannels.js +140 -0
- package/dist/modules/ecommerce/components/storeChannels.js.map +7 -0
- package/dist/modules/ecommerce/components/storeDomains.js +167 -0
- package/dist/modules/ecommerce/components/storeDomains.js.map +7 -0
- package/dist/modules/ecommerce/components/storeEditTabs.js +62 -0
- package/dist/modules/ecommerce/components/storeEditTabs.js.map +7 -0
- package/dist/modules/ecommerce/components/storeGeneral.js +95 -0
- package/dist/modules/ecommerce/components/storeGeneral.js.map +7 -0
- package/dist/modules/ecommerce/components/storeSeo.js +69 -0
- package/dist/modules/ecommerce/components/storeSeo.js.map +7 -0
- package/dist/modules/ecommerce/components/useChannelAssortmentCount.js +45 -0
- package/dist/modules/ecommerce/components/useChannelAssortmentCount.js.map +7 -0
- package/dist/modules/ecommerce/components/useStoreAccess.js +28 -0
- package/dist/modules/ecommerce/components/useStoreAccess.js.map +7 -0
- package/dist/modules/ecommerce/data/enrichers.js +157 -0
- package/dist/modules/ecommerce/data/enrichers.js.map +7 -0
- package/dist/modules/ecommerce/data/entities.js +197 -0
- package/dist/modules/ecommerce/data/entities.js.map +7 -0
- package/dist/modules/ecommerce/data/validators.js +406 -0
- package/dist/modules/ecommerce/data/validators.js.map +7 -0
- package/dist/modules/ecommerce/di.js +11 -0
- package/dist/modules/ecommerce/di.js.map +7 -0
- package/dist/modules/ecommerce/events.js +27 -0
- package/dist/modules/ecommerce/events.js.map +7 -0
- package/dist/modules/ecommerce/index.js +16 -0
- package/dist/modules/ecommerce/index.js.map +7 -0
- package/dist/modules/ecommerce/lib/assortmentCount.js +112 -0
- package/dist/modules/ecommerce/lib/assortmentCount.js.map +7 -0
- package/dist/modules/ecommerce/lib/brandingStyles.js +184 -0
- package/dist/modules/ecommerce/lib/brandingStyles.js.map +7 -0
- package/dist/modules/ecommerce/lib/buyerContext.js +284 -0
- package/dist/modules/ecommerce/lib/buyerContext.js.map +7 -0
- package/dist/modules/ecommerce/lib/cacheInvalidation.js +186 -0
- package/dist/modules/ecommerce/lib/cacheInvalidation.js.map +7 -0
- package/dist/modules/ecommerce/lib/cacheKeys.js +236 -0
- package/dist/modules/ecommerce/lib/cacheKeys.js.map +7 -0
- package/dist/modules/ecommerce/lib/createConflictRecheck.js +29 -0
- package/dist/modules/ecommerce/lib/createConflictRecheck.js.map +7 -0
- package/dist/modules/ecommerce/lib/crudEvents.js +94 -0
- package/dist/modules/ecommerce/lib/crudEvents.js.map +7 -0
- package/dist/modules/ecommerce/lib/crudSupport.js +64 -0
- package/dist/modules/ecommerce/lib/crudSupport.js.map +7 -0
- package/dist/modules/ecommerce/lib/domainBindingRebind.js +99 -0
- package/dist/modules/ecommerce/lib/domainBindingRebind.js.map +7 -0
- package/dist/modules/ecommerce/lib/domainMappingSummaries.js +39 -0
- package/dist/modules/ecommerce/lib/domainMappingSummaries.js.map +7 -0
- package/dist/modules/ecommerce/lib/exclusiveFlag.js +57 -0
- package/dist/modules/ecommerce/lib/exclusiveFlag.js.map +7 -0
- package/dist/modules/ecommerce/lib/references.js +70 -0
- package/dist/modules/ecommerce/lib/references.js.map +7 -0
- package/dist/modules/ecommerce/lib/seedDraftStore.js +99 -0
- package/dist/modules/ecommerce/lib/seedDraftStore.js.map +7 -0
- package/dist/modules/ecommerce/lib/storeBindingCascade.js +109 -0
- package/dist/modules/ecommerce/lib/storeBindingCascade.js.map +7 -0
- package/dist/modules/ecommerce/lib/storeBranding.js +40 -0
- package/dist/modules/ecommerce/lib/storeBranding.js.map +7 -0
- package/dist/modules/ecommerce/lib/storeBrandingRoute.js +76 -0
- package/dist/modules/ecommerce/lib/storeBrandingRoute.js.map +7 -0
- package/dist/modules/ecommerce/lib/storeContext.js +393 -0
- package/dist/modules/ecommerce/lib/storeContext.js.map +7 -0
- package/dist/modules/ecommerce/lib/storeContextService.js +43 -0
- package/dist/modules/ecommerce/lib/storeContextService.js.map +7 -0
- package/dist/modules/ecommerce/lib/storeLocale.js +60 -0
- package/dist/modules/ecommerce/lib/storeLocale.js.map +7 -0
- package/dist/modules/ecommerce/lib/storeNotifications.js +41 -0
- package/dist/modules/ecommerce/lib/storeNotifications.js.map +7 -0
- package/dist/modules/ecommerce/lib/storefrontCatalogSupport.js +248 -0
- package/dist/modules/ecommerce/lib/storefrontCatalogSupport.js.map +7 -0
- package/dist/modules/ecommerce/lib/storefrontCategories.js +241 -0
- package/dist/modules/ecommerce/lib/storefrontCategories.js.map +7 -0
- package/dist/modules/ecommerce/lib/storefrontCategoryCache.js +71 -0
- package/dist/modules/ecommerce/lib/storefrontCategoryCache.js.map +7 -0
- package/dist/modules/ecommerce/lib/storefrontDetail.js +447 -0
- package/dist/modules/ecommerce/lib/storefrontDetail.js.map +7 -0
- package/dist/modules/ecommerce/lib/storefrontFacets.js +441 -0
- package/dist/modules/ecommerce/lib/storefrontFacets.js.map +7 -0
- package/dist/modules/ecommerce/lib/storefrontOptionFilter.js +15 -0
- package/dist/modules/ecommerce/lib/storefrontOptionFilter.js.map +7 -0
- package/dist/modules/ecommerce/lib/storefrontPricing.js +393 -0
- package/dist/modules/ecommerce/lib/storefrontPricing.js.map +7 -0
- package/dist/modules/ecommerce/lib/storefrontProductCache.js +90 -0
- package/dist/modules/ecommerce/lib/storefrontProductCache.js.map +7 -0
- package/dist/modules/ecommerce/lib/storefrontProductScope.js +107 -0
- package/dist/modules/ecommerce/lib/storefrontProductScope.js.map +7 -0
- package/dist/modules/ecommerce/lib/storefrontProducts.js +670 -0
- package/dist/modules/ecommerce/lib/storefrontProducts.js.map +7 -0
- package/dist/modules/ecommerce/lib/storefrontQuery.js +156 -0
- package/dist/modules/ecommerce/lib/storefrontQuery.js.map +7 -0
- package/dist/modules/ecommerce/lib/storefrontRateLimit.js +99 -0
- package/dist/modules/ecommerce/lib/storefrontRateLimit.js.map +7 -0
- package/dist/modules/ecommerce/lib/storefrontSearch.js +303 -0
- package/dist/modules/ecommerce/lib/storefrontSearch.js.map +7 -0
- package/dist/modules/ecommerce/lib/storefrontSearchCache.js +35 -0
- package/dist/modules/ecommerce/lib/storefrontSearchCache.js.map +7 -0
- package/dist/modules/ecommerce/lib/subscriberSupport.js +33 -0
- package/dist/modules/ecommerce/lib/subscriberSupport.js.map +7 -0
- package/dist/modules/ecommerce/lib/types.js +1 -0
- package/dist/modules/ecommerce/lib/types.js.map +7 -0
- package/dist/modules/ecommerce/migrations/Migration20261005113233_ecommerce.js +32 -0
- package/dist/modules/ecommerce/migrations/Migration20261005113233_ecommerce.js.map +7 -0
- package/dist/modules/ecommerce/migrations/Migration20261006112733_ecommerce.js +17 -0
- package/dist/modules/ecommerce/migrations/Migration20261006112733_ecommerce.js.map +7 -0
- package/dist/modules/ecommerce/notifications.client.js +47 -0
- package/dist/modules/ecommerce/notifications.client.js.map +7 -0
- package/dist/modules/ecommerce/notifications.js +48 -0
- package/dist/modules/ecommerce/notifications.js.map +7 -0
- package/dist/modules/ecommerce/search.js +83 -0
- package/dist/modules/ecommerce/search.js.map +7 -0
- package/dist/modules/ecommerce/setup.js +17 -0
- package/dist/modules/ecommerce/setup.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/assortment-empty-notifications.js +14 -0
- package/dist/modules/ecommerce/subscribers/assortment-empty-notifications.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/availability-policy-cache-invalidation.js +14 -0
- package/dist/modules/ecommerce/subscribers/availability-policy-cache-invalidation.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/catalog-category-cache-invalidation.js +14 -0
- package/dist/modules/ecommerce/subscribers/catalog-category-cache-invalidation.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/catalog-price-cache-invalidation.js +14 -0
- package/dist/modules/ecommerce/subscribers/catalog-price-cache-invalidation.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/catalog-product-cache-invalidation.js +14 -0
- package/dist/modules/ecommerce/subscribers/catalog-product-cache-invalidation.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/catalog-variant-cache-invalidation.js +14 -0
- package/dist/modules/ecommerce/subscribers/catalog-variant-cache-invalidation.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/customer-group-cache-invalidation.js +14 -0
- package/dist/modules/ecommerce/subscribers/customer-group-cache-invalidation.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/customer-group-membership-cache-invalidation.js +14 -0
- package/dist/modules/ecommerce/subscribers/customer-group-membership-cache-invalidation.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/customer-group-terms-cache-invalidation.js +14 -0
- package/dist/modules/ecommerce/subscribers/customer-group-terms-cache-invalidation.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/customer-user-deleted-cache-invalidation.js +14 -0
- package/dist/modules/ecommerce/subscribers/customer-user-deleted-cache-invalidation.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/customer-user-updated-cache-invalidation.js +14 -0
- package/dist/modules/ecommerce/subscribers/customer-user-updated-cache-invalidation.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/domain-binding-rebind.js +16 -0
- package/dist/modules/ecommerce/subscribers/domain-binding-rebind.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/domain-mapping-cache-invalidation.js +14 -0
- package/dist/modules/ecommerce/subscribers/domain-mapping-cache-invalidation.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/store-cache-invalidation.js +14 -0
- package/dist/modules/ecommerce/subscribers/store-cache-invalidation.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/store-channel-binding-cache-invalidation.js +14 -0
- package/dist/modules/ecommerce/subscribers/store-channel-binding-cache-invalidation.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/store-domain-binding-cache-invalidation.js +14 -0
- package/dist/modules/ecommerce/subscribers/store-domain-binding-cache-invalidation.js.map +7 -0
- package/dist/modules/ecommerce/subscribers/store-notifications.js +14 -0
- package/dist/modules/ecommerce/subscribers/store-notifications.js.map +7 -0
- package/dist/modules/query_index/lib/batch.js +23 -9
- package/dist/modules/query_index/lib/batch.js.map +2 -2
- package/dist/modules/query_index/lib/doc-enrichers.js +212 -0
- package/dist/modules/query_index/lib/doc-enrichers.js.map +7 -0
- package/dist/modules/query_index/lib/document.js +2 -0
- package/dist/modules/query_index/lib/document.js.map +2 -2
- package/dist/modules/query_index/lib/engine.js +68 -1
- package/dist/modules/query_index/lib/engine.js.map +2 -2
- package/dist/modules/query_index/lib/indexer.js +7 -0
- package/dist/modules/query_index/lib/indexer.js.map +2 -2
- package/dist/modules/query_index/lib/search-tokens.js +2 -0
- package/dist/modules/query_index/lib/search-tokens.js.map +2 -2
- package/dist/modules/query_index/migrations/Migration20261005201500_query_index.js +17 -0
- package/dist/modules/query_index/migrations/Migration20261005201500_query_index.js.map +7 -0
- package/dist/modules/translations/components/TranslationManager.js +3 -3
- package/dist/modules/translations/components/TranslationManager.js.map +2 -2
- package/dist/modules/translations/data/validators.js +1 -1
- package/dist/modules/translations/data/validators.js.map +1 -1
- package/dist/modules/translations/lib/batch.js +21 -1
- package/dist/modules/translations/lib/batch.js.map +2 -2
- package/dist/modules/translations/lib/helpers.js +3 -0
- package/dist/modules/translations/lib/helpers.js.map +2 -2
- package/dist/modules/translations/lib/resolve-field-list.js +14 -2
- package/dist/modules/translations/lib/resolve-field-list.js.map +2 -2
- package/generated/entities/catalog_price_history_entry/index.ts +25 -0
- package/generated/entities/customer_group_terms/index.ts +1 -0
- package/generated/entities/ecommerce_store/index.ts +15 -0
- package/generated/entities/ecommerce_store_channel_binding/index.ts +13 -0
- package/generated/entities/ecommerce_store_domain_binding/index.ts +10 -0
- package/generated/entities.ids.generated.ts +8 -1
- package/generated/entity-fields-registry.ts +72 -0
- package/package.json +7 -7
- package/src/helpers/integration/customerGroupsFixtures.ts +2 -0
- package/src/modules/auth/i18n/de.json +8 -0
- package/src/modules/auth/i18n/en.json +8 -0
- package/src/modules/auth/i18n/es.json +8 -0
- package/src/modules/auth/i18n/ko.json +8 -0
- package/src/modules/auth/i18n/pl.json +8 -0
- package/src/modules/catalog/AGENTS.md +5 -2
- package/src/modules/catalog/acl.ts +7 -0
- package/src/modules/catalog/api/config/omnibus/route.ts +204 -0
- package/src/modules/catalog/api/prices/history/route.ts +139 -0
- package/src/modules/catalog/api/prices/omnibus-preview/route.ts +202 -0
- package/src/modules/catalog/api/products/route.ts +53 -308
- package/src/modules/catalog/api/tags/route.ts +6 -0
- package/src/modules/catalog/backend/config/catalog/page.tsx +2 -0
- package/src/modules/catalog/cli.ts +84 -1
- package/src/modules/catalog/commands/categories.ts +54 -2
- package/src/modules/catalog/commands/prices.ts +43 -1
- package/src/modules/catalog/commands/products.ts +84 -1
- package/src/modules/catalog/commands/variants.ts +7 -0
- package/src/modules/catalog/components/OmnibusSettings.tsx +832 -0
- package/src/modules/catalog/components/PriceEditorOmnibusRow.tsx +219 -0
- package/src/modules/catalog/components/lookupSources.ts +29 -0
- package/src/modules/catalog/components/prices/PriceScopeSelectors.tsx +9 -0
- package/src/modules/catalog/components/products/VariantBuilder.tsx +9 -0
- package/src/modules/catalog/data/entities.ts +123 -1
- package/src/modules/catalog/data/validators.ts +118 -0
- package/src/modules/catalog/di.ts +23 -0
- package/src/modules/catalog/i18n/de.json +77 -0
- package/src/modules/catalog/i18n/en.json +77 -0
- package/src/modules/catalog/i18n/es.json +77 -0
- package/src/modules/catalog/i18n/ko.json +77 -0
- package/src/modules/catalog/i18n/pl.json +77 -0
- package/src/modules/catalog/lib/omnibus.ts +406 -0
- package/src/modules/catalog/lib/omnibusBackfill.ts +198 -0
- package/src/modules/catalog/lib/omnibusCache.ts +111 -0
- package/src/modules/catalog/lib/omnibusConfig.ts +73 -0
- package/src/modules/catalog/lib/omnibusHistoryQueries.ts +248 -0
- package/src/modules/catalog/lib/omnibusPresentedEntry.ts +76 -0
- package/src/modules/catalog/lib/omnibusProductListEnrichment.ts +125 -0
- package/src/modules/catalog/lib/omnibusTypes.ts +202 -0
- package/src/modules/catalog/lib/optionSchemaTranslations.ts +55 -0
- package/src/modules/catalog/lib/priceHistoryQuery.ts +155 -0
- package/src/modules/catalog/lib/pricing.ts +42 -4
- package/src/modules/catalog/lib/productFilters.ts +349 -0
- package/src/modules/catalog/lib/productScopeKeys.ts +162 -0
- package/src/modules/catalog/lib/productScopeReindex.ts +139 -0
- package/src/modules/catalog/migrations/.snapshot-open-mercato.json +572 -0
- package/src/modules/catalog/migrations/Migration20261005105352_catalog.ts +39 -0
- package/src/modules/catalog/migrations/Migration20261005150824_catalog.ts +39 -0
- package/src/modules/catalog/services/catalogOmnibusService.ts +642 -0
- package/src/modules/catalog/setup.ts +2 -0
- package/src/modules/catalog/subscribers/product-scope-keys-category-deleted.ts +18 -0
- package/src/modules/catalog/subscribers/product-scope-keys-category-updated.ts +19 -0
- package/src/modules/catalog/translations.ts +12 -0
- package/src/modules/configs/i18n/de.json +5 -1
- package/src/modules/configs/i18n/en.json +5 -1
- package/src/modules/configs/i18n/es.json +5 -1
- package/src/modules/configs/i18n/ko.json +5 -1
- package/src/modules/configs/i18n/pl.json +5 -1
- package/src/modules/configs/lib/upgrade-actions.ts +35 -0
- package/src/modules/customer_groups/api/customer-groups/[id]/terms/route.ts +7 -0
- package/src/modules/customer_groups/components/CustomerGroupTermsSection.tsx +124 -2
- package/src/modules/customer_groups/components/customerGroupAssortmentScope.ts +46 -0
- package/src/modules/customer_groups/data/entities.ts +4 -0
- package/src/modules/customer_groups/data/validators.ts +14 -0
- package/src/modules/customer_groups/i18n/de.json +12 -0
- package/src/modules/customer_groups/i18n/en.json +12 -0
- package/src/modules/customer_groups/i18n/es.json +12 -0
- package/src/modules/customer_groups/i18n/ko.json +12 -0
- package/src/modules/customer_groups/i18n/pl.json +12 -0
- package/src/modules/customer_groups/migrations/.snapshot-open-mercato.json +17 -0
- package/src/modules/customer_groups/migrations/Migration20261005110250_customer_groups.ts +15 -0
- package/src/modules/customer_groups/services/customerGroupsService.ts +74 -23
- package/src/modules/ecommerce/acl.ts +9 -0
- package/src/modules/ecommerce/api/domain-mappings/route.ts +76 -0
- package/src/modules/ecommerce/api/openapi.ts +28 -0
- package/src/modules/ecommerce/api/store-channel-bindings/[id]/assortment-count/route.ts +141 -0
- package/src/modules/ecommerce/api/store-channel-bindings/crud.ts +283 -0
- package/src/modules/ecommerce/api/store-channel-bindings/route.ts +67 -0
- package/src/modules/ecommerce/api/store-domain-bindings/crud.ts +324 -0
- package/src/modules/ecommerce/api/store-domain-bindings/route.ts +73 -0
- package/src/modules/ecommerce/api/storefront/categories/[slug]/route.ts +94 -0
- package/src/modules/ecommerce/api/storefront/categories/openapiSchemas.ts +63 -0
- package/src/modules/ecommerce/api/storefront/categories/route.ts +78 -0
- package/src/modules/ecommerce/api/storefront/context/route.ts +203 -0
- package/src/modules/ecommerce/api/storefront/products/[idOrHandle]/route.ts +94 -0
- package/src/modules/ecommerce/api/storefront/products/openapiSchemas.ts +193 -0
- package/src/modules/ecommerce/api/storefront/products/route.ts +81 -0
- package/src/modules/ecommerce/api/storefront/search/suggest/openapiSchemas.ts +25 -0
- package/src/modules/ecommerce/api/storefront/search/suggest/route.ts +78 -0
- package/src/modules/ecommerce/api/storefront/storefrontRouteSupport.ts +68 -0
- package/src/modules/ecommerce/api/stores/[id]/branding/route.ts +205 -0
- package/src/modules/ecommerce/api/stores/[id]/preview-branding/route.ts +99 -0
- package/src/modules/ecommerce/api/stores/crud.ts +457 -0
- package/src/modules/ecommerce/api/stores/route.ts +66 -0
- package/src/modules/ecommerce/backend/config/ecommerce/[id]/page.meta.ts +12 -0
- package/src/modules/ecommerce/backend/config/ecommerce/[id]/page.tsx +5 -0
- package/src/modules/ecommerce/backend/config/ecommerce/page.meta.ts +12 -0
- package/src/modules/ecommerce/backend/config/ecommerce/page.tsx +5 -0
- package/src/modules/ecommerce/commands/stores.ts +154 -0
- package/src/modules/ecommerce/components/ChannelAssortmentCount.tsx +138 -0
- package/src/modules/ecommerce/components/ChannelBindingFormSections.tsx +40 -0
- package/src/modules/ecommerce/components/ChannelLookupPicker.tsx +5 -0
- package/src/modules/ecommerce/components/DomainStatusWarning.tsx +32 -0
- package/src/modules/ecommerce/components/StoreAvailabilityDefaultsSection.tsx +219 -0
- package/src/modules/ecommerce/components/StoreBrandingControls.tsx +73 -0
- package/src/modules/ecommerce/components/StoreBrandingPreview.tsx +77 -0
- package/src/modules/ecommerce/components/StoreBrandingTab.tsx +242 -0
- package/src/modules/ecommerce/components/StoreChannelBindingDialog.tsx +306 -0
- package/src/modules/ecommerce/components/StoreChannelsTab.tsx +375 -0
- package/src/modules/ecommerce/components/StoreCreateDialog.tsx +204 -0
- package/src/modules/ecommerce/components/StoreDomainBindingDialog.tsx +198 -0
- package/src/modules/ecommerce/components/StoreDomainsTab.tsx +426 -0
- package/src/modules/ecommerce/components/StoreEditPage.tsx +193 -0
- package/src/modules/ecommerce/components/StoreGeneralTab.tsx +189 -0
- package/src/modules/ecommerce/components/StoreListPage.tsx +326 -0
- package/src/modules/ecommerce/components/StoreSeoTab.tsx +152 -0
- package/src/modules/ecommerce/components/StoreStatusBadge.tsx +22 -0
- package/src/modules/ecommerce/components/channelLookups.ts +24 -0
- package/src/modules/ecommerce/components/storeAdmin.ts +56 -0
- package/src/modules/ecommerce/components/storeBrandingForm.ts +230 -0
- package/src/modules/ecommerce/components/storeChannels.ts +210 -0
- package/src/modules/ecommerce/components/storeDomains.ts +221 -0
- package/src/modules/ecommerce/components/storeEditTabs.tsx +76 -0
- package/src/modules/ecommerce/components/storeGeneral.ts +155 -0
- package/src/modules/ecommerce/components/storeSeo.ts +78 -0
- package/src/modules/ecommerce/components/useChannelAssortmentCount.ts +67 -0
- package/src/modules/ecommerce/components/useStoreAccess.ts +36 -0
- package/src/modules/ecommerce/data/enrichers.ts +213 -0
- package/src/modules/ecommerce/data/entities.ts +168 -0
- package/src/modules/ecommerce/data/validators.ts +587 -0
- package/src/modules/ecommerce/di.ts +9 -0
- package/src/modules/ecommerce/events.ts +27 -0
- package/src/modules/ecommerce/i18n/de.json +341 -0
- package/src/modules/ecommerce/i18n/en.json +341 -0
- package/src/modules/ecommerce/i18n/es.json +341 -0
- package/src/modules/ecommerce/i18n/ko.json +341 -0
- package/src/modules/ecommerce/i18n/pl.json +341 -0
- package/src/modules/ecommerce/index.ts +14 -0
- package/src/modules/ecommerce/lib/assortmentCount.ts +175 -0
- package/src/modules/ecommerce/lib/brandingStyles.ts +215 -0
- package/src/modules/ecommerce/lib/buyerContext.ts +401 -0
- package/src/modules/ecommerce/lib/cacheInvalidation.ts +302 -0
- package/src/modules/ecommerce/lib/cacheKeys.ts +340 -0
- package/src/modules/ecommerce/lib/createConflictRecheck.ts +31 -0
- package/src/modules/ecommerce/lib/crudEvents.ts +128 -0
- package/src/modules/ecommerce/lib/crudSupport.ts +85 -0
- package/src/modules/ecommerce/lib/domainBindingRebind.ts +138 -0
- package/src/modules/ecommerce/lib/domainMappingSummaries.ts +71 -0
- package/src/modules/ecommerce/lib/exclusiveFlag.ts +90 -0
- package/src/modules/ecommerce/lib/references.ts +93 -0
- package/src/modules/ecommerce/lib/seedDraftStore.ts +125 -0
- package/src/modules/ecommerce/lib/storeBindingCascade.ts +138 -0
- package/src/modules/ecommerce/lib/storeBranding.ts +48 -0
- package/src/modules/ecommerce/lib/storeBrandingRoute.ts +91 -0
- package/src/modules/ecommerce/lib/storeContext.ts +669 -0
- package/src/modules/ecommerce/lib/storeContextService.ts +71 -0
- package/src/modules/ecommerce/lib/storeLocale.ts +88 -0
- package/src/modules/ecommerce/lib/storeNotifications.ts +55 -0
- package/src/modules/ecommerce/lib/storefrontCatalogSupport.ts +427 -0
- package/src/modules/ecommerce/lib/storefrontCategories.ts +419 -0
- package/src/modules/ecommerce/lib/storefrontCategoryCache.ts +113 -0
- package/src/modules/ecommerce/lib/storefrontDetail.ts +654 -0
- package/src/modules/ecommerce/lib/storefrontFacets.ts +697 -0
- package/src/modules/ecommerce/lib/storefrontOptionFilter.ts +44 -0
- package/src/modules/ecommerce/lib/storefrontPricing.ts +583 -0
- package/src/modules/ecommerce/lib/storefrontProductCache.ts +126 -0
- package/src/modules/ecommerce/lib/storefrontProductScope.ts +181 -0
- package/src/modules/ecommerce/lib/storefrontProducts.ts +963 -0
- package/src/modules/ecommerce/lib/storefrontQuery.ts +215 -0
- package/src/modules/ecommerce/lib/storefrontRateLimit.ts +126 -0
- package/src/modules/ecommerce/lib/storefrontSearch.ts +454 -0
- package/src/modules/ecommerce/lib/storefrontSearchCache.ts +49 -0
- package/src/modules/ecommerce/lib/subscriberSupport.ts +41 -0
- package/src/modules/ecommerce/lib/types.ts +69 -0
- package/src/modules/ecommerce/migrations/.snapshot-open-mercato.json +829 -0
- package/src/modules/ecommerce/migrations/Migration20261005113233_ecommerce.ts +32 -0
- package/src/modules/ecommerce/migrations/Migration20261006112733_ecommerce.ts +15 -0
- package/src/modules/ecommerce/notifications.client.ts +46 -0
- package/src/modules/ecommerce/notifications.ts +46 -0
- package/src/modules/ecommerce/search.ts +93 -0
- package/src/modules/ecommerce/setup.ts +15 -0
- package/src/modules/ecommerce/subscribers/assortment-empty-notifications.ts +12 -0
- package/src/modules/ecommerce/subscribers/availability-policy-cache-invalidation.ts +12 -0
- package/src/modules/ecommerce/subscribers/catalog-category-cache-invalidation.ts +12 -0
- package/src/modules/ecommerce/subscribers/catalog-price-cache-invalidation.ts +12 -0
- package/src/modules/ecommerce/subscribers/catalog-product-cache-invalidation.ts +12 -0
- package/src/modules/ecommerce/subscribers/catalog-variant-cache-invalidation.ts +12 -0
- package/src/modules/ecommerce/subscribers/customer-group-cache-invalidation.ts +12 -0
- package/src/modules/ecommerce/subscribers/customer-group-membership-cache-invalidation.ts +12 -0
- package/src/modules/ecommerce/subscribers/customer-group-terms-cache-invalidation.ts +12 -0
- package/src/modules/ecommerce/subscribers/customer-user-deleted-cache-invalidation.ts +12 -0
- package/src/modules/ecommerce/subscribers/customer-user-updated-cache-invalidation.ts +12 -0
- package/src/modules/ecommerce/subscribers/domain-binding-rebind.ts +14 -0
- package/src/modules/ecommerce/subscribers/domain-mapping-cache-invalidation.ts +12 -0
- package/src/modules/ecommerce/subscribers/store-cache-invalidation.ts +12 -0
- package/src/modules/ecommerce/subscribers/store-channel-binding-cache-invalidation.ts +12 -0
- package/src/modules/ecommerce/subscribers/store-domain-binding-cache-invalidation.ts +12 -0
- package/src/modules/ecommerce/subscribers/store-notifications.ts +12 -0
- package/src/modules/query_index/lib/batch.ts +25 -9
- package/src/modules/query_index/lib/doc-enrichers.ts +306 -0
- package/src/modules/query_index/lib/document.ts +2 -0
- package/src/modules/query_index/lib/engine.ts +58 -1
- package/src/modules/query_index/lib/indexer.ts +8 -0
- package/src/modules/query_index/lib/search-tokens.ts +2 -0
- package/src/modules/query_index/migrations/Migration20261005201500_query_index.ts +42 -0
- package/src/modules/translations/components/TranslationManager.tsx +3 -3
- package/src/modules/translations/data/validators.ts +1 -1
- package/src/modules/translations/lib/batch.ts +47 -0
- package/src/modules/translations/lib/helpers.ts +4 -0
- package/src/modules/translations/lib/resolve-field-list.ts +16 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/ecommerce/api/stores/%5Bid%5D/preview-branding/route.ts"],
|
|
4
|
+
"sourcesContent": ["import { NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport { isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\nimport type { OpenApiRouteDoc } from '@open-mercato/shared/lib/openapi'\nimport { ecommerceStoreBrandingSchema } from '../../../../data/validators'\nimport {\n buildBrandingDeclarations,\n renderBrandingRootRule,\n renderBrandingStyleBlock,\n} from '../../../../lib/brandingStyles'\nimport { parseBrandingInput } from '../../../../lib/storeBranding'\nimport { ecommerceInternalErrorBody } from '../../../../lib/crudSupport'\nimport {\n BRANDING_MANAGE_FEATURE,\n requireScopedStore,\n resolveBrandingRouteContext,\n storeIdParamSchema,\n} from '../../../../lib/storeBrandingRoute'\n\nexport const metadata = {\n GET: { requireAuth: true, requireFeatures: [BRANDING_MANAGE_FEATURE] },\n}\n\nconst logger = createLogger('ecommerce').child({ component: 'store-branding-preview-route' })\n\ntype RouteParams = { params?: { id?: string } | Promise<{ id?: string }> }\n\nfunction readQueryValues(url: string): Record<string, string> {\n const values: Record<string, string> = {}\n for (const [key, value] of new URL(url).searchParams.entries()) values[key] = value\n return values\n}\n\nexport async function GET(req: Request, ctx: RouteParams) {\n try {\n const context = await resolveBrandingRouteContext(req)\n const { translate } = await resolveTranslations()\n const params = await ctx.params\n const storeId = storeIdParamSchema.safeParse(params?.id)\n if (!storeId.success) {\n return NextResponse.json(\n { error: translate('ecommerce.errors.storeNotFound', 'The selected store does not exist in this organization.') },\n { status: 404 },\n )\n }\n await requireScopedStore(context, storeId.data)\n\n const parsed = parseBrandingInput(readQueryValues(req.url), translate)\n if (!parsed.ok) {\n const [message] = Object.values(parsed.fieldErrors)\n return NextResponse.json({ error: message, fieldErrors: parsed.fieldErrors }, { status: 400 })\n }\n\n return NextResponse.json(\n {\n css: renderBrandingRootRule(parsed.branding),\n styleBlock: renderBrandingStyleBlock(parsed.branding),\n declarations: buildBrandingDeclarations(parsed.branding),\n },\n { headers: { 'Cache-Control': 'no-store' } },\n )\n } catch (err) {\n if (isCrudHttpError(err)) return NextResponse.json(err.body, { status: err.status })\n logger.error('ecommerce.stores.preview-branding.GET failed', { err })\n return NextResponse.json(await ecommerceInternalErrorBody(), { status: 500 })\n }\n}\n\nconst previewResponseSchema = z.object({\n css: z.string().describe('The :root rule that the storefront emits for these values.'),\n styleBlock: z.string().describe('The same rule wrapped in the style element the storefront server-renders.'),\n declarations: z.array(z.object({ property: z.string(), value: z.string() })),\n})\n\nconst errorSchema = z.object({ error: z.string() }).passthrough()\n\nexport const openApi: OpenApiRouteDoc = {\n tag: 'Ecommerce',\n summary: 'Store branding preview',\n pathParams: z.object({ id: z.string().uuid() }),\n methods: {\n GET: {\n summary: 'Preview the stylesheet for candidate branding values',\n description:\n 'Validates the candidate branding values passed as query parameters with the same rules as the save route and returns the CSS the storefront would emit. Nothing is persisted. Requires ecommerce.branding.manage.',\n tags: ['Ecommerce'],\n query: ecommerceStoreBrandingSchema,\n responses: [{ status: 200, description: 'Rendered branding stylesheet', schema: previewResponseSchema }],\n errors: [\n { status: 400, description: 'A branding value is invalid', schema: errorSchema },\n { status: 401, description: 'Unauthorized', schema: errorSchema },\n { status: 403, description: 'Missing ecommerce.branding.manage', schema: errorSchema },\n { status: 404, description: 'The store does not exist in the selected organization', schema: errorSchema },\n ],\n },\n },\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAClB,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAE7B,SAAS,oCAAoC;AAC7C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEA,MAAM,WAAW;AAAA,EACtB,KAAK,EAAE,aAAa,MAAM,iBAAiB,CAAC,uBAAuB,EAAE;AACvE;AAEA,MAAM,SAAS,aAAa,WAAW,EAAE,MAAM,EAAE,WAAW,+BAA+B,CAAC;AAI5F,SAAS,gBAAgB,KAAqC;AAC5D,QAAM,SAAiC,CAAC;AACxC,aAAW,CAAC,KAAK,KAAK,KAAK,IAAI,IAAI,GAAG,EAAE,aAAa,QAAQ,EAAG,QAAO,GAAG,IAAI;AAC9E,SAAO;AACT;AAEA,eAAsB,IAAI,KAAc,KAAkB;AACxD,MAAI;AACF,UAAM,UAAU,MAAM,4BAA4B,GAAG;AACrD,UAAM,EAAE,UAAU,IAAI,MAAM,oBAAoB;AAChD,UAAM,SAAS,MAAM,IAAI;AACzB,UAAM,UAAU,mBAAmB,UAAU,QAAQ,EAAE;AACvD,QAAI,CAAC,QAAQ,SAAS;AACpB,aAAO,aAAa;AAAA,QAClB,EAAE,OAAO,UAAU,kCAAkC,yDAAyD,EAAE;AAAA,QAChH,EAAE,QAAQ,I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E,KAAK,EAAE,CAAC;AAAA,EAC9C,SAAS;AAAA,IACP,KAAK;AAAA,MACH,SAAS;AAAA,MACT,aACE;AAAA,MACF,MAAM,CAAC,WAAW;AAAA,MAClB,OAAO;AAAA,MACP,WAAW,CAAC,EAAE,QAAQ,KAAK,aAAa,gCAAgC,QAAQ,sBAAsB,CAAC;AAAA,MACvG,QAAQ;AAAA,QACN,EAAE,QAAQ,KAAK,aAAa,+BAA+B,QAAQ,YAAY;AAAA,QAC/E,EAAE,QAAQ,KAAK,aAAa,gBAAgB,QAAQ,YAAY;AAAA,QAChE,EAAE,QAAQ,KAAK,aAAa,qCAAqC,QAAQ,YAAY;AAAA,QACrF,EAAE,QAAQ,KAAK,aAAa,yDAAyD,QAAQ,YAAY;AAAA,MAC3G;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { makeCrudRoute } from "@open-mercato/shared/lib/crud/factory";
|
|
3
|
+
import { isUniqueViolation } from "@open-mercato/shared/lib/crud/errors";
|
|
4
|
+
import { parseBooleanToken } from "@open-mercato/shared/lib/boolean";
|
|
5
|
+
import { buildIlikeTerm } from "@open-mercato/shared/lib/db/buildIlikeTerm";
|
|
6
|
+
import { resolveTranslations } from "@open-mercato/shared/lib/i18n/server";
|
|
7
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
8
|
+
import { getTelemetryRuntime } from "@open-mercato/shared/lib/telemetry/runtime";
|
|
9
|
+
import { E } from "../../../../generated/entities.ids.generated.js";
|
|
10
|
+
import * as F from "../../../../generated/entities/ecommerce_store/index.js";
|
|
11
|
+
import { EcommerceStore } from "../../data/entities.js";
|
|
12
|
+
import {
|
|
13
|
+
ecommerceStoreCreateSchema,
|
|
14
|
+
ecommerceStoreStatusSchema,
|
|
15
|
+
ecommerceStoreUpdateSchema
|
|
16
|
+
} from "../../data/validators.js";
|
|
17
|
+
import {
|
|
18
|
+
assertRecordInWriteScope,
|
|
19
|
+
fieldError,
|
|
20
|
+
hasOwn,
|
|
21
|
+
resolveScopeOrganizationId,
|
|
22
|
+
resolveWriteScope
|
|
23
|
+
} from "../../lib/crudSupport.js";
|
|
24
|
+
import { clearCreateConflictRecheck, registerCreateConflictRecheck } from "../../lib/createConflictRecheck.js";
|
|
25
|
+
import {
|
|
26
|
+
assignExclusiveFlag,
|
|
27
|
+
promoteExclusiveFlag
|
|
28
|
+
} from "../../lib/exclusiveFlag.js";
|
|
29
|
+
import {
|
|
30
|
+
announceStoresUpdated,
|
|
31
|
+
buildStoreEventPayload,
|
|
32
|
+
ECOMMERCE_EVENTS_MODULE,
|
|
33
|
+
STORE_EVENT_ENTITY
|
|
34
|
+
} from "../../lib/crudEvents.js";
|
|
35
|
+
import { announceStoreBindingCascade, cascadeStoreBindingDelete } from "../../lib/storeBindingCascade.js";
|
|
36
|
+
const logger = createLogger("ecommerce").child({ component: "store-crud" });
|
|
37
|
+
const rawBodySchema = z.object({}).passthrough();
|
|
38
|
+
const storeListQuerySchema = z.object({
|
|
39
|
+
page: z.coerce.number().min(1).default(1),
|
|
40
|
+
pageSize: z.coerce.number().min(1).max(100).default(50),
|
|
41
|
+
id: z.string().uuid().optional(),
|
|
42
|
+
search: z.string().optional(),
|
|
43
|
+
status: ecommerceStoreStatusSchema.optional(),
|
|
44
|
+
isPrimary: z.string().optional(),
|
|
45
|
+
sortField: z.string().optional(),
|
|
46
|
+
sortDir: z.enum(["asc", "desc"]).optional()
|
|
47
|
+
}).passthrough();
|
|
48
|
+
const storeRouteMetadata = {
|
|
49
|
+
GET: { requireAuth: true, requireFeatures: ["ecommerce.stores.view"] },
|
|
50
|
+
POST: { requireAuth: true, requireFeatures: ["ecommerce.stores.manage"] },
|
|
51
|
+
PUT: { requireAuth: true, requireFeatures: ["ecommerce.stores.manage"] },
|
|
52
|
+
DELETE: { requireAuth: true, requireFeatures: ["ecommerce.stores.manage"] }
|
|
53
|
+
};
|
|
54
|
+
const STORE_CODE_UNIQUE_CONSTRAINT = "ecommerce_stores_tenant_code_unique";
|
|
55
|
+
const STORE_SLUG_UNIQUE_CONSTRAINT = "ecommerce_stores_tenant_slug_unique";
|
|
56
|
+
const STORE_PRIMARY_UNIQUE_CONSTRAINT = "ecommerce_stores_org_primary_unique";
|
|
57
|
+
const storePrimaryFlag = {
|
|
58
|
+
entity: EcommerceStore,
|
|
59
|
+
flag: "isPrimary",
|
|
60
|
+
constraint: STORE_PRIMARY_UNIQUE_CONSTRAINT
|
|
61
|
+
};
|
|
62
|
+
function codeDuplicateMessage(translate) {
|
|
63
|
+
return translate("ecommerce.errors.codeDuplicate", "A store with this code already exists.");
|
|
64
|
+
}
|
|
65
|
+
function slugDuplicateMessage(translate) {
|
|
66
|
+
return translate("ecommerce.errors.slugDuplicate", "A store with this slug already exists.");
|
|
67
|
+
}
|
|
68
|
+
function primaryConflict(translate) {
|
|
69
|
+
return fieldError(409, {
|
|
70
|
+
isPrimary: translate(
|
|
71
|
+
"ecommerce.errors.primaryConflict",
|
|
72
|
+
"Another store was made primary at the same time. Reload and try again."
|
|
73
|
+
)
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function toStoreUniqueConflict(err, translate) {
|
|
77
|
+
if (isUniqueViolation(err, STORE_CODE_UNIQUE_CONSTRAINT)) return fieldError(409, { code: codeDuplicateMessage(translate) });
|
|
78
|
+
if (isUniqueViolation(err, STORE_SLUG_UNIQUE_CONSTRAINT)) return fieldError(409, { slug: slugDuplicateMessage(translate) });
|
|
79
|
+
if (isUniqueViolation(err, STORE_PRIMARY_UNIQUE_CONSTRAINT)) return primaryConflict(translate);
|
|
80
|
+
return err;
|
|
81
|
+
}
|
|
82
|
+
async function assertStoreIdentifiersAvailable(em, check, translate) {
|
|
83
|
+
const fieldErrors = {};
|
|
84
|
+
const taken = async (field, value) => {
|
|
85
|
+
const where = { tenantId: check.tenantId, [field]: value, deletedAt: null };
|
|
86
|
+
if (check.storeId) where.id = { $ne: check.storeId };
|
|
87
|
+
return await em.count(EcommerceStore, where) > 0;
|
|
88
|
+
};
|
|
89
|
+
if (check.code !== void 0 && await taken("code", check.code)) fieldErrors.code = codeDuplicateMessage(translate);
|
|
90
|
+
if (check.slug !== void 0 && await taken("slug", check.slug)) fieldErrors.slug = slugDuplicateMessage(translate);
|
|
91
|
+
if (Object.keys(fieldErrors).length) throw fieldError(409, fieldErrors);
|
|
92
|
+
}
|
|
93
|
+
function canonicalBranding(value) {
|
|
94
|
+
if (!value || typeof value !== "object") return "[]";
|
|
95
|
+
const entries = Object.entries(value).filter(([, entry]) => entry !== void 0 && entry !== null && entry !== "").sort(([left], [right]) => left.localeCompare(right));
|
|
96
|
+
return JSON.stringify(entries);
|
|
97
|
+
}
|
|
98
|
+
const BRANDING_MANAGE_FEATURE = "ecommerce.branding.manage";
|
|
99
|
+
async function assertCreateBrandingAllowed(settings, ctx, scope, translate) {
|
|
100
|
+
if (canonicalBranding(settings?.branding) === canonicalBranding(void 0)) return;
|
|
101
|
+
const subject = ctx.auth?.sub ?? null;
|
|
102
|
+
let rbac;
|
|
103
|
+
try {
|
|
104
|
+
rbac = ctx.container.resolve("rbacService");
|
|
105
|
+
} catch {
|
|
106
|
+
rbac = void 0;
|
|
107
|
+
}
|
|
108
|
+
if (subject && rbac && await rbac.userHasAllFeatures(subject, [BRANDING_MANAGE_FEATURE], scope)) return;
|
|
109
|
+
throw fieldError(403, {
|
|
110
|
+
"settings.branding": translate(
|
|
111
|
+
"ecommerce.errors.brandingPermissionRequired",
|
|
112
|
+
"You do not have permission to set the store branding."
|
|
113
|
+
)
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function assertBrandingUnchanged(current, patch, translate) {
|
|
117
|
+
if (!patch?.branding) return;
|
|
118
|
+
if (canonicalBranding(patch.branding) === canonicalBranding(current?.branding)) return;
|
|
119
|
+
throw fieldError(400, {
|
|
120
|
+
"settings.branding": translate(
|
|
121
|
+
"ecommerce.errors.brandingRouteRequired",
|
|
122
|
+
"Branding cannot be changed here. Save it through the branding endpoint (PUT /api/ecommerce/stores/{id}/branding)."
|
|
123
|
+
)
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function mergeStoreSettings(current, patch) {
|
|
127
|
+
return {
|
|
128
|
+
branding: current?.branding ?? {},
|
|
129
|
+
contact: patch.contact ?? current?.contact ?? {},
|
|
130
|
+
display: {
|
|
131
|
+
priceDisplayModeDefault: "gross",
|
|
132
|
+
enableSearch: true,
|
|
133
|
+
...current?.display,
|
|
134
|
+
...patch.display
|
|
135
|
+
},
|
|
136
|
+
seo: patch.seo ?? current?.seo ?? {}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function assertLocalesConsistent(store, input, translate) {
|
|
140
|
+
const defaultLocale = input.defaultLocale ?? store.defaultLocale;
|
|
141
|
+
const supportedLocales = input.supportedLocales ?? store.supportedLocales;
|
|
142
|
+
if (supportedLocales.includes(defaultLocale)) return;
|
|
143
|
+
const field = input.supportedLocales !== void 0 && input.defaultLocale === void 0 ? "supportedLocales" : "defaultLocale";
|
|
144
|
+
throw fieldError(400, {
|
|
145
|
+
[field]: translate("ecommerce.validation.defaultLocaleNotSupported", "The default locale must be one of the supported locales.")
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function assertStatusTransitionAllowed(store, input, translate) {
|
|
149
|
+
if (store.status !== "archived" || input.status === void 0 || input.status === "archived") return;
|
|
150
|
+
throw fieldError(400, {
|
|
151
|
+
status: translate("ecommerce.validation.archivedStoreTerminal", "An archived store cannot be reopened. Create a new store instead.")
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function parseCreateInput(input, ctx) {
|
|
155
|
+
return ecommerceStoreCreateSchema.parse({ ...input, ...resolveWriteScope(ctx) });
|
|
156
|
+
}
|
|
157
|
+
function parseUpdateInput(input, ctx) {
|
|
158
|
+
return ecommerceStoreUpdateSchema.parse({ ...input, ...resolveWriteScope(ctx) });
|
|
159
|
+
}
|
|
160
|
+
function toStoreEntityData(input) {
|
|
161
|
+
return {
|
|
162
|
+
organizationId: input.organizationId,
|
|
163
|
+
tenantId: input.tenantId,
|
|
164
|
+
code: input.code,
|
|
165
|
+
name: input.name,
|
|
166
|
+
slug: input.slug,
|
|
167
|
+
status: input.status,
|
|
168
|
+
defaultLocale: input.defaultLocale,
|
|
169
|
+
supportedLocales: input.supportedLocales,
|
|
170
|
+
defaultCurrencyCode: input.defaultCurrencyCode,
|
|
171
|
+
isPrimary: false,
|
|
172
|
+
settings: input.settings
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function applyStoreUpdate(store, input) {
|
|
176
|
+
if (input.code !== void 0) store.code = input.code;
|
|
177
|
+
if (input.name !== void 0) store.name = input.name;
|
|
178
|
+
if (input.slug !== void 0) store.slug = input.slug;
|
|
179
|
+
if (input.status !== void 0) store.status = input.status;
|
|
180
|
+
if (input.defaultLocale !== void 0) store.defaultLocale = input.defaultLocale;
|
|
181
|
+
if (input.supportedLocales !== void 0) store.supportedLocales = input.supportedLocales;
|
|
182
|
+
if (input.defaultCurrencyCode !== void 0) store.defaultCurrencyCode = input.defaultCurrencyCode;
|
|
183
|
+
if (input.isPrimary !== void 0) store.isPrimary = input.isPrimary;
|
|
184
|
+
if (hasOwn(input, "settings") && input.settings) store.settings = mergeStoreSettings(store.settings, input.settings);
|
|
185
|
+
}
|
|
186
|
+
function primaryScope(store) {
|
|
187
|
+
return { tenantId: store.tenantId, organizationId: store.organizationId };
|
|
188
|
+
}
|
|
189
|
+
const clearedPrimaryByUpdate = /* @__PURE__ */ new WeakMap();
|
|
190
|
+
function toStoreListItem(row) {
|
|
191
|
+
return {
|
|
192
|
+
id: row[F.id],
|
|
193
|
+
organizationId: row[F.organization_id] ?? null,
|
|
194
|
+
tenantId: row[F.tenant_id] ?? null,
|
|
195
|
+
code: row[F.code],
|
|
196
|
+
name: row[F.name],
|
|
197
|
+
slug: row[F.slug],
|
|
198
|
+
status: row[F.status],
|
|
199
|
+
defaultLocale: row[F.default_locale],
|
|
200
|
+
supportedLocales: row[F.supported_locales] ?? [],
|
|
201
|
+
defaultCurrencyCode: row[F.default_currency_code],
|
|
202
|
+
isPrimary: row[F.is_primary] === true,
|
|
203
|
+
settings: row[F.settings] ?? null,
|
|
204
|
+
createdAt: row[F.created_at] ?? null,
|
|
205
|
+
updatedAt: row[F.updated_at] ?? null
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
const NOT_FOUND = { key: "ecommerce.errors.storeNotFound", fallback: "The selected store does not exist in this organization." };
|
|
209
|
+
const storeCrud = makeCrudRoute({
|
|
210
|
+
metadata: storeRouteMetadata,
|
|
211
|
+
orm: {
|
|
212
|
+
entity: EcommerceStore,
|
|
213
|
+
idField: "id",
|
|
214
|
+
orgField: "organizationId",
|
|
215
|
+
tenantField: "tenantId",
|
|
216
|
+
softDeleteField: "deletedAt"
|
|
217
|
+
},
|
|
218
|
+
indexer: { entityType: E.ecommerce.ecommerce_store },
|
|
219
|
+
enrichers: { entityId: E.ecommerce.ecommerce_store },
|
|
220
|
+
list: {
|
|
221
|
+
schema: storeListQuerySchema,
|
|
222
|
+
entityId: E.ecommerce.ecommerce_store,
|
|
223
|
+
fields: [
|
|
224
|
+
F.id,
|
|
225
|
+
F.organization_id,
|
|
226
|
+
F.tenant_id,
|
|
227
|
+
F.code,
|
|
228
|
+
F.name,
|
|
229
|
+
F.slug,
|
|
230
|
+
F.status,
|
|
231
|
+
F.default_locale,
|
|
232
|
+
F.supported_locales,
|
|
233
|
+
F.default_currency_code,
|
|
234
|
+
F.is_primary,
|
|
235
|
+
F.settings,
|
|
236
|
+
F.created_at,
|
|
237
|
+
F.updated_at
|
|
238
|
+
],
|
|
239
|
+
sortFieldMap: {
|
|
240
|
+
name: F.name,
|
|
241
|
+
code: F.code,
|
|
242
|
+
slug: F.slug,
|
|
243
|
+
status: F.status,
|
|
244
|
+
createdAt: F.created_at,
|
|
245
|
+
updatedAt: F.updated_at
|
|
246
|
+
},
|
|
247
|
+
defaultSort: { field: "name", dir: "asc" },
|
|
248
|
+
tiebreakSortField: F.id,
|
|
249
|
+
buildFilters: async (query, ctx) => {
|
|
250
|
+
const filters = {};
|
|
251
|
+
const scopeOrganizationId = resolveScopeOrganizationId(ctx);
|
|
252
|
+
if (scopeOrganizationId) filters[F.organization_id] = { $eq: scopeOrganizationId };
|
|
253
|
+
if (query.id) filters[F.id] = { $eq: query.id };
|
|
254
|
+
if (query.search) {
|
|
255
|
+
const pattern = buildIlikeTerm(query.search);
|
|
256
|
+
filters.$or = [{ [F.code]: { $ilike: pattern } }, { [F.name]: { $ilike: pattern } }, { [F.slug]: { $ilike: pattern } }];
|
|
257
|
+
}
|
|
258
|
+
if (query.status) filters[F.status] = { $eq: query.status };
|
|
259
|
+
const isPrimary = parseBooleanToken(query.isPrimary);
|
|
260
|
+
if (isPrimary !== null) filters[F.is_primary] = { $eq: isPrimary };
|
|
261
|
+
return filters;
|
|
262
|
+
},
|
|
263
|
+
transformItem: (item) => toStoreListItem(item)
|
|
264
|
+
},
|
|
265
|
+
events: {
|
|
266
|
+
module: ECOMMERCE_EVENTS_MODULE,
|
|
267
|
+
entity: STORE_EVENT_ENTITY,
|
|
268
|
+
persistent: true,
|
|
269
|
+
buildPayload: (emitCtx) => buildStoreEventPayload(emitCtx.entity)
|
|
270
|
+
},
|
|
271
|
+
create: {
|
|
272
|
+
schema: rawBodySchema,
|
|
273
|
+
mapToEntity: (input, ctx) => toStoreEntityData(parseCreateInput(input, ctx)),
|
|
274
|
+
response: (entity) => {
|
|
275
|
+
const store = entity;
|
|
276
|
+
return { id: store.id, isPrimary: store.isPrimary };
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
update: {
|
|
280
|
+
schema: rawBodySchema,
|
|
281
|
+
getId: (input) => typeof input.id === "string" ? input.id : "",
|
|
282
|
+
applyToEntity: async (entity, input, ctx) => {
|
|
283
|
+
const store = entity;
|
|
284
|
+
const parsed = parseUpdateInput(input, ctx);
|
|
285
|
+
const em = ctx.container.resolve("em");
|
|
286
|
+
const { translate } = await resolveTranslations();
|
|
287
|
+
assertBrandingUnchanged(store.settings, parsed.settings, translate);
|
|
288
|
+
assertStatusTransitionAllowed(store, parsed, translate);
|
|
289
|
+
assertLocalesConsistent(store, parsed, translate);
|
|
290
|
+
await assertStoreIdentifiersAvailable(
|
|
291
|
+
em,
|
|
292
|
+
{
|
|
293
|
+
tenantId: store.tenantId,
|
|
294
|
+
storeId: store.id,
|
|
295
|
+
code: parsed.code !== void 0 && parsed.code !== store.code ? parsed.code : void 0,
|
|
296
|
+
slug: parsed.slug !== void 0 && parsed.slug !== store.slug ? parsed.slug : void 0
|
|
297
|
+
},
|
|
298
|
+
translate
|
|
299
|
+
);
|
|
300
|
+
if (parsed.isPrimary === true && !store.isPrimary) {
|
|
301
|
+
clearedPrimaryByUpdate.set(
|
|
302
|
+
store,
|
|
303
|
+
await assignExclusiveFlag(em, storePrimaryFlag, primaryScope(store), store.id, () => primaryConflict(translate))
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
applyStoreUpdate(store, parsed);
|
|
307
|
+
try {
|
|
308
|
+
await em.flush();
|
|
309
|
+
} catch (err) {
|
|
310
|
+
throw toStoreUniqueConflict(err, translate);
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
response: () => ({ ok: true })
|
|
314
|
+
},
|
|
315
|
+
del: { idFrom: "query", softDelete: true, response: () => ({ ok: true }) },
|
|
316
|
+
hooks: {
|
|
317
|
+
beforeUpdate: async (input, ctx) => {
|
|
318
|
+
await assertRecordInWriteScope(ctx, EcommerceStore, input.id, NOT_FOUND);
|
|
319
|
+
},
|
|
320
|
+
beforeDelete: async (id, ctx) => {
|
|
321
|
+
await assertRecordInWriteScope(ctx, EcommerceStore, id, NOT_FOUND);
|
|
322
|
+
},
|
|
323
|
+
beforeCreate: async (input, ctx) => {
|
|
324
|
+
const result = ecommerceStoreCreateSchema.safeParse({ ...input, ...resolveWriteScope(ctx) });
|
|
325
|
+
if (!result.success) return;
|
|
326
|
+
const { translate } = await resolveTranslations();
|
|
327
|
+
await assertCreateBrandingAllowed(
|
|
328
|
+
result.data.settings,
|
|
329
|
+
ctx,
|
|
330
|
+
{ tenantId: result.data.tenantId, organizationId: result.data.organizationId },
|
|
331
|
+
translate
|
|
332
|
+
);
|
|
333
|
+
const check = {
|
|
334
|
+
tenantId: result.data.tenantId,
|
|
335
|
+
storeId: null,
|
|
336
|
+
code: result.data.code,
|
|
337
|
+
slug: result.data.slug
|
|
338
|
+
};
|
|
339
|
+
await assertStoreIdentifiersAvailable(ctx.container.resolve("em").fork(), check, translate);
|
|
340
|
+
registerCreateConflictRecheck(
|
|
341
|
+
ctx.request,
|
|
342
|
+
() => assertStoreIdentifiersAvailable(ctx.container.resolve("em").fork(), check, translate)
|
|
343
|
+
);
|
|
344
|
+
},
|
|
345
|
+
afterCreate: async (entity, ctx) => {
|
|
346
|
+
clearCreateConflictRecheck(ctx.request);
|
|
347
|
+
const store = entity;
|
|
348
|
+
if (parseCreateInput(ctx.input, ctx).isPrimary !== true) return;
|
|
349
|
+
const now = /* @__PURE__ */ new Date();
|
|
350
|
+
const em = ctx.container.resolve("em");
|
|
351
|
+
const { promoted, cleared } = await promoteExclusiveFlag(em, storePrimaryFlag, primaryScope(store), store.id, now);
|
|
352
|
+
if (!promoted) return;
|
|
353
|
+
store.isPrimary = true;
|
|
354
|
+
store.updatedAt = now;
|
|
355
|
+
await announceStoresUpdated(ctx.container, cleared);
|
|
356
|
+
},
|
|
357
|
+
afterUpdate: async (entity, ctx) => {
|
|
358
|
+
const store = entity;
|
|
359
|
+
const cleared = clearedPrimaryByUpdate.get(store);
|
|
360
|
+
if (!cleared) return;
|
|
361
|
+
clearedPrimaryByUpdate.delete(store);
|
|
362
|
+
await announceStoresUpdated(ctx.container, cleared);
|
|
363
|
+
},
|
|
364
|
+
afterDelete: async (id, ctx) => {
|
|
365
|
+
const em = ctx.container.resolve("em");
|
|
366
|
+
const cascade = await cascadeStoreBindingDelete(em, id, ctx);
|
|
367
|
+
try {
|
|
368
|
+
await announceStoreBindingCascade(ctx.container, cascade);
|
|
369
|
+
} catch (err) {
|
|
370
|
+
logger.error("[internal] store binding cascade committed but could not be announced", {
|
|
371
|
+
storeId: id,
|
|
372
|
+
domainBindingCount: cascade.domainBindings.length,
|
|
373
|
+
channelBindingCount: cascade.channelBindings.length,
|
|
374
|
+
err
|
|
375
|
+
});
|
|
376
|
+
getTelemetryRuntime()?.reportError(err, {
|
|
377
|
+
module: "ecommerce",
|
|
378
|
+
code: "ecommerce.store_binding_cascade_announce_failed"
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
export {
|
|
385
|
+
BRANDING_MANAGE_FEATURE,
|
|
386
|
+
STORE_CODE_UNIQUE_CONSTRAINT,
|
|
387
|
+
STORE_PRIMARY_UNIQUE_CONSTRAINT,
|
|
388
|
+
STORE_SLUG_UNIQUE_CONSTRAINT,
|
|
389
|
+
assertBrandingUnchanged,
|
|
390
|
+
assertCreateBrandingAllowed,
|
|
391
|
+
assertLocalesConsistent,
|
|
392
|
+
assertStatusTransitionAllowed,
|
|
393
|
+
assertStoreIdentifiersAvailable,
|
|
394
|
+
mergeStoreSettings,
|
|
395
|
+
storeCrud,
|
|
396
|
+
storeListQuerySchema,
|
|
397
|
+
storeRouteMetadata,
|
|
398
|
+
toStoreListItem,
|
|
399
|
+
toStoreUniqueConflict
|
|
400
|
+
};
|
|
401
|
+
//# sourceMappingURL=crud.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/ecommerce/api/stores/crud.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from 'zod'\nimport type { EntityManager, FilterQuery } from '@mikro-orm/postgresql'\nimport type { CrudCtx } from '@open-mercato/shared/lib/crud/factory'\nimport { makeCrudRoute } from '@open-mercato/shared/lib/crud/factory'\nimport { isUniqueViolation } from '@open-mercato/shared/lib/crud/errors'\nimport { parseBooleanToken } from '@open-mercato/shared/lib/boolean'\nimport { buildIlikeTerm } from '@open-mercato/shared/lib/db/buildIlikeTerm'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\nimport { getTelemetryRuntime } from '@open-mercato/shared/lib/telemetry/runtime'\nimport { E } from '#generated/entities.ids.generated'\nimport * as F from '#generated/entities/ecommerce_store'\nimport { EcommerceStore } from '../../data/entities'\nimport {\n ecommerceStoreCreateSchema,\n ecommerceStoreStatusSchema,\n ecommerceStoreUpdateSchema,\n type EcommerceStoreCreateInput,\n type EcommerceStoreSettings,\n type EcommerceStoreSettingsPatch,\n type EcommerceStoreUpdateInput,\n} from '../../data/validators'\nimport {\n assertRecordInWriteScope,\n fieldError,\n hasOwn,\n resolveScopeOrganizationId,\n resolveWriteScope,\n type Translate,\n} from '../../lib/crudSupport'\nimport { clearCreateConflictRecheck, registerCreateConflictRecheck } from '../../lib/createConflictRecheck'\nimport {\n assignExclusiveFlag,\n promoteExclusiveFlag,\n type ExclusiveFlagConfig,\n} from '../../lib/exclusiveFlag'\nimport {\n announceStoresUpdated,\n buildStoreEventPayload,\n ECOMMERCE_EVENTS_MODULE,\n STORE_EVENT_ENTITY,\n} from '../../lib/crudEvents'\nimport { announceStoreBindingCascade, cascadeStoreBindingDelete } from '../../lib/storeBindingCascade'\n\nconst logger = createLogger('ecommerce').child({ component: 'store-crud' })\n\nconst rawBodySchema = z.object({}).passthrough()\ntype RawStoreInput = z.infer<typeof rawBodySchema>\n\nexport const storeListQuerySchema = z\n .object({\n page: z.coerce.number().min(1).default(1),\n pageSize: z.coerce.number().min(1).max(100).default(50),\n id: z.string().uuid().optional(),\n search: z.string().optional(),\n status: ecommerceStoreStatusSchema.optional(),\n isPrimary: z.string().optional(),\n sortField: z.string().optional(),\n sortDir: z.enum(['asc', 'desc']).optional(),\n })\n .passthrough()\n\nexport type StoreListQuery = z.infer<typeof storeListQuerySchema>\n\nexport const storeRouteMetadata = {\n GET: { requireAuth: true, requireFeatures: ['ecommerce.stores.view'] },\n POST: { requireAuth: true, requireFeatures: ['ecommerce.stores.manage'] },\n PUT: { requireAuth: true, requireFeatures: ['ecommerce.stores.manage'] },\n DELETE: { requireAuth: true, requireFeatures: ['ecommerce.stores.manage'] },\n}\n\nexport const STORE_CODE_UNIQUE_CONSTRAINT = 'ecommerce_stores_tenant_code_unique'\nexport const STORE_SLUG_UNIQUE_CONSTRAINT = 'ecommerce_stores_tenant_slug_unique'\nexport const STORE_PRIMARY_UNIQUE_CONSTRAINT = 'ecommerce_stores_org_primary_unique'\n\nconst storePrimaryFlag: ExclusiveFlagConfig<EcommerceStore> = {\n entity: EcommerceStore,\n flag: 'isPrimary',\n constraint: STORE_PRIMARY_UNIQUE_CONSTRAINT,\n}\n\nfunction codeDuplicateMessage(translate: Translate): string {\n return translate('ecommerce.errors.codeDuplicate', 'A store with this code already exists.')\n}\n\nfunction slugDuplicateMessage(translate: Translate): string {\n return translate('ecommerce.errors.slugDuplicate', 'A store with this slug already exists.')\n}\n\nfunction primaryConflict(translate: Translate) {\n return fieldError(409, {\n isPrimary: translate(\n 'ecommerce.errors.primaryConflict',\n 'Another store was made primary at the same time. Reload and try again.',\n ),\n })\n}\n\nexport function toStoreUniqueConflict(err: unknown, translate: Translate): unknown {\n if (isUniqueViolation(err, STORE_CODE_UNIQUE_CONSTRAINT)) return fieldError(409, { code: codeDuplicateMessage(translate) })\n if (isUniqueViolation(err, STORE_SLUG_UNIQUE_CONSTRAINT)) return fieldError(409, { slug: slugDuplicateMessage(translate) })\n if (isUniqueViolation(err, STORE_PRIMARY_UNIQUE_CONSTRAINT)) return primaryConflict(translate)\n return err\n}\n\nexport type StoreIdentifierCheck = {\n tenantId: string\n storeId: string | null\n code?: string\n slug?: string\n}\n\nexport async function assertStoreIdentifiersAvailable(\n em: EntityManager,\n check: StoreIdentifierCheck,\n translate: Translate,\n): Promise<void> {\n const fieldErrors: Record<string, string> = {}\n const taken = async (field: 'code' | 'slug', value: string): Promise<boolean> => {\n const where: Record<string, unknown> = { tenantId: check.tenantId, [field]: value, deletedAt: null }\n if (check.storeId) where.id = { $ne: check.storeId }\n return (await em.count(EcommerceStore, where as FilterQuery<EcommerceStore>)) > 0\n }\n if (check.code !== undefined && (await taken('code', check.code))) fieldErrors.code = codeDuplicateMessage(translate)\n if (check.slug !== undefined && (await taken('slug', check.slug))) fieldErrors.slug = slugDuplicateMessage(translate)\n if (Object.keys(fieldErrors).length) throw fieldError(409, fieldErrors)\n}\n\nfunction canonicalBranding(value: unknown): string {\n if (!value || typeof value !== 'object') return '[]'\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, entry]) => entry !== undefined && entry !== null && entry !== '')\n .sort(([left], [right]) => left.localeCompare(right))\n return JSON.stringify(entries)\n}\n\nexport const BRANDING_MANAGE_FEATURE = 'ecommerce.branding.manage'\n\ntype FeatureChecker = {\n userHasAllFeatures(\n userId: string,\n required: string[],\n scope: { tenantId: string | null; organizationId: string | null },\n ): Promise<boolean>\n}\n\nexport async function assertCreateBrandingAllowed(\n settings: Partial<EcommerceStoreSettings> | null | undefined,\n ctx: CrudCtx,\n scope: { tenantId: string; organizationId: string },\n translate: Translate,\n): Promise<void> {\n if (canonicalBranding(settings?.branding) === canonicalBranding(undefined)) return\n const subject = ctx.auth?.sub ?? null\n let rbac: FeatureChecker | undefined\n try {\n rbac = ctx.container.resolve('rbacService') as FeatureChecker | undefined\n } catch {\n rbac = undefined\n }\n if (subject && rbac && (await rbac.userHasAllFeatures(subject, [BRANDING_MANAGE_FEATURE], scope))) return\n throw fieldError(403, {\n 'settings.branding': translate(\n 'ecommerce.errors.brandingPermissionRequired',\n 'You do not have permission to set the store branding.',\n ),\n })\n}\n\nexport function assertBrandingUnchanged(\n current: Partial<EcommerceStoreSettings> | null | undefined,\n patch: EcommerceStoreSettingsPatch | undefined,\n translate: Translate,\n): void {\n if (!patch?.branding) return\n if (canonicalBranding(patch.branding) === canonicalBranding(current?.branding)) return\n throw fieldError(400, {\n 'settings.branding': translate(\n 'ecommerce.errors.brandingRouteRequired',\n 'Branding cannot be changed here. Save it through the branding endpoint (PUT /api/ecommerce/stores/{id}/branding).',\n ),\n })\n}\n\nexport function mergeStoreSettings(\n current: Partial<EcommerceStoreSettings> | null | undefined,\n patch: EcommerceStoreSettingsPatch,\n): EcommerceStoreSettings {\n return {\n branding: current?.branding ?? {},\n contact: patch.contact ?? current?.contact ?? {},\n display: {\n priceDisplayModeDefault: 'gross',\n enableSearch: true,\n ...current?.display,\n ...patch.display,\n },\n seo: patch.seo ?? current?.seo ?? {},\n }\n}\n\nexport function assertLocalesConsistent(store: EcommerceStore, input: EcommerceStoreUpdateInput, translate: Translate): void {\n const defaultLocale = input.defaultLocale ?? store.defaultLocale\n const supportedLocales = input.supportedLocales ?? store.supportedLocales\n if (supportedLocales.includes(defaultLocale)) return\n const field = input.supportedLocales !== undefined && input.defaultLocale === undefined ? 'supportedLocales' : 'defaultLocale'\n throw fieldError(400, {\n [field]: translate('ecommerce.validation.defaultLocaleNotSupported', 'The default locale must be one of the supported locales.'),\n })\n}\n\nexport function assertStatusTransitionAllowed(store: EcommerceStore, input: EcommerceStoreUpdateInput, translate: Translate): void {\n if (store.status !== 'archived' || input.status === undefined || input.status === 'archived') return\n throw fieldError(400, {\n status: translate('ecommerce.validation.archivedStoreTerminal', 'An archived store cannot be reopened. Create a new store instead.'),\n })\n}\n\nfunction parseCreateInput(input: RawStoreInput, ctx: CrudCtx): EcommerceStoreCreateInput {\n return ecommerceStoreCreateSchema.parse({ ...input, ...resolveWriteScope(ctx) })\n}\n\nfunction parseUpdateInput(input: RawStoreInput, ctx: CrudCtx): EcommerceStoreUpdateInput {\n return ecommerceStoreUpdateSchema.parse({ ...input, ...resolveWriteScope(ctx) })\n}\n\nfunction toStoreEntityData(input: EcommerceStoreCreateInput): Record<string, unknown> {\n return {\n organizationId: input.organizationId,\n tenantId: input.tenantId,\n code: input.code,\n name: input.name,\n slug: input.slug,\n status: input.status,\n defaultLocale: input.defaultLocale,\n supportedLocales: input.supportedLocales,\n defaultCurrencyCode: input.defaultCurrencyCode,\n isPrimary: false,\n settings: input.settings,\n }\n}\n\nfunction applyStoreUpdate(store: EcommerceStore, input: EcommerceStoreUpdateInput): void {\n if (input.code !== undefined) store.code = input.code\n if (input.name !== undefined) store.name = input.name\n if (input.slug !== undefined) store.slug = input.slug\n if (input.status !== undefined) store.status = input.status\n if (input.defaultLocale !== undefined) store.defaultLocale = input.defaultLocale\n if (input.supportedLocales !== undefined) store.supportedLocales = input.supportedLocales\n if (input.defaultCurrencyCode !== undefined) store.defaultCurrencyCode = input.defaultCurrencyCode\n if (input.isPrimary !== undefined) store.isPrimary = input.isPrimary\n if (hasOwn(input, 'settings') && input.settings) store.settings = mergeStoreSettings(store.settings, input.settings)\n}\n\nfunction primaryScope(store: Pick<EcommerceStore, 'tenantId' | 'organizationId'>): Record<string, string> {\n return { tenantId: store.tenantId, organizationId: store.organizationId }\n}\n\nconst clearedPrimaryByUpdate = new WeakMap<EcommerceStore, EcommerceStore[]>()\n\ntype StoreListRow = Record<string, unknown>\n\nexport function toStoreListItem(row: StoreListRow): Record<string, unknown> {\n return {\n id: row[F.id],\n organizationId: row[F.organization_id] ?? null,\n tenantId: row[F.tenant_id] ?? null,\n code: row[F.code],\n name: row[F.name],\n slug: row[F.slug],\n status: row[F.status],\n defaultLocale: row[F.default_locale],\n supportedLocales: row[F.supported_locales] ?? [],\n defaultCurrencyCode: row[F.default_currency_code],\n isPrimary: row[F.is_primary] === true,\n settings: row[F.settings] ?? null,\n createdAt: row[F.created_at] ?? null,\n updatedAt: row[F.updated_at] ?? null,\n }\n}\n\nconst NOT_FOUND = { key: 'ecommerce.errors.storeNotFound', fallback: 'The selected store does not exist in this organization.' }\n\nexport const storeCrud = makeCrudRoute<RawStoreInput, RawStoreInput, StoreListQuery>({\n metadata: storeRouteMetadata,\n orm: {\n entity: EcommerceStore,\n idField: 'id',\n orgField: 'organizationId',\n tenantField: 'tenantId',\n softDeleteField: 'deletedAt',\n },\n indexer: { entityType: E.ecommerce.ecommerce_store },\n enrichers: { entityId: E.ecommerce.ecommerce_store },\n list: {\n schema: storeListQuerySchema,\n entityId: E.ecommerce.ecommerce_store,\n fields: [\n F.id,\n F.organization_id,\n F.tenant_id,\n F.code,\n F.name,\n F.slug,\n F.status,\n F.default_locale,\n F.supported_locales,\n F.default_currency_code,\n F.is_primary,\n F.settings,\n F.created_at,\n F.updated_at,\n ],\n sortFieldMap: {\n name: F.name,\n code: F.code,\n slug: F.slug,\n status: F.status,\n createdAt: F.created_at,\n updatedAt: F.updated_at,\n },\n defaultSort: { field: 'name', dir: 'asc' },\n tiebreakSortField: F.id,\n buildFilters: async (query, ctx) => {\n const filters: Record<string, unknown> = {}\n const scopeOrganizationId = resolveScopeOrganizationId(ctx)\n if (scopeOrganizationId) filters[F.organization_id] = { $eq: scopeOrganizationId }\n if (query.id) filters[F.id] = { $eq: query.id }\n if (query.search) {\n const pattern = buildIlikeTerm(query.search)\n filters.$or = [{ [F.code]: { $ilike: pattern } }, { [F.name]: { $ilike: pattern } }, { [F.slug]: { $ilike: pattern } }]\n }\n if (query.status) filters[F.status] = { $eq: query.status }\n const isPrimary = parseBooleanToken(query.isPrimary)\n if (isPrimary !== null) filters[F.is_primary] = { $eq: isPrimary }\n return filters\n },\n transformItem: (item: StoreListRow) => toStoreListItem(item),\n },\n events: {\n module: ECOMMERCE_EVENTS_MODULE,\n entity: STORE_EVENT_ENTITY,\n persistent: true,\n buildPayload: (emitCtx) => buildStoreEventPayload(emitCtx.entity as EcommerceStore),\n },\n create: {\n schema: rawBodySchema,\n mapToEntity: (input, ctx) => toStoreEntityData(parseCreateInput(input, ctx)),\n response: (entity) => {\n const store = entity as EcommerceStore\n return { id: store.id, isPrimary: store.isPrimary }\n },\n },\n update: {\n schema: rawBodySchema,\n getId: (input) => (typeof input.id === 'string' ? input.id : ''),\n applyToEntity: async (entity, input, ctx) => {\n const store = entity as EcommerceStore\n const parsed = parseUpdateInput(input, ctx)\n const em = ctx.container.resolve('em') as EntityManager\n const { translate } = await resolveTranslations()\n assertBrandingUnchanged(store.settings, parsed.settings, translate)\n assertStatusTransitionAllowed(store, parsed, translate)\n assertLocalesConsistent(store, parsed, translate)\n await assertStoreIdentifiersAvailable(\n em,\n {\n tenantId: store.tenantId,\n storeId: store.id,\n code: parsed.code !== undefined && parsed.code !== store.code ? parsed.code : undefined,\n slug: parsed.slug !== undefined && parsed.slug !== store.slug ? parsed.slug : undefined,\n },\n translate,\n )\n if (parsed.isPrimary === true && !store.isPrimary) {\n clearedPrimaryByUpdate.set(\n store,\n await assignExclusiveFlag(em, storePrimaryFlag, primaryScope(store), store.id, () => primaryConflict(translate)),\n )\n }\n applyStoreUpdate(store, parsed)\n try {\n await em.flush()\n } catch (err) {\n throw toStoreUniqueConflict(err, translate)\n }\n },\n response: () => ({ ok: true }),\n },\n del: { idFrom: 'query', softDelete: true, response: () => ({ ok: true }) },\n hooks: {\n beforeUpdate: async (input, ctx) => {\n await assertRecordInWriteScope(ctx, EcommerceStore, (input as { id?: unknown }).id, NOT_FOUND)\n },\n beforeDelete: async (id, ctx) => {\n await assertRecordInWriteScope(ctx, EcommerceStore, id, NOT_FOUND)\n },\n beforeCreate: async (input, ctx) => {\n const result = ecommerceStoreCreateSchema.safeParse({ ...input, ...resolveWriteScope(ctx) })\n if (!result.success) return\n const { translate } = await resolveTranslations()\n await assertCreateBrandingAllowed(\n result.data.settings,\n ctx,\n { tenantId: result.data.tenantId, organizationId: result.data.organizationId },\n translate,\n )\n const check: StoreIdentifierCheck = {\n tenantId: result.data.tenantId,\n storeId: null,\n code: result.data.code,\n slug: result.data.slug,\n }\n await assertStoreIdentifiersAvailable((ctx.container.resolve('em') as EntityManager).fork(), check, translate)\n registerCreateConflictRecheck(ctx.request, () =>\n assertStoreIdentifiersAvailable((ctx.container.resolve('em') as EntityManager).fork(), check, translate),\n )\n },\n afterCreate: async (entity, ctx) => {\n clearCreateConflictRecheck(ctx.request)\n const store = entity as EcommerceStore\n if (parseCreateInput(ctx.input, ctx).isPrimary !== true) return\n const now = new Date()\n const em = ctx.container.resolve('em') as EntityManager\n const { promoted, cleared } = await promoteExclusiveFlag(em, storePrimaryFlag, primaryScope(store), store.id, now)\n if (!promoted) return\n store.isPrimary = true\n store.updatedAt = now\n await announceStoresUpdated(ctx.container, cleared)\n },\n afterUpdate: async (entity, ctx) => {\n const store = entity as EcommerceStore\n const cleared = clearedPrimaryByUpdate.get(store)\n if (!cleared) return\n clearedPrimaryByUpdate.delete(store)\n await announceStoresUpdated(ctx.container, cleared)\n },\n afterDelete: async (id, ctx) => {\n const em = ctx.container.resolve('em') as EntityManager\n const cascade = await cascadeStoreBindingDelete(em, id, ctx)\n try {\n await announceStoreBindingCascade(ctx.container, cascade)\n } catch (err) {\n logger.error('[internal] store binding cascade committed but could not be announced', {\n storeId: id,\n domainBindingCount: cascade.domainBindings.length,\n channelBindingCount: cascade.channelBindings.length,\n err,\n })\n getTelemetryRuntime()?.reportError(err, {\n module: 'ecommerce',\n code: 'ecommerce.store_binding_cascade_announce_failed',\n })\n }\n },\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAGlB,SAAS,qBAAqB;AAC9B,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAC/B,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AACpC,SAAS,SAAS;AAClB,YAAY,OAAO;AACnB,SAAS,sBAAsB;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,4BAA4B,qCAAqC;AAC1E;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EAC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,MACH;AAAA,IACF;AAAA,EACF;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { withCreateConflictRecheck } from "../../lib/createConflictRecheck.js";
|
|
3
|
+
import { storeCrud, storeListQuerySchema, storeRouteMetadata } from "./crud.js";
|
|
4
|
+
import { ecommerceStoreCreateSchema, ecommerceStoreUpdateSchema } from "../../data/validators.js";
|
|
5
|
+
import { createEcommerceCrudOpenApi, createPagedListResponseSchema, defaultOkResponseSchema } from "../openapi.js";
|
|
6
|
+
const metadata = storeRouteMetadata;
|
|
7
|
+
const GET = storeCrud.GET;
|
|
8
|
+
const POST = withCreateConflictRecheck(storeCrud.POST);
|
|
9
|
+
const PUT = storeCrud.PUT;
|
|
10
|
+
const DELETE = storeCrud.DELETE;
|
|
11
|
+
const storeListItemSchema = z.object({
|
|
12
|
+
id: z.string().uuid(),
|
|
13
|
+
organizationId: z.string().uuid().nullable(),
|
|
14
|
+
tenantId: z.string().uuid().nullable(),
|
|
15
|
+
code: z.string(),
|
|
16
|
+
name: z.string(),
|
|
17
|
+
slug: z.string(),
|
|
18
|
+
status: z.enum(["draft", "active", "archived"]),
|
|
19
|
+
defaultLocale: z.string(),
|
|
20
|
+
supportedLocales: z.array(z.string()),
|
|
21
|
+
defaultCurrencyCode: z.string(),
|
|
22
|
+
isPrimary: z.boolean(),
|
|
23
|
+
settings: z.record(z.string(), z.unknown()).nullable(),
|
|
24
|
+
createdAt: z.string().nullable(),
|
|
25
|
+
updatedAt: z.string().nullable(),
|
|
26
|
+
_ecommerce: z.object({
|
|
27
|
+
primaryDomain: z.object({ hostname: z.string(), pathPrefix: z.string().nullable() }).nullable(),
|
|
28
|
+
defaultChannel: z.object({ id: z.string().uuid(), name: z.string() }).nullable()
|
|
29
|
+
}).optional().describe("Response enricher: the hostname of the primary domain binding and the name of the default sales channel binding.")
|
|
30
|
+
});
|
|
31
|
+
const openApi = createEcommerceCrudOpenApi({
|
|
32
|
+
resourceName: "Store",
|
|
33
|
+
pluralName: "Stores",
|
|
34
|
+
querySchema: storeListQuerySchema,
|
|
35
|
+
listResponseSchema: createPagedListResponseSchema(storeListItemSchema),
|
|
36
|
+
create: {
|
|
37
|
+
schema: ecommerceStoreCreateSchema,
|
|
38
|
+
responseSchema: z.object({
|
|
39
|
+
id: z.string().uuid().nullable(),
|
|
40
|
+
isPrimary: z.boolean().describe("Whether the created store is the organization primary store. False when a concurrent request won the promotion.")
|
|
41
|
+
}),
|
|
42
|
+
description: "Creates a store in the selected organization. Requesting isPrimary clears the previous primary store of the organization. A duplicate code or slug is rejected with a field-level 409. A non-empty settings.branding requires ecommerce.branding.manage and is otherwise rejected with a 403 field error."
|
|
43
|
+
},
|
|
44
|
+
update: {
|
|
45
|
+
schema: ecommerceStoreUpdateSchema,
|
|
46
|
+
responseSchema: defaultOkResponseSchema,
|
|
47
|
+
description: "Updates a store by id (id in the body). Any change to settings.branding is rejected with a 400 field error: branding is written through PUT /api/ecommerce/stores/{id}/branding. Setting isPrimary clears the previous primary store of the organization."
|
|
48
|
+
},
|
|
49
|
+
del: {
|
|
50
|
+
schema: z.object({ id: z.string().uuid() }),
|
|
51
|
+
responseSchema: defaultOkResponseSchema,
|
|
52
|
+
description: "Soft-deletes a store by id (?id= query parameter). Its live domain and channel bindings are soft-deleted with it, releasing their domain and path prefix, and each emits its own deleted event."
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
export {
|
|
56
|
+
DELETE,
|
|
57
|
+
GET,
|
|
58
|
+
POST,
|
|
59
|
+
PUT,
|
|
60
|
+
metadata,
|
|
61
|
+
openApi,
|
|
62
|
+
storeListItemSchema
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/ecommerce/api/stores/route.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from 'zod'\nimport { withCreateConflictRecheck } from '../../lib/createConflictRecheck'\nimport { storeCrud, storeListQuerySchema, storeRouteMetadata } from './crud'\nimport { ecommerceStoreCreateSchema, ecommerceStoreUpdateSchema } from '../../data/validators'\nimport { createEcommerceCrudOpenApi, createPagedListResponseSchema, defaultOkResponseSchema } from '../openapi'\n\nexport const metadata = storeRouteMetadata\n\nexport const GET = storeCrud.GET\nexport const POST = withCreateConflictRecheck(storeCrud.POST)\nexport const PUT = storeCrud.PUT\nexport const DELETE = storeCrud.DELETE\n\nexport const storeListItemSchema = z.object({\n id: z.string().uuid(),\n organizationId: z.string().uuid().nullable(),\n tenantId: z.string().uuid().nullable(),\n code: z.string(),\n name: z.string(),\n slug: z.string(),\n status: z.enum(['draft', 'active', 'archived']),\n defaultLocale: z.string(),\n supportedLocales: z.array(z.string()),\n defaultCurrencyCode: z.string(),\n isPrimary: z.boolean(),\n settings: z.record(z.string(), z.unknown()).nullable(),\n createdAt: z.string().nullable(),\n updatedAt: z.string().nullable(),\n _ecommerce: z\n .object({\n primaryDomain: z.object({ hostname: z.string(), pathPrefix: z.string().nullable() }).nullable(),\n defaultChannel: z.object({ id: z.string().uuid(), name: z.string() }).nullable(),\n })\n .optional()\n .describe('Response enricher: the hostname of the primary domain binding and the name of the default sales channel binding.'),\n})\n\nexport const openApi = createEcommerceCrudOpenApi({\n resourceName: 'Store',\n pluralName: 'Stores',\n querySchema: storeListQuerySchema,\n listResponseSchema: createPagedListResponseSchema(storeListItemSchema),\n create: {\n schema: ecommerceStoreCreateSchema,\n responseSchema: z.object({\n id: z.string().uuid().nullable(),\n isPrimary: z\n .boolean()\n .describe('Whether the created store is the organization primary store. False when a concurrent request won the promotion.'),\n }),\n description:\n 'Creates a store in the selected organization. Requesting isPrimary clears the previous primary store of the organization. A duplicate code or slug is rejected with a field-level 409. A non-empty settings.branding requires ecommerce.branding.manage and is otherwise rejected with a 403 field error.',\n },\n update: {\n schema: ecommerceStoreUpdateSchema,\n responseSchema: defaultOkResponseSchema,\n description:\n 'Updates a store by id (id in the body). Any change to settings.branding is rejected with a 400 field error: branding is written through PUT /api/ecommerce/stores/{id}/branding. Setting isPrimary clears the previous primary store of the organization.',\n },\n del: {\n schema: z.object({ id: z.string().uuid() }),\n responseSchema: defaultOkResponseSchema,\n description:\n 'Soft-deletes a store by id (?id= query parameter). Its live domain and channel bindings are soft-deleted with it, releasing their domain and path prefix, and each emits its own deleted event.',\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS;AAClB,SAAS,iCAAiC;AAC1C,SAAS,WAAW,sBAAsB,0BAA0B;AACpE,SAAS,4BAA4B,kCAAkC;AACvE,SAAS,4BAA4B,+BAA+B,+BAA+B;AAE5F,MAAM,WAAW;AAEjB,MAAM,MAAM,UAAU;AACtB,MAAM,OAAO,0BAA0B,UAAU,IAAI;AACrD,MAAM,MAAM,UAAU;AACtB,MAAM,SAAS,UAAU;AAEzB,MAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,IAAI,EAAE,OAAO,EAAE,KAAK;AAAA,EACpB,gBAAgB,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS;AAAA,EAC3C,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS;AAAA,EACrC,MAAM,EAAE,OAAO;AAAA,EACf,MAAM,EAAE,OAAO;AAAA,EACf,MAAM,EAAE,OAAO;AAAA,EACf,QAAQ,EAAE,KAAK,CAAC,SAAS,UAAU,UAAU,CAAC;AAAA,EAC9C,eAAe,EAAE,OAAO;AAAA,EACxB,kBAAkB,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EACpC,qBAAqB,EAAE,OAAO;AAAA,EAC9B,WAAW,EAAE,QAAQ;AAAA,EACrB,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,EAAE,SAAS;AAAA,EACrD,WAAW,EAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,WAAW,EAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,YAAY,EACT,OAAO;AAAA,IACN,eAAe,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,GAAG,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS;AAAA,IAC9F,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,GAAG,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS;AAAA,EACjF,CAAC,EACA,SAAS,EACT,SAAS,kHAAkH;AAChI,CAAC;AAEM,MAAM,UAAU,2BAA2B;AAAA,EAChD,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,oBAAoB,8BAA8B,mBAAmB;AAAA,EACrE,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,gBAAgB,EAAE,OAAO;AAAA,MACvB,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS;AAAA,MAC/B,WAAW,EACR,QAAQ,EACR,SAAS,iHAAiH;AAAA,IAC/H,CAAC;AAAA,IACD,aACE;AAAA,EACJ;AAAA,EACA,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,aACE;AAAA,EACJ;AAAA,EACA,KAAK;AAAA,IACH,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAAA,IAC1C,gBAAgB;AAAA,IAChB,aACE;AAAA,EACJ;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { StoreEditPage } from "../../../../components/StoreEditPage.js";
|
|
3
|
+
function EcommerceStoreEditPage({ params }) {
|
|
4
|
+
return /* @__PURE__ */ jsx(StoreEditPage, { storeId: params?.id });
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
EcommerceStoreEditPage as default
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=page.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/ecommerce/backend/config/ecommerce/%5Bid%5D/page.tsx"],
|
|
4
|
+
"sourcesContent": ["import { StoreEditPage } from '../../../../components/StoreEditPage'\n\nexport default function EcommerceStoreEditPage({ params }: { params?: { id?: string } }) {\n return <StoreEditPage storeId={params?.id} />\n}\n"],
|
|
5
|
+
"mappings": "AAGS;AAHT,SAAS,qBAAqB;AAEf,SAAR,uBAAwC,EAAE,OAAO,GAAiC;AACvF,SAAO,oBAAC,iBAAc,SAAS,QAAQ,IAAI;AAC7C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const metadata = {
|
|
2
|
+
requireAuth: true,
|
|
3
|
+
requireFeatures: ["ecommerce.stores.view"],
|
|
4
|
+
navHidden: true,
|
|
5
|
+
pageTitle: "Store",
|
|
6
|
+
pageTitleKey: "ecommerce.backend.store.entityType",
|
|
7
|
+
pageContext: "settings",
|
|
8
|
+
breadcrumb: [
|
|
9
|
+
{ label: "Stores", labelKey: "ecommerce.module.title", href: "/backend/config/ecommerce" },
|
|
10
|
+
{ label: "Store", labelKey: "ecommerce.backend.store.entityType" }
|
|
11
|
+
]
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
metadata
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=page.meta.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../src/modules/ecommerce/backend/config/ecommerce/%5Bid%5D/page.meta.ts"],
|
|
4
|
+
"sourcesContent": ["export const metadata = {\n requireAuth: true,\n requireFeatures: ['ecommerce.stores.view'],\n navHidden: true,\n pageTitle: 'Store',\n pageTitleKey: 'ecommerce.backend.store.entityType',\n pageContext: 'settings' as const,\n breadcrumb: [\n { label: 'Stores', labelKey: 'ecommerce.module.title', href: '/backend/config/ecommerce' },\n { label: 'Store', labelKey: 'ecommerce.backend.store.entityType' },\n ],\n} as const\n"],
|
|
5
|
+
"mappings": "AAAO,MAAM,WAAW;AAAA,EACtB,aAAa;AAAA,EACb,iBAAiB,CAAC,uBAAuB;AAAA,EACzC,WAAW;AAAA,EACX,WAAW;AAAA,EACX,cAAc;AAAA,EACd,aAAa;AAAA,EACb,YAAY;AAAA,IACV,EAAE,OAAO,UAAU,UAAU,0BAA0B,MAAM,4BAA4B;AAAA,IACzF,EAAE,OAAO,SAAS,UAAU,qCAAqC;AAAA,EACnE;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { StoreListPage } from "../../../components/StoreListPage.js";
|
|
3
|
+
function EcommerceStoresPage() {
|
|
4
|
+
return /* @__PURE__ */ jsx(StoreListPage, {});
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
EcommerceStoresPage as default
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=page.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/modules/ecommerce/backend/config/ecommerce/page.tsx"],
|
|
4
|
+
"sourcesContent": ["import { StoreListPage } from '../../../components/StoreListPage'\n\nexport default function EcommerceStoresPage() {\n return <StoreListPage />\n}\n"],
|
|
5
|
+
"mappings": "AAGS;AAHT,SAAS,qBAAqB;AAEf,SAAR,sBAAuC;AAC5C,SAAO,oBAAC,iBAAc;AACxB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|