@mastra/mongodb 1.18.7 → 1.18.8-alpha.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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +108 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +108 -70
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/datasets/index.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -10,7 +10,7 @@ let _mastra_core_agent = require("@mastra/core/agent");
|
|
|
10
10
|
let _mastra_core_evals = require("@mastra/core/evals");
|
|
11
11
|
let _mastra_core_storage_domains_skills = require("@mastra/core/storage/domains/skills");
|
|
12
12
|
//#region package.json
|
|
13
|
-
var version = "1.18.
|
|
13
|
+
var version = "1.18.8-alpha.0";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/vector/filter.ts
|
|
16
16
|
/**
|
|
@@ -3097,42 +3097,65 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3097
3097
|
}
|
|
3098
3098
|
async _doUpdateItem(args) {
|
|
3099
3099
|
try {
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3100
|
+
if (!(args.input !== void 0 || args.groundTruth !== void 0 || args.expectedTrajectory !== void 0 || args.toolMocks !== void 0 || args.unmockedToolPolicy !== void 0 || args.scorerIds !== void 0 || args.requestContext !== void 0 || args.metadata !== void 0 || args.source !== void 0)) {
|
|
3101
|
+
const existing = await this.getItemById({ id: args.id });
|
|
3102
|
+
if (!existing) throw new _mastra_core_error.MastraError({
|
|
3103
|
+
id: (0, _mastra_core_storage.createStorageErrorId)("MONGODB", "UPDATE_ITEM", "NOT_FOUND"),
|
|
3104
|
+
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
3105
|
+
category: _mastra_core_error.ErrorCategory.USER,
|
|
3106
|
+
details: { itemId: args.id }
|
|
3107
|
+
});
|
|
3108
|
+
if (existing.datasetId !== args.datasetId) throw new _mastra_core_error.MastraError({
|
|
3109
|
+
id: (0, _mastra_core_storage.createStorageErrorId)("MONGODB", "UPDATE_ITEM", "DATASET_MISMATCH"),
|
|
3110
|
+
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
3111
|
+
category: _mastra_core_error.ErrorCategory.USER,
|
|
3112
|
+
details: {
|
|
3113
|
+
itemId: args.id,
|
|
3114
|
+
expectedDatasetId: args.datasetId,
|
|
3115
|
+
actualDatasetId: existing.datasetId
|
|
3116
|
+
}
|
|
3117
|
+
});
|
|
3118
|
+
return existing;
|
|
3119
|
+
}
|
|
3118
3120
|
const now = /* @__PURE__ */ new Date();
|
|
3119
3121
|
const versionId = (0, crypto$1.randomUUID)();
|
|
3120
|
-
const mergedInput = args.input !== void 0 ? args.input : existing.input;
|
|
3121
|
-
const mergedGroundTruth = args.groundTruth !== void 0 ? args.groundTruth : existing.groundTruth;
|
|
3122
|
-
const mergedExpectedTrajectory = args.expectedTrajectory !== void 0 ? args.expectedTrajectory : existing.expectedTrajectory;
|
|
3123
|
-
const mergedToolMocks = args.toolMocks !== void 0 ? args.toolMocks : existing.toolMocks;
|
|
3124
|
-
const mergedUnmockedToolPolicy = args.unmockedToolPolicy !== void 0 ? args.unmockedToolPolicy : existing.unmockedToolPolicy;
|
|
3125
|
-
const mergedScorerIds = args.scorerIds !== void 0 ? args.scorerIds ?? void 0 : existing.scorerIds;
|
|
3126
|
-
const mergedRequestContext = args.requestContext !== void 0 ? args.requestContext : existing.requestContext;
|
|
3127
|
-
const mergedMetadata = args.metadata !== void 0 ? args.metadata : existing.metadata;
|
|
3128
|
-
const mergedSource = args.source !== void 0 ? args.source : existing.source;
|
|
3129
3122
|
const datasetsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASETS);
|
|
3130
3123
|
const itemsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASET_ITEMS);
|
|
3131
3124
|
const versionsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASET_VERSIONS);
|
|
3132
|
-
let
|
|
3133
|
-
let parentOrganizationId = null;
|
|
3134
|
-
let parentProjectId = null;
|
|
3125
|
+
let updated;
|
|
3135
3126
|
await this.#connector.withTransaction(async (session) => {
|
|
3127
|
+
const row = await itemsCollection.findOne({
|
|
3128
|
+
id: args.id,
|
|
3129
|
+
validTo: null,
|
|
3130
|
+
isDeleted: false
|
|
3131
|
+
}, { session });
|
|
3132
|
+
const existing = row ? this.transformItemRow(row) : null;
|
|
3133
|
+
if (!existing) throw new _mastra_core_error.MastraError({
|
|
3134
|
+
id: (0, _mastra_core_storage.createStorageErrorId)("MONGODB", "UPDATE_ITEM", "NOT_FOUND"),
|
|
3135
|
+
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
3136
|
+
category: _mastra_core_error.ErrorCategory.USER,
|
|
3137
|
+
details: { itemId: args.id }
|
|
3138
|
+
});
|
|
3139
|
+
if (existing.datasetId !== args.datasetId) throw new _mastra_core_error.MastraError({
|
|
3140
|
+
id: (0, _mastra_core_storage.createStorageErrorId)("MONGODB", "UPDATE_ITEM", "DATASET_MISMATCH"),
|
|
3141
|
+
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
3142
|
+
category: _mastra_core_error.ErrorCategory.USER,
|
|
3143
|
+
details: {
|
|
3144
|
+
itemId: args.id,
|
|
3145
|
+
expectedDatasetId: args.datasetId,
|
|
3146
|
+
actualDatasetId: existing.datasetId
|
|
3147
|
+
}
|
|
3148
|
+
});
|
|
3149
|
+
if (existing.metadata?.__purged === true) throw new _mastra_core_error.MastraError({
|
|
3150
|
+
id: "DATASET_ITEM_PURGED",
|
|
3151
|
+
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
3152
|
+
category: _mastra_core_error.ErrorCategory.USER,
|
|
3153
|
+
details: {
|
|
3154
|
+
datasetId: args.datasetId,
|
|
3155
|
+
itemId: args.id
|
|
3156
|
+
},
|
|
3157
|
+
text: `Purged dataset item cannot be updated: ${args.id}`
|
|
3158
|
+
});
|
|
3136
3159
|
const result = await datasetsCollection.findOneAndUpdate({ id: args.datasetId }, { $inc: { version: 1 } }, {
|
|
3137
3160
|
session,
|
|
3138
3161
|
returnDocument: "after"
|
|
@@ -3143,9 +3166,18 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3143
3166
|
category: _mastra_core_error.ErrorCategory.USER,
|
|
3144
3167
|
details: { datasetId: args.datasetId }
|
|
3145
3168
|
});
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3169
|
+
const mergedInput = args.input !== void 0 ? args.input : existing.input;
|
|
3170
|
+
const mergedGroundTruth = args.groundTruth !== void 0 ? args.groundTruth : existing.groundTruth;
|
|
3171
|
+
const mergedExpectedTrajectory = args.expectedTrajectory !== void 0 ? args.expectedTrajectory : existing.expectedTrajectory;
|
|
3172
|
+
const mergedToolMocks = args.toolMocks !== void 0 ? args.toolMocks : existing.toolMocks;
|
|
3173
|
+
const mergedUnmockedToolPolicy = args.unmockedToolPolicy !== void 0 ? args.unmockedToolPolicy : existing.unmockedToolPolicy;
|
|
3174
|
+
const mergedScorerIds = args.scorerIds !== void 0 ? args.scorerIds ?? void 0 : existing.scorerIds;
|
|
3175
|
+
const mergedRequestContext = args.requestContext !== void 0 ? args.requestContext : existing.requestContext;
|
|
3176
|
+
const mergedMetadata = args.metadata !== void 0 ? args.metadata : existing.metadata;
|
|
3177
|
+
const mergedSource = args.source !== void 0 ? args.source : existing.source;
|
|
3178
|
+
const newVersion = result.version;
|
|
3179
|
+
const parentOrganizationId = result.organizationId ?? null;
|
|
3180
|
+
const parentProjectId = result.projectId ?? null;
|
|
3149
3181
|
await itemsCollection.updateOne({
|
|
3150
3182
|
id: args.id,
|
|
3151
3183
|
validTo: null,
|
|
@@ -3178,23 +3210,24 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3178
3210
|
version: newVersion,
|
|
3179
3211
|
createdAt: now
|
|
3180
3212
|
}, { session });
|
|
3213
|
+
updated = {
|
|
3214
|
+
...existing,
|
|
3215
|
+
datasetVersion: newVersion,
|
|
3216
|
+
organizationId: parentOrganizationId,
|
|
3217
|
+
projectId: parentProjectId,
|
|
3218
|
+
input: mergedInput,
|
|
3219
|
+
groundTruth: mergedGroundTruth,
|
|
3220
|
+
expectedTrajectory: mergedExpectedTrajectory,
|
|
3221
|
+
toolMocks: mergedToolMocks,
|
|
3222
|
+
unmockedToolPolicy: mergedUnmockedToolPolicy,
|
|
3223
|
+
scorerIds: mergedScorerIds,
|
|
3224
|
+
requestContext: mergedRequestContext,
|
|
3225
|
+
metadata: mergedMetadata,
|
|
3226
|
+
source: mergedSource,
|
|
3227
|
+
updatedAt: now
|
|
3228
|
+
};
|
|
3181
3229
|
});
|
|
3182
|
-
return
|
|
3183
|
-
...existing,
|
|
3184
|
-
datasetVersion: newVersion,
|
|
3185
|
-
organizationId: parentOrganizationId,
|
|
3186
|
-
projectId: parentProjectId,
|
|
3187
|
-
input: mergedInput,
|
|
3188
|
-
groundTruth: mergedGroundTruth,
|
|
3189
|
-
expectedTrajectory: mergedExpectedTrajectory,
|
|
3190
|
-
toolMocks: mergedToolMocks,
|
|
3191
|
-
unmockedToolPolicy: mergedUnmockedToolPolicy,
|
|
3192
|
-
scorerIds: mergedScorerIds,
|
|
3193
|
-
requestContext: mergedRequestContext,
|
|
3194
|
-
metadata: mergedMetadata,
|
|
3195
|
-
source: mergedSource,
|
|
3196
|
-
updatedAt: now
|
|
3197
|
-
};
|
|
3230
|
+
return updated;
|
|
3198
3231
|
} catch (error) {
|
|
3199
3232
|
if (error instanceof _mastra_core_error.MastraError) throw error;
|
|
3200
3233
|
throw new _mastra_core_error.MastraError({
|
|
@@ -3206,24 +3239,29 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3206
3239
|
}
|
|
3207
3240
|
async _doDeleteItem({ id, datasetId }) {
|
|
3208
3241
|
try {
|
|
3209
|
-
const existing = await this.getItemById({ id });
|
|
3210
|
-
if (!existing) return;
|
|
3211
|
-
if (existing.datasetId !== datasetId) throw new _mastra_core_error.MastraError({
|
|
3212
|
-
id: (0, _mastra_core_storage.createStorageErrorId)("MONGODB", "DELETE_ITEM", "DATASET_MISMATCH"),
|
|
3213
|
-
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
3214
|
-
category: _mastra_core_error.ErrorCategory.USER,
|
|
3215
|
-
details: {
|
|
3216
|
-
itemId: id,
|
|
3217
|
-
expectedDatasetId: datasetId,
|
|
3218
|
-
actualDatasetId: existing.datasetId
|
|
3219
|
-
}
|
|
3220
|
-
});
|
|
3221
3242
|
const now = /* @__PURE__ */ new Date();
|
|
3222
3243
|
const versionId = (0, crypto$1.randomUUID)();
|
|
3223
3244
|
const datasetsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASETS);
|
|
3224
3245
|
const itemsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASET_ITEMS);
|
|
3225
3246
|
const versionsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASET_VERSIONS);
|
|
3226
3247
|
await this.#connector.withTransaction(async (session) => {
|
|
3248
|
+
const row = await itemsCollection.findOne({
|
|
3249
|
+
id,
|
|
3250
|
+
validTo: null,
|
|
3251
|
+
isDeleted: false
|
|
3252
|
+
}, { session });
|
|
3253
|
+
const existing = row ? this.transformItemRow(row) : null;
|
|
3254
|
+
if (!existing) return;
|
|
3255
|
+
if (existing.datasetId !== datasetId) throw new _mastra_core_error.MastraError({
|
|
3256
|
+
id: (0, _mastra_core_storage.createStorageErrorId)("MONGODB", "DELETE_ITEM", "DATASET_MISMATCH"),
|
|
3257
|
+
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
3258
|
+
category: _mastra_core_error.ErrorCategory.USER,
|
|
3259
|
+
details: {
|
|
3260
|
+
itemId: id,
|
|
3261
|
+
expectedDatasetId: datasetId,
|
|
3262
|
+
actualDatasetId: existing.datasetId
|
|
3263
|
+
}
|
|
3264
|
+
});
|
|
3227
3265
|
const result = await datasetsCollection.findOneAndUpdate({ id: datasetId }, { $inc: { version: 1 } }, {
|
|
3228
3266
|
session,
|
|
3229
3267
|
returnDocument: "after"
|
|
@@ -3445,19 +3483,19 @@ var MongoDBDatasetsStorage = class extends _mastra_core_storage.DatasetsStorage
|
|
|
3445
3483
|
details: { datasetId: input.datasetId }
|
|
3446
3484
|
});
|
|
3447
3485
|
const itemsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASET_ITEMS);
|
|
3448
|
-
const currentItems = (await itemsCollection.find({
|
|
3449
|
-
id: { $in: input.itemIds },
|
|
3450
|
-
datasetId: input.datasetId,
|
|
3451
|
-
validTo: null,
|
|
3452
|
-
isDeleted: false
|
|
3453
|
-
}).toArray()).map((row) => this.transformItemRow(row));
|
|
3454
|
-
if (currentItems.length === 0) return;
|
|
3455
3486
|
const now = /* @__PURE__ */ new Date();
|
|
3456
3487
|
const versionId = (0, crypto$1.randomUUID)();
|
|
3457
3488
|
const datasetsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASETS);
|
|
3458
3489
|
const versionsCollection = await this.getCollection(_mastra_core_storage.TABLE_DATASET_VERSIONS);
|
|
3459
|
-
const currentIds = currentItems.map((i) => i.id);
|
|
3460
3490
|
await this.#connector.withTransaction(async (session) => {
|
|
3491
|
+
const currentItems = (await itemsCollection.find({
|
|
3492
|
+
id: { $in: input.itemIds },
|
|
3493
|
+
datasetId: input.datasetId,
|
|
3494
|
+
validTo: null,
|
|
3495
|
+
isDeleted: false
|
|
3496
|
+
}, { session }).toArray()).map((row) => this.transformItemRow(row));
|
|
3497
|
+
if (currentItems.length === 0) return;
|
|
3498
|
+
const currentIds = currentItems.map((i) => i.id);
|
|
3461
3499
|
const result = await datasetsCollection.findOneAndUpdate({ id: input.datasetId }, { $inc: { version: 1 } }, {
|
|
3462
3500
|
session,
|
|
3463
3501
|
returnDocument: "after"
|