@mastra/lance 1.5.2-alpha.1 → 1.6.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.
- package/README.md +1 -1
- package/dist/docs/SKILL.md +2 -2
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/{reference-vectors-lance.md → integrations-vectors-lance.md} +1 -1
- package/dist/docs/references/reference-rag-vector-databases.md +3 -3
- package/dist/index.cjs +22 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -9
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts +1 -0
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/dist/vector/filter.d.ts.map +1 -1
- package/dist/vector/index.d.ts +1 -1
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -411,7 +411,7 @@ var LanceDB = class extends MastraBase {
|
|
|
411
411
|
const quotedKey = /^[a-z][a-zA-Z]*$/.test(key) && /[A-Z]/.test(key) ? `\`${key}\`` : key;
|
|
412
412
|
if (typeof value === "string") return `${quotedKey} = '${value}'`;
|
|
413
413
|
else if (value === null) return `${quotedKey} IS NULL`;
|
|
414
|
-
|
|
414
|
+
return `${quotedKey} = ${value}`;
|
|
415
415
|
}).join(" AND ");
|
|
416
416
|
this.logger.debug("where clause generated: " + filterConditions);
|
|
417
417
|
query.where(filterConditions);
|
|
@@ -464,7 +464,9 @@ function toRecord(task) {
|
|
|
464
464
|
suspendedAt: task.suspendedAt ?? /* @__PURE__ */ new Date(0),
|
|
465
465
|
completedAt: task.completedAt ?? /* @__PURE__ */ new Date(0),
|
|
466
466
|
ownerId: task.ownerId ?? null,
|
|
467
|
-
leaseExpiresAt: task.leaseExpiresAt ?? null
|
|
467
|
+
leaseExpiresAt: task.leaseExpiresAt ?? null,
|
|
468
|
+
expiresAt: task.expiresAt ?? null,
|
|
469
|
+
metadata: serializeJson(task.metadata) ?? null
|
|
468
470
|
};
|
|
469
471
|
}
|
|
470
472
|
function fromRecord(row) {
|
|
@@ -481,6 +483,7 @@ function fromRecord(row) {
|
|
|
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;
|
|
483
485
|
const leaseExpiresAt = row.leaseExpiresAt instanceof Date ? row.leaseExpiresAt : row.leaseExpiresAt ? new Date(row.leaseExpiresAt) : void 0;
|
|
486
|
+
const expiresAt = row.expiresAt instanceof Date ? row.expiresAt : row.expiresAt ? new Date(row.expiresAt) : void 0;
|
|
484
487
|
return {
|
|
485
488
|
id: String(row.id),
|
|
486
489
|
status: String(row.status),
|
|
@@ -502,13 +505,16 @@ function fromRecord(row) {
|
|
|
502
505
|
suspendedAt: suspendedAt && suspendedAt.getTime() > 0 ? suspendedAt : void 0,
|
|
503
506
|
completedAt: completedAt && completedAt.getTime() > 0 ? completedAt : void 0,
|
|
504
507
|
ownerId: row.ownerId != null && row.ownerId !== "" ? String(row.ownerId) : void 0,
|
|
505
|
-
leaseExpiresAt
|
|
508
|
+
leaseExpiresAt,
|
|
509
|
+
expiresAt,
|
|
510
|
+
metadata: parseJson(row.metadata)
|
|
506
511
|
};
|
|
507
512
|
}
|
|
508
513
|
function escapeStr(val) {
|
|
509
514
|
return val.replace(/'/g, "''");
|
|
510
515
|
}
|
|
511
516
|
var StoreBackgroundTasksLance = class extends BackgroundTasksStorage {
|
|
517
|
+
supportsTaskExpiry = true;
|
|
512
518
|
client;
|
|
513
519
|
#db;
|
|
514
520
|
constructor(config) {
|
|
@@ -529,7 +535,9 @@ var StoreBackgroundTasksLance = class extends BackgroundTasksStorage {
|
|
|
529
535
|
"suspend_payload",
|
|
530
536
|
"suspendedAt",
|
|
531
537
|
"ownerId",
|
|
532
|
-
"leaseExpiresAt"
|
|
538
|
+
"leaseExpiresAt",
|
|
539
|
+
"expiresAt",
|
|
540
|
+
"metadata"
|
|
533
541
|
]
|
|
534
542
|
});
|
|
535
543
|
}
|
|
@@ -551,11 +559,14 @@ var StoreBackgroundTasksLance = class extends BackgroundTasksStorage {
|
|
|
551
559
|
if ("completedAt" in update) values.completedAt = update.completedAt?.getTime() ?? 0;
|
|
552
560
|
if ("ownerId" in update) values.ownerId = update.ownerId ?? null;
|
|
553
561
|
if ("leaseExpiresAt" in update) values.leaseExpiresAt = update.leaseExpiresAt?.getTime() ?? null;
|
|
562
|
+
if ("expiresAt" in update) values.expiresAt = update.expiresAt?.getTime() ?? null;
|
|
563
|
+
if ("metadata" in update) values.metadata = serializeJson(update.metadata) ?? null;
|
|
554
564
|
if (Object.keys(values).length === 0) return false;
|
|
555
565
|
const conditions = [`id = '${escapeStr(taskId)}'`];
|
|
556
566
|
if (options?.expectedStatus) conditions.push(`status = '${escapeStr(options.expectedStatus)}'`);
|
|
557
567
|
if (options?.expectedOwnerId !== void 0) conditions.push(options.expectedOwnerId === null ? "ownerId IS NULL" : `ownerId = '${escapeStr(options.expectedOwnerId)}'`);
|
|
558
568
|
if (options?.expectedLeaseExpiresAt !== void 0) conditions.push(options.expectedLeaseExpiresAt === null ? "leaseExpiresAt IS NULL" : `leaseExpiresAt = ${options.expectedLeaseExpiresAt.getTime()}`);
|
|
569
|
+
if (options?.expectedSuspendedAt !== void 0) conditions.push(options.expectedSuspendedAt === null ? "(suspendedAt IS NULL OR suspendedAt = 0)" : `suspendedAt = ${options.expectedSuspendedAt.getTime()}`);
|
|
559
570
|
return (await (await this.client.openTable(TABLE_BACKGROUND_TASKS)).update({
|
|
560
571
|
where: conditions.join(" AND "),
|
|
561
572
|
values
|
|
@@ -587,6 +598,7 @@ var StoreBackgroundTasksLance = class extends BackgroundTasksStorage {
|
|
|
587
598
|
let query = table.query();
|
|
588
599
|
if (conditions.length > 0) query = query.where(conditions.join(" AND "));
|
|
589
600
|
let tasks = (await query.toArray()).map(fromRecord);
|
|
601
|
+
if (filter.hasExpiresAt !== void 0) tasks = tasks.filter((t) => t.expiresAt != null === filter.hasExpiresAt);
|
|
590
602
|
const dateCol = filter.dateFilterBy ?? "createdAt";
|
|
591
603
|
if (filter.fromDate) tasks = tasks.filter((t) => {
|
|
592
604
|
const val = t[dateCol];
|
|
@@ -1985,13 +1997,13 @@ var LanceFilterTranslator = class extends BaseFilterTranslator {
|
|
|
1985
1997
|
if (keys.length > 1) return keys.map((key) => {
|
|
1986
1998
|
const value = obj[key];
|
|
1987
1999
|
if (this.isNestedObject(value) && !this.isDateObject(value)) return this.processNestedObject(key, value);
|
|
1988
|
-
|
|
2000
|
+
return this.processField(key, value);
|
|
1989
2001
|
}).join(" AND ");
|
|
1990
2002
|
if (keys.length === 1) {
|
|
1991
2003
|
const key = keys[0];
|
|
1992
2004
|
const value = obj[key];
|
|
1993
2005
|
if (this.isNestedObject(value) && !this.isDateObject(value)) return this.processNestedObject(key, value);
|
|
1994
|
-
|
|
2006
|
+
return this.processField(key, value);
|
|
1995
2007
|
}
|
|
1996
2008
|
}
|
|
1997
2009
|
return "";
|
|
@@ -2006,7 +2018,7 @@ var LanceFilterTranslator = class extends BaseFilterTranslator {
|
|
|
2006
2018
|
const keys = Object.keys(condObj);
|
|
2007
2019
|
if (keys.length === 1 && this.isOperator(keys[0])) {
|
|
2008
2020
|
if (this.isLogicalOperator(keys[0])) return `(${this.processLogicalOperator(keys[0], condObj[keys[0]])})`;
|
|
2009
|
-
|
|
2021
|
+
throw new Error(BaseFilterTranslator.ErrorMessages.UNSUPPORTED_OPERATOR(keys[0]));
|
|
2010
2022
|
}
|
|
2011
2023
|
if (keys.length > 1) return `(${this.processFilter(condition)})`;
|
|
2012
2024
|
return this.processFilter(condition);
|
|
@@ -2021,7 +2033,7 @@ var LanceFilterTranslator = class extends BaseFilterTranslator {
|
|
|
2021
2033
|
return keys.map((key) => {
|
|
2022
2034
|
const nestedPath = key.includes(".") ? `${path}.${key}` : `${path}.${key}`;
|
|
2023
2035
|
if (this.isNestedObject(obj[key]) && !this.isDateObject(obj[key])) return this.processNestedObject(nestedPath, obj[key]);
|
|
2024
|
-
|
|
2036
|
+
return this.processField(nestedPath, obj[key]);
|
|
2025
2037
|
}).join(" AND ");
|
|
2026
2038
|
}
|
|
2027
2039
|
processField(field, value) {
|
|
@@ -2593,7 +2605,8 @@ var LanceVectorStore = class LanceVectorStore extends MastraVector {
|
|
|
2593
2605
|
}
|
|
2594
2606
|
this.logger.debug(`Table ${resolvedTableName} created. Index creation deferred until data is available.`);
|
|
2595
2607
|
return;
|
|
2596
|
-
}
|
|
2608
|
+
}
|
|
2609
|
+
table = await this.lanceClient.openTable(resolvedTableName);
|
|
2597
2610
|
const metricType = this.mastraMetricToLance(metric);
|
|
2598
2611
|
const rowCount = await table.countRows();
|
|
2599
2612
|
if (rowCount < 256) {
|