@mastra/pg 1.0.0-beta.3 → 1.0.0-beta.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
@@ -1,11 +1,11 @@
1
1
  import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
2
+ import { createVectorErrorId, MastraStorage, createStorageErrorId, StoreOperations, TABLE_SCHEMAS, TABLE_WORKFLOW_SNAPSHOT, TABLE_SPANS, TABLE_THREADS, TABLE_MESSAGES, TABLE_TRACES, TABLE_SCORERS, ScoresStorage, normalizePerPage, calculatePagination, WorkflowsStorage, MemoryStorage, TABLE_RESOURCES, ObservabilityStorage, transformScoreRow as transformScoreRow$1 } from '@mastra/core/storage';
2
3
  import { parseSqlIdentifier, parseFieldKey } from '@mastra/core/utils';
3
4
  import { MastraVector } from '@mastra/core/vector';
4
5
  import { Mutex } from 'async-mutex';
5
6
  import * as pg from 'pg';
6
7
  import xxhash from 'xxhash-wasm';
7
8
  import { BaseFilterTranslator } from '@mastra/core/vector/filter';
8
- import { MastraStorage, StoreOperations, TABLE_SCHEMAS, TABLE_WORKFLOW_SNAPSHOT, TABLE_SPANS, TABLE_THREADS, TABLE_MESSAGES, TABLE_TRACES, TABLE_SCORERS, ScoresStorage, normalizePerPage, calculatePagination, WorkflowsStorage, MemoryStorage, TABLE_RESOURCES, ObservabilityStorage, transformScoreRow as transformScoreRow$1 } from '@mastra/core/storage';
9
9
  import pgPromise from 'pg-promise';
10
10
  import { MessageList } from '@mastra/core/agent';
11
11
  import { saveScorePayloadSchema } from '@mastra/core/evals';
