@mastra/upstash 1.4.7 → 1.5.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/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-rag-vector-databases.md +23 -0
- package/dist/index.cjs +26 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -3
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts +2 -4
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/docs/SKILL.md
CHANGED
|
@@ -54,6 +54,29 @@ const results = await store.hybridQuery({
|
|
|
54
54
|
|
|
55
55
|
See the [MongoDB vector reference](https://mastra.ai/reference/vectors/mongodb) for details on `createSearchIndex()`, `textQuery()`, and `hybridQuery()`.
|
|
56
56
|
|
|
57
|
+
### Automated Embedding
|
|
58
|
+
|
|
59
|
+
MongoDB can generate the embeddings itself, so you don't need an embedding provider in your application. Create the index with `autoEmbed` and a Voyage AI model, write plain text, and search with a query string:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
await store.createIndex({
|
|
63
|
+
indexName: 'myCollection',
|
|
64
|
+
autoEmbed: { model: 'voyage-4' },
|
|
65
|
+
})
|
|
66
|
+
await store.upsert({
|
|
67
|
+
indexName: 'myCollection',
|
|
68
|
+
documents: chunks.map(chunk => chunk.text),
|
|
69
|
+
metadata: chunks.map(chunk => ({ text: chunk.text })),
|
|
70
|
+
})
|
|
71
|
+
const results = await store.query({
|
|
72
|
+
indexName: 'myCollection',
|
|
73
|
+
queryText: 'search terms',
|
|
74
|
+
topK: 10,
|
|
75
|
+
})
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Automated Embedding is a MongoDB Preview feature and needs a deployment where it's available. See the [MongoDB vector reference](https://mastra.ai/reference/vectors/mongodb) for the supported options and requirements.
|
|
79
|
+
|
|
57
80
|
**PgVector**:
|
|
58
81
|
|
|
59
82
|
```ts
|
package/dist/index.cjs
CHANGED
|
@@ -189,7 +189,9 @@ function toStorageRecord(task) {
|
|
|
189
189
|
createdAt: task.createdAt.toISOString(),
|
|
190
190
|
startedAt: task.startedAt?.toISOString() ?? null,
|
|
191
191
|
suspendedAt: task.suspendedAt?.toISOString() ?? null,
|
|
192
|
-
completedAt: task.completedAt?.toISOString() ?? null
|
|
192
|
+
completedAt: task.completedAt?.toISOString() ?? null,
|
|
193
|
+
ownerId: task.ownerId ?? null,
|
|
194
|
+
leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null
|
|
193
195
|
};
|
|
194
196
|
}
|
|
195
197
|
function fromStorageRecord(record) {
|
|
@@ -212,7 +214,9 @@ function fromStorageRecord(record) {
|
|
|
212
214
|
createdAt: new Date(record.createdAt),
|
|
213
215
|
startedAt: record.startedAt ? new Date(record.startedAt) : void 0,
|
|
214
216
|
suspendedAt: record.suspendedAt ? new Date(record.suspendedAt) : void 0,
|
|
215
|
-
completedAt: record.completedAt ? new Date(record.completedAt) : void 0
|
|
217
|
+
completedAt: record.completedAt ? new Date(record.completedAt) : void 0,
|
|
218
|
+
ownerId: record.ownerId ?? void 0,
|
|
219
|
+
leaseExpiresAt: record.leaseExpiresAt ? new Date(record.leaseExpiresAt) : void 0
|
|
216
220
|
};
|
|
217
221
|
}
|
|
218
222
|
var BackgroundTasksUpstash = class extends _mastra_core_storage.BackgroundTasksStorage {
|
|
@@ -241,6 +245,8 @@ var BackgroundTasksUpstash = class extends _mastra_core_storage.BackgroundTasksS
|
|
|
241
245
|
if ("startedAt" in update) patch.startedAt = update.startedAt?.toISOString() ?? null;
|
|
242
246
|
if ("suspendedAt" in update) patch.suspendedAt = update.suspendedAt?.toISOString() ?? null;
|
|
243
247
|
if ("completedAt" in update) patch.completedAt = update.completedAt?.toISOString() ?? null;
|
|
248
|
+
if ("ownerId" in update) patch.ownerId = update.ownerId ?? null;
|
|
249
|
+
if ("leaseExpiresAt" in update) patch.leaseExpiresAt = update.leaseExpiresAt?.toISOString() ?? null;
|
|
244
250
|
if (Object.keys(patch).length === 0) return false;
|
|
245
251
|
const key = getKey(_mastra_core_storage.TABLE_BACKGROUND_TASKS, { id: taskId });
|
|
246
252
|
const result = await this.client.eval(`
|
|
@@ -248,11 +254,28 @@ var BackgroundTasksUpstash = class extends _mastra_core_storage.BackgroundTasksS
|
|
|
248
254
|
if not existing then return 0 end
|
|
249
255
|
local record = cjson.decode(existing)
|
|
250
256
|
if ARGV[1] ~= '' and record.status ~= ARGV[1] then return 0 end
|
|
257
|
+
local function normalize(value)
|
|
258
|
+
if value == nil or value == cjson.null then return nil end
|
|
259
|
+
return value
|
|
260
|
+
end
|
|
261
|
+
if ARGV[3] == '1' then
|
|
262
|
+
if normalize(record.ownerId) ~= normalize(cjson.decode(ARGV[4])) then return 0 end
|
|
263
|
+
end
|
|
264
|
+
if ARGV[5] == '1' then
|
|
265
|
+
if normalize(record.leaseExpiresAt) ~= normalize(cjson.decode(ARGV[6])) then return 0 end
|
|
266
|
+
end
|
|
251
267
|
local patch = cjson.decode(ARGV[2])
|
|
252
268
|
for field, value in pairs(patch) do record[field] = value end
|
|
253
269
|
redis.call('SET', KEYS[1], cjson.encode(record))
|
|
254
270
|
return 1
|
|
255
|
-
`, [key], [
|
|
271
|
+
`, [key], [
|
|
272
|
+
options?.expectedStatus ?? "",
|
|
273
|
+
JSON.stringify(patch),
|
|
274
|
+
options?.expectedOwnerId !== void 0 ? "1" : "0",
|
|
275
|
+
JSON.stringify(options?.expectedOwnerId ?? null),
|
|
276
|
+
options?.expectedLeaseExpiresAt !== void 0 ? "1" : "0",
|
|
277
|
+
JSON.stringify(options?.expectedLeaseExpiresAt?.toISOString() ?? null)
|
|
278
|
+
]);
|
|
256
279
|
return Number(result) === 1;
|
|
257
280
|
}
|
|
258
281
|
async getTask(taskId) {
|