@niledatabase/server 5.0.0-alpha.12 → 5.0.0-alpha.14

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
@@ -2512,10 +2512,23 @@ async function obtainCsrf(config, rawResponse = false) {
2512
2512
  var Users = class {
2513
2513
  #config;
2514
2514
  #logger;
2515
+ /**
2516
+ * Create a new Users helper.
2517
+ * @param config - The configuration used for requests.
2518
+ */
2515
2519
  constructor(config) {
2516
2520
  this.#config = config;
2517
2521
  this.#logger = config.logger("[me]");
2518
2522
  }
2523
+ /**
2524
+ * Update the current user via `PUT /api/me`.
2525
+ *
2526
+ * The OpenAPI description for this endpoint can be found in
2527
+ * `packages/server/src/api/routes/me/index.ts` under `updateSelf`.
2528
+ *
2529
+ * @param req - Partial user fields to send.
2530
+ * @param [rawResponse] - When `true`, return the raw {@link Response}.
2531
+ */
2519
2532
  async updateSelf(req, rawResponse) {
2520
2533
  const res = await fetchMe(this.#config, "PUT", JSON.stringify(req));
2521
2534
  if (rawResponse) {
@@ -2527,6 +2540,13 @@ var Users = class {
2527
2540
  return res;
2528
2541
  }
2529
2542
  }
2543
+ /**
2544
+ * Remove the current user using `DELETE /api/me`.
2545
+ *
2546
+ * After the request the authentication headers are cleared with
2547
+ * {@link updateHeaders}. The OpenAPI docs for this route are in
2548
+ * `packages/server/src/api/routes/me/index.ts` under `removeSelf`.
2549
+ */
2530
2550
  async removeSelf() {
2531
2551
  const me = await this.getSelf();
2532
2552
  if ("id" in me) {
@@ -2607,6 +2627,11 @@ var Tenants = class {
2607
2627
  constructor(config) {
2608
2628
  this.#config = config;
2609
2629
  }
2630
+ /**
2631
+ * Create a new tenant using `POST /api/tenants`.
2632
+ * See `packages/server/src/api/routes/tenants/POST.ts` for the
2633
+ * `createTenant` operation definition.
2634
+ */
2610
2635
  async create(req, rawResponse) {
2611
2636
  let res;
2612
2637
  if (typeof req === "string") {
@@ -2627,6 +2652,11 @@ var Tenants = class {
2627
2652
  return res;
2628
2653
  }
2629
2654
  }
2655
+ /**
2656
+ * Remove a tenant via `DELETE /api/tenants/{tenantId}`.
2657
+ *
2658
+ * @param req - The tenant to remove or context containing the id.
2659
+ */
2630
2660
  async delete(req) {
2631
2661
  if (typeof req === "string") {
2632
2662
  this.#config.tenantId = req;
@@ -2637,6 +2667,12 @@ var Tenants = class {
2637
2667
  const res = await fetchTenant(this.#config, "DELETE");
2638
2668
  return res;
2639
2669
  }
2670
+ /**
2671
+ * Fetch details for a tenant using `GET /api/tenants/{tenantId}`.
2672
+ *
2673
+ * @param req - Tenant identifier or context.
2674
+ * @param [rawResponse] - When true, return the raw {@link Response}.
2675
+ */
2640
2676
  async get(req, rawResponse) {
2641
2677
  if (typeof req === "string") {
2642
2678
  this.#config.tenantId = req;
@@ -2671,6 +2707,10 @@ var Tenants = class {
2671
2707
  return res;
2672
2708
  }
2673
2709
  }
2710
+ /**
2711
+ * List tenants for the current user via `GET /api/tenants`.
2712
+ * See `packages/server/src/api/routes/tenants/GET.ts` for details.
2713
+ */
2674
2714
  async list(req) {
2675
2715
  const res = await fetchTenantsByUser(this.#config);
2676
2716
  if (req === true) {
@@ -2682,6 +2722,11 @@ var Tenants = class {
2682
2722
  return res;
2683
2723
  }
2684
2724
  }
2725
+ /**
2726
+ * Leave the current tenant using `DELETE /api/tenants/{tenantId}/users/{userId}`.
2727
+ *
2728
+ * @param [req] - Optionally specify the tenant id to leave.
2729
+ */
2685
2730
  async leaveTenant(req) {
2686
2731
  const me = await fetchMe(this.#config);
2687
2732
  try {
@@ -2707,6 +2752,12 @@ var Tenants = class {
2707
2752
  const res = await fetchTenantUser(this.#config, "PUT");
2708
2753
  return responseHandler(res, rawResponse);
2709
2754
  }
2755
+ /**
2756
+ * Remove a user from a tenant with `DELETE /api/tenants/{tenantId}/users/{userId}`.
2757
+ *
2758
+ * @param req - User and tenant identifiers or context.
2759
+ * @param [rawResponse] - When true, return the raw {@link Response}.
2760
+ */
2710
2761
  async removeMember(req, rawResponse) {
2711
2762
  this.#handleContext(req);
2712
2763
  const res = await fetchTenantUser(this.#config, "DELETE");
@@ -2720,6 +2771,9 @@ var Tenants = class {
2720
2771
  rawResponse || typeof req === "boolean" && req
2721
2772
  );
2722
2773
  }
2774
+ /**
2775
+ * List invites for the current tenant via `GET /api/tenants/{tenantId}/invites`.
2776
+ */
2723
2777
  async invites() {
2724
2778
  const res = await fetchInvites(this.#config);
2725
2779
  return responseHandler(res);
@@ -2757,6 +2811,12 @@ var Tenants = class {
2757
2811
  );
2758
2812
  return responseHandler(res, rawResponse);
2759
2813
  }
2814
+ /**
2815
+ * Accept an invite using `PUT /api/tenants/{tenantId}/invite`.
2816
+ *
2817
+ * @param req - Identifier and token from the invite email.
2818
+ * @param [rawResponse] - When true, return the raw {@link Response}.
2819
+ */
2760
2820
  async acceptInvite(req, rawResponse) {
2761
2821
  if (!req) {
2762
2822
  throw new Error("The identifier and token are required.");
@@ -2775,6 +2835,11 @@ var Tenants = class {
2775
2835
  );
2776
2836
  return responseHandler(res, rawResponse);
2777
2837
  }
2838
+ /**
2839
+ * Delete a pending invite using `DELETE /api/tenants/{tenantId}/invite/{inviteId}`.
2840
+ *
2841
+ * @param req - Identifier of the invite to remove.
2842
+ */
2778
2843
  async deleteInvite(req) {
2779
2844
  let id = "";
2780
2845
  if (typeof req === "object") {