@happyvertical/smrt-commerce 0.53.0 → 0.53.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.
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-commerce",
5
- "packageVersion": "0.53.0",
5
+ "packageVersion": "0.53.2",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-commerce:ContractCollection": {
8
8
  "name": "contractcollection",
@@ -3,12 +3,12 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-commerce",
6
- "packageVersion": "0.53.0",
6
+ "packageVersion": "0.53.2",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "881bc58b7764bd37456e1bd32a18239d1ae6bacbdfd64c5acc328b7fac2f87b7",
11
- "packageJson": "e24ae90d30eb273a7b99f05f418de764a4e3316cf7a4f76721417ca3c281f2e4",
10
+ "manifest": "852201d595319ce948bf81df6053985bbf28aeb811b05ae393f838d068404242",
11
+ "packageJson": "2c2f47a3f4355bc345932475e17bc47c485e1ba3e899959123f480d761cd12d4",
12
12
  "agents": "bc41077ed3512b4e644bd2103261dcbe5be8c21127d670fb84e2ca47cb4f7254"
13
13
  },
14
14
  "exports": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-commerce",
3
- "version": "0.53.0",
3
+ "version": "0.53.2",
4
4
  "smrtJsdoc": "strict",
5
5
  "description": "Commerce models for the SMRT framework - contracts, fulfillments, payments",
6
6
  "type": "module",
@@ -52,13 +52,13 @@
52
52
  "dependencies": {
53
53
  "@happyvertical/accounting": "^0.98.0",
54
54
  "@happyvertical/payments": "^0.98.0",
55
- "@happyvertical/smrt-core": "0.53.0",
56
- "@happyvertical/smrt-jobs": "0.53.0",
57
- "@happyvertical/smrt-ledgers": "0.53.0",
58
- "@happyvertical/smrt-subscriptions": "0.53.0",
59
- "@happyvertical/smrt-tenancy": "0.53.0",
60
- "@happyvertical/smrt-types": "0.53.0",
61
- "@happyvertical/smrt-ui": "0.53.0"
55
+ "@happyvertical/smrt-core": "0.53.2",
56
+ "@happyvertical/smrt-jobs": "0.53.2",
57
+ "@happyvertical/smrt-ledgers": "0.53.2",
58
+ "@happyvertical/smrt-subscriptions": "0.53.2",
59
+ "@happyvertical/smrt-tenancy": "0.53.2",
60
+ "@happyvertical/smrt-types": "0.53.2",
61
+ "@happyvertical/smrt-ui": "0.53.2"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "svelte": "^5.57.0"
@@ -69,7 +69,7 @@
69
69
  }
70
70
  },
71
71
  "devDependencies": {
72
- "@happyvertical/smrt-vitest": "0.53.0",
72
+ "@happyvertical/smrt-vitest": "0.53.2",
73
73
  "@sveltejs/package": "^2.5.8",
74
74
  "@sveltejs/vite-plugin-svelte": "^7.3.0",
75
75
  "@types/node": "24.13.6",
@@ -81,7 +81,7 @@
81
81
  "vitest": "4.1.10"
82
82
  },
