@fonderie/client 0.23.0 → 0.25.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/dist/index.js CHANGED
@@ -1551,180 +1551,281 @@ function envQuery(environment) {
1551
1551
  var ConfigAdminClient = class {
1552
1552
  http;
1553
1553
  adminToken;
1554
+ prefix;
1554
1555
  actorHeaders;
1555
1556
  constructor(opts) {
1556
1557
  this.http = new HttpClient(opts.baseUrl);
1557
1558
  this.adminToken = opts.adminToken;
1559
+ this.prefix = opts.prefix?.replace(/\/+$/, "");
1558
1560
  this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
1559
1561
  }
1562
+ // The path literals stay on the legacy '/admin/...' so the route table and
1563
+ // the coverage gate read them; the prefix is applied here at request time.
1564
+ rebase(opts) {
1565
+ if (!this.prefix) return opts;
1566
+ return { ...opts, path: opts.path.replace(/^\/admin(?=\/|\?|$)/, this.prefix) };
1567
+ }
1560
1568
  // ── Config ───────────────────────────────────────────────────────────────
1561
1569
  listConfig(environment) {
1562
- return this.http.request({
1563
- method: "GET",
1564
- path: `/admin/config${envQuery(environment)}`,
1565
- token: this.adminToken
1566
- });
1570
+ return this.http.request(
1571
+ this.rebase({
1572
+ method: "GET",
1573
+ path: `/admin/config${envQuery(environment)}`,
1574
+ token: this.adminToken
1575
+ })
1576
+ );
1567
1577
  }
1568
1578
  getConfig(key, environment) {
1569
- return this.http.request({
1570
- method: "GET",
1571
- path: `/admin/config/${encodeURIComponent(key)}${envQuery(environment)}`,
1572
- token: this.adminToken
1573
- });
1579
+ return this.http.request(
1580
+ this.rebase({
1581
+ method: "GET",
1582
+ path: `/admin/config/${encodeURIComponent(key)}${envQuery(environment)}`,
1583
+ token: this.adminToken
1584
+ })
1585
+ );
1574
1586
  }
1575
1587
  setConfig(key, input, environment) {
1576
- return this.http.request({
1577
- method: "PUT",
1578
- path: `/admin/config/${encodeURIComponent(key)}${envQuery(environment)}`,
1579
- body: input,
1580
- token: this.adminToken,
1581
- headers: this.actorHeaders
1582
- });
1588
+ return this.http.request(
1589
+ this.rebase({
1590
+ method: "PUT",
1591
+ path: `/admin/config/${encodeURIComponent(key)}${envQuery(environment)}`,
1592
+ body: input,
1593
+ token: this.adminToken,
1594
+ headers: this.actorHeaders
1595
+ })
1596
+ );
1583
1597
  }
1584
1598
  deleteConfig(key, environment) {
1585
- return this.http.request({
1586
- method: "DELETE",
1587
- path: `/admin/config/${encodeURIComponent(key)}${envQuery(environment)}`,
1588
- token: this.adminToken,
1589
- headers: this.actorHeaders
1590
- });
1599
+ return this.http.request(
1600
+ this.rebase({
1601
+ method: "DELETE",
1602
+ path: `/admin/config/${encodeURIComponent(key)}${envQuery(environment)}`,
1603
+ token: this.adminToken,
1604
+ headers: this.actorHeaders
1605
+ })
1606
+ );
1591
1607
  }
1592
1608
  listConfigRevisions(key, environment) {
1593
- return this.http.request({
1594
- method: "GET",
1595
- path: `/admin/config/${encodeURIComponent(key)}/revisions${envQuery(environment)}`,
1596
- token: this.adminToken
1597
- });
1609
+ return this.http.request(
1610
+ this.rebase({
1611
+ method: "GET",
1612
+ path: `/admin/config/${encodeURIComponent(key)}/revisions${envQuery(environment)}`,
1613
+ token: this.adminToken
1614
+ })
1615
+ );
1598
1616
  }
1599
1617
  rollbackConfig(key, input, environment) {
1600
- return this.http.request({
1601
- method: "POST",
1602
- path: `/admin/config/${encodeURIComponent(key)}/rollback${envQuery(environment)}`,
1603
- body: input,
1604
- token: this.adminToken,
1605
- headers: this.actorHeaders
1606
- });
1618
+ return this.http.request(
1619
+ this.rebase({
1620
+ method: "POST",
1621
+ path: `/admin/config/${encodeURIComponent(key)}/rollback${envQuery(environment)}`,
1622
+ body: input,
1623
+ token: this.adminToken,
1624
+ headers: this.actorHeaders
1625
+ })
1626
+ );
1607
1627
  }
1608
1628
  // ── Secrets (masked) ─────────────────────────────────────────────────────
1609
1629
  listSecrets(environment) {
1610
- return this.http.request({
1611
- method: "GET",
1612
- path: `/admin/secrets${envQuery(environment)}`,
1613
- token: this.adminToken
1614
- });
1630
+ return this.http.request(
1631
+ this.rebase({
1632
+ method: "GET",
1633
+ path: `/admin/secrets${envQuery(environment)}`,
1634
+ token: this.adminToken
1635
+ })
1636
+ );
1615
1637
  }
1616
1638
  getSecret(key, environment) {
1617
- return this.http.request({
1618
- method: "GET",
1619
- path: `/admin/secrets/${encodeURIComponent(key)}${envQuery(environment)}`,
1620
- token: this.adminToken
1621
- });
1639
+ return this.http.request(
1640
+ this.rebase({
1641
+ method: "GET",
1642
+ path: `/admin/secrets/${encodeURIComponent(key)}${envQuery(environment)}`,
1643
+ token: this.adminToken
1644
+ })
1645
+ );
1622
1646
  }
1623
1647
  setSecret(key, input, environment) {
1624
- return this.http.request({
1625
- method: "PUT",
1626
- path: `/admin/secrets/${encodeURIComponent(key)}${envQuery(environment)}`,
1627
- body: input,
1628
- token: this.adminToken,
1629
- headers: this.actorHeaders
1630
- });
1648
+ return this.http.request(
1649
+ this.rebase({
1650
+ method: "PUT",
1651
+ path: `/admin/secrets/${encodeURIComponent(key)}${envQuery(environment)}`,
1652
+ body: input,
1653
+ token: this.adminToken,
1654
+ headers: this.actorHeaders
1655
+ })
1656
+ );
1631
1657
  }
1632
1658
  deleteSecret(key, environment) {
1633
- return this.http.request({
1634
- method: "DELETE",
1635
- path: `/admin/secrets/${encodeURIComponent(key)}${envQuery(environment)}`,
1636
- token: this.adminToken,
1637
- headers: this.actorHeaders
1638
- });
1659
+ return this.http.request(
1660
+ this.rebase({
1661
+ method: "DELETE",
1662
+ path: `/admin/secrets/${encodeURIComponent(key)}${envQuery(environment)}`,
1663
+ token: this.adminToken,
1664
+ headers: this.actorHeaders
1665
+ })
1666
+ );
1639
1667
  }
1640
1668
  listSecretRevisions(key, environment) {
1641
- return this.http.request({
1642
- method: "GET",
1643
- path: `/admin/secrets/${encodeURIComponent(key)}/revisions${envQuery(environment)}`,
1644
- token: this.adminToken
1645
- });
1669
+ return this.http.request(
1670
+ this.rebase({
1671
+ method: "GET",
1672
+ path: `/admin/secrets/${encodeURIComponent(key)}/revisions${envQuery(environment)}`,
1673
+ token: this.adminToken
1674
+ })
1675
+ );
1646
1676
  }
1647
1677
  rollbackSecret(key, input, environment) {
1648
- return this.http.request({
1649
- method: "POST",
1650
- path: `/admin/secrets/${encodeURIComponent(key)}/rollback${envQuery(environment)}`,
1651
- body: input,
1652
- token: this.adminToken,
1653
- headers: this.actorHeaders
1654
- });
1678
+ return this.http.request(
1679
+ this.rebase({
1680
+ method: "POST",
1681
+ path: `/admin/secrets/${encodeURIComponent(key)}/rollback${envQuery(environment)}`,
1682
+ body: input,
1683
+ token: this.adminToken,
1684
+ headers: this.actorHeaders
1685
+ })
1686
+ );
1655
1687
  }
1656
1688
  // POST (not GET) so the decrypted value never lands in a URL or access log.
1657
1689
  revealSecret(key, environment) {
1690
+ return this.http.request(
1691
+ this.rebase({
1692
+ method: "POST",
1693
+ path: `/admin/secrets/${encodeURIComponent(key)}/reveal${envQuery(environment)}`,
1694
+ token: this.adminToken,
1695
+ headers: this.actorHeaders
1696
+ })
1697
+ );
1698
+ }
1699
+ };
1700
+
1701
+ // src/modules/admin.ts
1702
+ var AdminClient = class {
1703
+ http;
1704
+ adminToken;
1705
+ prefix;
1706
+ actorHeaders;
1707
+ constructor(opts) {
1708
+ this.http = new HttpClient(opts.baseUrl);
1709
+ this.adminToken = opts.adminToken;
1710
+ this.prefix = (opts.prefix ?? "/_admin").replace(/\/+$/, "");
1711
+ this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
1712
+ }
1713
+ get(suffix) {
1658
1714
  return this.http.request({
1659
- method: "POST",
1660
- path: `/admin/secrets/${encodeURIComponent(key)}/reveal${envQuery(environment)}`,
1715
+ method: "GET",
1716
+ path: `${this.prefix}${suffix}`,
1661
1717
  token: this.adminToken,
1662
1718
  headers: this.actorHeaders
1663
1719
  });
1664
1720
  }
1721
+ attention() {
1722
+ return this.get("");
1723
+ }
1724
+ manifest() {
1725
+ return this.get("/manifest");
1726
+ }
1727
+ doctor() {
1728
+ return this.get("/doctor");
1729
+ }
1730
+ config() {
1731
+ return this.get("/config");
1732
+ }
1733
+ routes() {
1734
+ return this.get("/routes");
1735
+ }
1736
+ tokens() {
1737
+ return this.get("/access/tokens");
1738
+ }
1739
+ adminLog(query = {}) {
1740
+ const q = new URLSearchParams();
1741
+ if (query.limit) q.set("limit", String(query.limit));
1742
+ if (query.before) q.set("before", query.before);
1743
+ const qs = q.toString();
1744
+ return this.get(`/activity/admin-log${qs ? `?${qs}` : ""}`);
1745
+ }
1665
1746
  };
1666
1747
 
1667
1748
  // src/modules/courier-admin.ts
1668
1749
  var CourierAdminClient = class {
1669
1750
  http;
1670
1751
  adminToken;
1752
+ prefix;
1671
1753
  actorHeaders;
1672
1754
  constructor(opts) {
1673
1755
  this.http = new HttpClient(opts.baseUrl);
1674
1756
  this.adminToken = opts.adminToken;
1757
+ this.prefix = opts.prefix?.replace(/\/+$/, "");
1675
1758
  this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
1676
1759
  }
1760
+ // The path literals stay on the legacy '/admin/...' so the route table and
1761
+ // the coverage gate read them; the prefix is applied here at request time.
1762
+ rebase(opts) {
1763
+ if (!this.prefix) return opts;
1764
+ return { ...opts, path: opts.path.replace(/^\/admin(?=\/|\?|$)/, this.prefix) };
1765
+ }
1677
1766
  listTemplates() {
1678
- return this.http.request({
1679
- method: "GET",
1680
- path: "/admin/templates",
1681
- token: this.adminToken
1682
- });
1767
+ return this.http.request(
1768
+ this.rebase({
1769
+ method: "GET",
1770
+ path: "/admin/templates",
1771
+ token: this.adminToken
1772
+ })
1773
+ );
1683
1774
  }
1684
1775
  getTemplate(type, locale) {
1685
1776
  const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
1686
- return this.http.request({
1687
- method: "GET",
1688
- path: `/admin/templates/${encodeURIComponent(type)}${q}`,
1689
- token: this.adminToken
1690
- });
1777
+ return this.http.request(
1778
+ this.rebase({
1779
+ method: "GET",
1780
+ path: `/admin/templates/${encodeURIComponent(type)}${q}`,
1781
+ token: this.adminToken
1782
+ })
1783
+ );
1691
1784
  }
1692
1785
  setTemplate(type, input, locale) {
1693
1786
  const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
1694
- return this.http.request({
1695
- method: "PUT",
1696
- path: `/admin/templates/${encodeURIComponent(type)}${q}`,
1697
- body: input,
1698
- token: this.adminToken,
1699
- headers: this.actorHeaders
1700
- });
1787
+ return this.http.request(
1788
+ this.rebase({
1789
+ method: "PUT",
1790
+ path: `/admin/templates/${encodeURIComponent(type)}${q}`,
1791
+ body: input,
1792
+ token: this.adminToken,
1793
+ headers: this.actorHeaders
1794
+ })
1795
+ );
1701
1796
  }
1702
1797
  deleteTemplate(type, locale) {
1703
1798
  const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
1704
- return this.http.request({
1705
- method: "DELETE",
1706
- path: `/admin/templates/${encodeURIComponent(type)}${q}`,
1707
- token: this.adminToken,
1708
- headers: this.actorHeaders
1709
- });
1799
+ return this.http.request(
1800
+ this.rebase({
1801
+ method: "DELETE",
1802
+ path: `/admin/templates/${encodeURIComponent(type)}${q}`,
1803
+ token: this.adminToken,
1804
+ headers: this.actorHeaders
1805
+ })
1806
+ );
1710
1807
  }
1711
1808
  listRevisions(type, locale) {
1712
1809
  const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
1713
- return this.http.request({
1714
- method: "GET",
1715
- path: `/admin/templates/${encodeURIComponent(type)}/revisions${q}`,
1716
- token: this.adminToken
1717
- });
1810
+ return this.http.request(
1811
+ this.rebase({
1812
+ method: "GET",
1813
+ path: `/admin/templates/${encodeURIComponent(type)}/revisions${q}`,
1814
+ token: this.adminToken
1815
+ })
1816
+ );
1718
1817
  }
1719
1818
  rollback(type, input, locale) {
1720
1819
  const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
1721
- return this.http.request({
1722
- method: "POST",
1723
- path: `/admin/templates/${encodeURIComponent(type)}/rollback${q}`,
1724
- body: input,
1725
- token: this.adminToken,
1726
- headers: this.actorHeaders
1727
- });
1820
+ return this.http.request(
1821
+ this.rebase({
1822
+ method: "POST",
1823
+ path: `/admin/templates/${encodeURIComponent(type)}/rollback${q}`,
1824
+ body: input,
1825
+ token: this.adminToken,
1826
+ headers: this.actorHeaders
1827
+ })
1828
+ );
1728
1829
  }
1729
1830
  };
1730
1831
 
@@ -1733,6 +1834,7 @@ function isMfaRequired(result) {
1733
1834
  return !("tokens" in result);
1734
1835
  }
1735
1836
  export {
1837
+ AdminClient,
1736
1838
  AuditClient,
1737
1839
  AuthClient,
1738
1840
  BillingClient,