@mastra/pg 1.36.0-alpha.5 → 1.36.0-alpha.6
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 +17 -17
- package/dist/index.cjs +13 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/observability/v-next/index.d.ts +1 -1
- package/dist/storage/domains/observability/v-next/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/span-query.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/trace-query.d.ts +1 -1
- package/dist/storage/domains/observability/v-next/trace-query.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -19399,13 +19399,13 @@ const timingFeatures = [
|
|
|
19399
19399
|
* condition for rows level with it. Empty values sort last in both directions, so they are past
|
|
19400
19400
|
* every value and level only with each other.
|
|
19401
19401
|
*/
|
|
19402
|
-
function keysetSortBounds(field, direction, sortValue, values) {
|
|
19402
|
+
function keysetSortBounds(field, direction, sortValue, values, stringSort = false) {
|
|
19403
19403
|
if (sortValue === null) return {
|
|
19404
19404
|
past: [],
|
|
19405
19405
|
level: `${field} IS NULL`
|
|
19406
19406
|
};
|
|
19407
19407
|
values.push(sortValue);
|
|
19408
|
-
const parameter = `$${values.length}::${typeof sortValue === "number" ? "float8" : "timestamptz"}`;
|
|
19408
|
+
const parameter = `$${values.length}::${stringSort ? "text COLLATE \"C\"" : typeof sortValue === "number" ? "float8" : "timestamptz"}`;
|
|
19409
19409
|
return {
|
|
19410
19410
|
past: [`${field} ${direction === "asc" ? ">" : "<"} ${parameter}`, `${field} IS NULL`],
|
|
19411
19411
|
level: `${field} = ${parameter}`
|
|
@@ -20453,10 +20453,14 @@ function selectedKeys(rows, values) {
|
|
|
20453
20453
|
return `"${field}" ${field === "traceId" || field === "spanId" ? "=" : "IS NOT DISTINCT FROM"} $${values.length}::text`;
|
|
20454
20454
|
}).join(" AND ")})`).join(" OR ");
|
|
20455
20455
|
}
|
|
20456
|
+
function sortColumn(plan) {
|
|
20457
|
+
const column = `s."${plan.orderBy.field}"`;
|
|
20458
|
+
return plan.orderBy.field === "model" || plan.orderBy.field === "provider" ? `${column} COLLATE "C"` : column;
|
|
20459
|
+
}
|
|
20456
20460
|
function afterCursor(plan, values) {
|
|
20457
20461
|
if (!plan.cursor) return "TRUE";
|
|
20458
20462
|
const cursor = plan.cursor;
|
|
20459
|
-
const { past: terms, level } = keysetSortBounds(
|
|
20463
|
+
const { past: terms, level } = keysetSortBounds(sortColumn(plan), plan.orderBy.direction, cursor.sortValue, values, plan.orderBy.field === "model" || plan.orderBy.field === "provider");
|
|
20460
20464
|
const equal = [level];
|
|
20461
20465
|
for (const key of identityFields) {
|
|
20462
20466
|
const ref = `s."${key}" COLLATE "C"`;
|
|
@@ -20537,10 +20541,12 @@ function compilePostgresSpanQuery(schema, plan) {
|
|
|
20537
20541
|
"endedAt",
|
|
20538
20542
|
"durationMs",
|
|
20539
20543
|
"status",
|
|
20540
|
-
"version"
|
|
20544
|
+
"version",
|
|
20545
|
+
"model",
|
|
20546
|
+
"provider"
|
|
20541
20547
|
].map((field) => `s."${field}"`).join(", ")}
|
|
20542
20548
|
FROM selected s WHERE ${after}
|
|
20543
|
-
ORDER BY
|
|
20549
|
+
ORDER BY ${sortColumn(plan)} ${plan.orderBy.direction === "asc" ? "ASC" : "DESC"} NULLS LAST, ${identityOrder}
|
|
20544
20550
|
LIMIT $${values.length}`,
|
|
20545
20551
|
values
|
|
20546
20552
|
};
|
|
@@ -20575,6 +20581,7 @@ async function querySpans(client, schema, plan, timeoutMs) {
|
|
|
20575
20581
|
const rows = await tx.any(query.text, query.values);
|
|
20576
20582
|
const selected = rows.map(({ version: _version, startedAt, endedAt, timeToFirstChunkMs, timeToFirstTokenMs, outcome, stopReason, ...row }) => ({
|
|
20577
20583
|
...row,
|
|
20584
|
+
...(plan.orderBy.field === "model" || plan.orderBy.field === "provider") && { cursorSortValue: row[plan.orderBy.field] },
|
|
20578
20585
|
...timeToFirstChunkSupported && { timeToFirstChunkMs },
|
|
20579
20586
|
...timeToFirstTokenSupported && { timeToFirstTokenMs },
|
|
20580
20587
|
...spanQueryOutcomeFieldsSupported && {
|
|
@@ -21970,6 +21977,7 @@ const spanQueryFeatures = typeof coreStorage.planSpanQuery === "function" ? [
|
|
|
21970
21977
|
"span-query",
|
|
21971
21978
|
"span-query-context-fields",
|
|
21972
21979
|
...coreStorage.SPAN_QUERY_ORDER_FIELDS?.includes("durationMs") ? ["span-query-duration-sort"] : [],
|
|
21980
|
+
...coreStorage.SPAN_QUERY_ORDER_FIELDS?.includes("model") && coreStorage.SPAN_QUERY_ORDER_FIELDS?.includes("provider") ? ["span-query-model-provider-sort"] : [],
|
|
21973
21981
|
..."model" in (coreStorage.SPAN_QUERY_FIELD_REGISTRY ?? {}) ? ["span-query-model-fields"] : []
|
|
21974
21982
|
] : [];
|
|
21975
21983
|
const spanAggregateFeatures = typeof coreStorage.planSpanAggregate === "function" ? ["span-aggregate", ..."model" in (coreStorage.SPAN_AGGREGATE_DIMENSION_REGISTRY ?? {}) ? ["span-aggregate-model-dimensions"] : []] : [];
|