@happyvertical/smrt-commerce 0.51.32 → 0.51.34

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 (79) hide show
  1. package/AGENTS.md +17 -0
  2. package/README.md +88 -0
  3. package/dist/__tests__/foreign-key-fixtures.d.ts +13 -0
  4. package/dist/__tests__/foreign-key-fixtures.d.ts.map +1 -0
  5. package/dist/__tests__/helpers/anchor-fixture.d.ts +36 -0
  6. package/dist/__tests__/helpers/anchor-fixture.d.ts.map +1 -0
  7. package/dist/__tests__/helpers/billing-fixture.d.ts +51 -0
  8. package/dist/__tests__/helpers/billing-fixture.d.ts.map +1 -0
  9. package/dist/__tests__/helpers/consumer-license-sale.d.ts +13 -0
  10. package/dist/__tests__/helpers/consumer-license-sale.d.ts.map +1 -0
  11. package/dist/__tests__/helpers/crypto-rail.d.ts +69 -0
  12. package/dist/__tests__/helpers/crypto-rail.d.ts.map +1 -0
  13. package/dist/__tests__/helpers/fake-stripe.d.ts +147 -0
  14. package/dist/__tests__/helpers/fake-stripe.d.ts.map +1 -0
  15. package/dist/billing/btcpay.d.ts +40 -0
  16. package/dist/billing/btcpay.d.ts.map +1 -0
  17. package/dist/billing/cards.d.ts +14 -4
  18. package/dist/billing/credits.d.ts +7 -2
  19. package/dist/billing/credits.d.ts.map +1 -1
  20. package/dist/billing/crypto.d.ts +32 -0
  21. package/dist/billing/crypto.d.ts.map +1 -0
  22. package/dist/billing/cycles.d.ts +21 -1
  23. package/dist/billing/events.d.ts +23 -4
  24. package/dist/billing/events.d.ts.map +1 -1
  25. package/dist/billing/index.d.ts +5 -1
  26. package/dist/billing/index.d.ts.map +1 -1
  27. package/dist/billing/invoice-payments.d.ts +29 -0
  28. package/dist/billing/invoice-payments.d.ts.map +1 -0
  29. package/dist/billing/jobs.d.ts +3 -3
  30. package/dist/billing/payment-attempts.d.ts +143 -0
  31. package/dist/billing/payment-attempts.d.ts.map +1 -0
  32. package/dist/billing/period-close.d.ts +1 -1
  33. package/dist/billing/provider.d.ts +109 -3
  34. package/dist/billing/provider.d.ts.map +1 -1
  35. package/dist/billing/runtime.d.ts +122 -14
  36. package/dist/billing/runtime.d.ts.map +1 -1
  37. package/dist/billing/stripe.d.ts +16 -2
  38. package/dist/billing/stripe.d.ts.map +1 -1
  39. package/dist/billing/top-up.d.ts +4 -4
  40. package/dist/collections/ContractCollection.d.ts +4 -0
  41. package/dist/collections/ContractLineItemCollection.d.ts +4 -0
  42. package/dist/collections/CustomerCollection.d.ts +4 -0
  43. package/dist/collections/FulfillmentCollection.d.ts +5 -1
  44. package/dist/collections/FulfillmentLineItemCollection.d.ts +4 -0
  45. package/dist/collections/InvoiceCollection.d.ts +4 -0
  46. package/dist/collections/InvoiceLineItemCollection.d.ts +5 -1
  47. package/dist/collections/PaymentAllocationCollection.d.ts +4 -0
  48. package/dist/collections/PaymentCollection.d.ts +5 -1
  49. package/dist/collections/PaymentInstrumentCollection.d.ts +4 -0
  50. package/dist/collections/PaymentIntentCollection.d.ts +12 -1
  51. package/dist/collections/PayoutCollection.d.ts +12 -1
  52. package/dist/collections/VendorCollection.d.ts +4 -0
  53. package/dist/index.d.ts +64 -1
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +4055 -2859
  56. package/dist/index.js.map +1 -1
  57. package/dist/manifest.json +920 -91
  58. package/dist/migrations/moneyMinorUnits.d.ts +61 -1
  59. package/dist/models/Contract.d.ts +6 -2
  60. package/dist/models/ContractLineItem.d.ts +5 -1
  61. package/dist/models/Customer.d.ts +5 -1
  62. package/dist/models/Fulfillment.d.ts +5 -1
  63. package/dist/models/FulfillmentLineItem.d.ts +5 -1
  64. package/dist/models/Invoice.d.ts +6 -2
  65. package/dist/models/InvoiceLineItem.d.ts +5 -1
  66. package/dist/models/Payment.d.ts +6 -2
  67. package/dist/models/PaymentAllocation.d.ts +5 -1
  68. package/dist/models/PaymentInstrument.d.ts +5 -1
  69. package/dist/models/PaymentIntent.d.ts +24 -1
  70. package/dist/models/Payout.d.ts +24 -1
  71. package/dist/models/Vendor.d.ts +5 -1
  72. package/dist/models/billing.d.ts +111 -1
  73. package/dist/models/billing.d.ts.map +1 -1
  74. package/dist/models/index.d.ts +1 -1
  75. package/dist/models/index.d.ts.map +1 -1
  76. package/dist/smrt-knowledge.json +320 -9
  77. package/dist/types/index.d.ts +5 -1
  78. package/dist/ui.d.ts +14 -1
  79. package/package.json +11 -10
