@mastra/libsql 0.14.0 → 0.14.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/CHANGELOG.md +18 -0
- package/dist/index.cjs +37 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -4
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -2027,17 +2027,47 @@ var ObservabilityLibSQL = class extends ObservabilityStorage {
|
|
|
2027
2027
|
}) {
|
|
2028
2028
|
const page = pagination?.page ?? 0;
|
|
2029
2029
|
const perPage = pagination?.perPage ?? 10;
|
|
2030
|
+
const { entityId, entityType, ...actualFilters } = filters || {};
|
|
2030
2031
|
const filtersWithDateRange = {
|
|
2031
|
-
...
|
|
2032
|
-
...buildDateRangeFilter(pagination?.dateRange, "startedAt")
|
|
2032
|
+
...actualFilters,
|
|
2033
|
+
...buildDateRangeFilter(pagination?.dateRange, "startedAt"),
|
|
2034
|
+
parentSpanId: null
|
|
2033
2035
|
};
|
|
2034
2036
|
const whereClause = prepareWhereClause(filtersWithDateRange, AI_SPAN_SCHEMA);
|
|
2037
|
+
let actualWhereClause = whereClause.sql || "";
|
|
2038
|
+
if (entityId && entityType) {
|
|
2039
|
+
const statement = `name = ?`;
|
|
2040
|
+
let name = "";
|
|
2041
|
+
if (entityType === "workflow") {
|
|
2042
|
+
name = `workflow run: '${entityId}'`;
|
|
2043
|
+
} else if (entityType === "agent") {
|
|
2044
|
+
name = `agent run: '${entityId}'`;
|
|
2045
|
+
} else {
|
|
2046
|
+
const error = new MastraError({
|
|
2047
|
+
id: "LIBSQL_STORE_GET_AI_TRACES_PAGINATED_FAILED",
|
|
2048
|
+
domain: ErrorDomain.STORAGE,
|
|
2049
|
+
category: ErrorCategory.USER,
|
|
2050
|
+
details: {
|
|
2051
|
+
entityType
|
|
2052
|
+
},
|
|
2053
|
+
text: `Cannot filter by entity type: ${entityType}`
|
|
2054
|
+
});
|
|
2055
|
+
this.logger?.trackException(error);
|
|
2056
|
+
throw error;
|
|
2057
|
+
}
|
|
2058
|
+
whereClause.args.push(name);
|
|
2059
|
+
if (actualWhereClause) {
|
|
2060
|
+
actualWhereClause += ` AND ${statement}`;
|
|
2061
|
+
} else {
|
|
2062
|
+
actualWhereClause += `WHERE ${statement}`;
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2035
2065
|
const orderBy = "startedAt DESC";
|
|
2036
2066
|
let count = 0;
|
|
2037
2067
|
try {
|
|
2038
2068
|
count = await this.operations.loadTotalCount({
|
|
2039
2069
|
tableName: TABLE_AI_SPANS,
|
|
2040
|
-
whereClause: { sql:
|
|
2070
|
+
whereClause: { sql: actualWhereClause, args: whereClause.args }
|
|
2041
2071
|
});
|
|
2042
2072
|
} catch (error) {
|
|
2043
2073
|
throw new MastraError(
|
|
@@ -2063,7 +2093,10 @@ var ObservabilityLibSQL = class extends ObservabilityStorage {
|
|
|
2063
2093
|
try {
|
|
2064
2094
|
const spans = await this.operations.loadMany({
|
|
2065
2095
|
tableName: TABLE_AI_SPANS,
|
|
2066
|
-
whereClause
|
|
2096
|
+
whereClause: {
|
|
2097
|
+
sql: actualWhereClause,
|
|
2098
|
+
args: whereClause.args
|
|
2099
|
+
},
|
|
2067
2100
|
orderBy,
|
|
2068
2101
|
offset: page * perPage,
|
|
2069
2102
|
limit: perPage
|