83
83
  "scripts": {
84
- "build": "vite build --mode library && svelte-package -i src/svelte -o dist/svelte --tsconfig tsconfig.svelte.json",
84
+ "build": "vite build --mode library && svelte-package -i src/svelte -o dist/svelte --tsconfig tsconfig.svelte.json && node ../../scripts/prune-svelte-package-artifacts.js dist",
85
85
  "build:watch": "vite build --mode library --watch",
86
86
  "clean": "rm -rf dist",
87
87
  "dev": "npm run build:watch",
@@ -1,13 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,36 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,51 +0,0 @@
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
@@ -1 +0,0 @@
1
-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,CAAC;IAC9B,eAAe,EAAE,mBAAmB,EAAE,CAAC;IACvC,aAAa,EAAE,4BAA4B,CAAC;IAC5C,KAAK,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"}
@@ -1,13 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,69 +0,0 @@
1
- /**
2
- * A crypto payment rail world for #3138: the billing fixture's Stripe
3
- * issuing provider plus an in-memory `CryptoCheckoutGateway`, wired into one
4
- * seller runtime. Shared by the SQLite suite and the PostgreSQL lane.
5
- */
6
- import { type CreateCryptoCheckoutInput, type CryptoCheckout, type CryptoCheckoutException, type CryptoCheckoutGateway, type CryptoCheckoutPayment, type CryptoCheckoutStatus } from '@happyvertical/payments';
7
- import type { DatabaseInterface } from '@happyvertical/smrt-core/migrations';
8
- import type { BillingPaymentPolicy } from '../../billing/payment-attempts.js';
9
- import type { BillingProvider } from '../../billing/provider.js';
10
- import { type BillingLedgerAccounts, BillingRuntime } from '../../billing/runtime.js';
11
- import { type BillingWorld } from './billing-fixture.js';
12
- export declare const RAIL_METADATA_SECRET = "rail-metadata-secret";
13
- export declare const RAIL_SIGNATURE = "fake-rail-ok";
14
- interface FakeCheckout {
15
- id: string;
16
- orderId: string;
17
- amount: number;
18
- currency: string;
19
- metadata: Record<string, string>;
20
- status: CryptoCheckoutStatus;
21
- exception: CryptoCheckoutException;
22
- amountPaid: number;
23
- payments: CryptoCheckoutPayment[];
24
- owned: boolean;
25
- /** Settlement asset override (default BTC). */
26
- asset?: string;
27
- }
28
- /** An in-memory gateway: tests move checkouts through their states. */
29
- export declare class FakeCryptoGateway implements CryptoCheckoutGateway {
30
- readonly id = "btcpay";
31
- readonly checkouts: Map<string, FakeCheckout>;
32
- created: number;
33
- private counter;
34
- createCheckout(input: CreateCryptoCheckoutInput): Promise<CryptoCheckout>;
35
- getCheckout(checkoutId: string): Promise<CryptoCheckout>;
36
- listCheckouts(input: {
37
- orderId: string;
38
- }): Promise<CryptoCheckout[]>;
39
- verifyWebhook(rawBody: string, headers: Headers | Record<string, string | undefined>): {
40
- eventId: string;
41
- checkoutId: string | null;
42
- type: string;
43
- redelivery: boolean;
44
- };
45
- /** Move a checkout: `paid` is fiat minor units received. */
46
- set(checkoutId: string, status: CryptoCheckoutStatus, options?: {
47
- exception?: CryptoCheckoutException;
48
- paid?: number;
49
- paymentStatus?: CryptoCheckoutPayment['status'];
50
- }): void;
51
- private view;
52
- }
53
- export interface RailWorld extends BillingWorld {
54
- gateway: FakeCryptoGateway;
55
- rail: BillingProvider;
56
- runtime: BillingRuntime;
57
- railLedger: BillingLedgerAccounts;
58
- /** Provider invoice ids closed as paid out of band. */
59
- outOfBand: string[];
60
- /** Deliver a signed rail webhook for a checkout and process events. */
61
- railEvent(checkoutId: string, eventId?: string): Promise<void>;
62
- }
63
- export declare function createRailWorld(db: DatabaseInterface, options?: {
64
- paymentPolicy?: Partial<BillingPaymentPolicy>;
65
- /** Give Stripe the out-of-band method (default true). */
66
- outOfBand?: boolean;
67
- }): Promise<RailWorld>;
68
- export {};
69
- //# sourceMappingURL=crypto-rail.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto-rail.d.ts","sourceRoot":"","sources":["../../../src/__tests__/helpers/crypto-rail.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAE1B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAE1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAI7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,KAAK,EACV,eAAe,EAEhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,KAAK,qBAAqB,EAC1B,cAAc,EACf,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,KAAK,YAAY,EAGlB,MAAM,sBAAsB,CAAC;AAG9B,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAC3D,eAAO,MAAM,cAAc,iBAAiB,CAAC;AAG7C,UAAU,YAAY;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAA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,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,EAAE,qBAAqB,CAAC;IAClC,uDAAuD;IACvD,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,uEAAuE;IACvE,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChE;AAID,wBAAsB,eAAe,CACnC,EAAE,EAAE,iBAAiB,EACrB,OAAO,GAAE;IACP,aAAa,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC9C,yDAAyD;IACzD,SAAS,CAAC,EAAE,OAAO,CAAC;CAChB,GACL,OAAO,CAAC,SAAS,CAAC,CAmFpB"}
@@ -1,158 +0,0 @@
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
- tax_code?: string;
23
- }
24
- interface FakeInvoice {
25
- id: string;
26
- customer: string;
27
- currency: string;
28
- status: 'draft' | 'open' | 'paid' | 'void' | 'uncollectible';
29
- collection_method: 'send_invoice' | 'charge_automatically';
30
- auto_advance: boolean;
31
- finalized: number;
32
- due_date: number | null;
33
- created: number;
34
- automatic_tax: boolean;
35
- items: string[];
36
- subtotal: number;
37
- tax: number;
38
- total: number;
39
- amount_paid: number;
40
- amount_remaining: number;
41
- metadata: Record<string, string>;
42
- sent: number;
43
- paid_out_of_band?: boolean;
44
- }
45
- interface FakeSession {
46
- id: string;
47
- url: string;
48
- mode: string;
49
- currency: string | null;
50
- amount_subtotal: number | null;
51
- amount_tax: number;
52
- amount_total: number | null;
53
- customer: string | null;
54
- status: 'open' | 'complete' | 'expired';
55
- payment_status: 'paid' | 'unpaid' | 'no_payment_required';
56
- automatic_tax: boolean;
57
- customer_update_address: boolean;
58
- billing_address_collection: string | null;
59
- setup_future_usage: string | null;
60
- payment_method: string | null;
61
- metadata: Record<string, string>;
62
- tax_code: string | null;
63
- }
64
- /** A Stripe Tax calculation for an off-session charge (#3194). */
65
- interface FakeTaxCalculation {
66
- id: string;
67
- customer: string;
68
- amount_total: number;
69
- tax_amount_exclusive: number;
70
- tax_code: string | null;
71
- }
72
- /** How a saved payment method answers an off-session charge. */
73
- export type FakeCardBehavior = 'succeed' | 'processing' | 'decline' | 'authentication_required';
74
- interface FakePaymentIntent {
75
- id: string;
76
- object: 'payment_intent';
77
- created: number;
78
- amount: number;
79
- currency: string;
80
- customer: string;
81
- payment_method: string;
82
- status: string;
83
- last_payment_error: Record<string, string> | null;
84
- metadata: Record<string, string>;
85
- }
86
- export declare class FakeStripe {
87
- readonly customers: Map<string, FakeCustomer>;
88
- readonly invoiceItems: Map<string, FakeInvoiceItem>;
89
- readonly invoices: Map<string, FakeInvoice>;
90
- readonly sessions: Map<string, FakeSession>;
91
- readonly paymentIntents: Map<string, FakePaymentIntent>;
92
- readonly taxCalculations: Map<string, FakeTaxCalculation>;
93
- /** False while Stripe's search index lags behind writes. */
94
- searchable: boolean;
95
- /** Behavior of each saved payment method (default `succeed`). */
96
- readonly cards: Map<string, FakeCardBehavior>;
97
- readonly subscriptions: Map<string, Record<string, unknown>>;
98
- readonly requests: Array<{
99
- method: string;
100
- path: string;
101
- key?: string;
102
- }>;
103
- private readonly idempotent;
104
- private failures;
105
- private counter;
106
- private nextId;
107
- /** Make the next matching request(s) fail. */
108
- fail(method: string, path: RegExp, when?: 'before' | 'after', times?: number): void;
109
- provider(): Promise<StripeAccountingProvider>;
110
- readonly fetch: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
111
- private route;
112
- private applyCustomer;
113
- private recalculate;
114
- private customerView;
115
- private sessionView;
116
- private view;
117
- /** Customer pays an open invoice in full. */
118
- pay(invoiceId: string): void;
119
- /**
120
- * Stripe's automatic collection of a finalized `charge_automatically`
121
- * invoice: charges the customer's default card. Returns the outcome.
122
- */
123
- collect(invoiceId: string): 'paid' | 'failed';
124
- /**
125
- * The customer finishes a checkout: a payment session is paid with tax
126
- * from the collected (or customer) address; a setup session saves
127
- * `paymentMethod`. A collected address is saved to the customer when the
128
- * session asked to.
129
- */
130
- completeSession(sessionId: string, options?: {
131
- paymentMethod?: string;
132
- address?: Record<string, string>;
133
- }): FakeSession;
134
- private createPaymentIntent;
135
- /** A processing PaymentIntent settles (Stripe then sends its event). */
136
- settlePaymentIntent(intentId: string, status: 'succeeded' | 'failed'): FakePaymentIntent;
137
- setInvoiceStatus(invoiceId: string, status: FakeInvoice['status']): void;
138
- lineItemsOf(invoiceId: string): FakeInvoiceItem[];
139
- }
140
- /** A signed Stripe webhook delivery for `event`. */
141
- export declare function signedEvent(event: Record<string, unknown>): {
142
- payload: string;
143
- signature: string;
144
- };
145
- export declare function invoiceEvent(type: string, invoiceId: string): Record<string, unknown>;
146
- export declare function checkoutEvent(session: {
147
- id: string;
148
- mode?: string;
149
- currency: string | null;
150
- amount_subtotal: number | null;
151
- amount_total?: number | null;
152
- metadata: Record<string, string>;
153
- }, paymentStatus?: string, type?: string): Record<string, unknown>;
154
- /** A `payment_intent.*` event for a PaymentIntent the fake holds. */
155
- export declare function paymentIntentEvent(type: string, intent: Record<string, unknown>): Record<string, unknown>;
156
- export declare function subscriptionEvent(type: string, subscriptionId: string): Record<string, unknown>;
157
- export {};
158
- //# sourceMappingURL=fake-stripe.d.ts.map
@@ -1 +0,0 @@
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,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