@@ -1,20 +1,27 @@
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, type BillingPaymentAttempt, BillingPaymentAttemptCollection, type BillingPaymentAttemptPurpose, 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 CreateInvoicePaymentInput } from './invoice-payments.js';
21
+ import { type BillingPaymentPolicy, type CryptoConversionInput, type ManualRefundInput, type ManualRefundResult } from './payment-attempts.js';
22
+ import { type ClosePeriodInput, type PeriodCloseResult } from './period-close.js';
23
+ import { type BillingProvider, type BillingProviderCheckoutSession } from './provider.js';
24
+ import { type AutoTopUpFailureHook, type AutoTopUpHookOptions } from './top-up.js';
18
25
  /** Ledger accounts billing posts to, in the seller's books. */
19
26
  export interface BillingLedgerAccounts {
20
27
  /** Accounts receivable (debited when an invoice is issued). */
@@ -27,6 +34,15 @@ export interface BillingLedgerAccounts {
27
34
  cashAccountId: string;
28
35
  /** Liability credited when prepaid credit is purchased. */
29
36
  prepaidCreditAccountId: string;
37
+ /**
38
+ * Asset debited when a crypto rail payment settles and the seller holds
39
+ * the crypto (#3138). Defaults to `cashAccountId`.
40
+ */
41
+ cryptoHoldingsAccountId?: string;
42
+ /** Realized gain or loss when held crypto is converted (#3138). */
43
+ fxGainLossAccountId?: string;
44
+ /** Conversion and network fees (#3138). */
45
+ feesAccountId?: string;
30
46
  }
31
47
  /** A payer's standing changed after a provider invoice event. */
32
48
  export interface PayerStandingChange {
@@ -52,7 +68,16 @@ export interface BillingRuntimeOptions extends SmrtClassOptions {
52
68
  /** The tenant that issues invoices. */
53
69
  sellerTenantId: string;
54
70
  kind: BillingCloseKind;
71
+ /** The issuing provider: it issues, taxes, and sends invoices. */
55
72
  provider: BillingProvider;
73
+ /**
74
+ * Additional payment rails (#3138), for example a crypto checkout
75
+ * provider. A payer picks a rail per payment; each rail has its own inbox
76
+ * namespace and webhook route. Names must be unique across all providers.
77
+ */
78
+ paymentProviders?: BillingProvider[];
79
+ /** Per-seller rules for rail payments (#3138). */
80
+ paymentPolicy?: Partial<BillingPaymentPolicy>;
56
81
  /** smrt-tenancy's `BillingRelationshipService` (read access required). */
57
82
  billingRelationships: BillingRelationshipReader;
58
83
  ledger: BillingLedgerAccounts;
@@ -156,10 +181,29 @@ export declare class BillingRuntime {
156
181
  readonly pageSize: number;
157
182
  readonly autoChargeInvoices: boolean;
158
183
  readonly onAutoTopUpFailed?: AutoTopUpFailureHook;
159
- /** The inbox provider namespace for this runtime's events (per seller). */
184
+ /** The inbox provider namespace for the issuing provider's events. */
160
185
  readonly eventProvider: string;
186
+ /** Per-seller rules for rail payments (#3138). */
187
+ readonly paymentPolicy: BillingPaymentPolicy;
188
+ private readonly providersByName;
189
+ readonly attempts: BillingPaymentAttemptCollection;
161
190
  private constructor();
162
191
  static create(options: BillingRuntimeOptions): Promise<BillingRuntime>;
192
+ /** A provider by name; the issuing provider when `name` is omitted. */
193
+ providerFor(name?: string): BillingProvider;
194
+ /**
195
+ * Whether any payment rail is configured (#3138). A runtime without one
196
+ * never touches payment attempts, so it needs no attempt table.
197
+ */
198
+ get hasPaymentRails(): boolean;
199
+ /** Every provider of this runtime: the issuing one first. */
200
+ get providers(): BillingProvider[];
201
+ /** A provider's inbox namespace (per provider, per seller). */
202
+ eventProviderFor(name?: string): string;
203
+ /** Every inbox namespace this runtime claims events from. */
204
+ get eventProviders(): string[];
205
+ /** The provider whose inbox namespace this is, or null. */
206
+ providerForNamespace(namespace: string): BillingProvider | null;
163
207
  getAccount(payerTenantId: string): Promise<BillingAccount | null>;
164
208
  private accountId;
165
209
  /**
@@ -205,7 +249,12 @@ export declare class BillingRuntime {
205
249
  * paid checkout that claims to be a credit purchase but failed
206
250
  * verification, for example after a webhook-secret rotation).
207
251
  */
208
- acceptWebhook(payload: string, signature: string): Promise<{
252
+ acceptWebhook(payload: string, signature: string, options?: {
253
+ /** The rail whose webhook this is (default the issuing provider). */
254
+ provider?: string;
255
+ /** Request headers, for rails that sign with their own header. */
256
+ headers?: Headers | Record<string, string | undefined>;
257
+ }): Promise<{
209
258
  accepted: boolean;
210
259
  eventId: string;
211
260
  kind: string;
@@ -242,6 +291,65 @@ export declare class BillingRuntime {
242
291
  * Call only from trusted operator code. Throws when the provider cannot.
243
292
  */
244
293
  markInvoiceUncollectible(invoiceId: string): Promise<void>;
294
+ /**
295
+ * Pay an issued invoice on a payment rail: opens a rail checkout for the
296
+ * amount due. Settlement records the payment and closes the issuing
297
+ * provider's invoice as paid out of band. Callable by the payer or from a
298
+ * system context.
299
+ */
300
+ createInvoicePayment(input: CreateInvoicePaymentInput): Promise<BillingProviderCheckoutSession>;
301
+ /** Record a rail checkout just opened (idempotent). */
302
+ recordPaymentAttemptStart(input: {
303
+ /** The rail order id (the checkout idempotency key), when known. */
304
+ orderId?: string;
305
+ provider: string;
306
+ checkoutId: string;
307
+ checkoutUrl: string;
308
+ purpose: BillingPaymentAttemptPurpose;
309
+ payerTenantId: string;
310
+ billingAccountId: string;
311
+ invoiceId?: string;
312
+ spendingPolicyId?: string;
313
+ amount: number;
314
+ currency: string;
315
+ }): Promise<BillingPaymentAttempt>;
316
+ /** The deterministic id of a rail checkout's attempt row. */
317
+ paymentAttemptId(provider: string, checkoutId: string): Promise<string>;
318
+ /**
319
+ * This seller's rail payment attempts, newest first — for "payment
320
+ * confirming" displays and operator queues.
321
+ */
322
+ listPaymentAttempts(filter?: {
323
+ payerTenantId?: string;
324
+ invoiceId?: string;
325
+ status?: string;
326
+ flagged?: boolean;
327
+ limit?: number;
328
+ }): Promise<BillingPaymentAttempt[]>;
329
+ /**
330
+ * Queue a re-read of open and confirming attempts (the polling fallback
331
+ * for missed webhooks). Returns how many were queued; apply them with
332
+ * `processEvents()`.
333
+ */
334
+ refreshPaymentAttempts(limit?: number): Promise<number>;
335
+ /** Queue a re-read of one rail checkout; false if one is already queued. */
336
+ refreshPaymentAttempt(provider: string, checkoutId: string): Promise<boolean>;
337
+ /** Close an attempt's flag with an operator note (the flag is kept). */
338
+ resolvePaymentAttempt(attemptId: string, resolution: string): Promise<BillingPaymentAttempt>;
339
+ /**
340
+ * Record a refund an operator made outside billing (no provider call):
341
+ * posts a reversing journal and, for a credit purchase, removes the
342
+ * credit. Idempotent by `reference`.
343
+ */
344
+ recordManualRefund(input: ManualRefundInput): Promise<ManualRefundResult>;
345
+ /**
346
+ * Record converting held crypto to fiat: cash and fees against the
347
+ * holdings' carrying value, with the difference to FX gain/loss.
348
+ * Idempotent by `reference`.
349
+ */
350
+ recordCryptoConversion(input: CryptoConversionInput): Promise<{
351
+ journalId: string;
352
+ }>;
245
353
  /** Run in a system context (cross-tenant reads and payer-owned writes). */
246
354
  system<T>(operation: () => Promise<T>): Promise<T>;
247
355
  }
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/billing/runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAE7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,KAAK,aAAa,EAClB,2BAA2B,EAC3B,KAAK,yBAAyB,EAC9B,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,EACxB,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,mCAA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,CAAC;IAkBjC;;;;OAIG;IACH,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAIzE;;;;OAIG;IACH,sBAAsB,CACpB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAIjC,2EAA2E;IAC3E,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAGnD"}
@@ -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;
@@ -9,4 +18,9 @@ export interface StripeBillingProviderOptions {
9
18
  export declare function createStripeBillingProvider(options: StripeBillingProviderOptions): BillingProvider;
10
19
  /** Normalize a verified, parsed Stripe event. Exported for tests. */
11
20
  export declare function normalizeStripeEvent(event: WebhookEvent, webhookSecret: string): Promise<BillingProviderEvent>;
21
+ /** Metadata key holding the `smrt_*` HMAC (shared with crypto rails, #3138). */
22
+ export declare const SIGNATURE_KEY = "smrt_sig";
23
+ export declare function signMetadata(metadata: Record<string, string>, secret: string): Promise<Record<string, string>>;
24
+ export declare function metadataSignatureValid(metadata: Record<string, string>, secret: string): Promise<boolean>;
25
+ export declare function smrtMetadata(value: unknown): Record<string, string>;
12
26
  //# sourceMappingURL=stripe.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stripe.d.ts","sourceRoot":"","sources":["../../src/billing/stripe.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EACV,wBAAwB,EAExB,YAAY,EACb,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAGL,KAAK,eAAe,EAOpB,KAAK,oBAAoB,EAO1B,MAAM,eAAe,CAAC;AAQvB,MAAM,WAAW,4BAA4B;IAC3C,6EAA6E;IAC7E,MAAM,EAAE,wBAAwB,CAAC;IACjC,mDAAmD;IACnD,aAAa,EAAE,MAAM,CAAC;CACvB;AAsED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,4BAA4B,GACpC,eAAe,CA0SjB;AAED,qEAAqE;AACrE,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,YAAY,EACnB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,oBAAoB,CAAC,CAuG/B"}
1
+ {"version":3,"file":"stripe.d.ts","sourceRoot":"","sources":["../../src/billing/stripe.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EACV,wBAAwB,EAExB,YAAY,EACb,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAGL,KAAK,eAAe,EAOpB,KAAK,oBAAoB,EAO1B,MAAM,eAAe,CAAC;AAQvB,MAAM,WAAW,4BAA4B;IAC3C,6EAA6E;IAC7E,MAAM,EAAE,wBAAwB,CAAC;IACjC,mDAAmD;IACnD,aAAa,EAAE,MAAM,CAAC;CACvB;AAsED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,4BAA4B,GACpC,eAAe,CA4TjB;AAED,qEAAqE;AACrE,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,YAAY,EACnB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,oBAAoB,CAAC,CAuG/B;AAUD,gFAAgF;AAChF,eAAO,MAAM,aAAa,aAAa,CAAC;AA6BxC,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAQjC;AAED,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC,CAalB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASnE"}
@@ -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 {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * VendorCollection - Collection manager for Vendor objects
3
+ * @packageDocumentation
4
+ */
1
5
  import { SmrtCollection } from '@happyvertical/smrt-core';
2
6
  import { Vendor } from '../models/Vendor.js';
3
7
  import { VendorStatus } from '../types/index.js';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,70 @@
1
+ /**
2
+ * @happyvertical/smrt-commerce
3
+ *
4
+ * Commerce models for the SMRT framework - contracts, fulfillments, payments.
5
+ *
6
+ * Key concepts:
7
+ * - Customer/Vendor link to Profile (from smrt-profiles)
8
+ * - Contract uses STI for different types (Estimate, Order, Lease, etc.)
9
+ * - Payment integrates with smrt-ledgers for journal entries
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import {
14
+ * Customer,
15
+ * CustomerCollection,
16
+ * Order,
17
+ * ContractCollection,
18
+ * Payment,
19
+ * PaymentCollection,
20
+ * } from '@happyvertical/smrt-commerce';
21
+ *
22
+ * // Create collections
23
+ * const customers = await CustomerCollection.create({
24
+ * persistence: { type: 'sql', url: 'commerce.db' }
25
+ * });
26
+ *
27
+ * // Create a customer linked to a profile
28
+ * // Every money value is integer minor units — $100.00 is 10000 (#2401).
29
+ * const customer = await customers.create({
30
+ * profileId: 'profile-uuid',
31
+ * creditLimit: 1000000, // $10,000.00
32
+ * paymentTerms: 'Net 30'
33
+ * });
34
+ * await customer.save();
35
+ *
36
+ * // Create an order
37
+ * const contracts = await ContractCollection.create(customer.options);
38
+ * const order = await contracts.create({
39
+ * _meta_type: 'Order',
40
+ * customerId: customer.id,
41
+ * totalAmount: 150000 // $1,500.00
42
+ * });
43
+ * await order.save();
44
+ *
45
+ * // Record payment with ledger integration
46
+ * const payments = await PaymentCollection.create(order.options);
47
+ * const payment = await payments.create({
48
+ * contractId: order.id,
49
+ * customerId: customer.id,
50
+ * amount: 150000
51
+ * });
52
+ * await payment.save();
53
+ *
54
+ * await payment.recordPayment({
55
+ * ledgerId: ledger.id,
56
+ * receivablesAccountId: arAccount.id,
57
+ * cashAccountId: bankAccount.id
58
+ * });
59
+ * ```
60
+ *
61
+ * @packageDocumentation
62
+ */
63
+ import './__smrt-register__.js';
1
64
  export * from './billing/index.js';
2
65
  export { ContractCollection, ContractLineItemCollection, type CreatePayoutFromPaymentArgs, CustomerCollection, FulfillmentCollection, FulfillmentLineItemCollection, InvoiceCollection, InvoiceLineItemCollection, type InvoiceNumberOptions, PaymentAllocationCollection, PaymentCollection, PaymentInstrumentCollection, PaymentIntentCollection, type PaymentIntentIdempotencyArgs, type PaymentIntentSeed, PayoutCollection, UNPAID_STATUSES, VendorCollection, } from './collections/index.js';
3
66
  export { COMMERCE_MONEY_COLUMNS, COMMERCE_MONEY_MINOR_UNITS_BACKFILL, COMMERCE_NATIVE_UNIT_COLUMNS, migrateCommerceMoneyToMinorUnits, preflightCommerceMoneyMinorUnits, } from './migrations/moneyMinorUnits.js';
4
- export { Agreement, BillingAccount, type BillingCloseKind, BillingLineSource, type BillingLineSourceType, BillingPeriodClose, type BillingPeriodCloseStatus, type BillingStanding, Cart, Contract, ContractLineItem, Customer, Estimate, Fulfillment, FulfillmentLineItem, Invoice, InvoiceLineItem, Lease, type LicenseRightsSnapshot, LicenseSale, Order, Payment, PaymentAllocation, PaymentInstrument, PaymentIntent, Payout, ProductionOrder, PurchaseOrder, Vendor, WholesaleOrder, } from './models/index.js';
67
+ export { Agreement, BillingAccount, type BillingCloseKind, BillingLineSource, type BillingLineSourceType, BillingPaymentAttempt, type BillingPaymentAttemptFlag, type BillingPaymentAttemptPurpose, type BillingPaymentAttemptTransition, BillingPeriodClose, type BillingPeriodCloseStatus, type BillingStanding, Cart, Contract, ContractLineItem, Customer, Estimate, Fulfillment, FulfillmentLineItem, Invoice, InvoiceLineItem, Lease, type LicenseRightsSnapshot, LicenseSale, Order, Payment, PaymentAllocation, PaymentInstrument, PaymentIntent, Payout, ProductionOrder, PurchaseOrder, Vendor, WholesaleOrder, } from './models/index.js';
5
68
  export { assertIntegerMinorUnits } from './money.js';
6
69
  export { type Address, ContractStatus, ContractType, CustomerStatus, CustomerType, FulfillmentStatus, FulfillmentType, InvoiceStatus, PaymentInstrumentStatus, PaymentIntentStatus, PaymentMethod, type PaymentOption, PaymentStatus, PayoutStatus, type RecognizeRevenueOptions, type RecordPaymentOptions, VendorStatus, } from './types/index.js';
7
70
  export { COMMERCE_MODULE_META, COMMERCE_UI_SLOTS } from './ui.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAKH,OAAO,wBAAwB,CAAC;AAGhC,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,2BAA2B,EAChC,kBAAkB,EAClB,qBAAqB,EACrB,6BAA6B,EAC7B,iBAAiB,EACjB,yBAAyB,EACzB,KAAK,oBAAoB,EACzB,2BAA2B,EAC3B,iB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