@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.
@@ -3,7 +3,7 @@ name: mastra-duckdb
3
3
  description: Documentation for @mastra/duckdb. Use when working with @mastra/duckdb APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/duckdb"
6
- version: "1.11.1"
6
+ version: "1.11.2-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.11.1",
2
+ "version": "1.11.2-alpha.1",
3
3
  "package": "@mastra/duckdb",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -550,7 +550,7 @@ var ObservabilityStorageDuckDB = class extends _mastra_core_storage.Observabilit
550
550
  async loadDelegate() {
551
551
  if (this.delegate) return this.delegate;
552
552
  if (this.unavailableError) return null;
553
- if (!this.loadPromise) this.loadPromise = Promise.resolve().then(() => require("./observability-B8uK8pWn.cjs")).then(({ ObservabilityStorageDuckDB }) => {
553
+ if (!this.loadPromise) this.loadPromise = Promise.resolve().then(() => require("./observability-By0tHYDZ.cjs")).then(({ ObservabilityStorageDuckDB }) => {
554
554
  const delegate = new ObservabilityStorageDuckDB({ db: this.db });
555
555
  this.delegate = delegate;
556
556
  return delegate;
package/dist/index.js CHANGED
@@ -549,7 +549,7 @@ var ObservabilityStorageDuckDB = class extends ObservabilityStorage {
549
549
  async loadDelegate() {
550
550
  if (this.delegate) return this.delegate;
551
551
  if (this.unavailableError) return null;
552
- if (!this.loadPromise) this.loadPromise = import("./observability-BVE7R9Oz.js").then(({ ObservabilityStorageDuckDB }) => {
552
+ if (!this.loadPromise) this.loadPromise = import("./observability-DPpE45z0.js").then(({ ObservabilityStorageDuckDB }) => {
553
553
  const delegate = new ObservabilityStorageDuckDB({ db: this.db });
554
554
  this.delegate = delegate;
555
555
  return delegate;
@@ -4031,6 +4031,7 @@ async function insertSpanEvents(db, rows) {
4031
4031
  await db.execute(`INSERT INTO span_events (${COLUMNS_SQL}) VALUES ${tuples}`);
4032
4032
  }
4033
4033
  function createStartSpanRow(s) {
4034
+ const payloadOnEndRow = !!s.endedAt && !s.isEvent;
4034
4035
  return {
4035
4036
  eventType: "start",
4036
4037
  timestamp: s.startedAt,
@@ -4058,15 +4059,15 @@ function createStartSpanRow(s) {
4058
4059
  environment: s.environment ?? null,
4059
4060
  source: s.source ?? null,
4060
4061
  serviceName: s.serviceName ?? null,
4061
- attributes: s.attributes ?? null,
4062
- metadata: s.metadata ?? null,
4062
+ attributes: payloadOnEndRow ? null : s.attributes ?? null,
4063
+ metadata: payloadOnEndRow ? null : s.metadata ?? null,
4063
4064
  tags: s.tags == null ? null : normalizeTags(s.tags),
4064
4065
  scope: s.scope ?? null,
4065
4066
  links: null,
4066
- input: s.input ?? null,
4067
+ input: payloadOnEndRow ? null : s.input ?? null,
4067
4068
  output: null,
4068
4069
  error: null,
4069
- requestContext: s.requestContext ?? null
4070
+ requestContext: payloadOnEndRow ? null : s.requestContext ?? null
4070
4071
  };
4071
4072
  }
4072
4073
  function createEndSpanRow(s) {
@@ -4226,6 +4227,15 @@ async function listTraceRows(db, args, reconstructSelect, mapRow, toSpans) {
4226
4227
  `;
4227
4228
  const countResult = await db.query(countSql, prefilterParams);
4228
4229
  const total = Number(countResult[0]?.total ?? 0);
4230
+ if (total === 0 || offset >= total) return {
4231
+ pagination: {
4232
+ total,
4233
+ page,
4234
+ perPage,
4235
+ hasMore: false
4236
+ },
4237
+ spans: []
4238
+ };
4229
4239
  const pageSql = `
4230
4240
  WITH page_roots AS (
4231
4241
  SELECT traceId, spanId, min(timestamp) AS anchorStartedAt
@@ -4282,6 +4292,15 @@ async function listTraceRows(db, args, reconstructSelect, mapRow, toSpans) {
4282
4292
  `;
4283
4293
  const countResult = await db.query(countSql, [...prefilterParams, ...postAggParams]);
4284
4294
  const total = Number(countResult[0]?.total ?? 0);
4295
+ if (total === 0 || page * perPage >= total) return {
4296
+ pagination: {
4297
+ total,
4298
+ page,
4299
+ perPage,
4300
+ hasMore: false
4301
+ },
4302
+ spans: []
4303
+ };
4285
4304
  const dataSql = `
4286
4305
  ${cteSql},
4287
4306
  page_roots AS (
@@ -4589,9 +4608,9 @@ async function listBranches(db, args) {
4589
4608
  `;
4590
4609
  const countResult = await db.query(countSql, prefilterParams);
4591
4610
  const total = Number(countResult[0]?.total ?? 0);
4592
- if (total === 0) return {
4611
+ if (total === 0 || page * perPage >= total) return {
4593
4612
  pagination: {
4594
- total: 0,
4613
+ total,
4595
4614
  page,
4596
4615
  perPage,
4597
4616
  hasMore: false
@@ -4652,9 +4671,9 @@ async function listBranches(db, args) {
4652
4671
  `;
4653
4672
  const countResult = await db.query(countSql, [...prefilterParams, ...postAggParams]);
4654
4673
  const total = Number(countResult[0]?.total ?? 0);
4655
- if (total === 0) return {
4674
+ if (total === 0 || page * perPage >= total) return {
4656
4675
  pagination: {
4657
- total: 0,
4676
+ total,
4658
4677
  page,
4659
4678
  perPage,
4660
4679
  hasMore: false
@@ -4766,7 +4785,7 @@ async function getBranchDeltaCursor(db, filters) {
4766
4785
  branch_anchors AS (
4767
4786
  SELECT reconstructed.*, candidate_anchors.cursorId AS anchorCursorId
4768
4787
  FROM (
4769
- ${SPAN_RECONSTRUCT_SELECT}
4788
+ ${buildPostAggReconstructSelect(postAgg, "startedAt")}
4770
4789
  WHERE (traceId, spanId) IN (SELECT traceId, spanId FROM candidate_anchors)
4771
4790
  GROUP BY traceId, spanId
4772
4791
  ) AS reconstructed
@@ -5087,4 +5106,4 @@ var ObservabilityStorageDuckDB = class ObservabilityStorageDuckDB extends _mastr
5087
5106
  //#endregion
5088
5107
  exports.ObservabilityStorageDuckDB = ObservabilityStorageDuckDB;
5089
5108
 
5090
- //# sourceMappingURL=observability-B8uK8pWn.cjs.map
5109
+ //# sourceMappingURL=observability-By0tHYDZ.cjs.map