@openlup/platform 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +143 -0
- package/README.md +299 -6
- package/dist/catalog/activeSkuSelection.d.ts +2 -0
- package/dist/catalog/activeSkuSelection.js +20 -0
- package/dist/catalog/adminBindings.d.ts +72 -0
- package/dist/catalog/adminBindings.js +1 -0
- package/dist/catalog/adminBundleHandler.d.ts +26 -0
- package/dist/catalog/adminBundleHandler.js +111 -0
- package/dist/catalog/adminBundleReadHandler.d.ts +21 -0
- package/dist/catalog/adminBundleReadHandler.js +185 -0
- package/dist/catalog/adminBundleWritePort.d.ts +85 -0
- package/dist/catalog/adminBundleWritePort.js +1 -0
- package/dist/catalog/bundleAvailability.d.ts +63 -0
- package/dist/catalog/bundleAvailability.js +78 -0
- package/dist/catalog/bundleAvailabilityService.d.ts +65 -0
- package/dist/catalog/bundleAvailabilityService.js +89 -0
- package/dist/catalog/bundleBindings.d.ts +33 -0
- package/dist/catalog/bundleBindings.js +1 -0
- package/dist/catalog/bundleCatalogQueries.d.ts +28 -0
- package/dist/catalog/bundleCatalogQueries.js +84 -0
- package/dist/catalog/bundleCatalogReadPort.d.ts +173 -0
- package/dist/catalog/bundleCatalogReadPort.js +36 -0
- package/dist/catalog/bundleCatalogStore.d.ts +5 -0
- package/dist/catalog/bundleCatalogStore.js +156 -0
- package/dist/catalog/bundlePriceSelection.d.ts +13 -0
- package/dist/catalog/bundlePriceSelection.js +26 -0
- package/dist/catalog/bundleRuleCodes.d.ts +41 -0
- package/dist/catalog/bundleRuleCodes.js +110 -0
- package/dist/catalog/bundleRules.d.ts +69 -0
- package/dist/catalog/bundleRules.js +102 -0
- package/dist/catalog/catalogDraftStore.d.ts +4 -0
- package/dist/catalog/catalogDraftStore.js +63 -0
- package/dist/catalog/catalogSkuEnvelope.d.ts +7 -0
- package/dist/catalog/catalogSkuEnvelope.js +142 -0
- package/dist/catalog/catalogSkuEnvelopeMapper.d.ts +38 -0
- package/dist/catalog/catalogSkuEnvelopeMapper.js +88 -0
- package/dist/catalog/contracts/bundleAdmin.d.ts +143 -0
- package/dist/catalog/contracts/bundleAdmin.js +1 -0
- package/dist/catalog/contracts/bundleAvailability.d.ts +61 -0
- package/dist/catalog/contracts/bundleAvailability.js +1 -0
- package/dist/catalog/contracts/bundleRead.d.ts +241 -0
- package/dist/catalog/contracts/bundleRead.js +1 -0
- package/dist/catalog/contracts/draft.d.ts +79 -0
- package/dist/catalog/contracts/draft.js +47 -0
- package/dist/catalog/contracts/foundation.d.ts +78 -0
- package/dist/catalog/contracts/foundation.js +53 -0
- package/dist/catalog/contracts/index.d.ts +14 -0
- package/dist/catalog/contracts/index.js +6 -0
- package/dist/catalog/contracts/lifecycle.d.ts +77 -0
- package/dist/catalog/contracts/lifecycle.js +1 -0
- package/dist/catalog/contracts/productMediaContracts.d.ts +77 -0
- package/dist/catalog/contracts/productMediaContracts.js +149 -0
- package/dist/catalog/contracts/productTypes.d.ts +54 -0
- package/dist/catalog/contracts/productTypes.js +16 -0
- package/dist/catalog/contracts/resolveProductMedia.d.ts +3 -0
- package/dist/catalog/contracts/resolveProductMedia.js +78 -0
- package/dist/catalog/contracts/sellable.d.ts +23 -0
- package/dist/catalog/contracts/sellable.js +1 -0
- package/dist/catalog/draftHandler.d.ts +25 -0
- package/dist/catalog/draftHandler.js +118 -0
- package/dist/catalog/draftPorts.d.ts +18 -0
- package/dist/catalog/draftPorts.js +8 -0
- package/dist/catalog/draftSchemas.d.ts +423 -0
- package/dist/catalog/draftSchemas.js +89 -0
- package/dist/catalog/draftValidation.d.ts +21 -0
- package/dist/catalog/draftValidation.js +125 -0
- package/dist/catalog/effectiveBundleCatalogQueries.d.ts +8 -0
- package/dist/catalog/effectiveBundleCatalogQueries.js +79 -0
- package/dist/catalog/effectiveBundleCatalogStore.d.ts +4 -0
- package/dist/catalog/effectiveBundleCatalogStore.js +156 -0
- package/dist/catalog/foundationSchemas.d.ts +98 -0
- package/dist/catalog/foundationSchemas.js +110 -0
- package/dist/catalog/index.d.ts +44 -0
- package/dist/catalog/index.js +26 -0
- package/dist/catalog/mediaSourcePack.d.ts +51 -0
- package/dist/catalog/mediaSourcePack.js +247 -0
- package/dist/catalog/productTypeSchemas.d.ts +46 -0
- package/dist/catalog/productTypeSchemas.js +72 -0
- package/dist/catalog/publicationPorts.d.ts +42 -0
- package/dist/catalog/publicationPorts.js +1 -0
- package/dist/catalog/readPorts.d.ts +51 -0
- package/dist/catalog/readPorts.js +1 -0
- package/dist/catalog/referenceCatalogHandler.d.ts +7 -0
- package/dist/catalog/referenceCatalogHandler.js +27 -0
- package/dist/catalog/resolvedSkuProjection.d.ts +88 -0
- package/dist/catalog/resolvedSkuProjection.js +60 -0
- package/dist/catalog/sellableBundleHandler.d.ts +46 -0
- package/dist/catalog/sellableBundleHandler.js +84 -0
- package/dist/catalog/sellableSchemas.d.ts +46 -0
- package/dist/catalog/sellableSchemas.js +27 -0
- package/dist/catalog/sql.d.ts +46 -0
- package/dist/catalog/sql.js +13 -0
- package/dist/catalog/validation.d.ts +2 -0
- package/dist/catalog/validation.js +3 -0
- package/dist/communications/contracts/index.d.ts +1 -0
- package/dist/communications/contracts/marketingSync.d.ts +194 -0
- package/dist/communications/contracts/marketingSync.js +1 -0
- package/dist/communications/index.d.ts +1 -0
- package/dist/communications/klaviyo/consentPush.d.ts +51 -0
- package/dist/communications/klaviyo/consentPush.js +19 -0
- package/dist/communications/klaviyo/index.d.ts +110 -0
- package/dist/communications/klaviyo/index.js +860 -0
- package/dist/communications/newsletterIntegrationContracts.d.ts +3 -3
- package/dist/communications/resend/index.d.ts +40 -0
- package/dist/communications/resend/index.js +310 -0
- package/dist/composition/catalogContribution.d.ts +18 -0
- package/dist/composition/catalogContribution.js +21 -0
- package/dist/composition/index.d.ts +3 -0
- package/dist/composition/index.js +3 -0
- package/dist/composition/inventoryContribution.d.ts +16 -0
- package/dist/composition/inventoryContribution.js +17 -0
- package/dist/composition/shippingContribution.d.ts +16 -0
- package/dist/composition/shippingContribution.js +17 -0
- package/dist/identity/customerContracts.d.ts +2 -2
- package/dist/inventory/adminInventory.d.ts +13 -0
- package/dist/inventory/adminInventory.js +214 -0
- package/dist/inventory/bindings.d.ts +35 -0
- package/dist/inventory/bindings.js +45 -0
- package/dist/inventory/contracts/forecast.d.ts +86 -0
- package/dist/inventory/contracts/forecast.js +1 -0
- package/dist/inventory/contracts/index.d.ts +4 -0
- package/dist/inventory/contracts/index.js +1 -0
- package/dist/inventory/contracts/inventory.d.ts +157 -0
- package/dist/inventory/contracts/inventory.js +1 -0
- package/dist/inventory/contracts/newPurchaseStock.d.ts +20 -0
- package/dist/inventory/contracts/newPurchaseStock.js +1 -0
- package/dist/inventory/contracts/reservation.d.ts +18 -0
- package/dist/inventory/contracts/reservation.js +1 -0
- package/dist/inventory/forecast.d.ts +24 -0
- package/dist/inventory/forecast.js +200 -0
- package/dist/inventory/index.d.ts +14 -0
- package/dist/inventory/index.js +11 -0
- package/dist/inventory/inventoryHandlers.d.ts +53 -0
- package/dist/inventory/inventoryHandlers.js +151 -0
- package/dist/inventory/newPurchaseStockAvailability.d.ts +47 -0
- package/dist/inventory/newPurchaseStockAvailability.js +75 -0
- package/dist/inventory/ports.d.ts +21 -0
- package/dist/inventory/ports.js +16 -0
- package/dist/inventory/renewalReservation.d.ts +27 -0
- package/dist/inventory/renewalReservation.js +61 -0
- package/dist/inventory/reservationPolicy.d.ts +6 -0
- package/dist/inventory/reservationPolicy.js +19 -0
- package/dist/inventory/schemas.d.ts +137 -0
- package/dist/inventory/schemas.js +112 -0
- package/dist/inventory/sql.d.ts +14 -0
- package/dist/inventory/sql.js +5 -0
- package/dist/inventory/subscriptionForecastCalculation.d.ts +4 -0
- package/dist/inventory/subscriptionForecastCalculation.js +133 -0
- package/dist/pricing/acquisitionFinancialPolicy.d.ts +26 -0
- package/dist/pricing/acquisitionFinancialPolicy.js +1 -0
- package/dist/pricing/acquisitionOfferPricing.d.ts +27 -0
- package/dist/pricing/acquisitionOfferPricing.js +25 -0
- package/dist/pricing/acquisitionOfferPricingHandler.d.ts +20 -0
- package/dist/pricing/acquisitionOfferPricingHandler.js +105 -0
- package/dist/pricing/acquisitionOfferPricingSchemas.d.ts +31 -0
- package/dist/pricing/acquisitionOfferPricingSchemas.js +33 -0
- package/dist/pricing/acquisitionQuoteBinding.d.ts +12 -0
- package/dist/pricing/acquisitionQuoteBinding.js +12 -0
- package/dist/pricing/acquisitionReadiness.d.ts +31 -0
- package/dist/pricing/acquisitionReadiness.js +117 -0
- package/dist/pricing/acquisitionTerms.d.ts +19 -0
- package/dist/pricing/acquisitionTerms.js +126 -0
- package/dist/pricing/acquisitionTermsSchemas.d.ts +59 -0
- package/dist/pricing/acquisitionTermsSchemas.js +42 -0
- package/dist/pricing/catalogFactsProvenance.d.ts +33 -0
- package/dist/pricing/catalogFactsProvenance.js +64 -0
- package/dist/pricing/catalogFactsSchemas.d.ts +45 -0
- package/dist/pricing/catalogFactsSchemas.js +58 -0
- package/dist/pricing/commerceOfferPricing.d.ts +25 -0
- package/dist/pricing/commerceOfferPricing.js +139 -0
- package/dist/pricing/commerceOfferPricingCache.d.ts +10 -0
- package/dist/pricing/commerceOfferPricingCache.js +44 -0
- package/dist/pricing/commerceOfferPricingHandler.d.ts +21 -0
- package/dist/pricing/commerceOfferPricingHandler.js +78 -0
- package/dist/pricing/commercePriceAuthority.d.ts +28 -0
- package/dist/pricing/commercePriceAuthority.js +140 -0
- package/dist/pricing/commercePricingPolicyErrors.d.ts +40 -0
- package/dist/pricing/commercePricingPolicyErrors.js +67 -0
- package/dist/pricing/commerceQuoteBatchHandler.d.ts +37 -0
- package/dist/pricing/commerceQuoteBatchHandler.js +83 -0
- package/dist/pricing/commerceQuoteCatalogReadPort.d.ts +27 -0
- package/dist/pricing/commerceQuoteCatalogReadPort.js +8 -0
- package/dist/pricing/commerceQuoteHandler.d.ts +35 -0
- package/dist/pricing/commerceQuoteHandler.js +122 -0
- package/dist/pricing/commerceQuoteSnapshotExpect.d.ts +9 -0
- package/dist/pricing/commerceQuoteSnapshotExpect.js +22 -0
- package/dist/pricing/contracts/acquisitionTerms.d.ts +32 -0
- package/dist/pricing/contracts/acquisitionTerms.js +2 -0
- package/dist/pricing/contracts/authority.d.ts +27 -0
- package/dist/pricing/contracts/authority.js +1 -0
- package/dist/pricing/contracts/evidence.d.ts +33 -0
- package/dist/pricing/contracts/evidence.js +1 -0
- package/dist/pricing/contracts/index.d.ts +17 -0
- package/dist/pricing/contracts/index.js +7 -0
- package/dist/pricing/contracts/money.d.ts +27 -0
- package/dist/pricing/contracts/money.js +1 -0
- package/dist/pricing/contracts/offer.d.ts +52 -0
- package/dist/pricing/contracts/offer.js +4 -0
- package/dist/pricing/contracts/offerPolicy.d.ts +16 -0
- package/dist/pricing/contracts/offerPolicy.js +5 -0
- package/dist/pricing/contracts/policy.d.ts +22 -0
- package/dist/pricing/contracts/policy.js +3 -0
- package/dist/pricing/contracts/provenance.d.ts +24 -0
- package/dist/pricing/contracts/provenance.js +2 -0
- package/dist/pricing/contracts/quote.d.ts +94 -0
- package/dist/pricing/contracts/quote.js +1 -0
- package/dist/pricing/dbBackedCommerceQuoteHelpers.d.ts +78 -0
- package/dist/pricing/dbBackedCommerceQuoteHelpers.js +146 -0
- package/dist/pricing/dbBackedCommerceQuotePort.d.ts +74 -0
- package/dist/pricing/dbBackedCommerceQuotePort.js +223 -0
- package/dist/pricing/dbBackedCommerceQuoteSnapshotVerifier.d.ts +4 -0
- package/dist/pricing/dbBackedCommerceQuoteSnapshotVerifier.js +25 -0
- package/dist/pricing/index.d.ts +52 -0
- package/dist/pricing/index.js +36 -0
- package/dist/pricing/offerPolicyReadiness.d.ts +21 -0
- package/dist/pricing/offerPolicyReadiness.js +79 -0
- package/dist/pricing/offerPolicySchemas.d.ts +25 -0
- package/dist/pricing/offerPolicySchemas.js +15 -0
- package/dist/pricing/offerPricingSchemas.d.ts +315 -0
- package/dist/pricing/offerPricingSchemas.js +65 -0
- package/dist/pricing/ports.d.ts +13 -0
- package/dist/pricing/ports.js +9 -0
- package/dist/pricing/pricingPolicyToken.d.ts +39 -0
- package/dist/pricing/pricingPolicyToken.js +84 -0
- package/dist/pricing/quoteAcquisitionTerms.d.ts +2 -0
- package/dist/pricing/quoteAcquisitionTerms.js +4 -0
- package/dist/pricing/quoteCodeRejectionDetails.d.ts +20 -0
- package/dist/pricing/quoteCodeRejectionDetails.js +22 -0
- package/dist/pricing/quotePorts.d.ts +30 -0
- package/dist/pricing/quotePorts.js +20 -0
- package/dist/pricing/quotePrimitives.d.ts +13 -0
- package/dist/pricing/quotePrimitives.js +18 -0
- package/dist/pricing/quotePromotionEvidence.d.ts +39 -0
- package/dist/pricing/quotePromotionEvidence.js +73 -0
- package/dist/pricing/quoteSchemas.d.ts +1176 -0
- package/dist/pricing/quoteSchemas.js +196 -0
- package/dist/pricing/quoteShippingPromotions.d.ts +20 -0
- package/dist/pricing/quoteShippingPromotions.js +1 -0
- package/dist/pricing/subscriptionPricePolicy.d.ts +52 -0
- package/dist/pricing/subscriptionPricePolicy.js +96 -0
- package/dist/pricing/taxProfileGuard.d.ts +2 -0
- package/dist/pricing/taxProfileGuard.js +24 -0
- package/dist/pricing/validation.d.ts +2 -0
- package/dist/pricing/validation.js +3 -0
- package/dist/promotions/adminBindings.d.ts +72 -0
- package/dist/promotions/adminBindings.js +1 -0
- package/dist/promotions/adminPromotionCodesContracts.d.ts +498 -0
- package/dist/promotions/adminPromotionCodesContracts.js +211 -0
- package/dist/promotions/adminPromotionCodesDataPort.d.ts +47 -0
- package/dist/promotions/adminPromotionCodesDataPort.js +1 -0
- package/dist/promotions/adminPromotionCodesHandler.d.ts +14 -0
- package/dist/promotions/adminPromotionCodesHandler.js +194 -0
- package/dist/promotions/adminPromotionsContracts.d.ts +235 -0
- package/dist/promotions/adminPromotionsContracts.js +99 -0
- package/dist/promotions/adminPromotionsDataPort.d.ts +42 -0
- package/dist/promotions/adminPromotionsDataPort.js +1 -0
- package/dist/promotions/adminPromotionsHandler.d.ts +16 -0
- package/dist/promotions/adminPromotionsHandler.js +47 -0
- package/dist/promotions/commerceQuoteReadPreparation.d.ts +3 -0
- package/dist/promotions/commerceQuoteReadPreparation.js +27 -0
- package/dist/promotions/contracts/index.d.ts +387 -0
- package/dist/promotions/contracts/index.js +1 -0
- package/dist/promotions/index.d.ts +25 -0
- package/dist/promotions/index.js +22 -0
- package/dist/promotions/promoDataPort.d.ts +47 -0
- package/dist/promotions/promoDataPort.js +14 -0
- package/dist/promotions/promotionAcceptanceTelemetry.d.ts +29 -0
- package/dist/promotions/promotionAcceptanceTelemetry.js +45 -0
- package/dist/promotions/promotionBenefitDefinition.d.ts +37 -0
- package/dist/promotions/promotionBenefitDefinition.js +33 -0
- package/dist/promotions/promotionClaimSweepPort.d.ts +14 -0
- package/dist/promotions/promotionClaimSweepPort.js +8 -0
- package/dist/promotions/promotionClaims.d.ts +5 -0
- package/dist/promotions/promotionClaims.js +57 -0
- package/dist/promotions/promotionCodePreview.d.ts +11 -0
- package/dist/promotions/promotionCodePreview.js +154 -0
- package/dist/promotions/promotionCodeQuotePort.d.ts +25 -0
- package/dist/promotions/promotionCodeQuotePort.js +1 -0
- package/dist/promotions/promotionQuoteAcceptance.d.ts +70 -0
- package/dist/promotions/promotionQuoteAcceptance.js +202 -0
- package/dist/promotions/promotionQuoteBinding.d.ts +73 -0
- package/dist/promotions/promotionQuoteBinding.js +87 -0
- package/dist/promotions/quoteAcquisitionBinding.d.ts +6 -0
- package/dist/promotions/quoteAcquisitionBinding.js +1 -0
- package/dist/promotions/quoteAutomaticPromotions.d.ts +26 -0
- package/dist/promotions/quoteAutomaticPromotions.js +60 -0
- package/dist/promotions/quotePromoDiscounts.d.ts +36 -0
- package/dist/promotions/quotePromoDiscounts.js +146 -0
- package/dist/promotions/quotePromotionCodeAdjustments.d.ts +27 -0
- package/dist/promotions/quotePromotionCodeAdjustments.js +223 -0
- package/dist/promotions/quotePromotionV2.d.ts +30 -0
- package/dist/promotions/quotePromotionV2.js +186 -0
- package/dist/promotions/quoteShippingPolicy.d.ts +23 -0
- package/dist/promotions/quoteShippingPolicy.js +47 -0
- package/dist/promotions/sql.d.ts +14 -0
- package/dist/promotions/sql.js +5 -0
- package/dist/promotions/validation.d.ts +2 -0
- package/dist/promotions/validation.js +3 -0
- package/dist/shipping/addressCanonLookupHandler.d.ts +7 -0
- package/dist/shipping/addressCanonLookupHandler.js +105 -0
- package/dist/shipping/addressCanonical.d.ts +2 -0
- package/dist/shipping/addressCanonical.js +26 -0
- package/dist/shipping/addressPorts.d.ts +39 -0
- package/dist/shipping/addressPorts.js +1 -0
- package/dist/shipping/addressSchemas.d.ts +30 -0
- package/dist/shipping/addressSchemas.js +1 -0
- package/dist/shipping/adminShippingRateHandler.d.ts +4 -0
- package/dist/shipping/adminShippingRateHandler.js +64 -0
- package/dist/shipping/bindings.d.ts +57 -0
- package/dist/shipping/bindings.js +46 -0
- package/dist/shipping/contracts/address.d.ts +144 -0
- package/dist/shipping/contracts/address.js +1 -0
- package/dist/shipping/contracts/delivery.d.ts +110 -0
- package/dist/shipping/contracts/delivery.js +1 -0
- package/dist/shipping/contracts/index.d.ts +4 -0
- package/dist/shipping/contracts/index.js +1 -0
- package/dist/shipping/contracts/shippingRate.d.ts +11 -0
- package/dist/shipping/contracts/shippingRate.js +1 -0
- package/dist/shipping/contracts/threshold.d.ts +22 -0
- package/dist/shipping/contracts/threshold.js +1 -0
- package/dist/shipping/customerAddressesHandler.d.ts +5 -0
- package/dist/shipping/customerAddressesHandler.js +80 -0
- package/dist/shipping/customerSelfServiceAddressModels.d.ts +27 -0
- package/dist/shipping/customerSelfServiceAddressModels.js +101 -0
- package/dist/shipping/deliverySelectionHandler.d.ts +10 -0
- package/dist/shipping/deliverySelectionHandler.js +77 -0
- package/dist/shipping/deliverySelectionPort.d.ts +8 -0
- package/dist/shipping/deliverySelectionPort.js +1 -0
- package/dist/shipping/deliverySelectionSummary.d.ts +2 -0
- package/dist/shipping/deliverySelectionSummary.js +53 -0
- package/dist/shipping/handlerSchemas.d.ts +21 -0
- package/dist/shipping/handlerSchemas.js +1 -0
- package/dist/shipping/index.d.ts +20 -0
- package/dist/shipping/index.js +10 -0
- package/dist/shipping/pickupPointSearchPort.d.ts +4 -0
- package/dist/shipping/pickupPointSearchPort.js +1 -0
- package/dist/shipping/readDeliverySelectionEvidence.d.ts +2 -0
- package/dist/shipping/readDeliverySelectionEvidence.js +44 -0
- package/dist/shipping/shippingRatePorts.d.ts +52 -0
- package/dist/shipping/shippingRatePorts.js +1 -0
- package/dist/shipping/thresholdPolicy.d.ts +42 -0
- package/dist/shipping/thresholdPolicy.js +60 -0
- package/package.json +62 -2
- package/release-gates.json +263 -53
- package/sql/20260807140000_read_parity_catalog.sql +94 -0
- package/sql/20260810120000_storefront_catalog_attributes.sql +51 -0
- package/sql/20260812140000_sellable_bundle_catalog.sql +124 -0
- package/sql/20260812210000_bundle_operator_write_boundary.sql +567 -0
- package/sql/20260814000000_fulfillment_stock_evidence.sql +239 -0
- package/sql/20260815120000_automatic_subscription_renewal.sql +1083 -0
- package/sql/20260817180000_promotion_claim_lifecycle.sql +591 -0
- package/sql/20260817180100_promotion_claim_lifecycle_validation.sql +23 -0
- package/sql/20260827220000_catalog_document_revision_foundation.sql +226 -0
- package/sql/20260827220001_catalog_document_revision_foundation_validate.sql +10 -0
- package/sql/20260908100000_catalog_draft_foundation.sql +217 -0
- package/src/catalog/activeSkuSelection.ts +20 -0
- package/src/catalog/adminBindings.ts +59 -0
- package/src/catalog/adminBundleHandler.ts +165 -0
- package/src/catalog/adminBundleReadHandler.ts +263 -0
- package/src/catalog/adminBundleWritePort.ts +102 -0
- package/src/catalog/bundleAvailability.ts +129 -0
- package/src/catalog/bundleAvailabilityService.ts +171 -0
- package/src/catalog/bundleBindings.ts +29 -0
- package/src/catalog/bundleCatalogQueries.ts +98 -0
- package/src/catalog/bundleCatalogReadPort.ts +181 -0
- package/src/catalog/bundleCatalogStore.ts +274 -0
- package/src/catalog/bundlePriceSelection.ts +25 -0
- package/src/catalog/bundleRuleCodes.ts +134 -0
- package/src/catalog/bundleRules.ts +153 -0
- package/src/catalog/catalogDraftStore.ts +71 -0
- package/src/catalog/catalogSkuEnvelope.ts +214 -0
- package/src/catalog/catalogSkuEnvelopeMapper.ts +160 -0
- package/src/catalog/contracts/bundleAdmin.ts +20 -0
- package/src/catalog/contracts/bundleAvailability.ts +5 -0
- package/src/catalog/contracts/bundleRead.ts +13 -0
- package/src/catalog/contracts/draft.ts +69 -0
- package/src/catalog/contracts/foundation.ts +104 -0
- package/src/catalog/contracts/index.ts +14 -0
- package/src/catalog/contracts/lifecycle.ts +74 -0
- package/src/catalog/contracts/productMediaContracts.ts +170 -0
- package/src/catalog/contracts/productTypes.ts +35 -0
- package/src/catalog/contracts/resolveProductMedia.ts +85 -0
- package/src/catalog/contracts/sellable.ts +12 -0
- package/src/catalog/draftHandler.ts +105 -0
- package/src/catalog/draftPorts.ts +18 -0
- package/src/catalog/draftSchemas.ts +88 -0
- package/src/catalog/draftValidation.ts +100 -0
- package/src/catalog/effectiveBundleCatalogQueries.ts +80 -0
- package/src/catalog/effectiveBundleCatalogStore.ts +208 -0
- package/src/catalog/foundationSchemas.ts +123 -0
- package/src/catalog/index.ts +44 -0
- package/src/catalog/mediaSourcePack.ts +219 -0
- package/src/catalog/productTypeSchemas.ts +70 -0
- package/src/catalog/publicationPorts.ts +44 -0
- package/src/catalog/readPorts.ts +61 -0
- package/src/catalog/referenceCatalogHandler.ts +39 -0
- package/src/catalog/resolvedSkuProjection.ts +76 -0
- package/src/catalog/sellableBundleHandler.ts +133 -0
- package/src/catalog/sellableSchemas.ts +33 -0
- package/src/catalog/sql.ts +14 -0
- package/src/catalog/validation.ts +3 -0
- package/src/communications/contracts/index.ts +1 -0
- package/src/communications/contracts/marketingSync.ts +109 -0
- package/src/communications/index.ts +1 -0
- package/src/communications/klaviyo/consentPush.ts +19 -0
- package/src/communications/klaviyo/index.ts +649 -0
- package/src/communications/resend/index.ts +350 -0
- package/src/composition/catalogContribution.ts +32 -0
- package/src/composition/index.ts +3 -0
- package/src/composition/inventoryContribution.ts +24 -0
- package/src/composition/shippingContribution.ts +24 -0
- package/src/inventory/adminInventory.ts +251 -0
- package/src/inventory/bindings.ts +61 -0
- package/src/inventory/contracts/forecast.ts +96 -0
- package/src/inventory/contracts/index.ts +18 -0
- package/src/inventory/contracts/inventory.ts +14 -0
- package/src/inventory/contracts/newPurchaseStock.ts +23 -0
- package/src/inventory/contracts/reservation.ts +20 -0
- package/src/inventory/forecast.ts +239 -0
- package/src/inventory/index.ts +22 -0
- package/src/inventory/inventoryHandlers.ts +215 -0
- package/src/inventory/newPurchaseStockAvailability.ts +120 -0
- package/src/inventory/ports.ts +46 -0
- package/src/inventory/renewalReservation.ts +88 -0
- package/src/inventory/reservationPolicy.ts +27 -0
- package/src/inventory/schemas.ts +128 -0
- package/src/inventory/sql.ts +5 -0
- package/src/inventory/subscriptionForecastCalculation.ts +157 -0
- package/src/pricing/acquisitionFinancialPolicy.ts +26 -0
- package/src/pricing/acquisitionOfferPricing.ts +38 -0
- package/src/pricing/acquisitionOfferPricingHandler.ts +157 -0
- package/src/pricing/acquisitionOfferPricingSchemas.ts +35 -0
- package/src/pricing/acquisitionQuoteBinding.ts +12 -0
- package/src/pricing/acquisitionReadiness.ts +148 -0
- package/src/pricing/acquisitionTerms.ts +125 -0
- package/src/pricing/acquisitionTermsSchemas.ts +52 -0
- package/src/pricing/catalogFactsProvenance.ts +102 -0
- package/src/pricing/catalogFactsSchemas.ts +69 -0
- package/src/pricing/commerceOfferPricing.ts +224 -0
- package/src/pricing/commerceOfferPricingCache.ts +53 -0
- package/src/pricing/commerceOfferPricingHandler.ts +137 -0
- package/src/pricing/commercePriceAuthority.ts +169 -0
- package/src/pricing/commercePricingPolicyErrors.ts +88 -0
- package/src/pricing/commerceQuoteBatchHandler.ts +129 -0
- package/src/pricing/commerceQuoteCatalogReadPort.ts +42 -0
- package/src/pricing/commerceQuoteHandler.ts +199 -0
- package/src/pricing/commerceQuoteSnapshotExpect.ts +48 -0
- package/src/pricing/contracts/acquisitionTerms.ts +26 -0
- package/src/pricing/contracts/authority.ts +44 -0
- package/src/pricing/contracts/evidence.ts +25 -0
- package/src/pricing/contracts/index.ts +17 -0
- package/src/pricing/contracts/money.ts +32 -0
- package/src/pricing/contracts/offer.ts +42 -0
- package/src/pricing/contracts/offerPolicy.ts +17 -0
- package/src/pricing/contracts/policy.ts +26 -0
- package/src/pricing/contracts/provenance.ts +19 -0
- package/src/pricing/contracts/quote.ts +106 -0
- package/src/pricing/dbBackedCommerceQuoteHelpers.ts +256 -0
- package/src/pricing/dbBackedCommerceQuotePort.ts +280 -0
- package/src/pricing/dbBackedCommerceQuoteSnapshotVerifier.ts +49 -0
- package/src/pricing/index.ts +53 -0
- package/src/pricing/offerPolicyReadiness.ts +110 -0
- package/src/pricing/offerPolicySchemas.ts +23 -0
- package/src/pricing/offerPricingSchemas.ts +92 -0
- package/src/pricing/ports.ts +17 -0
- package/src/pricing/pricingPolicyToken.ts +119 -0
- package/src/pricing/quoteAcquisitionTerms.ts +10 -0
- package/src/pricing/quoteCodeRejectionDetails.ts +23 -0
- package/src/pricing/quotePorts.ts +58 -0
- package/src/pricing/quotePrimitives.ts +21 -0
- package/src/pricing/quotePromotionEvidence.ts +82 -0
- package/src/pricing/quoteSchemas.ts +230 -0
- package/src/pricing/quoteShippingPromotions.ts +21 -0
- package/src/pricing/subscriptionPricePolicy.ts +113 -0
- package/src/pricing/taxProfileGuard.ts +33 -0
- package/src/pricing/validation.ts +3 -0
- package/src/promotions/adminBindings.ts +53 -0
- package/src/promotions/adminPromotionCodesContracts.ts +244 -0
- package/src/promotions/adminPromotionCodesDataPort.ts +56 -0
- package/src/promotions/adminPromotionCodesHandler.ts +254 -0
- package/src/promotions/adminPromotionsContracts.ts +121 -0
- package/src/promotions/adminPromotionsDataPort.ts +48 -0
- package/src/promotions/adminPromotionsHandler.ts +72 -0
- package/src/promotions/commerceQuoteReadPreparation.ts +29 -0
- package/src/promotions/contracts/index.ts +387 -0
- package/src/promotions/index.ts +25 -0
- package/src/promotions/promoDataPort.ts +65 -0
- package/src/promotions/promotionAcceptanceTelemetry.ts +73 -0
- package/src/promotions/promotionBenefitDefinition.ts +48 -0
- package/src/promotions/promotionClaimSweepPort.ts +23 -0
- package/src/promotions/promotionClaims.ts +70 -0
- package/src/promotions/promotionCodePreview.ts +183 -0
- package/src/promotions/promotionCodeQuotePort.ts +35 -0
- package/src/promotions/promotionQuoteAcceptance.ts +291 -0
- package/src/promotions/promotionQuoteBinding.ts +163 -0
- package/src/promotions/quoteAcquisitionBinding.ts +7 -0
- package/src/promotions/quoteAutomaticPromotions.ts +84 -0
- package/src/promotions/quotePromoDiscounts.ts +194 -0
- package/src/promotions/quotePromotionCodeAdjustments.ts +277 -0
- package/src/promotions/quotePromotionV2.ts +239 -0
- package/src/promotions/quoteShippingPolicy.ts +61 -0
- package/src/promotions/sql.ts +5 -0
- package/src/promotions/validation.ts +3 -0
- package/src/shipping/addressCanonLookupHandler.ts +114 -0
- package/src/shipping/addressCanonical.ts +31 -0
- package/src/shipping/addressPorts.ts +48 -0
- package/src/shipping/addressSchemas.ts +28 -0
- package/src/shipping/adminShippingRateHandler.ts +72 -0
- package/src/shipping/bindings.ts +74 -0
- package/src/shipping/contracts/address.ts +71 -0
- package/src/shipping/contracts/delivery.ts +114 -0
- package/src/shipping/contracts/index.ts +19 -0
- package/src/shipping/contracts/shippingRate.ts +7 -0
- package/src/shipping/contracts/threshold.ts +22 -0
- package/src/shipping/customerAddressesHandler.ts +100 -0
- package/src/shipping/customerSelfServiceAddressModels.ts +124 -0
- package/src/shipping/deliverySelectionHandler.ts +94 -0
- package/src/shipping/deliverySelectionPort.ts +10 -0
- package/src/shipping/deliverySelectionSummary.ts +56 -0
- package/src/shipping/handlerSchemas.ts +19 -0
- package/src/shipping/index.ts +26 -0
- package/src/shipping/pickupPointSearchPort.ts +8 -0
- package/src/shipping/readDeliverySelectionEvidence.ts +51 -0
- package/src/shipping/shippingRatePorts.ts +36 -0
- package/src/shipping/thresholdPolicy.ts +65 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { calculateInventoryAtp, availableNow, INVENTORY_CONTRACT_VERSION } from "@openlup/core/inventory";
|
|
3
|
+
import { createInventorySubscriptionForecastResponseSchema } from "./schemas.js";
|
|
4
|
+
import { InventoryPersistenceError, } from "./ports.js";
|
|
5
|
+
const STOCK_SQL = `SELECT sku.id AS sku_id, sku.sku, stock.source_key,
|
|
6
|
+
stock.for_sale_quantity AS on_hand,
|
|
7
|
+
COALESCE((SELECT sum(line.quantity)::integer
|
|
8
|
+
FROM public.fulfillment_inventory_reservation_lines line
|
|
9
|
+
JOIN public.fulfillment_inventory_reservations reservation ON reservation.id = line.reservation_id
|
|
10
|
+
WHERE line.sku = stock.sku AND reservation.source_key = stock.source_key
|
|
11
|
+
AND reservation.status IN ('held', 'committed')), 0) AS reserved,
|
|
12
|
+
stock.last_synced_at, stock.stale_after,
|
|
13
|
+
count(*) OVER() AS total_count
|
|
14
|
+
FROM public.fulfillment_stock_current stock
|
|
15
|
+
JOIN public.catalog_skus sku ON sku.sku = stock.sku
|
|
16
|
+
WHERE ($1::uuid IS NULL OR sku.id = $1::uuid)
|
|
17
|
+
AND ($2::boolean OR stock.for_sale_quantity > 0)
|
|
18
|
+
ORDER BY stock.updated_at DESC, stock.source_key, stock.sku
|
|
19
|
+
LIMIT $3::integer OFFSET $4::integer`;
|
|
20
|
+
const RESERVATIONS_SQL = `SELECT reservation.id, order_row.id AS order_id, cycle.id AS cycle_id,
|
|
21
|
+
CASE reservation.status
|
|
22
|
+
WHEN 'held' THEN 'reserved' WHEN 'committed' THEN 'reserved'
|
|
23
|
+
ELSE reservation.status END AS status,
|
|
24
|
+
reservation.expires_at, reservation.created_at,
|
|
25
|
+
operation.identity_key, operation.operation_fingerprint, operation.terminal_outcome,
|
|
26
|
+
count(*) OVER() AS total_count
|
|
27
|
+
FROM public.fulfillment_inventory_reservations reservation
|
|
28
|
+
JOIN public.subscription_renewal_operations operation ON operation.id = reservation.renewal_operation_id
|
|
29
|
+
LEFT JOIN public.subscription_cycles cycle ON cycle.renewal_operation_id = operation.id
|
|
30
|
+
LEFT JOIN public.commerce_orders order_row ON order_row.renewal_operation_id = operation.id
|
|
31
|
+
WHERE ($1::text IS NULL OR CASE reservation.status
|
|
32
|
+
WHEN 'held' THEN 'reserved' WHEN 'committed' THEN 'reserved'
|
|
33
|
+
ELSE reservation.status END = $1::text)
|
|
34
|
+
AND ($2::uuid IS NULL OR order_row.id = $2::uuid)
|
|
35
|
+
ORDER BY reservation.created_at DESC, reservation.id
|
|
36
|
+
LIMIT $3::integer OFFSET $4::integer`;
|
|
37
|
+
const ATP_SQL = `SELECT sku.id AS sku_id, sku.sku, stock.source_key,
|
|
38
|
+
stock.for_sale_quantity AS on_hand,
|
|
39
|
+
COALESCE((SELECT sum(line.quantity)::integer
|
|
40
|
+
FROM public.fulfillment_inventory_reservation_lines line
|
|
41
|
+
JOIN public.fulfillment_inventory_reservations reservation ON reservation.id = line.reservation_id
|
|
42
|
+
WHERE line.sku = stock.sku AND reservation.source_key = stock.source_key
|
|
43
|
+
AND reservation.status IN ('held', 'committed')), 0) AS reserved,
|
|
44
|
+
stock.last_synced_at, stock.stale_after, 0 AS total_count
|
|
45
|
+
FROM public.fulfillment_stock_current stock
|
|
46
|
+
JOIN public.catalog_skus sku ON sku.sku = stock.sku
|
|
47
|
+
WHERE sku.id = ANY($1::uuid[])
|
|
48
|
+
AND stock.inventory_class = 'sellable'
|
|
49
|
+
AND stock.stale_after > $2::timestamptz
|
|
50
|
+
ORDER BY stock.source_key, stock.sku`;
|
|
51
|
+
const FORECAST_SQL = `WITH forecast_skus AS (
|
|
52
|
+
SELECT line.sku
|
|
53
|
+
FROM public.subscription_renewal_term_lines line
|
|
54
|
+
JOIN public.subscriptions subscription ON subscription.id = line.subscription_id
|
|
55
|
+
WHERE subscription.status = 'active'
|
|
56
|
+
UNION
|
|
57
|
+
SELECT stock.sku
|
|
58
|
+
FROM public.fulfillment_stock_current stock
|
|
59
|
+
WHERE stock.inventory_class = 'sellable'
|
|
60
|
+
), sellable_stock AS (
|
|
61
|
+
SELECT stock.sku,
|
|
62
|
+
sum(stock.for_sale_quantity)::integer AS for_sale_quantity,
|
|
63
|
+
max(stock.last_synced_at) AS last_synced_at,
|
|
64
|
+
min(stock.stale_after) AS stale_after
|
|
65
|
+
FROM public.fulfillment_stock_current stock
|
|
66
|
+
WHERE stock.inventory_class = 'sellable'
|
|
67
|
+
GROUP BY stock.sku
|
|
68
|
+
)
|
|
69
|
+
SELECT sku.id AS sku_id, sku.sku,
|
|
70
|
+
stock.for_sale_quantity, stock.last_synced_at, stock.stale_after,
|
|
71
|
+
COALESCE(reserved.quantity, 0)::integer AS reserved,
|
|
72
|
+
COALESCE(demand.days_30, 0)::integer AS days_30,
|
|
73
|
+
COALESCE(demand.days_45, 0)::integer AS days_45,
|
|
74
|
+
COALESCE(demand.days_60, 0)::integer AS days_60
|
|
75
|
+
FROM forecast_skus forecast
|
|
76
|
+
JOIN public.catalog_skus sku ON sku.sku = forecast.sku
|
|
77
|
+
LEFT JOIN sellable_stock stock ON stock.sku = forecast.sku
|
|
78
|
+
LEFT JOIN LATERAL (
|
|
79
|
+
SELECT sum(line.quantity)::integer AS quantity
|
|
80
|
+
FROM public.fulfillment_inventory_reservation_lines line
|
|
81
|
+
JOIN public.fulfillment_inventory_reservations reservation ON reservation.id = line.reservation_id
|
|
82
|
+
WHERE line.sku = forecast.sku
|
|
83
|
+
AND reservation.status IN ('held', 'committed')) reserved ON true
|
|
84
|
+
LEFT JOIN LATERAL (
|
|
85
|
+
SELECT
|
|
86
|
+
sum(CASE WHEN subscription.next_cycle_at <= $1::timestamptz + interval '30 days' THEN line.quantity ELSE 0 END)::integer AS days_30,
|
|
87
|
+
sum(CASE WHEN subscription.next_cycle_at <= $1::timestamptz + interval '45 days' THEN line.quantity ELSE 0 END)::integer AS days_45,
|
|
88
|
+
sum(CASE WHEN subscription.next_cycle_at <= $1::timestamptz + interval '60 days' THEN line.quantity ELSE 0 END)::integer AS days_60
|
|
89
|
+
FROM public.subscription_renewal_term_lines line
|
|
90
|
+
JOIN public.subscriptions subscription ON subscription.id = line.subscription_id
|
|
91
|
+
WHERE line.sku = forecast.sku AND subscription.status = 'active'
|
|
92
|
+
AND subscription.next_cycle_at <= $1::timestamptz + ($2::integer * interval '1 day')) demand ON true
|
|
93
|
+
ORDER BY sku.sku`;
|
|
94
|
+
const ACTIVE_SUBSCRIPTION_COUNT_SQL = `SELECT count(*)::integer AS active_subscription_count
|
|
95
|
+
FROM public.subscriptions WHERE status = 'active'`;
|
|
96
|
+
/** Operator readback over the same public stock and reservation rail used by renewal. */
|
|
97
|
+
export function createPostgresAdminInventoryPort(executor, config, now = () => new Date().toISOString()) {
|
|
98
|
+
const forecastResponseSchema = createInventorySubscriptionForecastResponseSchema(config.providerSchema);
|
|
99
|
+
return {
|
|
100
|
+
async listStock(request) {
|
|
101
|
+
const offset = (request.page - 1) * request.pageSize;
|
|
102
|
+
const result = await executor.query(STOCK_SQL, [
|
|
103
|
+
request.skuId ?? null, request.includeZero, request.pageSize, offset,
|
|
104
|
+
]);
|
|
105
|
+
const stock = result.rows.map(mapStock);
|
|
106
|
+
return {
|
|
107
|
+
contractVersion: INVENTORY_CONTRACT_VERSION,
|
|
108
|
+
stock: stock.map((line) => ({ ...line, availableNow: availableNow(line) })),
|
|
109
|
+
totalCount: count(result.rows[0]), page: request.page, pageSize: request.pageSize,
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
async listReservations(request) {
|
|
113
|
+
const offset = (request.page - 1) * request.pageSize;
|
|
114
|
+
const result = await executor.query(RESERVATIONS_SQL, [
|
|
115
|
+
request.status ?? null, request.orderId ?? null, request.pageSize, offset,
|
|
116
|
+
]);
|
|
117
|
+
return {
|
|
118
|
+
contractVersion: INVENTORY_CONTRACT_VERSION,
|
|
119
|
+
reservations: result.rows.map((row) => ({
|
|
120
|
+
id: text(row.id), orderId: text(row.order_id),
|
|
121
|
+
subscriptionCycleId: nullableText(row.cycle_id),
|
|
122
|
+
status: text(row.status),
|
|
123
|
+
kind: "subscription_retry_window",
|
|
124
|
+
expiresAt: timestampOrNull(row.expires_at), createdAt: timestamp(row.created_at),
|
|
125
|
+
})),
|
|
126
|
+
totalCount: count(result.rows[0]), page: request.page, pageSize: request.pageSize,
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
async checkAtp(request) {
|
|
130
|
+
const result = await executor.query(ATP_SQL, [
|
|
131
|
+
request.lines.map((line) => line.skuId), request.requestedAt,
|
|
132
|
+
]);
|
|
133
|
+
return calculateInventoryAtp({ request, stock: result.rows.map(mapStock) });
|
|
134
|
+
},
|
|
135
|
+
async forecastSubscriptions(request) {
|
|
136
|
+
const generatedAt = now();
|
|
137
|
+
const result = await executor.query(FORECAST_SQL, [generatedAt, request.horizonDays]);
|
|
138
|
+
const activeSubscriptionResult = await executor.query(ACTIVE_SUBSCRIPTION_COUNT_SQL);
|
|
139
|
+
const skus = result.rows.map((row) => mapForecast(row, generatedAt, request));
|
|
140
|
+
return forecastResponseSchema.parse({
|
|
141
|
+
contractVersion: INVENTORY_CONTRACT_VERSION,
|
|
142
|
+
generatedAt,
|
|
143
|
+
// Compatibility projection required by the existing admin BFF contract;
|
|
144
|
+
// the public tables themselves keep source_key opaque.
|
|
145
|
+
stockMasterProvider: config.stockMasterProvider,
|
|
146
|
+
horizonDays: request.horizonDays,
|
|
147
|
+
protectionDays: request.protectionDays,
|
|
148
|
+
skus,
|
|
149
|
+
totals: {
|
|
150
|
+
activeSubscriptionCount: integer(activeSubscriptionResult.rows[0]?.active_subscription_count),
|
|
151
|
+
excludedSubscriptionCount: 0,
|
|
152
|
+
missingProviderStockSkuCount: skus.filter((sku) => sku.stockStatus === "missing").length,
|
|
153
|
+
staleProviderStockSkuCount: skus.filter((sku) => sku.stockStatus === "stale").length,
|
|
154
|
+
horizonShortageSkuCount: skus.filter((sku) => sku.horizonMissingQty > 0).length,
|
|
155
|
+
protectionShortageSkuCount: skus.filter((sku) => sku.protectionMissingQty > 0).length,
|
|
156
|
+
shortageSkuCount: skus.filter((sku) => sku.missingQty > 0).length,
|
|
157
|
+
recommendedProductionQty: skus.reduce((sum, sku) => sum + sku.recommendedProductionQty, 0),
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
async adjustStock() {
|
|
162
|
+
throw new InventoryPersistenceError("Direct stock is externally observed; use the configured stock-source adapter");
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function mapStock(row) {
|
|
167
|
+
const source = text(row.source_key);
|
|
168
|
+
return {
|
|
169
|
+
skuId: text(row.sku_id), sku: text(row.sku),
|
|
170
|
+
locationId: stableUuid(source), locationCode: source,
|
|
171
|
+
locationKind: "third_party_logistics", locationStatus: "active", fulfillable: true,
|
|
172
|
+
lotId: null, lotCode: null, lotStatus: null, expiresAt: null,
|
|
173
|
+
onHand: integer(row.on_hand), reserved: integer(row.reserved), unavailable: 0,
|
|
174
|
+
incoming: 0, safetyStock: 0,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function mapForecast(row, generatedAt, request) {
|
|
178
|
+
const sellable = Math.max(0, integer(row.for_sale_quantity) - integer(row.reserved));
|
|
179
|
+
const horizonDemand = request.horizonDays <= 30 ? integer(row.days_30)
|
|
180
|
+
: request.horizonDays <= 45 ? integer(row.days_45) : integer(row.days_60);
|
|
181
|
+
const protectionDemand = request.protectionDays <= 30 ? integer(row.days_30)
|
|
182
|
+
: request.protectionDays <= 45 ? integer(row.days_45) : integer(row.days_60);
|
|
183
|
+
const horizonMissingQty = Math.max(0, horizonDemand - sellable);
|
|
184
|
+
const protectionMissingQty = Math.max(0, protectionDemand - sellable);
|
|
185
|
+
const staleAfter = timestampOrNull(row.stale_after);
|
|
186
|
+
const stockStatus = row.for_sale_quantity === null || row.for_sale_quantity === undefined
|
|
187
|
+
? "missing"
|
|
188
|
+
: staleAfter && staleAfter <= generatedAt ? "stale" : "fresh";
|
|
189
|
+
return {
|
|
190
|
+
skuId: text(row.sku_id), sku: text(row.sku),
|
|
191
|
+
providerCurrentForSale: nullableInteger(row.for_sale_quantity),
|
|
192
|
+
providerStockLastSyncedAt: timestampOrNull(row.last_synced_at),
|
|
193
|
+
providerStockStaleAfter: staleAfter, stockStatus,
|
|
194
|
+
openHardReservations: integer(row.reserved), safetyStock: 0, sellableNow: sellable,
|
|
195
|
+
activeSubscriptionDemand30: integer(row.days_30),
|
|
196
|
+
activeSubscriptionDemand45: integer(row.days_45),
|
|
197
|
+
activeSubscriptionDemand60: integer(row.days_60), plannedSupply: 0,
|
|
198
|
+
coverageDays: null, shortageDate: null,
|
|
199
|
+
horizonMissingQty, protectionMissingQty,
|
|
200
|
+
missingQty: Math.max(horizonMissingQty, protectionMissingQty),
|
|
201
|
+
recommendedProductionQty: Math.max(horizonMissingQty, protectionMissingQty),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function stableUuid(value) {
|
|
205
|
+
const hash = createHash("sha256").update(`inventory-source:${value}`).digest("hex");
|
|
206
|
+
return `${hash.slice(0, 8)}-${hash.slice(8, 12)}-4${hash.slice(13, 16)}-8${hash.slice(17, 20)}-${hash.slice(20, 32)}`;
|
|
207
|
+
}
|
|
208
|
+
function text(value) { return typeof value === "string" ? value : String(value ?? ""); }
|
|
209
|
+
function nullableText(value) { const result = text(value).trim(); return result || null; }
|
|
210
|
+
function integer(value) { const result = Number(value); return Number.isSafeInteger(result) && result >= 0 ? result : 0; }
|
|
211
|
+
function nullableInteger(value) { return value === null || value === undefined ? null : integer(value); }
|
|
212
|
+
function count(row) { return row ? integer(row.total_count) : 0; }
|
|
213
|
+
function timestamp(value) { return value instanceof Date ? value.toISOString() : text(value); }
|
|
214
|
+
function timestampOrNull(value) { return value === null || value === undefined ? null : timestamp(value); }
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { InventoryMutationPort, InventoryReadPort } from "./ports.js";
|
|
3
|
+
import type { NewPurchaseStockReadPort } from "./newPurchaseStockAvailability.js";
|
|
4
|
+
export interface InventoryBindingDependencies {
|
|
5
|
+
dataKind: string;
|
|
6
|
+
provider: {
|
|
7
|
+
stockMasterProvider: string;
|
|
8
|
+
providerSchema: z.ZodType<string>;
|
|
9
|
+
};
|
|
10
|
+
executor?: {
|
|
11
|
+
query(text: string, values?: unknown[]): Promise<{
|
|
12
|
+
rows: Record<string, unknown>[];
|
|
13
|
+
}>;
|
|
14
|
+
} | null;
|
|
15
|
+
createManagedStore?: (provider: InventoryBindingDependencies["provider"]) => {
|
|
16
|
+
readPort: InventoryReadPort;
|
|
17
|
+
mutationPort: InventoryMutationPort;
|
|
18
|
+
} | null;
|
|
19
|
+
newPurchaseStockReadPort?: NewPurchaseStockReadPort | null;
|
|
20
|
+
now?: () => string;
|
|
21
|
+
}
|
|
22
|
+
export interface InventoryBindings {
|
|
23
|
+
readPort: InventoryReadPort | null;
|
|
24
|
+
mutationPort: InventoryMutationPort | null;
|
|
25
|
+
newPurchaseStockReadPort: NewPurchaseStockReadPort | null;
|
|
26
|
+
readiness: {
|
|
27
|
+
ready: boolean;
|
|
28
|
+
reason: string | null;
|
|
29
|
+
};
|
|
30
|
+
unsupported: {
|
|
31
|
+
newPurchaseStockRead: string | null;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** Select one store only. Factories declare bindings, never discover or activate a host. */
|
|
35
|
+
export declare function createInventoryBindings(deps: InventoryBindingDependencies): InventoryBindings;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createPostgresAdminInventoryPort } from "./adminInventory.js";
|
|
2
|
+
import { createInventorySubscriptionForecastResponseSchema } from "./schemas.js";
|
|
3
|
+
/** Select one store only. Factories declare bindings, never discover or activate a host. */
|
|
4
|
+
export function createInventoryBindings(deps) {
|
|
5
|
+
const refused = (reason) => ({
|
|
6
|
+
readPort: null, mutationPort: null, newPurchaseStockReadPort: null,
|
|
7
|
+
readiness: { ready: false, reason }, unsupported: { newPurchaseStockRead: reason },
|
|
8
|
+
});
|
|
9
|
+
if (!deps.provider?.providerSchema?.safeParse(deps.provider.stockMasterProvider).success)
|
|
10
|
+
return refused("inventory_provider_mismatch");
|
|
11
|
+
let readPort, mutationPort;
|
|
12
|
+
if (deps.dataKind === "postgres") {
|
|
13
|
+
if (!deps.executor || typeof deps.executor.query !== "function")
|
|
14
|
+
return refused("inventory_executor_required");
|
|
15
|
+
readPort = mutationPort = createPostgresAdminInventoryPort(deps.executor, deps.provider, deps.now);
|
|
16
|
+
}
|
|
17
|
+
else if (deps.dataKind === "supabase") {
|
|
18
|
+
const store = deps.createManagedStore?.(deps.provider);
|
|
19
|
+
if (!store)
|
|
20
|
+
return refused("inventory_managed_store_required");
|
|
21
|
+
({ readPort, mutationPort } = store);
|
|
22
|
+
}
|
|
23
|
+
else
|
|
24
|
+
return refused("inventory_store_incompatible");
|
|
25
|
+
if (![readPort?.listStock, readPort?.listReservations, readPort?.checkAtp, readPort?.forecastSubscriptions, mutationPort?.adjustStock].every(fn => typeof fn === "function"))
|
|
26
|
+
return refused("inventory_store_incompatible");
|
|
27
|
+
const responseSchema = createInventorySubscriptionForecastResponseSchema(deps.provider.providerSchema);
|
|
28
|
+
const native = deps.dataKind === "postgres";
|
|
29
|
+
const stockRead = native ? null : deps.newPurchaseStockReadPort;
|
|
30
|
+
const newPurchaseStockReadPort = typeof stockRead?.read === "function" ? stockRead : null;
|
|
31
|
+
return {
|
|
32
|
+
readPort: {
|
|
33
|
+
listStock: request => readPort.listStock(request),
|
|
34
|
+
listReservations: request => readPort.listReservations(request),
|
|
35
|
+
checkAtp: request => readPort.checkAtp(request),
|
|
36
|
+
forecastSubscriptions: async (request) => responseSchema.parse(await readPort.forecastSubscriptions(request)),
|
|
37
|
+
},
|
|
38
|
+
mutationPort, newPurchaseStockReadPort,
|
|
39
|
+
readiness: { ready: true, reason: null },
|
|
40
|
+
unsupported: {
|
|
41
|
+
newPurchaseStockRead: native ? "inventory_native_new_purchase_stock_read_unsupported"
|
|
42
|
+
: newPurchaseStockReadPort ? null : "inventory_new_purchase_stock_reader_required",
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export interface InventoryProviderStockLine {
|
|
2
|
+
skuId: string;
|
|
3
|
+
sku: string;
|
|
4
|
+
forSaleQuantity: number;
|
|
5
|
+
lastSyncedAt: string;
|
|
6
|
+
staleAfter: string;
|
|
7
|
+
}
|
|
8
|
+
export interface InventoryHardReservationLine {
|
|
9
|
+
skuId: string;
|
|
10
|
+
quantity: number;
|
|
11
|
+
}
|
|
12
|
+
/** Structural inputs for dated subscription stock coverage; validation belongs to the caller. */
|
|
13
|
+
export interface SubscriptionForecastProviderStockLine {
|
|
14
|
+
skuId: string;
|
|
15
|
+
sku: string;
|
|
16
|
+
forSaleQuantity: number;
|
|
17
|
+
lastSyncedAt: string;
|
|
18
|
+
staleAfter: string;
|
|
19
|
+
}
|
|
20
|
+
export interface SubscriptionForecastHardReservationLine {
|
|
21
|
+
skuId: string;
|
|
22
|
+
quantity: number;
|
|
23
|
+
}
|
|
24
|
+
export interface SubscriptionForecastStockLine {
|
|
25
|
+
skuId: string;
|
|
26
|
+
sku: string;
|
|
27
|
+
fulfillable: boolean;
|
|
28
|
+
locationStatus: string;
|
|
29
|
+
safetyStock: number;
|
|
30
|
+
}
|
|
31
|
+
export interface SubscriptionForecastDemandLine {
|
|
32
|
+
skuId: string;
|
|
33
|
+
sku: string;
|
|
34
|
+
quantity: number;
|
|
35
|
+
dueAt: string;
|
|
36
|
+
status: string;
|
|
37
|
+
}
|
|
38
|
+
export interface SubscriptionForecastSupplyLine {
|
|
39
|
+
skuId: string;
|
|
40
|
+
quantity: number;
|
|
41
|
+
expectedAt: string;
|
|
42
|
+
status: string;
|
|
43
|
+
}
|
|
44
|
+
export interface SubscriptionForecastCalculationInput {
|
|
45
|
+
generatedAt: string;
|
|
46
|
+
horizonDays: number;
|
|
47
|
+
protectionDays: number;
|
|
48
|
+
providerCurrent: SubscriptionForecastProviderStockLine[];
|
|
49
|
+
openHardReservations: SubscriptionForecastHardReservationLine[];
|
|
50
|
+
stock: SubscriptionForecastStockLine[];
|
|
51
|
+
demand: SubscriptionForecastDemandLine[];
|
|
52
|
+
supply: SubscriptionForecastSupplyLine[];
|
|
53
|
+
}
|
|
54
|
+
export interface SubscriptionForecastCounts {
|
|
55
|
+
activeSubscriptionCount: number;
|
|
56
|
+
excludedSubscriptionCount: number;
|
|
57
|
+
}
|
|
58
|
+
export interface SubscriptionForecastSku {
|
|
59
|
+
skuId: string;
|
|
60
|
+
sku: string;
|
|
61
|
+
providerCurrentForSale: number | null;
|
|
62
|
+
providerStockLastSyncedAt: string | null;
|
|
63
|
+
providerStockStaleAfter: string | null;
|
|
64
|
+
stockStatus: "missing" | "stale" | "fresh";
|
|
65
|
+
openHardReservations: number;
|
|
66
|
+
safetyStock: number;
|
|
67
|
+
sellableNow: number;
|
|
68
|
+
activeSubscriptionDemand30: number;
|
|
69
|
+
activeSubscriptionDemand45: number;
|
|
70
|
+
activeSubscriptionDemand60: number;
|
|
71
|
+
plannedSupply: number;
|
|
72
|
+
coverageDays: number | null;
|
|
73
|
+
shortageDate: string | null;
|
|
74
|
+
horizonMissingQty: number;
|
|
75
|
+
protectionMissingQty: number;
|
|
76
|
+
missingQty: number;
|
|
77
|
+
recommendedProductionQty: number;
|
|
78
|
+
}
|
|
79
|
+
export interface SubscriptionForecastTotals extends SubscriptionForecastCounts {
|
|
80
|
+
missingProviderStockSkuCount: number;
|
|
81
|
+
staleProviderStockSkuCount: number;
|
|
82
|
+
horizonShortageSkuCount: number;
|
|
83
|
+
protectionShortageSkuCount: number;
|
|
84
|
+
shortageSkuCount: number;
|
|
85
|
+
recommendedProductionQty: number;
|
|
86
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { InventoryReservationStatus, AdminInventoryStockRequest, AdminInventoryReservationsRequest, AdminInventoryStockAdjustmentRequest, AdminInventorySubscriptionForecastRequest, InventoryStockListResponse, InventoryReservationsListResponse, InventoryStockAdjustmentResponse, InventorySubscriptionForecastResponse, InventorySubscriptionForecastSku, InventoryForecastDemandLine, InventoryForecastSupplyLine, InventoryForecastResponse, } from "./inventory.js";
|
|
2
|
+
export type { NewPurchaseStockRow, NewPurchaseStockMode, NewPurchaseStockAvailabilityOptions } from "./newPurchaseStock.js";
|
|
3
|
+
export type { ReservationPolicyInput, ReservationPolicy, AutomaticRenewalReservationResult } from "./reservation.js";
|
|
4
|
+
export type { InventoryProviderStockLine, InventoryHardReservationLine, SubscriptionForecastCalculationInput, SubscriptionForecastCounts, SubscriptionForecastSku, SubscriptionForecastTotals } from "./forecast.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/** Inventory wire DTOs. Runtime validation belongs to the server entry. */
|
|
2
|
+
export type InventoryReservationStatus = "reserved" | "released" | "consumed" | "expired";
|
|
3
|
+
export type AdminInventoryStockRequest = {
|
|
4
|
+
page: number;
|
|
5
|
+
pageSize: number;
|
|
6
|
+
includeZero: boolean;
|
|
7
|
+
skuId?: string | undefined;
|
|
8
|
+
locationId?: string | undefined;
|
|
9
|
+
};
|
|
10
|
+
export type AdminInventoryReservationsRequest = {
|
|
11
|
+
page: number;
|
|
12
|
+
pageSize: number;
|
|
13
|
+
status?: "reserved" | "released" | "consumed" | "expired" | undefined;
|
|
14
|
+
orderId?: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
export type AdminInventoryStockAdjustmentRequest = {
|
|
17
|
+
idempotencyKey: string;
|
|
18
|
+
skuId: string;
|
|
19
|
+
locationId: string;
|
|
20
|
+
quantityDelta: number;
|
|
21
|
+
reason: string;
|
|
22
|
+
lotId?: string | null | undefined;
|
|
23
|
+
note?: string | undefined;
|
|
24
|
+
};
|
|
25
|
+
export type AdminInventorySubscriptionForecastRequest = {
|
|
26
|
+
horizonDays: number;
|
|
27
|
+
protectionDays: number;
|
|
28
|
+
};
|
|
29
|
+
export type InventoryStockListResponse = {
|
|
30
|
+
contractVersion: "inventory.v0";
|
|
31
|
+
stock: {
|
|
32
|
+
skuId: string;
|
|
33
|
+
sku: string;
|
|
34
|
+
locationId: string;
|
|
35
|
+
locationCode: string;
|
|
36
|
+
locationKind: "internal_warehouse" | "third_party_logistics" | "supplier" | "quarantine" | "virtual";
|
|
37
|
+
locationStatus: "active" | "inactive";
|
|
38
|
+
fulfillable: boolean;
|
|
39
|
+
lotId: string | null;
|
|
40
|
+
lotCode: string | null;
|
|
41
|
+
lotStatus: "expired" | "available" | "quarantined" | "recalled" | null;
|
|
42
|
+
expiresAt: string | null;
|
|
43
|
+
onHand: number;
|
|
44
|
+
reserved: number;
|
|
45
|
+
unavailable: number;
|
|
46
|
+
incoming: number;
|
|
47
|
+
safetyStock: number;
|
|
48
|
+
availableNow: number;
|
|
49
|
+
}[];
|
|
50
|
+
totalCount: number;
|
|
51
|
+
page: number;
|
|
52
|
+
pageSize: number;
|
|
53
|
+
};
|
|
54
|
+
export type InventoryReservationsListResponse = {
|
|
55
|
+
contractVersion: "inventory.v0";
|
|
56
|
+
reservations: {
|
|
57
|
+
id: string;
|
|
58
|
+
orderId: string;
|
|
59
|
+
subscriptionCycleId: string | null;
|
|
60
|
+
status: "reserved" | "released" | "consumed" | "expired";
|
|
61
|
+
kind: "checkout_payment_window" | "subscription_retry_window" | "manual_ops";
|
|
62
|
+
expiresAt: string | null;
|
|
63
|
+
createdAt: string;
|
|
64
|
+
}[];
|
|
65
|
+
totalCount: number;
|
|
66
|
+
page: number;
|
|
67
|
+
pageSize: number;
|
|
68
|
+
};
|
|
69
|
+
export type InventoryStockAdjustmentResponse = {
|
|
70
|
+
contractVersion: "inventory.v0";
|
|
71
|
+
replayed: boolean;
|
|
72
|
+
};
|
|
73
|
+
export type InventorySubscriptionForecastResponse = {
|
|
74
|
+
contractVersion: "inventory.v0";
|
|
75
|
+
generatedAt: string;
|
|
76
|
+
stockMasterProvider: string;
|
|
77
|
+
horizonDays: number;
|
|
78
|
+
protectionDays: number;
|
|
79
|
+
skus: {
|
|
80
|
+
skuId: string;
|
|
81
|
+
sku: string;
|
|
82
|
+
providerCurrentForSale: number | null;
|
|
83
|
+
providerStockLastSyncedAt: string | null;
|
|
84
|
+
providerStockStaleAfter: string | null;
|
|
85
|
+
stockStatus: "fresh" | "stale" | "missing";
|
|
86
|
+
openHardReservations: number;
|
|
87
|
+
safetyStock: number;
|
|
88
|
+
sellableNow: number;
|
|
89
|
+
activeSubscriptionDemand30: number;
|
|
90
|
+
activeSubscriptionDemand45: number;
|
|
91
|
+
activeSubscriptionDemand60: number;
|
|
92
|
+
plannedSupply: number;
|
|
93
|
+
coverageDays: number | null;
|
|
94
|
+
shortageDate: string | null;
|
|
95
|
+
horizonMissingQty: number;
|
|
96
|
+
protectionMissingQty: number;
|
|
97
|
+
missingQty: number;
|
|
98
|
+
recommendedProductionQty: number;
|
|
99
|
+
}[];
|
|
100
|
+
totals: {
|
|
101
|
+
activeSubscriptionCount: number;
|
|
102
|
+
excludedSubscriptionCount: number;
|
|
103
|
+
missingProviderStockSkuCount: number;
|
|
104
|
+
staleProviderStockSkuCount: number;
|
|
105
|
+
horizonShortageSkuCount: number;
|
|
106
|
+
protectionShortageSkuCount: number;
|
|
107
|
+
shortageSkuCount: number;
|
|
108
|
+
recommendedProductionQty: number;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
export type InventorySubscriptionForecastSku = {
|
|
112
|
+
skuId: string;
|
|
113
|
+
sku: string;
|
|
114
|
+
providerCurrentForSale: number | null;
|
|
115
|
+
providerStockLastSyncedAt: string | null;
|
|
116
|
+
providerStockStaleAfter: string | null;
|
|
117
|
+
stockStatus: "fresh" | "stale" | "missing";
|
|
118
|
+
openHardReservations: number;
|
|
119
|
+
safetyStock: number;
|
|
120
|
+
sellableNow: number;
|
|
121
|
+
activeSubscriptionDemand30: number;
|
|
122
|
+
activeSubscriptionDemand45: number;
|
|
123
|
+
activeSubscriptionDemand60: number;
|
|
124
|
+
plannedSupply: number;
|
|
125
|
+
coverageDays: number | null;
|
|
126
|
+
shortageDate: string | null;
|
|
127
|
+
horizonMissingQty: number;
|
|
128
|
+
protectionMissingQty: number;
|
|
129
|
+
missingQty: number;
|
|
130
|
+
recommendedProductionQty: number;
|
|
131
|
+
};
|
|
132
|
+
export type InventoryForecastDemandLine = {
|
|
133
|
+
subscriptionId: string;
|
|
134
|
+
subscriptionCycleId: string | null;
|
|
135
|
+
skuId: string;
|
|
136
|
+
sku: string;
|
|
137
|
+
quantity: number;
|
|
138
|
+
dueAt: string;
|
|
139
|
+
status: "planned" | "payment_pending" | "paid" | "retry_scheduled" | "skipped" | "cancelled";
|
|
140
|
+
};
|
|
141
|
+
export type InventoryForecastSupplyLine = {
|
|
142
|
+
skuId: string;
|
|
143
|
+
quantity: number;
|
|
144
|
+
expectedAt: string;
|
|
145
|
+
status: "planned" | "cancelled" | "received";
|
|
146
|
+
};
|
|
147
|
+
export type InventoryForecastResponse = {
|
|
148
|
+
contractVersion: "inventory.v0";
|
|
149
|
+
shortages: {
|
|
150
|
+
skuId: string;
|
|
151
|
+
sku: string;
|
|
152
|
+
dueAt: string;
|
|
153
|
+
demandQuantity: number;
|
|
154
|
+
availableOrExpectedQuantity: number;
|
|
155
|
+
missingQuantity: number;
|
|
156
|
+
}[];
|
|
157
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface NewPurchaseStockRow {
|
|
2
|
+
sku: string;
|
|
3
|
+
catalogSkuId: string | null;
|
|
4
|
+
source: "provider" | "local" | "missing";
|
|
5
|
+
providerForSale: number | null;
|
|
6
|
+
activeHolds: number;
|
|
7
|
+
safetyStock: number;
|
|
8
|
+
available: number | null;
|
|
9
|
+
stale: boolean;
|
|
10
|
+
renewalDemand: number;
|
|
11
|
+
availableForNewPurchases: number | null;
|
|
12
|
+
/** Holds of the excluded order left out of `activeHolds`; 0 when no order is excluded. */
|
|
13
|
+
excludedOrderHolds: number;
|
|
14
|
+
}
|
|
15
|
+
export type NewPurchaseStockMode = "new_purchase" | "renewal";
|
|
16
|
+
export interface NewPurchaseStockAvailabilityOptions {
|
|
17
|
+
mode: NewPurchaseStockMode;
|
|
18
|
+
lowStockThreshold?: number;
|
|
19
|
+
horizonDays?: number;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface ReservationPolicyInput {
|
|
2
|
+
reservationKind: string;
|
|
3
|
+
paymentTargetKind: "one_time_order" | "subscription_cycle" | string;
|
|
4
|
+
orderMode: "one_time" | "subscription_cycle" | string;
|
|
5
|
+
now: Date;
|
|
6
|
+
checkoutTtlMinutes?: number | null;
|
|
7
|
+
}
|
|
8
|
+
export interface ReservationPolicy {
|
|
9
|
+
expiresAt: string | null;
|
|
10
|
+
ttlMinutes: number | null;
|
|
11
|
+
}
|
|
12
|
+
export interface AutomaticRenewalReservationResult {
|
|
13
|
+
reserved: boolean;
|
|
14
|
+
replayed: boolean;
|
|
15
|
+
reservationId: string | null;
|
|
16
|
+
status: "held" | "committed" | "consumed" | "released" | "expired" | "refused";
|
|
17
|
+
reason: string | null;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type InventoryStockLine } from "@openlup/core/inventory";
|
|
3
|
+
import type { InventoryForecastDemandLine, InventoryForecastResponse, InventoryForecastSupplyLine, InventorySubscriptionForecastResponse } from "./contracts/index.js";
|
|
4
|
+
import type { InventoryProviderStockLine, InventoryHardReservationLine } from "./contracts/forecast.js";
|
|
5
|
+
export declare function forecastSubscriptionInventoryShortages(input: {
|
|
6
|
+
demand: InventoryForecastDemandLine[];
|
|
7
|
+
supply: InventoryForecastSupplyLine[];
|
|
8
|
+
stock: InventoryStockLine[];
|
|
9
|
+
}): InventoryForecastResponse;
|
|
10
|
+
export declare function buildSubscriptionInventoryForecast(input: {
|
|
11
|
+
generatedAt: string;
|
|
12
|
+
horizonDays: number;
|
|
13
|
+
protectionDays: number;
|
|
14
|
+
providerCurrent: InventoryProviderStockLine[];
|
|
15
|
+
openHardReservations: InventoryHardReservationLine[];
|
|
16
|
+
stock: InventoryStockLine[];
|
|
17
|
+
demand: InventoryForecastDemandLine[];
|
|
18
|
+
supply: InventoryForecastSupplyLine[];
|
|
19
|
+
activeSubscriptionCount: number;
|
|
20
|
+
excludedSubscriptionCount: number;
|
|
21
|
+
}, config: {
|
|
22
|
+
stockMasterProvider: string;
|
|
23
|
+
providerSchema: z.ZodType<string>;
|
|
24
|
+
}): InventorySubscriptionForecastResponse;
|