@mastra/lance 1.3.2-alpha.1 → 1.4.0-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.
@@ -3,7 +3,7 @@ name: mastra-lance
3
3
  description: Documentation for @mastra/lance. Use when working with @mastra/lance APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/lance"
6
- version: "1.3.2-alpha.1"
6
+ version: "1.4.0-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3.2-alpha.1",
2
+ "version": "1.4.0-alpha.0",
3
3
  "package": "@mastra/lance",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -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
@@ -248,6 +271,34 @@ await store.upsert({
248
271
  })
249
272
  ```
250
273
 
274
+ **Weaviate**:
275
+
276
+ ```ts
277
+ import { WeaviateVector } from '@mastra/weaviate'
278
+
279
+ const store = new WeaviateVector({
280
+ id: 'weaviate-vector',
281
+ httpHost: process.env.WEAVIATE_HOST,
282
+ httpPort: 443,
283
+ httpSecure: true,
284
+ grpcHost: process.env.WEAVIATE_GRPC_HOST,
285
+ grpcPort: 443,
286
+ grpcSecure: true,
287
+ apiKey: process.env.WEAVIATE_API_KEY,
288
+ })
289
+
290
+ await store.createIndex({
291
+ indexName: 'myCollection',
292
+ dimension: 1536,
293
+ })
294
+
295
+ await store.upsert({
296
+ indexName: 'myCollection',
297
+ vectors: embeddings,
298
+ metadata: chunks.map(chunk => ({ text: chunk.text })),
299
+ })
300
+ ```
301
+
251
302
  **Cloudflare**:
252
303
 
253
304
  ```ts
