@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/catalog/lib/omnibusCache.ts"],
|
|
4
|
+
"sourcesContent": ["import { runWithCacheTenant, type CacheStrategy } from '@open-mercato/cache'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nexport const OMNIBUS_CACHE_TTL_MS = 5 * 60 * 1000\n\nconst OMNIBUS_CACHE_PREFIX = 'catalog:omnibus'\n\nconst logger = createLogger('catalog')\n\nexport type OmnibusCacheScope = {\n tenantId: string\n organizationId: string\n}\n\nexport type OmnibusCacheTargets = {\n productId?: string | null\n variantId?: string | null\n offerId?: string | null\n}\n\nexport type OmnibusInvalidationTarget = OmnibusCacheScope & OmnibusCacheTargets\n\ntype ContainerLike = { resolve: <T = unknown>(name: string) => T }\n\nexport function resolveOmnibusCache(container: ContainerLike | null | undefined): CacheStrategy | null {\n if (!container) return null\n try {\n return container.resolve<CacheStrategy>('cache') ?? null\n } catch {\n return null\n }\n}\n\nexport function omnibusTenantWideTag(tenantId: string): string {\n return `${OMNIBUS_CACHE_PREFIX}:${tenantId}`\n}\n\nexport function omnibusTenantTag(scope: OmnibusCacheScope): string {\n return `${OMNIBUS_CACHE_PREFIX}:${scope.tenantId}:${scope.organizationId}`\n}\n\nexport function omnibusTargetTags(scope: OmnibusCacheScope, targets: OmnibusCacheTargets): string[] {\n const base = omnibusTenantTag(scope)\n const tags: string[] = []\n if (targets.productId) tags.push(`${base}:product:${targets.productId}`)\n if (targets.variantId) tags.push(`${base}:variant:${targets.variantId}`)\n if (targets.offerId) tags.push(`${base}:offer:${targets.offerId}`)\n return tags\n}\n\nexport function buildOmnibusCacheTags(scope: OmnibusCacheScope, targets: OmnibusCacheTargets): string[] {\n return [omnibusTenantWideTag(scope.tenantId), omnibusTenantTag(scope), ...omnibusTargetTags(scope, targets)]\n}\n\nexport function buildOmnibusCacheKey(kind: string, parts: Array<string | number | null | undefined>): string {\n return [OMNIBUS_CACHE_PREFIX, 'v1', kind, ...parts.map((part) => (part === null || part === undefined ? '-' : String(part)))].join(':')\n}\n\nexport async function readOmnibusCache<T>(cache: CacheStrategy | null, tenantId: string, key: string): Promise<T | null> {\n if (!cache) return null\n try {\n const value = await runWithCacheTenant(tenantId, () => cache.get(key))\n return value === null || value === undefined ? null : (value as T)\n } catch {\n return null\n }\n}\n\nexport async function writeOmnibusCache(\n cache: CacheStrategy | null,\n tenantId: string,\n key: string,\n value: unknown,\n tags: string[],\n): Promise<void> {\n if (!cache) return\n try {\n await runWithCacheTenant(tenantId, () => cache.set(key, value, { ttl: OMNIBUS_CACHE_TTL_MS, tags }))\n } catch {}\n}\n\nexport async function invalidateOmnibusCache(\n cache: CacheStrategy | null | undefined,\n targets: OmnibusInvalidationTarget[],\n): Promise<void> {\n if (!cache || !targets.length) return\n const tagsByTenant = new Map<string, Set<string>>()\n for (const target of targets) {\n const tags = omnibusTargetTags(target, target)\n if (!tags.length) continue\n const bucket = tagsByTenant.get(target.tenantId) ?? new Set<string>()\n for (const tag of tags) bucket.add(tag)\n tagsByTenant.set(target.tenantId, bucket)\n }\n for (const [tenantId, tags] of tagsByTenant) {\n try {\n await runWithCacheTenant(tenantId, () => cache.deleteByTags(Array.from(tags)))\n } catch (err) {\n logger.warn('[internal] catalog omnibus cache invalidation failed', { tenantId, err })\n }\n }\n}\n\nexport async function invalidateOmnibusTenantCache(cache: CacheStrategy | null | undefined, tenantId: string): Promise<void> {\n if (!cache) return\n try {\n await runWithCacheTenant(tenantId, () => cache.deleteByTags([omnibusTenantWideTag(tenantId)]))\n } catch (err) {\n logger.warn('[internal] catalog omnibus tenant cache invalidation failed', { tenantId, err })\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,0BAA8C;AACvD,SAAS,oBAAoB;AAEtB,MAAM,uBAAuB,IAAI,KAAK;AAE7C,MAAM,uBAAuB;AAE7B,MAAM,SAAS,aAAa,SAAS;AAiB9B,SAAS,oBAAoB,WAAmE;AACrG,MAAI,CAAC,UAAW,QAAO;AACvB,MAAI;AACF,WAAO,UAAU,QAAuB,OAAO,KAAK;AAAA,EACtD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,qBAAqB,UAA0B;AAC7D,SAAO,GAAG,oBAAoB,IAAI,QAAQ;AAC5C;AAEO,SAAS,iBAAiB,OAAkC;AACjE,SAAO,GAAG,oBAAoB,IAAI,MAAM,QAAQ,IAAI,MAAM,cAAc;AAC1E;AAEO,SAAS,kBAAkB,OAA0B,SAAwC;AAClG,QAAM,OAAO,iBAAiB,KAAK;AACnC,QAAM,OAAiB,CAAC;AACxB,MAAI,QAAQ,UAAW,MAAK,KAAK,GAAG,IAAI,YAAY,QAAQ,SAAS,EAAE;AACvE,MAAI,QAAQ,UAAW,MAAK,KAAK,GAAG,IAAI,YAAY,QAAQ,SAAS,EAAE;AACvE,MAAI,QAAQ,QAAS,MAAK,KAAK,GAAG,IAAI,UAAU,QAAQ,OAAO,EAAE;AACjE,SAAO;AACT;AAEO,SAAS,sBAAsB,OAA0B,SAAwC;AACtG,SAAO,CAAC,qBAAqB,MAAM,QAAQ,GAAG,iBAAiB,KAAK,GAAG,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,CAAC;AAAA,IACvF;AAAA,EACF;AACF;AAEA,eAAsB,6BAA6B,OAAyC,UAAiC;AAC3H,MAAI,CAAC,MAAO;AACZ,MAAI;AACF,UAAM,mBAAmB,UAAU,MAAM,MAAM,aAAa,CAAC,qBAAqB,QAAQ,CAAC,CAAC,CAAC;AAAA,EAC/F,SAAS,KAAK;AACZ,WAAO,KAAK,+DAA+D,EAAE,UAAU,IAAI,CAAC;AAAA,EAC9F;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { omnibusConfigSchema } from "./omnibusTypes.js";
|
|
2
|
+
function parseStoredOmnibusConfig(raw) {
|
|
3
|
+
if (raw === null || raw === void 0) return null;
|
|
4
|
+
const parsed = omnibusConfigSchema.safeParse(raw);
|
|
5
|
+
return parsed.success ? parsed.data : null;
|
|
6
|
+
}
|
|
7
|
+
function buildOmnibusFieldErrors(issues) {
|
|
8
|
+
const fieldErrors = {};
|
|
9
|
+
for (const issue of issues) {
|
|
10
|
+
const basePath = issue.path.map((segment) => String(segment)).join(".");
|
|
11
|
+
const keys = issue.code === "unrecognized_keys" ? issue.keys : null;
|
|
12
|
+
const paths = keys ? keys.map((key) => basePath ? `${basePath}.${key}` : key) : [basePath || "_root"];
|
|
13
|
+
for (const path of paths) {
|
|
14
|
+
const bucket = fieldErrors[path] ?? [];
|
|
15
|
+
bucket.push(keys ? "omnibus_field_not_supported" : issue.message);
|
|
16
|
+
fieldErrors[path] = bucket;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return fieldErrors;
|
|
20
|
+
}
|
|
21
|
+
function invalidOmnibusConfig(fieldErrors) {
|
|
22
|
+
return { ok: false, status: 400, body: { error: "Invalid config", details: { fieldErrors } } };
|
|
23
|
+
}
|
|
24
|
+
function mergeOmnibusConfig(existing, patch) {
|
|
25
|
+
const next = { ...existing ?? {} };
|
|
26
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
27
|
+
if (value === void 0 || key === "backfillCoverage") continue;
|
|
28
|
+
if (value === null) {
|
|
29
|
+
delete next[key];
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
next[key] = value;
|
|
33
|
+
}
|
|
34
|
+
return omnibusConfigSchema.parse(next);
|
|
35
|
+
}
|
|
36
|
+
function listInScopeOmnibusChannels(config) {
|
|
37
|
+
const enabledCountries = new Set(config.enabledCountryCodes);
|
|
38
|
+
return Object.entries(config.channels).filter(([, channel]) => Boolean(channel.countryCode && enabledCountries.has(channel.countryCode))).map(([channelId]) => channelId).sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
|
|
39
|
+
}
|
|
40
|
+
function evaluateOmnibusConfig(config) {
|
|
41
|
+
if (!config.enabled) return { ok: true, config };
|
|
42
|
+
const inScope = listInScopeOmnibusChannels(config);
|
|
43
|
+
if (!config.defaultPresentedPriceKindId && inScope.length === 0) {
|
|
44
|
+
return invalidOmnibusConfig({ defaultPresentedPriceKindId: ["omnibus_presented_price_kind_required"] });
|
|
45
|
+
}
|
|
46
|
+
const uncovered = inScope.filter((channelId) => !config.backfillCoverage[channelId]);
|
|
47
|
+
if (uncovered.length > 0) {
|
|
48
|
+
return {
|
|
49
|
+
ok: false,
|
|
50
|
+
status: 422,
|
|
51
|
+
body: { field: "enabled", error: "backfill_required_before_enable", channels: uncovered }
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return { ok: true, config };
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
buildOmnibusFieldErrors,
|
|
58
|
+
evaluateOmnibusConfig,
|
|
59
|
+
invalidOmnibusConfig,
|
|
60
|
+
listInScopeOmnibusChannels,
|
|
61
|
+
mergeOmnibusConfig,
|
|
62
|
+
parseStoredOmnibusConfig
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=omnibusConfig.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/catalog/lib/omnibusConfig.ts"],
|
|
4
|
+
"sourcesContent": ["import type { z } from 'zod'\nimport type { OmnibusConfigPatch } from '../data/validators'\nimport { omnibusConfigSchema, type OmnibusConfig } from './omnibusTypes'\n\nexport type OmnibusConfigFieldErrors = Record<string, string[]>\n\nexport type OmnibusConfigEvaluation =\n | { ok: true; config: OmnibusConfig }\n | { ok: false; status: 400; body: { error: string; details: { fieldErrors: OmnibusConfigFieldErrors } } }\n | { ok: false; status: 422; body: { field: 'enabled'; error: 'backfill_required_before_enable'; channels: string[] } }\n\nexport function parseStoredOmnibusConfig(raw: unknown): OmnibusConfig | null {\n if (raw === null || raw === undefined) return null\n const parsed = omnibusConfigSchema.safeParse(raw)\n return parsed.success ? parsed.data : null\n}\n\nexport function buildOmnibusFieldErrors(issues: z.core.$ZodIssue[]): OmnibusConfigFieldErrors {\n const fieldErrors: OmnibusConfigFieldErrors = {}\n for (const issue of issues) {\n const basePath = issue.path.map((segment) => String(segment)).join('.')\n const keys = issue.code === 'unrecognized_keys' ? issue.keys : null\n const paths = keys ? keys.map((key) => (basePath ? `${basePath}.${key}` : key)) : [basePath || '_root']\n for (const path of paths) {\n const bucket = fieldErrors[path] ?? []\n bucket.push(keys ? 'omnibus_field_not_supported' : issue.message)\n fieldErrors[path] = bucket\n }\n }\n return fieldErrors\n}\n\nexport function invalidOmnibusConfig(fieldErrors: OmnibusConfigFieldErrors): OmnibusConfigEvaluation {\n return { ok: false, status: 400, body: { error: 'Invalid config', details: { fieldErrors } } }\n}\n\nexport function mergeOmnibusConfig(existing: OmnibusConfig | null, patch: OmnibusConfigPatch): OmnibusConfig {\n const next: Record<string, unknown> = { ...(existing ?? {}) }\n for (const [key, value] of Object.entries(patch)) {\n if (value === undefined || key === 'backfillCoverage') continue\n if (value === null) {\n delete next[key]\n continue\n }\n next[key] = value\n }\n return omnibusConfigSchema.parse(next)\n}\n\nexport function listInScopeOmnibusChannels(config: OmnibusConfig): string[] {\n const enabledCountries = new Set(config.enabledCountryCodes)\n return Object.entries(config.channels)\n .filter(([, channel]) => Boolean(channel.countryCode && enabledCountries.has(channel.countryCode)))\n .map(([channelId]) => channelId)\n .sort((left, right) => (left < right ? -1 : left > right ? 1 : 0))\n}\n\nexport function evaluateOmnibusConfig(config: OmnibusConfig): OmnibusConfigEvaluation {\n if (!config.enabled) return { ok: true, config }\n const inScope = listInScopeOmnibusChannels(config)\n if (!config.defaultPresentedPriceKindId && inScope.length === 0) {\n return invalidOmnibusConfig({ defaultPresentedPriceKindId: ['omnibus_presented_price_kind_required'] })\n }\n const uncovered = inScope.filter((channelId) => !config.backfillCoverage[channelId])\n if (uncovered.length > 0) {\n return {\n ok: false,\n status: 422,\n body: { field: 'enabled', error: 'backfill_required_before_enable', channels: uncovered },\n }\n }\n return { ok: true, config }\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,2BAA+C;AASjD,SAAS,yBAAyB,KAAoC;AAC3E,MAAI,QAAQ,QAAQ,QAAQ,OAAW,QAAO;AAC9C,QAAM,SAAS,oBAAoB,UAAU,GAAG;AAChD,SAAO,OAAO,UAAU,OAAO,OAAO;AACxC;AAEO,SAAS,wBAAwB,QAAsD;AAC5F,QAAM,cAAwC,CAAC;AAC/C,aAAW,SAAS,QAAQ;AAC1B,UAAM,WAAW,MAAM,KAAK,IAAI,CAAC,YAAY,OAAO,OAAO,CAAC,EAAE,KAAK,GAAG;AACtE,UAAM,OAAO,MAAM,SAAS,sBAAsB,MAAM,OAAO;AAC/D,UAAM,QAAQ,OAAO,KAAK,IAAI,CAAC,QAAS,WAAW,GAAG,QAAQ,IAAI,GAAG,KAAK,GAAI,IAAI,CAAC,YAAY,OAAO;AACtG,eAAW,QAAQ,OAAO;AACxB,YAAM,SAAS,YAAY,IAAI,KAAK,CAAC;AACrC,aAAO,KAAK,OAAO,gCAAgC,MAAM,OAAO;AAChE,kBAAY,IAAI,IAAI;AAAA,IACtB;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,qBAAqB,aAAgE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U;AAAA,IAC1F;AAAA,EACF;AACA,SAAO,EAAE,IAAI,MAAM,OAAO;AAC5B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { sql } from "kysely";
|
|
2
|
+
import { OMNIBUS_PRICE_REMOVING_UNDO_COMMAND } from "./omnibusTypes.js";
|
|
3
|
+
const OMNIBUS_IN_WINDOW_LIMIT = 1e3;
|
|
4
|
+
const SCOPE_COLUMNS = {
|
|
5
|
+
product_id: sql.ref("h.product_id"),
|
|
6
|
+
variant_id: sql.ref("h.variant_id"),
|
|
7
|
+
offer_id: sql.ref("h.offer_id")
|
|
8
|
+
};
|
|
9
|
+
const SCOPE_LEVEL_CLAUSES = {
|
|
10
|
+
product_id: sql`AND h.variant_id IS NULL`,
|
|
11
|
+
variant_id: sql``,
|
|
12
|
+
offer_id: sql``
|
|
13
|
+
};
|
|
14
|
+
const OBSERVATION_CLAUSE = sql`AND h.change_type <> 'delete'
|
|
15
|
+
AND NOT (h.change_type = 'undo' AND h.metadata->>'undoneCommand' = ${OMNIBUS_PRICE_REMOVING_UNDO_COMMAND})`;
|
|
16
|
+
const NOT_ENDED_BEFORE_WINDOW_CLAUSE = sql`AND NOT EXISTS (
|
|
17
|
+
SELECT 1 FROM catalog_price_history_entries ended
|
|
18
|
+
WHERE ended.tenant_id = h.tenant_id
|
|
19
|
+
AND ended.organization_id = h.organization_id
|
|
20
|
+
AND ended.price_id = h.price_id
|
|
21
|
+
AND ended.recorded_at > h.recorded_at
|
|
22
|
+
AND ended.recorded_at <= w.window_start
|
|
23
|
+
AND (
|
|
24
|
+
ended.change_type = 'delete'
|
|
25
|
+
OR (ended.change_type = 'undo' AND ended.metadata->>'undoneCommand' = ${OMNIBUS_PRICE_REMOVING_UNDO_COMMAND})
|
|
26
|
+
)
|
|
27
|
+
)`;
|
|
28
|
+
function lookupGroupKey(lookup) {
|
|
29
|
+
return `${lookup.scopeColumn}|${lookup.channelId ? "channel" : "any"}`;
|
|
30
|
+
}
|
|
31
|
+
function kyselyFor(em) {
|
|
32
|
+
return em.fork().getKysely();
|
|
33
|
+
}
|
|
34
|
+
async function runWindowGroup(em, scopeColumn, withChannel, lookups) {
|
|
35
|
+
const scopeRef = SCOPE_COLUMNS[scopeColumn];
|
|
36
|
+
const scopeLevelClause = SCOPE_LEVEL_CLAUSES[scopeColumn];
|
|
37
|
+
const channelClause = withChannel ? sql`AND (h.channel_id = w.channel_id OR h.channel_id IS NULL)` : sql``;
|
|
38
|
+
const tenantIds = lookups.map((lookup) => lookup.tenantId);
|
|
39
|
+
const organizationIds = lookups.map((lookup) => lookup.organizationId);
|
|
40
|
+
const scopeIds = lookups.map((lookup) => lookup.scopeId);
|
|
41
|
+
const priceKindIds = lookups.map((lookup) => lookup.priceKindId);
|
|
42
|
+
const currencyCodes = lookups.map((lookup) => lookup.currencyCode);
|
|
43
|
+
const channelIds = lookups.map((lookup) => lookup.channelId);
|
|
44
|
+
const windowStarts = lookups.map((lookup) => lookup.windowStart.toISOString());
|
|
45
|
+
const windowEnds = lookups.map((lookup) => lookup.windowEnd.toISOString());
|
|
46
|
+
const query = sql`
|
|
47
|
+
WITH w AS (
|
|
48
|
+
SELECT * FROM unnest(
|
|
49
|
+
${tenantIds}::uuid[],
|
|
50
|
+
${organizationIds}::uuid[],
|
|
51
|
+
${scopeIds}::uuid[],
|
|
52
|
+
${priceKindIds}::uuid[],
|
|
53
|
+
${currencyCodes}::text[],
|
|
54
|
+
${channelIds}::uuid[],
|
|
55
|
+
${windowStarts}::timestamptz[],
|
|
56
|
+
${windowEnds}::timestamptz[]
|
|
57
|
+
) WITH ORDINALITY AS t(tenant_id, organization_id, scope_id, price_kind_id, currency_code, channel_id, window_start, window_end, ord)
|
|
58
|
+
)
|
|
59
|
+
SELECT w.ord, 'baseline' AS part, baseline.id
|
|
60
|
+
FROM w
|
|
61
|
+
CROSS JOIN LATERAL (
|
|
62
|
+
SELECT h.id FROM catalog_price_history_entries h
|
|
63
|
+
WHERE h.tenant_id = w.tenant_id
|
|
64
|
+
AND h.organization_id = w.organization_id
|
|
65
|
+
AND ${scopeRef} = w.scope_id
|
|
66
|
+
${scopeLevelClause}
|
|
67
|
+
${channelClause}
|
|
68
|
+
AND h.price_kind_id = w.price_kind_id
|
|
69
|
+
AND h.currency_code = w.currency_code
|
|
70
|
+
${OBSERVATION_CLAUSE}
|
|
71
|
+
AND h.recorded_at <= w.window_start
|
|
72
|
+
${NOT_ENDED_BEFORE_WINDOW_CLAUSE}
|
|
73
|
+
ORDER BY h.recorded_at DESC, h.id DESC
|
|
74
|
+
LIMIT 1
|
|
75
|
+
) baseline
|
|
76
|
+
UNION ALL
|
|
77
|
+
SELECT w.ord, 'window' AS part, in_window.id
|
|
78
|
+
FROM w
|
|
79
|
+
CROSS JOIN LATERAL (
|
|
80
|
+
SELECT h.id FROM catalog_price_history_entries h
|
|
81
|
+
WHERE h.tenant_id = w.tenant_id
|
|
82
|
+
AND h.organization_id = w.organization_id
|
|
83
|
+
AND ${scopeRef} = w.scope_id
|
|
84
|
+
${scopeLevelClause}
|
|
85
|
+
${channelClause}
|
|
86
|
+
AND h.price_kind_id = w.price_kind_id
|
|
87
|
+
AND h.currency_code = w.currency_code
|
|
88
|
+
${OBSERVATION_CLAUSE}
|
|
89
|
+
AND h.recorded_at > w.window_start
|
|
90
|
+
AND h.recorded_at <= w.window_end
|
|
91
|
+
ORDER BY h.recorded_at DESC, h.id DESC
|
|
92
|
+
LIMIT ${OMNIBUS_IN_WINDOW_LIMIT}
|
|
93
|
+
) in_window
|
|
94
|
+
`;
|
|
95
|
+
const result = await query.execute(kyselyFor(em));
|
|
96
|
+
return result.rows;
|
|
97
|
+
}
|
|
98
|
+
async function fetchOmnibusWindowIds(em, lookups) {
|
|
99
|
+
const results = lookups.map(() => ({ baselineId: null, inWindowIds: [] }));
|
|
100
|
+
const groups = /* @__PURE__ */ new Map();
|
|
101
|
+
lookups.forEach((lookup, index) => {
|
|
102
|
+
const key = lookupGroupKey(lookup);
|
|
103
|
+
const bucket = groups.get(key) ?? [];
|
|
104
|
+
bucket.push(index);
|
|
105
|
+
groups.set(key, bucket);
|
|
106
|
+
});
|
|
107
|
+
for (const indexes of groups.values()) {
|
|
108
|
+
const groupLookups = indexes.map((index) => lookups[index]);
|
|
109
|
+
const first = groupLookups[0];
|
|
110
|
+
const rows = await runWindowGroup(em, first.scopeColumn, Boolean(first.channelId), groupLookups);
|
|
111
|
+
for (const row of rows) {
|
|
112
|
+
const target = results[indexes[Number(row.ord) - 1]];
|
|
113
|
+
if (!target) continue;
|
|
114
|
+
if (row.part === "baseline") target.baselineId = row.id;
|
|
115
|
+
else target.inWindowIds.push(row.id);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return results;
|
|
119
|
+
}
|
|
120
|
+
async function fetchOmnibusFirstOfferIds(em, lookups) {
|
|
121
|
+
if (!lookups.length) return [];
|
|
122
|
+
const query = sql`
|
|
123
|
+
WITH w AS (
|
|
124
|
+
SELECT * FROM unnest(
|
|
125
|
+
${lookups.map((lookup) => lookup.tenantId)}::uuid[],
|
|
126
|
+
${lookups.map((lookup) => lookup.organizationId)}::uuid[],
|
|
127
|
+
${lookups.map((lookup) => lookup.offerId)}::uuid[],
|
|
128
|
+
${lookups.map((lookup) => lookup.priceKindId)}::uuid[],
|
|
129
|
+
${lookups.map((lookup) => lookup.currencyCode)}::text[],
|
|
130
|
+
${lookups.map((lookup) => lookup.channelId)}::uuid[]
|
|
131
|
+
) WITH ORDINALITY AS t(tenant_id, organization_id, offer_id, price_kind_id, currency_code, channel_id, ord)
|
|
132
|
+
)
|
|
133
|
+
SELECT w.ord, first_offer.id
|
|
134
|
+
FROM w
|
|
135
|
+
CROSS JOIN LATERAL (
|
|
136
|
+
SELECT h.id FROM catalog_price_history_entries h
|
|
137
|
+
WHERE h.tenant_id = w.tenant_id
|
|
138
|
+
AND h.organization_id = w.organization_id
|
|
139
|
+
AND h.offer_id = w.offer_id
|
|
140
|
+
AND h.price_kind_id = w.price_kind_id
|
|
141
|
+
AND h.currency_code = w.currency_code
|
|
142
|
+
AND (h.channel_id = w.channel_id OR h.channel_id IS NULL)
|
|
143
|
+
${OBSERVATION_CLAUSE}
|
|
144
|
+
ORDER BY h.recorded_at ASC, h.id ASC
|
|
145
|
+
LIMIT 1
|
|
146
|
+
) first_offer
|
|
147
|
+
`;
|
|
148
|
+
const result = await query.execute(kyselyFor(em));
|
|
149
|
+
const ids = lookups.map(() => null);
|
|
150
|
+
for (const row of result.rows) {
|
|
151
|
+
const index = Number(row.ord) - 1;
|
|
152
|
+
if (index >= 0 && index < ids.length) ids[index] = row.id;
|
|
153
|
+
}
|
|
154
|
+
return ids;
|
|
155
|
+
}
|
|
156
|
+
async function fetchOmnibusLatestPriceEntryIds(em, lookups) {
|
|
157
|
+
if (!lookups.length) return [];
|
|
158
|
+
const query = sql`
|
|
159
|
+
WITH w AS (
|
|
160
|
+
SELECT * FROM unnest(
|
|
161
|
+
${lookups.map((lookup) => lookup.tenantId)}::uuid[],
|
|
162
|
+
${lookups.map((lookup) => lookup.organizationId)}::uuid[],
|
|
163
|
+
${lookups.map((lookup) => lookup.priceId)}::uuid[]
|
|
164
|
+
) WITH ORDINALITY AS t(tenant_id, organization_id, price_id, ord)
|
|
165
|
+
)
|
|
166
|
+
SELECT w.ord, latest.id
|
|
167
|
+
FROM w
|
|
168
|
+
CROSS JOIN LATERAL (
|
|
169
|
+
SELECT h.id FROM catalog_price_history_entries h
|
|
170
|
+
WHERE h.tenant_id = w.tenant_id
|
|
171
|
+
AND h.organization_id = w.organization_id
|
|
172
|
+
AND h.price_id = w.price_id
|
|
173
|
+
ORDER BY h.recorded_at DESC, h.id DESC
|
|
174
|
+
LIMIT 1
|
|
175
|
+
) latest
|
|
176
|
+
`;
|
|
177
|
+
const result = await query.execute(kyselyFor(em));
|
|
178
|
+
const ids = lookups.map(() => null);
|
|
179
|
+
for (const row of result.rows) {
|
|
180
|
+
const index = Number(row.ord) - 1;
|
|
181
|
+
if (index >= 0 && index < ids.length) ids[index] = row.id;
|
|
182
|
+
}
|
|
183
|
+
return ids;
|
|
184
|
+
}
|
|
185
|
+
export {
|
|
186
|
+
OMNIBUS_IN_WINDOW_LIMIT,
|
|
187
|
+
fetchOmnibusFirstOfferIds,
|
|
188
|
+
fetchOmnibusLatestPriceEntryIds,
|
|
189
|
+
fetchOmnibusWindowIds
|
|
190
|
+
};
|
|
191
|
+
//# sourceMappingURL=omnibusHistoryQueries.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/catalog/lib/omnibusHistoryQueries.ts"],
|
|
4
|
+
"sourcesContent": ["import { sql, type RawBuilder } from 'kysely'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { OMNIBUS_PRICE_REMOVING_UNDO_COMMAND } from './omnibusTypes'\n\nexport const OMNIBUS_IN_WINDOW_LIMIT = 1000\n\nexport type OmnibusScopeColumn = 'product_id' | 'variant_id' | 'offer_id'\n\nexport type OmnibusWindowLookup = {\n tenantId: string\n organizationId: string\n scopeColumn: OmnibusScopeColumn\n scopeId: string\n priceKindId: string\n currencyCode: string\n channelId: string | null\n windowStart: Date\n windowEnd: Date\n}\n\nexport type OmnibusWindowLookupResult = {\n baselineId: string | null\n inWindowIds: string[]\n}\n\nexport type OmnibusFirstOfferLookup = {\n tenantId: string\n organizationId: string\n offerId: string\n priceKindId: string\n currencyCode: string\n channelId: string | null\n}\n\ntype LookupRow = { ord: string | number; part: string; id: string }\n\ntype FirstOfferRow = { ord: string | number; id: string }\n\nconst SCOPE_COLUMNS: Record<OmnibusScopeColumn, RawBuilder<unknown>> = {\n product_id: sql.ref('h.product_id'),\n variant_id: sql.ref('h.variant_id'),\n offer_id: sql.ref('h.offer_id'),\n}\n\nconst SCOPE_LEVEL_CLAUSES: Record<OmnibusScopeColumn, RawBuilder<unknown>> = {\n product_id: sql`AND h.variant_id IS NULL`,\n variant_id: sql``,\n offer_id: sql``,\n}\n\nconst OBSERVATION_CLAUSE = sql`AND h.change_type <> 'delete'\n AND NOT (h.change_type = 'undo' AND h.metadata->>'undoneCommand' = ${OMNIBUS_PRICE_REMOVING_UNDO_COMMAND})`\n\nconst NOT_ENDED_BEFORE_WINDOW_CLAUSE = sql`AND NOT EXISTS (\n SELECT 1 FROM catalog_price_history_entries ended\n WHERE ended.tenant_id = h.tenant_id\n AND ended.organization_id = h.organization_id\n AND ended.price_id = h.price_id\n AND ended.recorded_at > h.recorded_at\n AND ended.recorded_at <= w.window_start\n AND (\n ended.change_type = 'delete'\n OR (ended.change_type = 'undo' AND ended.metadata->>'undoneCommand' = ${OMNIBUS_PRICE_REMOVING_UNDO_COMMAND})\n )\n )`\n\nfunction lookupGroupKey(lookup: OmnibusWindowLookup): string {\n return `${lookup.scopeColumn}|${lookup.channelId ? 'channel' : 'any'}`\n}\n\nfunction kyselyFor(em: EntityManager) {\n return em.fork().getKysely()\n}\n\nasync function runWindowGroup(\n em: EntityManager,\n scopeColumn: OmnibusScopeColumn,\n withChannel: boolean,\n lookups: OmnibusWindowLookup[],\n): Promise<LookupRow[]> {\n const scopeRef = SCOPE_COLUMNS[scopeColumn]\n const scopeLevelClause = SCOPE_LEVEL_CLAUSES[scopeColumn]\n const channelClause = withChannel ? sql`AND (h.channel_id = w.channel_id OR h.channel_id IS NULL)` : sql``\n const tenantIds = lookups.map((lookup) => lookup.tenantId)\n const organizationIds = lookups.map((lookup) => lookup.organizationId)\n const scopeIds = lookups.map((lookup) => lookup.scopeId)\n const priceKindIds = lookups.map((lookup) => lookup.priceKindId)\n const currencyCodes = lookups.map((lookup) => lookup.currencyCode)\n const channelIds = lookups.map((lookup) => lookup.channelId)\n const windowStarts = lookups.map((lookup) => lookup.windowStart.toISOString())\n const windowEnds = lookups.map((lookup) => lookup.windowEnd.toISOString())\n const query = sql<LookupRow>`\n WITH w AS (\n SELECT * FROM unnest(\n ${tenantIds}::uuid[],\n ${organizationIds}::uuid[],\n ${scopeIds}::uuid[],\n ${priceKindIds}::uuid[],\n ${currencyCodes}::text[],\n ${channelIds}::uuid[],\n ${windowStarts}::timestamptz[],\n ${windowEnds}::timestamptz[]\n ) WITH ORDINALITY AS t(tenant_id, organization_id, scope_id, price_kind_id, currency_code, channel_id, window_start, window_end, ord)\n )\n SELECT w.ord, 'baseline' AS part, baseline.id\n FROM w\n CROSS JOIN LATERAL (\n SELECT h.id FROM catalog_price_history_entries h\n WHERE h.tenant_id = w.tenant_id\n AND h.organization_id = w.organization_id\n AND ${scopeRef} = w.scope_id\n ${scopeLevelClause}\n ${channelClause}\n AND h.price_kind_id = w.price_kind_id\n AND h.currency_code = w.currency_code\n ${OBSERVATION_CLAUSE}\n AND h.recorded_at <= w.window_start\n ${NOT_ENDED_BEFORE_WINDOW_CLAUSE}\n ORDER BY h.recorded_at DESC, h.id DESC\n LIMIT 1\n ) baseline\n UNION ALL\n SELECT w.ord, 'window' AS part, in_window.id\n FROM w\n CROSS JOIN LATERAL (\n SELECT h.id FROM catalog_price_history_entries h\n WHERE h.tenant_id = w.tenant_id\n AND h.organization_id = w.organization_id\n AND ${scopeRef} = w.scope_id\n ${scopeLevelClause}\n ${channelClause}\n AND h.price_kind_id = w.price_kind_id\n AND h.currency_code = w.currency_code\n ${OBSERVATION_CLAUSE}\n AND h.recorded_at > w.window_start\n AND h.recorded_at <= w.window_end\n ORDER BY h.recorded_at DESC, h.id DESC\n LIMIT ${OMNIBUS_IN_WINDOW_LIMIT}\n ) in_window\n `\n const result = await query.execute(kyselyFor(em))\n return result.rows\n}\n\nexport async function fetchOmnibusWindowIds(\n em: EntityManager,\n lookups: OmnibusWindowLookup[],\n): Promise<OmnibusWindowLookupResult[]> {\n const results: OmnibusWindowLookupResult[] = lookups.map(() => ({ baselineId: null, inWindowIds: [] }))\n const groups = new Map<string, number[]>()\n lookups.forEach((lookup, index) => {\n const key = lookupGroupKey(lookup)\n const bucket = groups.get(key) ?? []\n bucket.push(index)\n groups.set(key, bucket)\n })\n for (const indexes of groups.values()) {\n const groupLookups = indexes.map((index) => lookups[index])\n const first = groupLookups[0]\n const rows = await runWindowGroup(em, first.scopeColumn, Boolean(first.channelId), groupLookups)\n for (const row of rows) {\n const target = results[indexes[Number(row.ord) - 1]]\n if (!target) continue\n if (row.part === 'baseline') target.baselineId = row.id\n else target.inWindowIds.push(row.id)\n }\n }\n return results\n}\n\nexport async function fetchOmnibusFirstOfferIds(\n em: EntityManager,\n lookups: OmnibusFirstOfferLookup[],\n): Promise<Array<string | null>> {\n if (!lookups.length) return []\n const query = sql<FirstOfferRow>`\n WITH w AS (\n SELECT * FROM unnest(\n ${lookups.map((lookup) => lookup.tenantId)}::uuid[],\n ${lookups.map((lookup) => lookup.organizationId)}::uuid[],\n ${lookups.map((lookup) => lookup.offerId)}::uuid[],\n ${lookups.map((lookup) => lookup.priceKindId)}::uuid[],\n ${lookups.map((lookup) => lookup.currencyCode)}::text[],\n ${lookups.map((lookup) => lookup.channelId)}::uuid[]\n ) WITH ORDINALITY AS t(tenant_id, organization_id, offer_id, price_kind_id, currency_code, channel_id, ord)\n )\n SELECT w.ord, first_offer.id\n FROM w\n CROSS JOIN LATERAL (\n SELECT h.id FROM catalog_price_history_entries h\n WHERE h.tenant_id = w.tenant_id\n AND h.organization_id = w.organization_id\n AND h.offer_id = w.offer_id\n AND h.price_kind_id = w.price_kind_id\n AND h.currency_code = w.currency_code\n AND (h.channel_id = w.channel_id OR h.channel_id IS NULL)\n ${OBSERVATION_CLAUSE}\n ORDER BY h.recorded_at ASC, h.id ASC\n LIMIT 1\n ) first_offer\n `\n const result = await query.execute(kyselyFor(em))\n const ids: Array<string | null> = lookups.map(() => null)\n for (const row of result.rows) {\n const index = Number(row.ord) - 1\n if (index >= 0 && index < ids.length) ids[index] = row.id\n }\n return ids\n}\n\nexport type OmnibusLatestPriceEntryLookup = {\n tenantId: string\n organizationId: string\n priceId: string\n}\n\nexport async function fetchOmnibusLatestPriceEntryIds(\n em: EntityManager,\n lookups: OmnibusLatestPriceEntryLookup[],\n): Promise<Array<string | null>> {\n if (!lookups.length) return []\n const query = sql<FirstOfferRow>`\n WITH w AS (\n SELECT * FROM unnest(\n ${lookups.map((lookup) => lookup.tenantId)}::uuid[],\n ${lookups.map((lookup) => lookup.organizationId)}::uuid[],\n ${lookups.map((lookup) => lookup.priceId)}::uuid[]\n ) WITH ORDINALITY AS t(tenant_id, organization_id, price_id, ord)\n )\n SELECT w.ord, latest.id\n FROM w\n CROSS JOIN LATERAL (\n SELECT h.id FROM catalog_price_history_entries h\n WHERE h.tenant_id = w.tenant_id\n AND h.organization_id = w.organization_id\n AND h.price_id = w.price_id\n ORDER BY h.recorded_at DESC, h.id DESC\n LIMIT 1\n ) latest\n `\n const result = await query.execute(kyselyFor(em))\n const ids: Array<string | null> = lookups.map(() => null)\n for (const row of result.rows) {\n const index = Number(row.ord) - 1\n if (index >= 0 && index < ids.length) ids[index] = row.id\n }\n return ids\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAA4B;AAErC,SAAS,2CAA2C;AAE7C,MAAM,0BAA0B;AAkCvC,MAAM,gBAAiE;AAAA,EACrE,YAAY,IAAI,IAAI,cAAc;AAAA,EAClC,YAAY,IAAI,IAAI,cAAc;AAAA,EAClC,UAAU,IAAI,IAAI,YAAY;AAChC;AAEA,MAAM,sBAAuE;AAAA,EAC3E,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,UAAU;AACZ;AAEA,MAAM,qBAAqB;AAAA,6EACkD,mCAAmC;AAEhH,MAAM,iCAAiC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sFAS+C,mCAAmC;AAAA;AAAA;AAIzH,SAAS,eAAe,QAAqC;AAC3D,SAAO,GAAG,OAAO,WAAW,IAAI,OAAO,YAAY,YAAY,KAAK;AACtE;AAEA,SAAS,UAAU,IAAmB;AACpC,SAAO,GAAG,KAAK,EAAE,UAAU;AAC7B;AAEA,eAAe,eACb,IAC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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAazC,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAK1B,QAAM,SAAS,MAAM,MAAM,QAAQ,UAAU,EAAE,CAAC;AAChD,QAAM,MAA4B,QAAQ,IAAI,MAAM,IAAI;AACxD,aAAW,OAAO,OAAO,MAAM;AAC7B,UAAM,QAAQ,OAAO,IAAI,GAAG,IAAI;AAChC,QAAI,SAAS,KAAK,QAAQ,IAAI,OAAQ,KAAI,KAAK,IAAI,IAAI;AAAA,EACzD;AACA,SAAO;AACT;AAQA,eAAsB,gCACpB,IACA,SAC+B;AAC/B,MAAI,CAAC,QAAQ,OAAQ,QAAO,CAAC;AAC7B,QAAM,QAAQ;AAAA;AAAA;AAAA,UAGN,QAAQ,IAAI,CAAC,WAAW,OAAO,QAAQ,CAAC;AAAA,UACxC,QAAQ,IAAI,CAAC,WAAW,OAAO,cAAc,CAAC;AAAA,UAC9C,QAAQ,IAAI,CAAC,WAAW,OAAO,OAAO,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAc/C,QAAM,SAAS,MAAM,MAAM,QAAQ,UAAU,EAAE,CAAC;AAChD,QAAM,MAA4B,QAAQ,IAAI,MAAM,IAAI;AACxD,aAAW,OAAO,OAAO,MAAM;AAC7B,UAAM,QAAQ,OAAO,IAAI,GAAG,IAAI;AAChC,QAAI,SAAS,KAAK,QAAQ,IAAI,OAAQ,KAAI,KAAK,IAAI,IAAI;AAAA,EACzD;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { findWithDecryption } from "@open-mercato/shared/lib/encryption/find";
|
|
2
|
+
import { CatalogPriceHistoryEntry } from "../data/entities.js";
|
|
3
|
+
import { fetchOmnibusLatestPriceEntryIds } from "./omnibusHistoryQueries.js";
|
|
4
|
+
import { resolvePriceOfferId } from "./pricing.js";
|
|
5
|
+
function isPromotionPriceKind(price) {
|
|
6
|
+
if (!price || !price.priceKind || typeof price.priceKind === "string") return false;
|
|
7
|
+
return price.priceKind.isPromotion === true;
|
|
8
|
+
}
|
|
9
|
+
function fallbackPresentedEntry(price) {
|
|
10
|
+
return {
|
|
11
|
+
priceId: price.id,
|
|
12
|
+
changeType: "update",
|
|
13
|
+
recordedAt: price.updatedAt ?? price.createdAt ?? /* @__PURE__ */ new Date(),
|
|
14
|
+
startsAt: price.startsAt ?? null,
|
|
15
|
+
offerId: resolvePriceOfferId(price),
|
|
16
|
+
isAnnounced: null
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
async function resolveOmnibusPresentedEntries(em, prices) {
|
|
20
|
+
const entries = /* @__PURE__ */ new Map();
|
|
21
|
+
const unique = /* @__PURE__ */ new Map();
|
|
22
|
+
for (const price of prices) {
|
|
23
|
+
if (price?.id && !unique.has(price.id)) unique.set(price.id, price);
|
|
24
|
+
}
|
|
25
|
+
if (!unique.size) return entries;
|
|
26
|
+
const priced = Array.from(unique.values());
|
|
27
|
+
const ids = await fetchOmnibusLatestPriceEntryIds(
|
|
28
|
+
em,
|
|
29
|
+
priced.map((price) => ({ tenantId: price.tenantId, organizationId: price.organizationId, priceId: price.id }))
|
|
30
|
+
);
|
|
31
|
+
const idsByScope = /* @__PURE__ */ new Map();
|
|
32
|
+
priced.forEach((price, index) => {
|
|
33
|
+
const id = ids[index];
|
|
34
|
+
if (!id) return;
|
|
35
|
+
const key = `${price.tenantId}|${price.organizationId}`;
|
|
36
|
+
const bucket = idsByScope.get(key) ?? { tenantId: price.tenantId, organizationId: price.organizationId, ids: [] };
|
|
37
|
+
bucket.ids.push(id);
|
|
38
|
+
idsByScope.set(key, bucket);
|
|
39
|
+
});
|
|
40
|
+
const rows = /* @__PURE__ */ new Map();
|
|
41
|
+
for (const scope of idsByScope.values()) {
|
|
42
|
+
const found = await findWithDecryption(
|
|
43
|
+
em,
|
|
44
|
+
CatalogPriceHistoryEntry,
|
|
45
|
+
{ id: { $in: scope.ids }, tenantId: scope.tenantId, organizationId: scope.organizationId },
|
|
46
|
+
void 0,
|
|
47
|
+
{ tenantId: scope.tenantId, organizationId: scope.organizationId }
|
|
48
|
+
);
|
|
49
|
+
for (const row of found) rows.set(row.id, row);
|
|
50
|
+
}
|
|
51
|
+
priced.forEach((price, index) => {
|
|
52
|
+
const id = ids[index];
|
|
53
|
+
const row = id ? rows.get(id) : void 0;
|
|
54
|
+
if (!row || row.priceId !== price.id) {
|
|
55
|
+
entries.set(price.id, fallbackPresentedEntry(price));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
entries.set(price.id, {
|
|
59
|
+
priceId: price.id,
|
|
60
|
+
changeType: row.changeType,
|
|
61
|
+
recordedAt: row.recordedAt,
|
|
62
|
+
startsAt: row.startsAt ?? price.startsAt ?? null,
|
|
63
|
+
offerId: row.offerId ?? resolvePriceOfferId(price),
|
|
64
|
+
isAnnounced: row.isAnnounced ?? null
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
return entries;
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
isPromotionPriceKind,
|
|
71
|
+
resolveOmnibusPresentedEntries
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=omnibusPresentedEntry.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/catalog/lib/omnibusPresentedEntry.ts"],
|
|
4
|
+
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { findWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { CatalogPriceHistoryEntry } from '../data/entities'\nimport { fetchOmnibusLatestPriceEntryIds } from './omnibusHistoryQueries'\nimport type { OmnibusPresentedEntry } from './omnibusTypes'\nimport { resolvePriceOfferId, type PriceRow } from './pricing'\n\nexport function isPromotionPriceKind(price: PriceRow | null | undefined): boolean {\n if (!price || !price.priceKind || typeof price.priceKind === 'string') return false\n return price.priceKind.isPromotion === true\n}\n\nfunction fallbackPresentedEntry(price: PriceRow): OmnibusPresentedEntry {\n return {\n priceId: price.id,\n changeType: 'update',\n recordedAt: price.updatedAt ?? price.createdAt ?? new Date(),\n startsAt: price.startsAt ?? null,\n offerId: resolvePriceOfferId(price),\n isAnnounced: null,\n }\n}\n\nexport async function resolveOmnibusPresentedEntries(\n em: EntityManager,\n prices: PriceRow[],\n): Promise<Map<string, OmnibusPresentedEntry>> {\n const entries = new Map<string, OmnibusPresentedEntry>()\n const unique = new Map<string, PriceRow>()\n for (const price of prices) {\n if (price?.id && !unique.has(price.id)) unique.set(price.id, price)\n }\n if (!unique.size) return entries\n const priced = Array.from(unique.values())\n const ids = await fetchOmnibusLatestPriceEntryIds(\n em,\n priced.map((price) => ({ tenantId: price.tenantId, organizationId: price.organizationId, priceId: price.id })),\n )\n const idsByScope = new Map<string, { tenantId: string; organizationId: string; ids: string[] }>()\n priced.forEach((price, index) => {\n const id = ids[index]\n if (!id) return\n const key = `${price.tenantId}|${price.organizationId}`\n const bucket = idsByScope.get(key) ?? { tenantId: price.tenantId, organizationId: price.organizationId, ids: [] }\n bucket.ids.push(id)\n idsByScope.set(key, bucket)\n })\n const rows = new Map<string, CatalogPriceHistoryEntry>()\n for (const scope of idsByScope.values()) {\n const found = await findWithDecryption(\n em,\n CatalogPriceHistoryEntry,\n { id: { $in: scope.ids }, tenantId: scope.tenantId, organizationId: scope.organizationId },\n undefined,\n { tenantId: scope.tenantId, organizationId: scope.organizationId },\n )\n for (const row of found) rows.set(row.id, row)\n }\n priced.forEach((price, index) => {\n const id = ids[index]\n const row = id ? rows.get(id) : undefined\n if (!row || row.priceId !== price.id) {\n entries.set(price.id, fallbackPresentedEntry(price))\n return\n }\n entries.set(price.id, {\n priceId: price.id,\n changeType: row.changeType,\n recordedAt: row.recordedAt,\n startsAt: row.startsAt ?? price.startsAt ?? null,\n offerId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AAK,EAAE,UAAU,MAAM,UAAU,gBAAgB,MAAM,gBAAgB,KAAK,CAAC,EAAE;AAChH,WAAO,IAAI,KAAK,EAAE;AAClB,eAAW,IAAI,KAAK,MAAM;AAAA,EAC5B,CAAC;AACD,QAAM,OAAO,oBAAI,IAAsC;AACvD,aAAW,SAAS,WAAW,OAAO,GAAG;AACvC,UAAM,QAAQ,MAAM;AAAA,MAClB;AAAA,MACA;AAAA,MACA,EAAE,IAAI,EAAE,KAAK,MAAM,IAAI,GAAG,UAAU,MAAM,UAAU,gBAAgB,MAAM,eAAe;AAAA,MACzF;AAAA,MACA,EAAE,UAAU,MAAM,UAAU,gBAAgB,MAAM,eAAe;AAAA,IACnE;AACA,eAAW,OAAO,MAAO,MAAK,IAAI,IAAI,IAAI,GAAG;AAAA,EAC/C;AACA,SAAO,QAAQ,CAAC,OAAO,UAAU;AAC/B,UAAM,KAAK,IAAI,KAAK;AACpB,UAAM,MAAM,KAAK,KAAK,IAAI,EAAE,IAAI;AAChC,QAAI,CAAC,OAAO,IAAI,YAAY,MAAM,IAAI;AACpC,cAAQ,IAAI,MAAM,IAAI,uBAAuB,KAAK,CAAC;AACnD;AAAA,IACF;AACA,YAAQ,IAAI,MAAM,IAAI;AAAA,MACpB,SAAS,MAAM;AAAA,MACf,YAAY,IAAI;AAAA,MAChB,YAAY,IAAI;AAAA,MAChB,UAAU,IAAI,YAAY,MAAM,YAAY;AAAA,MAC5C,SAAS,IAAI,WAAW,oBAAoB,KAAK;AAAA,MACjD,aAAa,IAAI,eAAe;AAAA,IAClC,CAAC;AAAA,EACH,CAAC;AACD,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
2
|
+
import { getTelemetryRuntime } from "@open-mercato/shared/lib/telemetry/runtime";
|
|
3
|
+
import { isPromotionPriceKind, resolveOmnibusPresentedEntries } from "./omnibusPresentedEntry.js";
|
|
4
|
+
import {
|
|
5
|
+
resolvePriceChannelId,
|
|
6
|
+
resolvePriceKindId,
|
|
7
|
+
resolvePriceVariantId,
|
|
8
|
+
selectBestPrice
|
|
9
|
+
} from "./pricing.js";
|
|
10
|
+
const logger = createLogger("catalog");
|
|
11
|
+
async function loadEnabledConfigs(service, tenantId, organizationIds) {
|
|
12
|
+
const configs = await Promise.all(
|
|
13
|
+
organizationIds.map((organizationId) => service.getConfig({ tenantId, organizationId }))
|
|
14
|
+
);
|
|
15
|
+
const enabled = /* @__PURE__ */ new Map();
|
|
16
|
+
organizationIds.forEach((organizationId, index) => {
|
|
17
|
+
const config = configs[index];
|
|
18
|
+
if (config && config.enabled === true) enabled.set(organizationId, config);
|
|
19
|
+
});
|
|
20
|
+
return enabled;
|
|
21
|
+
}
|
|
22
|
+
function selectPresentedPrice(entry, presentedPriceKindId) {
|
|
23
|
+
if (!presentedPriceKindId || presentedPriceKindId === resolvePriceKindId(entry.best)) return entry.best;
|
|
24
|
+
return selectBestPrice(entry.candidates, {
|
|
25
|
+
...entry.context,
|
|
26
|
+
priceKindId: presentedPriceKindId,
|
|
27
|
+
currencyCode: entry.best.currencyCode
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async function attachProductListOmnibusBlocks(params) {
|
|
31
|
+
const { em, container, entries } = params;
|
|
32
|
+
const tenantId = params.tenantId ?? null;
|
|
33
|
+
if (!tenantId || !entries.length) return;
|
|
34
|
+
try {
|
|
35
|
+
const service = container.resolve("catalogOmnibusService");
|
|
36
|
+
const organizationIds = Array.from(new Set(entries.map((entry) => entry.best.organizationId).filter(Boolean)));
|
|
37
|
+
const configs = await loadEnabledConfigs(service, tenantId, organizationIds);
|
|
38
|
+
if (!configs.size) return;
|
|
39
|
+
const enabled = [];
|
|
40
|
+
for (const entry of entries) {
|
|
41
|
+
const config = configs.get(entry.best.organizationId);
|
|
42
|
+
if (!config) continue;
|
|
43
|
+
const channelId = entry.context.channelId ?? resolvePriceChannelId(entry.best) ?? null;
|
|
44
|
+
const presentedPriceKindId = service.resolvePresentedPriceKindId(config, channelId, resolvePriceKindId(entry.best));
|
|
45
|
+
enabled.push({
|
|
46
|
+
...entry,
|
|
47
|
+
config,
|
|
48
|
+
channelId,
|
|
49
|
+
presentedPriceKindId,
|
|
50
|
+
presentedPrice: selectPresentedPrice(entry, presentedPriceKindId)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (!enabled.length) return;
|
|
54
|
+
const presentedEntries = await resolveOmnibusPresentedEntries(
|
|
55
|
+
em,
|
|
56
|
+
enabled.map((entry) => entry.presentedPrice).filter((price) => price !== null)
|
|
57
|
+
);
|
|
58
|
+
const requests = enabled.map((entry) => ({
|
|
59
|
+
context: {
|
|
60
|
+
tenantId,
|
|
61
|
+
organizationId: entry.best.organizationId,
|
|
62
|
+
productId: entry.productId,
|
|
63
|
+
variantId: entry.presentedPrice ? resolvePriceVariantId(entry.presentedPrice) : null,
|
|
64
|
+
offerId: entry.context.offerId ?? null,
|
|
65
|
+
channelId: entry.channelId,
|
|
66
|
+
priceKindId: entry.presentedPriceKindId,
|
|
67
|
+
currencyCode: entry.presentedPrice?.currencyCode ?? entry.best.currencyCode,
|
|
68
|
+
isStorefront: false
|
|
69
|
+
},
|
|
70
|
+
presentedEntry: entry.presentedPrice ? presentedEntries.get(entry.presentedPrice.id) ?? null : null,
|
|
71
|
+
priceKindIsPromotion: isPromotionPriceKind(entry.presentedPrice)
|
|
72
|
+
}));
|
|
73
|
+
const blocks = await service.resolveOmnibusBlocks(em, requests);
|
|
74
|
+
enabled.forEach((entry, index) => {
|
|
75
|
+
const block = blocks[index];
|
|
76
|
+
if (block) entry.item.omnibus = block;
|
|
77
|
+
});
|
|
78
|
+
} catch (err) {
|
|
79
|
+
logger.error("[internal] catalog products omnibus enrichment failed", {
|
|
80
|
+
tenantId,
|
|
81
|
+
productCount: entries.length,
|
|
82
|
+
err
|
|
83
|
+
});
|
|
84
|
+
getTelemetryRuntime()?.reportError(err, {
|
|
85
|
+
module: "catalog",
|
|
86
|
+
code: "catalog.omnibus_list_enrichment_failed",
|
|
87
|
+
attributes: { productCount: entries.length }
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
attachProductListOmnibusBlocks
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=omnibusProductListEnrichment.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/catalog/lib/omnibusProductListEnrichment.ts"],
|
|
4
|
+
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\nimport { getTelemetryRuntime } from '@open-mercato/shared/lib/telemetry/runtime'\nimport type { CatalogOmnibusService } from '../services/catalogOmnibusService'\nimport type { OmnibusBlock, OmnibusConfig, OmnibusResolutionRequest } from './omnibusTypes'\nimport { isPromotionPriceKind, resolveOmnibusPresentedEntries } from './omnibusPresentedEntry'\nimport {\n resolvePriceChannelId,\n resolvePriceKindId,\n resolvePriceVariantId,\n selectBestPrice,\n type PriceRow,\n type PricingContext,\n} from './pricing'\n\nconst logger = createLogger('catalog')\n\nexport type OmnibusProductListEntry = {\n item: { omnibus?: OmnibusBlock }\n productId: string\n candidates: PriceRow[]\n best: PriceRow\n context: PricingContext\n}\n\nexport type AttachProductListOmnibusParams = {\n em: EntityManager\n container: { resolve: <T = unknown>(name: string) => T }\n tenantId: string | null | undefined\n entries: OmnibusProductListEntry[]\n}\n\ntype EnabledEntry = OmnibusProductListEntry & {\n config: OmnibusConfig\n channelId: string | null\n presentedPriceKindId: string | null\n presentedPrice: PriceRow | null\n}\n\nasync function loadEnabledConfigs(\n service: CatalogOmnibusService,\n tenantId: string,\n organizationIds: string[],\n): Promise<Map<string, OmnibusConfig>> {\n const configs = await Promise.all(\n organizationIds.map((organizationId) => service.getConfig({ tenantId, organizationId })),\n )\n const enabled = new Map<string, OmnibusConfig>()\n organizationIds.forEach((organizationId, index) => {\n const config = configs[index]\n if (config && config.enabled === true) enabled.set(organizationId, config)\n })\n return enabled\n}\n\nfunction selectPresentedPrice(entry: OmnibusProductListEntry, presentedPriceKindId: string | null): PriceRow | null {\n if (!presentedPriceKindId || presentedPriceKindId === resolvePriceKindId(entry.best)) return entry.best\n return selectBestPrice(entry.candidates, {\n ...entry.context,\n priceKindId: presentedPriceKindId,\n currencyCode: entry.best.currencyCode,\n })\n}\n\nexport async function attachProductListOmnibusBlocks(params: AttachProductListOmnibusParams): Promise<void> {\n const { em, container, entries } = params\n const tenantId = params.tenantId ?? null\n if (!tenantId || !entries.length) return\n try {\n const service = container.resolve<CatalogOmnibusService>('catalogOmnibusService')\n const organizationIds = Array.from(new Set(entries.map((entry) => entry.best.organizationId).filter(Boolean)))\n const configs = await loadEnabledConfigs(service, tenantId, organizationIds)\n if (!configs.size) return\n const enabled: EnabledEntry[] = []\n for (const entry of entries) {\n const config = configs.get(entry.best.organizationId)\n if (!config) continue\n const channelId = entry.context.channelId ?? resolvePriceChannelId(entry.best) ?? null\n const presentedPriceKindId = service.resolvePresentedPriceKindId(config, channelId, resolvePriceKindId(entry.best))\n enabled.push({\n ...entry,\n config,\n channelId,\n presentedPriceKindId,\n presentedPrice: selectPresentedPrice(entry, presentedPriceKindId),\n })\n }\n if (!enabled.length) return\n const presentedEntries = await resolveOmnibusPresentedEntries(\n em,\n enabled.map((entry) => entry.presentedPrice).filter((price): price is PriceRow => price !== null),\n )\n const requests: OmnibusResolutionRequest[] = enabled.map((entry) => ({\n context: {\n tenantId,\n organizationId: entry.best.organizationId,\n productId: entry.productId,\n variantId: entry.presentedPrice ? resolvePriceVariantId(entry.presentedPrice) : null,\n offerId: entry.context.offerId ?? null,\n channelId: entry.channelId,\n priceKindId: entry.presentedPriceKindId,\n currencyCode: entry.presentedPrice?.currencyCode ?? entry.best.currencyCode,\n isStorefront: false,\n },\n presentedEntry: entry.presentedPrice ? presentedEntries.get(entry.presentedPrice.id) ?? null : null,\n priceKindIsPromotion: isPromotionPriceKind(entry.presentedPrice),\n }))\n const blocks = await service.resolveOmnibusBlocks(em, requests)\n enabled.forEach((entry, index) => {\n const block = blocks[index]\n if (block) entry.item.omnibus = block\n })\n } catch (err) {\n logger.error('[internal] catalog products omnibus enrichment failed', {\n tenantId,\n productCount: entries.length,\n err,\n })\n getTelemetryRuntime()?.reportError(err, {\n module: 'catalog',\n code: 'catalog.omnibus_list_enrichment_failed',\n attributes: { productCount: entries.length },\n })\n }\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AAGpC,SAAS,sBAAsB,sCAAsC;AACrE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP,MAAM,SAAS,aAAa,SAAS;AAwBrC,eAAe,mBACb,SACA,UACA,iBACqC;AACrC,QAAM,UAAU,MAAM,QAAQ;AAAA,IAC5B,gBAAgB,IAAI,CAAC,mBAAmB,QAAQ,UAAU,EAAE,UAAU,eAAe,CAAC,CAAC;AAAA,EACzF;AACA,QAAM,UAAU,oBAAI,IAA2B;AAC/C,kBAAgB,QAAQ,CAAC,gBAAgB,UAAU;AACjD,UAAM,SAAS,QAAQ,KAAK;AAC5B,QAAI,UAAU,OAAO,YAAY,KAAM,SAAQ,IAAI,gBAAgB,MAAM;AAAA,EAC3E,CAAC;AACD,SAAO;AACT;AAEA,SAAS,qBAAqB,OAAgC,sBAAsD;AAClH,MAAI,CAAC,wBAAwB,yBAAyB,mBAAmB,MAAM,IAAI,EAAG,QAAO,MAAM;AACnG,SAAO,gBAAgB,MAAM,YAAY;AAAA,IACvC,GAAG,MAAM;AAAA,IACT,aAAa;AAAA,IACb,cAAc,MAAM,KAAK;AAAA,EAC3B,CAAC;AACH;AAEA,eAAsB,+BAA+B,QAAuD;AAC1G,QAAM,EAAE,IAAI,WAAW,QAAQ,IAAI;AACnC,QAAM,WAAW,O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AChB;AAAA,MACA,gBAAgB,MAAM,iBAAiB,iBAAiB,IAAI,MAAM,eAAe,EAAE,KAAK,OAAO;AAAA,MAC/F,sBAAsB,qBAAqB,MAAM,cAAc;AAAA,IACjE,EAAE;AACF,UAAM,SAAS,MAAM,QAAQ,qBAAqB,IAAI,QAAQ;AAC9D,YAAQ,QAAQ,CAAC,OAAO,UAAU;AAChC,YAAM,QAAQ,OAAO,KAAK;AAC1B,UAAI,MAAO,OAAM,KAAK,UAAU;AAAA,IAClC,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,WAAO,MAAM,yDAAyD;AAAA,MACpE;AAAA,MACA,cAAc,QAAQ;AAAA,MACtB;AAAA,IACF,CAAC;AACD,wBAAoB,GAAG,YAAY,KAAK;AAAA,MACtC,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,YAAY,EAAE,cAAc,QAAQ,OAAO;AAAA,IAC7C,CAAC;AAAA,EACH;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const PRICE_HISTORY_CHANGE_TYPES = ["create", "update", "delete", "undo"];
|
|
3
|
+
const priceHistoryChangeTypeSchema = z.enum(PRICE_HISTORY_CHANGE_TYPES);
|
|
4
|
+
const PRICE_HISTORY_SOURCES = ["api", "system"];
|
|
5
|
+
const priceHistorySourceSchema = z.enum(PRICE_HISTORY_SOURCES);
|
|
6
|
+
const numericString = z.string().regex(/^-?\d+(\.\d+)?$/);
|
|
7
|
+
const priceHistoryEntrySchema = z.object({
|
|
8
|
+
tenantId: z.string().uuid(),
|
|
9
|
+
organizationId: z.string().uuid(),
|
|
10
|
+
priceId: z.string().uuid(),
|
|
11
|
+
productId: z.string().uuid(),
|
|
12
|
+
variantId: z.string().uuid().nullable(),
|
|
13
|
+
offerId: z.string().uuid().nullable(),
|
|
14
|
+
channelId: z.string().uuid().nullable(),
|
|
15
|
+
priceKindId: z.string().uuid(),
|
|
16
|
+
priceKindCode: z.string().min(1),
|
|
17
|
+
currencyCode: z.string().length(3),
|
|
18
|
+
unitPriceNet: numericString.nullable(),
|
|
19
|
+
unitPriceGross: numericString.nullable(),
|
|
20
|
+
taxRate: numericString.nullable(),
|
|
21
|
+
taxAmount: numericString.nullable(),
|
|
22
|
+
minQuantity: z.number().int().nullable(),
|
|
23
|
+
maxQuantity: z.number().int().nullable(),
|
|
24
|
+
startsAt: z.date().nullable(),
|
|
25
|
+
endsAt: z.date().nullable(),
|
|
26
|
+
recordedAt: z.date(),
|
|
27
|
+
changeType: priceHistoryChangeTypeSchema,
|
|
28
|
+
source: priceHistorySourceSchema,
|
|
29
|
+
isAnnounced: z.boolean().nullable(),
|
|
30
|
+
idempotencyKey: z.string().min(1).nullable(),
|
|
31
|
+
metadata: z.record(z.string(), z.unknown()).nullable()
|
|
32
|
+
});
|
|
33
|
+
const OMNIBUS_CONFIG_MODULE_ID = "catalog";
|
|
34
|
+
const OMNIBUS_CONFIG_NAME = "omnibus";
|
|
35
|
+
const OMNIBUS_DEFAULT_LOOKBACK_DAYS = 30;
|
|
36
|
+
const OMNIBUS_NO_CHANNEL_MODES = ["best_effort", "require_channel"];
|
|
37
|
+
const omnibusNoChannelModeSchema = z.enum(OMNIBUS_NO_CHANNEL_MODES);
|
|
38
|
+
const OMNIBUS_MINIMIZATION_AXES = ["gross", "net"];
|
|
39
|
+
const omnibusMinimizationAxisSchema = z.enum(OMNIBUS_MINIMIZATION_AXES);
|
|
40
|
+
const OMNIBUS_APPLICABILITY_REASONS = [
|
|
41
|
+
"no_history",
|
|
42
|
+
"not_in_eu_market",
|
|
43
|
+
"missing_channel_context",
|
|
44
|
+
"insufficient_history",
|
|
45
|
+
"announced_promotion",
|
|
46
|
+
"not_announced",
|
|
47
|
+
"progressive_reduction_frozen",
|
|
48
|
+
"perishable_exempt",
|
|
49
|
+
"perishable_last_price",
|
|
50
|
+
"new_arrival_reduced_window"
|
|
51
|
+
];
|
|
52
|
+
const omnibusApplicabilityReasonSchema = z.enum(OMNIBUS_APPLICABILITY_REASONS);
|
|
53
|
+
const omnibusCountryCodeSchema = z.string().regex(/^[A-Z]{2}$/).refine((value) => value !== "EU");
|
|
54
|
+
const omnibusLookbackDaysSchema = z.number().int().min(1).max(365);
|
|
55
|
+
const omnibusChannelConfigSchema = z.object({
|
|
56
|
+
presentedPriceKindId: z.string().uuid(),
|
|
57
|
+
countryCode: omnibusCountryCodeSchema.optional(),
|
|
58
|
+
lookbackDays: omnibusLookbackDaysSchema.optional(),
|
|
59
|
+
minimizationAxis: omnibusMinimizationAxisSchema.optional()
|
|
60
|
+
});
|
|
61
|
+
const omnibusBackfillCoverageSchema = z.object({
|
|
62
|
+
completedAt: z.string().datetime({ offset: true }),
|
|
63
|
+
lookbackDays: omnibusLookbackDaysSchema
|
|
64
|
+
});
|
|
65
|
+
const omnibusConfigSchema = z.object({
|
|
66
|
+
enabled: z.boolean().default(false),
|
|
67
|
+
enabledCountryCodes: z.array(omnibusCountryCodeSchema).default([]),
|
|
68
|
+
noChannelMode: omnibusNoChannelModeSchema.default("best_effort"),
|
|
69
|
+
lookbackDays: omnibusLookbackDaysSchema.default(OMNIBUS_DEFAULT_LOOKBACK_DAYS),
|
|
70
|
+
minimizationAxis: omnibusMinimizationAxisSchema.default("gross"),
|
|
71
|
+
defaultPresentedPriceKindId: z.string().uuid().optional(),
|
|
72
|
+
backfillCoverage: z.record(z.string(), omnibusBackfillCoverageSchema).default({}),
|
|
73
|
+
channels: z.record(z.string().uuid(), omnibusChannelConfigSchema).default({})
|
|
74
|
+
});
|
|
75
|
+
const OMNIBUS_PRICE_REMOVING_UNDO_COMMAND = "catalog.prices.create";
|
|
76
|
+
const omnibusBlockSchema = z.object({
|
|
77
|
+
presentedPriceKindId: z.string().uuid().nullable(),
|
|
78
|
+
lookbackDays: z.number().int(),
|
|
79
|
+
minimizationAxis: omnibusMinimizationAxisSchema,
|
|
80
|
+
promotionAnchorAt: z.string().nullable(),
|
|
81
|
+
windowStart: z.string().nullable(),
|
|
82
|
+
windowEnd: z.string().nullable(),
|
|
83
|
+
coverageStartAt: z.string().nullable(),
|
|
84
|
+
lowestPriceNet: z.string().nullable(),
|
|
85
|
+
lowestPriceGross: z.string().nullable(),
|
|
86
|
+
previousPriceNet: z.string().nullable(),
|
|
87
|
+
previousPriceGross: z.string().nullable(),
|
|
88
|
+
currencyCode: z.string(),
|
|
89
|
+
applicable: z.boolean(),
|
|
90
|
+
applicabilityReason: omnibusApplicabilityReasonSchema
|
|
91
|
+
});
|
|
92
|
+
export {
|
|
93
|
+
OMNIBUS_APPLICABILITY_REASONS,
|
|
94
|
+
OMNIBUS_CONFIG_MODULE_ID,
|
|
95
|
+
OMNIBUS_CONFIG_NAME,
|
|
96
|
+
OMNIBUS_DEFAULT_LOOKBACK_DAYS,
|
|
97
|
+
OMNIBUS_MINIMIZATION_AXES,
|
|
98
|
+
OMNIBUS_NO_CHANNEL_MODES,
|
|
99
|
+
OMNIBUS_PRICE_REMOVING_UNDO_COMMAND,
|
|
100
|
+
PRICE_HISTORY_CHANGE_TYPES,
|
|
101
|
+
PRICE_HISTORY_SOURCES,
|
|
102
|
+
omnibusApplicabilityReasonSchema,
|
|
103
|
+
omnibusBackfillCoverageSchema,
|
|
104
|
+
omnibusBlockSchema,
|
|
105
|
+
omnibusChannelConfigSchema,
|
|
106
|
+
omnibusConfigSchema,
|
|
107
|
+
omnibusCountryCodeSchema,
|
|
108
|
+
omnibusLookbackDaysSchema,
|
|
109
|
+
omnibusMinimizationAxisSchema,
|
|
110
|
+
omnibusNoChannelModeSchema,
|
|
111
|
+
priceHistoryChangeTypeSchema,
|
|
112
|
+
priceHistoryEntrySchema,
|
|
113
|
+
priceHistorySourceSchema
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=omnibusTypes.js.map
|