@mastra/pg 1.13.0-alpha.0 → 1.13.0

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
@@ -1,11 +1,12 @@
1
1
  import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
2
- import { BRANCH_SPAN_TYPES, createVectorErrorId, AgentsStorage, TABLE_AGENTS, TABLE_AGENT_VERSIONS, TABLE_SCHEMAS, createStorageErrorId, normalizePerPage, calculatePagination, BackgroundTasksStorage, TABLE_BACKGROUND_TASKS, BlobStore, TABLE_SKILL_BLOBS, ChannelsStorage, TABLE_CHANNEL_INSTALLATIONS, TABLE_CHANNEL_CONFIG, DatasetsStorage, TABLE_DATASETS, TABLE_DATASET_ITEMS, TABLE_DATASET_VERSIONS, DATASETS_SCHEMA, TABLE_CONFIGS, DATASET_ITEMS_SCHEMA, DATASET_VERSIONS_SCHEMA, ensureDate, safelyParseJSON, ExperimentsStorage, TABLE_EXPERIMENTS, TABLE_EXPERIMENT_RESULTS, EXPERIMENTS_SCHEMA, EXPERIMENT_RESULTS_SCHEMA, FavoritesStorage, TABLE_FAVORITES, MCPClientsStorage, TABLE_MCP_CLIENTS, TABLE_MCP_CLIENT_VERSIONS, MCPServersStorage, TABLE_MCP_SERVERS, TABLE_MCP_SERVER_VERSIONS, MemoryStorage, TABLE_THREADS, TABLE_MESSAGES, TABLE_RESOURCES, NotificationsStorage, TABLE_NOTIFICATIONS, ObservabilityStorage, TABLE_SPANS, listTracesArgsSchema, toTraceSpans, PromptBlocksStorage, TABLE_PROMPT_BLOCKS, TABLE_PROMPT_BLOCK_VERSIONS, SchedulesStorage, TABLE_SCHEDULES, TABLE_SCHEDULE_TRIGGERS, ScorerDefinitionsStorage, TABLE_SCORER_DEFINITIONS, TABLE_SCORER_DEFINITION_VERSIONS, ScoresStorage, TABLE_SCORERS, SkillsStorage, TABLE_SKILLS, TABLE_SKILL_VERSIONS, ToolProviderConnectionsStorage, TABLE_TOOL_PROVIDER_CONNECTIONS, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, WorkspacesStorage, TABLE_WORKSPACES, TABLE_WORKSPACE_VERSIONS, MastraCompositeStore, TraceStatus, getDefaultValue, listBranchesArgsSchema, listLogsArgsSchema, listMetricsArgsSchema, listScoresArgsSchema, listFeedbackArgsSchema, transformScoreRow as transformScoreRow$1, getSqlType, EntityType, METRIC_DISTINCT_COLUMNS } from '@mastra/core/storage';
2
+ import { BRANCH_SPAN_TYPES, createVectorErrorId, AgentsStorage, TABLE_AGENTS, TABLE_AGENT_VERSIONS, TABLE_SCHEMAS, createStorageErrorId, normalizePerPage, calculatePagination, BackgroundTasksStorage, TABLE_BACKGROUND_TASKS, BlobStore, TABLE_SKILL_BLOBS, ChannelsStorage, TABLE_CHANNEL_INSTALLATIONS, TABLE_CHANNEL_CONFIG, DatasetsStorage, TABLE_DATASETS, TABLE_DATASET_ITEMS, TABLE_DATASET_VERSIONS, DATASETS_SCHEMA, TABLE_CONFIGS, DATASET_ITEMS_SCHEMA, DATASET_VERSIONS_SCHEMA, ensureDate, safelyParseJSON, ExperimentsStorage, TABLE_EXPERIMENTS, TABLE_EXPERIMENT_RESULTS, EXPERIMENTS_SCHEMA, EXPERIMENT_RESULTS_SCHEMA, FavoritesStorage, TABLE_FAVORITES, MCPClientsStorage, TABLE_MCP_CLIENTS, TABLE_MCP_CLIENT_VERSIONS, MCPServersStorage, TABLE_MCP_SERVERS, TABLE_MCP_SERVER_VERSIONS, MemoryStorage, TABLE_THREADS, TABLE_MESSAGES, TABLE_RESOURCES, NotificationsStorage, TABLE_NOTIFICATIONS, ObservabilityStorage, TABLE_SPANS, listTracesArgsSchema, toTraceSpans, PromptBlocksStorage, TABLE_PROMPT_BLOCKS, TABLE_PROMPT_BLOCK_VERSIONS, SchedulesStorage, TABLE_SCHEDULES, TABLE_SCHEDULE_TRIGGERS, ScorerDefinitionsStorage, TABLE_SCORER_DEFINITIONS, TABLE_SCORER_DEFINITION_VERSIONS, ScoresStorage, TABLE_SCORERS, SkillsStorage, TABLE_SKILLS, TABLE_SKILL_VERSIONS, ToolProviderConnectionsStorage, TABLE_TOOL_PROVIDER_CONNECTIONS, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, mergeWorkflowStepResult, WorkspacesStorage, TABLE_WORKSPACES, TABLE_WORKSPACE_VERSIONS, MastraCompositeStore, TraceStatus, getDefaultValue, listBranchesArgsSchema, listLogsArgsSchema, listMetricsArgsSchema, listScoresArgsSchema, listFeedbackArgsSchema, transformScoreRow as transformScoreRow$1, getSqlType, EntityType, METRIC_DISTINCT_COLUMNS } from '@mastra/core/storage';
3
3
  import { parseSqlIdentifier, parseFieldKey } from '@mastra/core/utils';
