@mastra/client-js 1.29.1-alpha.4 → 1.30.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.js CHANGED
@@ -297,6 +297,14 @@ function requestContextQueryString(requestContext, delimiter = "?") {
297
297
  const queryString = searchParams.toString();
298
298
  return queryString ? `${delimiter}${queryString}` : "";
299
299
  }
300
+ function buildTenancyQuery(tenancy) {
301
+ if (!tenancy) return "";
302
+ const searchParams = new URLSearchParams();
303
+ if (tenancy.organizationId) searchParams.set("organizationId", tenancy.organizationId);
304
+ if (tenancy.projectId) searchParams.set("projectId", tenancy.projectId);
305
+ const queryString = searchParams.toString();
306
+ return queryString ? `?${queryString}` : "";
307
+ }
300
308
 
301
309
  // src/utils/client-tool-model-output.ts
302
310
  function normalizeModelOutput(output) {
@@ -7695,10 +7703,13 @@ var MastraClient = class extends BaseResource {
7695
7703
  return this.request(`/datasets${qs ? `?${qs}` : ""}`);
7696
7704
  }
7697
7705
  /**
7698
- * Gets a single dataset by ID
7706
+ * Gets a single dataset by ID. Optionally scope the lookup to a specific
7707
+ * tenant organization/project — the server returns 404 if the dataset does
7708
+ * not belong to the given tenant.
7699
7709
  */
7700
- getDataset(datasetId) {
7701
- return this.request(`/datasets/${encodeURIComponent(datasetId)}`);
7710
+ getDataset(datasetId, tenancy) {
7711
+ const qs = buildTenancyQuery(tenancy);
7712
+ return this.request(`/datasets/${encodeURIComponent(datasetId)}${qs}`);
7702
7713
  }
7703
7714
  /**
7704
7715
  * Creates a new dataset
@@ -7707,20 +7718,26 @@ var MastraClient = class extends BaseResource {
7707
7718
  return this.request("/datasets", { method: "POST", body: params });
7708
7719
  }
7709
7720
  /**
7710
- * Updates a dataset
7721
+ * Updates a dataset. Tenancy fields, when provided, scope the existence
7722
+ * check on the server side so that a caller can only update datasets that
7723
+ * belong to the given tenant.
7711
7724
  */
7712
7725
  updateDataset(params) {
7713
- const { datasetId, ...body } = params;
7714
- return this.request(`/datasets/${encodeURIComponent(datasetId)}`, {
7726
+ const { datasetId, organizationId, projectId, ...body } = params;
7727
+ const qs = buildTenancyQuery({ organizationId, projectId });
7728
+ return this.request(`/datasets/${encodeURIComponent(datasetId)}${qs}`, {
7715
7729
  method: "PATCH",
7716
7730
  body
7717
7731
  });
7718
7732
  }
7719
7733
  /**
7720
- * Deletes a dataset
7734
+ * Deletes a dataset. When tenancy fields are supplied, the server only
7735
+ * deletes the dataset if it belongs to the given tenant (silent no-op
7736
+ * otherwise).
7721
7737
  */
7722
- deleteDataset(datasetId) {
7723
- return this.request(`/datasets/${encodeURIComponent(datasetId)}`, {
7738
+ deleteDataset(datasetId, tenancy) {
7739
+ const qs = buildTenancyQuery(tenancy);
7740
+ return this.request(`/datasets/${encodeURIComponent(datasetId)}${qs}`, {
7724
7741
  method: "DELETE"
7725
7742
  });
7726
7743
  }