@hoststack.dev/sdk 0.8.1 → 0.9.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/dist/index.cjs CHANGED
@@ -314,7 +314,8 @@ var DomainsResource = class {
314
314
  /** Add a custom domain. */
315
315
  async add(teamId, data) {
316
316
  const tid = await this.client.resolveId(teamId, { kind: "team" });
317
- return this.client.request("POST", `/api/domains/${tid}`, data);
317
+ const sid = await this.client.resolveId(data.serviceId, { kind: "service", teamId: tid });
318
+ return this.client.request("POST", `/api/domains/${tid}`, { ...data, serviceId: sid });
318
319
  }
319
320
  /** Update a domain. */
320
321
  async update(teamId, domainId, data) {
@@ -566,12 +567,12 @@ function normalizeEntries(logs) {
566
567
  return logs;
567
568
  }
568
569
  function sleep(ms, signal) {
569
- return new Promise((resolve, reject) => {
570
+ return new Promise((resolve) => {
570
571
  const timer = setTimeout(resolve, ms);
571
572
  if (signal) {
572
573
  signal.addEventListener("abort", () => {
573
574
  clearTimeout(timer);
574
- reject(new DOMException("Aborted", "AbortError"));
575
+ resolve();
575
576
  });
576
577
  }
577
578
  });
@@ -728,6 +729,22 @@ var ServicesResource = class {
728
729
  }
729
730
  };
730
731
 
732
+ // src/resources/teams.ts
733
+ var TeamsResource = class {
734
+ constructor(client) {
735
+ this.client = client;
736
+ }
737
+ /**
738
+ * List the teams the authenticated principal can access.
739
+ *
740
+ * Session auth: all teams the user belongs to.
741
+ * API-key auth: the single team the key is bound to.
742
+ */
743
+ async list() {
744
+ return this.client.request("GET", "/api/auth/teams");
745
+ }
746
+ };
747
+
731
748
  // src/resources/volumes.ts
732
749
  var VolumesResource = class {
733
750
  constructor(client) {
@@ -817,6 +834,8 @@ var HostStack = class {
817
834
  * failures, restart loops, ACME failures, git auth losses, etc.
818
835
  */
819
836
  notifications;
837
+ /** List the teams this API key (or session) can access. */
838
+ teams;
820
839
  constructor(options) {
821
840
  if (!options.apiKey) {
822
841
  throw new Error("apiKey is required");
@@ -833,6 +852,15 @@ var HostStack = class {
833
852
  this.cron = new CronResource(this);
834
853
  this.volumes = new VolumesResource(this);
835
854
  this.notifications = new NotificationsResource(this);
855
+ this.teams = new TeamsResource(this);
856
+ }
857
+ /**
858
+ * Identify the authenticated principal. For API-key auth, `user` is
859
+ * `null` and `team` is the team the key is bound to; `apiKey` carries
860
+ * the key's permission scope (read or full).
861
+ */
862
+ async me() {
863
+ return this.request("GET", "/api/auth/me");
836
864
  }
837
865
  /**
838
866
  * Make an authenticated request to the HostStack API.
@@ -986,22 +1014,14 @@ function cacheScope(scope) {
986
1014
  function buildPaginationQuery(params) {
987
1015
  if (!params) return "";
988
1016
  const qs = new URLSearchParams();
989
- if (params.limit !== void 0) qs.set("limit", String(params.limit));
990
- if (params.offset !== void 0) qs.set("offset", String(params.offset));
1017
+ if (params.page !== void 0) qs.set("page", String(params.page));
1018
+ if (params.perPage !== void 0) qs.set("perPage", String(params.perPage));
1019
+ if (params.search !== void 0) qs.set("search", params.search);
1020
+ if (params.sortBy !== void 0) qs.set("sortBy", params.sortBy);
1021
+ if (params.sortOrder !== void 0) qs.set("sortOrder", params.sortOrder);
991
1022
  const str = qs.toString();
992
1023
  return str ? `?${str}` : "";
993
1024
  }
994
- function wrapArray(items, params) {
995
- const limit = params?.limit ?? items.length;
996
- const offset = params?.offset ?? 0;
997
- return {
998
- items,
999
- total: items.length,
1000
- limit,
1001
- offset,
1002
- hasMore: false
1003
- };
1004
- }
1005
1025
 
1006
1026
  exports.AuthenticationError = AuthenticationError;
1007
1027
  exports.ConflictError = ConflictError;
@@ -1011,6 +1031,5 @@ exports.HostStackError = HostStackError;
1011
1031
  exports.NotFoundError = NotFoundError;
1012
1032
  exports.RateLimitError = RateLimitError;
1013
1033
  exports.buildPaginationQuery = buildPaginationQuery;
1014
- exports.wrapArray = wrapArray;
1015
1034
  //# sourceMappingURL=index.cjs.map
1016
1035
  //# sourceMappingURL=index.cjs.map