@mastra/clickhouse 1.30.0-alpha.2 → 1.30.0-alpha.4

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/index.js CHANGED
@@ -8216,10 +8216,11 @@ function afterCursor$1(plan, parameters) {
8216
8216
  const equal = [];
8217
8217
  if (cursor.sortValue === null) equal.push(`isNull(${field})`);
8218
8218
  else {
8219
- const numeric = plan.orderBy.field === "timeToFirstChunkMs" || plan.orderBy.field === "timeToFirstTokenMs";
8220
- const value = parameters.add(cursor.sortValue, numeric ? "Float64" : "DateTime64(3, 'UTC')");
8219
+ const numeric = typeof cursor.sortValue === "number";
8220
+ const stringSort = plan.orderBy.field === "model" || plan.orderBy.field === "provider";
8221
+ const value = parameters.add(cursor.sortValue, stringSort ? "String" : numeric ? "Float64" : "DateTime64(3, 'UTC')");
8221
8222
  terms.push(`${field} ${plan.orderBy.direction === "asc" ? ">" : "<"} ${value}`);
8222
- if (numeric) terms.push(`isNull(${field})`);
8223
+ if (numeric || stringSort) terms.push(`isNull(${field})`);
8223
8224
  equal.push(`${field} = ${value}`);
8224
8225
  }
8225
8226
  for (const key of identityFields) {
@@ -8444,7 +8445,8 @@ async function querySpans(client, plan, timeoutMs) {
8444
8445
  const selected = (await run(compileClickHouseSpanQuery(plan))).map((row) => ({
8445
8446
  ...row,
8446
8447
  startedAt: iso$1(row.startedAt),
8447
- endedAt: iso$1(row.endedAt)
8448
+ endedAt: iso$1(row.endedAt),
8449
+ ...row.durationMs === void 0 ? {} : { durationMs: Number(row.durationMs) }
8448
8450
  }));
8449
8451
  const page = selected.slice(0, plan.limit);
8450
8452
  if (!page.length) return {
@@ -8486,6 +8488,8 @@ async function querySpans(client, plan, timeoutMs) {
8486
8488
  return [{
8487
8489
  ...metadata,
8488
8490
  ...identity,
8491
+ model: row.model,
8492
+ provider: row.provider,
8489
8493
  durationMs: Number(row.durationMs),
8490
8494
  ...timeToFirstChunkSupported && { timeToFirstChunkMs: timeToFirstChunkMs == null ? null : Number(timeToFirstChunkMs) },
8491
8495
  ...timeToFirstTokenSupported && { timeToFirstTokenMs: timeToFirstTokenMs == null ? null : Number(timeToFirstTokenMs) },
@@ -10041,6 +10045,8 @@ function buildBranchCursor(row) {
10041
10045
  const spanQueryFeatures = typeof coreStorage.planSpanQuery === "function" ? [
10042
10046
  "span-query",
10043
10047
  "span-query-context-fields",
10048
+ ...coreStorage.SPAN_QUERY_ORDER_FIELDS?.includes("durationMs") ? ["span-query-duration-sort"] : [],
10049
+ ...coreStorage.SPAN_QUERY_ORDER_FIELDS?.includes("model") && coreStorage.SPAN_QUERY_ORDER_FIELDS?.includes("provider") ? ["span-query-model-provider-sort"] : [],
10044
10050
  ..."model" in (coreStorage.SPAN_QUERY_FIELD_REGISTRY ?? {}) ? ["span-query-model-fields"] : []
10045
10051
  ] : [];
10046
10052
  const spanAggregateFeatures = typeof coreStorage.planSpanAggregate === "function" ? ["span-aggregate", ..."model" in (coreStorage.SPAN_AGGREGATE_DIMENSION_REGISTRY ?? {}) ? ["span-aggregate-model-dimensions"] : []] : [];