@fonderie/client 0.26.0 → 0.27.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 +78 -0
- package/dist/index.cjs +62 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +81 -1
- package/dist/index.d.ts +81 -1
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/brain/signatures.md
CHANGED
|
@@ -305,6 +305,29 @@ new AuthAdminClient(opts: IAuthAdminClientOptions): AuthAdminClient
|
|
|
305
305
|
.suspendUser(id: string): Promise<IApiResponse<IAdminUserDTO>>
|
|
306
306
|
.unsuspendUser(id: string): Promise<IApiResponse<IAdminUserDTO>>
|
|
307
307
|
|
|
308
|
+
interface IBillingAdminClientOptions {
|
|
309
|
+
baseUrl: string;
|
|
310
|
+
adminToken: string;
|
|
311
|
+
prefix?: string;
|
|
312
|
+
actor?: string;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
interface IAdminLedgerQuery {
|
|
316
|
+
currency?: string;
|
|
317
|
+
limit?: number;
|
|
318
|
+
cursor?: string;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
new BillingAdminClient(opts: IBillingAdminClientOptions): BillingAdminClient
|
|
322
|
+
.catalog(): Promise<IApiResponse<IAdminCatalog>>
|
|
323
|
+
.createPlan(input: IAdminPlanInput & { name: string; }): Promise<IApiResponse<IPlanDTO>>
|
|
324
|
+
.updatePlan(planId: string, input: IAdminPlanInput): Promise<IApiResponse<IPlanDTO>>
|
|
325
|
+
.deletePlan(planId: string): Promise<IApiResponse<undefined>>
|
|
326
|
+
.subscription(type: SubscriberType, id: string): Promise<IApiResponse<IAdminSubscriptionDTO>>
|
|
327
|
+
.wallet(type: SubscriberType, id: string, currency?: string | undefined): Promise<IApiResponse<IAdminWalletDTO>>
|
|
328
|
+
.walletLedger(type: SubscriberType, id: string, query?: IAdminLedgerQuery): Promise<IApiResponse<IAdminWalletLedgerPage>>
|
|
329
|
+
.grant(input: IAdminGrantInput): Promise<IApiResponse<unknown>>
|
|
330
|
+
|
|
308
331
|
interface ICourierAdminClientOptions {
|
|
309
332
|
baseUrl: string;
|
|
310
333
|
adminToken: string;
|
|
@@ -763,6 +786,61 @@ interface IAdminUserDTO extends IUserDTO {
|
|
|
763
786
|
deletedAt: string | null;
|
|
764
787
|
}
|
|
765
788
|
|
|
789
|
+
interface IAdminCatalog {
|
|
790
|
+
configured: unknown[];
|
|
791
|
+
stored: IPlanDTO[];
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
interface IAdminSubscriptionDTO {
|
|
795
|
+
id: string;
|
|
796
|
+
subscriberType: SubscriberType;
|
|
797
|
+
subscriberId: string;
|
|
798
|
+
plan: string;
|
|
799
|
+
interval: string;
|
|
800
|
+
status: string;
|
|
801
|
+
providerCustomerId: string | null;
|
|
802
|
+
providerSubscriptionId: string | null;
|
|
803
|
+
currentPeriodStart: string | null;
|
|
804
|
+
currentPeriodEnd: string | null;
|
|
805
|
+
cancelAtPeriodEnd: boolean;
|
|
806
|
+
trialEndsAt: string | null;
|
|
807
|
+
createdAt: string;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
interface IAdminWalletDTO extends IWalletDTO {
|
|
811
|
+
version: number;
|
|
812
|
+
updatedAt: string | null;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
interface IAdminWalletLedgerPage {
|
|
816
|
+
currency: string;
|
|
817
|
+
entries: IWalletTransactionDTO[];
|
|
818
|
+
nextCursor: string | null;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
interface IAdminPlanInput {
|
|
822
|
+
name?: string;
|
|
823
|
+
description?: string | null;
|
|
824
|
+
tier?: number;
|
|
825
|
+
seats?: number | null;
|
|
826
|
+
trialDays?: number;
|
|
827
|
+
monthlyAmount?: number | null;
|
|
828
|
+
monthlyPriceId?: string | null;
|
|
829
|
+
yearlyAmount?: number | null;
|
|
830
|
+
yearlyPriceId?: string | null;
|
|
831
|
+
features?: unknown;
|
|
832
|
+
metadata?: unknown;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
interface IAdminGrantInput {
|
|
836
|
+
subscriberType: SubscriberType;
|
|
837
|
+
subscriberId: string;
|
|
838
|
+
amount: string | number;
|
|
839
|
+
currency?: string;
|
|
840
|
+
description?: string;
|
|
841
|
+
idempotencyKey: string;
|
|
842
|
+
}
|
|
843
|
+
|
|
766
844
|
interface IConfigEntry {
|
|
767
845
|
key: string;
|
|
768
846
|
value: unknown;
|
package/dist/index.cjs
CHANGED
|
@@ -24,6 +24,7 @@ __export(index_exports, {
|
|
|
24
24
|
AuditClient: () => AuditClient,
|
|
25
25
|
AuthAdminClient: () => AuthAdminClient,
|
|
26
26
|
AuthClient: () => AuthClient,
|
|
27
|
+
BillingAdminClient: () => BillingAdminClient,
|
|
27
28
|
BillingClient: () => BillingClient,
|
|
28
29
|
ConfigAdminClient: () => ConfigAdminClient,
|
|
29
30
|
CourierAdminClient: () => CourierAdminClient,
|
|
@@ -1836,6 +1837,66 @@ var AuthAdminClient = class {
|
|
|
1836
1837
|
}
|
|
1837
1838
|
};
|
|
1838
1839
|
|
|
1840
|
+
// src/modules/billing-admin.ts
|
|
1841
|
+
var BillingAdminClient = class {
|
|
1842
|
+
http;
|
|
1843
|
+
adminToken;
|
|
1844
|
+
prefix;
|
|
1845
|
+
actorHeaders;
|
|
1846
|
+
constructor(opts) {
|
|
1847
|
+
this.http = new HttpClient(opts.baseUrl);
|
|
1848
|
+
this.adminToken = opts.adminToken;
|
|
1849
|
+
this.prefix = (opts.prefix ?? "/_admin").replace(/\/+$/, "");
|
|
1850
|
+
this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
|
|
1851
|
+
}
|
|
1852
|
+
call(method, suffix, body) {
|
|
1853
|
+
return this.http.request({
|
|
1854
|
+
method,
|
|
1855
|
+
path: `${this.prefix}${suffix}`,
|
|
1856
|
+
token: this.adminToken,
|
|
1857
|
+
headers: this.actorHeaders,
|
|
1858
|
+
...body !== void 0 ? { body } : {}
|
|
1859
|
+
});
|
|
1860
|
+
}
|
|
1861
|
+
sub(type, id) {
|
|
1862
|
+
return `/${type}/${encodeURIComponent(id)}`;
|
|
1863
|
+
}
|
|
1864
|
+
catalog() {
|
|
1865
|
+
return this.call("GET", "/catalog");
|
|
1866
|
+
}
|
|
1867
|
+
createPlan(input) {
|
|
1868
|
+
return this.call("POST", "/plans", input);
|
|
1869
|
+
}
|
|
1870
|
+
updatePlan(planId, input) {
|
|
1871
|
+
return this.call("PUT", `/plans/${encodeURIComponent(planId)}`, input);
|
|
1872
|
+
}
|
|
1873
|
+
deletePlan(planId) {
|
|
1874
|
+
return this.call("DELETE", `/plans/${encodeURIComponent(planId)}`);
|
|
1875
|
+
}
|
|
1876
|
+
subscription(type, id) {
|
|
1877
|
+
return this.call("GET", `/subscriptions${this.sub(type, id)}`);
|
|
1878
|
+
}
|
|
1879
|
+
wallet(type, id, currency) {
|
|
1880
|
+
const qs = currency ? `?currency=${encodeURIComponent(currency)}` : "";
|
|
1881
|
+
return this.call("GET", `/wallet${this.sub(type, id)}${qs}`);
|
|
1882
|
+
}
|
|
1883
|
+
walletLedger(type, id, query = {}) {
|
|
1884
|
+
const q = new URLSearchParams();
|
|
1885
|
+
if (query.currency) q.set("currency", query.currency);
|
|
1886
|
+
if (query.limit) q.set("limit", String(query.limit));
|
|
1887
|
+
if (query.cursor) q.set("cursor", query.cursor);
|
|
1888
|
+
const qs = q.toString();
|
|
1889
|
+
return this.call(
|
|
1890
|
+
"GET",
|
|
1891
|
+
`/wallet${this.sub(type, id)}/ledger${qs ? `?${qs}` : ""}`
|
|
1892
|
+
);
|
|
1893
|
+
}
|
|
1894
|
+
// Manual credit — an idempotency key is required by the server.
|
|
1895
|
+
grant(input) {
|
|
1896
|
+
return this.call("POST", "/wallet/grant", input);
|
|
1897
|
+
}
|
|
1898
|
+
};
|
|
1899
|
+
|
|
1839
1900
|
// src/modules/courier-admin.ts
|
|
1840
1901
|
var CourierAdminClient = class {
|
|
1841
1902
|
http;
|
|
@@ -1930,6 +1991,7 @@ function isMfaRequired(result) {
|
|
|
1930
1991
|
AuditClient,
|
|
1931
1992
|
AuthAdminClient,
|
|
1932
1993
|
AuthClient,
|
|
1994
|
+
BillingAdminClient,
|
|
1933
1995
|
BillingClient,
|
|
1934
1996
|
ConfigAdminClient,
|
|
1935
1997
|
CourierAdminClient,
|