@mastra/upstash 1.6.0 → 1.6.1-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 -10
- package/dist/docs/assets/SOURCE_MAP.json +43 -2
- package/dist/index.cjs +23 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -28
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +1 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/vector/filter.d.ts +2 -1
- package/dist/vector/filter.d.ts.map +1 -1
- package/package.json +10 -10
- package/dist/docs/references/docs-memory-working-memory.md +0 -450
- package/dist/docs/references/reference-rag-retrieval.md +0 -672
- package/dist/docs/references/reference-rag-vector-databases.md +0 -808
package/dist/index.js
CHANGED
|
@@ -606,6 +606,7 @@ function getMessageIndexKey(messageId) {
|
|
|
606
606
|
return `msg-idx:${messageId}`;
|
|
607
607
|
}
|
|
608
608
|
var StoreMemoryUpstash = class extends MemoryStorage {
|
|
609
|
+
listThreadsPaginatesInMemory = true;
|
|
609
610
|
supportsPartialThreadUpdate = true;
|
|
610
611
|
client;
|
|
611
612
|
#db;
|
|
@@ -2502,31 +2503,20 @@ var UpstashFilterTranslator = class extends BaseFilterTranslator {
|
|
|
2502
2503
|
default: throw new Error(`Unsupported operator: ${operator}`);
|
|
2503
2504
|
}
|
|
2504
2505
|
}
|
|
2505
|
-
NEGATED_OPERATORS = {
|
|
2506
|
-
$eq: "$ne",
|
|
2507
|
-
$ne: "$eq",
|
|
2508
|
-
$gt: "$lte",
|
|
2509
|
-
$gte: "$lt",
|
|
2510
|
-
$lt: "$gte",
|
|
2511
|
-
$lte: "$gt",
|
|
2512
|
-
$in: "$nin",
|
|
2513
|
-
$nin: "$in",
|
|
2514
|
-
$exists: "$exists"
|
|
2515
|
-
};
|
|
2516
2506
|
formatNot(path, value) {
|
|
2517
2507
|
if (typeof value !== "object") return `${path} != ${this.formatValue(value)}`;
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
}
|
|
2527
|
-
return `${fieldName} != ${this.formatValue(fieldValue)}`;
|
|
2508
|
+
const negated = Object.entries(value).map(([key, val]) => key.startsWith("$") ? this.negateOperator(path, key, val) : this.negateField(path ? `${path}.${key}` : key, val));
|
|
2509
|
+
return negated.length > 1 ? `(${negated.join(" OR ")})` : negated[0] ?? "";
|
|
2510
|
+
}
|
|
2511
|
+
negateField(fieldName, fieldValue) {
|
|
2512
|
+
if (Array.isArray(fieldValue)) return fieldValue.length === 0 ? "(HAS FIELD empty OR HAS NOT FIELD empty)" : `${fieldName} NOT IN (${this.formatArray(fieldValue)})`;
|
|
2513
|
+
if (typeof fieldValue === "object" && fieldValue !== null && Object.keys(fieldValue).length > 0) {
|
|
2514
|
+
const negated = Object.entries(fieldValue).map(([key, val]) => key.startsWith("$") ? this.negateOperator(fieldName, key, val) : this.negateField(`${fieldName}.${key}`, val));
|
|
2515
|
+
return negated.length > 1 ? `(${negated.join(" OR ")})` : negated[0];
|
|
2528
2516
|
}
|
|
2529
|
-
|
|
2517
|
+
return `${fieldName} != ${this.formatValue(fieldValue)}`;
|
|
2518
|
+
}
|
|
2519
|
+
negateOperator(path, op, val) {
|
|
2530
2520
|
if (op === "$lt") return `${path} >= ${this.formatValue(val)}`;
|
|
2531
2521
|
if (op === "$lte") return `${path} > ${this.formatValue(val)}`;
|
|
2532
2522
|
if (op === "$gt") return `${path} <= ${this.formatValue(val)}`;
|
|
@@ -2538,16 +2528,21 @@ var UpstashFilterTranslator = class extends BaseFilterTranslator {
|
|
|
2538
2528
|
if (op === "$in") return `${path} NOT IN (${this.formatArray(val)})`;
|
|
2539
2529
|
if (op === "$nin") return `${path} IN (${this.formatArray(val)})`;
|
|
2540
2530
|
if (op === "$exists") return val ? `HAS NOT FIELD ${path}` : `HAS FIELD ${path}`;
|
|
2531
|
+
if (op === "$all") {
|
|
2532
|
+
if (!Array.isArray(val) || val.length === 0) return "(HAS FIELD empty AND HAS NOT FIELD empty)";
|
|
2533
|
+
const negated = val.map((item) => `${path} NOT CONTAINS ${this.formatValue(item)}`);
|
|
2534
|
+
return negated.length > 1 ? `(${negated.join(" OR ")})` : negated[0];
|
|
2535
|
+
}
|
|
2541
2536
|
if (op === "$and" || op === "$or") {
|
|
2542
2537
|
const newOp = op === "$and" ? "$or" : "$and";
|
|
2543
|
-
const conditions = val.map((condition) => {
|
|
2544
|
-
const [fieldName, fieldValue] = Object.entries(condition)[0] ?? [];
|
|
2545
|
-
return { [fieldName]: { $not: fieldValue } };
|
|
2546
|
-
});
|
|
2538
|
+
const conditions = val.map((condition) => path ? { [path]: { $not: condition } } : { $not: condition });
|
|
2547
2539
|
return this.translateOperator(newOp, conditions, "");
|
|
2548
2540
|
}
|
|
2549
|
-
if (op === "$nor")
|
|
2550
|
-
|
|
2541
|
+
if (op === "$nor") {
|
|
2542
|
+
const conditions = val.map((condition) => path ? { [path]: condition } : condition);
|
|
2543
|
+
return this.translateOperator("$or", conditions, "");
|
|
2544
|
+
}
|
|
2545
|
+
throw new Error(`Unsupported operator in NOT: ${op}`);
|
|
2551
2546
|
}
|
|
2552
2547
|
formatValue(value) {
|
|
2553
2548
|
if (value === null || value === void 0) throw new Error("Filtering for null/undefined values is not supported by Upstash Vector");
|