@openlup/platform 0.22.0 → 0.24.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 +440 -158
- package/README.md +141 -589
- package/dist/fulfillment/adapterConformance.js +1 -1
- package/dist/fulfillment/bindings.js +1 -1
- package/dist/fulfillment/contracts/conformance.d.ts +3 -1
- package/dist/fulfillment/contracts/dispatch.d.ts +45 -3
- package/dist/fulfillment/contracts/index.d.ts +3 -3
- package/dist/fulfillment/contracts/observation.d.ts +21 -1
- package/dist/fulfillment/contracts/readback.d.ts +21 -0
- package/dist/fulfillment/contracts/store.d.ts +3 -0
- package/dist/fulfillment/contracts/sync.d.ts +58 -2
- package/dist/fulfillment/dispatchProjection.d.ts +20 -1
- package/dist/fulfillment/dispatchProjection.js +97 -6
- package/dist/fulfillment/index.d.ts +3 -2
- package/dist/fulfillment/index.js +2 -2
- package/dist/fulfillment/migrations.d.ts +5 -0
- package/dist/fulfillment/migrations.js +1 -0
- package/dist/fulfillment/observationProjection.d.ts +24 -3
- package/dist/fulfillment/observationProjection.js +65 -12
- package/dist/fulfillment/omnipack/client.d.ts +3 -1
- package/dist/fulfillment/omnipack/client.js +31 -13
- package/dist/fulfillment/omnipack/index.d.ts +4 -1
- package/dist/fulfillment/omnipack/index.js +107 -45
- package/dist/fulfillment/omnipack/mappers.d.ts +7 -1
- package/dist/fulfillment/omnipack/mappers.js +24 -2
- package/dist/fulfillment/omnipack/observation.d.ts +11 -4
- package/dist/fulfillment/omnipack/observation.js +44 -29
- package/dist/fulfillment/omnipack/reconciliation.d.ts +15 -0
- package/dist/fulfillment/omnipack/reconciliation.js +55 -0
- package/dist/fulfillment/postgresDispatchStore.js +1 -1
- package/dist/fulfillment/postgresShipmentSpine.d.ts +8 -1
- package/dist/fulfillment/postgresShipmentSpine.js +17 -3
- package/dist/fulfillment/postgresStockSyncPort.js +6 -3
- package/dist/fulfillment/providerDispatchAcceptance.d.ts +1 -0
- package/dist/fulfillment/providerDispatchAcceptance.js +8 -2
- package/dist/fulfillment/providerDispatchWorker.d.ts +51 -0
- package/dist/fulfillment/providerDispatchWorker.js +65 -20
- package/dist/fulfillment/providerReconciliationWorker.d.ts +27 -19
- package/dist/fulfillment/providerReconciliationWorker.js +75 -19
- package/dist/fulfillment/providerStockSyncWorker.d.ts +5 -1
- package/dist/fulfillment/providerStockSyncWorker.js +229 -120
- package/dist/fulfillment/providerTrackingReferences.d.ts +3 -2
- package/dist/fulfillment/verifiedIngress.d.ts +38 -11
- package/dist/fulfillment/verifiedIngress.js +36 -8
- package/dist/invoicing/accountingCanonicalProviderLines.d.ts +5 -0
- package/dist/invoicing/accountingCanonicalProviderLines.js +104 -0
- package/dist/invoicing/accountingLineAllocation.d.ts +2 -0
- package/dist/invoicing/accountingLineAllocation.js +69 -0
- package/dist/invoicing/adapterConformance.d.ts +42 -0
- package/dist/invoicing/adapterConformance.js +296 -0
- package/dist/invoicing/artifacts.d.ts +7 -0
- package/dist/invoicing/artifacts.js +20 -0
- package/dist/invoicing/bindings.d.ts +46 -0
- package/dist/invoicing/bindings.js +69 -0
- package/dist/invoicing/capabilities.d.ts +11 -0
- package/dist/invoicing/capabilities.js +10 -0
- package/dist/invoicing/channelPolicy.d.ts +28 -0
- package/dist/invoicing/channelPolicy.js +27 -0
- package/dist/invoicing/continuity.d.ts +12 -0
- package/dist/invoicing/continuity.js +18 -0
- package/dist/invoicing/contracts/capabilities.d.ts +40 -0
- package/dist/invoicing/contracts/capabilities.js +1 -0
- package/dist/invoicing/contracts/companyLookup.d.ts +49 -0
- package/dist/invoicing/contracts/companyLookup.js +1 -0
- package/dist/invoicing/contracts/delivery.d.ts +74 -0
- package/dist/invoicing/contracts/delivery.js +1 -0
- package/dist/invoicing/contracts/facts.d.ts +110 -0
- package/dist/invoicing/contracts/facts.js +1 -0
- package/dist/invoicing/contracts/host.d.ts +245 -0
- package/dist/invoicing/contracts/host.js +1 -0
- package/dist/invoicing/contracts/index.d.ts +16 -0
- package/dist/invoicing/contracts/index.js +1 -0
- package/dist/invoicing/contracts/provider.d.ts +126 -0
- package/dist/invoicing/contracts/provider.js +1 -0
- package/dist/invoicing/contracts/settlement.d.ts +66 -0
- package/dist/invoicing/contracts/settlement.js +1 -0
- package/dist/invoicing/contracts/store.d.ts +277 -0
- package/dist/invoicing/contracts/store.js +1 -0
- package/dist/invoicing/contribution.d.ts +21 -0
- package/dist/invoicing/contribution.js +19 -0
- package/dist/invoicing/correction.d.ts +42 -0
- package/dist/invoicing/correction.js +44 -0
- package/dist/invoicing/delivery.d.ts +85 -0
- package/dist/invoicing/delivery.js +79 -0
- package/dist/invoicing/documentHistory.d.ts +50 -0
- package/dist/invoicing/documentHistory.js +213 -0
- package/dist/invoicing/documentSync.d.ts +24 -0
- package/dist/invoicing/documentSync.js +26 -0
- package/dist/invoicing/dutyCollector.d.ts +15 -0
- package/dist/invoicing/dutyCollector.js +35 -0
- package/dist/invoicing/fulfillmentTrigger.d.ts +56 -0
- package/dist/invoicing/fulfillmentTrigger.js +90 -0
- package/dist/invoicing/handoff.d.ts +37 -0
- package/dist/invoicing/handoff.js +62 -0
- package/dist/invoicing/index.d.ts +39 -0
- package/dist/invoicing/index.js +37 -0
- package/dist/invoicing/issue.d.ts +39 -0
- package/dist/invoicing/issue.js +55 -0
- package/dist/invoicing/migrations.d.ts +48 -0
- package/dist/invoicing/migrations.js +25 -0
- package/dist/invoicing/nativeUnsupported.d.ts +9 -0
- package/dist/invoicing/nativeUnsupported.js +22 -0
- package/dist/invoicing/paymentReadback.d.ts +20 -0
- package/dist/invoicing/paymentReadback.js +47 -0
- package/dist/invoicing/postgresInvoiceStore.d.ts +55 -0
- package/dist/invoicing/postgresInvoiceStore.js +344 -0
- package/dist/invoicing/readModel.d.ts +74 -0
- package/dist/invoicing/readModel.js +90 -0
- package/dist/invoicing/readback.d.ts +4 -0
- package/dist/invoicing/readback.js +30 -0
- package/dist/invoicing/reversal.d.ts +37 -0
- package/dist/invoicing/reversal.js +28 -0
- package/dist/invoicing/sellerRevision.d.ts +19 -0
- package/dist/invoicing/sellerRevision.js +14 -0
- package/dist/invoicing/settlementSync.d.ts +18 -0
- package/dist/invoicing/settlementSync.js +32 -0
- package/dist/invoicing/snapshot.d.ts +52 -0
- package/dist/invoicing/snapshot.js +141 -0
- package/dist/subscriptions/automaticRenewal.d.ts +44 -0
- package/dist/subscriptions/automaticRenewal.js +81 -0
- package/dist/subscriptions/automaticRenewalExecution.d.ts +21 -0
- package/dist/subscriptions/automaticRenewalExecution.js +44 -0
- package/dist/subscriptions/contracts/commands.d.ts +115 -0
- package/dist/subscriptions/contracts/commands.js +1 -0
- package/dist/subscriptions/contracts/dunning.d.ts +133 -0
- package/dist/subscriptions/contracts/dunning.js +1 -0
- package/dist/subscriptions/contracts/index.d.ts +6 -0
- package/dist/subscriptions/contracts/index.js +1 -0
- package/dist/subscriptions/contracts/messages.d.ts +43 -0
- package/dist/subscriptions/contracts/messages.js +1 -0
- package/dist/subscriptions/contracts/renewal.d.ts +533 -0
- package/dist/subscriptions/contracts/renewal.js +1 -0
- package/dist/subscriptions/contracts/stockWait.d.ts +73 -0
- package/dist/subscriptions/contracts/stockWait.js +1 -0
- package/dist/subscriptions/index.d.ts +39 -0
- package/dist/subscriptions/index.js +17 -0
- package/dist/subscriptions/paymentOutcomes.d.ts +8 -0
- package/dist/subscriptions/paymentOutcomes.js +27 -0
- package/dist/subscriptions/postgresRenewalStore.d.ts +20 -0
- package/dist/subscriptions/postgresRenewalStore.js +61 -0
- package/dist/subscriptions/postgresRetryStore.d.ts +78 -0
- package/dist/subscriptions/postgresRetryStore.js +142 -0
- package/dist/subscriptions/renewalCycleFailureMechanism.d.ts +34 -0
- package/dist/subscriptions/renewalCycleFailureMechanism.js +79 -0
- package/dist/subscriptions/renewalCycleMechanism.d.ts +46 -0
- package/dist/subscriptions/renewalCycleMechanism.js +157 -0
- package/dist/subscriptions/renewalCycleRefusalMechanism.d.ts +41 -0
- package/dist/subscriptions/renewalCycleRefusalMechanism.js +160 -0
- package/dist/subscriptions/renewalIdentity.d.ts +3 -0
- package/dist/subscriptions/renewalIdentity.js +4 -0
- package/package.json +23 -3
- package/release-gates.json +74 -7
- package/sql/20260809210000_accounting_document_rail.sql +889 -0
- package/sql/20260811150000_accounting_payout_rail.sql +333 -0
- package/sql/20260812130000_accounting_document_lifecycle_rail.sql +460 -0
- package/sql/20261022160000_subscription_retry_lifecycle.sql +328 -0
- package/sql/20261022165000_fulfillment_stock_evidence_replay_reopen.sql +30 -0
- package/sql/20261022190000_invoicing_durable_duties.sql +494 -0
- package/sql/20261022191000_invoicing_document_effects.sql +249 -0
- package/sql/20261022192000_invoicing_payment_decoupling.sql +144 -0
- package/sql/20261022195000_invoicing_seller_revision.sql +65 -0
- package/src/fulfillment/adapterConformance.ts +1 -1
- package/src/fulfillment/bindings.ts +1 -1
- package/src/fulfillment/contracts/conformance.ts +3 -1
- package/src/fulfillment/contracts/dispatch.ts +24 -5
- package/src/fulfillment/contracts/index.ts +3 -3
- package/src/fulfillment/contracts/observation.ts +11 -3
- package/src/fulfillment/contracts/readback.ts +13 -0
- package/src/fulfillment/contracts/store.ts +1 -0
- package/src/fulfillment/contracts/sync.ts +13 -2
- package/src/fulfillment/dispatchProjection.ts +94 -7
- package/src/fulfillment/index.ts +3 -2
- package/src/fulfillment/migrations.ts +1 -0
- package/src/fulfillment/observationProjection.ts +64 -13
- package/src/fulfillment/omnipack/client.ts +32 -13
- package/src/fulfillment/omnipack/index.ts +99 -39
- package/src/fulfillment/omnipack/mappers.ts +23 -2
- package/src/fulfillment/omnipack/observation.ts +45 -27
- package/src/fulfillment/omnipack/reconciliation.ts +56 -0
- package/src/fulfillment/postgresDispatchStore.ts +1 -1
- package/src/fulfillment/postgresShipmentSpine.ts +21 -4
- package/src/fulfillment/postgresStockSyncPort.ts +6 -3
- package/src/fulfillment/providerDispatchAcceptance.ts +9 -3
- package/src/fulfillment/providerDispatchWorker.ts +61 -20
- package/src/fulfillment/providerReconciliationWorker.ts +81 -25
- package/src/fulfillment/providerStockSyncWorker.ts +222 -126
- package/src/fulfillment/providerTrackingReferences.ts +3 -2
- package/src/fulfillment/verifiedIngress.ts +44 -11
- package/src/invoicing/accountingCanonicalProviderLines.ts +134 -0
- package/src/invoicing/accountingLineAllocation.ts +69 -0
- package/src/invoicing/adapterConformance.ts +249 -0
- package/src/invoicing/artifacts.ts +19 -0
- package/src/invoicing/bindings.ts +80 -0
- package/src/invoicing/capabilities.ts +9 -0
- package/src/invoicing/channelPolicy.ts +50 -0
- package/src/invoicing/continuity.ts +15 -0
- package/src/invoicing/contracts/capabilities.ts +15 -0
- package/src/invoicing/contracts/companyLookup.ts +13 -0
- package/src/invoicing/contracts/delivery.ts +24 -0
- package/src/invoicing/contracts/facts.ts +71 -0
- package/src/invoicing/contracts/host.ts +84 -0
- package/src/invoicing/contracts/index.ts +16 -0
- package/src/invoicing/contracts/provider.ts +78 -0
- package/src/invoicing/contracts/settlement.ts +39 -0
- package/src/invoicing/contracts/store.ts +102 -0
- package/src/invoicing/contribution.ts +28 -0
- package/src/invoicing/correction.ts +56 -0
- package/src/invoicing/delivery.ts +122 -0
- package/src/invoicing/documentHistory.ts +301 -0
- package/src/invoicing/documentSync.ts +51 -0
- package/src/invoicing/dutyCollector.ts +31 -0
- package/src/invoicing/fulfillmentTrigger.ts +144 -0
- package/src/invoicing/handoff.ts +71 -0
- package/src/invoicing/index.ts +39 -0
- package/src/invoicing/issue.ts +64 -0
- package/src/invoicing/migrations.ts +25 -0
- package/src/invoicing/nativeUnsupported.ts +24 -0
- package/src/invoicing/paymentReadback.ts +70 -0
- package/src/invoicing/postgresInvoiceStore.ts +334 -0
- package/src/invoicing/readModel.ts +80 -0
- package/src/invoicing/readback.ts +26 -0
- package/src/invoicing/reversal.ts +34 -0
- package/src/invoicing/sellerRevision.ts +20 -0
- package/src/invoicing/settlementSync.ts +37 -0
- package/src/invoicing/snapshot.ts +192 -0
- package/src/subscriptions/automaticRenewal.ts +87 -0
- package/src/subscriptions/automaticRenewalExecution.ts +39 -0
- package/src/subscriptions/contracts/commands.ts +46 -0
- package/src/subscriptions/contracts/dunning.ts +48 -0
- package/src/subscriptions/contracts/index.ts +6 -0
- package/src/subscriptions/contracts/messages.ts +18 -0
- package/src/subscriptions/contracts/renewal.ts +325 -0
- package/src/subscriptions/contracts/stockWait.ts +34 -0
- package/src/subscriptions/index.ts +24 -0
- package/src/subscriptions/paymentOutcomes.ts +23 -0
- package/src/subscriptions/postgresRenewalStore.ts +76 -0
- package/src/subscriptions/postgresRetryStore.ts +174 -0
- package/src/subscriptions/renewalCycleFailureMechanism.ts +119 -0
- package/src/subscriptions/renewalCycleMechanism.ts +225 -0
- package/src/subscriptions/renewalCycleRefusalMechanism.ts +215 -0
- package/src/subscriptions/renewalIdentity.ts +5 -0
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
import type { PaymentAttemptStatus, PaymentExecutionBaseInput, PaymentExecutionBaseResult, PaymentProviderCapabilityDescriptor, ProviderAttemptIdentity } from "@openlup/core/payment";
|
|
2
|
+
/** Structural hosted-cycle contracts; native vocabulary is bound by the caller. */
|
|
3
|
+
export type SubscriptionRenewalOutcome = "charged" | "requires_action" | "failed" | "skipped";
|
|
4
|
+
export interface HostedRenewalDue {
|
|
5
|
+
subscriptionId: string;
|
|
6
|
+
nextCycleAt: string;
|
|
7
|
+
providerKind: string;
|
|
8
|
+
providerMethodRef: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface SubscriptionRenewalChargeResult {
|
|
11
|
+
subscriptionId: string;
|
|
12
|
+
outcome: SubscriptionRenewalOutcome;
|
|
13
|
+
cycleId: string | null;
|
|
14
|
+
cycleNumber: number | null;
|
|
15
|
+
orderId: string | null;
|
|
16
|
+
paymentIntentId: string | null;
|
|
17
|
+
attemptStatus: PaymentAttemptStatus | null;
|
|
18
|
+
replayed: boolean;
|
|
19
|
+
dunningCaseId?: string | null;
|
|
20
|
+
retryAttempt?: number | null;
|
|
21
|
+
applyReplayed?: boolean;
|
|
22
|
+
dunningPropagationFailed?: boolean;
|
|
23
|
+
reason?: string;
|
|
24
|
+
admissionDeferralReference?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface SubscriptionCycleSnapshotResult {
|
|
27
|
+
cycleNumber: number;
|
|
28
|
+
retryAttempt: number;
|
|
29
|
+
providerAttemptSequence: number;
|
|
30
|
+
templateSnapshot: Record<string, unknown>;
|
|
31
|
+
pricingSnapshot: Record<string, unknown>;
|
|
32
|
+
orderSnapshot: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
export interface SubscriptionCycleOrderInput {
|
|
35
|
+
idempotencyKey: string;
|
|
36
|
+
subscriptionId: string;
|
|
37
|
+
cycleNumber: number;
|
|
38
|
+
scheduledAt: string;
|
|
39
|
+
templateSnapshot: Record<string, unknown>;
|
|
40
|
+
pricingSnapshot: Record<string, unknown>;
|
|
41
|
+
orderSnapshot: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
export interface SubscriptionCycleOrderResult {
|
|
44
|
+
cycleId: string;
|
|
45
|
+
orderRef: string;
|
|
46
|
+
orderUuid: string;
|
|
47
|
+
paymentRef: string;
|
|
48
|
+
replayed: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface SubscriptionReservationPreflightResult {
|
|
51
|
+
ok: boolean;
|
|
52
|
+
reason: string | null;
|
|
53
|
+
itemsChecked: number;
|
|
54
|
+
reacquired: number;
|
|
55
|
+
}
|
|
56
|
+
export interface SubscriptionRenewalPersistencePort<M extends string | null | undefined = string | null | undefined> {
|
|
57
|
+
buildCycleSnapshots(input: {
|
|
58
|
+
subscriptionId: string;
|
|
59
|
+
scheduledAt: string;
|
|
60
|
+
}): Promise<SubscriptionCycleSnapshotResult>;
|
|
61
|
+
createCycleOrder(input: SubscriptionCycleOrderInput): Promise<SubscriptionCycleOrderResult>;
|
|
62
|
+
preflightReservation(input: {
|
|
63
|
+
orderId: string;
|
|
64
|
+
now: string;
|
|
65
|
+
}): Promise<SubscriptionReservationPreflightResult>;
|
|
66
|
+
readMandateRecurringModel(providerKind: string, providerMethodRef: string | null): Promise<M>;
|
|
67
|
+
noteRowOutcome(input: {
|
|
68
|
+
subscriptionId: string;
|
|
69
|
+
scheduledAt: string;
|
|
70
|
+
errorKey: string | null;
|
|
71
|
+
}): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
export type FailurePropagationKind = "off_session_requires_action" | "provider_declined" | "preflight_block";
|
|
74
|
+
export interface FailurePropagationContext {
|
|
75
|
+
kind: FailurePropagationKind;
|
|
76
|
+
executionIdempotencyKey: string;
|
|
77
|
+
providerIdempotencyKey: string;
|
|
78
|
+
providerRequestFingerprint: string;
|
|
79
|
+
paymentIntentId: string;
|
|
80
|
+
cycleId: string;
|
|
81
|
+
subscriptionId: string;
|
|
82
|
+
orderUuid: string;
|
|
83
|
+
providerKind: string;
|
|
84
|
+
failureReason: string;
|
|
85
|
+
failureClassification?: {
|
|
86
|
+
failureClass: string;
|
|
87
|
+
decidedBy: string;
|
|
88
|
+
} | null;
|
|
89
|
+
occurredAt: string;
|
|
90
|
+
attemptAlreadyPrepared?: boolean;
|
|
91
|
+
}
|
|
92
|
+
export interface CycleRetryState {
|
|
93
|
+
retryAttempt: number | null;
|
|
94
|
+
nextRetryAt: string | null;
|
|
95
|
+
rowPresent: boolean;
|
|
96
|
+
}
|
|
97
|
+
export type DunningCaseOpenOutcome = {
|
|
98
|
+
status: "opened";
|
|
99
|
+
caseId: string | null;
|
|
100
|
+
} | {
|
|
101
|
+
status: "rejected";
|
|
102
|
+
reason: string;
|
|
103
|
+
code?: string;
|
|
104
|
+
} | {
|
|
105
|
+
status: "unavailable";
|
|
106
|
+
reason: string;
|
|
107
|
+
};
|
|
108
|
+
export interface CycleChargeFailurePropagationPort {
|
|
109
|
+
recordBlockedPreflightAttempt(input: {
|
|
110
|
+
idempotencyKey: string;
|
|
111
|
+
paymentIntentId: string;
|
|
112
|
+
providerKind: string;
|
|
113
|
+
providerIdempotencyKey: string;
|
|
114
|
+
providerRequestFingerprint: string;
|
|
115
|
+
failureReason: string;
|
|
116
|
+
}): Promise<void>;
|
|
117
|
+
readDurableAttemptInstant(input: {
|
|
118
|
+
paymentIntentId: string;
|
|
119
|
+
attemptIdempotencyKey: string;
|
|
120
|
+
}): Promise<string | null>;
|
|
121
|
+
applyFailedResult(input: {
|
|
122
|
+
idempotencyKey: string;
|
|
123
|
+
paymentIntentId: string;
|
|
124
|
+
occurredAt: string;
|
|
125
|
+
failureReason: string;
|
|
126
|
+
failureClassification: {
|
|
127
|
+
failureClass: string;
|
|
128
|
+
decidedBy: string;
|
|
129
|
+
};
|
|
130
|
+
}): Promise<{
|
|
131
|
+
replayed: boolean;
|
|
132
|
+
}>;
|
|
133
|
+
readCycleRetryState(cycleId: string): Promise<CycleRetryState>;
|
|
134
|
+
openDunningCase(input: {
|
|
135
|
+
idempotencyKey: string;
|
|
136
|
+
cycleId: string;
|
|
137
|
+
subscriptionId: string;
|
|
138
|
+
orderUuid: string;
|
|
139
|
+
paymentIntentId: string;
|
|
140
|
+
retryAttempt: number;
|
|
141
|
+
nextRetryAt: string | null;
|
|
142
|
+
failureReason: string;
|
|
143
|
+
occurredAt: string;
|
|
144
|
+
failureClass: string;
|
|
145
|
+
}): Promise<DunningCaseOpenOutcome>;
|
|
146
|
+
}
|
|
147
|
+
export interface FailurePropagationResult {
|
|
148
|
+
dunningCaseId: string | null;
|
|
149
|
+
retryAttempt: number | null;
|
|
150
|
+
applyReplayed: boolean;
|
|
151
|
+
dunningPropagationFailed: boolean;
|
|
152
|
+
}
|
|
153
|
+
export type RenewalPrepareInput<P extends string> = Parameters<RenewalPreparedAttemptPersistencePort<P, string>["prepareProviderAttempt"]>[0];
|
|
154
|
+
export type RenewalAttemptResult<N extends string> = Awaited<ReturnType<RenewalPreparedAttemptPersistencePort<string, N>["finalizeProviderAttempt"]>>;
|
|
155
|
+
export interface RenewalIntentResult {
|
|
156
|
+
paymentIntentId: string;
|
|
157
|
+
replayed: boolean;
|
|
158
|
+
}
|
|
159
|
+
export interface RenewalPaymentPort<CI, IR extends RenewalIntentResult, P extends string, N extends string> extends RenewalPreparedAttemptPersistencePort<P, N> {
|
|
160
|
+
createIntent(input: CI): Promise<IR>;
|
|
161
|
+
}
|
|
162
|
+
export interface RenewalExecutionPort<I extends PaymentExecutionBaseInput, R extends PaymentExecutionBaseResult> {
|
|
163
|
+
execute(input: I): Promise<R>;
|
|
164
|
+
}
|
|
165
|
+
export interface RenewalDeliveryAdmission {
|
|
166
|
+
allowed: boolean;
|
|
167
|
+
state: string;
|
|
168
|
+
reason: string;
|
|
169
|
+
}
|
|
170
|
+
export type RenewalAllowedAdmission = RenewalDeliveryAdmission & {
|
|
171
|
+
allowed: true;
|
|
172
|
+
};
|
|
173
|
+
export interface RenewalDeliveryClient {
|
|
174
|
+
admitDeliveryAlignment(input: {
|
|
175
|
+
subscriptionId: string;
|
|
176
|
+
scheduledAt: string;
|
|
177
|
+
asOf: string;
|
|
178
|
+
}): Promise<RenewalDeliveryAdmission>;
|
|
179
|
+
}
|
|
180
|
+
export interface RenewalFailureDeps {
|
|
181
|
+
chargeFailurePropagation: CycleChargeFailurePropagationPort;
|
|
182
|
+
now?: () => string;
|
|
183
|
+
}
|
|
184
|
+
export interface RenewalPreflightDeps<CI, IR extends RenewalIntentResult, M extends string | null | undefined> extends RenewalFailureDeps {
|
|
185
|
+
persistence: SubscriptionRenewalPersistencePort<M>;
|
|
186
|
+
paymentPort: {
|
|
187
|
+
createIntent(input: CI): Promise<IR>;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
export interface RenewalCycleDeps<CI, IR extends RenewalIntentResult, P extends string, N extends string, I extends PaymentExecutionBaseInput, R extends PaymentExecutionBaseResult, M extends string | null | undefined> extends RenewalPreflightDeps<CI, IR, M> {
|
|
191
|
+
paymentPort: RenewalPaymentPort<CI, IR, P, N>;
|
|
192
|
+
executionPort: RenewalExecutionPort<I, R>;
|
|
193
|
+
deliveryAlignment: RenewalDeliveryClient;
|
|
194
|
+
capability: PaymentProviderCapabilityDescriptor;
|
|
195
|
+
deliveryAlignmentAdmission?: RenewalAllowedAdmission;
|
|
196
|
+
}
|
|
197
|
+
/** Local references, never a snapshot of the original due/ports or their getters. */
|
|
198
|
+
export interface RenewalExecutionContext<IR extends RenewalIntentResult, M extends string | null | undefined, F extends string> {
|
|
199
|
+
snapshots: SubscriptionCycleSnapshotResult;
|
|
200
|
+
cycleOrder: SubscriptionCycleOrderResult;
|
|
201
|
+
intent: IR;
|
|
202
|
+
totalGrossMinor: number;
|
|
203
|
+
executionIdempotencyKey: string;
|
|
204
|
+
attemptIdentity: ProviderAttemptIdentity;
|
|
205
|
+
providerFlow: F;
|
|
206
|
+
paymentMethodRecurringModel: M | undefined;
|
|
207
|
+
}
|
|
208
|
+
export interface RenewalOutcomeContext {
|
|
209
|
+
executionIdempotencyKey: string;
|
|
210
|
+
attemptIdentity: ProviderAttemptIdentity;
|
|
211
|
+
intent: RenewalIntentResult;
|
|
212
|
+
cycleOrder: Pick<SubscriptionCycleOrderResult, "cycleId" | "orderUuid" | "replayed">;
|
|
213
|
+
snapshots: Pick<SubscriptionCycleSnapshotResult, "cycleNumber">;
|
|
214
|
+
finalizedAttempt: {
|
|
215
|
+
status: PaymentAttemptStatus;
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
export interface RenewalReplayContext {
|
|
219
|
+
cycleId: string;
|
|
220
|
+
cycleNumber: number;
|
|
221
|
+
orderId: string;
|
|
222
|
+
paymentIntentId: string;
|
|
223
|
+
executionIdempotencyKey: string;
|
|
224
|
+
providerIdempotencyKey: string;
|
|
225
|
+
providerRequestFingerprint: string;
|
|
226
|
+
providerKind: string;
|
|
227
|
+
}
|
|
228
|
+
/** Durable preparation facts; provider admission belongs to the caller. */
|
|
229
|
+
export interface RenewalPreparedAttemptPrepareInput<P extends string = string> {
|
|
230
|
+
idempotencyKey: string;
|
|
231
|
+
paymentIntentId: string;
|
|
232
|
+
provider: P;
|
|
233
|
+
providerIdempotencyKey: string;
|
|
234
|
+
providerRequestFingerprint: string;
|
|
235
|
+
providerFlow: string;
|
|
236
|
+
paymentMethodRef?: string | null;
|
|
237
|
+
requestPayload: Record<string, unknown>;
|
|
238
|
+
}
|
|
239
|
+
export interface RenewalPreparedAttemptPersistenceResult<N extends string = string> {
|
|
240
|
+
paymentAttemptId: string;
|
|
241
|
+
status: PaymentAttemptStatus;
|
|
242
|
+
replayed: boolean;
|
|
243
|
+
providerAttemptId: string | null;
|
|
244
|
+
providerSessionId: string | null;
|
|
245
|
+
nextActionKind: N | null;
|
|
246
|
+
}
|
|
247
|
+
export interface RenewalPreparedAttemptFinalizeInput<N extends string = string> extends Pick<PaymentExecutionBaseResult, "providerAttemptId" | "providerSessionId" | "attemptStatus" | "requestPayload" | "responsePayload"> {
|
|
248
|
+
idempotencyKey: string;
|
|
249
|
+
paymentIntentId: string;
|
|
250
|
+
paymentAttemptId: string;
|
|
251
|
+
providerIdempotencyKey: string;
|
|
252
|
+
providerRequestFingerprint: string;
|
|
253
|
+
nextActionKind: N | null;
|
|
254
|
+
}
|
|
255
|
+
/** Only persistence capabilities needed by interactive attempt ordering. */
|
|
256
|
+
export interface RenewalPreparedAttemptPersistencePort<P extends string = string, N extends string = string> {
|
|
257
|
+
prepareProviderAttempt(input: RenewalPreparedAttemptPrepareInput<P>): Promise<RenewalPreparedAttemptPersistenceResult<N>>;
|
|
258
|
+
finalizeProviderAttempt(input: RenewalPreparedAttemptFinalizeInput<N>): Promise<RenewalPreparedAttemptPersistenceResult<N>>;
|
|
259
|
+
}
|
|
260
|
+
/** Original text is an identity input; instant is for comparisons only. */
|
|
261
|
+
export interface RenewalSchedule {
|
|
262
|
+
subscriptionId: string;
|
|
263
|
+
scheduledAt: string;
|
|
264
|
+
scheduledInstant: number;
|
|
265
|
+
}
|
|
266
|
+
export interface RenewalIdentity {
|
|
267
|
+
cycleIdempotencyKey: string;
|
|
268
|
+
executionIdempotencyKey: string;
|
|
269
|
+
externalIdempotencyKey: string;
|
|
270
|
+
requestFingerprint: string;
|
|
271
|
+
}
|
|
272
|
+
export type RenewalAdmission = {
|
|
273
|
+
allowed: true;
|
|
274
|
+
state: string;
|
|
275
|
+
reason: string;
|
|
276
|
+
} | {
|
|
277
|
+
allowed: false;
|
|
278
|
+
state: string;
|
|
279
|
+
reason: string;
|
|
280
|
+
deferred: true;
|
|
281
|
+
caseRef?: string;
|
|
282
|
+
} | {
|
|
283
|
+
allowed: false;
|
|
284
|
+
state: string;
|
|
285
|
+
reason: string;
|
|
286
|
+
deferred: false;
|
|
287
|
+
};
|
|
288
|
+
export interface RenewalLine {
|
|
289
|
+
lineOrdinal: number;
|
|
290
|
+
sku: string;
|
|
291
|
+
quantity: number;
|
|
292
|
+
unitAmountMinor: number;
|
|
293
|
+
}
|
|
294
|
+
/** Logical numbering is evidence-bound, never a universal nativeCounter + 1. */
|
|
295
|
+
export type RenewalCycleCorrelation = {
|
|
296
|
+
status: "correlated";
|
|
297
|
+
logicalCycleNumber: number;
|
|
298
|
+
nativeRenewalCounter: number | null;
|
|
299
|
+
activationCycleId: string | null;
|
|
300
|
+
evidenceRef: string;
|
|
301
|
+
} | {
|
|
302
|
+
status: "ambiguous";
|
|
303
|
+
logicalCycleNumber: null;
|
|
304
|
+
nativeRenewalCounter: number | null;
|
|
305
|
+
activationCycleId: string | null;
|
|
306
|
+
reason: string;
|
|
307
|
+
};
|
|
308
|
+
export interface RenewalTemplateSnapshot {
|
|
309
|
+
templateId: string;
|
|
310
|
+
version: number;
|
|
311
|
+
cadenceDays: number;
|
|
312
|
+
lines: readonly RenewalLine[];
|
|
313
|
+
}
|
|
314
|
+
export interface RenewalPricingSnapshot {
|
|
315
|
+
currency: string;
|
|
316
|
+
totalAmountMinor: number;
|
|
317
|
+
shippingAmountMinor: number;
|
|
318
|
+
agreementPolicy: "lock_until_edit";
|
|
319
|
+
proration: "none";
|
|
320
|
+
}
|
|
321
|
+
export interface RenewalOrderSnapshot {
|
|
322
|
+
shippingAddressRef: string | null;
|
|
323
|
+
shippingQuoteRef: string | null;
|
|
324
|
+
acquisitionRef: string | null;
|
|
325
|
+
lines: readonly RenewalLine[];
|
|
326
|
+
}
|
|
327
|
+
export interface RenewalFrozenSnapshot extends RenewalSchedule {
|
|
328
|
+
contractVersion: "platform.subscription.renewal.v1";
|
|
329
|
+
clientId: string;
|
|
330
|
+
frozenRevision: string;
|
|
331
|
+
frozenFingerprint: string;
|
|
332
|
+
cycle: RenewalCycleCorrelation;
|
|
333
|
+
retryAttempt: number;
|
|
334
|
+
externalAttemptSequence: number;
|
|
335
|
+
templateSnapshot: RenewalTemplateSnapshot;
|
|
336
|
+
pricingSnapshot: RenewalPricingSnapshot;
|
|
337
|
+
orderSnapshot: RenewalOrderSnapshot;
|
|
338
|
+
stockSourceKey: string;
|
|
339
|
+
settlementChannelKey: string;
|
|
340
|
+
authorizationRef: string;
|
|
341
|
+
payerAccountRef: string | null;
|
|
342
|
+
unattendedChargeAuthorizedAt: string;
|
|
343
|
+
}
|
|
344
|
+
export interface RenewalDue extends RenewalSchedule {
|
|
345
|
+
clientId: string;
|
|
346
|
+
cadenceDays: number;
|
|
347
|
+
cycle: RenewalCycleCorrelation;
|
|
348
|
+
currency: string;
|
|
349
|
+
stockSourceKey: string;
|
|
350
|
+
settlementChannelKey: string;
|
|
351
|
+
authorizationRef: string;
|
|
352
|
+
payerAccountRef: string | null;
|
|
353
|
+
unattendedChargeAuthorizedAt: string;
|
|
354
|
+
deliveryAdmission: "allowed" | "blocked";
|
|
355
|
+
deliveryBlockReason: string | null;
|
|
356
|
+
}
|
|
357
|
+
export type RenewalOperationState = "claimed" | "reserved" | "attempt_prepared" | "succeeded" | "refused";
|
|
358
|
+
export interface RenewalReadback extends RenewalSchedule {
|
|
359
|
+
contractVersion: "platform.subscription.renewal.v1";
|
|
360
|
+
acquired: boolean;
|
|
361
|
+
replayed: boolean;
|
|
362
|
+
reason: string;
|
|
363
|
+
operationId: string;
|
|
364
|
+
identityKey: string;
|
|
365
|
+
operationFingerprint: string;
|
|
366
|
+
cycle: RenewalCycleCorrelation;
|
|
367
|
+
state: RenewalOperationState;
|
|
368
|
+
claimToken: string;
|
|
369
|
+
claimGeneration: number;
|
|
370
|
+
leaseExpiresAt: string;
|
|
371
|
+
cycleSnapshot: RenewalFrozenSnapshot;
|
|
372
|
+
externalAttemptRef: string | null;
|
|
373
|
+
externalAttemptAcknowledgedAt: string | null;
|
|
374
|
+
terminalOutcome: "succeeded" | "refused" | null;
|
|
375
|
+
terminalReason: string | null;
|
|
376
|
+
terminalAt: string | null;
|
|
377
|
+
reservationId: string | null;
|
|
378
|
+
cycleId: string | null;
|
|
379
|
+
orderId: string | null;
|
|
380
|
+
settlementIntentId: string | null;
|
|
381
|
+
}
|
|
382
|
+
/** M07 verified truth. Nullable money is not positive matching evidence. */
|
|
383
|
+
export interface RenewalPaymentEvidence {
|
|
384
|
+
status: "succeeded" | "failed" | "pending" | "unknown";
|
|
385
|
+
disposition: "observed" | "ambiguous" | "late_positive";
|
|
386
|
+
operationId: string;
|
|
387
|
+
eventKey: string;
|
|
388
|
+
requestFingerprint: string;
|
|
389
|
+
verifiedEvidenceRef: string;
|
|
390
|
+
externalAttemptRef: string | null;
|
|
391
|
+
occurredAt: string | null;
|
|
392
|
+
observedAt: string;
|
|
393
|
+
firstRecordedAt: string;
|
|
394
|
+
amountMinor: number | null;
|
|
395
|
+
currency: string | null;
|
|
396
|
+
reason: string | null;
|
|
397
|
+
}
|
|
398
|
+
/** Payment execution is outside all SQL transactions. */
|
|
399
|
+
export type RenewalTransactionUnits = {
|
|
400
|
+
graph: "native";
|
|
401
|
+
prepare: "cycle_order_items_settlement_reservation_attempt";
|
|
402
|
+
outcome: "settlement_outcome_schedule_counter_reservation";
|
|
403
|
+
recovery: "settlement_cycle_receipt_case_counter";
|
|
404
|
+
} | {
|
|
405
|
+
graph: "managed";
|
|
406
|
+
prepare: "create_cycle_order_then_prepare_attempt";
|
|
407
|
+
failure: "record_attempt_then_apply_result_then_open_case";
|
|
408
|
+
recovery: "authorize_method_then_schedule";
|
|
409
|
+
};
|
|
410
|
+
export interface RenewalReservationResult {
|
|
411
|
+
reserved: boolean;
|
|
412
|
+
replayed: boolean;
|
|
413
|
+
reservationId: string | null;
|
|
414
|
+
status: "held" | "committed" | "consumed" | "released" | "expired" | "refused";
|
|
415
|
+
reason: string | null;
|
|
416
|
+
}
|
|
417
|
+
export interface RenewalPreparedSettlement {
|
|
418
|
+
contractVersion: "platform.subscription.renewal.v1";
|
|
419
|
+
replayed: boolean;
|
|
420
|
+
operationId: string;
|
|
421
|
+
operationFingerprint: string;
|
|
422
|
+
cycleId: string;
|
|
423
|
+
orderId: string;
|
|
424
|
+
settlementIntentId: string;
|
|
425
|
+
state: "attempt_prepared";
|
|
426
|
+
}
|
|
427
|
+
export interface RenewalStorePort {
|
|
428
|
+
readonly transactions: RenewalTransactionUnits;
|
|
429
|
+
listDue(limit: number, asOf: string): Promise<RenewalDue[]>;
|
|
430
|
+
buildCycleSnapshots(input: RenewalSchedule): Promise<RenewalFrozenSnapshot>;
|
|
431
|
+
readMandateEvidence(input: RenewalSchedule): Promise<{
|
|
432
|
+
authorized: boolean;
|
|
433
|
+
authorizationRef: string;
|
|
434
|
+
authorizedAt: string | null;
|
|
435
|
+
}>;
|
|
436
|
+
admitDeliveryAlignment(input: RenewalSchedule & {
|
|
437
|
+
occurredAt: string;
|
|
438
|
+
}): Promise<RenewalAdmission>;
|
|
439
|
+
claimDue(input: {
|
|
440
|
+
snapshot: RenewalFrozenSnapshot;
|
|
441
|
+
workerId: string;
|
|
442
|
+
leaseSeconds?: number;
|
|
443
|
+
now: string;
|
|
444
|
+
}): Promise<RenewalReadback>;
|
|
445
|
+
readRenewal(identityKey: string): Promise<RenewalReadback | null>;
|
|
446
|
+
refuseBeforePayment(input: {
|
|
447
|
+
operationId: string;
|
|
448
|
+
claimToken: string;
|
|
449
|
+
reason: string;
|
|
450
|
+
occurredAt: string;
|
|
451
|
+
}): Promise<RenewalReadback>;
|
|
452
|
+
}
|
|
453
|
+
export interface RenewalSettlementPort {
|
|
454
|
+
prepareRenewal(input: {
|
|
455
|
+
operationId: string;
|
|
456
|
+
claimToken: string;
|
|
457
|
+
now: string;
|
|
458
|
+
}): Promise<RenewalPreparedSettlement>;
|
|
459
|
+
acknowledgeExternalAttempt(input: {
|
|
460
|
+
operationId: string;
|
|
461
|
+
operationFingerprint: string;
|
|
462
|
+
externalAttemptRef: string;
|
|
463
|
+
acknowledgedAt: string;
|
|
464
|
+
}): Promise<RenewalReadback>;
|
|
465
|
+
recordTerminalOutcome(input: {
|
|
466
|
+
operationId: string;
|
|
467
|
+
eventKey: string;
|
|
468
|
+
operationFingerprint: string;
|
|
469
|
+
outcome: "succeeded" | "refused";
|
|
470
|
+
externalRef?: string | null;
|
|
471
|
+
reason?: string | null;
|
|
472
|
+
occurredAt: string;
|
|
473
|
+
}): Promise<RenewalReadback>;
|
|
474
|
+
}
|
|
475
|
+
export interface RenewalExecutionRequest extends RenewalIdentity {
|
|
476
|
+
paymentIntentId: string;
|
|
477
|
+
amountMinor: number;
|
|
478
|
+
currency: string;
|
|
479
|
+
mode: string;
|
|
480
|
+
orderRef: string;
|
|
481
|
+
orderId: string;
|
|
482
|
+
flow: string;
|
|
483
|
+
customerRef: string | null;
|
|
484
|
+
paymentMethodRef: string;
|
|
485
|
+
recurringModel: string | null;
|
|
486
|
+
clientId: string;
|
|
487
|
+
payer: {
|
|
488
|
+
email: string | null;
|
|
489
|
+
name: string | null;
|
|
490
|
+
} | null;
|
|
491
|
+
}
|
|
492
|
+
export interface RenewalPaymentRail {
|
|
493
|
+
execute(input: RenewalExecutionRequest): Promise<{
|
|
494
|
+
status: "succeeded" | "failed" | "requires_action" | "pending" | "unknown";
|
|
495
|
+
externalAttemptRef: string | null;
|
|
496
|
+
failure?: {
|
|
497
|
+
reason: string;
|
|
498
|
+
failureClass: string;
|
|
499
|
+
};
|
|
500
|
+
}>;
|
|
501
|
+
findExternalAttempt(input: {
|
|
502
|
+
settlementIntentId: string;
|
|
503
|
+
}): Promise<string | null>;
|
|
504
|
+
readOutcome(input: {
|
|
505
|
+
externalAttemptRef: string;
|
|
506
|
+
settlementIntentId: string;
|
|
507
|
+
orderId: string;
|
|
508
|
+
subscriptionId: string;
|
|
509
|
+
amountMinor: number;
|
|
510
|
+
currency: string;
|
|
511
|
+
}): Promise<RenewalPaymentEvidence>;
|
|
512
|
+
}
|
|
513
|
+
export type RenewalResult = {
|
|
514
|
+
outcome: "deferred";
|
|
515
|
+
subscriptionId: string;
|
|
516
|
+
scheduledAt: string;
|
|
517
|
+
reason: string;
|
|
518
|
+
caseRef?: string;
|
|
519
|
+
} | {
|
|
520
|
+
outcome: "charged" | "requires_action" | "failed" | "skipped";
|
|
521
|
+
subscriptionId: string;
|
|
522
|
+
cycleId: string | null;
|
|
523
|
+
cycleNumber: number | null;
|
|
524
|
+
orderId: string | null;
|
|
525
|
+
paymentIntentId: string | null;
|
|
526
|
+
attemptStatus: string | null;
|
|
527
|
+
replayed: boolean;
|
|
528
|
+
dunningCaseId?: string | null;
|
|
529
|
+
retryAttempt?: number | null;
|
|
530
|
+
applyReplayed?: boolean;
|
|
531
|
+
dunningPropagationFailed?: boolean;
|
|
532
|
+
reason?: string;
|
|
533
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { RenewalFrozenSnapshot, RenewalReadback, RenewalSchedule } from "./renewal.js";
|
|
2
|
+
export interface StockWaitRecoveryBinding {
|
|
3
|
+
caseId: string | null;
|
|
4
|
+
cycleId: string | null;
|
|
5
|
+
orderId: string | null;
|
|
6
|
+
paymentId: string | null;
|
|
7
|
+
engineIdempotencyKey: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface StockWaitDeficit {
|
|
10
|
+
skuId: string;
|
|
11
|
+
sku: string;
|
|
12
|
+
displayName: string;
|
|
13
|
+
size: string | null;
|
|
14
|
+
required: number;
|
|
15
|
+
reserved: number;
|
|
16
|
+
available: number;
|
|
17
|
+
missing: number;
|
|
18
|
+
}
|
|
19
|
+
export interface StockWaitCase extends RenewalSchedule {
|
|
20
|
+
caseId: string;
|
|
21
|
+
clientId: string;
|
|
22
|
+
state: "waiting" | "stock_secured" | "resumed" | "closed";
|
|
23
|
+
frozenSnapshot: RenewalFrozenSnapshot;
|
|
24
|
+
frozenFingerprint: string;
|
|
25
|
+
binding: StockWaitRecoveryBinding;
|
|
26
|
+
deficits: readonly StockWaitDeficit[];
|
|
27
|
+
fulfillmentRef: string | null;
|
|
28
|
+
blockReason: string | null;
|
|
29
|
+
openedAt: string;
|
|
30
|
+
checkedAt: string | null;
|
|
31
|
+
selectedAt: string | null;
|
|
32
|
+
securedAt: string | null;
|
|
33
|
+
resumedAt: string | null;
|
|
34
|
+
closedAt: string | null;
|
|
35
|
+
startedNoticeKey: string;
|
|
36
|
+
resumedNoticeKey: string;
|
|
37
|
+
noticeEligible: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** All-line reserve/reacquire and the wait transition share a DB transaction.
|
|
40
|
+
* A shortage rolls back the subtransaction, retaining previous commitments;
|
|
41
|
+
* record the wait outside that failed subtransaction. Technical failure is unknown.
|
|
42
|
+
*/
|
|
43
|
+
export interface StockWaitStorePort {
|
|
44
|
+
listCandidates(input: {
|
|
45
|
+
limit: number;
|
|
46
|
+
asOf: string;
|
|
47
|
+
}): Promise<StockWaitCase[]>;
|
|
48
|
+
readFrozenCase(input: StockWaitRecoveryBinding): Promise<StockWaitCase | null>;
|
|
49
|
+
reserveAndTransition(input: {
|
|
50
|
+
caseId: string;
|
|
51
|
+
frozenFingerprint: string;
|
|
52
|
+
now: string;
|
|
53
|
+
}): Promise<StockWaitCase>;
|
|
54
|
+
/** Only elapsed, unprepared, unacknowledged, stock-only refusals may reset.
|
|
55
|
+
* Requires unchanged schedule/fingerprint and no payment artifacts or outcomes.
|
|
56
|
+
* Rotate fencing generation atomically with reacquisition. Never reset ambiguity.
|
|
57
|
+
*/
|
|
58
|
+
recoverRefusedSchedule(input: {
|
|
59
|
+
operationId: string;
|
|
60
|
+
caseId: string;
|
|
61
|
+
claimGeneration: number;
|
|
62
|
+
frozenFingerprint: string;
|
|
63
|
+
scheduledAt: string;
|
|
64
|
+
now: string;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
outcome: "recovered";
|
|
67
|
+
operation: RenewalReadback;
|
|
68
|
+
replayed: boolean;
|
|
69
|
+
} | {
|
|
70
|
+
outcome: "refused";
|
|
71
|
+
reason: "not_stock_only" | "external_ownership" | "stale_snapshot" | "lease_active" | "inventory_unavailable";
|
|
72
|
+
}>;
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export { renewalIdentity } from "./renewalIdentity.js";
|
|
2
|
+
export declare const NATIVE_SUBSCRIPTION_CAPABILITIES: Readonly<{
|
|
3
|
+
readonly graph: "native";
|
|
4
|
+
readonly multiCyclePrepaid: Readonly<{
|
|
5
|
+
supported: false;
|
|
6
|
+
refusalCode: "multi_cycle_prepaid_unsupported";
|
|
7
|
+
}>;
|
|
8
|
+
readonly genericBundleCommands: Readonly<{
|
|
9
|
+
supported: false;
|
|
10
|
+
refusalCode: "native_generic_bundle_commands_unsupported";
|
|
11
|
+
}>;
|
|
12
|
+
readonly commandBoundReceipts: Readonly<{
|
|
13
|
+
supported: false;
|
|
14
|
+
refusalCode: "native_command_bound_receipts_unsupported";
|
|
15
|
+
}>;
|
|
16
|
+
readonly preparedAttemptStore: Readonly<{
|
|
17
|
+
supported: false;
|
|
18
|
+
refusalCode: "native_prepared_attempt_store_unsupported";
|
|
19
|
+
}>;
|
|
20
|
+
readonly retryRecovery: "selected";
|
|
21
|
+
readonly stockRecovery: "unavailable";
|
|
22
|
+
readonly deliveryAdmission: "required";
|
|
23
|
+
readonly executorCount: 1;
|
|
24
|
+
readonly defaultEnabled: false;
|
|
25
|
+
}>;
|
|
26
|
+
export { executeRenewalCycle, prepareRenewalAttempt, checkRenewalDeliveryAdmission } from "./renewalCycleMechanism.js";
|
|
27
|
+
export type { RenewalCyclePolicy } from "./renewalCycleMechanism.js";
|
|
28
|
+
export { recordRenewalPreflightBlock, replayRenewalAttempt, declinedRenewalOutcome, requiresActionRenewalOutcome } from "./renewalCycleRefusalMechanism.js";
|
|
29
|
+
export type { RenewalPreflightPolicy, RenewalReplayPolicy, RenewalOutcomePolicy } from "./renewalCycleRefusalMechanism.js";
|
|
30
|
+
export { propagateRenewalFailure } from "./renewalCycleFailureMechanism.js";
|
|
31
|
+
export type { RenewalFailurePolicy } from "./renewalCycleFailureMechanism.js";
|
|
32
|
+
export { runAutomaticSubscriptionRenewals, runOneAutomaticSubscriptionRenewal, correlatedLogicalCycle } from "./automaticRenewal.js";
|
|
33
|
+
export type { AutomaticRenewalRunStatus, AutomaticRenewalRunResult, AutomaticRenewalRunDeps, AutomaticRenewalPolicy } from "./automaticRenewal.js";
|
|
34
|
+
export { createPostgresRenewalStore } from "./postgresRenewalStore.js";
|
|
35
|
+
export type { NativeRenewalCodec, SubscriptionQueryExecutor } from "./postgresRenewalStore.js";
|
|
36
|
+
export { createPostgresRetryStore } from "./postgresRetryStore.js";
|
|
37
|
+
export type { NativeRetryFailure, NativeRetryRequest, NativeRetryPositive, NativeRetryPreparation, NativeRetryRow } from "./postgresRetryStore.js";
|
|
38
|
+
export { createPostgresRetryLifecycleBinding } from "./postgresRetryStore.js";
|
|
39
|
+
export type { NativeRetryLifecycleBinding } from "./postgresRetryStore.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { renewalIdentity } from "./renewalIdentity.js";
|
|
2
|
+
export const NATIVE_SUBSCRIPTION_CAPABILITIES = Object.freeze({
|
|
3
|
+
graph: "native",
|
|
4
|
+
multiCyclePrepaid: Object.freeze({ supported: false, refusalCode: "multi_cycle_prepaid_unsupported" }),
|
|
5
|
+
genericBundleCommands: Object.freeze({ supported: false, refusalCode: "native_generic_bundle_commands_unsupported" }),
|
|
6
|
+
commandBoundReceipts: Object.freeze({ supported: false, refusalCode: "native_command_bound_receipts_unsupported" }),
|
|
7
|
+
preparedAttemptStore: Object.freeze({ supported: false, refusalCode: "native_prepared_attempt_store_unsupported" }),
|
|
8
|
+
retryRecovery: "selected", stockRecovery: "unavailable",
|
|
9
|
+
deliveryAdmission: "required", executorCount: 1, defaultEnabled: false,
|
|
10
|
+
});
|
|
11
|
+
export { executeRenewalCycle, prepareRenewalAttempt, checkRenewalDeliveryAdmission } from "./renewalCycleMechanism.js";
|
|
12
|
+
export { recordRenewalPreflightBlock, replayRenewalAttempt, declinedRenewalOutcome, requiresActionRenewalOutcome } from "./renewalCycleRefusalMechanism.js";
|
|
13
|
+
export { propagateRenewalFailure } from "./renewalCycleFailureMechanism.js";
|
|
14
|
+
export { runAutomaticSubscriptionRenewals, runOneAutomaticSubscriptionRenewal, correlatedLogicalCycle } from "./automaticRenewal.js";
|
|
15
|
+
export { createPostgresRenewalStore } from "./postgresRenewalStore.js";
|
|
16
|
+
export { createPostgresRetryStore } from "./postgresRetryStore.js";
|
|
17
|
+
export { createPostgresRetryLifecycleBinding } from "./postgresRetryStore.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RenewalPaymentRail, RenewalReadback } from "./contracts/renewal.js";
|
|
2
|
+
import type { AutomaticRenewalRunDeps, AutomaticRenewalRunResult } from "./automaticRenewal.js";
|
|
3
|
+
/** H4: only explicit verified matching M07 evidence may become positive local truth. */
|
|
4
|
+
export declare function readAndApplyProviderOutcome(deps: AutomaticRenewalRunDeps, operation: RenewalReadback, prepared: {
|
|
5
|
+
cycleId: string;
|
|
6
|
+
orderId: string;
|
|
7
|
+
settlementIntentId: string;
|
|
8
|
+
}, rail: RenewalPaymentRail, externalAttemptRef: string, occurredAt: string): Promise<AutomaticRenewalRunResult>;
|