@mastra/core
Version:
155 lines • 6.14 kB
TypeScript
import type { Mastra } from '../mastra/index.js';
import type { ListDatasetsInput, TargetType } from '../storage/types.js';
import { Dataset } from './dataset.js';
/**
* Public API for managing datasets.
*
* Provides methods for dataset CRUD and cross-dataset experiment operations.
* Typically accessed via `mastra.datasets` (Phase 4).
*/
export declare class DatasetsManager {
#private;
constructor(mastra: Mastra);
/**
* Create a new dataset.
*
* Accepts Zod schemas for `inputSchema` / `groundTruthSchema` (typed as
* `unknown` here); they are normalized to JSON Schema via `zodToJsonSchema`
* before being forwarded to the storage-canonical
* {@link import('../storage/types.js').CreateDatasetInput} shape. All other
* fields mirror `CreateDatasetInput` exactly.
*/
create(input: {
id?: string;
name: string;
description?: string;
inputSchema?: unknown;
groundTruthSchema?: unknown;
requestContextSchema?: Record<string, unknown> | null;
metadata?: Record<string, unknown>;
targetType?: TargetType;
targetIds?: string[];
scorerIds?: string[];
organizationId?: string | null;
projectId?: string | null;
candidateKey?: string | null;
candidateId?: string | null;
}): Promise<Dataset>;
/**
* Get an existing dataset by ID, optionally scoped to a tenant.
*
* When `organizationId` / `projectId` are provided, the read is scoped to
* that tenancy: a dataset row that exists but belongs to a different tenant
* returns NOT_FOUND (same 404 as a truly missing row) rather than leaking
* cross-tenant existence. The returned {@link Dataset} handle carries the
* scope forward on all subsequent reads and item mutations.
*/
get(args: {
id: string;
organizationId?: string;
projectId?: string;
}): Promise<Dataset>;
/**
* List all datasets with pagination.
*
* Supports optional tenancy and candidate-identity filters. When omitted, all
* datasets visible to the configured storage instance are returned.
*/
list(args?: {
page?: number;
/** Datasets per page, or `false` to return every match on one page. */
perPage?: number | false;
filters?: {
organizationId?: string;
projectId?: string;
candidateKey?: string;
candidateId?: string;
/** Filter by dataset target type. */
targetType?: TargetType;
/**
* Filter to datasets whose `targetIds` intersect this list (any overlap matches).
*/
targetIds?: string[];
/**
* Only return datasets with these IDs. An empty array matches no datasets.
* Pass `perPage: false` to get every match; otherwise the page size still applies.
*/
datasetIds?: string[];
/** Substring match on dataset `name`, case-insensitive. */
name?: string;
};
orderBy?: ListDatasetsInput['orderBy'];
}): Promise<import("../storage/types.js").ListDatasetsOutput>;
/**
* Delete a dataset by ID, optionally scoped to a tenant.
*
* When `organizationId` / `projectId` are provided, the delete is scoped to
* that tenancy: a dataset row in another tenant is a silent no-op (no error)
* so cross-tenant existence is not leaked via error timing/text.
*/
delete(args: {
id: string;
organizationId?: string;
projectId?: string;
}): Promise<void>;
/**
* Get a specific experiment (run) by ID, optionally scoped to a tenant.
*
* When `organizationId` / `projectId` are provided, the read is scoped to
* that tenancy: an experiment row that exists but belongs to a different
* tenant returns `null` (same as a truly missing row) rather than leaking
* cross-tenant existence via error timing/text.
*/
getExperiment(args: {
experimentId: string;
organizationId?: string;
projectId?: string;
}): Promise<import("../storage/types.js").Experiment | null>;
/**
* Delete an experiment (run) by ID, optionally scoped to a tenant.
*
* Unlike {@link Dataset.deleteExperiment} this does not require the experiment
* to still belong to a dataset, so it can clean up experiments orphaned by
* dataset deletion (their `datasetId` is nulled out).
*
* When `organizationId` / `projectId` are provided, the delete is scoped to
* that tenancy: an experiment row in another tenant is a silent no-op (no
* error) so cross-tenant existence is not leaked via error timing/text.
*
* The experiment's traces are deleted too: they are excluded from normal trace
* reads, so leaving them behind would make them invisible but still-retained
* data. Stores without an observability domain — or without tenant-scoped trace
* deletion — log a warning and skip the trace cascade so the experiment itself
* is still deleted.
*/
deleteExperiment(args: {
experimentId: string;
organizationId?: string;
projectId?: string;
}): Promise<void>;
/**
* Compare two or more experiments.
*
* Each contender is compared pairwise against the baseline with the internal
* `compareExperiments` function; the pairs are then merged so every item has
* a result entry for every experiment (or `null` when it did not run the item).
*/
compareExperiments(args: {
experimentIds: string[];
baselineId?: string;
organizationId?: string;
projectId?: string;
}): Promise<{
baselineId: string;
items: {
itemId: string;
input: {} | null;
groundTruth: {} | null;
results: Record<string, {
output: unknown;
scores: Record<string, number | null>;
} | null>;
}[];
}>;
}
//# sourceMappingURL=manager.d.ts.map