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

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.mjs CHANGED
@@ -2506,10 +2506,23 @@ async function obtainCsrf(config, rawResponse = false) {
2506
2506
  var Users = class {
2507
2507
  #config;
2508
2508
  #logger;
2509
+ /**
2510
+ * Create a new Users helper.
2511
+ * @param config - The configuration used for requests.
2512
+ */
2509
2513
  constructor(config) {
2510
2514
  this.#config = config;
2511
2515
  this.#logger = config.logger("[me]");
2512
2516
  }
2517
+ /**
2518
+ * Update the current user via `PUT /api/me`.
2519
+ *
2520
+ * The OpenAPI description for this endpoint can be found in
2521
+ * `packages/server/src/api/routes/me/index.ts` under `updateSelf`.
2522
+ *
2523
+ * @param req - Partial user fields to send.
2524
+ * @param [rawResponse] - When `true`, return the raw {@link Response}.
2525
+ */
2513
2526
  async updateSelf(req, rawResponse) {
2514
2527
  const res = await fetchMe(this.#config, "PUT", JSON.stringify(req));
2515
2528
  if (rawResponse) {
@@ -2521,6 +2534,13 @@ var Users = class {
2521
2534
  return res;
2522
2535
  }
2523
2536
  }
2537
+ /**
2538
+ * Remove the current user using `DELETE /api/me`.
2539
+ *
2540
+ * After the request the authentication headers are cleared with
2541
+ * {@link updateHeaders}. The OpenAPI docs for this route are in
2542
+ * `packages/server/src/api/routes/me/index.ts` under `removeSelf`.
2543
+ */
2524
2544
  async removeSelf() {
2525
2545
  const me = await this.getSelf();
2526
2546
  if ("id" in me) {
@@ -2601,6 +2621,11 @@ var Tenants = class {
2601
2621
  constructor(config) {
2602
2622
  this.#config = config;
2603
2623
  }
2624
+ /**
2625
+ * Create a new tenant using `POST /api/tenants`.
2626
+ * See `packages/server/src/api/routes/tenants/POST.ts` for the
2627
+ * `createTenant` operation definition.
2628
+ */
2604
2629
  async create(req, rawResponse) {
2605
2630
  let res;
2606
2631
  if (typeof req === "string") {
@@ -2621,6 +2646,11 @@ var Tenants = class {
2621
2646
  return res;
2622
2647
  }
2623
2648
  }
2649
+ /**
2650
+ * Remove a tenant via `DELETE /api/tenants/{tenantId}`.
2651
+ *
2652
+ * @param req - The tenant to remove or context containing the id.
2653
+ */
2624
2654
  async delete(req) {
2625
2655
  if (typeof req === "string") {
2626
2656
  this.#config.tenantId = req;
@@ -2631,6 +2661,12 @@ var Tenants = class {
2631
2661
  const res = await fetchTenant(this.#config, "DELETE");
2632
2662
  return res;
2633
2663
  }
2664
+ /**
2665
+ * Fetch details for a tenant using `GET /api/tenants/{tenantId}`.
2666
+ *
2667
+ * @param req - Tenant identifier or context.
2668
+ * @param [rawResponse] - When true, return the raw {@link Response}.
2669
+ */
2634
2670
  async get(req, rawResponse) {
2635
2671
  if (typeof req === "string") {
2636
2672
  this.#config.tenantId = req;
@@ -2665,6 +2701,10 @@ var Tenants = class {
2665
2701
  return res;
2666
2702
  }
2667
2703
  }
2704
+ /**
2705
+ * List tenants for the current user via `GET /api/tenants`.
2706
+ * See `packages/server/src/api/routes/tenants/GET.ts` for details.
2707
+ */
2668
2708
  async list(req) {
2669
2709
  const res = await fetchTenantsByUser(this.#config);
2670
2710
  if (req === true) {
@@ -2676,6 +2716,11 @@ var Tenants = class {
2676
2716
  return res;
2677
2717
  }
2678
2718
  }
2719
+ /**
2720
+ * Leave the current tenant using `DELETE /api/tenants/{tenantId}/users/{userId}`.
2721
+ *
2722
+ * @param [req] - Optionally specify the tenant id to leave.
2723
+ */
2679
2724
  async leaveTenant(req) {
2680
2725
  const me = await fetchMe(this.#config);
2681
2726
  try {
@@ -2701,6 +2746,12 @@ var Tenants = class {
2701
2746
  const res = await fetchTenantUser(this.#config, "PUT");
2702
2747
  return responseHandler(res, rawResponse);
2703
2748
  }
2749
+ /**
2750
+ * Remove a user from a tenant with `DELETE /api/tenants/{tenantId}/users/{userId}`.
2751
+ *
2752
+ * @param req - User and tenant identifiers or context.
2753
+ * @param [rawResponse] - When true, return the raw {@link Response}.
2754
+ */
2704
2755
  async removeMember(req, rawResponse) {
2705
2756
  this.#handleContext(req);
2706
2757
  const res = await fetchTenantUser(this.#config, "DELETE");
@@ -2714,6 +2765,9 @@ var Tenants = class {
2714
2765
  rawResponse || typeof req === "boolean" && req
2715
2766
  );
2716
2767
  }
2768
+ /**
2769
+ * List invites for the current tenant via `GET /api/tenants/{tenantId}/invites`.
2770
+ */
2717
2771
  async invites() {
2718
2772
  const res = await fetchInvites(this.#config);
2719
2773
  return responseHandler(res);
@@ -2751,6 +2805,12 @@ var Tenants = class {
2751
2805
  );
2752
2806
  return responseHandler(res, rawResponse);
2753
2807
  }
2808
+ /**
2809
+ * Accept an invite using `PUT /api/tenants/{tenantId}/invite`.
2810
+ *
2811
+ * @param req - Identifier and token from the invite email.
2812
+ * @param [rawResponse] - When true, return the raw {@link Response}.
2813
+ */
2754
2814
  async acceptInvite(req, rawResponse) {
2755
2815
  if (!req) {
2756
2816
  throw new Error("The identifier and token are required.");
@@ -2769,6 +2829,11 @@ var Tenants = class {
2769
2829
  );
2770
2830
  return responseHandler(res, rawResponse);
2771
2831
  }
2832
+ /**
2833
+ * Delete a pending invite using `DELETE /api/tenants/{tenantId}/invite/{inviteId}`.
2834
+ *
2835
+ * @param req - Identifier of the invite to remove.
2836
+ */
2772
2837
  async deleteInvite(req) {
2773
2838
  let id = "";
2774
2839
  if (typeof req === "object") {