@mastra/pg 1.28.0-alpha.2 → 1.28.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
@@ -458,14 +458,8 @@ function buildDeleteFilterQuery(filter) {
458
458
  const joined = value.map((f) => {
459
459
  const entries = Object.entries(f || {});
460
460
  if (entries.length === 0) return "";
461
- const [firstKey, firstValue] = entries[0] || [];
462
- if ([
463
- "$and",
464
- "$or",
465
- "$not",
466
- "$nor"
467
- ].includes(firstKey)) return buildCondition(firstKey, firstValue, parentPath);
468
- return entries.map(([k, v]) => buildCondition(k, v, parentPath)).join(` ${joinOperator} `);
461
+ const branchConditions = entries.map(([k, v]) => buildCondition(k, v, parentPath));
462
+ return branchConditions.length === 1 ? branchConditions[0] : `(${branchConditions.join(" AND ")})`;
469
463
  }).join(` ${joinOperator} `);
470
464
  const operatorFn = FILTER_OPERATORS[key];
471
465
  return operatorFn(joined, 0, value).sql;
@@ -549,14 +543,8 @@ function buildFilterQuery(filter, minScore, topK) {
549
543
  const joined = value.map((f) => {
550
544
  const entries = Object.entries(f || {});
551
545
  if (entries.length === 0) return "";
552
- const [firstKey, firstValue] = entries[0] || [];
553
- if ([
554
- "$and",
555
- "$or",
556
- "$not",
557
- "$nor"
558
- ].includes(firstKey)) return buildCondition(firstKey, firstValue, parentPath);
559
- return entries.map(([k, v]) => buildCondition(k, v, parentPath)).join(` ${joinOperator} `);
546
+ const branchConditions = entries.map(([k, v]) => buildCondition(k, v, parentPath));
547
+ return branchConditions.length === 1 ? branchConditions[0] : `(${branchConditions.join(" AND ")})`;
560
548
  }).join(` ${joinOperator} `);
561
549
  const operatorFn = FILTER_OPERATORS[key];
562
550
  return operatorFn(joined, 0, value).sql;
@@ -17393,6 +17381,10 @@ const TRACE_FIELDS = {
17393
17381
  traceId: "r.\"traceId\"",
17394
17382
  threadId: "r.\"threadId\"",
17395
17383
  resourceId: "r.\"resourceId\"",
17384
+ runId: "r.\"runId\"",
17385
+ sessionId: "r.\"sessionId\"",
17386
+ userId: "r.\"userId\"",
17387
+ organizationId: "r.\"organizationId\"",
17396
17388
  startedAt: "r.\"startedAt\"",
17397
17389
  endedAt: "r.\"endedAt\"",
17398
17390
  durationMs: durationMsSql("r.\"startedAt\"", "r.\"endedAt\""),
@@ -17417,7 +17409,11 @@ const SPAN_FIELDS = {
17417
17409
  entityName: "s.\"entityName\"",
17418
17410
  entityVersionId: "s.\"entityVersionId\"",
17419
17411
  parentEntityVersionId: "s.\"parentEntityVersionId\"",
17420
- rootEntityVersionId: "s.\"rootEntityVersionId\""
17412
+ rootEntityVersionId: "s.\"rootEntityVersionId\"",
17413
+ runId: "s.\"runId\"",
17414
+ sessionId: "s.\"sessionId\"",
17415
+ userId: "s.\"userId\"",
17416
+ organizationId: "s.\"organizationId\""
17421
17417
  };
17422
17418
  const SCORE_FIELDS = {
17423
17419
  scorerId: "s.\"scorerId\"",
@@ -17733,7 +17729,11 @@ function compilePostgresTraceScope(schema, selection, relationCollections, scope
17733
17729
  s."entityName",
17734
17730
  s."entityVersionId",
17735
17731
  s."parentEntityVersionId",
17736
- s."rootEntityVersionId"
17732
+ s."rootEntityVersionId",
17733
+ s."runId",
17734
+ s."sessionId",
17735
+ s."userId",
17736
+ s."organizationId"
17737
17737
  FROM ${spanTable} s
17738
17738
  WHERE s."traceId" IS NOT NULL
17739
17739
  AND s."traceId" IN (SELECT "traceId" FROM root_scope)
@@ -19076,7 +19076,8 @@ var ObservabilityStoragePostgresVNext = class ObservabilityStoragePostgresVNext
19076
19076
  "trace-query-discovery",
19077
19077
  "thread-query",
19078
19078
  "trace-query-tenant-scope",
19079
- "feedback"
19079
+ "feedback",
19080
+ "trace-query-context-ids"
19080
19081
  ];
19081
19082
  return [
19082
19083
  "metrics",
@@ -19093,7 +19094,8 @@ var ObservabilityStoragePostgresVNext = class ObservabilityStoragePostgresVNext
19093
19094
  "trace-query-discovery",
19094
19095
  "thread-query",
19095
19096
  "trace-query-tenant-scope",
19096
- "feedback"
19097
+ "feedback",
19098
+ "trace-query-context-ids"
19097
19099
  ];
19098
19100
  }
19099
19101
  async #run(op, fn, details) {