@happyvertical/smrt-commerce 0.51.32 → 0.51.33

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.
Files changed (55) hide show
  1. package/dist/__tests__/foreign-key-fixtures.d.ts +13 -0
  2. package/dist/__tests__/foreign-key-fixtures.d.ts.map +1 -0
  3. package/dist/__tests__/helpers/anchor-fixture.d.ts +36 -0
  4. package/dist/__tests__/helpers/anchor-fixture.d.ts.map +1 -0
  5. package/dist/__tests__/helpers/billing-fixture.d.ts +51 -0
  6. package/dist/__tests__/helpers/billing-fixture.d.ts.map +1 -0
  7. package/dist/__tests__/helpers/consumer-license-sale.d.ts +13 -0
  8. package/dist/__tests__/helpers/consumer-license-sale.d.ts.map +1 -0
  9. package/dist/__tests__/helpers/fake-stripe.d.ts +146 -0
  10. package/dist/__tests__/helpers/fake-stripe.d.ts.map +1 -0
  11. package/dist/billing/cards.d.ts +14 -4
  12. package/dist/billing/credits.d.ts +2 -2
  13. package/dist/billing/cycles.d.ts +21 -1
  14. package/dist/billing/events.d.ts +14 -4
  15. package/dist/billing/jobs.d.ts +3 -3
  16. package/dist/billing/period-close.d.ts +1 -1
  17. package/dist/billing/provider.d.ts +12 -2
  18. package/dist/billing/runtime.d.ts +17 -12
  19. package/dist/billing/stripe.d.ts +11 -2
  20. package/dist/billing/top-up.d.ts +4 -4
  21. package/dist/collections/ContractCollection.d.ts +4 -0
  22. package/dist/collections/ContractLineItemCollection.d.ts +4 -0
  23. package/dist/collections/CustomerCollection.d.ts +4 -0
  24. package/dist/collections/FulfillmentCollection.d.ts +5 -1
  25. package/dist/collections/FulfillmentLineItemCollection.d.ts +4 -0
  26. package/dist/collections/InvoiceCollection.d.ts +4 -0
  27. package/dist/collections/InvoiceLineItemCollection.d.ts +5 -1
  28. package/dist/collections/PaymentAllocationCollection.d.ts +4 -0
  29. package/dist/collections/PaymentCollection.d.ts +5 -1
  30. package/dist/collections/PaymentInstrumentCollection.d.ts +4 -0
  31. package/dist/collections/PaymentIntentCollection.d.ts +12 -1
  32. package/dist/collections/PayoutCollection.d.ts +12 -1
  33. package/dist/collections/VendorCollection.d.ts +4 -0
  34. package/dist/index.d.ts +63 -0
  35. package/dist/index.js +1 -1
  36. package/dist/manifest.json +1 -1
  37. package/dist/migrations/moneyMinorUnits.d.ts +61 -1
  38. package/dist/models/Contract.d.ts +6 -2
  39. package/dist/models/ContractLineItem.d.ts +5 -1
  40. package/dist/models/Customer.d.ts +5 -1
  41. package/dist/models/Fulfillment.d.ts +5 -1
  42. package/dist/models/FulfillmentLineItem.d.ts +5 -1
  43. package/dist/models/Invoice.d.ts +6 -2
  44. package/dist/models/InvoiceLineItem.d.ts +5 -1
  45. package/dist/models/Payment.d.ts +6 -2
  46. package/dist/models/PaymentAllocation.d.ts +5 -1
  47. package/dist/models/PaymentInstrument.d.ts +5 -1
  48. package/dist/models/PaymentIntent.d.ts +24 -1
  49. package/dist/models/Payout.d.ts +24 -1
  50. package/dist/models/Vendor.d.ts +5 -1
  51. package/dist/models/billing.d.ts +8 -1
  52. package/dist/smrt-knowledge.json +4 -4
  53. package/dist/types/index.d.ts +5 -1
  54. package/dist/ui.d.ts +14 -1
  55. package/package.json +10 -10
