@whooshbang/contract-mock 2.0.0-rc.6 → 2.0.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/billing.d.ts +35 -29
- package/dist/billing.js +430 -362
- package/dist/billing.js.map +1 -1
- package/dist/core.js +84 -26
- package/dist/core.js.map +1 -1
- package/dist/recipient-copy-defaults.d.ts +111 -111
- package/dist/recipient-copy-defaults.js +111 -111
- package/dist/recipient-copy-defaults.js.map +1 -1
- package/dist/types.d.ts +10 -7
- package/package.json +3 -3
- package/scenarios/v1/manifest.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,18 @@ recorded here.
|
|
|
5
5
|
|
|
6
6
|
## Unreleased
|
|
7
7
|
|
|
8
|
+
## 2.0.0-rc.8
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Deterministic service-notice email enrollment (FXO-3033), subscription changes without unused-time credits (FXO-2988) and updated subscriber copy (FXO-3000), through the rc.8 contract.
|
|
13
|
+
|
|
14
|
+
## 2.0.0-rc.7
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Deterministic in-app card, credit purchase, receipt address, invoice history and Team and Agency subscription-change scenarios through the rc.7 contract, including undoing a scheduled change (FXO-2941).
|
|
19
|
+
|
|
8
20
|
## 2.0.0-rc.6
|
|
9
21
|
|
|
10
22
|
### Added
|
package/dist/billing.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type { AutoTopUpSettings, UpdateAutoTopUpSettingsRequest,
|
|
1
|
+
import type { AutoTopUpSettings, UpdateAutoTopUpSettingsRequest, BillingAccount, BillingEntitlements, BillingInvoiceCollection, BillingProjectSlots, CardSetup, ContractValidator, CreditPurchase, Problem, ProblemCode, Project, ProjectAttribution, SubscriptionChange, SubscriptionSelection } from "@whooshbang/contracts";
|
|
2
2
|
import type { Hono } from "hono";
|
|
3
3
|
import type { ContractMockBillingOptions, OrganizationScope } from "./types.js";
|
|
4
|
-
interface
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
interface ChangeState {
|
|
5
|
+
organizationId: string;
|
|
6
|
+
resource: SubscriptionChange;
|
|
7
|
+
selectedOffers: BillingEntitlements["offers"];
|
|
8
|
+
quotedAt: string;
|
|
9
|
+
purchases: {
|
|
10
|
+
kind: BillingEntitlements["offers"][number]["kind"];
|
|
11
|
+
quantity: number;
|
|
12
|
+
}[];
|
|
11
13
|
}
|
|
12
14
|
/** Local, isolated financial fixtures. All state resets with the mock. The
|
|
13
15
|
* production service independently verifies Stripe objects and signatures. */
|
|
@@ -15,18 +17,17 @@ export declare class MockBillingState {
|
|
|
15
17
|
private readonly options;
|
|
16
18
|
readonly cardSetups: Map<string, {
|
|
17
19
|
organizationId: string;
|
|
18
|
-
|
|
19
|
-
resource: AutoTopUpSetup;
|
|
20
|
-
applied: boolean;
|
|
20
|
+
resource: CardSetup;
|
|
21
21
|
}>;
|
|
22
|
-
|
|
23
|
-
private readonly accounts;
|
|
24
|
-
readonly checkouts: Map<string, CheckoutState>;
|
|
25
|
-
readonly changes: Map<string, {
|
|
22
|
+
readonly purchases: Map<string, {
|
|
26
23
|
organizationId: string;
|
|
27
|
-
resource:
|
|
28
|
-
|
|
24
|
+
resource: CreditPurchase;
|
|
25
|
+
createdAt: string;
|
|
29
26
|
}>;
|
|
27
|
+
private readonly automaticSettings;
|
|
28
|
+
private readonly accounts;
|
|
29
|
+
readonly changes: Map<string, ChangeState>;
|
|
30
|
+
private readonly invoices;
|
|
30
31
|
readonly attribution: Map<string, boolean>;
|
|
31
32
|
readonly replays: Map<string, {
|
|
32
33
|
fingerprint: string;
|
|
@@ -36,19 +37,26 @@ export declare class MockBillingState {
|
|
|
36
37
|
}>;
|
|
37
38
|
readonly offers: BillingEntitlements["offers"];
|
|
38
39
|
private sequence;
|
|
39
|
-
readAutoTopUp(organizationId: string): AutoTopUpSettings;
|
|
40
|
-
autoTopUpRevision(organizationId: string): number;
|
|
41
|
-
updateAutoTopUp(organizationId: string, input: UpdateAutoTopUpSettingsRequest): AutoTopUpSettings;
|
|
42
|
-
createCardSetup(organizationId: string): AutoTopUpSetup | null;
|
|
43
|
-
reconcileCardSetup(organizationId: string, id: string): "applied" | "unpaid" | "ignored";
|
|
44
40
|
constructor(options?: ContractMockBillingOptions);
|
|
41
|
+
private id;
|
|
45
42
|
private account;
|
|
46
|
-
|
|
43
|
+
private record;
|
|
44
|
+
private outcome;
|
|
45
|
+
readAccount(organizationId: string, now?: string): BillingAccount;
|
|
46
|
+
setReceiptEmail(organizationId: string, email: string | null): void;
|
|
47
|
+
createCardSetup(organizationId: string): CardSetup;
|
|
48
|
+
reconcileCardSetup(organizationId: string, id: string): CardSetup | null;
|
|
49
|
+
createCreditPurchase(organizationId: string, purchaseCents: number, now: string): CreditPurchase | "card_required";
|
|
50
|
+
settlePurchase(organizationId: string, id: string): CreditPurchase | null;
|
|
51
|
+
listInvoices(organizationId: string, page: number, limit: number): BillingInvoiceCollection;
|
|
52
|
+
readAutoTopUp(organizationId: string): AutoTopUpSettings;
|
|
53
|
+
updateAutoTopUp(organizationId: string, input: UpdateAutoTopUpSettingsRequest): AutoTopUpSettings;
|
|
47
54
|
private changeOffers;
|
|
48
55
|
private selectionTotal;
|
|
49
|
-
createChange(organizationId: string, selection:
|
|
56
|
+
createChange(organizationId: string, selection: SubscriptionSelection, now: string): SubscriptionChange | null;
|
|
57
|
+
private apply;
|
|
50
58
|
settleChange(organizationId: string, id: string, now: string): SubscriptionChange | null;
|
|
51
|
-
confirmChange(organizationId: string, id: string, charge: string, now: string): SubscriptionChange | null;
|
|
59
|
+
confirmChange(organizationId: string, id: string, charge: string, now: string): SubscriptionChange | "card_required" | null;
|
|
52
60
|
readEntitlements(organizationId: string, now: string): BillingEntitlements;
|
|
53
61
|
readAttribution(organizationId: string, projectId: string, now: string): ProjectAttribution;
|
|
54
62
|
readSlots(organizationId: string, projects: readonly Project[], now: string): BillingProjectSlots;
|
|
@@ -58,8 +66,6 @@ export declare class MockBillingState {
|
|
|
58
66
|
* answers never call this function, so retries and later failures do not debit. */
|
|
59
67
|
hasCoreFunding(organizationId: string, now: string): boolean;
|
|
60
68
|
fundLive(organizationId: string, sharedEmail: boolean, now: string): "wallet_insufficient" | "email_credit_insufficient" | null;
|
|
61
|
-
createCheckout(organizationId: string, selection: number | CreateSubscriptionCheckoutRequest): CheckoutState | null;
|
|
62
|
-
reconcile(checkout: CheckoutState, now: string): "applied" | "unpaid" | "ignored";
|
|
63
69
|
}
|
|
64
70
|
interface BillingHooks {
|
|
65
71
|
state(): MockBillingState;
|
|
@@ -71,7 +77,7 @@ interface BillingHooks {
|
|
|
71
77
|
reply<T>(body: T, validator: ContractValidator<T>, status?: number): Response;
|
|
72
78
|
read<T>(request: Request, validator: ContractValidator<T>): Promise<T | Response>;
|
|
73
79
|
}
|
|
74
|
-
/** Register only published public resources. Synthetic
|
|
75
|
-
*
|
|
80
|
+
/** Register only published public resources. Synthetic card completion and
|
|
81
|
+
* charge outcomes are programmatic fixtures, never caller-supplied flags. */
|
|
76
82
|
export declare function addMockBillingRoutes(app: Hono, hooks: BillingHooks): void;
|
|
77
83
|
export {};
|