@fonderie/client 0.25.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 +103 -0
- package/dist/index.cjs +115 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +110 -1
- package/dist/index.d.ts +110 -1
- package/dist/index.js +113 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/brain/signatures.md
CHANGED
|
@@ -284,6 +284,50 @@ new AdminClient(opts: IAdminClientOptions): AdminClient
|
|
|
284
284
|
.tokens(): Promise<IApiResponse<IAdminTokensReport>>
|
|
285
285
|
.adminLog(query?: IAdminLogQuery): Promise<IApiResponse<IAdminLogPage>>
|
|
286
286
|
|
|
287
|
+
interface IAuthAdminClientOptions {
|
|
288
|
+
baseUrl: string;
|
|
289
|
+
adminToken: string;
|
|
290
|
+
prefix?: string;
|
|
291
|
+
actor?: string;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
interface IAdminLoginHistoryQuery {
|
|
295
|
+
limit?: number;
|
|
296
|
+
cursor?: string;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
new AuthAdminClient(opts: IAuthAdminClientOptions): AuthAdminClient
|
|
300
|
+
.findUser(email: string): Promise<IApiResponse<IAdminUserDTO>>
|
|
301
|
+
.getUser(id: string): Promise<IApiResponse<IAdminUserDTO>>
|
|
302
|
+
.listUserSessions(id: string): Promise<IApiResponse<ISessionDTO[]>>
|
|
303
|
+
.revokeUserSessions(id: string): Promise<IApiResponse<undefined>>
|
|
304
|
+
.userLoginHistory(id: string, query?: IAdminLoginHistoryQuery): Promise<IApiResponse<ILoginHistoryPageResult>>
|
|
305
|
+
.suspendUser(id: string): Promise<IApiResponse<IAdminUserDTO>>
|
|
306
|
+
.unsuspendUser(id: string): Promise<IApiResponse<IAdminUserDTO>>
|
|
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
|
+
|
|
287
331
|
interface ICourierAdminClientOptions {
|
|
288
332
|
baseUrl: string;
|
|
289
333
|
adminToken: string;
|
|
@@ -738,6 +782,65 @@ interface IAdminTokensReport {
|
|
|
738
782
|
}>;
|
|
739
783
|
}
|
|
740
784
|
|
|
785
|
+
interface IAdminUserDTO extends IUserDTO {
|
|
786
|
+
deletedAt: string | null;
|
|
787
|
+
}
|
|
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
|
+
|
|
741
844
|
interface IConfigEntry {
|
|
742
845
|
key: string;
|
|
743
846
|
value: unknown;
|
package/dist/index.cjs
CHANGED
|
@@ -22,7 +22,9 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
AdminClient: () => AdminClient,
|
|
24
24
|
AuditClient: () => AuditClient,
|
|
25
|
+
AuthAdminClient: () => AuthAdminClient,
|
|
25
26
|
AuthClient: () => AuthClient,
|
|
27
|
+
BillingAdminClient: () => BillingAdminClient,
|
|
26
28
|
BillingClient: () => BillingClient,
|
|
27
29
|
ConfigAdminClient: () => ConfigAdminClient,
|
|
28
30
|
CourierAdminClient: () => CourierAdminClient,
|
|
@@ -1784,6 +1786,117 @@ var AdminClient = class {
|
|
|
1784
1786
|
}
|
|
1785
1787
|
};
|
|
1786
1788
|
|
|
1789
|
+
// src/modules/auth-admin.ts
|
|
1790
|
+
var AuthAdminClient = class {
|
|
1791
|
+
http;
|
|
1792
|
+
adminToken;
|
|
1793
|
+
prefix;
|
|
1794
|
+
actorHeaders;
|
|
1795
|
+
constructor(opts) {
|
|
1796
|
+
this.http = new HttpClient(opts.baseUrl);
|
|
1797
|
+
this.adminToken = opts.adminToken;
|
|
1798
|
+
this.prefix = (opts.prefix ?? "/_admin").replace(/\/+$/, "");
|
|
1799
|
+
this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
|
|
1800
|
+
}
|
|
1801
|
+
call(method, suffix) {
|
|
1802
|
+
return this.http.request({
|
|
1803
|
+
method,
|
|
1804
|
+
path: `${this.prefix}/users${suffix}`,
|
|
1805
|
+
token: this.adminToken,
|
|
1806
|
+
headers: this.actorHeaders
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
findUser(email) {
|
|
1810
|
+
return this.call("GET", `?email=${encodeURIComponent(email)}`);
|
|
1811
|
+
}
|
|
1812
|
+
getUser(id) {
|
|
1813
|
+
return this.call("GET", `/${encodeURIComponent(id)}`);
|
|
1814
|
+
}
|
|
1815
|
+
listUserSessions(id) {
|
|
1816
|
+
return this.call("GET", `/${encodeURIComponent(id)}/sessions`);
|
|
1817
|
+
}
|
|
1818
|
+
// Signs the user out everywhere.
|
|
1819
|
+
revokeUserSessions(id) {
|
|
1820
|
+
return this.call("DELETE", `/${encodeURIComponent(id)}/sessions`);
|
|
1821
|
+
}
|
|
1822
|
+
userLoginHistory(id, query = {}) {
|
|
1823
|
+
const q = new URLSearchParams();
|
|
1824
|
+
if (query.limit) q.set("limit", String(query.limit));
|
|
1825
|
+
if (query.cursor) q.set("cursor", query.cursor);
|
|
1826
|
+
const qs = q.toString();
|
|
1827
|
+
return this.call(
|
|
1828
|
+
"GET",
|
|
1829
|
+
`/${encodeURIComponent(id)}/login-history${qs ? `?${qs}` : ""}`
|
|
1830
|
+
);
|
|
1831
|
+
}
|
|
1832
|
+
suspendUser(id) {
|
|
1833
|
+
return this.call("POST", `/${encodeURIComponent(id)}/suspend`);
|
|
1834
|
+
}
|
|
1835
|
+
unsuspendUser(id) {
|
|
1836
|
+
return this.call("POST", `/${encodeURIComponent(id)}/unsuspend`);
|
|
1837
|
+
}
|
|
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
|
+
|
|
1787
1900
|
// src/modules/courier-admin.ts
|
|
1788
1901
|
var CourierAdminClient = class {
|
|
1789
1902
|
http;
|
|
@@ -1876,7 +1989,9 @@ function isMfaRequired(result) {
|
|
|
1876
1989
|
0 && (module.exports = {
|
|
1877
1990
|
AdminClient,
|
|
1878
1991
|
AuditClient,
|
|
1992
|
+
AuthAdminClient,
|
|
1879
1993
|
AuthClient,
|
|
1994
|
+
BillingAdminClient,
|
|
1880
1995
|
BillingClient,
|
|
1881
1996
|
ConfigAdminClient,
|
|
1882
1997
|
CourierAdminClient,
|