@fonderie/client 0.11.0 → 0.13.0
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/brain/signatures.md +84 -0
- package/dist/index.cjs +90 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -1
- package/dist/index.d.ts +76 -1
- package/dist/index.js +90 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/brain/signatures.md
CHANGED
|
@@ -170,6 +170,10 @@ interface IRecordUsageInput {
|
|
|
170
170
|
|
|
171
171
|
type IUpdatePlanInput = Partial<ICreatePlanInput>;
|
|
172
172
|
|
|
173
|
+
interface IWalletPreferencesInput {
|
|
174
|
+
spendPurchased: boolean;
|
|
175
|
+
}
|
|
176
|
+
|
|
173
177
|
new BillingClient(http: HttpClient, tokens: TokenStore): BillingClient
|
|
174
178
|
.setAccessToken(token: string | undefined): void
|
|
175
179
|
.setWorkspaceId(workspaceId: string | undefined): void
|
|
@@ -179,10 +183,18 @@ new BillingClient(http: HttpClient, tokens: TokenStore): BillingClient
|
|
|
179
183
|
.updatePlan(planId: string, input: Partial<ICreatePlanInput>): Promise<IApiResponse<IPlanResult>>
|
|
180
184
|
.deletePlan(planId: string): Promise<IApiResponse<undefined>>
|
|
181
185
|
.getSubscription(opts?: IReadOptions | undefined): Promise<IApiResponse<ISubscriptionResult>>
|
|
186
|
+
.cancelSubscription(input?: ICancelSubscriptionInput | undefined): Promise<IApiResponse<ISubscriptionChangeResult>>
|
|
187
|
+
.reactivateSubscription(): Promise<IApiResponse<ISubscriptionChangeResult>>
|
|
182
188
|
.createCheckoutSession(input: ICheckoutInput): Promise<IApiResponse<ICheckoutUrlResult>>
|
|
183
189
|
.createPortalSession(): Promise<IApiResponse<IPortalUrlResult>>
|
|
184
190
|
.recordUsage(input: IRecordUsageInput): Promise<IApiResponse<undefined>>
|
|
185
191
|
.getUsage(metric: string, opts?: IReadOptions | undefined): Promise<IApiResponse<IUsageResult>>
|
|
192
|
+
.getWallet(opts?: IReadOptions | undefined): Promise<IApiResponse<IWalletResult>>
|
|
193
|
+
.setWalletPreferences(input: IWalletPreferencesInput): Promise<IApiResponse<IWalletResult>>
|
|
194
|
+
.createWalletCheckout(input: IWalletCheckoutInput): Promise<IApiResponse<ICheckoutUrlResult>>
|
|
195
|
+
.getWalletTransactions(opts?: (IReadOptions & { cursor?: string; limit?: number; }) | undefined): Promise<IApiResponse<IWalletTransactionsResult>>
|
|
196
|
+
.getPaymentMethod(opts?: IReadOptions | undefined): Promise<IApiResponse<IPaymentMethodResult>>
|
|
197
|
+
.listInvoices(opts?: IReadOptions | undefined): Promise<IApiResponse<IInvoicesResult>>
|
|
186
198
|
|
|
187
199
|
interface IConfigAdminClientOptions {
|
|
188
200
|
baseUrl: string;
|
|
@@ -510,6 +522,10 @@ interface IAuditPageResult {
|
|
|
510
522
|
nextCursor: string | null;
|
|
511
523
|
}
|
|
512
524
|
|
|
525
|
+
interface ICancelSubscriptionInput {
|
|
526
|
+
atPeriodEnd?: boolean;
|
|
527
|
+
}
|
|
528
|
+
|
|
513
529
|
interface ICheckoutUrlResult {
|
|
514
530
|
url: string;
|
|
515
531
|
}
|
|
@@ -716,6 +732,22 @@ interface IInviteResult {
|
|
|
716
732
|
}>;
|
|
717
733
|
}
|
|
718
734
|
|
|
735
|
+
interface IInvoiceDTO {
|
|
736
|
+
id: string;
|
|
737
|
+
number: string | null;
|
|
738
|
+
amountDue: string;
|
|
739
|
+
amountPaid: string;
|
|
740
|
+
currency: string;
|
|
741
|
+
status: string;
|
|
742
|
+
created: string;
|
|
743
|
+
hostedInvoiceUrl: string | null;
|
|
744
|
+
invoicePdf: string | null;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
interface IInvoicesResult {
|
|
748
|
+
invoices: IInvoiceDTO[];
|
|
749
|
+
}
|
|
750
|
+
|
|
719
751
|
interface ILoginResult {
|
|
720
752
|
tokens: ITokens;
|
|
721
753
|
user: IUserDTO;
|
|
@@ -756,6 +788,17 @@ interface IMfaSetupResult {
|
|
|
756
788
|
backupCodes: string[];
|
|
757
789
|
}
|
|
758
790
|
|
|
791
|
+
interface IPaymentMethodDTO {
|
|
792
|
+
brand: string;
|
|
793
|
+
last4: string;
|
|
794
|
+
expMonth: number;
|
|
795
|
+
expYear: number;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
interface IPaymentMethodResult {
|
|
799
|
+
paymentMethod: IPaymentMethodDTO | null;
|
|
800
|
+
}
|
|
801
|
+
|
|
759
802
|
interface IPlanDTO {
|
|
760
803
|
id: string;
|
|
761
804
|
planId: string;
|
|
@@ -851,6 +894,12 @@ interface ISecretRevision {
|
|
|
851
894
|
createdAt: string;
|
|
852
895
|
}
|
|
853
896
|
|
|
897
|
+
interface ISubscriptionChangeResult {
|
|
898
|
+
atPeriodEnd: boolean;
|
|
899
|
+
status: string;
|
|
900
|
+
currentPeriodEnd: string | null;
|
|
901
|
+
}
|
|
902
|
+
|
|
854
903
|
interface ISubscriptionDTO {
|
|
855
904
|
id: string;
|
|
856
905
|
subscriberType: SubscriberType;
|
|
@@ -948,6 +997,41 @@ interface IVerifyEmailResult {
|
|
|
948
997
|
email: string;
|
|
949
998
|
}
|
|
950
999
|
|
|
1000
|
+
interface IWalletCheckoutInput {
|
|
1001
|
+
packId: string;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
interface IWalletDTO {
|
|
1005
|
+
balance: string;
|
|
1006
|
+
currency: string;
|
|
1007
|
+
precision: number;
|
|
1008
|
+
granted?: string;
|
|
1009
|
+
purchased?: string;
|
|
1010
|
+
spendPurchased?: boolean;
|
|
1011
|
+
grantedExpiresAt?: string | null;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
interface IWalletResult {
|
|
1015
|
+
wallet: IWalletDTO;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
interface IWalletTransactionDTO {
|
|
1019
|
+
id: string;
|
|
1020
|
+
type: string;
|
|
1021
|
+
amount: string;
|
|
1022
|
+
balanceAfter: string;
|
|
1023
|
+
currency: string;
|
|
1024
|
+
description: string | null;
|
|
1025
|
+
providerTxId: string | null;
|
|
1026
|
+
metadata: Record<string, unknown>;
|
|
1027
|
+
createdAt: string;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
interface IWalletTransactionsResult {
|
|
1031
|
+
transactions: IWalletTransactionDTO[];
|
|
1032
|
+
nextCursor: string | null;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
951
1035
|
interface IWebhookDeliveryDTO {
|
|
952
1036
|
id: string;
|
|
953
1037
|
eventId: string;
|
package/dist/index.cjs
CHANGED
|
@@ -456,6 +456,28 @@ var BillingClient = class {
|
|
|
456
456
|
bust: opts?.bust
|
|
457
457
|
});
|
|
458
458
|
}
|
|
459
|
+
// First-party cancel — no portal round-trip. Default keeps access until the
|
|
460
|
+
// paid-through date; pass { atPeriodEnd: false } to end it immediately. 501
|
|
461
|
+
// when the provider has no first-party cancel (the portal remains a fallback).
|
|
462
|
+
cancelSubscription(input) {
|
|
463
|
+
return this.http.request({
|
|
464
|
+
method: "POST",
|
|
465
|
+
path: "/billing/subscription/cancel",
|
|
466
|
+
body: input ?? {},
|
|
467
|
+
token: this.tokens.get(),
|
|
468
|
+
workspaceId: this.workspaceId
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
// Un-cancel a subscription scheduled to cancel at period end. Idempotent; 409
|
|
472
|
+
// when the subscription is already fully canceled (start a new checkout).
|
|
473
|
+
reactivateSubscription() {
|
|
474
|
+
return this.http.request({
|
|
475
|
+
method: "POST",
|
|
476
|
+
path: "/billing/subscription/reactivate",
|
|
477
|
+
token: this.tokens.get(),
|
|
478
|
+
workspaceId: this.workspaceId
|
|
479
|
+
});
|
|
480
|
+
}
|
|
459
481
|
// ── Checkout / portal ────────────────────────────────────────────────────────
|
|
460
482
|
createCheckoutSession(input) {
|
|
461
483
|
return this.http.request({
|
|
@@ -493,6 +515,74 @@ var BillingClient = class {
|
|
|
493
515
|
bust: opts?.bust
|
|
494
516
|
});
|
|
495
517
|
}
|
|
518
|
+
// ── Wallet ─────────────────────────────────────────────────────────────────────
|
|
519
|
+
getWallet(opts) {
|
|
520
|
+
return this.http.request({
|
|
521
|
+
method: "GET",
|
|
522
|
+
path: "/billing/wallet",
|
|
523
|
+
token: this.tokens.get(),
|
|
524
|
+
workspaceId: this.workspaceId,
|
|
525
|
+
bust: opts?.bust
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
setWalletPreferences(input) {
|
|
529
|
+
return this.http.request({
|
|
530
|
+
method: "POST",
|
|
531
|
+
path: "/billing/wallet/preferences",
|
|
532
|
+
body: input,
|
|
533
|
+
token: this.tokens.get(),
|
|
534
|
+
workspaceId: this.workspaceId
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
// Start a one-time credit-pack purchase. Returns a hosted checkout URL to
|
|
538
|
+
// redirect the buyer to; the wallet is credited by the payment webhook.
|
|
539
|
+
createWalletCheckout(input) {
|
|
540
|
+
return this.http.request({
|
|
541
|
+
method: "POST",
|
|
542
|
+
path: "/billing/wallet/checkout",
|
|
543
|
+
body: input,
|
|
544
|
+
token: this.tokens.get(),
|
|
545
|
+
workspaceId: this.workspaceId
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
// The wallet ledger, newest first — every credit/debit with a running
|
|
549
|
+
// balanceAfter. Cursor-paginated: pass the previous result's `nextCursor`.
|
|
550
|
+
getWalletTransactions(opts) {
|
|
551
|
+
const params = new URLSearchParams();
|
|
552
|
+
if (opts?.cursor) params.set("cursor", opts.cursor);
|
|
553
|
+
if (opts?.limit !== void 0) params.set("limit", String(opts.limit));
|
|
554
|
+
const qs = params.toString();
|
|
555
|
+
return this.http.request({
|
|
556
|
+
method: "GET",
|
|
557
|
+
path: `/billing/wallet/transactions${qs ? "?" + qs : ""}`,
|
|
558
|
+
token: this.tokens.get(),
|
|
559
|
+
workspaceId: this.workspaceId,
|
|
560
|
+
bust: opts?.bust
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
// ── Account ──────────────────────────────────────────────────────────────────
|
|
564
|
+
// The customer's card on file (brand/last4/expiry), or { paymentMethod: null }
|
|
565
|
+
// when none is stored. 501 when the provider can't retrieve it.
|
|
566
|
+
getPaymentMethod(opts) {
|
|
567
|
+
return this.http.request({
|
|
568
|
+
method: "GET",
|
|
569
|
+
path: "/billing/payment-method",
|
|
570
|
+
token: this.tokens.get(),
|
|
571
|
+
workspaceId: this.workspaceId,
|
|
572
|
+
bust: opts?.bust
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
// The customer's invoices, newest first — each links out to the hosted
|
|
576
|
+
// invoice / PDF. 501 when the provider can't list them.
|
|
577
|
+
listInvoices(opts) {
|
|
578
|
+
return this.http.request({
|
|
579
|
+
method: "GET",
|
|
580
|
+
path: "/billing/invoices",
|
|
581
|
+
token: this.tokens.get(),
|
|
582
|
+
workspaceId: this.workspaceId,
|
|
583
|
+
bust: opts?.bust
|
|
584
|
+
});
|
|
585
|
+
}
|
|
496
586
|
};
|
|
497
587
|
|
|
498
588
|
// src/modules/customers.ts
|