@openlup/platform 0.16.0 → 0.18.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 +180 -0
- package/README.md +564 -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 +20 -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 +166 -0
- package/dist/catalog/bundleCatalogReadPort.js +36 -0
- package/dist/catalog/bundleCatalogStore.d.ts +3 -0
- package/dist/catalog/bundleCatalogStore.js +152 -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 +223 -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/foundationSchemas.d.ts +98 -0
- package/dist/catalog/foundationSchemas.js +110 -0
- package/dist/catalog/index.d.ts +43 -0
- package/dist/catalog/index.js +25 -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/accountingDocumentDelivery.d.ts +35 -0
- package/dist/communications/accountingDocumentDelivery.js +33 -0
- package/dist/communications/authEmailError.d.ts +5 -0
- package/dist/communications/authEmailError.js +8 -0
- package/dist/communications/authEmailPorts.d.ts +2 -0
- package/dist/communications/authEmailPorts.js +1 -0
- package/dist/communications/authSendEmailHook.d.ts +35 -0
- package/dist/communications/authSendEmailHook.js +250 -0
- package/dist/communications/capturedTransactionalDelivery.d.ts +13 -0
- package/dist/communications/capturedTransactionalDelivery.js +14 -0
- package/dist/communications/communicationSync.d.ts +11 -0
- package/dist/communications/communicationSync.js +79 -0
- package/dist/communications/communicationSyncWorker.d.ts +68 -0
- package/dist/communications/communicationSyncWorker.js +218 -0
- package/dist/communications/consentPolicy.d.ts +19 -0
- package/dist/communications/consentPolicy.js +43 -0
- package/dist/communications/consentPurposeRegistry.d.ts +4 -0
- package/dist/communications/consentPurposeRegistry.js +24 -0
- package/dist/communications/contracts/abandonedCart.d.ts +27 -0
- package/dist/communications/contracts/abandonedCart.js +25 -0
- package/dist/communications/contracts/authEmail.d.ts +62 -0
- package/dist/communications/contracts/authEmail.js +1 -0
- package/dist/communications/contracts/backInStock.d.ts +28 -0
- package/dist/communications/contracts/backInStock.js +28 -0
- package/dist/communications/contracts/blocks.d.ts +24 -0
- package/dist/communications/contracts/blocks.js +23 -0
- package/dist/communications/contracts/checkoutExpired.d.ts +22 -0
- package/dist/communications/contracts/checkoutExpired.js +25 -0
- package/dist/communications/contracts/checkoutRecovery.d.ts +26 -0
- package/dist/communications/contracts/checkoutRecovery.js +37 -0
- package/dist/communications/contracts/commerceEmailContent.d.ts +176 -0
- package/dist/communications/contracts/commerceEmailContent.js +1 -0
- package/dist/communications/contracts/commerceEngagementEmailContent.d.ts +95 -0
- package/dist/communications/contracts/commerceEngagementEmailContent.js +1 -0
- package/dist/communications/contracts/consent.d.ts +12 -0
- package/dist/communications/contracts/consent.js +1 -0
- package/dist/communications/contracts/email.d.ts +182 -0
- package/dist/communications/contracts/email.js +1 -0
- package/dist/communications/contracts/guideCard.d.ts +3 -0
- package/dist/communications/contracts/guideCard.js +26 -0
- package/dist/communications/contracts/index.d.ts +52 -0
- package/dist/communications/contracts/index.js +42 -0
- package/dist/communications/contracts/inquiryContent.d.ts +32 -0
- package/dist/communications/contracts/inquiryContent.js +33 -0
- package/dist/communications/contracts/invoiceDocumentContent.d.ts +26 -0
- package/dist/communications/contracts/invoiceDocumentContent.js +36 -0
- package/dist/communications/contracts/marketingAutomation.d.ts +52 -0
- package/dist/communications/contracts/marketingAutomation.js +1 -0
- package/dist/communications/contracts/marketingSync.d.ts +194 -0
- package/dist/communications/contracts/marketingSync.js +1 -0
- package/dist/communications/contracts/newsletter.d.ts +63 -0
- package/dist/communications/contracts/newsletter.js +1 -0
- package/dist/communications/contracts/newsletterWebhook.d.ts +26 -0
- package/dist/communications/contracts/newsletterWebhook.js +1 -0
- package/dist/communications/contracts/optOutContent.d.ts +11 -0
- package/dist/communications/contracts/optOutContent.js +17 -0
- package/dist/communications/contracts/orderCanceled.d.ts +25 -0
- package/dist/communications/contracts/orderCanceled.js +27 -0
- package/dist/communications/contracts/orderDraft.d.ts +46 -0
- package/dist/communications/contracts/orderDraft.js +46 -0
- package/dist/communications/contracts/orderPaid.d.ts +53 -0
- package/dist/communications/contracts/orderPaid.js +71 -0
- package/dist/communications/contracts/orderRefunded.d.ts +24 -0
- package/dist/communications/contracts/orderRefunded.js +27 -0
- package/dist/communications/contracts/paymentFailed.d.ts +24 -0
- package/dist/communications/contracts/paymentFailed.js +24 -0
- package/dist/communications/contracts/publicIntake.d.ts +49 -0
- package/dist/communications/contracts/publicIntake.js +1 -0
- package/dist/communications/contracts/render.d.ts +2 -0
- package/dist/communications/contracts/render.js +229 -0
- package/dist/communications/contracts/reorderReminder.d.ts +24 -0
- package/dist/communications/contracts/reorderReminder.js +24 -0
- package/dist/communications/contracts/returnEmails.d.ts +25 -0
- package/dist/communications/contracts/returnEmails.js +62 -0
- package/dist/communications/contracts/reviewEffects.d.ts +26 -0
- package/dist/communications/contracts/reviewEffects.js +25 -0
- package/dist/communications/contracts/reviewRequest.d.ts +26 -0
- package/dist/communications/contracts/reviewRequest.js +24 -0
- package/dist/communications/contracts/roleNotificationContent.d.ts +25 -0
- package/dist/communications/contracts/roleNotificationContent.js +46 -0
- package/dist/communications/contracts/shipmentDelivered.d.ts +23 -0
- package/dist/communications/contracts/shipmentDelivered.js +24 -0
- package/dist/communications/contracts/shipmentDispatched.d.ts +27 -0
- package/dist/communications/contracts/shipmentDispatched.js +35 -0
- package/dist/communications/contracts/shipmentException.d.ts +21 -0
- package/dist/communications/contracts/shipmentException.js +26 -0
- package/dist/communications/contracts/subscriptionActivationActionRequired.d.ts +17 -0
- package/dist/communications/contracts/subscriptionActivationActionRequired.js +22 -0
- package/dist/communications/contracts/subscriptionAddressChanged.d.ts +19 -0
- package/dist/communications/contracts/subscriptionAddressChanged.js +25 -0
- package/dist/communications/contracts/subscriptionCancelled.d.ts +19 -0
- package/dist/communications/contracts/subscriptionCancelled.js +25 -0
- package/dist/communications/contracts/subscriptionCycleSkipped.d.ts +25 -0
- package/dist/communications/contracts/subscriptionCycleSkipped.js +40 -0
- package/dist/communications/contracts/subscriptionDeliveryRescheduled.d.ts +25 -0
- package/dist/communications/contracts/subscriptionDeliveryRescheduled.js +39 -0
- package/dist/communications/contracts/subscriptionEmailContent.d.ts +145 -0
- package/dist/communications/contracts/subscriptionEmailContent.js +1 -0
- package/dist/communications/contracts/subscriptionPackageChanged.d.ts +20 -0
- package/dist/communications/contracts/subscriptionPackageChanged.js +26 -0
- package/dist/communications/contracts/subscriptionPauseReminder.d.ts +23 -0
- package/dist/communications/contracts/subscriptionPauseReminder.js +29 -0
- package/dist/communications/contracts/subscriptionPaused.d.ts +21 -0
- package/dist/communications/contracts/subscriptionPaused.js +25 -0
- package/dist/communications/contracts/subscriptionPaymentExpired.d.ts +34 -0
- package/dist/communications/contracts/subscriptionPaymentExpired.js +37 -0
- package/dist/communications/contracts/subscriptionPaymentFailed.d.ts +49 -0
- package/dist/communications/contracts/subscriptionPaymentFailed.js +56 -0
- package/dist/communications/contracts/subscriptionPaymentRecovered.d.ts +19 -0
- package/dist/communications/contracts/subscriptionPaymentRecovered.js +22 -0
- package/dist/communications/contracts/subscriptionRenewalAtRisk.d.ts +36 -0
- package/dist/communications/contracts/subscriptionRenewalAtRisk.js +36 -0
- package/dist/communications/contracts/subscriptionRenewalUpcoming.d.ts +49 -0
- package/dist/communications/contracts/subscriptionRenewalUpcoming.js +43 -0
- package/dist/communications/contracts/subscriptionResumed.d.ts +23 -0
- package/dist/communications/contracts/subscriptionResumed.js +25 -0
- package/dist/communications/contracts/subscriptionWelcome.d.ts +44 -0
- package/dist/communications/contracts/subscriptionWelcome.js +45 -0
- package/dist/communications/contracts/subscriptionWinback.d.ts +21 -0
- package/dist/communications/contracts/subscriptionWinback.js +28 -0
- package/dist/communications/contracts/transactionalDelivery.d.ts +42 -0
- package/dist/communications/contracts/transactionalDelivery.js +1 -0
- package/dist/communications/contracts/types.d.ts +46 -0
- package/dist/communications/contracts/types.js +1 -0
- package/dist/communications/contribution.d.ts +10 -0
- package/dist/communications/contribution.js +24 -0
- package/dist/communications/deliveryReconciliation.d.ts +64 -0
- package/dist/communications/deliveryReconciliation.js +60 -0
- package/dist/communications/emailEgress.d.ts +38 -0
- package/dist/communications/emailEgress.js +100 -0
- package/dist/communications/emailHealthAssessment.d.ts +39 -0
- package/dist/communications/emailHealthAssessment.js +59 -0
- package/dist/communications/emailHealthMetricsPort.d.ts +17 -0
- package/dist/communications/emailHealthMetricsPort.js +1 -0
- package/dist/communications/emailNotificationControl.d.ts +27 -0
- package/dist/communications/emailNotificationControl.js +10 -0
- package/dist/communications/emailObservation.d.ts +28 -0
- package/dist/communications/emailObservation.js +23 -0
- package/dist/communications/emailTransport.d.ts +82 -0
- package/dist/communications/emailTransport.js +95 -0
- package/dist/communications/errors.d.ts +15 -0
- package/dist/communications/errors.js +30 -0
- package/dist/communications/index.d.ts +47 -0
- package/dist/communications/index.js +38 -0
- package/dist/communications/integrationEventSignature.d.ts +15 -0
- package/dist/communications/integrationEventSignature.js +37 -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/managedTransactionalDeliveryStore.d.ts +12 -0
- package/dist/communications/managedTransactionalDeliveryStore.js +49 -0
- package/dist/communications/nativeOperations.d.ts +79 -0
- package/dist/communications/nativeOperations.js +3 -0
- package/dist/communications/newsletterIntegrationContracts.d.ts +130 -0
- package/dist/communications/newsletterIntegrationContracts.js +128 -0
- package/dist/communications/newsletterWebhookPort.d.ts +11 -0
- package/dist/communications/newsletterWebhookPort.js +84 -0
- package/dist/communications/newsletterWebhookProcessing.d.ts +17 -0
- package/dist/communications/newsletterWebhookProcessing.js +71 -0
- package/dist/communications/originPolicy.d.ts +40 -0
- package/dist/communications/originPolicy.js +100 -0
- package/dist/communications/postgresCommunicationSync.d.ts +79 -0
- package/dist/communications/postgresCommunicationSync.js +111 -0
- package/dist/communications/postgresConsentEvaluator.d.ts +19 -0
- package/dist/communications/postgresConsentEvaluator.js +43 -0
- package/dist/communications/postgresDeliveryReconciliation.d.ts +3 -0
- package/dist/communications/postgresDeliveryReconciliation.js +113 -0
- package/dist/communications/postgresNativeOperations.d.ts +13 -0
- package/dist/communications/postgresNativeOperations.js +63 -0
- package/dist/communications/postgresNotificationRecipients.d.ts +37 -0
- package/dist/communications/postgresNotificationRecipients.js +60 -0
- package/dist/communications/postgresTransactionalDeliveryStore.d.ts +7 -0
- package/dist/communications/postgresTransactionalDeliveryStore.js +55 -0
- package/dist/communications/preferencesToken.d.ts +10 -0
- package/dist/communications/preferencesToken.js +40 -0
- package/dist/communications/publicPreferenceToken.d.ts +24 -0
- package/dist/communications/publicPreferenceToken.js +53 -0
- package/dist/communications/resend/index.d.ts +40 -0
- package/dist/communications/resend/index.js +310 -0
- package/dist/communications/shipmentNotifications.d.ts +34 -0
- package/dist/communications/shipmentNotifications.js +61 -0
- package/dist/communications/sql.d.ts +26 -0
- package/dist/communications/sql.js +7 -0
- package/dist/communications/standardWebhooks.d.ts +14 -0
- package/dist/communications/standardWebhooks.js +73 -0
- package/dist/communications/status.d.ts +11 -0
- package/dist/communications/status.js +36 -0
- package/dist/communications/transactionalDelivery.d.ts +19 -0
- package/dist/communications/transactionalDelivery.js +96 -0
- package/dist/communications/transactionalDeliveryIdentifier.d.ts +3 -0
- package/dist/communications/transactionalDeliveryIdentifier.js +6 -0
- package/dist/communications/unsubscribeToken.d.ts +77 -0
- package/dist/communications/unsubscribeToken.js +150 -0
- package/dist/communications/validation.d.ts +2 -0
- package/dist/communications/validation.js +3 -0
- package/dist/composition/catalogContribution.d.ts +18 -0
- package/dist/composition/catalogContribution.js +21 -0
- package/dist/composition/index.d.ts +1 -0
- package/dist/composition/index.js +1 -0
- package/dist/http/index.d.ts +1 -0
- package/dist/http/index.js +1 -0
- package/dist/http/webhookSignature.d.ts +42 -0
- package/dist/http/webhookSignature.js +86 -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/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 +13 -0
- package/dist/inventory/index.js +10 -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 +26 -0
- package/dist/pricing/commercePriceAuthority.js +79 -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 +31 -0
- package/dist/pricing/commerceQuoteHandler.js +110 -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 +66 -0
- package/dist/pricing/dbBackedCommerceQuotePort.js +206 -0
- package/dist/pricing/dbBackedCommerceQuoteSnapshotVerifier.d.ts +4 -0
- package/dist/pricing/dbBackedCommerceQuoteSnapshotVerifier.js +25 -0
- package/dist/pricing/index.d.ts +51 -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/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/contracts/index.d.ts +387 -0
- package/dist/promotions/contracts/index.js +1 -0
- package/dist/promotions/index.d.ts +22 -0
- package/dist/promotions/index.js +21 -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 +65 -0
- package/dist/promotions/promotionQuoteAcceptance.js +202 -0
- package/dist/promotions/promotionQuoteBinding.d.ts +71 -0
- package/dist/promotions/promotionQuoteBinding.js +85 -0
- package/dist/promotions/quoteAutomaticPromotions.d.ts +24 -0
- package/dist/promotions/quoteAutomaticPromotions.js +36 -0
- package/dist/promotions/quotePromoDiscounts.d.ts +32 -0
- package/dist/promotions/quotePromoDiscounts.js +140 -0
- package/dist/promotions/quotePromotionCodeAdjustments.d.ts +27 -0
- package/dist/promotions/quotePromotionCodeAdjustments.js +223 -0
- package/dist/promotions/quotePromotionV2.d.ts +29 -0
- package/dist/promotions/quotePromotionV2.js +174 -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/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 +3 -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/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 +17 -0
- package/dist/shipping/index.js +8 -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/package.json +72 -2
- package/release-gates.json +249 -8
- package/sql/20260807140000_read_parity_catalog.sql +94 -0
- package/sql/20260807190000_comms_outbox_rail.sql +329 -0
- package/sql/20260810120000_storefront_catalog_attributes.sql +51 -0
- package/sql/20260810120001_transactional_delivery_receipts.sql +209 -0
- package/sql/20260812140000_sellable_bundle_catalog.sql +124 -0
- package/sql/20260812210000_bundle_operator_write_boundary.sql +567 -0
- package/sql/20260813120000_communications_control_plane.sql +568 -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/sql/20261019200000_communications_native_operations.sql +68 -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 +261 -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 +177 -0
- package/src/catalog/bundleCatalogStore.ts +269 -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/foundationSchemas.ts +123 -0
- package/src/catalog/index.ts +43 -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/accountingDocumentDelivery.ts +63 -0
- package/src/communications/authEmailError.ts +10 -0
- package/src/communications/authEmailPorts.ts +2 -0
- package/src/communications/authSendEmailHook.ts +310 -0
- package/src/communications/capturedTransactionalDelivery.ts +29 -0
- package/src/communications/communicationSync.ts +96 -0
- package/src/communications/communicationSyncWorker.ts +302 -0
- package/src/communications/consentPolicy.ts +82 -0
- package/src/communications/consentPurposeRegistry.ts +31 -0
- package/src/communications/contracts/abandonedCart.ts +64 -0
- package/src/communications/contracts/authEmail.ts +73 -0
- package/src/communications/contracts/backInStock.ts +69 -0
- package/src/communications/contracts/blocks.ts +47 -0
- package/src/communications/contracts/checkoutExpired.ts +62 -0
- package/src/communications/contracts/checkoutRecovery.ts +68 -0
- package/src/communications/contracts/commerceEmailContent.ts +189 -0
- package/src/communications/contracts/commerceEngagementEmailContent.ts +106 -0
- package/src/communications/contracts/consent.ts +13 -0
- package/src/communications/contracts/email.ts +210 -0
- package/src/communications/contracts/guideCard.ts +34 -0
- package/src/communications/contracts/index.ts +52 -0
- package/src/communications/contracts/inquiryContent.ts +53 -0
- package/src/communications/contracts/invoiceDocumentContent.ts +57 -0
- package/src/communications/contracts/marketingAutomation.ts +45 -0
- package/src/communications/contracts/marketingSync.ts +109 -0
- package/src/communications/contracts/newsletter.ts +78 -0
- package/src/communications/contracts/newsletterWebhook.ts +23 -0
- package/src/communications/contracts/optOutContent.ts +23 -0
- package/src/communications/contracts/orderCanceled.ts +64 -0
- package/src/communications/contracts/orderDraft.ts +112 -0
- package/src/communications/contracts/orderPaid.ts +147 -0
- package/src/communications/contracts/orderRefunded.ts +63 -0
- package/src/communications/contracts/paymentFailed.ts +59 -0
- package/src/communications/contracts/publicIntake.ts +53 -0
- package/src/communications/contracts/render.ts +271 -0
- package/src/communications/contracts/reorderReminder.ts +59 -0
- package/src/communications/contracts/returnEmails.ts +113 -0
- package/src/communications/contracts/reviewEffects.ts +60 -0
- package/src/communications/contracts/reviewRequest.ts +59 -0
- package/src/communications/contracts/roleNotificationContent.ts +65 -0
- package/src/communications/contracts/shipmentDelivered.ts +59 -0
- package/src/communications/contracts/shipmentDispatched.ts +77 -0
- package/src/communications/contracts/shipmentException.ts +62 -0
- package/src/communications/contracts/subscriptionActivationActionRequired.ts +37 -0
- package/src/communications/contracts/subscriptionAddressChanged.ts +56 -0
- package/src/communications/contracts/subscriptionCancelled.ts +57 -0
- package/src/communications/contracts/subscriptionCycleSkipped.ts +80 -0
- package/src/communications/contracts/subscriptionDeliveryRescheduled.ts +79 -0
- package/src/communications/contracts/subscriptionEmailContent.ts +163 -0
- package/src/communications/contracts/subscriptionPackageChanged.ts +59 -0
- package/src/communications/contracts/subscriptionPauseReminder.ts +63 -0
- package/src/communications/contracts/subscriptionPaused.ts +58 -0
- package/src/communications/contracts/subscriptionPaymentExpired.ts +83 -0
- package/src/communications/contracts/subscriptionPaymentFailed.ts +117 -0
- package/src/communications/contracts/subscriptionPaymentRecovered.ts +50 -0
- package/src/communications/contracts/subscriptionRenewalAtRisk.ts +85 -0
- package/src/communications/contracts/subscriptionRenewalUpcoming.ts +103 -0
- package/src/communications/contracts/subscriptionResumed.ts +60 -0
- package/src/communications/contracts/subscriptionWelcome.ts +102 -0
- package/src/communications/contracts/subscriptionWinback.ts +62 -0
- package/src/communications/contracts/transactionalDelivery.ts +43 -0
- package/src/communications/contracts/types.ts +58 -0
- package/src/communications/contribution.ts +33 -0
- package/src/communications/deliveryReconciliation.ts +108 -0
- package/src/communications/emailEgress.ts +111 -0
- package/src/communications/emailHealthAssessment.ts +106 -0
- package/src/communications/emailHealthMetricsPort.ts +17 -0
- package/src/communications/emailNotificationControl.ts +28 -0
- package/src/communications/emailObservation.ts +43 -0
- package/src/communications/emailTransport.ts +167 -0
- package/src/communications/errors.ts +34 -0
- package/src/communications/index.ts +47 -0
- package/src/communications/integrationEventSignature.ts +49 -0
- package/src/communications/klaviyo/consentPush.ts +19 -0
- package/src/communications/klaviyo/index.ts +649 -0
- package/src/communications/managedTransactionalDeliveryStore.ts +59 -0
- package/src/communications/nativeOperations.ts +40 -0
- package/src/communications/newsletterIntegrationContracts.ts +154 -0
- package/src/communications/newsletterWebhookPort.ts +104 -0
- package/src/communications/newsletterWebhookProcessing.ts +102 -0
- package/src/communications/originPolicy.ts +151 -0
- package/src/communications/postgresCommunicationSync.ts +127 -0
- package/src/communications/postgresConsentEvaluator.ts +49 -0
- package/src/communications/postgresDeliveryReconciliation.ts +101 -0
- package/src/communications/postgresNativeOperations.ts +55 -0
- package/src/communications/postgresNotificationRecipients.ts +57 -0
- package/src/communications/postgresTransactionalDeliveryStore.ts +79 -0
- package/src/communications/preferencesToken.ts +62 -0
- package/src/communications/publicPreferenceToken.ts +68 -0
- package/src/communications/resend/index.ts +350 -0
- package/src/communications/shipmentNotifications.ts +78 -0
- package/src/communications/sql.ts +7 -0
- package/src/communications/standardWebhooks.ts +84 -0
- package/src/communications/status.ts +51 -0
- package/src/communications/transactionalDelivery.ts +114 -0
- package/src/communications/transactionalDeliveryIdentifier.ts +9 -0
- package/src/communications/unsubscribeToken.ts +186 -0
- package/src/communications/validation.ts +3 -0
- package/src/composition/catalogContribution.ts +32 -0
- package/src/composition/index.ts +1 -0
- package/src/http/index.ts +1 -0
- package/src/http/webhookSignature.ts +96 -0
- package/src/inventory/adminInventory.ts +251 -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 +21 -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 +104 -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 +184 -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 +260 -0
- package/src/pricing/dbBackedCommerceQuoteSnapshotVerifier.ts +49 -0
- package/src/pricing/index.ts +52 -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/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/contracts/index.ts +387 -0
- package/src/promotions/index.ts +22 -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 +284 -0
- package/src/promotions/promotionQuoteBinding.ts +158 -0
- package/src/promotions/quoteAutomaticPromotions.ts +58 -0
- package/src/promotions/quotePromoDiscounts.ts +185 -0
- package/src/promotions/quotePromotionCodeAdjustments.ts +277 -0
- package/src/promotions/quotePromotionV2.ts +223 -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/contracts/address.ts +71 -0
- package/src/shipping/contracts/delivery.ts +114 -0
- package/src/shipping/contracts/index.ts +18 -0
- package/src/shipping/contracts/shippingRate.ts +7 -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 +23 -0
- package/src/shipping/pickupPointSearchPort.ts +8 -0
- package/src/shipping/readDeliverySelectionEvidence.ts +51 -0
- package/src/shipping/shippingRatePorts.ts +36 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
-- Public platform communications outbox rail: the queue table, the dormant-event-type
|
|
2
|
+
-- allowlist, and the claim/ack protocol that drains them.
|
|
3
|
+
--
|
|
4
|
+
-- WHAT THIS FORWARD SHIPS, AND WHY IT IS THE FIRST ONE CARRYING FUNCTIONS.
|
|
5
|
+
-- The baseline and the read-parity forward both hold `grep -c 'CREATE FUNCTION'` = 0 on
|
|
6
|
+
-- purpose. This migration breaks that property deliberately, because the dispatch rail
|
|
7
|
+
-- has no non-RPC surface: claim is an atomic `UPDATE ... FOR UPDATE SKIP LOCKED` that
|
|
8
|
+
-- hands back a claim token and evaluates a per-aggregate ordering barrier inside the same
|
|
9
|
+
-- statement. Expressing it through the gateway's query builder would mean reimplementing
|
|
10
|
+
-- pessimistic locking in the application, i.e. a second and divergent rail. Four functions
|
|
11
|
+
-- is the whole crossing: no privilege model, no `private` schema, no queue statistics, no
|
|
12
|
+
-- pruning, no preview-matrix claim scope, and above all no enqueue -- rows are written by
|
|
13
|
+
-- capabilities that own their own business logic, and none of them is authored here.
|
|
14
|
+
--
|
|
15
|
+
-- AUTHORED, NOT COPIED. The protocol below was written for this migration against the
|
|
16
|
+
-- observable contract the platform outbox store port issues (five named RPC arguments sets,
|
|
17
|
+
-- a boolean/text/integer/SETOF return shape). It is not a cut of any historical migration:
|
|
18
|
+
-- the provider-specific idempotency window and the hardcoded product event-type vocabulary
|
|
19
|
+
-- that the managed implementation calls into are absent, the preview-matrix claim scope is
|
|
20
|
+
-- absent, row-level security and role grants are absent because this kernel creates no
|
|
21
|
+
-- roles to grant to, `SECURITY DEFINER` is absent for the same reason, every constraint is
|
|
22
|
+
-- named rather than left to a generated identifier, and `CREATE` is unconditional because a
|
|
23
|
+
-- manifest-ordered forward runs exactly once against a known prefix -- `IF NOT EXISTS` there
|
|
24
|
+
-- would hide the drift the migration ledger exists to catch. `SET search_path` is kept: it
|
|
25
|
+
-- is a real injection-hardening property that does not depend on a role model.
|
|
26
|
+
|
|
27
|
+
CREATE TABLE public.outbox_events (
|
|
28
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
29
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
30
|
+
available_at timestamptz NOT NULL DEFAULT now(),
|
|
31
|
+
processed_at timestamptz,
|
|
32
|
+
aggregate_type text NOT NULL,
|
|
33
|
+
aggregate_id uuid NOT NULL,
|
|
34
|
+
event_type text NOT NULL,
|
|
35
|
+
idempotency_key text NOT NULL,
|
|
36
|
+
status text NOT NULL DEFAULT 'pending',
|
|
37
|
+
attempts integer NOT NULL DEFAULT 0,
|
|
38
|
+
payload jsonb NOT NULL,
|
|
39
|
+
error text,
|
|
40
|
+
metadata jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
41
|
+
CONSTRAINT outbox_events_aggregate_type_nonempty_check CHECK (btrim(aggregate_type) <> ''),
|
|
42
|
+
CONSTRAINT outbox_events_event_type_nonempty_check CHECK (btrim(event_type) <> ''),
|
|
43
|
+
CONSTRAINT outbox_events_idempotency_key_nonempty_check CHECK (btrim(idempotency_key) <> ''),
|
|
44
|
+
CONSTRAINT outbox_events_attempts_check CHECK (attempts >= 0),
|
|
45
|
+
CONSTRAINT outbox_events_status_check
|
|
46
|
+
CHECK (status IN ('pending', 'processing', 'processed', 'failed', 'discarded')),
|
|
47
|
+
CONSTRAINT outbox_events_event_type_idempotency_key_key UNIQUE (event_type, idempotency_key)
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
CREATE INDEX idx_outbox_events_status_available
|
|
51
|
+
ON public.outbox_events (status, available_at);
|
|
52
|
+
|
|
53
|
+
CREATE INDEX idx_outbox_events_aggregate
|
|
54
|
+
ON public.outbox_events (aggregate_type, aggregate_id);
|
|
55
|
+
|
|
56
|
+
-- The claim barrier below refuses to skip an older unprocessed row for the same aggregate,
|
|
57
|
+
-- INCLUDING one whose event type the caller does not know about. Without a way to declare a
|
|
58
|
+
-- type intentionally unconsumed, a single retired producer would stall its aggregate
|
|
59
|
+
-- forever. This table is that declaration, and it ships empty: which types are dormant is
|
|
60
|
+
-- operator data, not platform content.
|
|
61
|
+
CREATE TABLE public.outbox_dormant_event_types (
|
|
62
|
+
event_type text PRIMARY KEY,
|
|
63
|
+
owner text NOT NULL,
|
|
64
|
+
reason text NOT NULL,
|
|
65
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
66
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
67
|
+
CONSTRAINT outbox_dormant_event_types_event_type_nonempty_check CHECK (btrim(event_type) <> ''),
|
|
68
|
+
CONSTRAINT outbox_dormant_event_types_owner_nonempty_check CHECK (btrim(owner) <> ''),
|
|
69
|
+
CONSTRAINT outbox_dormant_event_types_reason_nonempty_check CHECK (btrim(reason) <> '')
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
-- Claim a batch for one allowlist of event types.
|
|
73
|
+
--
|
|
74
|
+
-- Three properties make this more than a SELECT, and each is load-bearing:
|
|
75
|
+
-- 1. an empty allowlist is refused, never widened -- a caller that forgot its filter must
|
|
76
|
+
-- not drain every event type on the instance;
|
|
77
|
+
-- 2. rows whose attempts already reached the ceiling are discarded before the scan, so an
|
|
78
|
+
-- exhausted row cannot be re-selected on every tick;
|
|
79
|
+
-- 3. per aggregate, an older unprocessed row blocks the newer one. A prior of an event
|
|
80
|
+
-- type the caller neither claims nor knows also blocks, unless it has been declared
|
|
81
|
+
-- dormant -- ordering within an aggregate is the guarantee producers rely on.
|
|
82
|
+
-- The claim token written into metadata is the authorization for every later acknowledgement:
|
|
83
|
+
-- knowing the row id is not enough, which is what makes a stale ack detectable rather than
|
|
84
|
+
-- destructive.
|
|
85
|
+
CREATE FUNCTION public.outbox_claim_batch(
|
|
86
|
+
p_event_types text[],
|
|
87
|
+
p_known_event_types text[] DEFAULT ARRAY[]::text[],
|
|
88
|
+
p_batch_size integer DEFAULT 25,
|
|
89
|
+
p_visibility_seconds integer DEFAULT 300,
|
|
90
|
+
p_max_attempts integer DEFAULT 8
|
|
91
|
+
)
|
|
92
|
+
RETURNS SETOF public.outbox_events
|
|
93
|
+
LANGUAGE plpgsql
|
|
94
|
+
SET search_path = public, pg_catalog
|
|
95
|
+
AS $$
|
|
96
|
+
DECLARE
|
|
97
|
+
v_batch integer := LEAST(GREATEST(COALESCE(p_batch_size, 25), 1), 100);
|
|
98
|
+
v_visibility integer := LEAST(GREATEST(COALESCE(p_visibility_seconds, 300), 300), 3600);
|
|
99
|
+
v_max integer := LEAST(GREATEST(COALESCE(p_max_attempts, 8), 1), 20);
|
|
100
|
+
v_known text[];
|
|
101
|
+
BEGIN
|
|
102
|
+
IF p_event_types IS NULL OR cardinality(p_event_types) = 0 THEN
|
|
103
|
+
RAISE EXCEPTION 'outbox_claim_allowlist_required' USING ERRCODE = '22023';
|
|
104
|
+
END IF;
|
|
105
|
+
|
|
106
|
+
-- Everything the caller can recognise: what it claims now, plus what it declares it knows
|
|
107
|
+
-- about. A prior outside this set is treated as foreign, and only the dormant table can
|
|
108
|
+
-- release it.
|
|
109
|
+
SELECT array_agg(DISTINCT event_type)
|
|
110
|
+
INTO v_known
|
|
111
|
+
FROM unnest(COALESCE(p_known_event_types, ARRAY[]::text[]) || p_event_types) AS known(event_type)
|
|
112
|
+
WHERE event_type IS NOT NULL AND btrim(event_type) <> '';
|
|
113
|
+
|
|
114
|
+
WITH exhausted AS (
|
|
115
|
+
SELECT event.id
|
|
116
|
+
FROM public.outbox_events event
|
|
117
|
+
WHERE event.event_type = ANY (p_event_types)
|
|
118
|
+
AND event.status IN ('pending', 'failed', 'processing')
|
|
119
|
+
AND event.available_at <= now()
|
|
120
|
+
AND event.attempts >= v_max
|
|
121
|
+
ORDER BY event.created_at, event.id
|
|
122
|
+
LIMIT 100
|
|
123
|
+
FOR UPDATE SKIP LOCKED
|
|
124
|
+
)
|
|
125
|
+
UPDATE public.outbox_events event
|
|
126
|
+
SET status = 'discarded',
|
|
127
|
+
error = left(COALESCE(event.error, '') || ' | max_attempts_exhausted_at_claim', 2000),
|
|
128
|
+
metadata = event.metadata || jsonb_build_object(
|
|
129
|
+
'discardReason', 'max_attempts',
|
|
130
|
+
'discardedAt', now(),
|
|
131
|
+
'finalAttempts', event.attempts)
|
|
132
|
+
FROM exhausted
|
|
133
|
+
WHERE event.id = exhausted.id;
|
|
134
|
+
|
|
135
|
+
RETURN QUERY
|
|
136
|
+
WITH candidates AS (
|
|
137
|
+
SELECT event.id
|
|
138
|
+
FROM public.outbox_events event
|
|
139
|
+
WHERE event.event_type = ANY (p_event_types)
|
|
140
|
+
AND event.available_at <= now()
|
|
141
|
+
AND event.status IN ('pending', 'failed', 'processing')
|
|
142
|
+
AND event.attempts < v_max
|
|
143
|
+
AND NOT EXISTS (
|
|
144
|
+
SELECT 1
|
|
145
|
+
FROM public.outbox_events prior
|
|
146
|
+
WHERE prior.aggregate_type = event.aggregate_type
|
|
147
|
+
AND prior.aggregate_id = event.aggregate_id
|
|
148
|
+
AND prior.status IN ('pending', 'failed', 'processing')
|
|
149
|
+
AND (prior.created_at, prior.id) < (event.created_at, event.id)
|
|
150
|
+
AND (
|
|
151
|
+
prior.event_type = ANY (p_event_types)
|
|
152
|
+
OR (
|
|
153
|
+
prior.event_type <> ALL (COALESCE(v_known, ARRAY[]::text[]))
|
|
154
|
+
AND NOT EXISTS (
|
|
155
|
+
SELECT 1
|
|
156
|
+
FROM public.outbox_dormant_event_types dormant
|
|
157
|
+
WHERE dormant.event_type = prior.event_type
|
|
158
|
+
)
|
|
159
|
+
)
|
|
160
|
+
))
|
|
161
|
+
ORDER BY event.created_at, event.id
|
|
162
|
+
LIMIT v_batch
|
|
163
|
+
FOR UPDATE SKIP LOCKED
|
|
164
|
+
)
|
|
165
|
+
UPDATE public.outbox_events event
|
|
166
|
+
SET status = 'processing',
|
|
167
|
+
attempts = event.attempts + 1,
|
|
168
|
+
available_at = now() + make_interval(secs => v_visibility),
|
|
169
|
+
metadata = event.metadata || jsonb_build_object(
|
|
170
|
+
'lastClaimedAt', now(),
|
|
171
|
+
'claimToken', gen_random_uuid()::text)
|
|
172
|
+
FROM candidates
|
|
173
|
+
WHERE event.id = candidates.id
|
|
174
|
+
RETURNING event.*;
|
|
175
|
+
END;
|
|
176
|
+
$$;
|
|
177
|
+
|
|
178
|
+
-- Acknowledge success. Returns false rather than raising when the row is no longer the
|
|
179
|
+
-- caller's: a lease that expired and was re-claimed elsewhere is an ordinary race, and the
|
|
180
|
+
-- caller logs it instead of aborting a batch.
|
|
181
|
+
CREATE FUNCTION public.outbox_mark_processed(
|
|
182
|
+
p_event_id uuid,
|
|
183
|
+
p_claim_token text,
|
|
184
|
+
p_metadata jsonb DEFAULT '{}'::jsonb
|
|
185
|
+
)
|
|
186
|
+
RETURNS boolean
|
|
187
|
+
LANGUAGE sql
|
|
188
|
+
SET search_path = public, pg_catalog
|
|
189
|
+
AS $$
|
|
190
|
+
WITH updated AS (
|
|
191
|
+
UPDATE public.outbox_events
|
|
192
|
+
SET status = 'processed',
|
|
193
|
+
processed_at = now(),
|
|
194
|
+
error = NULL,
|
|
195
|
+
metadata = metadata || COALESCE(p_metadata, '{}'::jsonb)
|
|
196
|
+
WHERE id = p_event_id
|
|
197
|
+
AND status = 'processing'
|
|
198
|
+
AND metadata->>'claimToken' = p_claim_token
|
|
199
|
+
RETURNING id
|
|
200
|
+
)
|
|
201
|
+
SELECT EXISTS (SELECT 1 FROM updated);
|
|
202
|
+
$$;
|
|
203
|
+
|
|
204
|
+
-- Acknowledge failure. The outcome the handler asks for is a request, not a verdict: a
|
|
205
|
+
-- 'retry' on a row that has already spent its attempts becomes a discard, so the ceiling is
|
|
206
|
+
-- enforced in one place instead of in every caller.
|
|
207
|
+
--
|
|
208
|
+
-- 'snooze' means the downstream is unavailable rather than the row being bad, so the attempt
|
|
209
|
+
-- taken at claim is refunded -- an outage must not consume the DLQ budget of the events it
|
|
210
|
+
-- happened to touch. Retry delay is exponential with equal jitter in [d/2, d]: without the
|
|
211
|
+
-- jitter every row that failed in the same tick returns in the same later tick, and the
|
|
212
|
+
-- convoy reforms on each retry instead of dispersing.
|
|
213
|
+
CREATE FUNCTION public.outbox_mark_failed(
|
|
214
|
+
p_event_id uuid,
|
|
215
|
+
p_claim_token text,
|
|
216
|
+
p_error text,
|
|
217
|
+
p_outcome text DEFAULT 'retry',
|
|
218
|
+
p_base_delay_seconds integer DEFAULT 60,
|
|
219
|
+
p_max_delay_seconds integer DEFAULT 3600,
|
|
220
|
+
p_max_attempts integer DEFAULT 8,
|
|
221
|
+
p_snooze_seconds integer DEFAULT 300
|
|
222
|
+
)
|
|
223
|
+
RETURNS text
|
|
224
|
+
LANGUAGE plpgsql
|
|
225
|
+
SET search_path = public, pg_catalog
|
|
226
|
+
AS $$
|
|
227
|
+
DECLARE
|
|
228
|
+
v_row public.outbox_events%ROWTYPE;
|
|
229
|
+
v_base integer := LEAST(GREATEST(COALESCE(p_base_delay_seconds, 60), 5), 3600);
|
|
230
|
+
v_cap integer;
|
|
231
|
+
v_max integer := LEAST(GREATEST(COALESCE(p_max_attempts, 8), 1), 20);
|
|
232
|
+
v_snooze integer := LEAST(GREATEST(COALESCE(p_snooze_seconds, 300), 60), 3600);
|
|
233
|
+
v_delay double precision;
|
|
234
|
+
BEGIN
|
|
235
|
+
IF p_outcome IS NULL OR p_outcome NOT IN ('retry', 'discard', 'snooze') THEN
|
|
236
|
+
RAISE EXCEPTION 'outbox_mark_failed_invalid_outcome' USING ERRCODE = '22023';
|
|
237
|
+
END IF;
|
|
238
|
+
|
|
239
|
+
v_cap := LEAST(GREATEST(v_base, COALESCE(p_max_delay_seconds, 3600)), 86400);
|
|
240
|
+
|
|
241
|
+
SELECT *
|
|
242
|
+
INTO v_row
|
|
243
|
+
FROM public.outbox_events
|
|
244
|
+
WHERE id = p_event_id
|
|
245
|
+
AND status = 'processing'
|
|
246
|
+
AND metadata->>'claimToken' = p_claim_token
|
|
247
|
+
FOR UPDATE;
|
|
248
|
+
|
|
249
|
+
IF NOT FOUND THEN
|
|
250
|
+
RETURN 'missed';
|
|
251
|
+
END IF;
|
|
252
|
+
|
|
253
|
+
IF p_outcome = 'discard' OR (p_outcome = 'retry' AND v_row.attempts >= v_max) THEN
|
|
254
|
+
UPDATE public.outbox_events
|
|
255
|
+
SET status = 'discarded',
|
|
256
|
+
error = left(p_error, 2000),
|
|
257
|
+
metadata = metadata || jsonb_build_object(
|
|
258
|
+
'discardReason',
|
|
259
|
+
CASE WHEN p_outcome = 'discard' THEN 'permanent_error' ELSE 'max_attempts' END,
|
|
260
|
+
'discardedAt', now(),
|
|
261
|
+
'finalAttempts', v_row.attempts)
|
|
262
|
+
WHERE id = v_row.id;
|
|
263
|
+
RETURN 'discarded';
|
|
264
|
+
END IF;
|
|
265
|
+
|
|
266
|
+
IF p_outcome = 'snooze' THEN
|
|
267
|
+
UPDATE public.outbox_events
|
|
268
|
+
SET status = 'failed',
|
|
269
|
+
attempts = GREATEST(v_row.attempts - 1, 0),
|
|
270
|
+
available_at = now() + make_interval(secs => v_snooze),
|
|
271
|
+
error = left(p_error, 2000),
|
|
272
|
+
metadata = metadata || jsonb_build_object(
|
|
273
|
+
'snoozeCount', COALESCE((metadata->>'snoozeCount')::integer, 0) + 1,
|
|
274
|
+
'lastSnoozedAt', now())
|
|
275
|
+
WHERE id = v_row.id;
|
|
276
|
+
RETURN 'snoozed';
|
|
277
|
+
END IF;
|
|
278
|
+
|
|
279
|
+
v_delay := LEAST(
|
|
280
|
+
v_cap::double precision,
|
|
281
|
+
v_base::double precision * power(2, LEAST(GREATEST(v_row.attempts - 1, 0), 16))
|
|
282
|
+
) * (0.5 + random() * 0.5);
|
|
283
|
+
|
|
284
|
+
UPDATE public.outbox_events
|
|
285
|
+
SET status = 'failed',
|
|
286
|
+
available_at = now() + make_interval(secs => v_delay),
|
|
287
|
+
error = left(p_error, 2000)
|
|
288
|
+
WHERE id = v_row.id;
|
|
289
|
+
RETURN 'failed';
|
|
290
|
+
END;
|
|
291
|
+
$$;
|
|
292
|
+
|
|
293
|
+
-- Hand back rows the caller claimed but never ran -- a drain loop that aborts mid-batch, or
|
|
294
|
+
-- one handler reporting the downstream is out. The attempt taken at claim is refunded for
|
|
295
|
+
-- exactly the same reason as in 'snooze': nothing was tried, so nothing was spent. Ids and
|
|
296
|
+
-- tokens are supplied as parallel arrays and must agree in length, because a mismatch means
|
|
297
|
+
-- the caller lost track of which token belongs to which row and releasing the wrong pairing
|
|
298
|
+
-- would silently release nothing.
|
|
299
|
+
CREATE FUNCTION public.outbox_release_unprocessed(
|
|
300
|
+
p_event_ids uuid[],
|
|
301
|
+
p_claim_tokens text[],
|
|
302
|
+
p_delay_seconds integer DEFAULT 0
|
|
303
|
+
)
|
|
304
|
+
RETURNS integer
|
|
305
|
+
LANGUAGE plpgsql
|
|
306
|
+
SET search_path = public, pg_catalog
|
|
307
|
+
AS $$
|
|
308
|
+
DECLARE
|
|
309
|
+
v_delay integer := LEAST(GREATEST(COALESCE(p_delay_seconds, 0), 0), 3600);
|
|
310
|
+
v_count integer;
|
|
311
|
+
BEGIN
|
|
312
|
+
IF p_event_ids IS NULL OR p_claim_tokens IS NULL
|
|
313
|
+
OR cardinality(p_event_ids) <> cardinality(p_claim_tokens) THEN
|
|
314
|
+
RAISE EXCEPTION 'outbox_release_invalid_input' USING ERRCODE = '22023';
|
|
315
|
+
END IF;
|
|
316
|
+
|
|
317
|
+
UPDATE public.outbox_events event
|
|
318
|
+
SET status = 'pending',
|
|
319
|
+
available_at = now() + make_interval(secs => v_delay),
|
|
320
|
+
attempts = GREATEST(event.attempts - 1, 0)
|
|
321
|
+
FROM unnest(p_event_ids, p_claim_tokens) AS released(id, token)
|
|
322
|
+
WHERE event.id = released.id
|
|
323
|
+
AND event.status = 'processing'
|
|
324
|
+
AND event.metadata->>'claimToken' = released.token;
|
|
325
|
+
|
|
326
|
+
GET DIAGNOSTICS v_count = ROW_COUNT;
|
|
327
|
+
RETURN v_count;
|
|
328
|
+
END;
|
|
329
|
+
$$;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
-- Public platform catalogue attributes: the three columns a public listing needs.
|
|
2
|
+
--
|
|
3
|
+
-- Authored from scratch for this delta. The read-parity forward that created these two
|
|
4
|
+
-- relations deliberately left every sellable attribute out, on the ruling that the slice
|
|
5
|
+
-- which actually executes them would author them as its own forward. This is that slice,
|
|
6
|
+
-- and the demand is no longer a guess: the shipped response contract was validated against
|
|
7
|
+
-- an assembly read out of a live kernel database, and it refused with thirteen issues over
|
|
8
|
+
-- five field paths -- a product line, a positive net weight per sellable unit, a non-empty
|
|
9
|
+
-- declared composition with at least one entry, and a non-empty format label. Every one of
|
|
10
|
+
-- them is `too_small`, which is the schema saying "you gave me nothing", not "you gave me
|
|
11
|
+
-- the wrong thing". Nothing here is optional decoration: without these three columns the
|
|
12
|
+
-- listing route answers 502 for an operator's own rows, on any schema.
|
|
13
|
+
--
|
|
14
|
+
-- WHY THESE THREE NAMES AND NOT THE FIVE THAT WERE SIZED. The neutral projection is served
|
|
15
|
+
-- to BOTH bundles by the discovery harness, so a column this kernel invents and the managed
|
|
16
|
+
-- chain lacks would fail the managed half of the proof on contact. The names below are the
|
|
17
|
+
-- ones that chain already carries with a compatible type and, critically, with no foreign
|
|
18
|
+
-- key. Two further names were sized and are refused here: on the managed chain both are
|
|
19
|
+
-- foreign keys into lookup relations of sellable-unit vocabulary, so honouring them would
|
|
20
|
+
-- force this kernel to grow two dictionaries of exactly the domain language the public
|
|
21
|
+
-- platform must not own. The packaging unit therefore stays at the assembly's own default
|
|
22
|
+
-- and the calorific figures stay absent, which is why the composition this platform can
|
|
23
|
+
-- express is a list of declared entries and not the richer card set an overlay keeps beside
|
|
24
|
+
-- it.
|
|
25
|
+
--
|
|
26
|
+
-- WHY NULLABILITY IS SPENT AS A DEFAULT AND NOT AS NULL. Every column arrives NOT NULL with
|
|
27
|
+
-- a neutral zero value -- an empty array, an empty object, a zero integer -- so an already
|
|
28
|
+
-- populated deployment boots unchanged and no read has to branch on absence. A zero weight
|
|
29
|
+
-- and an empty composition are still refused by the response contract, which is the correct
|
|
30
|
+
-- outcome: the platform now HAS somewhere to put the answer, and an operator who has not
|
|
31
|
+
-- put one there has published nothing, rather than published something broken. No CHECK is
|
|
32
|
+
-- added, for the same reason the managed chain has none on these columns -- the shape that
|
|
33
|
+
-- matters is enforced by the response contract, one layer up, where it can name the field.
|
|
34
|
+
--
|
|
35
|
+
-- NO FUNCTION, NO TRIGGER, NO POLICY, NO GRANT, NO INDEX. Three ALTER TABLE statements and
|
|
36
|
+
-- three comments. The read path that consumes them is a projection widening in application
|
|
37
|
+
-- code, not a database behaviour.
|
|
38
|
+
|
|
39
|
+
ALTER TABLE public.catalog_products
|
|
40
|
+
ADD COLUMN ingredients text[] NOT NULL DEFAULT ARRAY[]::text[],
|
|
41
|
+
ADD COLUMN marketing_content jsonb NOT NULL DEFAULT '{}'::jsonb;
|
|
42
|
+
|
|
43
|
+
ALTER TABLE public.catalog_skus
|
|
44
|
+
ADD COLUMN net_weight_g integer NOT NULL DEFAULT 0;
|
|
45
|
+
|
|
46
|
+
COMMENT ON COLUMN public.catalog_products.ingredients IS
|
|
47
|
+
'Declared composition, one free-text entry per line. An entry may end in a percentage share; the read splits it, and keeps the whole entry as the label when it does not.';
|
|
48
|
+
COMMENT ON COLUMN public.catalog_products.marketing_content IS
|
|
49
|
+
'Front-of-house copy the platform stores and never interprets. The public read looks up two keys in it: line_name and format_marketing_copy.';
|
|
50
|
+
COMMENT ON COLUMN public.catalog_skus.net_weight_g IS
|
|
51
|
+
'Net weight of one sellable unit, in grams. Zero means the operator has not declared one, and the response contract refuses such a unit.';
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
-- Public platform transactional-delivery receipt capability.
|
|
2
|
+
--
|
|
3
|
+
-- The forward exposes one neutral durable receipt and three invoker-rights RPCs:
|
|
4
|
+
-- read, record accepted, and record failed. It persists only a command digest,
|
|
5
|
+
-- a neutral delivery reference, a constrained failure code, transition state,
|
|
6
|
+
-- attempt count and timestamps. Delivery content and transport diagnostics stay
|
|
7
|
+
-- outside this compact kernel boundary.
|
|
8
|
+
|
|
9
|
+
CREATE TABLE public.transactional_delivery_receipts (
|
|
10
|
+
idempotency_key text PRIMARY KEY,
|
|
11
|
+
command_fingerprint text NOT NULL,
|
|
12
|
+
state text NOT NULL,
|
|
13
|
+
delivery_reference text,
|
|
14
|
+
error_code text,
|
|
15
|
+
attempt_count integer NOT NULL,
|
|
16
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
17
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
18
|
+
accepted_at timestamptz,
|
|
19
|
+
failed_at timestamptz,
|
|
20
|
+
CONSTRAINT transactional_delivery_receipts_idempotency_key_nonempty_check
|
|
21
|
+
CHECK (btrim(idempotency_key) <> ''),
|
|
22
|
+
CONSTRAINT transactional_delivery_receipts_idempotency_key_format_check
|
|
23
|
+
CHECK (idempotency_key ~ '^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$'),
|
|
24
|
+
CONSTRAINT transactional_delivery_receipts_fingerprint_format_check
|
|
25
|
+
CHECK (command_fingerprint ~ '^[a-f0-9]{64}$'),
|
|
26
|
+
CONSTRAINT transactional_delivery_receipts_state_check
|
|
27
|
+
CHECK (state IN ('accepted', 'failed')),
|
|
28
|
+
CONSTRAINT transactional_delivery_receipts_attempt_count_check
|
|
29
|
+
CHECK (attempt_count >= 1),
|
|
30
|
+
CONSTRAINT transactional_delivery_receipts_evidence_shape_check
|
|
31
|
+
CHECK (
|
|
32
|
+
(state = 'accepted'
|
|
33
|
+
AND delivery_reference IS NOT NULL
|
|
34
|
+
AND error_code IS NULL
|
|
35
|
+
AND accepted_at IS NOT NULL)
|
|
36
|
+
OR
|
|
37
|
+
(state = 'failed'
|
|
38
|
+
AND delivery_reference IS NULL
|
|
39
|
+
AND error_code IS NOT NULL
|
|
40
|
+
AND accepted_at IS NULL
|
|
41
|
+
AND failed_at IS NOT NULL)
|
|
42
|
+
),
|
|
43
|
+
CONSTRAINT transactional_delivery_receipts_timestamp_order_check
|
|
44
|
+
CHECK (
|
|
45
|
+
updated_at >= created_at
|
|
46
|
+
AND (accepted_at IS NULL OR accepted_at >= created_at)
|
|
47
|
+
AND (failed_at IS NULL OR failed_at >= created_at)
|
|
48
|
+
)
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
CREATE FUNCTION public.transactional_delivery_read_receipt(
|
|
52
|
+
p_idempotency_key text
|
|
53
|
+
)
|
|
54
|
+
RETURNS SETOF public.transactional_delivery_receipts
|
|
55
|
+
LANGUAGE sql
|
|
56
|
+
STABLE
|
|
57
|
+
SET search_path = public, pg_catalog
|
|
58
|
+
AS $$
|
|
59
|
+
SELECT receipt.*
|
|
60
|
+
FROM public.transactional_delivery_receipts AS receipt
|
|
61
|
+
WHERE receipt.idempotency_key = p_idempotency_key;
|
|
62
|
+
$$;
|
|
63
|
+
|
|
64
|
+
CREATE FUNCTION public.transactional_delivery_record_accepted(
|
|
65
|
+
p_idempotency_key text,
|
|
66
|
+
p_command_fingerprint text,
|
|
67
|
+
p_delivery_reference text
|
|
68
|
+
)
|
|
69
|
+
RETURNS public.transactional_delivery_receipts
|
|
70
|
+
LANGUAGE plpgsql
|
|
71
|
+
SET search_path = public, pg_catalog
|
|
72
|
+
AS $$
|
|
73
|
+
DECLARE
|
|
74
|
+
v_receipt public.transactional_delivery_receipts%ROWTYPE;
|
|
75
|
+
BEGIN
|
|
76
|
+
IF p_idempotency_key IS NULL
|
|
77
|
+
OR p_idempotency_key !~ '^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$' THEN
|
|
78
|
+
RAISE EXCEPTION 'transactional_delivery_invalid_idempotency_key' USING ERRCODE = '22023';
|
|
79
|
+
END IF;
|
|
80
|
+
IF p_command_fingerprint IS NULL OR p_command_fingerprint !~ '^[a-f0-9]{64}$' THEN
|
|
81
|
+
RAISE EXCEPTION 'transactional_delivery_invalid_command_fingerprint' USING ERRCODE = '22023';
|
|
82
|
+
END IF;
|
|
83
|
+
IF p_delivery_reference IS NULL
|
|
84
|
+
OR p_delivery_reference !~ '^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$' THEN
|
|
85
|
+
RAISE EXCEPTION 'transactional_delivery_invalid_delivery_reference' USING ERRCODE = '22023';
|
|
86
|
+
END IF;
|
|
87
|
+
|
|
88
|
+
LOOP
|
|
89
|
+
SELECT * INTO v_receipt
|
|
90
|
+
FROM public.transactional_delivery_receipts
|
|
91
|
+
WHERE idempotency_key = p_idempotency_key
|
|
92
|
+
FOR UPDATE;
|
|
93
|
+
|
|
94
|
+
IF FOUND THEN
|
|
95
|
+
IF v_receipt.command_fingerprint <> p_command_fingerprint THEN
|
|
96
|
+
RAISE EXCEPTION 'transactional_delivery_command_fingerprint_conflict' USING ERRCODE = '22023';
|
|
97
|
+
END IF;
|
|
98
|
+
IF v_receipt.state = 'accepted' THEN
|
|
99
|
+
RETURN v_receipt;
|
|
100
|
+
END IF;
|
|
101
|
+
|
|
102
|
+
UPDATE public.transactional_delivery_receipts
|
|
103
|
+
SET state = 'accepted',
|
|
104
|
+
delivery_reference = p_delivery_reference,
|
|
105
|
+
error_code = NULL,
|
|
106
|
+
attempt_count = attempt_count + 1,
|
|
107
|
+
updated_at = now(),
|
|
108
|
+
accepted_at = now()
|
|
109
|
+
WHERE idempotency_key = p_idempotency_key
|
|
110
|
+
RETURNING * INTO v_receipt;
|
|
111
|
+
RETURN v_receipt;
|
|
112
|
+
END IF;
|
|
113
|
+
|
|
114
|
+
INSERT INTO public.transactional_delivery_receipts (
|
|
115
|
+
idempotency_key,
|
|
116
|
+
command_fingerprint,
|
|
117
|
+
state,
|
|
118
|
+
delivery_reference,
|
|
119
|
+
attempt_count,
|
|
120
|
+
accepted_at
|
|
121
|
+
) VALUES (
|
|
122
|
+
p_idempotency_key,
|
|
123
|
+
p_command_fingerprint,
|
|
124
|
+
'accepted',
|
|
125
|
+
p_delivery_reference,
|
|
126
|
+
1,
|
|
127
|
+
now()
|
|
128
|
+
)
|
|
129
|
+
ON CONFLICT (idempotency_key) DO NOTHING
|
|
130
|
+
RETURNING * INTO v_receipt;
|
|
131
|
+
|
|
132
|
+
IF FOUND THEN
|
|
133
|
+
RETURN v_receipt;
|
|
134
|
+
END IF;
|
|
135
|
+
END LOOP;
|
|
136
|
+
END;
|
|
137
|
+
$$;
|
|
138
|
+
|
|
139
|
+
CREATE FUNCTION public.transactional_delivery_record_failed(
|
|
140
|
+
p_idempotency_key text,
|
|
141
|
+
p_command_fingerprint text,
|
|
142
|
+
p_error_code text
|
|
143
|
+
)
|
|
144
|
+
RETURNS public.transactional_delivery_receipts
|
|
145
|
+
LANGUAGE plpgsql
|
|
146
|
+
SET search_path = public, pg_catalog
|
|
147
|
+
AS $$
|
|
148
|
+
DECLARE
|
|
149
|
+
v_receipt public.transactional_delivery_receipts%ROWTYPE;
|
|
150
|
+
BEGIN
|
|
151
|
+
IF p_idempotency_key IS NULL
|
|
152
|
+
OR p_idempotency_key !~ '^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$' THEN
|
|
153
|
+
RAISE EXCEPTION 'transactional_delivery_invalid_idempotency_key' USING ERRCODE = '22023';
|
|
154
|
+
END IF;
|
|
155
|
+
IF p_command_fingerprint IS NULL OR p_command_fingerprint !~ '^[a-f0-9]{64}$' THEN
|
|
156
|
+
RAISE EXCEPTION 'transactional_delivery_invalid_command_fingerprint' USING ERRCODE = '22023';
|
|
157
|
+
END IF;
|
|
158
|
+
IF p_error_code IS NULL OR p_error_code !~ '^[a-z][a-z0-9_.-]{0,127}$' THEN
|
|
159
|
+
RAISE EXCEPTION 'transactional_delivery_invalid_error_code' USING ERRCODE = '22023';
|
|
160
|
+
END IF;
|
|
161
|
+
|
|
162
|
+
LOOP
|
|
163
|
+
SELECT * INTO v_receipt
|
|
164
|
+
FROM public.transactional_delivery_receipts
|
|
165
|
+
WHERE idempotency_key = p_idempotency_key
|
|
166
|
+
FOR UPDATE;
|
|
167
|
+
|
|
168
|
+
IF FOUND THEN
|
|
169
|
+
IF v_receipt.command_fingerprint <> p_command_fingerprint THEN
|
|
170
|
+
RAISE EXCEPTION 'transactional_delivery_command_fingerprint_conflict' USING ERRCODE = '22023';
|
|
171
|
+
END IF;
|
|
172
|
+
IF v_receipt.state = 'accepted' THEN
|
|
173
|
+
RETURN v_receipt;
|
|
174
|
+
END IF;
|
|
175
|
+
|
|
176
|
+
UPDATE public.transactional_delivery_receipts
|
|
177
|
+
SET error_code = p_error_code,
|
|
178
|
+
attempt_count = attempt_count + 1,
|
|
179
|
+
updated_at = now(),
|
|
180
|
+
failed_at = now()
|
|
181
|
+
WHERE idempotency_key = p_idempotency_key
|
|
182
|
+
RETURNING * INTO v_receipt;
|
|
183
|
+
RETURN v_receipt;
|
|
184
|
+
END IF;
|
|
185
|
+
|
|
186
|
+
INSERT INTO public.transactional_delivery_receipts (
|
|
187
|
+
idempotency_key,
|
|
188
|
+
command_fingerprint,
|
|
189
|
+
state,
|
|
190
|
+
error_code,
|
|
191
|
+
attempt_count,
|
|
192
|
+
failed_at
|
|
193
|
+
) VALUES (
|
|
194
|
+
p_idempotency_key,
|
|
195
|
+
p_command_fingerprint,
|
|
196
|
+
'failed',
|
|
197
|
+
p_error_code,
|
|
198
|
+
1,
|
|
199
|
+
now()
|
|
200
|
+
)
|
|
201
|
+
ON CONFLICT (idempotency_key) DO NOTHING
|
|
202
|
+
RETURNING * INTO v_receipt;
|
|
203
|
+
|
|
204
|
+
IF FOUND THEN
|
|
205
|
+
RETURN v_receipt;
|
|
206
|
+
END IF;
|
|
207
|
+
END LOOP;
|
|
208
|
+
END;
|
|
209
|
+
$$;
|