4
4
  import { MastraVector, validateTopK, validateUpsertInput } from '@mastra/core/vector';
5
5
  import { Mutex } from 'async-mutex';
6
6
  import * as pg from 'pg';
7
7
  import { Pool } from 'pg';
8
8
  import xxhash from 'xxhash-wasm';
9
+ import { parse } from 'pg-connection-string';
9
10
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
10
11
  import { MastraBase } from '@mastra/core/base';
11
12
  import { randomUUID } from 'crypto';
@@ -13,7 +14,6 @@ import { createRequire } from 'module';
13
14
  import { MessageList } from '@mastra/core/agent';
14
15
  import { coreFeatures } from '@mastra/core/features';
15
16
  import { saveScorePayloadSchema } from '@mastra/core/evals';
16
- import { parse } from 'pg-connection-string';
17
17
 
18
18
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
19
19
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -66,6 +66,15 @@ var validateConfig = (name, config) => {
66
66
  );
67
67
  }
68
68
  };
69
+ function buildConnectionStringPoolConfig(config, defaults) {
70
+ const parsed = parse(config.connectionString);
71
+ return {
72
+ ...parsed,
73
+ ...config.ssl !== void 0 ? { ssl: config.ssl } : {},
74
+ max: config.max ?? defaults.max,
75
+ idleTimeoutMillis: config.idleTimeoutMillis ?? defaults.idleTimeoutMillis
76
+ };
77
+ }
69
78
  var PGFilterTranslator = class extends BaseFilterTranslator {
70
79
  getSupportedOperators() {
71
80
  return {
@@ -613,10 +622,7 @@ var PgVector = class extends MastraVector {
613
622
  let poolConfig;
614
623
  if (isConnectionStringConfig(config)) {
615
624
  poolConfig = {
616
- connectionString: config.connectionString,
617
- ssl: config.ssl,
618
- max: config.max ?? 20,
619
- idleTimeoutMillis: config.idleTimeoutMillis ?? 3e4,
625
+ ...buildConnectionStringPoolConfig(config, { max: 20, idleTimeoutMillis: 3e4 }),
620
626
  connectionTimeoutMillis: 2e3,
621
627
  ...config.pgPoolOptions
622
628
  };
@@ -17942,8 +17948,7 @@ var WorkflowsPG = class _WorkflowsPG extends WorkflowsStorage {
17942
17948
  const existingSnapshot = existingSnapshotResult.snapshot;
17943
17949
  snapshot = typeof existingSnapshot === "string" ? JSON.parse(existingSnapshot) : existingSnapshot;
17944
17950
  }
17945
- snapshot.context[stepId] = result;
17946
- snapshot.requestContext = { ...snapshot.requestContext, ...requestContext };
17951
+ mergeWorkflowStepResult({ snapshot, stepId, result, requestContext });
17947
17952
  const now = /* @__PURE__ */ new Date();
17948
17953
  const sanitizedSnapshot = sanitizeJsonForPg(JSON.stringify(snapshot));
17949
17954
  await t.none(
@@ -18916,15 +18921,6 @@ var WorkspacesPG = class _WorkspacesPG extends WorkspacesStorage {
18916
18921
  };
18917
18922
  }
18918
18923
  };
18919
- function buildConnectionStringPoolConfig(config, defaults) {
18920
- const parsed = parse(config.connectionString);
18921
- return {
18922
- ...parsed,
18923
- ...config.ssl !== void 0 ? { ssl: config.ssl } : {},
18924
- max: config.max ?? defaults.max,
18925
- idleTimeoutMillis: config.idleTimeoutMillis ?? defaults.idleTimeoutMillis
18926
- };
18927
- }
18928
18924
 
18929
18925
  // src/storage/index.ts
18930
18926
  var DEFAULT_MAX_CONNECTIONS = 20;