@@ -550,7 +550,7 @@ var PgVector = class extends MastraVector {
550
550
  } catch (error) {
551
551
  throw new MastraError(
552
552
  {
553
- id: "MASTRA_STORAGE_PG_VECTOR_INITIALIZATION_FAILED",
553
+ id: createVectorErrorId("PG", "INITIALIZATION", "FAILED"),
554
554
  domain: ErrorDomain.MASTRA_VECTOR,
555
555
  category: ErrorCategory.THIRD_PARTY,
556
556
  details: {
@@ -644,7 +644,7 @@ var PgVector = class extends MastraVector {
644
644
  } catch (error) {
645
645
  const mastraError = new MastraError(
646
646
  {
647
- id: "MASTRA_STORAGE_PG_VECTOR_QUERY_INVALID_INPUT",
647
+ id: createVectorErrorId("PG", "QUERY", "INVALID_INPUT"),
648
648
  domain: ErrorDomain.MASTRA_VECTOR,
649
649
  category: ErrorCategory.USER,
650
650
  details: {
@@ -700,7 +700,7 @@ var PgVector = class extends MastraVector {
700
700
  await client.query("ROLLBACK");
701
701
  const mastraError = new MastraError(
702
702
  {
703
- id: "MASTRA_STORAGE_PG_VECTOR_QUERY_FAILED",
703
+ id: createVectorErrorId("PG", "QUERY", "FAILED"),
704
704
  domain: ErrorDomain.MASTRA_VECTOR,
705
705
  category: ErrorCategory.THIRD_PARTY,
706
706
  details: {
@@ -769,7 +769,7 @@ var PgVector = class extends MastraVector {
769
769
  const [, expected, actual] = match;
770
770
  const mastraError2 = new MastraError(
771
771
  {
772
- id: "MASTRA_STORAGE_PG_VECTOR_UPSERT_INVALID_INPUT",
772
+ id: createVectorErrorId("PG", "UPSERT", "INVALID_INPUT"),
773
773
  domain: ErrorDomain.MASTRA_VECTOR,
774
774
  category: ErrorCategory.USER,
775
775
  text: `Vector dimension mismatch: Index "${indexName}" expects ${expected} dimensions but got ${actual} dimensions. Either use a matching embedding model or delete and recreate the index with the new dimension.`,
@@ -787,7 +787,7 @@ var PgVector = class extends MastraVector {
787
787
  }
788
788
  const mastraError = new MastraError(
789
789
  {
790
- id: "MASTRA_STORAGE_PG_VECTOR_UPSERT_FAILED",
790
+ id: createVectorErrorId("PG", "UPSERT", "FAILED"),
791
791
  domain: ErrorDomain.MASTRA_VECTOR,
792
792
  category: ErrorCategory.THIRD_PARTY,
793
793
  details: {
@@ -875,7 +875,7 @@ var PgVector = class extends MastraVector {
875
875
  } catch (error) {
876
876
  const mastraError = new MastraError(
877
877
  {
878
- id: "MASTRA_STORAGE_PG_VECTOR_CREATE_INDEX_INVALID_INPUT",
878
+ id: createVectorErrorId("PG", "CREATE_INDEX", "INVALID_INPUT"),
879
879
  domain: ErrorDomain.MASTRA_VECTOR,
880
880
  category: ErrorCategory.USER,
881
881
  details: {
@@ -925,7 +925,7 @@ var PgVector = class extends MastraVector {
925
925
  }).catch((error) => {
926
926
  const mastraError = new MastraError(
927
927
  {
928
- id: "MASTRA_STORAGE_PG_VECTOR_CREATE_INDEX_FAILED",
928
+ id: createVectorErrorId("PG", "CREATE_INDEX", "FAILED"),
929
929
  domain: ErrorDomain.MASTRA_VECTOR,
930
930
  category: ErrorCategory.THIRD_PARTY,
931
931
  details: {
@@ -945,7 +945,7 @@ var PgVector = class extends MastraVector {
945
945
  } catch (error) {
946
946
  const mastraError = new MastraError(
947
947
  {
948
- id: "MASTRA_STORAGE_PG_VECTOR_BUILD_INDEX_FAILED",
948
+ id: createVectorErrorId("PG", "BUILD_INDEX", "FAILED"),
949
949
  domain: ErrorDomain.MASTRA_VECTOR,
950
950
  category: ErrorCategory.THIRD_PARTY,
951
951
  details: {
@@ -1145,7 +1145,7 @@ var PgVector = class extends MastraVector {
1145
1145
  } catch (e) {
1146
1146
  const mastraError = new MastraError(
1147
1147
  {
1148
- id: "MASTRA_STORAGE_PG_VECTOR_LIST_INDEXES_FAILED",
1148
+ id: createVectorErrorId("PG", "LIST_INDEXES", "FAILED"),
1149
1149
  domain: ErrorDomain.MASTRA_VECTOR,
1150
1150
  category: ErrorCategory.THIRD_PARTY
1151
1151
  },
@@ -1234,7 +1234,7 @@ var PgVector = class extends MastraVector {
1234
1234
  await client.query("ROLLBACK");
1235
1235
  const mastraError = new MastraError(
1236
1236
  {
1237
- id: "MASTRA_STORAGE_PG_VECTOR_DESCRIBE_INDEX_FAILED",
1237
+ id: createVectorErrorId("PG", "DESCRIBE_INDEX", "FAILED"),
1238
1238
  domain: ErrorDomain.MASTRA_VECTOR,
1239
1239
  category: ErrorCategory.THIRD_PARTY,
1240
1240
  details: {
@@ -1259,7 +1259,7 @@ var PgVector = class extends MastraVector {
1259
1259
  await client.query("ROLLBACK");
1260
1260
  const mastraError = new MastraError(
1261
1261
  {
1262
- id: "MASTRA_STORAGE_PG_VECTOR_DELETE_INDEX_FAILED",
1262
+ id: createVectorErrorId("PG", "DELETE_INDEX", "FAILED"),
1263
1263
  domain: ErrorDomain.MASTRA_VECTOR,
1264
1264
  category: ErrorCategory.THIRD_PARTY,
1265
1265
  details: {
@@ -1283,7 +1283,7 @@ var PgVector = class extends MastraVector {
1283
1283
  await client.query("ROLLBACK");
1284
1284
  const mastraError = new MastraError(
1285
1285
  {
1286
- id: "MASTRA_STORAGE_PG_VECTOR_TRUNCATE_INDEX_FAILED",
1286
+ id: createVectorErrorId("PG", "TRUNCATE_INDEX", "FAILED"),
1287
1287
  domain: ErrorDomain.MASTRA_VECTOR,
1288
1288
  category: ErrorCategory.THIRD_PARTY,
1289
1289
  details: {
@@ -1325,7 +1325,7 @@ var PgVector = class extends MastraVector {
1325
1325
  }
1326
1326
  if (!id && !filter) {
1327
1327
  throw new MastraError({
1328
- id: "MASTRA_STORAGE_PG_VECTOR_UPDATE_MISSING_PARAMS",
1328
+ id: createVectorErrorId("PG", "UPDATE_VECTOR", "NO_TARGET"),
1329
1329
  text: "Either id or filter must be provided",
1330
1330
  domain: ErrorDomain.MASTRA_VECTOR,
1331
1331
  category: ErrorCategory.USER,
@@ -1334,7 +1334,7 @@ var PgVector = class extends MastraVector {
1334
1334
  }
1335
1335
  if (id && filter) {
1336
1336
  throw new MastraError({
1337
- id: "MASTRA_STORAGE_PG_VECTOR_UPDATE_CONFLICTING_PARAMS",
1337
+ id: createVectorErrorId("PG", "UPDATE_VECTOR", "MUTUALLY_EXCLUSIVE"),
1338
1338
  text: "Cannot provide both id and filter - they are mutually exclusive",
1339
1339
  domain: ErrorDomain.MASTRA_VECTOR,
1340
1340
  category: ErrorCategory.USER,
@@ -1368,7 +1368,7 @@ var PgVector = class extends MastraVector {
1368
1368
  } else {
1369
1369
  if (!filter || Object.keys(filter).length === 0) {
1370
1370
  throw new MastraError({
1371
- id: "MASTRA_STORAGE_PG_VECTOR_UPDATE_EMPTY_FILTER",
1371
+ id: createVectorErrorId("PG", "UPDATE_VECTOR", "EMPTY_FILTER"),
1372
1372
  text: "Cannot update with empty filter",
1373
1373
  domain: ErrorDomain.MASTRA_VECTOR,
1374
1374
  category: ErrorCategory.USER,
@@ -1380,7 +1380,7 @@ var PgVector = class extends MastraVector {
1380
1380
  whereClause = filterQuery.trim().replace(/^WHERE\s+/i, "");
1381
1381
  if (!whereClause) {
1382
1382
  throw new MastraError({
1383
- id: "MASTRA_STORAGE_PG_VECTOR_UPDATE_INVALID_FILTER",
1383
+ id: createVectorErrorId("PG", "UPDATE_VECTOR", "INVALID_FILTER"),
1384
1384
  text: "Filter produced empty WHERE clause",
1385
1385
  domain: ErrorDomain.MASTRA_VECTOR,
1386
1386
  category: ErrorCategory.USER,
@@ -1411,7 +1411,7 @@ var PgVector = class extends MastraVector {
1411
1411
  }
1412
1412
  const mastraError = new MastraError(
1413
1413
  {
1414
- id: "MASTRA_STORAGE_PG_VECTOR_UPDATE_VECTOR_FAILED",
1414
+ id: createVectorErrorId("PG", "UPDATE_VECTOR", "FAILED"),
1415
1415
  domain: ErrorDomain.MASTRA_VECTOR,
1416
1416
  category: ErrorCategory.THIRD_PARTY,
1417
1417
  details: {
@@ -1448,7 +1448,7 @@ var PgVector = class extends MastraVector {
1448
1448
  } catch (error) {
1449
1449
  const mastraError = new MastraError(
1450
1450
  {
1451
- id: "MASTRA_STORAGE_PG_VECTOR_DELETE_VECTOR_FAILED",
1451
+ id: createVectorErrorId("PG", "DELETE_VECTOR", "FAILED"),
1452
1452
  domain: ErrorDomain.MASTRA_VECTOR,
1453
1453
  category: ErrorCategory.THIRD_PARTY,
1454
1454
  details: {
@@ -1478,7 +1478,7 @@ var PgVector = class extends MastraVector {
1478
1478
  const { tableName } = this.getTableName(indexName);
1479
1479
  if (!filter && !ids) {
1480
1480
  throw new MastraError({
1481
- id: "MASTRA_STORAGE_PG_VECTOR_DELETE_MISSING_PARAMS",
1481
+ id: createVectorErrorId("PG", "DELETE_VECTORS", "NO_TARGET"),
1482
1482
  text: "Either filter or ids must be provided",
1483
1483
  domain: ErrorDomain.MASTRA_VECTOR,
1484
1484
  category: ErrorCategory.USER,
@@ -1487,7 +1487,7 @@ var PgVector = class extends MastraVector {
1487
1487
  }
1488
1488
  if (filter && ids) {
1489
1489
  throw new MastraError({
1490
- id: "MASTRA_STORAGE_PG_VECTOR_DELETE_CONFLICTING_PARAMS",
1490
+ id: createVectorErrorId("PG", "DELETE_VECTORS", "MUTUALLY_EXCLUSIVE"),
1491
1491
  text: "Cannot provide both filter and ids - they are mutually exclusive",
1492
1492
  domain: ErrorDomain.MASTRA_VECTOR,
1493
1493
  category: ErrorCategory.USER,
@@ -1499,7 +1499,7 @@ var PgVector = class extends MastraVector {
1499
1499
  if (ids) {
1500
1500
  if (ids.length === 0) {
1501
1501
  throw new MastraError({
1502
- id: "MASTRA_STORAGE_PG_VECTOR_DELETE_EMPTY_IDS",
1502
+ id: createVectorErrorId("PG", "DELETE_VECTORS", "EMPTY_IDS"),
1503
1503
  text: "Cannot delete with empty ids array",
1504
1504
  domain: ErrorDomain.MASTRA_VECTOR,
1505
1505
  category: ErrorCategory.USER,
@@ -1512,7 +1512,7 @@ var PgVector = class extends MastraVector {
1512
1512
  } else {
1513
1513
  if (!filter || Object.keys(filter).length === 0) {
1514
1514
  throw new MastraError({
1515
- id: "MASTRA_STORAGE_PG_VECTOR_DELETE_EMPTY_FILTER",
1515
+ id: createVectorErrorId("PG", "DELETE_VECTORS", "EMPTY_FILTER"),
1516
1516
  text: "Cannot delete with empty filter. Use deleteIndex to delete all vectors.",
1517
1517
  domain: ErrorDomain.MASTRA_VECTOR,
1518
1518
  category: ErrorCategory.USER,
@@ -1524,7 +1524,7 @@ var PgVector = class extends MastraVector {
1524
1524
  const whereClause = filterQuery.trim().replace(/^WHERE\s+/i, "");
1525
1525
  if (!whereClause) {
1526
1526
  throw new MastraError({
1527
- id: "MASTRA_STORAGE_PG_VECTOR_DELETE_INVALID_FILTER",
1527
+ id: createVectorErrorId("PG", "DELETE_VECTORS", "INVALID_FILTER"),
1528
1528
  text: "Filter produced empty WHERE clause",
1529
1529
  domain: ErrorDomain.MASTRA_VECTOR,
1530
1530
  category: ErrorCategory.USER,
@@ -1547,7 +1547,7 @@ var PgVector = class extends MastraVector {
1547
1547
  }
1548
1548
  const mastraError = new MastraError(
1549
1549
  {
1550
- id: "MASTRA_STORAGE_PG_VECTOR_DELETE_VECTORS_FAILED",
1550
+ id: createVectorErrorId("PG", "DELETE_VECTORS", "FAILED"),
1551
1551
  domain: ErrorDomain.MASTRA_VECTOR,
1552
1552
  category: ErrorCategory.THIRD_PARTY,
1553
1553
  details: {
@@ -1687,7 +1687,7 @@ var MemoryPG = class extends MemoryStorage {
1687
1687
  } catch (error) {
1688
1688
  throw new MastraError(
1689
1689
  {
1690
- id: "MASTRA_STORAGE_PG_STORE_GET_THREAD_BY_ID_FAILED",
1690
+ id: createStorageErrorId("PG", "GET_THREAD_BY_ID", "FAILED"),
1691
1691
  domain: ErrorDomain.STORAGE,
1692
1692
  category: ErrorCategory.THIRD_PARTY,
1693
1693
  details: {
@@ -1702,7 +1702,7 @@ var MemoryPG = class extends MemoryStorage {
1702
1702
  const { resourceId, page = 0, perPage: perPageInput, orderBy } = args;
1703
1703
  if (page < 0) {
1704
1704
  throw new MastraError({
1705
- id: "MASTRA_STORAGE_PG_STORE_INVALID_PAGE",
1705
+ id: createStorageErrorId("PG", "LIST_THREADS_BY_RESOURCE_ID", "INVALID_PAGE"),
1706
1706
  domain: ErrorDomain.STORAGE,
1707
1707
  category: ErrorCategory.USER,
1708
1708
  text: "Page number must be non-negative",
@@ -1751,7 +1751,7 @@ var MemoryPG = class extends MemoryStorage {
1751
1751
  } catch (error) {
1752
1752
  const mastraError = new MastraError(
1753
1753
  {
1754
- id: "MASTRA_STORAGE_PG_STORE_LIST_THREADS_BY_RESOURCE_ID_FAILED",
1754
+ id: createStorageErrorId("PG", "LIST_THREADS_BY_RESOURCE_ID", "FAILED"),
1755
1755
  domain: ErrorDomain.STORAGE,
1756
1756
  category: ErrorCategory.THIRD_PARTY,
1757
1757
  details: {
@@ -1809,7 +1809,7 @@ var MemoryPG = class extends MemoryStorage {
1809
1809
  } catch (error) {
1810
1810
  throw new MastraError(
1811
1811
  {
1812
- id: "MASTRA_STORAGE_PG_STORE_SAVE_THREAD_FAILED",
1812
+ id: createStorageErrorId("PG", "SAVE_THREAD", "FAILED"),
1813
1813
  domain: ErrorDomain.STORAGE,
1814
1814
  category: ErrorCategory.THIRD_PARTY,
1815
1815
  details: {
@@ -1829,7 +1829,7 @@ var MemoryPG = class extends MemoryStorage {
1829
1829
  const existingThread = await this.getThreadById({ threadId: id });
1830
1830
  if (!existingThread) {
1831
1831
  throw new MastraError({
1832
- id: "MASTRA_STORAGE_PG_STORE_UPDATE_THREAD_FAILED",
1832
+ id: createStorageErrorId("PG", "UPDATE_THREAD", "FAILED"),
1833
1833
  domain: ErrorDomain.STORAGE,
1834
1834
  category: ErrorCategory.USER,
1835
1835
  text: `Thread ${id} not found`,
@@ -1867,7 +1867,7 @@ var MemoryPG = class extends MemoryStorage {
1867
1867
  } catch (error) {
1868
1868
  throw new MastraError(
1869
1869
  {
1870
- id: "MASTRA_STORAGE_PG_STORE_UPDATE_THREAD_FAILED",
1870
+ id: createStorageErrorId("PG", "UPDATE_THREAD", "FAILED"),
1871
1871
  domain: ErrorDomain.STORAGE,
1872
1872
  category: ErrorCategory.THIRD_PARTY,
1873
1873
  details: {
@@ -1904,7 +1904,7 @@ var MemoryPG = class extends MemoryStorage {
1904
1904
  } catch (error) {
1905
1905
  throw new MastraError(
1906
1906
  {
1907
- id: "MASTRA_STORAGE_PG_STORE_DELETE_THREAD_FAILED",
1907
+ id: createStorageErrorId("PG", "DELETE_THREAD", "FAILED"),
1908
1908
  domain: ErrorDomain.STORAGE,
1909
1909
  category: ErrorCategory.THIRD_PARTY,
1910
1910
  details: {
@@ -2011,7 +2011,7 @@ var MemoryPG = class extends MemoryStorage {
2011
2011
  } catch (error) {
2012
2012
  const mastraError = new MastraError(
2013
2013
  {
2014
- id: "MASTRA_STORAGE_PG_STORE_LIST_MESSAGES_BY_ID_FAILED",
2014
+ id: createStorageErrorId("PG", "LIST_MESSAGES_BY_ID", "FAILED"),
2015
2015
  domain: ErrorDomain.STORAGE,
2016
2016
  category: ErrorCategory.THIRD_PARTY,
2017
2017
  details: {
@@ -2033,7 +2033,7 @@ var MemoryPG = class extends MemoryStorage {
2033
2033
  if (threadIds.length === 0 || threadIds.some((id) => !id.trim())) {
2034
2034
  throw new MastraError(
2035
2035
  {
2036
- id: "STORAGE_PG_LIST_MESSAGES_INVALID_THREAD_ID",
2036
+ id: createStorageErrorId("PG", "LIST_MESSAGES", "INVALID_THREAD_ID"),
2037
2037
  domain: ErrorDomain.STORAGE,
2038
2038
  category: ErrorCategory.THIRD_PARTY,
2039
2039
  details: { threadId: Array.isArray(threadId) ? String(threadId) : String(threadId) }
@@ -2043,7 +2043,7 @@ var MemoryPG = class extends MemoryStorage {
2043
2043
  }
2044
2044
  if (page < 0) {
2045
2045
  throw new MastraError({
2046
- id: "MASTRA_STORAGE_PG_STORE_INVALID_PAGE",
2046
+ id: createStorageErrorId("PG", "LIST_MESSAGES", "INVALID_PAGE"),
2047
2047
  domain: ErrorDomain.STORAGE,
2048
2048
  category: ErrorCategory.USER,
2049
2049
  text: "Page number must be non-negative",
@@ -2138,7 +2138,7 @@ var MemoryPG = class extends MemoryStorage {
2138
2138
  } catch (error) {
2139
2139
  const mastraError = new MastraError(
2140
2140
  {
2141
- id: "MASTRA_STORAGE_PG_STORE_LIST_MESSAGES_FAILED",
2141
+ id: createStorageErrorId("PG", "LIST_MESSAGES", "FAILED"),
2142
2142
  domain: ErrorDomain.STORAGE,
2143
2143
  category: ErrorCategory.THIRD_PARTY,
2144
2144
  details: {
@@ -2164,7 +2164,7 @@ var MemoryPG = class extends MemoryStorage {
2164
2164
  const threadId = messages[0]?.threadId;
2165
2165
  if (!threadId) {
2166
2166
  throw new MastraError({
2167
- id: "MASTRA_STORAGE_PG_STORE_SAVE_MESSAGES_FAILED",
2167
+ id: createStorageErrorId("PG", "SAVE_MESSAGES", "FAILED"),
2168
2168
  domain: ErrorDomain.STORAGE,
2169
2169
  category: ErrorCategory.THIRD_PARTY,
2170
2170
  text: `Thread ID is required`
@@ -2173,7 +2173,7 @@ var MemoryPG = class extends MemoryStorage {
2173
2173
  const thread = await this.getThreadById({ threadId });
2174
2174
  if (!thread) {
2175
2175
  throw new MastraError({
2176
- id: "MASTRA_STORAGE_PG_STORE_SAVE_MESSAGES_FAILED",
2176
+ id: createStorageErrorId("PG", "SAVE_MESSAGES", "FAILED"),
2177
2177
  domain: ErrorDomain.STORAGE,
2178
2178
  category: ErrorCategory.THIRD_PARTY,
2179
2179
  text: `Thread ${threadId} not found`,
@@ -2244,7 +2244,7 @@ var MemoryPG = class extends MemoryStorage {
2244
2244
  } catch (error) {
2245
2245
  throw new MastraError(
2246
2246
  {
2247
- id: "MASTRA_STORAGE_PG_STORE_SAVE_MESSAGES_FAILED",
2247
+ id: createStorageErrorId("PG", "SAVE_MESSAGES", "FAILED"),
2248
2248
  domain: ErrorDomain.STORAGE,
2249
2249
  category: ErrorCategory.THIRD_PARTY,
2250
2250
  details: {
@@ -2373,7 +2373,7 @@ var MemoryPG = class extends MemoryStorage {
2373
2373
  } catch (error) {
2374
2374
  throw new MastraError(
2375
2375
  {
2376
- id: "PG_STORE_DELETE_MESSAGES_FAILED",
2376
+ id: createStorageErrorId("PG", "DELETE_MESSAGES", "FAILED"),
2377
2377
  domain: ErrorDomain.STORAGE,
2378
2378
  category: ErrorCategory.THIRD_PARTY,
2379
2379
  details: { messageIds: messageIds.join(", ") }
@@ -2494,7 +2494,7 @@ var ObservabilityPG = class extends ObservabilityStorage {
2494
2494
  } catch (error) {
2495
2495
  throw new MastraError(
2496
2496
  {
2497
- id: "PG_STORE_CREATE_SPAN_FAILED",
2497
+ id: createStorageErrorId("PG", "CREATE_SPAN", "FAILED"),
2498
2498
  domain: ErrorDomain.STORAGE,
2499
2499
  category: ErrorCategory.USER,
2500
2500
  details: {
@@ -2540,7 +2540,7 @@ var ObservabilityPG = class extends ObservabilityStorage {
2540
2540
  } catch (error) {
2541
2541
  throw new MastraError(
2542
2542
  {
2543
- id: "PG_STORE_GET_TRACE_FAILED",
2543
+ id: createStorageErrorId("PG", "GET_TRACE", "FAILED"),
2544
2544
  domain: ErrorDomain.STORAGE,
2545
2545
  category: ErrorCategory.USER,
2546
2546
  details: {
@@ -2572,7 +2572,7 @@ var ObservabilityPG = class extends ObservabilityStorage {
2572
2572
  } catch (error) {
2573
2573
  throw new MastraError(
2574
2574
  {
2575
- id: "PG_STORE_UPDATE_SPAN_FAILED",
2575
+ id: createStorageErrorId("PG", "UPDATE_SPAN", "FAILED"),
2576
2576
  domain: ErrorDomain.STORAGE,
2577
2577
  category: ErrorCategory.USER,
2578
2578
  details: {
@@ -2608,7 +2608,7 @@ var ObservabilityPG = class extends ObservabilityStorage {
2608
2608
  name = `agent run: '${entityId}'`;
2609
2609
  } else {
2610
2610
  const error = new MastraError({
2611
- id: "PG_STORE_GET_TRACES_PAGINATED_FAILED",
2611
+ id: createStorageErrorId("PG", "GET_TRACES_PAGINATED", "INVALID_ENTITY_TYPE"),
2612
2612
  domain: ErrorDomain.STORAGE,
2613
2613
  category: ErrorCategory.USER,
2614
2614
  details: {
@@ -2676,7 +2676,7 @@ var ObservabilityPG = class extends ObservabilityStorage {
2676
2676
  } catch (error) {
2677
2677
  throw new MastraError(
2678
2678
  {
2679
- id: "PG_STORE_GET_TRACES_PAGINATED_FAILED",
2679
+ id: createStorageErrorId("PG", "GET_TRACES_PAGINATED", "FAILED"),
2680
2680
  domain: ErrorDomain.STORAGE,
2681
2681
  category: ErrorCategory.USER
2682
2682
  },
@@ -2705,7 +2705,7 @@ var ObservabilityPG = class extends ObservabilityStorage {
2705
2705
  } catch (error) {
2706
2706
  throw new MastraError(
2707
2707
  {
2708
- id: "PG_STORE_BATCH_CREATE_SPANS_FAILED",
2708
+ id: createStorageErrorId("PG", "BATCH_CREATE_SPANS", "FAILED"),
2709
2709
  domain: ErrorDomain.STORAGE,
2710
2710
  category: ErrorCategory.USER
2711
2711
  },
@@ -2740,7 +2740,7 @@ var ObservabilityPG = class extends ObservabilityStorage {
2740
2740
  } catch (error) {
2741
2741
  throw new MastraError(
2742
2742
  {
2743
- id: "PG_STORE_BATCH_UPDATE_SPANS_FAILED",
2743
+ id: createStorageErrorId("PG", "BATCH_UPDATE_SPANS", "FAILED"),
2744
2744
  domain: ErrorDomain.STORAGE,
2745
2745
  category: ErrorCategory.USER
2746
2746
  },
@@ -2759,7 +2759,7 @@ var ObservabilityPG = class extends ObservabilityStorage {
2759
2759
  } catch (error) {
2760
2760
  throw new MastraError(
2761
2761
  {
2762
- id: "PG_STORE_BATCH_DELETE_TRACES_FAILED",
2762
+ id: createStorageErrorId("PG", "BATCH_DELETE_TRACES", "FAILED"),
2763
2763
  domain: ErrorDomain.STORAGE,
2764
2764
  category: ErrorCategory.USER
2765
2765
  },
@@ -2889,7 +2889,7 @@ var StoreOperationsPG = class extends StoreOperations {
2889
2889
  } catch (error) {
2890
2890
  throw new MastraError(
2891
2891
  {
2892
- id: "MASTRA_STORAGE_PG_STORE_INSERT_FAILED",
2892
+ id: createStorageErrorId("PG", "INSERT", "FAILED"),
2893
2893
  domain: ErrorDomain.STORAGE,
2894
2894
  category: ErrorCategory.THIRD_PARTY,
2895
2895
  details: {
@@ -2908,7 +2908,7 @@ var StoreOperationsPG = class extends StoreOperations {
2908
2908
  } catch (error) {
2909
2909
  throw new MastraError(
2910
2910
  {
2911
- id: "MASTRA_STORAGE_PG_STORE_CLEAR_TABLE_FAILED",
2911
+ id: createStorageErrorId("PG", "CLEAR_TABLE", "FAILED"),
2912
2912
  domain: ErrorDomain.STORAGE,
2913
2913
  category: ErrorCategory.THIRD_PARTY,
2914
2914
  details: {
@@ -2981,7 +2981,7 @@ var StoreOperationsPG = class extends StoreOperations {
2981
2981
  } catch (error) {
2982
2982
  throw new MastraError(
2983
2983
  {
2984
- id: "MASTRA_STORAGE_PG_STORE_CREATE_TABLE_FAILED",
2984
+ id: createStorageErrorId("PG", "CREATE_TABLE", "FAILED"),
2985
2985
  domain: ErrorDomain.STORAGE,
2986
2986
  category: ErrorCategory.THIRD_PARTY,
2987
2987
  details: {
@@ -3068,7 +3068,7 @@ var StoreOperationsPG = class extends StoreOperations {
3068
3068
  } catch (error) {
3069
3069
  throw new MastraError(
3070
3070
  {
3071
- id: "MASTRA_STORAGE_PG_STORE_ALTER_TABLE_FAILED",
3071
+ id: createStorageErrorId("PG", "ALTER_TABLE", "FAILED"),
3072
3072
  domain: ErrorDomain.STORAGE,
3073
3073
  category: ErrorCategory.THIRD_PARTY,
3074
3074
  details: {
@@ -3102,7 +3102,7 @@ var StoreOperationsPG = class extends StoreOperations {
3102
3102
  } catch (error) {
3103
3103
  throw new MastraError(
3104
3104
  {
3105
- id: "MASTRA_STORAGE_PG_STORE_LOAD_FAILED",
3105
+ id: createStorageErrorId("PG", "LOAD", "FAILED"),
3106
3106
  domain: ErrorDomain.STORAGE,
3107
3107
  category: ErrorCategory.THIRD_PARTY,
3108
3108
  details: {
@@ -3124,7 +3124,7 @@ var StoreOperationsPG = class extends StoreOperations {
3124
3124
  await this.client.query("ROLLBACK");
3125
3125
  throw new MastraError(
3126
3126
  {
3127
- id: "MASTRA_STORAGE_PG_STORE_BATCH_INSERT_FAILED",
3127
+ id: createStorageErrorId("PG", "BATCH_INSERT", "FAILED"),
3128
3128
  domain: ErrorDomain.STORAGE,
3129
3129
  category: ErrorCategory.THIRD_PARTY,
3130
3130
  details: {
@@ -3144,7 +3144,7 @@ var StoreOperationsPG = class extends StoreOperations {
3144
3144
  } catch (error) {
3145
3145
  throw new MastraError(
3146
3146
  {
3147
- id: "MASTRA_STORAGE_PG_STORE_DROP_TABLE_FAILED",
3147
+ id: createStorageErrorId("PG", "DROP_TABLE", "FAILED"),
3148
3148
  domain: ErrorDomain.STORAGE,
3149
3149
  category: ErrorCategory.THIRD_PARTY,
3150
3150
  details: {
@@ -3217,7 +3217,7 @@ var StoreOperationsPG = class extends StoreOperations {
3217
3217
  }
3218
3218
  throw new MastraError(
3219
3219
  {
3220
- id: "MASTRA_STORAGE_PG_INDEX_CREATE_FAILED",
3220
+ id: createStorageErrorId("PG", "INDEX_CREATE", "FAILED"),
3221
3221
  domain: ErrorDomain.STORAGE,
3222
3222
  category: ErrorCategory.THIRD_PARTY,
3223
3223
  details: {
@@ -3249,7 +3249,7 @@ var StoreOperationsPG = class extends StoreOperations {
3249
3249
  } catch (error) {
3250
3250
  throw new MastraError(
3251
3251
  {
3252
- id: "MASTRA_STORAGE_PG_INDEX_DROP_FAILED",
3252
+ id: createStorageErrorId("PG", "INDEX_DROP", "FAILED"),
3253
3253
  domain: ErrorDomain.STORAGE,
3254
3254
  category: ErrorCategory.THIRD_PARTY,
3255
3255
  details: {
@@ -3325,7 +3325,7 @@ var StoreOperationsPG = class extends StoreOperations {
3325
3325
  } catch (error) {
3326
3326
  throw new MastraError(
3327
3327
  {
3328
- id: "MASTRA_STORAGE_PG_INDEX_LIST_FAILED",
3328
+ id: createStorageErrorId("PG", "INDEX_LIST", "FAILED"),
3329
3329
  domain: ErrorDomain.STORAGE,
3330
3330
  category: ErrorCategory.THIRD_PARTY,
3331
3331
  details: tableName ? {
@@ -3407,7 +3407,7 @@ var StoreOperationsPG = class extends StoreOperations {
3407
3407
  } catch (error) {
3408
3408
  throw new MastraError(
3409
3409
  {
3410
- id: "MASTRA_STORAGE_PG_STORE_CREATE_PERFORMANCE_INDEXES_FAILED",
3410
+ id: createStorageErrorId("PG", "CREATE_AUTOMATIC_INDEXES", "FAILED"),
3411
3411
  domain: ErrorDomain.STORAGE,
3412
3412
  category: ErrorCategory.THIRD_PARTY
3413
3413
  },
@@ -3469,7 +3469,7 @@ var StoreOperationsPG = class extends StoreOperations {
3469
3469
  } catch (error) {
3470
3470
  throw new MastraError(
3471
3471
  {
3472
- id: "MASTRA_STORAGE_PG_INDEX_DESCRIBE_FAILED",
3472
+ id: createStorageErrorId("PG", "INDEX_DESCRIBE", "FAILED"),
3473
3473
  domain: ErrorDomain.STORAGE,
3474
3474
  category: ErrorCategory.THIRD_PARTY,
3475
3475
  details: {
@@ -3514,7 +3514,7 @@ var StoreOperationsPG = class extends StoreOperations {
3514
3514
  } catch (error) {
3515
3515
  throw new MastraError(
3516
3516
  {
3517
- id: "MASTRA_STORAGE_PG_STORE_UPDATE_FAILED",
3517
+ id: createStorageErrorId("PG", "UPDATE", "FAILED"),
3518
3518
  domain: ErrorDomain.STORAGE,
3519
3519
  category: ErrorCategory.THIRD_PARTY,
3520
3520
  details: {
@@ -3542,7 +3542,7 @@ var StoreOperationsPG = class extends StoreOperations {
3542
3542
  await this.client.query("ROLLBACK");
3543
3543
  throw new MastraError(
3544
3544
  {
3545
- id: "MASTRA_STORAGE_PG_STORE_BATCH_UPDATE_FAILED",
3545
+ id: createStorageErrorId("PG", "BATCH_UPDATE", "FAILED"),
3546
3546
  domain: ErrorDomain.STORAGE,
3547
3547
  category: ErrorCategory.THIRD_PARTY,
3548
3548
  details: {
@@ -3583,7 +3583,7 @@ var StoreOperationsPG = class extends StoreOperations {
3583
3583
  } catch (error) {
3584
3584
  throw new MastraError(
3585
3585
  {
3586
- id: "MASTRA_STORAGE_PG_STORE_BATCH_DELETE_FAILED",
3586
+ id: createStorageErrorId("PG", "BATCH_DELETE", "FAILED"),
3587
3587
  domain: ErrorDomain.STORAGE,
3588
3588
  category: ErrorCategory.THIRD_PARTY,
3589
3589
  details: {
@@ -3628,7 +3628,7 @@ var ScoresPG = class extends ScoresStorage {
3628
3628
  } catch (error) {
3629
3629
  throw new MastraError(
3630
3630
  {
3631
- id: "MASTRA_STORAGE_PG_STORE_GET_SCORE_BY_ID_FAILED",
3631
+ id: createStorageErrorId("PG", "GET_SCORE_BY_ID", "FAILED"),
3632
3632
  domain: ErrorDomain.STORAGE,
3633
3633
  category: ErrorCategory.THIRD_PARTY
3634
3634
  },
@@ -3696,7 +3696,7 @@ var ScoresPG = class extends ScoresStorage {
3696
3696
  } catch (error) {
3697
3697
  throw new MastraError(
3698
3698
  {
3699
- id: "MASTRA_STORAGE_PG_STORE_GET_SCORES_BY_SCORER_ID_FAILED",
3699
+ id: createStorageErrorId("PG", "GET_SCORES_BY_SCORER_ID", "FAILED"),
3700
3700
  domain: ErrorDomain.STORAGE,
3701
3701
  category: ErrorCategory.THIRD_PARTY
3702
3702
  },
@@ -3711,7 +3711,7 @@ var ScoresPG = class extends ScoresStorage {
3711
3711
  } catch (error) {
3712
3712
  throw new MastraError(
3713
3713
  {
3714
- id: "MASTRA_STORAGE_PG_STORE_SAVE_SCORE_FAILED_INVALID_SCORE_PAYLOAD",
3714
+ id: createStorageErrorId("PG", "SAVE_SCORE", "INVALID_PAYLOAD"),
3715
3715
  domain: ErrorDomain.STORAGE,
3716
3716
  category: ErrorCategory.USER,
3717
3717
  details: {
@@ -3760,7 +3760,7 @@ var ScoresPG = class extends ScoresStorage {
3760
3760
  } catch (error) {
3761
3761
  throw new MastraError(
3762
3762
  {
3763
- id: "MASTRA_STORAGE_PG_STORE_SAVE_SCORE_FAILED",
3763
+ id: createStorageErrorId("PG", "SAVE_SCORE", "FAILED"),
3764
3764
  domain: ErrorDomain.STORAGE,
3765
3765
  category: ErrorCategory.THIRD_PARTY
3766
3766
  },
@@ -3809,7 +3809,7 @@ var ScoresPG = class extends ScoresStorage {
3809
3809
  } catch (error) {
3810
3810
  throw new MastraError(
3811
3811
  {
3812
- id: "MASTRA_STORAGE_PG_STORE_GET_SCORES_BY_RUN_ID_FAILED",
3812
+ id: createStorageErrorId("PG", "GET_SCORES_BY_RUN_ID", "FAILED"),
3813
3813
  domain: ErrorDomain.STORAGE,
3814
3814
  category: ErrorCategory.THIRD_PARTY
3815
3815
  },
@@ -3859,7 +3859,7 @@ var ScoresPG = class extends ScoresStorage {
3859
3859
  } catch (error) {
3860
3860
  throw new MastraError(
3861
3861
  {
3862
- id: "MASTRA_STORAGE_PG_STORE_GET_SCORES_BY_ENTITY_ID_FAILED",
3862
+ id: createStorageErrorId("PG", "GET_SCORES_BY_ENTITY_ID", "FAILED"),
3863
3863
  domain: ErrorDomain.STORAGE,
3864
3864
  category: ErrorCategory.THIRD_PARTY
3865
3865
  },
@@ -3902,7 +3902,7 @@ var ScoresPG = class extends ScoresStorage {
3902
3902
  } catch (error) {
3903
3903
  throw new MastraError(
3904
3904
  {
3905
- id: "MASTRA_STORAGE_PG_STORE_GET_SCORES_BY_SPAN_FAILED",
3905
+ id: createStorageErrorId("PG", "GET_SCORES_BY_SPAN", "FAILED"),
3906
3906
  domain: ErrorDomain.STORAGE,
3907
3907
  category: ErrorCategory.THIRD_PARTY
3908
3908
  },
@@ -3977,7 +3977,7 @@ var WorkflowsPG = class extends WorkflowsStorage {
3977
3977
  } catch (error) {
3978
3978
  throw new MastraError(
3979
3979
  {
3980
- id: "MASTRA_STORAGE_PG_STORE_PERSIST_WORKFLOW_SNAPSHOT_FAILED",
3980
+ id: createStorageErrorId("PG", "PERSIST_WORKFLOW_SNAPSHOT", "FAILED"),
3981
3981
  domain: ErrorDomain.STORAGE,
3982
3982
  category: ErrorCategory.THIRD_PARTY
3983
3983
  },
@@ -3998,7 +3998,7 @@ var WorkflowsPG = class extends WorkflowsStorage {
3998
3998
  } catch (error) {
3999
3999
  throw new MastraError(
4000
4000
  {
4001
- id: "MASTRA_STORAGE_PG_STORE_LOAD_WORKFLOW_SNAPSHOT_FAILED",
4001
+ id: createStorageErrorId("PG", "LOAD_WORKFLOW_SNAPSHOT", "FAILED"),
4002
4002
  domain: ErrorDomain.STORAGE,
4003
4003
  category: ErrorCategory.THIRD_PARTY
4004
4004
  },
@@ -4039,7 +4039,7 @@ var WorkflowsPG = class extends WorkflowsStorage {
4039
4039
  } catch (error) {
4040
4040
  throw new MastraError(
4041
4041
  {
4042
- id: "MASTRA_STORAGE_PG_STORE_GET_WORKFLOW_RUN_BY_ID_FAILED",
4042
+ id: createStorageErrorId("PG", "GET_WORKFLOW_RUN_BY_ID", "FAILED"),
4043
4043
  domain: ErrorDomain.STORAGE,
4044
4044
  category: ErrorCategory.THIRD_PARTY,
4045
4045
  details: {
@@ -4121,7 +4121,7 @@ var WorkflowsPG = class extends WorkflowsStorage {
4121
4121
  } catch (error) {
4122
4122
  throw new MastraError(
4123
4123
  {
4124
- id: "MASTRA_STORAGE_PG_STORE_LIST_WORKFLOW_RUNS_FAILED",
4124
+ id: createStorageErrorId("PG", "LIST_WORKFLOW_RUNS", "FAILED"),
4125
4125
  domain: ErrorDomain.STORAGE,
4126
4126
  category: ErrorCategory.THIRD_PARTY,
4127
4127
  details: {
@@ -4145,7 +4145,7 @@ var PostgresStore = class extends MastraStorage {
4145
4145
  constructor(config) {
4146
4146
  try {
4147
4147
  validateConfig("PostgresStore", config);
4148
- super({ id: config.id, name: "PostgresStore" });
4148
+ super({ id: config.id, name: "PostgresStore", disableInit: config.disableInit });
4149
4149
  this.schema = config.schemaName || "public";
4150
4150
  if (isConnectionStringConfig(config)) {
4151
4151
  this.#config = {
@@ -4183,7 +4183,7 @@ var PostgresStore = class extends MastraStorage {
4183
4183
  } catch (e) {
4184
4184
  throw new MastraError(
4185
4185
  {
4186
- id: "MASTRA_STORAGE_PG_STORE_INITIALIZATION_FAILED",
4186
+ id: createStorageErrorId("PG", "INITIALIZATION", "FAILED"),
4187
4187
  domain: ErrorDomain.STORAGE,
4188
4188
  category: ErrorCategory.USER
4189
4189
  },
@@ -4221,7 +4221,7 @@ var PostgresStore = class extends MastraStorage {
4221
4221
  this.isConnected = false;
4222
4222
  throw new MastraError(
4223
4223
  {
4224
- id: "MASTRA_STORAGE_POSTGRES_STORE_INIT_FAILED",
4224
+ id: createStorageErrorId("PG", "INIT", "FAILED"),
4225
4225
  domain: ErrorDomain.STORAGE,
4226
4226
  category: ErrorCategory.THIRD_PARTY
4227
4227
  },
@@ -4378,7 +4378,7 @@ var PostgresStore = class extends MastraStorage {
4378
4378
  async createSpan(span) {
4379
4379
  if (!this.stores.observability) {
4380
4380
  throw new MastraError({
4381
- id: "PG_STORE_OBSERVABILITY_NOT_INITIALIZED",
4381
+ id: createStorageErrorId("PG", "OBSERVABILITY", "NOT_INITIALIZED"),
4382
4382
  domain: ErrorDomain.STORAGE,
4383
4383
  category: ErrorCategory.SYSTEM,
4384
4384
  text: "Observability storage is not initialized"
@@ -4393,7 +4393,7 @@ var PostgresStore = class extends MastraStorage {
4393
4393
  }) {
4394
4394
  if (!this.stores.observability) {
4395
4395
  throw new MastraError({
4396
- id: "PG_STORE_OBSERVABILITY_NOT_INITIALIZED",
4396
+ id: createStorageErrorId("PG", "OBSERVABILITY", "NOT_INITIALIZED"),
4397
4397
  domain: ErrorDomain.STORAGE,
4398
4398
  category: ErrorCategory.SYSTEM,
4399
4399
  text: "Observability storage is not initialized"
@@ -4404,7 +4404,7 @@ var PostgresStore = class extends MastraStorage {
4404
4404
  async getTrace(traceId) {
4405
4405
  if (!this.stores.observability) {
4406
4406
  throw new MastraError({
4407
- id: "PG_STORE_OBSERVABILITY_NOT_INITIALIZED",
4407
+ id: createStorageErrorId("PG", "OBSERVABILITY", "NOT_INITIALIZED"),
4408
4408
  domain: ErrorDomain.STORAGE,
4409
4409
  category: ErrorCategory.SYSTEM,
4410
4410
  text: "Observability storage is not initialized"
@@ -4415,7 +4415,7 @@ var PostgresStore = class extends MastraStorage {
4415
4415
  async getTracesPaginated(args) {
4416
4416
  if (!this.stores.observability) {
4417
4417
  throw new MastraError({
4418
- id: "PG_STORE_OBSERVABILITY_NOT_INITIALIZED",
4418
+ id: createStorageErrorId("PG", "OBSERVABILITY", "NOT_INITIALIZED"),
4419
4419
  domain: ErrorDomain.STORAGE,
4420
4420
  category: ErrorCategory.SYSTEM,
4421
4421
  text: "Observability storage is not initialized"
@@ -4426,7 +4426,7 @@ var PostgresStore = class extends MastraStorage {
4426
4426
  async batchCreateSpans(args) {
4427
4427
  if (!this.stores.observability) {
4428
4428
  throw new MastraError({
4429
- id: "PG_STORE_OBSERVABILITY_NOT_INITIALIZED",
4429
+ id: createStorageErrorId("PG", "OBSERVABILITY", "NOT_INITIALIZED"),
4430
4430
  domain: ErrorDomain.STORAGE,
4431
4431
  category: ErrorCategory.SYSTEM,
4432
4432
  text: "Observability storage is not initialized"
@@ -4437,7 +4437,7 @@ var PostgresStore = class extends MastraStorage {
4437
4437
  async batchUpdateSpans(args) {
4438
4438
  if (!this.stores.observability) {
4439
4439
  throw new MastraError({
4440
- id: "PG_STORE_OBSERVABILITY_NOT_INITIALIZED",
4440
+ id: createStorageErrorId("PG", "OBSERVABILITY", "NOT_INITIALIZED"),
4441
4441
  domain: ErrorDomain.STORAGE,
4442
4442
  category: ErrorCategory.SYSTEM,
4443
4443
  text: "Observability storage is not initialized"
@@ -4448,7 +4448,7 @@ var PostgresStore = class extends MastraStorage {
4448
4448
  async batchDeleteTraces(args) {
4449
4449
  if (!this.stores.observability) {
4450
4450
  throw new MastraError({
4451
- id: "PG_STORE_OBSERVABILITY_NOT_INITIALIZED",
4451
+ id: createStorageErrorId("PG", "OBSERVABILITY", "NOT_INITIALIZED"),
4452
4452
  domain: ErrorDomain.STORAGE,
4453
4453
  category: ErrorCategory.SYSTEM,
4454
4454
  text: "Observability storage is not initialized"