@@ -0,0 +1,13 @@
1
+ interface CommerceForeignKeyFixtures {
2
+ db: {
3
+ type: 'sqlite';
4
+ url: string;
5
+ };
6
+ customerIds?: string[];
7
+ vendorIds?: string[];
8
+ contractIds?: string[];
9
+ }
10
+ /** Seed only the real same-package parents referenced by a test scenario. */
11
+ export declare function seedCommerceForeignKeyFixtures({ db, customerIds, vendorIds, contractIds, }: CommerceForeignKeyFixtures): Promise<void>;
12
+ export {};
13
+ //# sourceMappingURL=foreign-key-fixtures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foreign-key-fixtures.d.ts","sourceRoot":"","sources":["../../src/__tests__/foreign-key-fixtures.ts"],"names":[],"mappings":"AAIA,UAAU,0BAA0B;IAClC,EAAE,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,6EAA6E;AAC7E,wBAAsB,8BAA8B,CAAC,EACnD,EAAE,EACF,WAAgB,EAChB,SAAc,EACd,WAAgB,GACjB,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CA2B5C"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Helpers for billing-cycle anchor tests (#3116), shared by the SQLite suite
3
+ * and the PostgreSQL lane. Scenarios run at fixed future dates with no usage
4
+ * charges, so only flat plans are billed.
5
+ */
6
+ import type { TenantSubscription } from '@happyvertical/smrt-subscriptions';
7
+ import type { BillingRuntime } from '../../billing/runtime.js';
8
+ import { type BillingLineSource } from '../../models/billing.js';
9
+ import { type BillingWorld } from './billing-fixture.js';
10
+ export declare const at: (iso: string) => Date;
11
+ export declare const DAY = 86400000;
12
+ export declare function subscriptionOf(world: BillingWorld, tenantId: string): Promise<TenantSubscription>;
13
+ export declare function updateSubscription(world: BillingWorld, tenantId: string, patch: Partial<Pick<TenantSubscription, 'startedAt' | 'canceledAt' | 'trialEndsAt' | 'status'>>): Promise<TenantSubscription>;
14
+ /** Put SITE (billed to NETWORK) out of the way so NETWORK has nothing due. */
15
+ export declare function parkNetwork(world: BillingWorld): Promise<void>;
16
+ /** Subscribe another tenant to the provider's site plan, billed to NETWORK. */
17
+ export declare function addNetworkSite(world: BillingWorld, tenantId: string, startedAt: Date): Promise<TenantSubscription>;
18
+ /** A payer's invoices from the provider runtime, oldest period first. */
19
+ export declare function invoicesOf(world: BillingWorld, payer: string, runtime?: BillingRuntime): Promise<import("../../index.js").Invoice[]>;
20
+ export declare function flatClaims(world: BillingWorld, subscriptionId?: string): Promise<BillingLineSource[]>;
21
+ /** Claimed windows as ISO pairs with amounts, in time order. */
22
+ export declare function claimedWindows(world: BillingWorld, subscriptionId: string): Promise<Array<[string, string, number]>>;
23
+ /** Assert that no two flat claims of one subscription cover the same time. */
24
+ export declare function overlappingClaims(world: BillingWorld): Promise<string[]>;
25
+ /**
26
+ * Hold a runtime's first flat-plan claim insert for `lineKey` until
27
+ * `release()`: `reached` resolves once the claim has read the existing
28
+ * coverage and is about to insert, so a test can interleave a second worker
29
+ * deterministically.
30
+ */
31
+ export declare function holdFlatClaim(runtime: BillingRuntime, lineKey: string): {
32
+ reached: Promise<void>;
33
+ release: () => void;
34
+ restore: () => void;
35
+ };
36
+ //# sourceMappingURL=anchor-fixture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor-fixture.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/anchor-fixture.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAG5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,YAAY,EAIlB,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,EAAE,GAAI,KAAK,MAAM,SAAkB,CAAC;AACjD,eAAO,MAAM,GAAG,WAAa,CAAC;AAE9B,wBAAsB,cAAc,CAClC,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,kBAAkB,CAAC,CAM7B;AAED,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,CACZ,IAAI,CACF,kBAAkB,EAClB,WAAW,GAAG,YAAY,GAAG,aAAa,GAAG,QAAQ,CACtD,CACF,GACA,OAAO,CAAC,kBAAkB,CAAC,CAO7B;AAED,8EAA8E;AAC9E,wBAAsB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpE;AAED,+EAA+E;AAC/E,wBAAsB,cAAc,CAClC,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,IAAI,GACd,OAAO,CAAC,kBAAkB,CAAC,CAgB7B;AAED,yEAAyE;AACzE,wBAAsB,UAAU,CAC9B,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,cAA+B,+CAUzC;AAED,wBAAsB,UAAU,CAC9B,KAAK,EAAE,YAAY,EACnB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAW9B;AAED,gEAAgE;AAChE,wBAAsB,cAAc,CAClC,KAAK,EAAE,YAAY,EACnB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAM1C;AAED,8EAA8E;AAC9E,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,MAAM,EAAE,CAAC,CAqBnB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM;;mBAGhD,IAAI;;EAqBzB"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * A small reseller world for billing-period close tests (#3060), shared by
3
+ * the SQLite suite and the PostgreSQL lane.
4
+ *
5
+ * PROVIDER sells to NETWORK (a reseller that pays for SITE's usage and plan)
6
+ * and to SOLO (billed for itself). NETWORK resells to SITE (retail usage) and
7
+ * to SITE2 (NETWORK's own flat plan).
8
+ */
9
+ import type { DatabaseInterface } from '@happyvertical/smrt-core/migrations';
10
+ import { BillingAdjustmentCollection, ClientChargeCollection, CommercialUsageService, ResellerBillingService, SubscriptionPlanCollection, TenantSubscriptionCollection } from '@happyvertical/smrt-subscriptions';
11
+ import { BillingRelationshipService } from '@happyvertical/smrt-tenancy';
12
+ import { type BillingLedgerAccounts, BillingRuntime, type PayerStandingChange } from '../../billing/runtime.js';
13
+ import { FakeStripe } from './fake-stripe.js';
14
+ export declare const PROVIDER = "00000000-0000-4000-8000-00000000000a";
15
+ export declare const NETWORK = "aaaaaaaa-1111-4111-8111-aaaaaaaaaaaa";
16
+ export declare const SITE = "cccccccc-3333-4333-8333-cccccccccccc";
17
+ export declare const SITE2 = "eeeeeeee-5555-4555-8555-eeeeeeeeeeee";
18
+ export declare const SOLO = "dddddddd-4444-4444-8444-dddddddddddd";
19
+ export declare const STRANGER = "ffffffff-6666-4666-8666-ffffffffffff";
20
+ /** The current UTC calendar month, closable by passing `now: periodEnd + 1d`. */
21
+ export declare function currentMonth(): {
22
+ periodStart: Date;
23
+ periodEnd: Date;
24
+ now: Date;
25
+ };
26
+ export declare function nextMonth(period: {
27
+ periodEnd: Date;
28
+ }): {
29
+ periodStart: Date;
30
+ periodEnd: Date;
31
+ now: Date;
32
+ };
33
+ export interface BillingWorld {
34
+ db: DatabaseInterface;
35
+ stripe: FakeStripe;
36
+ provider: BillingRuntime;
37
+ reseller: BillingRuntime;
38
+ commercial: CommercialUsageService;
39
+ relationships: BillingRelationshipService;
40
+ resellerBilling: ResellerBillingService;
41
+ ledger: BillingLedgerAccounts;
42
+ standingChanges: PayerStandingChange[];
43
+ subscriptions: TenantSubscriptionCollection;
44
+ plans: SubscriptionPlanCollection;
45
+ charges: ClientChargeCollection;
46
+ adjustments: BillingAdjustmentCollection;
47
+ /** Record and rate one usage event (10 tokens) for a tenant. */
48
+ usage(tenantId: string, quantity?: number): Promise<void>;
49
+ }
50
+ export declare function createBillingWorld(db: DatabaseInterface): Promise<BillingWorld>;
51
+ //# sourceMappingURL=billing-fixture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-fixture.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/billing-fixture.ts"],"names":[],"mappings":"AAAA;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,EAAE,0BAA0B,CAAC;IAClC,OAAO,EAAE,sBAAsB,CAAC;IAChC,WAAW,EAAE,2BAA2B,CAAC;IACzC,gEAAgE;IAChE,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3D;AAID,wBAAsB,kBAAkB,CACtC,EAAE,EAAE,iBAAiB,GACpB,OAAO,CAAC,YAAY,CAAC,CA6OvB"}
@@ -0,0 +1,13 @@
1
+ import { type SmrtObject } from '@happyvertical/smrt-core';
2
+ export declare const CONSUMER_PACKAGE = "@fixture/market-core";
3
+ export declare function defineConsumerLicenseSale(): Promise<{
4
+ ctor: typeof SmrtObject;
5
+ dispose: () => void;
6
+ }>;
7
+ /**
8
+ * Each `LicenseSale` keeps its own identity and table, the schema planner
9
+ * keeps commerce's `contracts` free of the consumer's class, and commerce's
10
+ * `LicenseSale` still round-trips through its own table.
11
+ */
12
+ export declare function assertLicenseSalesCoexist(consumer: typeof SmrtObject): Promise<void>;
13
+ //# sourceMappingURL=consumer-license-sale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumer-license-sale.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/consumer-license-sale.ts"],"names":[],"mappings":"AAwBA,OAAO,EAEL,KAAK,UAAU,EAGhB,MAAM,0BAA0B,CAAC;AAKlC,eAAO,MAAM,gBAAgB,yBAAyB,CAAC;AAEvD,wBAAsB,yBAAyB,IAAI,OAAO,CAAC;IACzD,IAAI,EAAE,OAAO,UAAU,CAAC;IACxB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC,CAgCD;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,OAAO,UAAU,GAC1B,OAAO,CAAC,IAAI,CAAC,CA2Cf"}
@@ -0,0 +1,146 @@
1
+ import type { StripeAccountingProvider } from '@happyvertical/accounting';
2
+ export declare const WEBHOOK_SECRET = "whsec_test_billing";
3
+ interface FakeCustomer {
4
+ id: string;
5
+ created: number;
6
+ name?: string;
7
+ email?: string;
8
+ address?: Record<string, string>;
9
+ tax_exempt?: string;
10
+ default_payment_method?: string;
11
+ metadata: Record<string, string>;
12
+ }
13
+ interface FakeInvoiceItem {
14
+ id: string;
15
+ customer: string;
16
+ currency: string;
17
+ quantity: number;
18
+ unit_amount: number;
19
+ description: string;
20
+ invoice: string | null;
21
+ metadata: Record<string, string>;
22
+ }
23
+ interface FakeInvoice {
24
+ id: string;
25
+ customer: string;
26
+ currency: string;
27
+ status: 'draft' | 'open' | 'paid' | 'void' | 'uncollectible';
28
+ collection_method: 'send_invoice' | 'charge_automatically';
29
+ auto_advance: boolean;
30
+ finalized: number;
31
+ due_date: number | null;
32
+ created: number;
33
+ automatic_tax: boolean;
34
+ items: string[];
35
+ subtotal: number;
36
+ tax: number;
37
+ total: number;
38
+ amount_paid: number;
39
+ amount_remaining: number;
40
+ metadata: Record<string, string>;
41
+ sent: number;
42
+ }
43
+ interface FakeSession {
44
+ id: string;
45
+ url: string;
46
+ mode: string;
47
+ currency: string | null;
48
+ amount_subtotal: number | null;
49
+ amount_tax: number;
50
+ amount_total: number | null;
51
+ customer: string | null;
52
+ status: 'open' | 'complete' | 'expired';
53
+ payment_status: 'paid' | 'unpaid' | 'no_payment_required';
54
+ automatic_tax: boolean;
55
+ customer_update_address: boolean;
56
+ billing_address_collection: string | null;
57
+ setup_future_usage: string | null;
58
+ payment_method: string | null;
59
+ metadata: Record<string, string>;
60
+ }
61
+ /** How a saved payment method answers an off-session charge. */
62
+ export type FakeCardBehavior = 'succeed' | 'processing' | 'decline' | 'authentication_required';
63
+ interface FakePaymentIntent {
64
+ id: string;
65
+ object: 'payment_intent';
66
+ created: number;
67
+ amount: number;
68
+ currency: string;
69
+ customer: string;
70
+ payment_method: string;
71
+ status: string;
72
+ last_payment_error: Record<string, string> | null;
73
+ metadata: Record<string, string>;
74
+ }
75
+ export declare class FakeStripe {
76
+ readonly customers: Map<string, FakeCustomer>;
77
+ readonly invoiceItems: Map<string, FakeInvoiceItem>;
78
+ readonly invoices: Map<string, FakeInvoice>;
79
+ readonly sessions: Map<string, FakeSession>;
80
+ readonly paymentIntents: Map<string, FakePaymentIntent>;
81
+ /** False while Stripe's search index lags behind writes. */
82
+ searchable: boolean;
83
+ /** Behavior of each saved payment method (default `succeed`). */
84
+ readonly cards: Map<string, FakeCardBehavior>;
85
+ readonly subscriptions: Map<string, Record<string, unknown>>;
86
+ readonly requests: Array<{
87
+ method: string;
88
+ path: string;
89
+ key?: string;
90
+ }>;
91
+ private readonly idempotent;
92
+ private failures;
93
+ private counter;
94
+ private nextId;
95
+ /** Make the next matching request(s) fail. */
96
+ fail(method: string, path: RegExp, when?: 'before' | 'after', times?: number): void;
97
+ provider(): Promise<StripeAccountingProvider>;
98
+ readonly fetch: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
99
+ private route;
100
+ private applyCustomer;
101
+ private recalculate;
102
+ private customerView;
103
+ private sessionView;
104
+ private view;
105
+ /** Customer pays an open invoice in full. */
106
+ pay(invoiceId: string): void;
107
+ /**
108
+ * Stripe's automatic collection of a finalized `charge_automatically`
109
+ * invoice: charges the customer's default card. Returns the outcome.
110
+ */
111
+ collect(invoiceId: string): 'paid' | 'failed';
112
+ /**
113
+ * The customer finishes a checkout: a payment session is paid with tax
114
+ * from the collected (or customer) address; a setup session saves
115
+ * `paymentMethod`. A collected address is saved to the customer when the
116
+ * session asked to.
117
+ */
118
+ completeSession(sessionId: string, options?: {
119
+ paymentMethod?: string;
120
+ address?: Record<string, string>;
121
+ }): FakeSession;
122
+ private createPaymentIntent;
123
+ /** A processing PaymentIntent settles (Stripe then sends its event). */
124
+ settlePaymentIntent(intentId: string, status: 'succeeded' | 'failed'): FakePaymentIntent;
125
+ setInvoiceStatus(invoiceId: string, status: FakeInvoice['status']): void;
126
+ lineItemsOf(invoiceId: string): FakeInvoiceItem[];
127
+ }
128
+ /** A signed Stripe webhook delivery for `event`. */
129
+ export declare function signedEvent(event: Record<string, unknown>): {
130
+ payload: string;
131
+ signature: string;
132
+ };
133
+ export declare function invoiceEvent(type: string, invoiceId: string): Record<string, unknown>;
134
+ export declare function checkoutEvent(session: {
135
+ id: string;
136
+ mode?: string;
137
+ currency: string | null;
138
+ amount_subtotal: number | null;
139
+ amount_total?: number | null;
140
+ metadata: Record<string, string>;
141
+ }, paymentStatus?: string, type?: string): Record<string, unknown>;
142
+ /** A `payment_intent.*` event for a PaymentIntent the fake holds. */
143
+ export declare function paymentIntentEvent(type: string, intent: Record<string, unknown>): Record<string, unknown>;
144
+ export declare function subscriptionEvent(type: string, subscriptionId: string): Record<string, unknown>;
145
+ export {};
146
+ //# sourceMappingURL=fake-stripe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fake-stripe.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/fake-stripe.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAG1E,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAEnD,UAAU,YAAY;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,UAAU,eAAe;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;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,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAOA;AAID,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE;IACP,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,EACD,aAAa,SAAS,EACtB,IAAI,SAA+B,GAClC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAmBzB;AAED,qEAAqE;AACrE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,GACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB"}
@@ -1,7 +1,17 @@
1
- import { DatabaseInterface } from '@happyvertical/smrt-core/migrations';
2
- import { BillingAccount } from '../models/billing.js';
3
- import { BillingProviderCheckoutSession, BillingProviderCheckoutState } from './provider.js';
4
- import { BillingRuntime } from './runtime.js';
1
+ /**
2
+ * Card on file (#3139): a provider checkout that saves a payment method
3
+ * without charging, and the settlement that makes it the payer's default.
4
+ *
5
+ * A completed setup (or a credit purchase that saved its card) is applied
6
+ * from the provider's checkout event: `observe()` re-reads the session and
7
+ * makes the saved method the provider customer's default; `project()`
8
+ * records it as the payer customer's default commerce `PaymentInstrument`
9
+ * and adopts the billing address collected at checkout as the tax location.
10
+ */
11
+ import type { DatabaseInterface } from '@happyvertical/smrt-core/migrations';
12
+ import type { BillingAccount } from '../models/billing.js';
13
+ import type { BillingProviderCheckoutSession, BillingProviderCheckoutState } from './provider.js';
14
+ import type { BillingRuntime } from './runtime.js';
5
15
  export declare const CARD_SETUP_PURPOSE = "card_setup";
6
16
  /** Checkout metadata flag: the session saves its payment method. */
7
17
  export declare const SAVE_CARD_METADATA = "smrt_save_card";
@@ -1,5 +1,5 @@
1
- import { BillingProviderCheckoutSession } from './provider.js';
2
- import { BillingRuntime } from './runtime.js';
1
+ import type { BillingProviderCheckoutSession } from './provider.js';
2
+ import type { BillingRuntime } from './runtime.js';
3
3
  export declare const CREDIT_PURCHASE_PURPOSE = "credit_purchase";
4
4
  export interface CreateCreditCheckoutInput {
5
5
  /** The `period: 'balance'` spending policy to credit. */
@@ -1,4 +1,24 @@
1
- import { BillingPeriod } from './period-close.js';
1
+ /**
2
+ * Billing-cycle schedule and proration math (#3116).
3
+ *
4
+ * A payer's billing periods are a pure function of its account's
5
+ * `billingAnchorAt`:
6
+ *
7
+ * - no anchor: UTC calendar months (the default, and the only schedule before
8
+ * #3116);
9
+ * - an anchor `A`: monthly periods `[A + k months, A + (k + 1) months)` at
10
+ * `A`'s UTC time of day. A day past the end of a shorter month is clamped to
11
+ * its last day, always computed from `A` itself, so an anchor on the 31st
12
+ * runs Jan 31 → Feb 28 (29) → Mar 31 without drifting. Before `A` the
13
+ * schedule stays calendar months, and the month `A` falls in ends early at
14
+ * `A` (a *stub* period), so an account that moves from calendar months to an
15
+ * anchor has no gap and no overlap.
16
+ *
17
+ * Every period carries the full cycle it belongs to (`cycleStart`/`cycleEnd`);
18
+ * that cycle's length is the proration denominator, so a stub is billed as the
19
+ * fraction of its calendar month it covers.
20
+ */
21
+ import type { BillingPeriod } from './period-close.js';
2
22
  /** A period of a payer's schedule and the full cycle it prorates against. */
3
23
  export interface ScheduledBillingPeriod extends BillingPeriod {
4
24
  /** Start of the full monthly cycle (equals `periodStart` except for a stub). */
@@ -1,7 +1,17 @@
1
- import { ForgeProjector } from '@happyvertical/smrt-jobs';
2
- import { SavedCard } from './cards.js';
3
- import { BillingProviderCheckoutState, BillingProviderEvent, BillingProviderInvoiceState, BillingProviderSubscriptionState } from './provider.js';
4
- import { BillingRuntime } from './runtime.js';
1
+ /**
2
+ * Provider event processing (#3060): verified webhook deliveries queued in
3
+ * smrt-jobs' durable delivery inbox are applied here.
4
+ *
5
+ * `observe()` re-reads the invoice or subscription from the provider, so an
6
+ * event is applied against current provider state rather than the snapshot it
7
+ * carried; out-of-order and duplicate deliveries therefore converge. The
8
+ * application writes, the inbox completion, and the host standing hook share
9
+ * one transaction.
10
+ */
11
+ import { type ForgeProjector } from '@happyvertical/smrt-jobs';
12
+ import { type SavedCard } from './cards.js';
13
+ import type { BillingProviderCheckoutState, BillingProviderEvent, BillingProviderInvoiceState, BillingProviderSubscriptionState } from './provider.js';
14
+ import type { BillingRuntime } from './runtime.js';
5
15
  type InvoiceEvent = Extract<BillingProviderEvent, {
6
16
  kind: 'invoice';
7
17
  }>;
@@ -1,6 +1,6 @@
1
- import { SmrtJob } from '@happyvertical/smrt-jobs';
2
- import { PeriodCloseResult } from './period-close.js';
3
- import { BillingRuntime } from './runtime.js';
1
+ import { type SmrtJob } from '@happyvertical/smrt-jobs';
2
+ import type { PeriodCloseResult } from './period-close.js';
3
+ import type { BillingRuntime } from './runtime.js';
4
4
  /** Make a runtime available to billing jobs under `name`. */
5
5
  export declare function registerBillingRuntime(name: string, runtime: BillingRuntime): void;
6
6
  export declare function unregisterBillingRuntime(name: string): void;
@@ -1,4 +1,4 @@
1
- import { BillingRuntime } from './runtime.js';
1
+ import type { BillingRuntime } from './runtime.js';
2
2
  export interface BillingPeriod {
3
3
  /** Inclusive start. */
4
4
  periodStart: Date;
@@ -1,5 +1,15 @@
1
- import { SubscriptionStatus } from '@happyvertical/smrt-subscriptions';
2
- import { Address } from '../types/index.js';
1
+ /**
2
+ * The provider-neutral port period close, webhook intake, and credit
3
+ * purchases talk to (#3060).
4
+ *
5
+ * Every amount crossing this port is **integer minor units** of the named
6
+ * currency, like the rest of commerce. Adapters (see
7
+ * {@link createStripeBillingProvider}) own the conversion to the provider's
8
+ * representation and every provider call; this package never calls a payment
9
+ * provider directly.
10
+ */
11
+ import type { SubscriptionStatus } from '@happyvertical/smrt-subscriptions';
12
+ import type { Address } from '../types/index.js';
3
13
  export interface BillingProviderCustomerInput {
4
14
  /** The local billing account id, recorded on the provider customer. */
5
15
  accountId: string;
@@ -1,20 +1,25 @@
1
- import { SmrtClassOptions } from '@happyvertical/smrt-core';
2
- import { DatabaseInterface } from '@happyvertical/smrt-core/migrations';
1
+ /**
2
+ * One seller's billing wiring (#3060): its payment provider, ledger accounts,
3
+ * billing-owner reader, and the collections period close and provider events
4
+ * write through.
5
+ */
6
+ import type { SmrtClassOptions } from '@happyvertical/smrt-core';
7
+ import type { DatabaseInterface } from '@happyvertical/smrt-core/migrations';
3
8
  import { JournalCollection } from '@happyvertical/smrt-ledgers';
4
- import { AutoTopUpHook, BillingAdjustmentCollection, BillingRelationshipReader, ClientChargeCollection, PriceBookCollection, RetailChargeCollection, SpendingPolicyCollection, SubscriptionPlanCollection, TenantSubscriptionCollection } from '@happyvertical/smrt-subscriptions';
9
+ import { type AutoTopUpHook, BillingAdjustmentCollection, type BillingRelationshipReader, ClientChargeCollection, PriceBookCollection, RetailChargeCollection, SpendingPolicyCollection, SubscriptionPlanCollection, TenantSubscriptionCollection } from '@happyvertical/smrt-subscriptions';
5
10
  import { CustomerCollection } from '../collections/CustomerCollection.js';
6
11
  import { InvoiceCollection } from '../collections/InvoiceCollection.js';
7
12
  import { InvoiceLineItemCollection } from '../collections/InvoiceLineItemCollection.js';
8
13
  import { PaymentInstrumentCollection } from '../collections/PaymentInstrumentCollection.js';
9
- import { BillingAccount, BillingAccountCollection, BillingCloseKind, BillingLineSourceCollection, BillingPeriodCloseCollection, BillingStanding } from '../models/billing.js';
10
- import { Invoice } from '../models/Invoice.js';
11
- import { Address } from '../types/index.js';
12
- import { CreateCardSetupCheckoutInput } from './cards.js';
13
- import { CreateCreditCheckoutInput } from './credits.js';
14
- import { ScheduledBillingPeriod } from './cycles.js';
15
- import { ClosePeriodInput, PeriodCloseResult } from './period-close.js';
16
- import { BillingProvider, BillingProviderCheckoutSession } from './provider.js';
17
- import { AutoTopUpFailureHook, AutoTopUpHookOptions } from './top-up.js';
14
+ import { type BillingAccount, BillingAccountCollection, type BillingCloseKind, BillingLineSourceCollection, BillingPeriodCloseCollection, type BillingStanding } from '../models/billing.js';
15
+ import type { Invoice } from '../models/Invoice.js';
16
+ import { type Address } from '../types/index.js';
17
+ import { type CreateCardSetupCheckoutInput } from './cards.js';
18
+ import { type CreateCreditCheckoutInput } from './credits.js';
19
+ import { type ScheduledBillingPeriod } from './cycles.js';
20
+ import { type ClosePeriodInput, type PeriodCloseResult } from './period-close.js';
21
+ import type { BillingProvider, BillingProviderCheckoutSession } from './provider.js';
22
+ import { type AutoTopUpFailureHook, type AutoTopUpHookOptions } from './top-up.js';
18
23
  /** Ledger accounts billing posts to, in the seller's books. */
19
24
  export interface BillingLedgerAccounts {
20
25
  /** Accounts receivable (debited when an invoice is issued). */
@@ -1,5 +1,14 @@
1
- import { StripeAccountingProvider, WebhookEvent } from '@happyvertical/accounting';
2
- import { BillingProvider, BillingProviderEvent } from './provider.js';
1
+ /**
2
+ * Stripe adapter for the {@link BillingProvider} port (#3060).
3
+ *
4
+ * Every provider call goes through `@happyvertical/accounting`'s Stripe
5
+ * provider; this module only maps between commerce's integer minor units and
6
+ * the SDK's major-unit contract, and normalizes verified webhook events. The
7
+ * SDK's `*Minor` fields (checkout prices, session totals, off-session charges)
8
+ * are already ISO minor units and pass through unconverted (#3139).
9
+ */
10
+ import type { StripeAccountingProvider, WebhookEvent } from '@happyvertical/accounting';
11
+ import { type BillingProvider, type BillingProviderEvent } from './provider.js';
3
12
  export interface StripeBillingProviderOptions {
4
13
  /** A Stripe provider from `getAccountingProvider({ type: 'stripe', … })`. */
5
14
  stripe: StripeAccountingProvider;
@@ -1,7 +1,7 @@
1
- import { DatabaseInterface } from '@happyvertical/smrt-core/migrations';
2
- import { AutoTopUpGrant, AutoTopUpHook, AutoTopUpRequest } from '@happyvertical/smrt-subscriptions';
3
- import { BillingChargeStatus } from './provider.js';
4
- import { BillingRuntime } from './runtime.js';
1
+ import type { DatabaseInterface } from '@happyvertical/smrt-core/migrations';
2
+ import { type AutoTopUpGrant, type AutoTopUpHook, type AutoTopUpRequest } from '@happyvertical/smrt-subscriptions';
3
+ import type { BillingChargeStatus } from './provider.js';
4
+ import type { BillingRuntime } from './runtime.js';
5
5
  /** Prefix of every auto top-up charge key (the provider idempotency key). */
6
6
  export declare const AUTO_TOP_UP_CHARGE_PREFIX = "smrt-auto-top-up:";
7
7
  /** `Payment.reference` of an auto top-up attempt: prefix + policy id. */
@@ -1,3 +1,7 @@
1
+ /**
2
+ * ContractCollection - Collection manager for Contract objects (STI)
3
+ * @packageDocumentation
4
+ */
1
5
  import { SmrtCollection } from '@happyvertical/smrt-core';
2
6
  import { Contract } from '../models/Contract.js';
3
7
  import { ContractStatus, ContractType } from '../types/index.js';
@@ -1,3 +1,7 @@
1
+ /**
2
+ * ContractLineItemCollection - Collection manager for ContractLineItem objects
3
+ * @packageDocumentation
4
+ */
1
5
  import { SmrtCollection } from '@happyvertical/smrt-core';
2
6
  import { ContractLineItem } from '../models/ContractLineItem.js';
3
7
  export declare class ContractLineItemCollection extends SmrtCollection<ContractLineItem> {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * CustomerCollection - Collection manager for Customer objects
3
+ * @packageDocumentation
4
+ */
1
5
  import { SmrtCollection } from '@happyvertical/smrt-core';
2
6
  import { Customer } from '../models/Customer.js';
3
7
  import { CustomerStatus } from '../types/index.js';
@@ -1,6 +1,10 @@
1
+ /**
2
+ * FulfillmentCollection - Collection manager for Fulfillment objects
3
+ * @packageDocumentation
4
+ */
1
5
  import { SmrtCollection } from '@happyvertical/smrt-core';
2
6
  import { Fulfillment } from '../models/Fulfillment.js';
3
- import { FulfillmentStatus, FulfillmentType } from '../types/index.js';
7
+ import { FulfillmentStatus, type FulfillmentType } from '../types/index.js';
4
8
  export declare class FulfillmentCollection extends SmrtCollection<Fulfillment> {
5
9
  static readonly _itemClass: typeof Fulfillment;
6
10
  /**
@@ -1,3 +1,7 @@
1
+ /**
2
+ * FulfillmentLineItemCollection - Collection manager for FulfillmentLineItem objects
3
+ * @packageDocumentation
4
+ */
1
5
  import { SmrtCollection } from '@happyvertical/smrt-core';
2
6
  import { FulfillmentLineItem } from '../models/FulfillmentLineItem.js';
3
7
  export declare class FulfillmentLineItemCollection extends SmrtCollection<FulfillmentLineItem> {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * InvoiceCollection - Collection manager for Invoice objects
3
+ * @packageDocumentation
4
+ */
1
5
  import { SmrtCollection } from '@happyvertical/smrt-core';
2
6
  import { Invoice } from '../models/Invoice.js';
3
7
  import { InvoiceStatus } from '../types/index.js';
@@ -1,6 +1,10 @@
1
+ /**
2
+ * InvoiceLineItemCollection - Collection manager for InvoiceLineItem objects
3
+ * @packageDocumentation
4
+ */
1
5
  import { SmrtCollection } from '@happyvertical/smrt-core';
2
6
  import { InvoiceLineItem } from '../models/InvoiceLineItem.js';
3
- import { AccountingLineItemInput } from '../types/index.js';
7
+ import type { AccountingLineItemInput } from '../types/index.js';
4
8
  export declare class InvoiceLineItemCollection extends SmrtCollection<InvoiceLineItem> {
5
9
  static readonly _itemClass: typeof InvoiceLineItem;
6
10
  /**
@@ -1,3 +1,7 @@
1
+ /**
2
+ * PaymentAllocationCollection - Collection manager for PaymentAllocation objects
3
+ * @packageDocumentation
4
+ */
1
5
  import { SmrtCollection } from '@happyvertical/smrt-core';
2
6
  import { PaymentAllocation } from '../models/PaymentAllocation.js';
3
7
  export declare class PaymentAllocationCollection extends SmrtCollection<PaymentAllocation> {
@@ -1,6 +1,10 @@
1
+ /**
2
+ * PaymentCollection - Collection manager for Payment objects
3
+ * @packageDocumentation
4
+ */
1
5
  import { SmrtCollection } from '@happyvertical/smrt-core';
2
6
  import { Payment } from '../models/Payment.js';
3
- import { PaymentMethod, PaymentStatus } from '../types/index.js';
7
+ import { type PaymentMethod, PaymentStatus } from '../types/index.js';
4
8
  export declare class PaymentCollection extends SmrtCollection<Payment> {
5
9
  static readonly _itemClass: typeof Payment;
6
10
  /**
@@ -1,3 +1,7 @@
1
+ /**
2
+ * PaymentInstrumentCollection - Collection manager for PaymentInstrument objects
3
+ * @packageDocumentation
4
+ */
1
5
  import { SmrtCollection } from '@happyvertical/smrt-core';
2
6
  import { PaymentInstrument } from '../models/PaymentInstrument.js';
3
7
  export declare class PaymentInstrumentCollection extends SmrtCollection<PaymentInstrument> {
@@ -1,6 +1,17 @@
1
+ /**
2
+ * PaymentIntentCollection — collection manager for {@link PaymentIntent}.
3
+ *
4
+ * Adds helpers for the common query shapes (find by idempotency key,
5
+ * find still-open intents, find by licensee email, find expired) and a
6
+ * `getOrCreateByIdempotencyKey` helper that callers use to implement
7
+ * safe at-least-once retries from the marketplace's PaymentIntent
8
+ * issuance handler.
9
+ *
10
+ * @packageDocumentation
11
+ */
1
12
  import { SmrtCollection } from '@happyvertical/smrt-core';
2
13
  import { PaymentIntent } from '../models/PaymentIntent.js';
3
- import { PaymentIntentStatus, PaymentOption } from '../types/index.js';
14
+ import { PaymentIntentStatus, type PaymentOption } from '../types/index.js';
4
15
  export interface PaymentIntentIdempotencyArgs {
5
16
  /** Caller-supplied scope (Sku id / tier id / etc.) */
6
17
  offeringRef: string;
@@ -1,5 +1,16 @@
1
+ /**
2
+ * PayoutCollection — collection manager for {@link Payout} rows.
3
+ *
4
+ * Adds helpers for the common operator-side query shapes: payouts for
5
+ * a specific vendor, payouts derived from a specific source payment,
6
+ * status-bucketed lookups for the operator dashboard, and a
7
+ * `createFromPayment` convenience that wires up the source-payment
8
+ * link in one call.
9
+ *
10
+ * @packageDocumentation
11
+ */
1
12
  import { SmrtCollection } from '@happyvertical/smrt-core';
2
- import { Payment } from '../models/Payment.js';
13
+ import type { Payment } from '../models/Payment.js';
3
14
  import { Payout } from '../models/Payout.js';
4
15
  import { PayoutStatus } from '../types/index.js';
5
16
  export interface CreatePayoutFromPaymentArgs {