@mastra/duckdb 1.11.1 → 1.11.2-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.
@@ -4009,6 +4009,7 @@ async function insertSpanEvents(db, rows) {
4009
4009
  await db.execute(`INSERT INTO span_events (${COLUMNS_SQL}) VALUES ${tuples}`);
4010
4010
  }
4011
4011
  function createStartSpanRow(s) {
4012
+ const payloadOnEndRow = !!s.endedAt && !s.isEvent;
4012
4013
  return {
4013
4014
  eventType: "start",
4014
4015
  timestamp: s.startedAt,
@@ -4036,15 +4037,15 @@ function createStartSpanRow(s) {
4036
4037
  environment: s.environment ?? null,
4037
4038
  source: s.source ?? null,
4038
4039
  serviceName: s.serviceName ?? null,
4039
- attributes: s.attributes ?? null,
4040
- metadata: s.metadata ?? null,
4040
+ attributes: payloadOnEndRow ? null : s.attributes ?? null,
4041
+ metadata: payloadOnEndRow ? null : s.metadata ?? null,
4041
4042
  tags: s.tags == null ? null : normalizeTags(s.tags),
4042
4043
  scope: s.scope ?? null,
4043
4044
  links: null,
4044
- input: s.input ?? null,
4045
+ input: payloadOnEndRow ? null : s.input ?? null,
4045
4046
  output: null,
4046
4047
  error: null,
4047
- requestContext: s.requestContext ?? null
4048
+ requestContext: payloadOnEndRow ? null : s.requestContext ?? null
4048
4049
  };
4049
4050
  }
4050
4051
  function createEndSpanRow(s) {
@@ -4204,6 +4205,15 @@ async function listTraceRows(db, args, reconstructSelect, mapRow, toSpans) {
4204
4205
  `;
4205
4206
  const countResult = await db.query(countSql, prefilterParams);
4206
4207
  const total = Number(countResult[0]?.total ?? 0);
4208
+ if (total === 0 || offset >= total) return {
4209
+ pagination: {
4210
+ total,
4211
+ page,
4212
+ perPage,
4213
+ hasMore: false
4214
+ },
4215
+ spans: []
4216
+ };
4207
4217
  const pageSql = `
4208
4218
  WITH page_roots AS (
4209
4219
  SELECT traceId, spanId, min(timestamp) AS anchorStartedAt
@@ -4260,6 +4270,15 @@ async function listTraceRows(db, args, reconstructSelect, mapRow, toSpans) {
4260
4270
  `;
4261
4271
  const countResult = await db.query(countSql, [...prefilterParams, ...postAggParams]);
4262
4272
  const total = Number(countResult[0]?.total ?? 0);
4273
+ if (total === 0 || page * perPage >= total) return {
4274
+ pagination: {
4275
+ total,
4276
+ page,
4277
+ perPage,
4278
+ hasMore: false
4279
+ },
4280
+ spans: []
4281
+ };
4263
4282
  const dataSql = `
4264
4283
  ${cteSql},
4265
4284
  page_roots AS (
@@ -4567,9 +4586,9 @@ async function listBranches(db, args) {
4567
4586
  `;
4568
4587
  const countResult = await db.query(countSql, prefilterParams);
4569
4588
  const total = Number(countResult[0]?.total ?? 0);
4570
- if (total === 0) return {
4589
+ if (total === 0 || page * perPage >= total) return {
4571
4590
  pagination: {
4572
- total: 0,
4591
+ total,
4573
4592
  page,
4574
4593
  perPage,
4575
4594
  hasMore: false
@@ -4630,9 +4649,9 @@ async function listBranches(db, args) {
4630
4649
  `;
4631
4650
  const countResult = await db.query(countSql, [...prefilterParams, ...postAggParams]);
4632
4651
  const total = Number(countResult[0]?.total ?? 0);
4633
- if (total === 0) return {
4652
+ if (total === 0 || page * perPage >= total) return {
4634
4653
  pagination: {
4635
- total: 0,
4654
+ total,
4636
4655
  page,
4637
4656
  perPage,
4638
4657
  hasMore: false
@@ -4744,7 +4763,7 @@ async function getBranchDeltaCursor(db, filters) {
4744
4763
  branch_anchors AS (
4745
4764
  SELECT reconstructed.*, candidate_anchors.cursorId AS anchorCursorId
4746
4765
  FROM (
4747
- ${SPAN_RECONSTRUCT_SELECT}
4766
+ ${buildPostAggReconstructSelect(postAgg, "startedAt")}
4748
4767
  WHERE (traceId, spanId) IN (SELECT traceId, spanId FROM candidate_anchors)
4749
4768
  GROUP BY traceId, spanId
4750
4769
  ) AS reconstructed
@@ -5065,4 +5084,4 @@ var ObservabilityStorageDuckDB = class ObservabilityStorageDuckDB extends Observ
5065
5084
  //#endregion
5066
5085
  export { ObservabilityStorageDuckDB };
5067
5086
 
5068
- //# sourceMappingURL=observability-BVE7R9Oz.js.map
5087
+ //# sourceMappingURL=observability-DPpE45z0.js.map