@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.
package/dist/index.d.cts CHANGED
@@ -1260,13 +1260,16 @@ interface IRollbackInput {
1260
1260
  interface IConfigAdminClientOptions {
1261
1261
  baseUrl: string;
1262
1262
  adminToken: string;
1263
+ prefix?: string;
1263
1264
  actor?: string;
1264
1265
  }
1265
1266
  declare class ConfigAdminClient {
1266
1267
  private http;
1267
1268
  private adminToken;
1269
+ private prefix;
1268
1270
  private actorHeaders;
1269
1271
  constructor(opts: IConfigAdminClientOptions);
1272
+ private rebase;
1270
1273
  listConfig(environment?: string): Promise<IApiResponse<IConfigEntry[]>>;
1271
1274
  getConfig(key: string, environment?: string): Promise<IApiResponse<IConfigEntry>>;
1272
1275
  setConfig(key: string, input: ISetConfigInput, environment?: string): Promise<IApiResponse<IConfigEntry>>;
@@ -1321,13 +1324,16 @@ interface IRollbackTemplateInput {
1321
1324
  interface ICourierAdminClientOptions {
1322
1325
  baseUrl: string;
1323
1326
  adminToken: string;
1327
+ prefix?: string;
1324
1328
  actor?: string;
1325
1329
  }
1326
1330
  declare class CourierAdminClient {
1327
1331
  private http;
1328
1332
  private adminToken;
1333
+ private prefix;
1329
1334
  private actorHeaders;
1330
1335
  constructor(opts: ICourierAdminClientOptions);
1336
+ private rebase;
1331
1337
  listTemplates(): Promise<IApiResponse<ITemplateEntry[]>>;
1332
1338
  getTemplate(type: string, locale?: string | null): Promise<IApiResponse<ITemplateEntry>>;
1333
1339
  setTemplate(type: string, input: ISetTemplateInput, locale?: string | null): Promise<IApiResponse<ITemplateEntry>>;
package/dist/index.d.ts CHANGED
@@ -1260,13 +1260,16 @@ interface IRollbackInput {
1260
1260
  interface IConfigAdminClientOptions {
1261
1261
  baseUrl: string;
1262
1262
  adminToken: string;
1263
+ prefix?: string;
1263
1264
  actor?: string;
1264
1265
  }
1265
1266
  declare class ConfigAdminClient {
1266
1267
  private http;
1267
1268
  private adminToken;
1269
+ private prefix;
1268
1270
  private actorHeaders;
1269
1271
  constructor(opts: IConfigAdminClientOptions);
1272
+ private rebase;
1270
1273
  listConfig(environment?: string): Promise<IApiResponse<IConfigEntry[]>>;
1271
1274
  getConfig(key: string, environment?: string): Promise<IApiResponse<IConfigEntry>>;
1272
1275
  setConfig(key: string, input: ISetConfigInput, environment?: string): Promise<IApiResponse<IConfigEntry>>;
@@ -1321,13 +1324,16 @@ interface IRollbackTemplateInput {
1321
1324
  interface ICourierAdminClientOptions {
1322
1325
  baseUrl: string;
1323
1326
  adminToken: string;
1327
+ prefix?: string;
1324
1328
  actor?: string;
1325
1329
  }
1326
1330
  declare class CourierAdminClient {
1327
1331
  private http;
1328
1332
  private adminToken;
1333
+ private prefix;
1329
1334
  private actorHeaders;
1330
1335
  constructor(opts: ICourierAdminClientOptions);
1336
+ private rebase;
1331
1337
  listTemplates(): Promise<IApiResponse<ITemplateEntry[]>>;
1332
1338
  getTemplate(type: string, locale?: string | null): Promise<IApiResponse<ITemplateEntry>>;
1333
1339
  setTemplate(type: string, input: ISetTemplateInput, locale?: string | null): Promise<IApiResponse<ITemplateEntry>>;
package/dist/index.js CHANGED
@@ -1551,116 +1551,150 @@ 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) {
1658
- return this.http.request({
1659
- method: "POST",
1660
- path: `/admin/secrets/${encodeURIComponent(key)}/reveal${envQuery(environment)}`,
1661
- token: this.adminToken,
1662
- headers: this.actorHeaders
1663
- });
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
+ );
1664
1698
  }
1665
1699
  };
1666
1700
 
@@ -1715,63 +1749,83 @@ var AdminClient = class {
1715
1749
  var CourierAdminClient = class {
1716
1750
  http;
1717
1751
  adminToken;
1752
+ prefix;
1718
1753
  actorHeaders;
1719
1754
  constructor(opts) {
1720
1755
  this.http = new HttpClient(opts.baseUrl);
1721
1756
  this.adminToken = opts.adminToken;
1757
+ this.prefix = opts.prefix?.replace(/\/+$/, "");
1722
1758
  this.actorHeaders = opts.actor ? { "X-Actor": opts.actor } : void 0;
1723
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
+ }
1724
1766
  listTemplates() {
1725
- return this.http.request({
1726
- method: "GET",
1727
- path: "/admin/templates",
1728
- token: this.adminToken
1729
- });
1767
+ return this.http.request(
1768
+ this.rebase({
1769
+ method: "GET",
1770
+ path: "/admin/templates",
1771
+ token: this.adminToken
1772
+ })
1773
+ );
1730
1774
  }
1731
1775
  getTemplate(type, locale) {
1732
1776
  const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
1733
- return this.http.request({
1734
- method: "GET",
1735
- path: `/admin/templates/${encodeURIComponent(type)}${q}`,
1736
- token: this.adminToken
1737
- });
1777
+ return this.http.request(
1778
+ this.rebase({
1779
+ method: "GET",
1780
+ path: `/admin/templates/${encodeURIComponent(type)}${q}`,
1781
+ token: this.adminToken
1782
+ })
1783
+ );
1738
1784
  }
1739
1785
  setTemplate(type, input, locale) {
1740
1786
  const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
1741
- return this.http.request({
1742
- method: "PUT",
1743
- path: `/admin/templates/${encodeURIComponent(type)}${q}`,
1744
- body: input,
1745
- token: this.adminToken,
1746
- headers: this.actorHeaders
1747
- });
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
+ );
1748
1796
  }
1749
1797
  deleteTemplate(type, locale) {
1750
1798
  const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
1751
- return this.http.request({
1752
- method: "DELETE",
1753
- path: `/admin/templates/${encodeURIComponent(type)}${q}`,
1754
- token: this.adminToken,
1755
- headers: this.actorHeaders
1756
- });
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
+ );
1757
1807
  }
1758
1808
  listRevisions(type, locale) {
1759
1809
  const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
1760
- return this.http.request({
1761
- method: "GET",
1762
- path: `/admin/templates/${encodeURIComponent(type)}/revisions${q}`,
1763
- token: this.adminToken
1764
- });
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
+ );
1765
1817
  }
1766
1818
  rollback(type, input, locale) {
1767
1819
  const q = locale ? `?locale=${encodeURIComponent(locale)}` : "";
1768
- return this.http.request({
1769
- method: "POST",
1770
- path: `/admin/templates/${encodeURIComponent(type)}/rollback${q}`,
1771
- body: input,
1772
- token: this.adminToken,
1773
- headers: this.actorHeaders
1774
- });
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
+ );
1775
1829
  }
1776
1830
  };
1777
1831