@mastra/pg 1.35.0-alpha.0 → 1.35.0-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 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +25 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -0
- 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/trace-aggregate.d.ts +5 -0
- package/dist/storage/domains/observability/v-next/trace-aggregate.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -20526,6 +20526,18 @@ const PERCENTILES = {
|
|
|
20526
20526
|
"duration.p95": .95,
|
|
20527
20527
|
"duration.p99": .99
|
|
20528
20528
|
};
|
|
20529
|
+
/** Quantile for each percentile statistic of a time-to-first measure. */
|
|
20530
|
+
const STATISTIC_PERCENTILES = {
|
|
20531
|
+
p50: .5,
|
|
20532
|
+
p90: .9,
|
|
20533
|
+
p95: .95,
|
|
20534
|
+
p99: .99
|
|
20535
|
+
};
|
|
20536
|
+
/**
|
|
20537
|
+
* Store features this compiler supports beyond `trace-aggregate` / `span-aggregate`. Core before
|
|
20538
|
+
* the time-to-first measures rejects them, so they are only declared when core plans them.
|
|
20539
|
+
*/
|
|
20540
|
+
const aggregateTimeToFirstFeatures = "timeToFirstToken.p50" in _mastra_core_storage.TRACE_AGGREGATE_MEASURE_REGISTRY ? ["aggregate-time-to-first-measures"] : [];
|
|
20529
20541
|
const COMPARISON_SQL = {
|
|
20530
20542
|
eq: "=",
|
|
20531
20543
|
ne: "<>",
|
|
@@ -20593,6 +20605,8 @@ function compilePostgresAggregate(schema, plan, source) {
|
|
|
20593
20605
|
factColumns.push(`(${distinctSql(measure.field)})::text AS ${column}`);
|
|
20594
20606
|
}
|
|
20595
20607
|
factColumns.push(`(${durationMsSql("r.\"startedAt\"", "r.\"endedAt\"")})::float8 AS "durationMs"`, `r."error" IS NOT NULL AS "isError"`);
|
|
20608
|
+
const timeToFirstFields = new Set(plan.measures.map((measure) => measureRule(measure.name)?.field));
|
|
20609
|
+
for (const field of timeToFirstFields) if (field) factColumns.push(`r."${field}"::float8 AS "${field}"`);
|
|
20596
20610
|
if (plan.interval !== void 0) {
|
|
20597
20611
|
const intervalMs = _mastra_core_storage.TRACE_AGGREGATE_INTERVAL_MS[plan.interval];
|
|
20598
20612
|
if (intervalMs === void 0) throw new Error(`Unsupported trusted trace-aggregate interval: ${plan.interval}`);
|
|
@@ -20624,6 +20638,15 @@ function compilePostgresAggregate(schema, plan, source) {
|
|
|
20624
20638
|
const aggregate = rule.statistic === "avg" ? "AVG" : "SUM";
|
|
20625
20639
|
return `(CASE WHEN ${mixedUnitsSql(alias)} THEN NULL ELSE ${aggregate}(${column("traceCost")}) END)::float8`;
|
|
20626
20640
|
}
|
|
20641
|
+
if (rule?.field) {
|
|
20642
|
+
const value = column(rule.field);
|
|
20643
|
+
if (rule.statistic === "count") return `COUNT(${value})::float8`;
|
|
20644
|
+
if (rule.statistic === "avg") return `AVG(${value})`;
|
|
20645
|
+
if (rule.statistic === "min") return `MIN(${value})`;
|
|
20646
|
+
if (rule.statistic === "max") return `MAX(${value})`;
|
|
20647
|
+
const quantile = rule.statistic && STATISTIC_PERCENTILES[rule.statistic];
|
|
20648
|
+
if (quantile !== void 0) return `percentile_cont(${quantile}) WITHIN GROUP (ORDER BY ${value})`;
|
|
20649
|
+
}
|
|
20627
20650
|
if (name === "errorCount") return `(COUNT(*) FILTER (WHERE ${column("isError")}))::float8`;
|
|
20628
20651
|
if (name === "errorRate") return `(COUNT(*) FILTER (WHERE ${column("isError")}))::float8 / COUNT(*)`;
|
|
20629
20652
|
if (name === "duration.avg") return `AVG(${column("durationMs")})`;
|
|
@@ -21778,6 +21801,7 @@ var ObservabilityStoragePostgresVNext = class ObservabilityStoragePostgresVNext
|
|
|
21778
21801
|
"metric-discovery",
|
|
21779
21802
|
"trace-query",
|
|
21780
21803
|
"trace-aggregate",
|
|
21804
|
+
...aggregateTimeToFirstFeatures,
|
|
21781
21805
|
...spanQueryFeatures,
|
|
21782
21806
|
...spanAggregateFeatures,
|
|
21783
21807
|
...typeof _mastra_core_storage.planThreadRowsQuery === "function" ? ["thread-query-rows"] : [],
|
|
@@ -21804,6 +21828,7 @@ var ObservabilityStoragePostgresVNext = class ObservabilityStoragePostgresVNext
|
|
|
21804
21828
|
"delta-polling",
|
|
21805
21829
|
"trace-query",
|
|
21806
21830
|
"trace-aggregate",
|
|
21831
|
+
...aggregateTimeToFirstFeatures,
|
|
21807
21832
|
...spanQueryFeatures,
|
|
21808
21833
|
...spanAggregateFeatures,
|
|
21809
21834
|
...typeof _mastra_core_storage.planThreadRowsQuery === "function" ? ["thread-query-rows"] : [],
|