@fonderie/client 0.28.0 → 0.29.1
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 +26 -0
- package/dist/index.cjs +56 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +56 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/brain/signatures.md
CHANGED
|
@@ -283,6 +283,8 @@ new AdminClient(opts: IAdminClientOptions): AdminClient
|
|
|
283
283
|
.routes(): Promise<IApiResponse<IAdminRoutesReport>>
|
|
284
284
|
.tokens(): Promise<IApiResponse<IAdminTokensReport>>
|
|
285
285
|
.adminLog(query?: IAdminLogQuery): Promise<IApiResponse<IAdminLogPage>>
|
|
286
|
+
.issueToken(input: IAdminIssueTokenInput): Promise<IApiResponse<IAdminIssuedToken>>
|
|
287
|
+
.revokeToken(id: string): Promise<IApiResponse<undefined>>
|
|
286
288
|
|
|
287
289
|
interface IAuthAdminClientOptions {
|
|
288
290
|
baseUrl: string;
|
|
@@ -800,6 +802,30 @@ interface IAdminTokensReport {
|
|
|
800
802
|
module: string;
|
|
801
803
|
set: boolean;
|
|
802
804
|
}>;
|
|
805
|
+
issued: IAdminTokenRecord[] | null;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
type AdminScope = 'read' | 'write' | 'secrets';
|
|
809
|
+
|
|
810
|
+
interface IAdminTokenRecord {
|
|
811
|
+
id: string;
|
|
812
|
+
name: string;
|
|
813
|
+
scopes: AdminScope[];
|
|
814
|
+
createdBy: string;
|
|
815
|
+
createdAt: string;
|
|
816
|
+
expiresAt: string | null;
|
|
817
|
+
revokedAt: string | null;
|
|
818
|
+
lastUsedAt: string | null;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
interface IAdminIssueTokenInput {
|
|
822
|
+
name: string;
|
|
823
|
+
scopes: AdminScope[];
|
|
824
|
+
expiresInDays?: number;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
interface IAdminIssuedToken extends IAdminTokenRecord {
|
|
828
|
+
token: string;
|
|
803
829
|
}
|
|
804
830
|
|
|
805
831
|
interface IAdminUserDTO extends IUserDTO {
|
package/dist/index.cjs
CHANGED
|
@@ -170,7 +170,8 @@ var HttpClient = class {
|
|
|
170
170
|
if (newToken) return this.exec({ ...opts, token: newToken }, true);
|
|
171
171
|
}
|
|
172
172
|
if (res.status === 204) {
|
|
173
|
-
if (!res.ok)
|
|
173
|
+
if (!res.ok)
|
|
174
|
+
throw new FonderieApiError("unknown", res.statusText, res.status, void 0, rid);
|
|
174
175
|
return void 0;
|
|
175
176
|
}
|
|
176
177
|
const data = await res.json();
|
|
@@ -1573,19 +1574,49 @@ var FonderieClient = class {
|
|
|
1573
1574
|
});
|
|
1574
1575
|
}
|
|
1575
1576
|
post(path, body, config) {
|
|
1576
|
-
return this.request({
|
|
1577
|
+
return this.request({
|
|
1578
|
+
method: "POST",
|
|
1579
|
+
path,
|
|
1580
|
+
body,
|
|
1581
|
+
token: config?.token,
|
|
1582
|
+
workspaceId: config?.workspaceId,
|
|
1583
|
+
invalidate: config?.invalidate
|
|
1584
|
+
});
|
|
1577
1585
|
}
|
|
1578
1586
|
put(path, body, config) {
|
|
1579
|
-
return this.request({
|
|
1587
|
+
return this.request({
|
|
1588
|
+
method: "PUT",
|
|
1589
|
+
path,
|
|
1590
|
+
body,
|
|
1591
|
+
token: config?.token,
|
|
1592
|
+
workspaceId: config?.workspaceId,
|
|
1593
|
+
invalidate: config?.invalidate
|
|
1594
|
+
});
|
|
1580
1595
|
}
|
|
1581
1596
|
patch(path, body, config) {
|
|
1582
|
-
return this.request({
|
|
1597
|
+
return this.request({
|
|
1598
|
+
method: "PATCH",
|
|
1599
|
+
path,
|
|
1600
|
+
body,
|
|
1601
|
+
token: config?.token,
|
|
1602
|
+
workspaceId: config?.workspaceId,
|
|
1603
|
+
invalidate: config?.invalidate
|
|
1604
|
+
});
|
|
1583
1605
|
}
|
|
1584
1606
|
delete(path, config) {
|
|
1585
|
-
return this.request({
|
|
1607
|
+
return this.request({
|
|
1608
|
+
method: "DELETE",
|
|
1609
|
+
path,
|
|
1610
|
+
token: config?.token,
|
|
1611
|
+
workspaceId: config?.workspaceId,
|
|
1612
|
+
invalidate: config?.invalidate
|
|
1613
|
+
});
|
|
1586
1614
|
}
|
|
1587
1615
|
};
|
|
1588
1616
|
|
|
1617
|
+
// src/path.ts
|
|
1618
|
+
var normalizeMountPath = (path) => path.replace(/\/+$/, "");
|
|
1619
|
+
|
|
1589
1620
|
// src/modules/config-admin.ts
|
|
1590
1621
|
function envQuery(environment) {
|
|
1591
1622
|
return environment ? `?environment=${encodeURIComponent(environment)}` : "";
|
|
@@ -1598,7 +1629,7 @@ var ConfigAdminClient = class {
|
|
|
1598
1629
|
constructor(opts) {
|
|
1599
1630
|
this.http = new HttpClient(opts.baseUrl);
|
|
1600
1631
|
this.adminToken = opts.adminToken;
|
|
1601
|
-
this.prefix = opts.prefix
|
|
1632
|
+
this.prefix = opts.prefix ? normalizeMountPath(opts.prefix) : void 0;
|
|
1602
1633
|
this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
|
|
1603
1634
|
}
|
|
1604
1635
|
// The path literals stay on the legacy '/admin/...' so the route table and
|
|
@@ -1749,15 +1780,19 @@ var AdminClient = class {
|
|
|
1749
1780
|
constructor(opts) {
|
|
1750
1781
|
this.http = new HttpClient(opts.baseUrl);
|
|
1751
1782
|
this.adminToken = opts.adminToken;
|
|
1752
|
-
this.prefix = (opts.prefix ?? "/_admin")
|
|
1783
|
+
this.prefix = normalizeMountPath(opts.prefix ?? "/_admin");
|
|
1753
1784
|
this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
|
|
1754
1785
|
}
|
|
1755
1786
|
get(suffix) {
|
|
1787
|
+
return this.call("GET", suffix);
|
|
1788
|
+
}
|
|
1789
|
+
call(method, suffix, body) {
|
|
1756
1790
|
return this.http.request({
|
|
1757
|
-
method
|
|
1791
|
+
method,
|
|
1758
1792
|
path: `${this.prefix}${suffix}`,
|
|
1759
1793
|
token: this.adminToken,
|
|
1760
|
-
headers: this.actorHeaders
|
|
1794
|
+
headers: this.actorHeaders,
|
|
1795
|
+
...body !== void 0 ? { body } : {}
|
|
1761
1796
|
});
|
|
1762
1797
|
}
|
|
1763
1798
|
attention() {
|
|
@@ -1785,6 +1820,14 @@ var AdminClient = class {
|
|
|
1785
1820
|
const qs = q.toString();
|
|
1786
1821
|
return this.get(`/activity/admin-log${qs ? `?${qs}` : ""}`);
|
|
1787
1822
|
}
|
|
1823
|
+
// Root token only. The plaintext comes back once.
|
|
1824
|
+
issueToken(input) {
|
|
1825
|
+
return this.call("POST", "/access/tokens", input);
|
|
1826
|
+
}
|
|
1827
|
+
// Root token only.
|
|
1828
|
+
revokeToken(id) {
|
|
1829
|
+
return this.call("DELETE", `/access/tokens/${encodeURIComponent(id)}`);
|
|
1830
|
+
}
|
|
1788
1831
|
};
|
|
1789
1832
|
|
|
1790
1833
|
// src/modules/auth-admin.ts
|
|
@@ -1796,7 +1839,7 @@ var AuthAdminClient = class {
|
|
|
1796
1839
|
constructor(opts) {
|
|
1797
1840
|
this.http = new HttpClient(opts.baseUrl);
|
|
1798
1841
|
this.adminToken = opts.adminToken;
|
|
1799
|
-
this.prefix = (opts.prefix ?? "/_admin")
|
|
1842
|
+
this.prefix = normalizeMountPath(opts.prefix ?? "/_admin");
|
|
1800
1843
|
this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
|
|
1801
1844
|
}
|
|
1802
1845
|
call(method, suffix) {
|
|
@@ -1847,7 +1890,7 @@ var BillingAdminClient = class {
|
|
|
1847
1890
|
constructor(opts) {
|
|
1848
1891
|
this.http = new HttpClient(opts.baseUrl);
|
|
1849
1892
|
this.adminToken = opts.adminToken;
|
|
1850
|
-
this.prefix = (opts.prefix ?? "/_admin")
|
|
1893
|
+
this.prefix = normalizeMountPath(opts.prefix ?? "/_admin");
|
|
1851
1894
|
this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
|
|
1852
1895
|
}
|
|
1853
1896
|
call(method, suffix, body) {
|
|
@@ -1907,7 +1950,7 @@ var AuditAdminClient = class {
|
|
|
1907
1950
|
constructor(opts) {
|
|
1908
1951
|
this.http = new HttpClient(opts.baseUrl);
|
|
1909
1952
|
this.adminToken = opts.adminToken;
|
|
1910
|
-
this.prefix = (opts.prefix ?? "/_admin")
|
|
1953
|
+
this.prefix = normalizeMountPath(opts.prefix ?? "/_admin");
|
|
1911
1954
|
this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
|
|
1912
1955
|
}
|
|
1913
1956
|
// Every workspace unless one is named. Newest first, keyset-paged.
|
|
@@ -1939,7 +1982,7 @@ var CourierAdminClient = class {
|
|
|
1939
1982
|
constructor(opts) {
|
|
1940
1983
|
this.http = new HttpClient(opts.baseUrl);
|
|
1941
1984
|
this.adminToken = opts.adminToken;
|
|
1942
|
-
this.prefix = opts.prefix
|
|
1985
|
+
this.prefix = opts.prefix ? normalizeMountPath(opts.prefix) : void 0;
|
|
1943
1986
|
this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
|
|
1944
1987
|
}
|
|
1945
1988
|
// The path literals stay on the legacy '/admin/...' so the route table and
|