@fonderie/client 0.24.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.
@@ -226,6 +226,7 @@ new BillingClient(http: HttpClient, tokens: TokenStore): BillingClient
226
226
  interface IConfigAdminClientOptions {
227
227
  baseUrl: string;
228
228
  adminToken: string;
229
+ prefix?: string;
229
230
  actor?: string;
230
231
  }
231
232
 
@@ -286,6 +287,7 @@ new AdminClient(opts: IAdminClientOptions): AdminClient
286
287
  interface ICourierAdminClientOptions {
287
288
  baseUrl: string;
288
289
  adminToken: string;
290
+ prefix?: string;
289
291
  actor?: string;
290
292
  }
291
293
 
package/dist/index.cjs CHANGED
@@ -1590,116 +1590,150 @@ function envQuery(environment) {
1590
1590
  var ConfigAdminClient = class {
1591
1591
  http;
1592
1592
  adminToken;
1593
+ prefix;
1593
1594
  actorHeaders;
1594
1595
  constructor(opts) {
1595
1596
  this.http = new HttpClient(opts.baseUrl);
1596
1597
  this.adminToken = opts.adminToken;
1598
+ this.prefix = opts.prefix?.replace(/\/+$/, "");
1597
1599
  this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
1598
1600
  }
1601
+ // The path literals stay on the legacy '/admin/...' so the route table and
1602
+ // the coverage gate read them; the prefix is applied here at request time.
1603
+ rebase(opts) {
1604
+ if (!this.prefix) return opts;
1605
+ return { ...opts, path: opts.path.replace(/^\/admin(?=\/|\?|$)/, this.prefix) };
1606
+ }
1599
1607
  // ── Config ───────────────────────────────────────────────────────────────
1600
1608
  listConfig(environment) {
1601
- return this.http.request({
1602
- method: "GET",
1603
- path: `/admin/config${envQuery(environment)}`,
1604
- token: this.adminToken
1605
- });
1609
+ return this.http.request(
1610
+ this.rebase({
1611
+ method: "GET",
1612
+ path: `/admin/config${envQuery(environment)}`,
1613
+ token: this.adminToken
1614
+ })
1615
+ );
1606
1616
  }
1607
1617
  getConfig(key, environment) {
1608
- return this.http.request({
1609
- method: "GET",
1610
- path: `/admin/config/${encodeURIComponent(key)}${envQuery(environment)}`,
1611
- token: this.adminToken
1612
- });
1618
+ return this.http.request(
1619
+ this.rebase({
1620
+ method: "GET",
1621
+ path: `/admin/config/${encodeURIComponent(key)}${envQuery(environment)}`,
1622
+ token: this.adminToken
1623
+ })
1624
+ );
1613
1625
  }
1614
1626
  setConfig(key, input, environment) {
1615
- return this.http.request({
1616
- method: "PUT",
1617
- path: `/admin/config/${encodeURIComponent(key)}${envQuery(environment)}`,
1618
- body: input,
1619
- token: this.adminToken,
1620
- headers: this.actorHeaders
1621
- });
1627
+ return this.http.request(
1628
+ this.rebase({
1629
+ method: "PUT",
1630
+ path: `/admin/config/${encodeURIComponent(key)}${envQuery(environment)}`,
1631
+ body: input,
1632
+ token: this.adminToken,
1633
+ headers: this.actorHeaders
1634
+ })
1635
+ );
1622
1636
  }
1623
1637
  deleteConfig(key, environment) {
1624
- return this.http.request({
1625
- method: "DELETE",
1626
- path: `/admin/config/${encodeURIComponent(key)}${envQuery(environment)}`,
1627
- token: this.adminToken,
1628
- headers: this.actorHeaders
1629
- });
1638
+ return this.http.request(
1639
+ this.rebase({
1640
+ method: "DELETE",
1641
+ path: `/admin/config/${encodeURIComponent(key)}${envQuery(environment)}`,
1642
+ token: this.adminToken,
1643
+ headers: this.actorHeaders
1644
+ })
1645
+ );
1630
1646
  }
1631
1647
  listConfigRevisions(key, environment) {
1632
- return this.http.request({
1633
- method: "GET",
1634
- path: `/admin/config/${encodeURIComponent(key)}/revisions${envQuery(environment)}`,
1635
- token: this.adminToken
1636
- });
1648
+ return this.http.request(
1649
+ this.rebase({
1650
+ method: "GET",
1651
+ path: `/admin/config/${encodeURIComponent(key)}/revisions${envQuery(environment)}`,
1652
+ token: this.adminToken
1653
+ })
1654
+ );
1637
1655
  }
1638
1656
  rollbackConfig(key, input, environment) {
1639
- return this.http.request({
1640
- method: "POST",
1641
- path: `/admin/config/${encodeURIComponent(key)}/rollback${envQuery(environment)}`,
1642
- body: input,
1643
- token: this.adminToken,
1644
- headers: this.actorHeaders
1645
- });
1657
+ return this.http.request(
1658
+ this.rebase({
1659
+ method: "POST",
1660
+ path: `/admin/config/${encodeURIComponent(key)}/rollback${envQuery(environment)}`,
1661
+ body: input,
1662
+ token: this.adminToken,
1663
+ headers: this.actorHeaders
1664
+ })
1665
+ );
1646
1666
  }
1647
1667
  // ── Secrets (masked) ─────────────────────────────────────────────────────
1648
1668
  listSecrets(environment) {
1649
- return this.http.request({
1650
- method: "GET",
1651
- path: `/admin/secrets${envQuery(environment)}`,
1652
- token: this.adminToken
1653
- });
1669
+ return this.http.request(
1670
+ this.rebase({
1671
+ method: "GET",
1672
+ path: `/admin/secrets${envQuery(environment)}`,
1673
+ token: this.adminToken
1674
+ })
1675
+ );
1654
1676
  }
1655
1677
  getSecret(key, environment) {
1656
- return this.http.request({
1657
- method: "GET",
1658
- path: `/admin/secrets/${encodeURIComponent(key)}${envQuery(environment)}`,
1659
- token: this.adminToken
1660
- });
1678
+ return this.http.request(
1679
+ this.rebase({
1680
+ method: "GET",
1681
+ path: `/admin/secrets/${encodeURIComponent(key)}${envQuery(environment)}`,
1682
+ token: this.adminToken
1683
+ })
1684
+ );
1661
1685
  }
1662
1686
  setSecret(key, input, environment) {
1663
- return this.http.request({
1664
- method: "PUT",
1665
- path: `/admin/secrets/${encodeURIComponent(key)}${envQuery(environment)}`,
1666
- body: input,
1667
- token: this.adminToken,
1668
- headers: this.actorHeaders
1669
- });
1687
+ return this.http.request(
1688
+ this.rebase({
1689
+ method: "PUT",
1690
+ path: `/admin/secrets/${encodeURIComponent(key)}${envQuery(environment)}`,
1691
+ body: input,
1692
+ token: this.adminToken,
1693
+ headers: this.actorHeaders
1694
+ })
1695
+ );
1670
1696
  }
1671
1697
  deleteSecret(key, environment) {
1672
- return this.http.request({
1673
- method: "DELETE",
1674
- path: `/admin/secrets/${encodeURIComponent(key)}${envQuery(environment)}`,
1675
- token: this.adminToken,
1676
- headers: this.actorHeaders
1677
- });
1698
+ return this.http.request(
1699
+ this.rebase({
1700
+ method: "DELETE",
1701
+ path: `/admin/secrets/${encodeURIComponent(key)}${envQuery(environment)}`,
1702
+ token: this.adminToken,
1703
+ headers: this.actorHeaders
1704
+ })
1705
+ );
1678
1706
  }
1679
1707
  listSecretRevisions(key, environment) {
1680
- return this.http.request({
1681
- method: "GET",
1682
- path: `/admin/secrets/${encodeURIComponent(key)}/revisions${envQuery(environment)}`,
1683
- token: this.adminToken
1684
- });
1708
+ return this.http.request(
1709
+ this.rebase({
1710
+ method: "GET",
1711
+ path: `/admin/secrets/${encodeURIComponent(key)}/revisions${envQuery(environment)}`,
1712
+ token: this.adminToken
1713
+ })
1714
+ );
1685
1715
  }
1686
1716
  rollbackSecret(key, input, environment) {
1687
- return this.http.request({
1688
- method: "POST",
1689
- path: `/admin/secrets/${encodeURIComponent(key)}/rollback${envQuery(environment)}`,
1690
- body: input,
1691
- token: this.adminToken,
1692
- headers: this.actorHeaders
1693
- });
1717
+ return this.http.request(
1718
+ this.rebase({
1719
+ method: "POST",
1720
+ path: `/admin/secrets/${encodeURIComponent(key)}/rollback${envQuery(environment)}`,
1721
+ body: input,
1722
+ token: this.adminToken,
1723
+ headers: this.actorHeaders
1724
+ })
1725
+ );
1694
1726
  }
1695
1727
  // POST (not GET) so the decrypted value never lands in a URL or access log.
1696
1728
  revealSecret(key, environment) {
1697
- return this.http.request({
1698
- method: "POST",
1699
- path: `/admin/secrets/${encodeURIComponent(key)}/reveal${envQuery(environment)}`,
1700
- token: this.adminToken,
1701
- headers: this.actorHeaders
1702
- });
1729
+ return this.http.request(
1730
+ this.rebase({
1731
+ method: "POST",
1732
+ path: `/admin/secrets/${encodeURIComponent(key)}/reveal${envQuery(environment)}`,
1733
+ token: this.adminToken,
1734
+ headers: this.actorHeaders
1735
+ })
1736
+ );
1703
1737
  }
1704
1738
  };
1705
1739
 
@@ -1754,63 +1788,83 @@ var AdminClient = class {
1754
1788
  var CourierAdminClient = class {
1755
1789
  http;
1756
1790
  adminToken;
1791
+ prefix;
1757
1792
  actorHeaders;
1758
1793
  constructor(opts) {
1759
1794
  this.http = new HttpClient(opts.baseUrl);
1760
1795
  this.adminToken = opts.adminToken;
1796
+ this.prefix = opts.prefix?.replace(/\/+$/, "");
1761
1797
  this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
1762
1798
  }
1799
+ // The path literals stay on the legacy '/admin/...' so the route table and
1800
+ // the coverage gate read them; the prefix is applied here at request time.
1801
+ rebase(opts) {
1802
+ if (!this.prefix) return opts;
1803
+ return { ...opts, path: opts.path.replace(/^\/admin(?=\/|\?|$)/, this.prefix) };
1804
+ }
1763
1805
  listTemplates() {
1764
- return this.http.request({
1765
- method: "GET",
1766
- path: "/admin/templates",
1767
- token: this.adminToken
1768
- });
1806
+ return this.http.request(
1807
+ this.rebase({
1808
+ method: "GET",
1809
+ path: "/admin/templates",
1810
+ token: this.adminToken
1811
+ })
1812
+ );
1769
1813
  }
1770
1814
  getTemplate(type, locale) {
1771
1815
  const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
1772
- return this.http.request({
1773
- method: "GET",
1774
- path: `/admin/templates/${encodeURIComponent(type)}${q}`,
1775
- token: this.adminToken
1776
- });
1816
+ return this.http.request(
1817
+ this.rebase({
1818
+ method: "GET",
1819
+ path: `/admin/templates/${encodeURIComponent(type)}${q}`,
1820
+ token: this.adminToken
1821
+ })
1822
+ );
1777
1823
  }
1778
1824
  setTemplate(type, input, locale) {
1779
1825
  const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
1780
- return this.http.request({
1781
- method: "PUT",
1782
- path: `/admin/templates/${encodeURIComponent(type)}${q}`,
1783
- body: input,
1784
- token: this.adminToken,
1785
- headers: this.actorHeaders
1786
- });
1826
+ return this.http.request(
1827
+ this.rebase({
1828
+ method: "PUT",
1829
+ path: `/admin/templates/${encodeURIComponent(type)}${q}`,
1830
+ body: input,
1831
+ token: this.adminToken,
1832
+ headers: this.actorHeaders
1833
+ })
1834
+ );
1787
1835
  }
1788
1836
  deleteTemplate(type, locale) {
1789
1837
  const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
1790
- return this.http.request({
1791
- method: "DELETE",
1792
- path: `/admin/templates/${encodeURIComponent(type)}${q}`,
1793
- token: this.adminToken,
1794
- headers: this.actorHeaders
1795
- });
1838
+ return this.http.request(
1839
+ this.rebase({
1840
+ method: "DELETE",
1841
+ path: `/admin/templates/${encodeURIComponent(type)}${q}`,
1842
+ token: this.adminToken,
1843
+ headers: this.actorHeaders
1844
+ })
1845
+ );
1796
1846
  }
1797
1847
  listRevisions(type, locale) {
1798
1848
  const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
1799
- return this.http.request({
1800
- method: "GET",
1801
- path: `/admin/templates/${encodeURIComponent(type)}/revisions${q}`,
1802
- token: this.adminToken
1803
- });
1849
+ return this.http.request(
1850
+ this.rebase({
1851
+ method: "GET",
1852
+ path: `/admin/templates/${encodeURIComponent(type)}/revisions${q}`,
1853
+ token: this.adminToken
1854
+ })
1855
+ );
1804
1856
  }
1805
1857
  rollback(type, input, locale) {
1806
1858
  const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
1807
- return this.http.request({
1808
- method: "POST",
1809
- path: `/admin/templates/${encodeURIComponent(type)}/rollback${q}`,
1810
- body: input,
1811
- token: this.adminToken,
1812
- headers: this.actorHeaders
1813
- });
1859
+ return this.http.request(
1860
+ this.rebase({
1861
+ method: "POST",
1862
+ path: `/admin/templates/${encodeURIComponent(type)}/rollback${q}`,
1863
+ body: input,
1864
+ token: this.adminToken,
1865
+ headers: this.actorHeaders
1866
+ })
1867
+ );
1814
1868
  }
1815
1869
  };
1816
1870