@@ -317,6 +368,29 @@ await store.upsert({
317
368
 
318
369
  For detailed setup instructions and best practices, see the [official Elasticsearch documentation](https://www.elastic.co/docs/solutions/search/get-started).
319
370
 
371
+ **Azure AI Search**:
372
+
373
+ ```ts
374
+ import { AzureAISearchVector } from '@mastra/azure-ai-search'
375
+
376
+ const store = new AzureAISearchVector({
377
+ id: 'azure-search-vectors',
378
+ endpoint: process.env.AZURE_AI_SEARCH_ENDPOINT!,
379
+ credential: process.env.AZURE_AI_SEARCH_CREDENTIAL!,
380
+ })
381
+
382
+ await store.createIndex({
383
+ indexName: 'my-collection',
384
+ dimension: 1536,
385
+ })
386
+
387
+ await store.upsert({
388
+ indexName: 'my-collection',
389
+ vectors: embeddings,
390
+ metadata: chunks.map(chunk => ({ text: chunk.text })),
391
+ })
392
+ ```
393
+
320
394
  **Couchbase**:
321
395
 
322
396
  ```ts
@@ -534,6 +608,17 @@ Namespace names must:
534
608
 
535
609
  - Example: `_namespace` isn't valid (starts with underscore)
536
610
 
611
+ **Weaviate**:
612
+
613
+ Index names map to Weaviate collections, which:
614
+
615
+ - Are capitalized by Weaviate (the first letter is upper-cased)
616
+ - Should contain only letters, numbers, and the `_` character
617
+ - Must start with a letter, since only the first character is upper-cased (a leading digit or symbol stays invalid)
618
+ - Preserve the original Mastra index name in the collection description, so `listIndexes()` and `describeIndex()` return the name you supplied
619
+ - Example: `my_collection` is stored as `My_collection` and returned as `my_collection`
620
+ - Example: `123_collection` isn't valid (starts with a digit)
621
+
537
622
  **Cloudflare**:
538
623
 
539
624
  Index names must:
@@ -587,6 +672,17 @@ Index names must:
587
672
  - Example: `myindex-` isn't valid (ends with hyphen)
588
673
  - Example: `MyIndex` isn't valid (contains uppercase letters)
589
674
 
675
+ **Azure AI Search**:
676
+
677
+ Index names must:
678
+
679
+ - Use only lowercase letters, numbers, dashes (`-`), and underscore (`_`) characters
680
+ - Not start or end with a dash
681
+ - Be between 2 and 128 characters long
682
+ - Example: `my-index-123` and `my_index` are valid
683
+ - Example: `MyIndex` isn't valid (contains uppercase letters)
684
+ - Example: `my-index-` isn't valid (ends with a dash)
685
+
590
686
  ### Upserting Embeddings
591
687
 
592
688
  After creating an index, you can store embeddings along with their basic metadata:
@@ -650,7 +746,7 @@ Key metadata considerations:
650
746
 
651
747
  ## Deleting vectors
652
748
 
653
- When building RAG applications, you often need to clean up stale vectors when documents are deleted or updated. Mastra provides the `deleteVectors` method that supports deleting vectors by metadata filters, making it straightforward to remove all embeddings associated with a specific document.
749
+ Use `deleteVectors` with a metadata filter to remove embeddings associated with a document. This is useful for cleaning up stale vectors after a document is deleted or updated.
654
750
 
655
751
  ### Delete by Metadata Filter
656
752
 
package/dist/index.cjs CHANGED
@@ -464,7 +464,9 @@ function toRecord(task) {
464
464
  createdAt: task.createdAt,
465
465
  startedAt: task.startedAt ?? /* @__PURE__ */ new Date(0),
466
466
  suspendedAt: task.suspendedAt ?? /* @__PURE__ */ new Date(0),
467
- completedAt: task.completedAt ?? /* @__PURE__ */ new Date(0)
467
+ completedAt: task.completedAt ?? /* @__PURE__ */ new Date(0),
468
+ ownerId: task.ownerId ?? null,
469
+ leaseExpiresAt: task.leaseExpiresAt ?? null
468
470
  };
469
471
  }
470
472
  function fromRecord(row) {
@@ -480,6 +482,7 @@ function fromRecord(row) {
480
482
  const startedAt = row.startedAt instanceof Date ? row.startedAt : row.startedAt ? new Date(row.startedAt) : void 0;
481
483
  const suspendedAt = row.suspendedAt instanceof Date ? row.suspendedAt : row.suspendedAt ? new Date(row.suspendedAt) : void 0;
482
484
  const completedAt = row.completedAt instanceof Date ? row.completedAt : row.completedAt ? new Date(row.completedAt) : void 0;
485
+ const leaseExpiresAt = row.leaseExpiresAt instanceof Date ? row.leaseExpiresAt : row.leaseExpiresAt ? new Date(row.leaseExpiresAt) : void 0;
483
486
  return {
484
487
  id: String(row.id),
485
488
  status: String(row.status),
@@ -499,7 +502,9 @@ function fromRecord(row) {
499
502
  createdAt: row.createdAt instanceof Date ? row.createdAt : new Date(row.createdAt),
500
503
  startedAt: startedAt && startedAt.getTime() > 0 ? startedAt : void 0,
501
504
  suspendedAt: suspendedAt && suspendedAt.getTime() > 0 ? suspendedAt : void 0,
502
- completedAt: completedAt && completedAt.getTime() > 0 ? completedAt : void 0
505
+ completedAt: completedAt && completedAt.getTime() > 0 ? completedAt : void 0,
506
+ ownerId: row.ownerId != null && row.ownerId !== "" ? String(row.ownerId) : void 0,
507
+ leaseExpiresAt
503
508
  };
504
509
  }
505
510
  function escapeStr(val) {
@@ -522,7 +527,12 @@ var StoreBackgroundTasksLance = class extends _mastra_core_storage.BackgroundTas
522
527
  await this.#db.alterTable({
523
528
  tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS,
524
529
  schema: _mastra_core_storage.TABLE_SCHEMAS[_mastra_core_storage.TABLE_BACKGROUND_TASKS],
525
- ifNotExists: ["suspend_payload", "suspendedAt"]
530
+ ifNotExists: [
531
+ "suspend_payload",
532
+ "suspendedAt",
533
+ "ownerId",
534
+ "leaseExpiresAt"
535
+ ]
526
536
  });
527
537
  }
528
538
  async dangerouslyClearAll() {
@@ -541,9 +551,13 @@ var StoreBackgroundTasksLance = class extends _mastra_core_storage.BackgroundTas
541
551
  if ("startedAt" in update) values.startedAt = update.startedAt?.getTime() ?? 0;
542
552
  if ("suspendedAt" in update) values.suspendedAt = update.suspendedAt?.getTime() ?? 0;
543
553
  if ("completedAt" in update) values.completedAt = update.completedAt?.getTime() ?? 0;
554
+ if ("ownerId" in update) values.ownerId = update.ownerId ?? null;
555
+ if ("leaseExpiresAt" in update) values.leaseExpiresAt = update.leaseExpiresAt?.getTime() ?? null;
544
556
  if (Object.keys(values).length === 0) return false;
545
557
  const conditions = [`id = '${escapeStr(taskId)}'`];
546
558
  if (options?.expectedStatus) conditions.push(`status = '${escapeStr(options.expectedStatus)}'`);
559
+ if (options?.expectedOwnerId !== void 0) conditions.push(options.expectedOwnerId === null ? "ownerId IS NULL" : `ownerId = '${escapeStr(options.expectedOwnerId)}'`);
560
+ if (options?.expectedLeaseExpiresAt !== void 0) conditions.push(options.expectedLeaseExpiresAt === null ? "leaseExpiresAt IS NULL" : `leaseExpiresAt = ${options.expectedLeaseExpiresAt.getTime()}`);
547
561
  return (await (await this.client.openTable(_mastra_core_storage.TABLE_BACKGROUND_TASKS)).update({
548
562
  where: conditions.join(" AND "),
549
563
  values