@plasius/economy 0.3.1 → 0.3.2
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/README.md +39 -0
- package/dist/index.cjs +1349 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +240 -1
- package/dist/index.d.ts +240 -1
- package/dist/index.js +1328 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -503,6 +503,88 @@ interface AdjustmentRequestV1 {
|
|
|
503
503
|
/** Proves that production adjustment approval was performed by another actor. */
|
|
504
504
|
declare function assertDistinctAdjustmentApproval(request: AdjustmentRequestV1): void;
|
|
505
505
|
|
|
506
|
+
type PaidLotLifecycleStatusV1 = "clear" | "partially-reversed" | "disputed" | "fully-reversed" | "chargeback-lost";
|
|
507
|
+
type PaidLotLifecycleEventTypeV1 = "refund" | "dispute-hold" | "dispute-won" | "dispute-lost" | "chargeback" | "reversal";
|
|
508
|
+
/** Paid-purchase facts not already carried by the source lot. */
|
|
509
|
+
interface PaidLotPurchaseProvenanceV1 {
|
|
510
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
511
|
+
readonly purchaseId: string;
|
|
512
|
+
readonly catalogVersion: string;
|
|
513
|
+
readonly purchasedAt: IsoTimestamp;
|
|
514
|
+
}
|
|
515
|
+
/** Provider-neutral refund/dispute evidence for a paid source lot. */
|
|
516
|
+
interface PaidLotLifecycleEventV1 {
|
|
517
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
518
|
+
readonly eventId: string;
|
|
519
|
+
readonly lotId: LotId;
|
|
520
|
+
readonly eventType: PaidLotLifecycleEventTypeV1;
|
|
521
|
+
readonly amount: TokenSubunitString;
|
|
522
|
+
readonly occurredAt: IsoTimestamp;
|
|
523
|
+
}
|
|
524
|
+
interface PaidLotLifecycleReceiptV1 {
|
|
525
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
526
|
+
readonly event: PaidLotLifecycleEventV1;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Retained paid-lot projection. Immutable purchase/original facts plus every
|
|
530
|
+
* receipt are sufficient to rebuild all derived amounts in occurrence order.
|
|
531
|
+
*/
|
|
532
|
+
interface PaidLotLifecycleV1 {
|
|
533
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
534
|
+
readonly lotId: LotId;
|
|
535
|
+
readonly payerAccountId: AccountId;
|
|
536
|
+
readonly receivingHouseholdId: HouseholdId;
|
|
537
|
+
readonly purchaseId: string;
|
|
538
|
+
readonly catalogVersion: string;
|
|
539
|
+
readonly purchasedAt: IsoTimestamp;
|
|
540
|
+
readonly settledAt: IsoTimestamp;
|
|
541
|
+
readonly creditedAt: IsoTimestamp;
|
|
542
|
+
readonly originalAmount: TokenSubunitString;
|
|
543
|
+
readonly retainedAmount: TokenSubunitString;
|
|
544
|
+
readonly heldAmount: TokenSubunitString;
|
|
545
|
+
readonly reversedAmount: TokenSubunitString;
|
|
546
|
+
readonly refundedAmount: TokenSubunitString;
|
|
547
|
+
readonly chargebackAmount: TokenSubunitString;
|
|
548
|
+
readonly oneTimeReversalAmount: TokenSubunitString;
|
|
549
|
+
readonly status: PaidLotLifecycleStatusV1;
|
|
550
|
+
readonly version: number;
|
|
551
|
+
readonly receipts: readonly PaidLotLifecycleReceiptV1[];
|
|
552
|
+
readonly effectiveEventIds: readonly string[];
|
|
553
|
+
}
|
|
554
|
+
/** Exact signed projection deltas produced when one receipt is appended. */
|
|
555
|
+
interface PaidLotLifecycleArithmeticV1 {
|
|
556
|
+
readonly retainedDelta: TokenSubunitString;
|
|
557
|
+
readonly heldDelta: TokenSubunitString;
|
|
558
|
+
readonly reversedDelta: TokenSubunitString;
|
|
559
|
+
readonly refundedDelta: TokenSubunitString;
|
|
560
|
+
readonly chargebackDelta: TokenSubunitString;
|
|
561
|
+
readonly oneTimeReversalDelta: TokenSubunitString;
|
|
562
|
+
}
|
|
563
|
+
interface PaidLotLifecycleMutationResultV1 {
|
|
564
|
+
readonly lifecycle: PaidLotLifecycleV1;
|
|
565
|
+
/** False only for an exact event-ID replay already recorded. */
|
|
566
|
+
readonly applied: boolean;
|
|
567
|
+
readonly stateChanged: boolean;
|
|
568
|
+
readonly arithmetic: PaidLotLifecycleArithmeticV1;
|
|
569
|
+
}
|
|
570
|
+
/** Validates the paid purchase facts paired with a source lot. */
|
|
571
|
+
declare function assertPaidLotPurchaseProvenance(provenance: PaidLotPurchaseProvenanceV1): void;
|
|
572
|
+
/** Validates one provider-neutral paid-lot lifecycle event. */
|
|
573
|
+
declare function assertPaidLotLifecycleEvent(event: PaidLotLifecycleEventV1): void;
|
|
574
|
+
/** Validates and deterministically rebuilds retained paid-lot arithmetic. */
|
|
575
|
+
declare function assertPaidLotLifecycle(lifecycle: PaidLotLifecycleV1): void;
|
|
576
|
+
/** Creates the retained projection for one newly credited paid source lot. */
|
|
577
|
+
declare function createPaidLotLifecycle(lot: SourceLotV1, provenance: PaidLotPurchaseProvenanceV1): PaidLotLifecycleV1;
|
|
578
|
+
/**
|
|
579
|
+
* Appends one event then rebuilds every receipt in authoritative occurrence
|
|
580
|
+
* order. Exact retries succeed before stale-version validation.
|
|
581
|
+
*/
|
|
582
|
+
declare function applyPaidLotLifecycleEvent(lifecycle: PaidLotLifecycleV1, event: PaidLotLifecycleEventV1, expectedVersion: number): PaidLotLifecycleMutationResultV1;
|
|
583
|
+
/** Reduces unordered/retried lifecycle evidence in canonical event order. */
|
|
584
|
+
declare function reducePaidLotLifecycleEvents(initial: PaidLotLifecycleV1, events: readonly PaidLotLifecycleEventV1[]): PaidLotLifecycleV1;
|
|
585
|
+
/** Creates the exact retained-basis input used by early-backer evaluators. */
|
|
586
|
+
declare function createEarlyBackerRetentionFromPaidLot(lifecycle: PaidLotLifecycleV1): PaidLotRetentionV1;
|
|
587
|
+
|
|
506
588
|
type WalletKind = "household-treasury" | "personal" | "gameplay-allocation" | "hold" | "purchase-clearing" | "provider-clearing" | "system";
|
|
507
589
|
type WalletStatus = "active" | "restricted" | "closed";
|
|
508
590
|
type WalletOwnerType = "account" | "household" | "system";
|
|
@@ -926,6 +1008,163 @@ interface EconomyQueryPortV1 {
|
|
|
926
1008
|
listPortfolioActivity(scope: WalletPortfolioReadScopeV1, request: WalletActivityPageRequestV1): Promise<WalletActivityPageV1>;
|
|
927
1009
|
}
|
|
928
1010
|
|
|
1011
|
+
declare const gbpMinorUnitStringBrand: unique symbol;
|
|
1012
|
+
/** Canonical non-negative GBP minor-unit string used by cap contracts. */
|
|
1013
|
+
type GbpMinorUnitString = string & {
|
|
1014
|
+
readonly [gbpMinorUnitStringBrand]: "GbpMinorUnitString";
|
|
1015
|
+
};
|
|
1016
|
+
/** Parses exact GBP minor units without floating point or coercion. */
|
|
1017
|
+
declare function parseGbpMinorUnits(value: string): bigint;
|
|
1018
|
+
/** Serializes exact GBP minor units using the canonical wire representation. */
|
|
1019
|
+
declare function serializeGbpMinorUnits(amount: bigint): GbpMinorUnitString;
|
|
1020
|
+
type PurchaseCapScopeTypeV1 = "payer" | "household";
|
|
1021
|
+
type PurchaseCapReservationStatusV1 = "reserved" | "settled" | "released" | "expired";
|
|
1022
|
+
type PurchaseCapReservationTransitionTypeV1 = "settle" | "release" | "expire";
|
|
1023
|
+
interface PurchaseCapReservationTransitionV1 {
|
|
1024
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1025
|
+
readonly transitionId: string;
|
|
1026
|
+
readonly reservationId: string;
|
|
1027
|
+
readonly transitionType: PurchaseCapReservationTransitionTypeV1;
|
|
1028
|
+
readonly occurredAt: IsoTimestamp;
|
|
1029
|
+
}
|
|
1030
|
+
/** Append-only cap evidence; effectiveness is rebuilt from occurrence order. */
|
|
1031
|
+
interface PurchaseCapReservationTransitionReceiptV1 {
|
|
1032
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1033
|
+
readonly transition: PurchaseCapReservationTransitionV1;
|
|
1034
|
+
}
|
|
1035
|
+
/** One purchase amount mirrored into payer and household cap aggregates. */
|
|
1036
|
+
interface PurchaseCapReservationV1 {
|
|
1037
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1038
|
+
readonly reservationId: string;
|
|
1039
|
+
readonly payerAccountId: AccountId;
|
|
1040
|
+
readonly householdId: HouseholdId;
|
|
1041
|
+
readonly priceMinorUnits: GbpMinorUnitString;
|
|
1042
|
+
readonly status: PurchaseCapReservationStatusV1;
|
|
1043
|
+
readonly reservedAt: IsoTimestamp;
|
|
1044
|
+
readonly expiresAt: IsoTimestamp;
|
|
1045
|
+
/** Derived winning transition; every delivery remains in `transitionReceipts`. */
|
|
1046
|
+
readonly finalTransitionId?: string;
|
|
1047
|
+
readonly finalizedAt?: IsoTimestamp;
|
|
1048
|
+
readonly transitionReceipts: readonly PurchaseCapReservationTransitionReceiptV1[];
|
|
1049
|
+
}
|
|
1050
|
+
/** Optimistic aggregate for exactly one payer or household rolling ceiling. */
|
|
1051
|
+
interface RollingPurchaseCapStateV1 {
|
|
1052
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1053
|
+
readonly scopeType: PurchaseCapScopeTypeV1;
|
|
1054
|
+
readonly scopeId: string;
|
|
1055
|
+
readonly version: number;
|
|
1056
|
+
readonly reservations: readonly PurchaseCapReservationV1[];
|
|
1057
|
+
}
|
|
1058
|
+
interface ReservePurchaseCapsCommandV1 {
|
|
1059
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1060
|
+
readonly reservationId: string;
|
|
1061
|
+
readonly payerAccountId: AccountId;
|
|
1062
|
+
readonly householdId: HouseholdId;
|
|
1063
|
+
readonly priceMinorUnits: GbpMinorUnitString;
|
|
1064
|
+
readonly reservedAt: IsoTimestamp;
|
|
1065
|
+
readonly expiresAt: IsoTimestamp;
|
|
1066
|
+
readonly expectedPayerVersion: number;
|
|
1067
|
+
readonly expectedHouseholdVersion: number;
|
|
1068
|
+
}
|
|
1069
|
+
interface PurchaseCapMutationResultV1 {
|
|
1070
|
+
readonly payerState: RollingPurchaseCapStateV1;
|
|
1071
|
+
readonly householdState: RollingPurchaseCapStateV1;
|
|
1072
|
+
readonly reservation: PurchaseCapReservationV1;
|
|
1073
|
+
/** True when a reservation or transition receipt was newly recorded. */
|
|
1074
|
+
readonly applied: boolean;
|
|
1075
|
+
readonly stateChanged: boolean;
|
|
1076
|
+
readonly payerUsageMinorUnits: GbpMinorUnitString;
|
|
1077
|
+
readonly householdUsageMinorUnits: GbpMinorUnitString;
|
|
1078
|
+
}
|
|
1079
|
+
/** Validates one rolling-cap transition envelope. */
|
|
1080
|
+
declare function assertPurchaseCapReservationTransition(transition: PurchaseCapReservationTransitionV1): void;
|
|
1081
|
+
/** Validates one mirrored rolling-cap reservation and its complete rebuild. */
|
|
1082
|
+
declare function assertPurchaseCapReservation(reservation: PurchaseCapReservationV1): void;
|
|
1083
|
+
/** Validates one payer or household rolling-cap aggregate. */
|
|
1084
|
+
declare function assertRollingPurchaseCapState(state: RollingPurchaseCapStateV1): void;
|
|
1085
|
+
/** Returns the exact cap usage at one point in time. */
|
|
1086
|
+
declare function calculateRollingPurchaseCapUsage(state: RollingPurchaseCapStateV1, checkedAt: IsoTimestamp, policy: PurchaseLimitPolicyV1): GbpMinorUnitString;
|
|
1087
|
+
/** Creates an empty compare-and-swap aggregate for one cap scope. */
|
|
1088
|
+
declare function createRollingPurchaseCapState(scopeType: PurchaseCapScopeTypeV1, scopeId: string): RollingPurchaseCapStateV1;
|
|
1089
|
+
/**
|
|
1090
|
+
* Atomically reserves the same amount in payer and household aggregates.
|
|
1091
|
+
* Adapters must compare-and-swap both returned versions in one transaction.
|
|
1092
|
+
*/
|
|
1093
|
+
declare function reserveRollingPurchaseCaps(payerState: RollingPurchaseCapStateV1, householdState: RollingPurchaseCapStateV1, command: ReservePurchaseCapsCommandV1, policy: PurchaseLimitPolicyV1): PurchaseCapMutationResultV1;
|
|
1094
|
+
/**
|
|
1095
|
+
* Appends a settle/release/expiry receipt and rebuilds authoritative order. A
|
|
1096
|
+
* late-delivered pre-expiry settlement corrects a stored expiry while retaining
|
|
1097
|
+
* both receipts. Payer and household versions still advance atomically.
|
|
1098
|
+
*/
|
|
1099
|
+
declare function transitionRollingPurchaseCapReservation(payerState: RollingPurchaseCapStateV1, householdState: RollingPurchaseCapStateV1, transition: PurchaseCapReservationTransitionV1, expectedPayerVersion: number, expectedHouseholdVersion: number, policy: PurchaseLimitPolicyV1): PurchaseCapMutationResultV1;
|
|
1100
|
+
|
|
1101
|
+
type PurchaseIntentTransitionTypeV1 = "checkout-bound" | "payment-observed" | "credit-recorded" | "expire" | "cancel" | "dispute-opened" | "dispute-won" | "dispute-lost";
|
|
1102
|
+
type PurchaseIntentDisputeDispositionV1 = "none" | "open" | "won" | "lost";
|
|
1103
|
+
/** Provider-neutral evidence for one requested purchase-intent transition. */
|
|
1104
|
+
interface PurchaseIntentTransitionV1 {
|
|
1105
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1106
|
+
readonly transitionId: string;
|
|
1107
|
+
readonly intentId: string;
|
|
1108
|
+
readonly transitionType: PurchaseIntentTransitionTypeV1;
|
|
1109
|
+
readonly occurredAt: IsoTimestamp;
|
|
1110
|
+
/** Sanitized binding; raw provider checkout references are adapter concerns. */
|
|
1111
|
+
readonly providerCheckoutReferenceHash?: string;
|
|
1112
|
+
}
|
|
1113
|
+
/** Append-only receipt. Whether it is effective is a rebuildable projection. */
|
|
1114
|
+
interface PurchaseIntentTransitionReceiptV1 {
|
|
1115
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1116
|
+
readonly transition: PurchaseIntentTransitionV1;
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Versioned lifecycle projection. `initialIntent` never changes; every delivery
|
|
1120
|
+
* is rebuilt from its append-only receipts in authoritative occurrence order.
|
|
1121
|
+
*/
|
|
1122
|
+
interface PurchaseIntentLifecycleV1 {
|
|
1123
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1124
|
+
readonly initialIntent: PurchaseIntentV1;
|
|
1125
|
+
readonly intent: PurchaseIntentV1;
|
|
1126
|
+
readonly version: number;
|
|
1127
|
+
readonly creditRecorded: boolean;
|
|
1128
|
+
readonly disputeDisposition: PurchaseIntentDisputeDispositionV1;
|
|
1129
|
+
readonly receipts: readonly PurchaseIntentTransitionReceiptV1[];
|
|
1130
|
+
readonly effectiveTransitionIds: readonly string[];
|
|
1131
|
+
}
|
|
1132
|
+
/** Stable instruction identity for the one permitted purchase credit. */
|
|
1133
|
+
interface PurchaseCreditInstructionV1 {
|
|
1134
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1135
|
+
readonly intentId: string;
|
|
1136
|
+
readonly transitionId: string;
|
|
1137
|
+
readonly idempotencyKey: string;
|
|
1138
|
+
}
|
|
1139
|
+
interface PurchaseIntentTransitionResultV1 {
|
|
1140
|
+
readonly lifecycle: PurchaseIntentLifecycleV1;
|
|
1141
|
+
/** False only for an exact transition-ID replay already in `receipts`. */
|
|
1142
|
+
readonly recorded: boolean;
|
|
1143
|
+
readonly stateChanged: boolean;
|
|
1144
|
+
readonly creditInstruction?: PurchaseCreditInstructionV1;
|
|
1145
|
+
}
|
|
1146
|
+
interface PurchaseIntentReductionV1 {
|
|
1147
|
+
readonly lifecycle: PurchaseIntentLifecycleV1;
|
|
1148
|
+
readonly creditInstructions: readonly PurchaseCreditInstructionV1[];
|
|
1149
|
+
}
|
|
1150
|
+
/** Validates one provider-neutral purchase-intent transition envelope. */
|
|
1151
|
+
declare function assertPurchaseIntentTransition(transition: PurchaseIntentTransitionV1): void;
|
|
1152
|
+
/** Validates and deterministically rebuilds a lifecycle projection. */
|
|
1153
|
+
declare function assertPurchaseIntentLifecycle(lifecycle: PurchaseIntentLifecycleV1, pack: TokenPackV1): void;
|
|
1154
|
+
/** Creates a lifecycle from immutable, server-created purchase-intent facts. */
|
|
1155
|
+
declare function createPurchaseIntentLifecycle(initialIntent: PurchaseIntentV1, pack: TokenPackV1): PurchaseIntentLifecycleV1;
|
|
1156
|
+
/**
|
|
1157
|
+
* Appends one event and rebuilds all receipts by authoritative occurrence time.
|
|
1158
|
+
* A late pre-expiry payment can therefore correct a stored expiry without
|
|
1159
|
+
* deleting the expiry receipt. Exact retries succeed before version checking.
|
|
1160
|
+
*/
|
|
1161
|
+
declare function applyPurchaseIntentTransition(lifecycle: PurchaseIntentLifecycleV1, transition: PurchaseIntentTransitionV1, expectedVersion: number, pack: TokenPackV1): PurchaseIntentTransitionResultV1;
|
|
1162
|
+
/**
|
|
1163
|
+
* Reduces an unordered delivery batch in canonical event-time/type/ID order.
|
|
1164
|
+
* Exact duplicate IDs collapse; conflicting duplicate facts are rejected.
|
|
1165
|
+
*/
|
|
1166
|
+
declare function reducePurchaseIntentTransitions(initialIntent: PurchaseIntentV1, transitions: readonly PurchaseIntentTransitionV1[], pack: TokenPackV1): PurchaseIntentReductionV1;
|
|
1167
|
+
|
|
929
1168
|
type RecurrenceInterval = "daily" | "weekly" | "monthly";
|
|
930
1169
|
/** Provider-neutral subscription contract. Site policy controls enablement. */
|
|
931
1170
|
interface TokenSubscriptionPlanV1 {
|
|
@@ -965,4 +1204,4 @@ interface SpendRequestV1 {
|
|
|
965
1204
|
/** Validates future child requests while creation remains policy-disabled. */
|
|
966
1205
|
declare function assertSpendRequest(request: SpendRequestV1): void;
|
|
967
1206
|
|
|
968
|
-
export { type AccountId, type ActivityEntryV1, type ActivityStatus, type ActivityType, type AdjustmentRequestV1, type AdjustmentStatus, type AllocationId, type AllocationStatus, BASELINE_GBP_CATALOG_VERSION, BASELINE_GBP_REFERENCE_RATE, BASELINE_GBP_TOKEN_PACKS, BASELINE_MONTHLY_SUBSCRIPTION_PLAN, BASELINE_PURCHASE_LIMIT_POLICY, type BalanceProjection, type BalanceProjectionSnapshotV1, type BitLabsConversionState, type BoostGameplayAllocationInputV1, type ChainedEconomicJournalTransactionV1, type CreateGameplayAllocationInputV1, EARLY_BACKER_SETTLEMENT_POLICY_V2, ECONOMY_CONTRACT_VERSION, type EarlyBackerEvaluationV1, type EarlyBackerEvaluationV2, type EarlyBackerWindowV1, type EconomicActivityStatusV1, type EconomicJournalStatus, type EconomicJournalTransactionV1, type EconomicWalletActivityEntryV1, type EconomyClockPort, type EconomyCommandEnvelopeV1, type EconomyCommandType, type EconomyCommandWorkflowEventV1, type EconomyCommandWorkflowStateV1, type EconomyContractVersion, EconomyError, type EconomyErrorCode, type EconomyErrorEnvelopeV1, type EconomyIdPort, type EconomyIdempotencyScopeV1, type EconomyOutboxEventV1, type EconomyPersistencePort, type EconomyPersistencePortV2, type EconomyQueryPortV1, type EconomyUnitOfWork, type EconomyUnitOfWorkV2, type FxSnapshotV1, type GameplayAllocationV1, type GameplayLimitsV1, type HouseholdId, type IsoTimestamp, type JournalChainHeadV1, type JournalChainId, type LedgerPostingV1, type LedgerTransactionV1, type LotId, type LotRefundState, type LotTransferPolicy, type LotUseContextV1, type LotUseOperation, PRE_UTILITY_BACKER_COHORT, type PaidLotRetentionV1, type PeriodicLimitWindow, type PersistedIdempotencyResultV1, type PostingId, type ProviderEventId, type PurchaseIntentStatus, type PurchaseIntentV1, type PurchaseLimitPolicyV1, type ReclaimGameplayAllocationInputV1, type RecurrenceInterval, type ReversalInputV1, type RewardActivityTransitionV1, type RewardConversionStatus, type RewardConversionV1, type RewardRateV1, type ScopedPersistedIdempotencyResultV1, type SourceLotMovementType, type SourceLotMovementV1, type SourceLotSliceV1, type SourceLotV1, type SpendRequestPurpose, type SpendRequestStatus, type SpendRequestV1, TOKEN_SUBUNITS_MAX, TOKEN_SUBUNITS_MIN, TOKEN_SUBUNITS_PER_TOKEN, type TokenPackV1, type TokenReferenceRateV1, type TokenSource, type TokenSubscriptionPlanV1, type TokenSubunitString, type TransactionId, type VersionedSourceLotV1, type WalletActivityEntryV1, type WalletActivityFilterV1, type WalletActivityPageRequestV1, type WalletActivityPageV1, type WalletActivityStatusV1, type WalletBalanceDeltaV1, type WalletBalanceProjectionV1, type WalletBalanceSummaryV1, type WalletBalanceTotalsV1, type WalletId, type WalletKind, type WalletLifetimeBucket, type WalletLifetimeDeltaV1, type WalletLifetimeSnapshotV1, type WalletLifetimeTotalsV1, type WalletOwnerReferenceV1, type WalletOwnerType, type WalletPortfolioBalanceComponentV1, type WalletPortfolioComponentRole, type WalletPortfolioComponentScopeV1, type WalletPortfolioLifetimeComponentV1, type WalletPortfolioLifetimeV1, type WalletPortfolioReadScopeV1, type WalletPortfolioSummaryV1, type WalletPostingAccountBindingV1, type WalletProjectionBucket, type WalletStatus, type WalletV1, type WorkflowActivityStatusV1, type WorkflowWalletActivityEntryV1, advanceJournalChainHead, applySourceLotMovement, applyTransactionToProjection, applyWalletBalanceDelta, applyWalletLifetimeDeltas, assertActivityEntry, assertBalancedTransaction, assertDeterministicWalletBalanceSummary, assertDistinctAdjustmentApproval, assertEconomicJournalTransaction, assertEconomyCommandEnvelope, assertEconomyCommandWorkflowEvent, assertEconomyIdempotencyScope, assertEconomyIdentifier, assertFlatTokenCatalog, assertFxSnapshot, assertGameplayAllocation, assertJournalChainHead, assertNonNegativeAccounts, assertOpenPurchaseIntent, assertPurchaseIntentBinding, assertPurchaseLimitPolicy, assertReversalAvailable, assertRewardConversion, assertRewardRate, assertScopedPersistedIdempotencyResult, assertSourceLot, assertSourceLotMovement, assertSpendRequest, assertTokenPack, assertTokenReferenceRate, assertTokenSubscriptionPlan, assertVersionedSourceLot, assertWallet, assertWalletActivityEntry, assertWalletActivityPage, assertWalletActivityPageForPortfolio, assertWalletActivityPageRequest, assertWalletBalanceDelta, assertWalletBalanceDeltaBatch, assertWalletBalanceProjection, assertWalletBalanceSummary, assertWalletLifetimeSnapshot, assertWalletLifetimeTotals, assertWalletOwnerReference, assertWalletPortfolioLifetime, assertWalletPortfolioReadScope, assertWalletPortfolioSummary, availableSourceLotAmount, boostGameplayAllocation, canUseSourceLot, canonicalTransactionPayload, convertRewardPayout, createGameplayAllocation, createInitialSourceLotSnapshot, createProjectionSnapshot, createReversalTransaction, createWalletBalanceSummary, createWalletPortfolioLifetime, createWalletPortfolioSummary, deriveWalletBalanceDeltas, deriveWalletLifetimeDeltas, economyAssert, evaluateEarlyBacker, evaluateEarlyBackerBySettlementV2, isWholeTokenAmount, mapBitLabsConversionState, parseIsoTimestamp, parseTokenSubunits, rebuildBalanceProjection, reclaimGameplayAllocation, selectSourceLots, serializeTokenSubunits, sortStringRecord, subunitsToWholeTokens, sumTokenSubunits, toEconomyErrorEnvelope, wholeTokensToSubunits };
|
|
1207
|
+
export { type AccountId, type ActivityEntryV1, type ActivityStatus, type ActivityType, type AdjustmentRequestV1, type AdjustmentStatus, type AllocationId, type AllocationStatus, BASELINE_GBP_CATALOG_VERSION, BASELINE_GBP_REFERENCE_RATE, BASELINE_GBP_TOKEN_PACKS, BASELINE_MONTHLY_SUBSCRIPTION_PLAN, BASELINE_PURCHASE_LIMIT_POLICY, type BalanceProjection, type BalanceProjectionSnapshotV1, type BitLabsConversionState, type BoostGameplayAllocationInputV1, type ChainedEconomicJournalTransactionV1, type CreateGameplayAllocationInputV1, EARLY_BACKER_SETTLEMENT_POLICY_V2, ECONOMY_CONTRACT_VERSION, type EarlyBackerEvaluationV1, type EarlyBackerEvaluationV2, type EarlyBackerWindowV1, type EconomicActivityStatusV1, type EconomicJournalStatus, type EconomicJournalTransactionV1, type EconomicWalletActivityEntryV1, type EconomyClockPort, type EconomyCommandEnvelopeV1, type EconomyCommandType, type EconomyCommandWorkflowEventV1, type EconomyCommandWorkflowStateV1, type EconomyContractVersion, EconomyError, type EconomyErrorCode, type EconomyErrorEnvelopeV1, type EconomyIdPort, type EconomyIdempotencyScopeV1, type EconomyOutboxEventV1, type EconomyPersistencePort, type EconomyPersistencePortV2, type EconomyQueryPortV1, type EconomyUnitOfWork, type EconomyUnitOfWorkV2, type FxSnapshotV1, type GameplayAllocationV1, type GameplayLimitsV1, type GbpMinorUnitString, type HouseholdId, type IsoTimestamp, type JournalChainHeadV1, type JournalChainId, type LedgerPostingV1, type LedgerTransactionV1, type LotId, type LotRefundState, type LotTransferPolicy, type LotUseContextV1, type LotUseOperation, PRE_UTILITY_BACKER_COHORT, type PaidLotLifecycleArithmeticV1, type PaidLotLifecycleEventTypeV1, type PaidLotLifecycleEventV1, type PaidLotLifecycleMutationResultV1, type PaidLotLifecycleReceiptV1, type PaidLotLifecycleStatusV1, type PaidLotLifecycleV1, type PaidLotPurchaseProvenanceV1, type PaidLotRetentionV1, type PeriodicLimitWindow, type PersistedIdempotencyResultV1, type PostingId, type ProviderEventId, type PurchaseCapMutationResultV1, type PurchaseCapReservationStatusV1, type PurchaseCapReservationTransitionReceiptV1, type PurchaseCapReservationTransitionTypeV1, type PurchaseCapReservationTransitionV1, type PurchaseCapReservationV1, type PurchaseCapScopeTypeV1, type PurchaseCreditInstructionV1, type PurchaseIntentDisputeDispositionV1, type PurchaseIntentLifecycleV1, type PurchaseIntentReductionV1, type PurchaseIntentStatus, type PurchaseIntentTransitionReceiptV1, type PurchaseIntentTransitionResultV1, type PurchaseIntentTransitionTypeV1, type PurchaseIntentTransitionV1, type PurchaseIntentV1, type PurchaseLimitPolicyV1, type ReclaimGameplayAllocationInputV1, type RecurrenceInterval, type ReservePurchaseCapsCommandV1, type ReversalInputV1, type RewardActivityTransitionV1, type RewardConversionStatus, type RewardConversionV1, type RewardRateV1, type RollingPurchaseCapStateV1, type ScopedPersistedIdempotencyResultV1, type SourceLotMovementType, type SourceLotMovementV1, type SourceLotSliceV1, type SourceLotV1, type SpendRequestPurpose, type SpendRequestStatus, type SpendRequestV1, TOKEN_SUBUNITS_MAX, TOKEN_SUBUNITS_MIN, TOKEN_SUBUNITS_PER_TOKEN, type TokenPackV1, type TokenReferenceRateV1, type TokenSource, type TokenSubscriptionPlanV1, type TokenSubunitString, type TransactionId, type VersionedSourceLotV1, type WalletActivityEntryV1, type WalletActivityFilterV1, type WalletActivityPageRequestV1, type WalletActivityPageV1, type WalletActivityStatusV1, type WalletBalanceDeltaV1, type WalletBalanceProjectionV1, type WalletBalanceSummaryV1, type WalletBalanceTotalsV1, type WalletId, type WalletKind, type WalletLifetimeBucket, type WalletLifetimeDeltaV1, type WalletLifetimeSnapshotV1, type WalletLifetimeTotalsV1, type WalletOwnerReferenceV1, type WalletOwnerType, type WalletPortfolioBalanceComponentV1, type WalletPortfolioComponentRole, type WalletPortfolioComponentScopeV1, type WalletPortfolioLifetimeComponentV1, type WalletPortfolioLifetimeV1, type WalletPortfolioReadScopeV1, type WalletPortfolioSummaryV1, type WalletPostingAccountBindingV1, type WalletProjectionBucket, type WalletStatus, type WalletV1, type WorkflowActivityStatusV1, type WorkflowWalletActivityEntryV1, advanceJournalChainHead, applyPaidLotLifecycleEvent, applyPurchaseIntentTransition, applySourceLotMovement, applyTransactionToProjection, applyWalletBalanceDelta, applyWalletLifetimeDeltas, assertActivityEntry, assertBalancedTransaction, assertDeterministicWalletBalanceSummary, assertDistinctAdjustmentApproval, assertEconomicJournalTransaction, assertEconomyCommandEnvelope, assertEconomyCommandWorkflowEvent, assertEconomyIdempotencyScope, assertEconomyIdentifier, assertFlatTokenCatalog, assertFxSnapshot, assertGameplayAllocation, assertJournalChainHead, assertNonNegativeAccounts, assertOpenPurchaseIntent, assertPaidLotLifecycle, assertPaidLotLifecycleEvent, assertPaidLotPurchaseProvenance, assertPurchaseCapReservation, assertPurchaseCapReservationTransition, assertPurchaseIntentBinding, assertPurchaseIntentLifecycle, assertPurchaseIntentTransition, assertPurchaseLimitPolicy, assertReversalAvailable, assertRewardConversion, assertRewardRate, assertRollingPurchaseCapState, assertScopedPersistedIdempotencyResult, assertSourceLot, assertSourceLotMovement, assertSpendRequest, assertTokenPack, assertTokenReferenceRate, assertTokenSubscriptionPlan, assertVersionedSourceLot, assertWallet, assertWalletActivityEntry, assertWalletActivityPage, assertWalletActivityPageForPortfolio, assertWalletActivityPageRequest, assertWalletBalanceDelta, assertWalletBalanceDeltaBatch, assertWalletBalanceProjection, assertWalletBalanceSummary, assertWalletLifetimeSnapshot, assertWalletLifetimeTotals, assertWalletOwnerReference, assertWalletPortfolioLifetime, assertWalletPortfolioReadScope, assertWalletPortfolioSummary, availableSourceLotAmount, boostGameplayAllocation, calculateRollingPurchaseCapUsage, canUseSourceLot, canonicalTransactionPayload, convertRewardPayout, createEarlyBackerRetentionFromPaidLot, createGameplayAllocation, createInitialSourceLotSnapshot, createPaidLotLifecycle, createProjectionSnapshot, createPurchaseIntentLifecycle, createReversalTransaction, createRollingPurchaseCapState, createWalletBalanceSummary, createWalletPortfolioLifetime, createWalletPortfolioSummary, deriveWalletBalanceDeltas, deriveWalletLifetimeDeltas, economyAssert, evaluateEarlyBacker, evaluateEarlyBackerBySettlementV2, isWholeTokenAmount, mapBitLabsConversionState, parseGbpMinorUnits, parseIsoTimestamp, parseTokenSubunits, rebuildBalanceProjection, reclaimGameplayAllocation, reducePaidLotLifecycleEvents, reducePurchaseIntentTransitions, reserveRollingPurchaseCaps, selectSourceLots, serializeGbpMinorUnits, serializeTokenSubunits, sortStringRecord, subunitsToWholeTokens, sumTokenSubunits, toEconomyErrorEnvelope, transitionRollingPurchaseCapReservation, wholeTokensToSubunits };
|
package/dist/index.d.ts
CHANGED
|
@@ -503,6 +503,88 @@ interface AdjustmentRequestV1 {
|
|
|
503
503
|
/** Proves that production adjustment approval was performed by another actor. */
|
|
504
504
|
declare function assertDistinctAdjustmentApproval(request: AdjustmentRequestV1): void;
|
|
505
505
|
|
|
506
|
+
type PaidLotLifecycleStatusV1 = "clear" | "partially-reversed" | "disputed" | "fully-reversed" | "chargeback-lost";
|
|
507
|
+
type PaidLotLifecycleEventTypeV1 = "refund" | "dispute-hold" | "dispute-won" | "dispute-lost" | "chargeback" | "reversal";
|
|
508
|
+
/** Paid-purchase facts not already carried by the source lot. */
|
|
509
|
+
interface PaidLotPurchaseProvenanceV1 {
|
|
510
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
511
|
+
readonly purchaseId: string;
|
|
512
|
+
readonly catalogVersion: string;
|
|
513
|
+
readonly purchasedAt: IsoTimestamp;
|
|
514
|
+
}
|
|
515
|
+
/** Provider-neutral refund/dispute evidence for a paid source lot. */
|
|
516
|
+
interface PaidLotLifecycleEventV1 {
|
|
517
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
518
|
+
readonly eventId: string;
|
|
519
|
+
readonly lotId: LotId;
|
|
520
|
+
readonly eventType: PaidLotLifecycleEventTypeV1;
|
|
521
|
+
readonly amount: TokenSubunitString;
|
|
522
|
+
readonly occurredAt: IsoTimestamp;
|
|
523
|
+
}
|
|
524
|
+
interface PaidLotLifecycleReceiptV1 {
|
|
525
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
526
|
+
readonly event: PaidLotLifecycleEventV1;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Retained paid-lot projection. Immutable purchase/original facts plus every
|
|
530
|
+
* receipt are sufficient to rebuild all derived amounts in occurrence order.
|
|
531
|
+
*/
|
|
532
|
+
interface PaidLotLifecycleV1 {
|
|
533
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
534
|
+
readonly lotId: LotId;
|
|
535
|
+
readonly payerAccountId: AccountId;
|
|
536
|
+
readonly receivingHouseholdId: HouseholdId;
|
|
537
|
+
readonly purchaseId: string;
|
|
538
|
+
readonly catalogVersion: string;
|
|
539
|
+
readonly purchasedAt: IsoTimestamp;
|
|
540
|
+
readonly settledAt: IsoTimestamp;
|
|
541
|
+
readonly creditedAt: IsoTimestamp;
|
|
542
|
+
readonly originalAmount: TokenSubunitString;
|
|
543
|
+
readonly retainedAmount: TokenSubunitString;
|
|
544
|
+
readonly heldAmount: TokenSubunitString;
|
|
545
|
+
readonly reversedAmount: TokenSubunitString;
|
|
546
|
+
readonly refundedAmount: TokenSubunitString;
|
|
547
|
+
readonly chargebackAmount: TokenSubunitString;
|
|
548
|
+
readonly oneTimeReversalAmount: TokenSubunitString;
|
|
549
|
+
readonly status: PaidLotLifecycleStatusV1;
|
|
550
|
+
readonly version: number;
|
|
551
|
+
readonly receipts: readonly PaidLotLifecycleReceiptV1[];
|
|
552
|
+
readonly effectiveEventIds: readonly string[];
|
|
553
|
+
}
|
|
554
|
+
/** Exact signed projection deltas produced when one receipt is appended. */
|
|
555
|
+
interface PaidLotLifecycleArithmeticV1 {
|
|
556
|
+
readonly retainedDelta: TokenSubunitString;
|
|
557
|
+
readonly heldDelta: TokenSubunitString;
|
|
558
|
+
readonly reversedDelta: TokenSubunitString;
|
|
559
|
+
readonly refundedDelta: TokenSubunitString;
|
|
560
|
+
readonly chargebackDelta: TokenSubunitString;
|
|
561
|
+
readonly oneTimeReversalDelta: TokenSubunitString;
|
|
562
|
+
}
|
|
563
|
+
interface PaidLotLifecycleMutationResultV1 {
|
|
564
|
+
readonly lifecycle: PaidLotLifecycleV1;
|
|
565
|
+
/** False only for an exact event-ID replay already recorded. */
|
|
566
|
+
readonly applied: boolean;
|
|
567
|
+
readonly stateChanged: boolean;
|
|
568
|
+
readonly arithmetic: PaidLotLifecycleArithmeticV1;
|
|
569
|
+
}
|
|
570
|
+
/** Validates the paid purchase facts paired with a source lot. */
|
|
571
|
+
declare function assertPaidLotPurchaseProvenance(provenance: PaidLotPurchaseProvenanceV1): void;
|
|
572
|
+
/** Validates one provider-neutral paid-lot lifecycle event. */
|
|
573
|
+
declare function assertPaidLotLifecycleEvent(event: PaidLotLifecycleEventV1): void;
|
|
574
|
+
/** Validates and deterministically rebuilds retained paid-lot arithmetic. */
|
|
575
|
+
declare function assertPaidLotLifecycle(lifecycle: PaidLotLifecycleV1): void;
|
|
576
|
+
/** Creates the retained projection for one newly credited paid source lot. */
|
|
577
|
+
declare function createPaidLotLifecycle(lot: SourceLotV1, provenance: PaidLotPurchaseProvenanceV1): PaidLotLifecycleV1;
|
|
578
|
+
/**
|
|
579
|
+
* Appends one event then rebuilds every receipt in authoritative occurrence
|
|
580
|
+
* order. Exact retries succeed before stale-version validation.
|
|
581
|
+
*/
|
|
582
|
+
declare function applyPaidLotLifecycleEvent(lifecycle: PaidLotLifecycleV1, event: PaidLotLifecycleEventV1, expectedVersion: number): PaidLotLifecycleMutationResultV1;
|
|
583
|
+
/** Reduces unordered/retried lifecycle evidence in canonical event order. */
|
|
584
|
+
declare function reducePaidLotLifecycleEvents(initial: PaidLotLifecycleV1, events: readonly PaidLotLifecycleEventV1[]): PaidLotLifecycleV1;
|
|
585
|
+
/** Creates the exact retained-basis input used by early-backer evaluators. */
|
|
586
|
+
declare function createEarlyBackerRetentionFromPaidLot(lifecycle: PaidLotLifecycleV1): PaidLotRetentionV1;
|
|
587
|
+
|
|
506
588
|
type WalletKind = "household-treasury" | "personal" | "gameplay-allocation" | "hold" | "purchase-clearing" | "provider-clearing" | "system";
|
|
507
589
|
type WalletStatus = "active" | "restricted" | "closed";
|
|
508
590
|
type WalletOwnerType = "account" | "household" | "system";
|
|
@@ -926,6 +1008,163 @@ interface EconomyQueryPortV1 {
|
|
|
926
1008
|
listPortfolioActivity(scope: WalletPortfolioReadScopeV1, request: WalletActivityPageRequestV1): Promise<WalletActivityPageV1>;
|
|
927
1009
|
}
|
|
928
1010
|
|
|
1011
|
+
declare const gbpMinorUnitStringBrand: unique symbol;
|
|
1012
|
+
/** Canonical non-negative GBP minor-unit string used by cap contracts. */
|
|
1013
|
+
type GbpMinorUnitString = string & {
|
|
1014
|
+
readonly [gbpMinorUnitStringBrand]: "GbpMinorUnitString";
|
|
1015
|
+
};
|
|
1016
|
+
/** Parses exact GBP minor units without floating point or coercion. */
|
|
1017
|
+
declare function parseGbpMinorUnits(value: string): bigint;
|
|
1018
|
+
/** Serializes exact GBP minor units using the canonical wire representation. */
|
|
1019
|
+
declare function serializeGbpMinorUnits(amount: bigint): GbpMinorUnitString;
|
|
1020
|
+
type PurchaseCapScopeTypeV1 = "payer" | "household";
|
|
1021
|
+
type PurchaseCapReservationStatusV1 = "reserved" | "settled" | "released" | "expired";
|
|
1022
|
+
type PurchaseCapReservationTransitionTypeV1 = "settle" | "release" | "expire";
|
|
1023
|
+
interface PurchaseCapReservationTransitionV1 {
|
|
1024
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1025
|
+
readonly transitionId: string;
|
|
1026
|
+
readonly reservationId: string;
|
|
1027
|
+
readonly transitionType: PurchaseCapReservationTransitionTypeV1;
|
|
1028
|
+
readonly occurredAt: IsoTimestamp;
|
|
1029
|
+
}
|
|
1030
|
+
/** Append-only cap evidence; effectiveness is rebuilt from occurrence order. */
|
|
1031
|
+
interface PurchaseCapReservationTransitionReceiptV1 {
|
|
1032
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1033
|
+
readonly transition: PurchaseCapReservationTransitionV1;
|
|
1034
|
+
}
|
|
1035
|
+
/** One purchase amount mirrored into payer and household cap aggregates. */
|
|
1036
|
+
interface PurchaseCapReservationV1 {
|
|
1037
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1038
|
+
readonly reservationId: string;
|
|
1039
|
+
readonly payerAccountId: AccountId;
|
|
1040
|
+
readonly householdId: HouseholdId;
|
|
1041
|
+
readonly priceMinorUnits: GbpMinorUnitString;
|
|
1042
|
+
readonly status: PurchaseCapReservationStatusV1;
|
|
1043
|
+
readonly reservedAt: IsoTimestamp;
|
|
1044
|
+
readonly expiresAt: IsoTimestamp;
|
|
1045
|
+
/** Derived winning transition; every delivery remains in `transitionReceipts`. */
|
|
1046
|
+
readonly finalTransitionId?: string;
|
|
1047
|
+
readonly finalizedAt?: IsoTimestamp;
|
|
1048
|
+
readonly transitionReceipts: readonly PurchaseCapReservationTransitionReceiptV1[];
|
|
1049
|
+
}
|
|
1050
|
+
/** Optimistic aggregate for exactly one payer or household rolling ceiling. */
|
|
1051
|
+
interface RollingPurchaseCapStateV1 {
|
|
1052
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1053
|
+
readonly scopeType: PurchaseCapScopeTypeV1;
|
|
1054
|
+
readonly scopeId: string;
|
|
1055
|
+
readonly version: number;
|
|
1056
|
+
readonly reservations: readonly PurchaseCapReservationV1[];
|
|
1057
|
+
}
|
|
1058
|
+
interface ReservePurchaseCapsCommandV1 {
|
|
1059
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1060
|
+
readonly reservationId: string;
|
|
1061
|
+
readonly payerAccountId: AccountId;
|
|
1062
|
+
readonly householdId: HouseholdId;
|
|
1063
|
+
readonly priceMinorUnits: GbpMinorUnitString;
|
|
1064
|
+
readonly reservedAt: IsoTimestamp;
|
|
1065
|
+
readonly expiresAt: IsoTimestamp;
|
|
1066
|
+
readonly expectedPayerVersion: number;
|
|
1067
|
+
readonly expectedHouseholdVersion: number;
|
|
1068
|
+
}
|
|
1069
|
+
interface PurchaseCapMutationResultV1 {
|
|
1070
|
+
readonly payerState: RollingPurchaseCapStateV1;
|
|
1071
|
+
readonly householdState: RollingPurchaseCapStateV1;
|
|
1072
|
+
readonly reservation: PurchaseCapReservationV1;
|
|
1073
|
+
/** True when a reservation or transition receipt was newly recorded. */
|
|
1074
|
+
readonly applied: boolean;
|
|
1075
|
+
readonly stateChanged: boolean;
|
|
1076
|
+
readonly payerUsageMinorUnits: GbpMinorUnitString;
|
|
1077
|
+
readonly householdUsageMinorUnits: GbpMinorUnitString;
|
|
1078
|
+
}
|
|
1079
|
+
/** Validates one rolling-cap transition envelope. */
|
|
1080
|
+
declare function assertPurchaseCapReservationTransition(transition: PurchaseCapReservationTransitionV1): void;
|
|
1081
|
+
/** Validates one mirrored rolling-cap reservation and its complete rebuild. */
|
|
1082
|
+
declare function assertPurchaseCapReservation(reservation: PurchaseCapReservationV1): void;
|
|
1083
|
+
/** Validates one payer or household rolling-cap aggregate. */
|
|
1084
|
+
declare function assertRollingPurchaseCapState(state: RollingPurchaseCapStateV1): void;
|
|
1085
|
+
/** Returns the exact cap usage at one point in time. */
|
|
1086
|
+
declare function calculateRollingPurchaseCapUsage(state: RollingPurchaseCapStateV1, checkedAt: IsoTimestamp, policy: PurchaseLimitPolicyV1): GbpMinorUnitString;
|
|
1087
|
+
/** Creates an empty compare-and-swap aggregate for one cap scope. */
|
|
1088
|
+
declare function createRollingPurchaseCapState(scopeType: PurchaseCapScopeTypeV1, scopeId: string): RollingPurchaseCapStateV1;
|
|
1089
|
+
/**
|
|
1090
|
+
* Atomically reserves the same amount in payer and household aggregates.
|
|
1091
|
+
* Adapters must compare-and-swap both returned versions in one transaction.
|
|
1092
|
+
*/
|
|
1093
|
+
declare function reserveRollingPurchaseCaps(payerState: RollingPurchaseCapStateV1, householdState: RollingPurchaseCapStateV1, command: ReservePurchaseCapsCommandV1, policy: PurchaseLimitPolicyV1): PurchaseCapMutationResultV1;
|
|
1094
|
+
/**
|
|
1095
|
+
* Appends a settle/release/expiry receipt and rebuilds authoritative order. A
|
|
1096
|
+
* late-delivered pre-expiry settlement corrects a stored expiry while retaining
|
|
1097
|
+
* both receipts. Payer and household versions still advance atomically.
|
|
1098
|
+
*/
|
|
1099
|
+
declare function transitionRollingPurchaseCapReservation(payerState: RollingPurchaseCapStateV1, householdState: RollingPurchaseCapStateV1, transition: PurchaseCapReservationTransitionV1, expectedPayerVersion: number, expectedHouseholdVersion: number, policy: PurchaseLimitPolicyV1): PurchaseCapMutationResultV1;
|
|
1100
|
+
|
|
1101
|
+
type PurchaseIntentTransitionTypeV1 = "checkout-bound" | "payment-observed" | "credit-recorded" | "expire" | "cancel" | "dispute-opened" | "dispute-won" | "dispute-lost";
|
|
1102
|
+
type PurchaseIntentDisputeDispositionV1 = "none" | "open" | "won" | "lost";
|
|
1103
|
+
/** Provider-neutral evidence for one requested purchase-intent transition. */
|
|
1104
|
+
interface PurchaseIntentTransitionV1 {
|
|
1105
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1106
|
+
readonly transitionId: string;
|
|
1107
|
+
readonly intentId: string;
|
|
1108
|
+
readonly transitionType: PurchaseIntentTransitionTypeV1;
|
|
1109
|
+
readonly occurredAt: IsoTimestamp;
|
|
1110
|
+
/** Sanitized binding; raw provider checkout references are adapter concerns. */
|
|
1111
|
+
readonly providerCheckoutReferenceHash?: string;
|
|
1112
|
+
}
|
|
1113
|
+
/** Append-only receipt. Whether it is effective is a rebuildable projection. */
|
|
1114
|
+
interface PurchaseIntentTransitionReceiptV1 {
|
|
1115
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1116
|
+
readonly transition: PurchaseIntentTransitionV1;
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Versioned lifecycle projection. `initialIntent` never changes; every delivery
|
|
1120
|
+
* is rebuilt from its append-only receipts in authoritative occurrence order.
|
|
1121
|
+
*/
|
|
1122
|
+
interface PurchaseIntentLifecycleV1 {
|
|
1123
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1124
|
+
readonly initialIntent: PurchaseIntentV1;
|
|
1125
|
+
readonly intent: PurchaseIntentV1;
|
|
1126
|
+
readonly version: number;
|
|
1127
|
+
readonly creditRecorded: boolean;
|
|
1128
|
+
readonly disputeDisposition: PurchaseIntentDisputeDispositionV1;
|
|
1129
|
+
readonly receipts: readonly PurchaseIntentTransitionReceiptV1[];
|
|
1130
|
+
readonly effectiveTransitionIds: readonly string[];
|
|
1131
|
+
}
|
|
1132
|
+
/** Stable instruction identity for the one permitted purchase credit. */
|
|
1133
|
+
interface PurchaseCreditInstructionV1 {
|
|
1134
|
+
readonly schemaVersion: EconomyContractVersion;
|
|
1135
|
+
readonly intentId: string;
|
|
1136
|
+
readonly transitionId: string;
|
|
1137
|
+
readonly idempotencyKey: string;
|
|
1138
|
+
}
|
|
1139
|
+
interface PurchaseIntentTransitionResultV1 {
|
|
1140
|
+
readonly lifecycle: PurchaseIntentLifecycleV1;
|
|
1141
|
+
/** False only for an exact transition-ID replay already in `receipts`. */
|
|
1142
|
+
readonly recorded: boolean;
|
|
1143
|
+
readonly stateChanged: boolean;
|
|
1144
|
+
readonly creditInstruction?: PurchaseCreditInstructionV1;
|
|
1145
|
+
}
|
|
1146
|
+
interface PurchaseIntentReductionV1 {
|
|
1147
|
+
readonly lifecycle: PurchaseIntentLifecycleV1;
|
|
1148
|
+
readonly creditInstructions: readonly PurchaseCreditInstructionV1[];
|
|
1149
|
+
}
|
|
1150
|
+
/** Validates one provider-neutral purchase-intent transition envelope. */
|
|
1151
|
+
declare function assertPurchaseIntentTransition(transition: PurchaseIntentTransitionV1): void;
|
|
1152
|
+
/** Validates and deterministically rebuilds a lifecycle projection. */
|
|
1153
|
+
declare function assertPurchaseIntentLifecycle(lifecycle: PurchaseIntentLifecycleV1, pack: TokenPackV1): void;
|
|
1154
|
+
/** Creates a lifecycle from immutable, server-created purchase-intent facts. */
|
|
1155
|
+
declare function createPurchaseIntentLifecycle(initialIntent: PurchaseIntentV1, pack: TokenPackV1): PurchaseIntentLifecycleV1;
|
|
1156
|
+
/**
|
|
1157
|
+
* Appends one event and rebuilds all receipts by authoritative occurrence time.
|
|
1158
|
+
* A late pre-expiry payment can therefore correct a stored expiry without
|
|
1159
|
+
* deleting the expiry receipt. Exact retries succeed before version checking.
|
|
1160
|
+
*/
|
|
1161
|
+
declare function applyPurchaseIntentTransition(lifecycle: PurchaseIntentLifecycleV1, transition: PurchaseIntentTransitionV1, expectedVersion: number, pack: TokenPackV1): PurchaseIntentTransitionResultV1;
|
|
1162
|
+
/**
|
|
1163
|
+
* Reduces an unordered delivery batch in canonical event-time/type/ID order.
|
|
1164
|
+
* Exact duplicate IDs collapse; conflicting duplicate facts are rejected.
|
|
1165
|
+
*/
|
|
1166
|
+
declare function reducePurchaseIntentTransitions(initialIntent: PurchaseIntentV1, transitions: readonly PurchaseIntentTransitionV1[], pack: TokenPackV1): PurchaseIntentReductionV1;
|
|
1167
|
+
|
|
929
1168
|
type RecurrenceInterval = "daily" | "weekly" | "monthly";
|
|
930
1169
|
/** Provider-neutral subscription contract. Site policy controls enablement. */
|
|
931
1170
|
interface TokenSubscriptionPlanV1 {
|
|
@@ -965,4 +1204,4 @@ interface SpendRequestV1 {
|
|
|
965
1204
|
/** Validates future child requests while creation remains policy-disabled. */
|
|
966
1205
|
declare function assertSpendRequest(request: SpendRequestV1): void;
|
|
967
1206
|
|
|
968
|
-
export { type AccountId, type ActivityEntryV1, type ActivityStatus, type ActivityType, type AdjustmentRequestV1, type AdjustmentStatus, type AllocationId, type AllocationStatus, BASELINE_GBP_CATALOG_VERSION, BASELINE_GBP_REFERENCE_RATE, BASELINE_GBP_TOKEN_PACKS, BASELINE_MONTHLY_SUBSCRIPTION_PLAN, BASELINE_PURCHASE_LIMIT_POLICY, type BalanceProjection, type BalanceProjectionSnapshotV1, type BitLabsConversionState, type BoostGameplayAllocationInputV1, type ChainedEconomicJournalTransactionV1, type CreateGameplayAllocationInputV1, EARLY_BACKER_SETTLEMENT_POLICY_V2, ECONOMY_CONTRACT_VERSION, type EarlyBackerEvaluationV1, type EarlyBackerEvaluationV2, type EarlyBackerWindowV1, type EconomicActivityStatusV1, type EconomicJournalStatus, type EconomicJournalTransactionV1, type EconomicWalletActivityEntryV1, type EconomyClockPort, type EconomyCommandEnvelopeV1, type EconomyCommandType, type EconomyCommandWorkflowEventV1, type EconomyCommandWorkflowStateV1, type EconomyContractVersion, EconomyError, type EconomyErrorCode, type EconomyErrorEnvelopeV1, type EconomyIdPort, type EconomyIdempotencyScopeV1, type EconomyOutboxEventV1, type EconomyPersistencePort, type EconomyPersistencePortV2, type EconomyQueryPortV1, type EconomyUnitOfWork, type EconomyUnitOfWorkV2, type FxSnapshotV1, type GameplayAllocationV1, type GameplayLimitsV1, type HouseholdId, type IsoTimestamp, type JournalChainHeadV1, type JournalChainId, type LedgerPostingV1, type LedgerTransactionV1, type LotId, type LotRefundState, type LotTransferPolicy, type LotUseContextV1, type LotUseOperation, PRE_UTILITY_BACKER_COHORT, type PaidLotRetentionV1, type PeriodicLimitWindow, type PersistedIdempotencyResultV1, type PostingId, type ProviderEventId, type PurchaseIntentStatus, type PurchaseIntentV1, type PurchaseLimitPolicyV1, type ReclaimGameplayAllocationInputV1, type RecurrenceInterval, type ReversalInputV1, type RewardActivityTransitionV1, type RewardConversionStatus, type RewardConversionV1, type RewardRateV1, type ScopedPersistedIdempotencyResultV1, type SourceLotMovementType, type SourceLotMovementV1, type SourceLotSliceV1, type SourceLotV1, type SpendRequestPurpose, type SpendRequestStatus, type SpendRequestV1, TOKEN_SUBUNITS_MAX, TOKEN_SUBUNITS_MIN, TOKEN_SUBUNITS_PER_TOKEN, type TokenPackV1, type TokenReferenceRateV1, type TokenSource, type TokenSubscriptionPlanV1, type TokenSubunitString, type TransactionId, type VersionedSourceLotV1, type WalletActivityEntryV1, type WalletActivityFilterV1, type WalletActivityPageRequestV1, type WalletActivityPageV1, type WalletActivityStatusV1, type WalletBalanceDeltaV1, type WalletBalanceProjectionV1, type WalletBalanceSummaryV1, type WalletBalanceTotalsV1, type WalletId, type WalletKind, type WalletLifetimeBucket, type WalletLifetimeDeltaV1, type WalletLifetimeSnapshotV1, type WalletLifetimeTotalsV1, type WalletOwnerReferenceV1, type WalletOwnerType, type WalletPortfolioBalanceComponentV1, type WalletPortfolioComponentRole, type WalletPortfolioComponentScopeV1, type WalletPortfolioLifetimeComponentV1, type WalletPortfolioLifetimeV1, type WalletPortfolioReadScopeV1, type WalletPortfolioSummaryV1, type WalletPostingAccountBindingV1, type WalletProjectionBucket, type WalletStatus, type WalletV1, type WorkflowActivityStatusV1, type WorkflowWalletActivityEntryV1, advanceJournalChainHead, applySourceLotMovement, applyTransactionToProjection, applyWalletBalanceDelta, applyWalletLifetimeDeltas, assertActivityEntry, assertBalancedTransaction, assertDeterministicWalletBalanceSummary, assertDistinctAdjustmentApproval, assertEconomicJournalTransaction, assertEconomyCommandEnvelope, assertEconomyCommandWorkflowEvent, assertEconomyIdempotencyScope, assertEconomyIdentifier, assertFlatTokenCatalog, assertFxSnapshot, assertGameplayAllocation, assertJournalChainHead, assertNonNegativeAccounts, assertOpenPurchaseIntent, assertPurchaseIntentBinding, assertPurchaseLimitPolicy, assertReversalAvailable, assertRewardConversion, assertRewardRate, assertScopedPersistedIdempotencyResult, assertSourceLot, assertSourceLotMovement, assertSpendRequest, assertTokenPack, assertTokenReferenceRate, assertTokenSubscriptionPlan, assertVersionedSourceLot, assertWallet, assertWalletActivityEntry, assertWalletActivityPage, assertWalletActivityPageForPortfolio, assertWalletActivityPageRequest, assertWalletBalanceDelta, assertWalletBalanceDeltaBatch, assertWalletBalanceProjection, assertWalletBalanceSummary, assertWalletLifetimeSnapshot, assertWalletLifetimeTotals, assertWalletOwnerReference, assertWalletPortfolioLifetime, assertWalletPortfolioReadScope, assertWalletPortfolioSummary, availableSourceLotAmount, boostGameplayAllocation, canUseSourceLot, canonicalTransactionPayload, convertRewardPayout, createGameplayAllocation, createInitialSourceLotSnapshot, createProjectionSnapshot, createReversalTransaction, createWalletBalanceSummary, createWalletPortfolioLifetime, createWalletPortfolioSummary, deriveWalletBalanceDeltas, deriveWalletLifetimeDeltas, economyAssert, evaluateEarlyBacker, evaluateEarlyBackerBySettlementV2, isWholeTokenAmount, mapBitLabsConversionState, parseIsoTimestamp, parseTokenSubunits, rebuildBalanceProjection, reclaimGameplayAllocation, selectSourceLots, serializeTokenSubunits, sortStringRecord, subunitsToWholeTokens, sumTokenSubunits, toEconomyErrorEnvelope, wholeTokensToSubunits };
|
|
1207
|
+
export { type AccountId, type ActivityEntryV1, type ActivityStatus, type ActivityType, type AdjustmentRequestV1, type AdjustmentStatus, type AllocationId, type AllocationStatus, BASELINE_GBP_CATALOG_VERSION, BASELINE_GBP_REFERENCE_RATE, BASELINE_GBP_TOKEN_PACKS, BASELINE_MONTHLY_SUBSCRIPTION_PLAN, BASELINE_PURCHASE_LIMIT_POLICY, type BalanceProjection, type BalanceProjectionSnapshotV1, type BitLabsConversionState, type BoostGameplayAllocationInputV1, type ChainedEconomicJournalTransactionV1, type CreateGameplayAllocationInputV1, EARLY_BACKER_SETTLEMENT_POLICY_V2, ECONOMY_CONTRACT_VERSION, type EarlyBackerEvaluationV1, type EarlyBackerEvaluationV2, type EarlyBackerWindowV1, type EconomicActivityStatusV1, type EconomicJournalStatus, type EconomicJournalTransactionV1, type EconomicWalletActivityEntryV1, type EconomyClockPort, type EconomyCommandEnvelopeV1, type EconomyCommandType, type EconomyCommandWorkflowEventV1, type EconomyCommandWorkflowStateV1, type EconomyContractVersion, EconomyError, type EconomyErrorCode, type EconomyErrorEnvelopeV1, type EconomyIdPort, type EconomyIdempotencyScopeV1, type EconomyOutboxEventV1, type EconomyPersistencePort, type EconomyPersistencePortV2, type EconomyQueryPortV1, type EconomyUnitOfWork, type EconomyUnitOfWorkV2, type FxSnapshotV1, type GameplayAllocationV1, type GameplayLimitsV1, type GbpMinorUnitString, type HouseholdId, type IsoTimestamp, type JournalChainHeadV1, type JournalChainId, type LedgerPostingV1, type LedgerTransactionV1, type LotId, type LotRefundState, type LotTransferPolicy, type LotUseContextV1, type LotUseOperation, PRE_UTILITY_BACKER_COHORT, type PaidLotLifecycleArithmeticV1, type PaidLotLifecycleEventTypeV1, type PaidLotLifecycleEventV1, type PaidLotLifecycleMutationResultV1, type PaidLotLifecycleReceiptV1, type PaidLotLifecycleStatusV1, type PaidLotLifecycleV1, type PaidLotPurchaseProvenanceV1, type PaidLotRetentionV1, type PeriodicLimitWindow, type PersistedIdempotencyResultV1, type PostingId, type ProviderEventId, type PurchaseCapMutationResultV1, type PurchaseCapReservationStatusV1, type PurchaseCapReservationTransitionReceiptV1, type PurchaseCapReservationTransitionTypeV1, type PurchaseCapReservationTransitionV1, type PurchaseCapReservationV1, type PurchaseCapScopeTypeV1, type PurchaseCreditInstructionV1, type PurchaseIntentDisputeDispositionV1, type PurchaseIntentLifecycleV1, type PurchaseIntentReductionV1, type PurchaseIntentStatus, type PurchaseIntentTransitionReceiptV1, type PurchaseIntentTransitionResultV1, type PurchaseIntentTransitionTypeV1, type PurchaseIntentTransitionV1, type PurchaseIntentV1, type PurchaseLimitPolicyV1, type ReclaimGameplayAllocationInputV1, type RecurrenceInterval, type ReservePurchaseCapsCommandV1, type ReversalInputV1, type RewardActivityTransitionV1, type RewardConversionStatus, type RewardConversionV1, type RewardRateV1, type RollingPurchaseCapStateV1, type ScopedPersistedIdempotencyResultV1, type SourceLotMovementType, type SourceLotMovementV1, type SourceLotSliceV1, type SourceLotV1, type SpendRequestPurpose, type SpendRequestStatus, type SpendRequestV1, TOKEN_SUBUNITS_MAX, TOKEN_SUBUNITS_MIN, TOKEN_SUBUNITS_PER_TOKEN, type TokenPackV1, type TokenReferenceRateV1, type TokenSource, type TokenSubscriptionPlanV1, type TokenSubunitString, type TransactionId, type VersionedSourceLotV1, type WalletActivityEntryV1, type WalletActivityFilterV1, type WalletActivityPageRequestV1, type WalletActivityPageV1, type WalletActivityStatusV1, type WalletBalanceDeltaV1, type WalletBalanceProjectionV1, type WalletBalanceSummaryV1, type WalletBalanceTotalsV1, type WalletId, type WalletKind, type WalletLifetimeBucket, type WalletLifetimeDeltaV1, type WalletLifetimeSnapshotV1, type WalletLifetimeTotalsV1, type WalletOwnerReferenceV1, type WalletOwnerType, type WalletPortfolioBalanceComponentV1, type WalletPortfolioComponentRole, type WalletPortfolioComponentScopeV1, type WalletPortfolioLifetimeComponentV1, type WalletPortfolioLifetimeV1, type WalletPortfolioReadScopeV1, type WalletPortfolioSummaryV1, type WalletPostingAccountBindingV1, type WalletProjectionBucket, type WalletStatus, type WalletV1, type WorkflowActivityStatusV1, type WorkflowWalletActivityEntryV1, advanceJournalChainHead, applyPaidLotLifecycleEvent, applyPurchaseIntentTransition, applySourceLotMovement, applyTransactionToProjection, applyWalletBalanceDelta, applyWalletLifetimeDeltas, assertActivityEntry, assertBalancedTransaction, assertDeterministicWalletBalanceSummary, assertDistinctAdjustmentApproval, assertEconomicJournalTransaction, assertEconomyCommandEnvelope, assertEconomyCommandWorkflowEvent, assertEconomyIdempotencyScope, assertEconomyIdentifier, assertFlatTokenCatalog, assertFxSnapshot, assertGameplayAllocation, assertJournalChainHead, assertNonNegativeAccounts, assertOpenPurchaseIntent, assertPaidLotLifecycle, assertPaidLotLifecycleEvent, assertPaidLotPurchaseProvenance, assertPurchaseCapReservation, assertPurchaseCapReservationTransition, assertPurchaseIntentBinding, assertPurchaseIntentLifecycle, assertPurchaseIntentTransition, assertPurchaseLimitPolicy, assertReversalAvailable, assertRewardConversion, assertRewardRate, assertRollingPurchaseCapState, assertScopedPersistedIdempotencyResult, assertSourceLot, assertSourceLotMovement, assertSpendRequest, assertTokenPack, assertTokenReferenceRate, assertTokenSubscriptionPlan, assertVersionedSourceLot, assertWallet, assertWalletActivityEntry, assertWalletActivityPage, assertWalletActivityPageForPortfolio, assertWalletActivityPageRequest, assertWalletBalanceDelta, assertWalletBalanceDeltaBatch, assertWalletBalanceProjection, assertWalletBalanceSummary, assertWalletLifetimeSnapshot, assertWalletLifetimeTotals, assertWalletOwnerReference, assertWalletPortfolioLifetime, assertWalletPortfolioReadScope, assertWalletPortfolioSummary, availableSourceLotAmount, boostGameplayAllocation, calculateRollingPurchaseCapUsage, canUseSourceLot, canonicalTransactionPayload, convertRewardPayout, createEarlyBackerRetentionFromPaidLot, createGameplayAllocation, createInitialSourceLotSnapshot, createPaidLotLifecycle, createProjectionSnapshot, createPurchaseIntentLifecycle, createReversalTransaction, createRollingPurchaseCapState, createWalletBalanceSummary, createWalletPortfolioLifetime, createWalletPortfolioSummary, deriveWalletBalanceDeltas, deriveWalletLifetimeDeltas, economyAssert, evaluateEarlyBacker, evaluateEarlyBackerBySettlementV2, isWholeTokenAmount, mapBitLabsConversionState, parseGbpMinorUnits, parseIsoTimestamp, parseTokenSubunits, rebuildBalanceProjection, reclaimGameplayAllocation, reducePaidLotLifecycleEvents, reducePurchaseIntentTransitions, reserveRollingPurchaseCaps, selectSourceLots, serializeGbpMinorUnits, serializeTokenSubunits, sortStringRecord, subunitsToWholeTokens, sumTokenSubunits, toEconomyErrorEnvelope, transitionRollingPurchaseCapReservation, wholeTokensToSubunits };
|