@mastra/mongodb 1.10.0 → 1.11.0-alpha.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/CHANGELOG.md +84 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +157 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +157 -41
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/datasets/index.d.ts.map +1 -1
- package/dist/storage/domains/experiments/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts +1 -0
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { skillSnapshotFieldValuesEqual } from '@mastra/core/storage/domains/skil
|
|
|
13
13
|
|
|
14
14
|
// package.json
|
|
15
15
|
var package_default = {
|
|
16
|
-
version: "1.
|
|
16
|
+
version: "1.11.0-alpha.1"};
|
|
17
17
|
var MongoDBFilterTranslator = class extends BaseFilterTranslator {
|
|
18
18
|
getSupportedOperators() {
|
|
19
19
|
return {
|
|
@@ -1928,7 +1928,22 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
1928
1928
|
return [
|
|
1929
1929
|
{ collection: TABLE_DATASETS, keys: { id: 1 }, options: { name: "idx_datasets_id", unique: true } },
|
|
1930
1930
|
{ collection: TABLE_DATASETS, keys: { createdAt: -1, id: 1 }, options: { name: "idx_datasets_createdat_id" } },
|
|
1931
|
+
{
|
|
1932
|
+
collection: TABLE_DATASETS,
|
|
1933
|
+
keys: { organizationId: 1, projectId: 1, createdAt: -1, id: 1 },
|
|
1934
|
+
options: { name: "idx_datasets_tenancy_createdat_id" }
|
|
1935
|
+
},
|
|
1936
|
+
{
|
|
1937
|
+
collection: TABLE_DATASETS,
|
|
1938
|
+
keys: { organizationId: 1, projectId: 1, candidateKey: 1, candidateId: 1 },
|
|
1939
|
+
options: { name: "idx_datasets_tenancy_candidate" }
|
|
1940
|
+
},
|
|
1931
1941
|
{ collection: TABLE_DATASET_ITEMS, keys: { datasetId: 1 }, options: { name: "idx_dataset_items_datasetid" } },
|
|
1942
|
+
{
|
|
1943
|
+
collection: TABLE_DATASET_ITEMS,
|
|
1944
|
+
keys: { organizationId: 1, projectId: 1, datasetId: 1, validTo: 1, isDeleted: 1 },
|
|
1945
|
+
options: { name: "idx_dataset_items_tenancy_list" }
|
|
1946
|
+
},
|
|
1932
1947
|
{
|
|
1933
1948
|
collection: TABLE_DATASET_ITEMS,
|
|
1934
1949
|
keys: { datasetId: 1, validTo: 1 },
|
|
@@ -2006,6 +2021,10 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2006
2021
|
targetIds: typeof row.targetIds === "string" ? safelyParseJSON(row.targetIds) : row.targetIds ?? void 0,
|
|
2007
2022
|
scorerIds: typeof row.scorerIds === "string" ? safelyParseJSON(row.scorerIds) : row.scorerIds ?? void 0,
|
|
2008
2023
|
version: row.version ?? 0,
|
|
2024
|
+
organizationId: row.organizationId ?? null,
|
|
2025
|
+
projectId: row.projectId ?? null,
|
|
2026
|
+
candidateKey: row.candidateKey ?? null,
|
|
2027
|
+
candidateId: row.candidateId ?? null,
|
|
2009
2028
|
createdAt: ensureDate(row.createdAt),
|
|
2010
2029
|
updatedAt: ensureDate(row.updatedAt)
|
|
2011
2030
|
};
|
|
@@ -2015,9 +2034,12 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2015
2034
|
id: row.id,
|
|
2016
2035
|
datasetId: row.datasetId,
|
|
2017
2036
|
datasetVersion: row.datasetVersion,
|
|
2037
|
+
organizationId: row.organizationId ?? null,
|
|
2038
|
+
projectId: row.projectId ?? null,
|
|
2018
2039
|
input: typeof row.input === "string" ? safelyParseJSON(row.input) : row.input,
|
|
2019
2040
|
groundTruth: typeof row.groundTruth === "string" ? safelyParseJSON(row.groundTruth) : row.groundTruth,
|
|
2020
2041
|
expectedTrajectory: typeof row.expectedTrajectory === "string" ? safelyParseJSON(row.expectedTrajectory) : row.expectedTrajectory,
|
|
2042
|
+
toolMocks: (typeof row.toolMocks === "string" ? safelyParseJSON(row.toolMocks) : row.toolMocks) ?? void 0,
|
|
2021
2043
|
requestContext: typeof row.requestContext === "string" ? safelyParseJSON(row.requestContext) : row.requestContext,
|
|
2022
2044
|
metadata: typeof row.metadata === "string" ? safelyParseJSON(row.metadata) : row.metadata,
|
|
2023
2045
|
source: typeof row.source === "string" ? safelyParseJSON(row.source) : row.source,
|
|
@@ -2058,6 +2080,10 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2058
2080
|
targetIds: input.targetIds ?? null,
|
|
2059
2081
|
scorerIds: input.scorerIds ?? null,
|
|
2060
2082
|
version: 0,
|
|
2083
|
+
organizationId: input.organizationId ?? null,
|
|
2084
|
+
projectId: input.projectId ?? null,
|
|
2085
|
+
candidateKey: input.candidateKey ?? null,
|
|
2086
|
+
candidateId: input.candidateId ?? null,
|
|
2061
2087
|
createdAt: now,
|
|
2062
2088
|
updatedAt: now
|
|
2063
2089
|
};
|
|
@@ -2168,7 +2194,12 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2168
2194
|
try {
|
|
2169
2195
|
const { page, perPage: perPageInput } = args.pagination;
|
|
2170
2196
|
const collection = await this.getCollection(TABLE_DATASETS);
|
|
2171
|
-
const
|
|
2197
|
+
const filter = {};
|
|
2198
|
+
if (args.filters?.organizationId !== void 0) filter.organizationId = args.filters.organizationId;
|
|
2199
|
+
if (args.filters?.projectId !== void 0) filter.projectId = args.filters.projectId;
|
|
2200
|
+
if (args.filters?.candidateKey !== void 0) filter.candidateKey = args.filters.candidateKey;
|
|
2201
|
+
if (args.filters?.candidateId !== void 0) filter.candidateId = args.filters.candidateId;
|
|
2202
|
+
const total = await collection.countDocuments(filter);
|
|
2172
2203
|
if (total === 0) {
|
|
2173
2204
|
return { datasets: [], pagination: { total: 0, page, perPage: perPageInput, hasMore: false } };
|
|
2174
2205
|
}
|
|
@@ -2178,7 +2209,7 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2178
2209
|
return { datasets: [], pagination: { total, page, perPage: perPageForResponse, hasMore: total > 0 } };
|
|
2179
2210
|
}
|
|
2180
2211
|
const limitValue = perPageInput === false ? total : perPage;
|
|
2181
|
-
const rows = await collection.find(
|
|
2212
|
+
const rows = await collection.find(filter).sort({ createdAt: -1, id: 1 }).skip(offset).limit(limitValue).toArray();
|
|
2182
2213
|
return {
|
|
2183
2214
|
datasets: rows.map((row) => this.transformDatasetRow(row)),
|
|
2184
2215
|
pagination: {
|
|
@@ -2222,15 +2253,20 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2222
2253
|
});
|
|
2223
2254
|
}
|
|
2224
2255
|
const newVersion = result.version;
|
|
2256
|
+
const organizationId = result.organizationId ?? null;
|
|
2257
|
+
const projectId = result.projectId ?? null;
|
|
2225
2258
|
await itemsCollection.insertOne({
|
|
2226
2259
|
id,
|
|
2227
2260
|
datasetId: args.datasetId,
|
|
2228
2261
|
datasetVersion: newVersion,
|
|
2262
|
+
organizationId,
|
|
2263
|
+
projectId,
|
|
2229
2264
|
validTo: null,
|
|
2230
2265
|
isDeleted: false,
|
|
2231
2266
|
input: args.input,
|
|
2232
2267
|
groundTruth: args.groundTruth ?? null,
|
|
2233
2268
|
expectedTrajectory: args.expectedTrajectory ?? null,
|
|
2269
|
+
toolMocks: args.toolMocks ?? null,
|
|
2234
2270
|
requestContext: args.requestContext ?? null,
|
|
2235
2271
|
metadata: args.metadata ?? null,
|
|
2236
2272
|
source: args.source ?? null,
|
|
@@ -2247,9 +2283,12 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2247
2283
|
id,
|
|
2248
2284
|
datasetId: args.datasetId,
|
|
2249
2285
|
datasetVersion: newVersion,
|
|
2286
|
+
organizationId,
|
|
2287
|
+
projectId,
|
|
2250
2288
|
input: args.input,
|
|
2251
2289
|
groundTruth: args.groundTruth,
|
|
2252
2290
|
expectedTrajectory: args.expectedTrajectory,
|
|
2291
|
+
toolMocks: args.toolMocks,
|
|
2253
2292
|
requestContext: args.requestContext,
|
|
2254
2293
|
metadata: args.metadata,
|
|
2255
2294
|
source: args.source,
|
|
@@ -2287,7 +2326,7 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2287
2326
|
details: { itemId: args.id, expectedDatasetId: args.datasetId, actualDatasetId: existing.datasetId }
|
|
2288
2327
|
});
|
|
2289
2328
|
}
|
|
2290
|
-
const hasChanges = args.input !== void 0 || args.groundTruth !== void 0 || args.expectedTrajectory !== void 0 || args.requestContext !== void 0 || args.metadata !== void 0 || args.source !== void 0;
|
|
2329
|
+
const hasChanges = args.input !== void 0 || args.groundTruth !== void 0 || args.expectedTrajectory !== void 0 || args.toolMocks !== void 0 || args.requestContext !== void 0 || args.metadata !== void 0 || args.source !== void 0;
|
|
2291
2330
|
if (!hasChanges) {
|
|
2292
2331
|
return existing;
|
|
2293
2332
|
}
|
|
@@ -2296,6 +2335,7 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2296
2335
|
const mergedInput = args.input !== void 0 ? args.input : existing.input;
|
|
2297
2336
|
const mergedGroundTruth = args.groundTruth !== void 0 ? args.groundTruth : existing.groundTruth;
|
|
2298
2337
|
const mergedExpectedTrajectory = args.expectedTrajectory !== void 0 ? args.expectedTrajectory : existing.expectedTrajectory;
|
|
2338
|
+
const mergedToolMocks = args.toolMocks !== void 0 ? args.toolMocks : existing.toolMocks;
|
|
2299
2339
|
const mergedRequestContext = args.requestContext !== void 0 ? args.requestContext : existing.requestContext;
|
|
2300
2340
|
const mergedMetadata = args.metadata !== void 0 ? args.metadata : existing.metadata;
|
|
2301
2341
|
const mergedSource = args.source !== void 0 ? args.source : existing.source;
|
|
@@ -2316,6 +2356,8 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2316
2356
|
});
|
|
2317
2357
|
}
|
|
2318
2358
|
const newVersion = result.version;
|
|
2359
|
+
const parentOrganizationId = result.organizationId ?? null;
|
|
2360
|
+
const parentProjectId = result.projectId ?? null;
|
|
2319
2361
|
await itemsCollection.updateOne(
|
|
2320
2362
|
{ id: args.id, validTo: null, isDeleted: false },
|
|
2321
2363
|
{ $set: { validTo: newVersion } }
|
|
@@ -2324,11 +2366,14 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2324
2366
|
id: args.id,
|
|
2325
2367
|
datasetId: args.datasetId,
|
|
2326
2368
|
datasetVersion: newVersion,
|
|
2369
|
+
organizationId: parentOrganizationId,
|
|
2370
|
+
projectId: parentProjectId,
|
|
2327
2371
|
validTo: null,
|
|
2328
2372
|
isDeleted: false,
|
|
2329
2373
|
input: mergedInput,
|
|
2330
2374
|
groundTruth: mergedGroundTruth,
|
|
2331
2375
|
expectedTrajectory: mergedExpectedTrajectory ?? null,
|
|
2376
|
+
toolMocks: mergedToolMocks ?? null,
|
|
2332
2377
|
requestContext: mergedRequestContext,
|
|
2333
2378
|
metadata: mergedMetadata,
|
|
2334
2379
|
source: mergedSource,
|
|
@@ -2344,9 +2389,12 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2344
2389
|
return {
|
|
2345
2390
|
...existing,
|
|
2346
2391
|
datasetVersion: newVersion,
|
|
2392
|
+
organizationId: parentOrganizationId,
|
|
2393
|
+
projectId: parentProjectId,
|
|
2347
2394
|
input: mergedInput,
|
|
2348
2395
|
groundTruth: mergedGroundTruth,
|
|
2349
2396
|
expectedTrajectory: mergedExpectedTrajectory,
|
|
2397
|
+
toolMocks: mergedToolMocks,
|
|
2350
2398
|
requestContext: mergedRequestContext,
|
|
2351
2399
|
metadata: mergedMetadata,
|
|
2352
2400
|
source: mergedSource,
|
|
@@ -2395,15 +2443,21 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2395
2443
|
});
|
|
2396
2444
|
}
|
|
2397
2445
|
const newVersion = result.version;
|
|
2446
|
+
const parentOrganizationId = result.organizationId ?? null;
|
|
2447
|
+
const parentProjectId = result.projectId ?? null;
|
|
2398
2448
|
await itemsCollection.updateOne({ id, validTo: null, isDeleted: false }, { $set: { validTo: newVersion } });
|
|
2399
2449
|
await itemsCollection.insertOne({
|
|
2400
2450
|
id,
|
|
2401
2451
|
datasetId,
|
|
2402
2452
|
datasetVersion: newVersion,
|
|
2453
|
+
organizationId: parentOrganizationId,
|
|
2454
|
+
projectId: parentProjectId,
|
|
2403
2455
|
validTo: null,
|
|
2404
2456
|
isDeleted: true,
|
|
2405
2457
|
input: existing.input,
|
|
2406
2458
|
groundTruth: existing.groundTruth,
|
|
2459
|
+
expectedTrajectory: existing.expectedTrajectory ?? null,
|
|
2460
|
+
toolMocks: existing.toolMocks ?? null,
|
|
2407
2461
|
requestContext: existing.requestContext,
|
|
2408
2462
|
metadata: existing.metadata,
|
|
2409
2463
|
source: existing.source,
|
|
@@ -2466,16 +2520,21 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2466
2520
|
});
|
|
2467
2521
|
}
|
|
2468
2522
|
const newVersion = result.version;
|
|
2523
|
+
const organizationId = result.organizationId ?? null;
|
|
2524
|
+
const projectId = result.projectId ?? null;
|
|
2469
2525
|
if (itemsWithIds.length > 0) {
|
|
2470
2526
|
const docs = itemsWithIds.map(({ generatedId, itemInput }) => ({
|
|
2471
2527
|
id: generatedId,
|
|
2472
2528
|
datasetId: input.datasetId,
|
|
2473
2529
|
datasetVersion: newVersion,
|
|
2530
|
+
organizationId,
|
|
2531
|
+
projectId,
|
|
2474
2532
|
validTo: null,
|
|
2475
2533
|
isDeleted: false,
|
|
2476
2534
|
input: itemInput.input,
|
|
2477
2535
|
groundTruth: itemInput.groundTruth ?? null,
|
|
2478
2536
|
expectedTrajectory: itemInput.expectedTrajectory ?? null,
|
|
2537
|
+
toolMocks: itemInput.toolMocks ?? null,
|
|
2479
2538
|
requestContext: itemInput.requestContext ?? null,
|
|
2480
2539
|
metadata: itemInput.metadata ?? null,
|
|
2481
2540
|
source: itemInput.source ?? null,
|
|
@@ -2494,9 +2553,12 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2494
2553
|
id: generatedId,
|
|
2495
2554
|
datasetId: input.datasetId,
|
|
2496
2555
|
datasetVersion: newVersion,
|
|
2556
|
+
organizationId,
|
|
2557
|
+
projectId,
|
|
2497
2558
|
input: itemInput.input,
|
|
2498
2559
|
groundTruth: itemInput.groundTruth,
|
|
2499
2560
|
expectedTrajectory: itemInput.expectedTrajectory,
|
|
2561
|
+
toolMocks: itemInput.toolMocks,
|
|
2500
2562
|
requestContext: itemInput.requestContext,
|
|
2501
2563
|
metadata: itemInput.metadata,
|
|
2502
2564
|
source: itemInput.source,
|
|
@@ -2553,6 +2615,8 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2553
2615
|
});
|
|
2554
2616
|
}
|
|
2555
2617
|
const newVersion = result.version;
|
|
2618
|
+
const parentOrganizationId = result.organizationId ?? null;
|
|
2619
|
+
const parentProjectId = result.projectId ?? null;
|
|
2556
2620
|
const currentIds = currentItems.map((i) => i.id);
|
|
2557
2621
|
await itemsCollection.updateMany(
|
|
2558
2622
|
{ id: { $in: currentIds }, validTo: null, isDeleted: false },
|
|
@@ -2562,10 +2626,14 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2562
2626
|
id: item.id,
|
|
2563
2627
|
datasetId: input.datasetId,
|
|
2564
2628
|
datasetVersion: newVersion,
|
|
2629
|
+
organizationId: parentOrganizationId,
|
|
2630
|
+
projectId: parentProjectId,
|
|
2565
2631
|
validTo: null,
|
|
2566
2632
|
isDeleted: true,
|
|
2567
2633
|
input: item.input,
|
|
2568
2634
|
groundTruth: item.groundTruth,
|
|
2635
|
+
expectedTrajectory: item.expectedTrajectory ?? null,
|
|
2636
|
+
toolMocks: item.toolMocks ?? null,
|
|
2569
2637
|
requestContext: item.requestContext,
|
|
2570
2638
|
metadata: item.metadata,
|
|
2571
2639
|
source: item.source,
|
|
@@ -2667,6 +2735,8 @@ var MongoDBDatasetsStorage = class extends DatasetsStorage {
|
|
|
2667
2735
|
const { page, perPage: perPageInput } = args.pagination;
|
|
2668
2736
|
const collection = await this.getCollection(TABLE_DATASET_ITEMS);
|
|
2669
2737
|
const filter = { datasetId: args.datasetId };
|
|
2738
|
+
if (args.filters?.organizationId !== void 0) filter.organizationId = args.filters.organizationId;
|
|
2739
|
+
if (args.filters?.projectId !== void 0) filter.projectId = args.filters.projectId;
|
|
2670
2740
|
if (args.version !== void 0) {
|
|
2671
2741
|
filter.datasetVersion = { $lte: args.version };
|
|
2672
2742
|
filter.$or = [{ validTo: null }, { validTo: { $gt: args.version } }];
|
|
@@ -2821,6 +2891,8 @@ function transformExperimentRow(row) {
|
|
|
2821
2891
|
metadata: parseJsonField(row.metadata) ?? void 0,
|
|
2822
2892
|
datasetId: row.datasetId ?? null,
|
|
2823
2893
|
datasetVersion: row.datasetVersion != null ? Number(row.datasetVersion) : null,
|
|
2894
|
+
organizationId: row.organizationId ?? null,
|
|
2895
|
+
projectId: row.projectId ?? null,
|
|
2824
2896
|
targetType: row.targetType,
|
|
2825
2897
|
targetId: row.targetId,
|
|
2826
2898
|
status: row.status,
|
|
@@ -2841,6 +2913,8 @@ function transformExperimentResultRow(row) {
|
|
|
2841
2913
|
experimentId: row.experimentId,
|
|
2842
2914
|
itemId: row.itemId,
|
|
2843
2915
|
itemDatasetVersion: row.itemDatasetVersion != null ? Number(row.itemDatasetVersion) : null,
|
|
2916
|
+
organizationId: row.organizationId ?? null,
|
|
2917
|
+
projectId: row.projectId ?? null,
|
|
2844
2918
|
input: parseJsonField(row.input),
|
|
2845
2919
|
output: parseJsonField(row.output) ?? null,
|
|
2846
2920
|
groundTruth: parseJsonField(row.groundTruth) ?? null,
|
|
@@ -2851,6 +2925,7 @@ function transformExperimentResultRow(row) {
|
|
|
2851
2925
|
traceId: row.traceId ?? null,
|
|
2852
2926
|
status: row.status ?? null,
|
|
2853
2927
|
tags: Array.isArray(row.tags) ? row.tags : parseJsonField(row.tags) ?? null,
|
|
2928
|
+
toolMockReport: parseJsonField(row.toolMockReport) ?? null,
|
|
2854
2929
|
createdAt: toDate(row.createdAt)
|
|
2855
2930
|
};
|
|
2856
2931
|
}
|
|
@@ -2878,11 +2953,14 @@ var MongoDBExperimentsStorage = class _MongoDBExperimentsStorage extends Experim
|
|
|
2878
2953
|
{ collection: TABLE_EXPERIMENTS, keys: { id: 1 }, options: { unique: true } },
|
|
2879
2954
|
{ collection: TABLE_EXPERIMENTS, keys: { datasetId: 1 } },
|
|
2880
2955
|
{ collection: TABLE_EXPERIMENTS, keys: { createdAt: -1, id: 1 } },
|
|
2956
|
+
// Tenancy: leading-tenant indexes for multi-tenant scans (parity with datasets domain).
|
|
2957
|
+
{ collection: TABLE_EXPERIMENTS, keys: { organizationId: 1, projectId: 1 } },
|
|
2881
2958
|
{ collection: TABLE_EXPERIMENT_RESULTS, keys: { id: 1 }, options: { unique: true } },
|
|
2882
2959
|
{ collection: TABLE_EXPERIMENT_RESULTS, keys: { experimentId: 1 } },
|
|
2883
2960
|
{ collection: TABLE_EXPERIMENT_RESULTS, keys: { experimentId: 1, itemId: 1 }, options: { unique: true } },
|
|
2884
2961
|
{ collection: TABLE_EXPERIMENT_RESULTS, keys: { createdAt: -1 } },
|
|
2885
|
-
{ collection: TABLE_EXPERIMENT_RESULTS, keys: { experimentId: 1, startedAt: 1, id: 1 } }
|
|
2962
|
+
{ collection: TABLE_EXPERIMENT_RESULTS, keys: { experimentId: 1, startedAt: 1, id: 1 } },
|
|
2963
|
+
{ collection: TABLE_EXPERIMENT_RESULTS, keys: { organizationId: 1, projectId: 1 } }
|
|
2886
2964
|
];
|
|
2887
2965
|
}
|
|
2888
2966
|
async createDefaultIndexes() {
|
|
@@ -2924,6 +3002,8 @@ var MongoDBExperimentsStorage = class _MongoDBExperimentsStorage extends Experim
|
|
|
2924
3002
|
metadata: input.metadata ?? null,
|
|
2925
3003
|
datasetId: input.datasetId ?? null,
|
|
2926
3004
|
datasetVersion: input.datasetVersion ?? null,
|
|
3005
|
+
organizationId: input.organizationId ?? null,
|
|
3006
|
+
projectId: input.projectId ?? null,
|
|
2927
3007
|
targetType: input.targetType,
|
|
2928
3008
|
targetId: input.targetId,
|
|
2929
3009
|
status: "pending",
|
|
@@ -2947,6 +3027,8 @@ var MongoDBExperimentsStorage = class _MongoDBExperimentsStorage extends Experim
|
|
|
2947
3027
|
metadata: input.metadata,
|
|
2948
3028
|
datasetId: input.datasetId ?? null,
|
|
2949
3029
|
datasetVersion: input.datasetVersion ?? null,
|
|
3030
|
+
organizationId: input.organizationId ?? null,
|
|
3031
|
+
projectId: input.projectId ?? null,
|
|
2950
3032
|
targetType: input.targetType,
|
|
2951
3033
|
targetId: input.targetId,
|
|
2952
3034
|
status: "pending",
|
|
@@ -3048,6 +3130,15 @@ var MongoDBExperimentsStorage = class _MongoDBExperimentsStorage extends Experim
|
|
|
3048
3130
|
if (args.status) {
|
|
3049
3131
|
filter.status = args.status;
|
|
3050
3132
|
}
|
|
3133
|
+
if (args.filters) {
|
|
3134
|
+
const { organizationId, projectId } = args.filters;
|
|
3135
|
+
if (organizationId !== void 0) {
|
|
3136
|
+
filter.organizationId = organizationId;
|
|
3137
|
+
}
|
|
3138
|
+
if (projectId !== void 0) {
|
|
3139
|
+
filter.projectId = projectId;
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3051
3142
|
const total = await collection.countDocuments(filter);
|
|
3052
3143
|
if (total === 0) {
|
|
3053
3144
|
return { experiments: [], pagination: { total: 0, page, perPage: perPageInput, hasMore: false } };
|
|
@@ -3108,6 +3199,8 @@ var MongoDBExperimentsStorage = class _MongoDBExperimentsStorage extends Experim
|
|
|
3108
3199
|
experimentId: input.experimentId,
|
|
3109
3200
|
itemId: input.itemId,
|
|
3110
3201
|
itemDatasetVersion: input.itemDatasetVersion ?? null,
|
|
3202
|
+
organizationId: input.organizationId ?? null,
|
|
3203
|
+
projectId: input.projectId ?? null,
|
|
3111
3204
|
input: input.input,
|
|
3112
3205
|
output: input.output ?? null,
|
|
3113
3206
|
groundTruth: input.groundTruth ?? null,
|
|
@@ -3118,6 +3211,7 @@ var MongoDBExperimentsStorage = class _MongoDBExperimentsStorage extends Experim
|
|
|
3118
3211
|
traceId: input.traceId ?? null,
|
|
3119
3212
|
status: input.status ?? null,
|
|
3120
3213
|
tags: input.tags ?? null,
|
|
3214
|
+
toolMockReport: input.toolMockReport ?? null,
|
|
3121
3215
|
createdAt: now
|
|
3122
3216
|
};
|
|
3123
3217
|
try {
|
|
@@ -3128,6 +3222,8 @@ var MongoDBExperimentsStorage = class _MongoDBExperimentsStorage extends Experim
|
|
|
3128
3222
|
experimentId: input.experimentId,
|
|
3129
3223
|
itemId: input.itemId,
|
|
3130
3224
|
itemDatasetVersion: input.itemDatasetVersion ?? null,
|
|
3225
|
+
organizationId: input.organizationId ?? null,
|
|
3226
|
+
projectId: input.projectId ?? null,
|
|
3131
3227
|
input: input.input,
|
|
3132
3228
|
output: input.output ?? null,
|
|
3133
3229
|
groundTruth: input.groundTruth ?? null,
|
|
@@ -3138,6 +3234,7 @@ var MongoDBExperimentsStorage = class _MongoDBExperimentsStorage extends Experim
|
|
|
3138
3234
|
traceId: input.traceId ?? null,
|
|
3139
3235
|
status: input.status ?? null,
|
|
3140
3236
|
tags: input.tags ?? null,
|
|
3237
|
+
toolMockReport: input.toolMockReport ?? null,
|
|
3141
3238
|
createdAt: now
|
|
3142
3239
|
};
|
|
3143
3240
|
} catch (error) {
|
|
@@ -3226,6 +3323,15 @@ var MongoDBExperimentsStorage = class _MongoDBExperimentsStorage extends Experim
|
|
|
3226
3323
|
if (args.status) {
|
|
3227
3324
|
filter.status = args.status;
|
|
3228
3325
|
}
|
|
3326
|
+
if (args.filters) {
|
|
3327
|
+
const { organizationId, projectId } = args.filters;
|
|
3328
|
+
if (organizationId !== void 0) {
|
|
3329
|
+
filter.organizationId = organizationId;
|
|
3330
|
+
}
|
|
3331
|
+
if (projectId !== void 0) {
|
|
3332
|
+
filter.projectId = projectId;
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3229
3335
|
const total = await collection.countDocuments(filter);
|
|
3230
3336
|
if (total === 0) {
|
|
3231
3337
|
return { results: [], pagination: { total: 0, page, perPage: perPageInput, hasMore: false } };
|
|
@@ -6863,17 +6969,39 @@ Note: This migration may take some time for large collections.
|
|
|
6863
6969
|
supported: ["batch-with-updates", "insert-only"]
|
|
6864
6970
|
};
|
|
6865
6971
|
}
|
|
6972
|
+
createDateRangeCondition(field, range) {
|
|
6973
|
+
const dateFilter = {};
|
|
6974
|
+
const stringFilter = {};
|
|
6975
|
+
if (range.start) {
|
|
6976
|
+
const operator = range.startExclusive ? "$gt" : "$gte";
|
|
6977
|
+
const start = range.start instanceof Date ? range.start : new Date(range.start);
|
|
6978
|
+
dateFilter[operator] = start;
|
|
6979
|
+
stringFilter[operator] = start.toISOString();
|
|
6980
|
+
}
|
|
6981
|
+
if (range.end) {
|
|
6982
|
+
const operator = range.endExclusive ? "$lt" : "$lte";
|
|
6983
|
+
const end = range.end instanceof Date ? range.end : new Date(range.end);
|
|
6984
|
+
dateFilter[operator] = end;
|
|
6985
|
+
stringFilter[operator] = end.toISOString();
|
|
6986
|
+
}
|
|
6987
|
+
if (Object.keys(dateFilter).length === 0) {
|
|
6988
|
+
return null;
|
|
6989
|
+
}
|
|
6990
|
+
return {
|
|
6991
|
+
$or: [{ [field]: dateFilter }, { [field]: stringFilter }]
|
|
6992
|
+
};
|
|
6993
|
+
}
|
|
6866
6994
|
async createSpan(args) {
|
|
6867
6995
|
const { span } = args;
|
|
6868
6996
|
try {
|
|
6869
|
-
const startedAt = span.startedAt instanceof Date ? span.startedAt
|
|
6870
|
-
const endedAt = span.endedAt instanceof Date ? span.endedAt
|
|
6997
|
+
const startedAt = span.startedAt instanceof Date ? span.startedAt : new Date(span.startedAt);
|
|
6998
|
+
const endedAt = span.endedAt == null ? span.endedAt : span.endedAt instanceof Date ? span.endedAt : new Date(span.endedAt);
|
|
6871
6999
|
const record = {
|
|
6872
7000
|
...span,
|
|
6873
7001
|
startedAt,
|
|
6874
7002
|
endedAt,
|
|
6875
|
-
createdAt:
|
|
6876
|
-
updatedAt:
|
|
7003
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
7004
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
6877
7005
|
};
|
|
6878
7006
|
const collection = await this.getCollection(TABLE_SPANS);
|
|
6879
7007
|
await collection.insertOne(record);
|
|
@@ -7008,15 +7136,15 @@ Note: This migration may take some time for large collections.
|
|
|
7008
7136
|
const { traceId, spanId, updates } = args;
|
|
7009
7137
|
try {
|
|
7010
7138
|
const data = { ...updates };
|
|
7011
|
-
if (data.endedAt instanceof Date) {
|
|
7012
|
-
data.endedAt = data.endedAt
|
|
7139
|
+
if (data.endedAt != null && !(data.endedAt instanceof Date)) {
|
|
7140
|
+
data.endedAt = new Date(data.endedAt);
|
|
7013
7141
|
}
|
|
7014
|
-
if (data.startedAt instanceof Date) {
|
|
7015
|
-
data.startedAt = data.startedAt
|
|
7142
|
+
if (data.startedAt != null && !(data.startedAt instanceof Date)) {
|
|
7143
|
+
data.startedAt = new Date(data.startedAt);
|
|
7016
7144
|
}
|
|
7017
7145
|
const updateData = {
|
|
7018
7146
|
...data,
|
|
7019
|
-
updatedAt:
|
|
7147
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
7020
7148
|
};
|
|
7021
7149
|
const collection = await this.getCollection(TABLE_SPANS);
|
|
7022
7150
|
await collection.updateOne({ spanId, traceId }, { $set: updateData });
|
|
@@ -7048,27 +7176,15 @@ Note: This migration may take some time for large collections.
|
|
|
7048
7176
|
const andConditions = [];
|
|
7049
7177
|
if (filters) {
|
|
7050
7178
|
if (filters.startedAt) {
|
|
7051
|
-
const
|
|
7052
|
-
if (
|
|
7053
|
-
|
|
7054
|
-
}
|
|
7055
|
-
if (filters.startedAt.end) {
|
|
7056
|
-
startedAtFilter.$lte = filters.startedAt.end.toISOString();
|
|
7057
|
-
}
|
|
7058
|
-
if (Object.keys(startedAtFilter).length > 0) {
|
|
7059
|
-
mongoFilter.startedAt = startedAtFilter;
|
|
7179
|
+
const startedAtCondition = this.createDateRangeCondition("startedAt", filters.startedAt);
|
|
7180
|
+
if (startedAtCondition) {
|
|
7181
|
+
andConditions.push(startedAtCondition);
|
|
7060
7182
|
}
|
|
7061
7183
|
}
|
|
7062
7184
|
if (filters.endedAt) {
|
|
7063
|
-
const
|
|
7064
|
-
if (
|
|
7065
|
-
|
|
7066
|
-
}
|
|
7067
|
-
if (filters.endedAt.end) {
|
|
7068
|
-
endedAtFilter.$lte = filters.endedAt.end.toISOString();
|
|
7069
|
-
}
|
|
7070
|
-
if (Object.keys(endedAtFilter).length > 0) {
|
|
7071
|
-
andConditions.push({ endedAt: endedAtFilter });
|
|
7185
|
+
const endedAtCondition = this.createDateRangeCondition("endedAt", filters.endedAt);
|
|
7186
|
+
if (endedAtCondition) {
|
|
7187
|
+
andConditions.push(endedAtCondition);
|
|
7072
7188
|
}
|
|
7073
7189
|
}
|
|
7074
7190
|
if (filters.spanType !== void 0) {
|
|
@@ -7276,14 +7392,14 @@ Note: This migration may take some time for large collections.
|
|
|
7276
7392
|
async batchCreateSpans(args) {
|
|
7277
7393
|
try {
|
|
7278
7394
|
const records = args.records.map((record) => {
|
|
7279
|
-
const startedAt = record.startedAt instanceof Date ? record.startedAt
|
|
7280
|
-
const endedAt = record.endedAt instanceof Date ? record.endedAt
|
|
7395
|
+
const startedAt = record.startedAt instanceof Date ? record.startedAt : new Date(record.startedAt);
|
|
7396
|
+
const endedAt = record.endedAt == null ? record.endedAt : record.endedAt instanceof Date ? record.endedAt : new Date(record.endedAt);
|
|
7281
7397
|
return {
|
|
7282
7398
|
...record,
|
|
7283
7399
|
startedAt,
|
|
7284
7400
|
endedAt,
|
|
7285
|
-
createdAt:
|
|
7286
|
-
updatedAt:
|
|
7401
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
7402
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
7287
7403
|
};
|
|
7288
7404
|
});
|
|
7289
7405
|
if (records.length > 0) {
|
|
@@ -7308,15 +7424,15 @@ Note: This migration may take some time for large collections.
|
|
|
7308
7424
|
}
|
|
7309
7425
|
const bulkOps = args.records.map((record) => {
|
|
7310
7426
|
const data = { ...record.updates };
|
|
7311
|
-
if (data.endedAt instanceof Date) {
|
|
7312
|
-
data.endedAt = data.endedAt
|
|
7427
|
+
if (data.endedAt != null && !(data.endedAt instanceof Date)) {
|
|
7428
|
+
data.endedAt = new Date(data.endedAt);
|
|
7313
7429
|
}
|
|
7314
|
-
if (data.startedAt instanceof Date) {
|
|
7315
|
-
data.startedAt = data.startedAt
|
|
7430
|
+
if (data.startedAt != null && !(data.startedAt instanceof Date)) {
|
|
7431
|
+
data.startedAt = new Date(data.startedAt);
|
|
7316
7432
|
}
|
|
7317
7433
|
const updateData = {
|
|
7318
7434
|
...data,
|
|
7319
|
-
updatedAt:
|
|
7435
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
7320
7436
|
};
|
|
7321
7437
|
return {
|
|
7322
7438
|
updateOne: {
|