Skip to main content

syrup_rail_postgres/
lib.rs

1//! PostgreSQL schema contract and transaction orchestration for Syrup Rail.
2//!
3//! Production service construction must not expose or invoke a migrator; host
4//! applications materialize versioned install artifacts as immutable migrations.
5
6#![doc = include_str!("../README.md")]
7#![forbid(unsafe_code)]
8
9mod attempts;
10mod billing_portal;
11mod cancellation;
12mod deletion;
13mod discounts;
14mod enrollment_application;
15mod entitlement;
16mod gateway_accounts;
17mod grants;
18mod host_charge_application;
19mod host_charge_reconciliation;
20mod host_charges;
21mod host_error;
22mod lifecycle_quarantine;
23mod lifecycle_reconciliation;
24mod mode_verified_gateway;
25mod operator_review;
26#[cfg(test)]
27mod paid_trial_dunning_tests;
28mod processor_charge_persistence;
29mod processor_charges;
30mod reconciliation;
31mod renewal;
32mod renewal_failure;
33// Production hosts receive only the runtime compatibility assertion. The
34// feature-gated public module retains the checked-in install/upgrade artifacts
35// for schema-contract fixtures and explicit test support without embedding a
36// migrator in ordinary binaries.
37#[cfg(any(test, feature = "schema-contract-test-support"))]
38pub mod schema_contract;
39#[cfg(not(any(test, feature = "schema-contract-test-support")))]
40mod schema_contract;
41mod subscription_billing_service;
42mod subscription_persistence;
43#[cfg(test)]
44mod test_support;
45mod transactions;
46
47pub use attempts::{
48    PaymentAttemptStoreError, admit_subscription_enrollment_submission_in_transaction,
49    admit_subscription_payment_method_replacement_in_transaction,
50    admit_subscription_recovery_submission_in_transaction,
51    admit_subscription_renewal_submission_in_transaction,
52    find_payment_attempt_by_id_in_transaction, lock_payment_attempt_by_idempotency_in_transaction,
53    preflight_subscription_enrollment_in_transaction,
54    preflight_subscription_payment_method_replacement_in_transaction,
55    preflight_subscription_recovery_in_transaction, reserve_subscription_enrollment_in_transaction,
56    reserve_subscription_payment_method_replacement_in_transaction,
57    reserve_subscription_recovery_in_transaction, reserve_subscription_renewal_in_transaction,
58};
59pub use billing_portal::{
60    SubscriptionBillingPortalQueryError, subscription_billing_portal,
61    subscription_payment_history_page,
62};
63pub use cancellation::{SubscriptionCancellationError, cancel_subscription_in_transaction};
64pub use deletion::{billing_deletion_blockers, scrub_subscriber_billing_data};
65pub use discounts::{
66    SubscriptionDiscountOperationError, SubscriptionEnrollmentOfferContext,
67    SubscriptionEnrollmentOfferStage, SubscriptionOfferStore, claim_subscription_discount,
68    claim_subscription_discount_in_transaction, clear_subscription_discount,
69    clear_subscription_discount_in_transaction, create_subscription_discount_code,
70    create_subscription_discount_code_in_transaction, disable_subscription_discount_code,
71    disable_subscription_discount_code_in_transaction, list_subscription_discount_codes,
72    list_subscription_discount_codes_in_transaction,
73    mark_subscription_discount_claim_applied_in_transaction, saved_subscription_discount_claim,
74    saved_subscription_discount_claim_in_transaction, update_subscription_discount_code,
75    update_subscription_discount_code_in_transaction, validate_subscription_discount_code,
76    validate_subscription_discount_code_in_transaction,
77};
78pub use enrollment_application::{
79    AdmittedSubscriptionEnrollment, AdmittedSubscriptionPaymentMethodReplacement,
80    AdmittedSubscriptionRecovery, AdmittedSubscriptionRenewal,
81    SubscriptionEnrollmentAdmissionOutcome, SubscriptionEnrollmentApplicationError,
82    SubscriptionEnrollmentProviderResult, SubscriptionPaymentMethodReplacementAdmissionOutcome,
83    SubscriptionPaymentMethodReplacementProviderResult, SubscriptionRecoveryAdmissionOutcome,
84    SubscriptionRecoveryProviderResult, SubscriptionRenewalAdmissionOutcome,
85    SubscriptionRenewalProviderResult, admit_subscription_enrollment_submission,
86    admit_subscription_payment_method_replacement, admit_subscription_recovery_submission,
87    admit_subscription_renewal_submission,
88    apply_reconciled_subscription_enrollment_gateway_outcome,
89    apply_reconciled_subscription_payment_method_replacement_gateway_outcome,
90    apply_reconciled_subscription_recovery_gateway_outcome,
91    apply_reconciled_subscription_renewal_gateway_outcome,
92    apply_subscription_enrollment_gateway_outcome,
93    apply_subscription_payment_method_replacement_gateway_outcome,
94    apply_subscription_recovery_gateway_outcome, apply_subscription_renewal_gateway_outcome,
95    submit_admitted_subscription_enrollment,
96    submit_admitted_subscription_payment_method_replacement, submit_admitted_subscription_recovery,
97    submit_admitted_subscription_renewal,
98};
99pub use entitlement::{
100    AdmittedEntitlementWriteTransaction, EntitlementGuardError, EntitlementQueryError,
101    EntitlementWriteTransaction, entitlement, require_entitlement_for_update,
102};
103pub use gateway_accounts::{activate_gateway_configuration, register_gateway_account};
104pub use grants::{
105    SubscriptionGrantMutationError, create_subscription_grant, revoke_subscription_grant,
106};
107pub use host_charge_application::{
108    AdmittedHostCharge, HostChargeAdmissionOutcome, HostChargeApplicationError,
109    HostChargeProviderResult, admit_host_charge_submission, apply_host_charge_gateway_outcome,
110    apply_reconciled_host_charge_gateway_outcome, submit_admitted_host_charge,
111};
112pub use host_charge_reconciliation::{
113    StaleHostChargeCleanupSummary, fail_stale_unsubmitted_host_charges,
114};
115pub use host_charges::{
116    HostChargeLedgerAdmission, HostChargeLedgerAdmissionError, HostChargeLedgerAdmissionMode,
117    HostChargeLedgerAdmissionQuery, HostChargePreflightOutcome, HostChargeReservationDecision,
118    HostChargeReservationOutcome, HostChargeStoreError, HostChargeSubmissionAdmission,
119    HostChargeSubmissionDecision, HostChargeSubmissionOutcome, HostChargeTargetError,
120    HostChargeTargetReservation, HostChargeTargetStore,
121    admit_host_charge_submission_in_transaction, host_charge_ledger_admission,
122    preflight_host_charge_in_transaction, reserve_host_charge_in_transaction,
123};
124pub use lifecycle_quarantine::{
125    GatewayLifecycleQuarantineAlert, GatewayLifecycleQuarantineResolutionOutcome,
126    GatewayLifecycleQuarantineResolutionRecord, GatewayLifecycleQuarantineReviewRecord,
127    claim_gateway_lifecycle_quarantine_alert, gateway_lifecycle_quarantine_review_page,
128    resolve_gateway_lifecycle_quarantine,
129};
130pub use lifecycle_reconciliation::{
131    GatewayLifecycleApplyOutcome, GatewayLifecycleReconciliationError,
132    GatewayLifecycleReconciliationSummary, apply_gateway_lifecycle_evidence,
133    apply_staged_gateway_lifecycle_evidence, gateway_lifecycle_reconciliation_start,
134    reconcile_gateway_transaction_reports, record_gateway_lifecycle_quarantines,
135    save_gateway_lifecycle_reconciliation_cursor, stage_gateway_lifecycle_evidence,
136};
137pub use mode_verified_gateway::{
138    GatewayAccountModeVerificationError, ModeVerifiedGateway, verify_gateway_account_mode,
139};
140pub use operator_review::{
141    ExternalReversalAttestationOutcome, ExternalReversalHostStore, ExternalReversalHostStoreError,
142    ExternalReversalHostTransitionOutcome, ManualAttemptFailureHostStore,
143    ManualAttemptFailureHostStoreError, ManualAttemptFailureHostTransitionOutcome,
144    OperatorReviewError, attempt_review_page, attest_external_reversal,
145    fail_review_required_attempt, processor_charge_review_page,
146};
147pub use processor_charges::{
148    CompensatingProcessorChargeOutcome, ProcessorChargeObservationOutcome,
149    ProcessorChargeStoreError, observe_processor_charge_in_transaction,
150    store_compensating_processor_charge, transition_processor_charge_in_transaction,
151};
152pub use reconciliation::{
153    ExactQueryObservation, ProcessorChargeClassificationSummary, apply_exact_query_observation,
154    claim_exact_reconciliation_attempts, classify_pending_processor_charges,
155    fail_stale_unsubmitted_payment_method_replacements,
156    fail_stale_unsubmitted_subscription_charges, fail_stale_unsubmitted_subscription_enrollments,
157    reconciliation_gateway_accounts,
158};
159pub use renewal::{
160    RenewalStoreError, due_renewals, due_renewals_for_mode, due_renewals_page,
161    due_renewals_page_for_mode, renewal_attempt_state,
162};
163#[cfg(any(test, feature = "schema-contract-test-support"))]
164pub use schema_contract::assert_runtime_schema_v3_compatible;
165pub use schema_contract::{
166    SUPPORTED_POSTGRES_MAJOR_VERSION, SchemaConformanceError, assert_runtime_schema_v4_compatible,
167};
168pub use subscription_billing_service::{
169    GatewayMutationCooldownScope, SubscriptionBillingService, SubscriptionBillingServiceError,
170    SubscriptionBillingServiceErrorDisposition,
171};
172pub use transactions::{
173    BillingEventWriteError, BillingTransaction, BillingTransactionCoordinator,
174    BillingTransactionError, BillingTransactionSubjectState,
175};