@mastra/pg 1.26.0-alpha.3 → 1.26.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.
@@ -7,10 +7,20 @@ export declare function truncateIdentifier(value: string, maxLength?: number): s
7
7
  * in system catalogs (pg_constraint.conname, pg_indexes.indexname, etc.).
8
8
  * Without this normalisation, runtime lookups that compare a mixed-case name
9
9
  * against the catalog would silently fail.
10
+ *
11
+ * With `hashWhenTruncated`, a name that exceeds the limit is truncated further
12
+ * to make room for `_` + 8 hex chars of the full name's sha256. Plain
13
+ * truncation cuts the tail, so two names sharing a long `<schema>_<prefix>`
14
+ * collapse to the same identifier and `CREATE INDEX IF NOT EXISTS` (which
15
+ * matches by name only) silently skips the second one. The suffix is
16
+ * deterministic, so creation, warm-init snapshot checks, and DDL export all
17
+ * agree on the same name. Opt-in because renaming already-released constraint
18
+ * names would orphan the existing objects in deployed catalogs.
10
19
  */
11
- export declare function buildConstraintName({ baseName, schemaName, maxLength, }: {
20
+ export declare function buildConstraintName({ baseName, schemaName, maxLength, hashWhenTruncated, }: {
12
21
  baseName: string;
13
22
  schemaName?: string;
14
23
  maxLength?: number;
24
+ hashWhenTruncated?: boolean;
15
25
  }): string;
16
26
  //# sourceMappingURL=constraint-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constraint-utils.d.ts","sourceRoot":"","sources":["../../../src/storage/db/constraint-utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,8BAA8B,KAAK,CAAC;AAEjD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAiC,GAAG,MAAM,CAapG;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,UAAU,EACV,SAA0C,GAC3C,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAGT"}
1
+ {"version":3,"file":"constraint-utils.d.ts","sourceRoot":"","sources":["../../../src/storage/db/constraint-utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,8BAA8B,KAAK,CAAC;AAKjD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAiC,GAAG,MAAM,CAapG;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,UAAU,EACV,SAA0C,EAC1C,iBAAyB,GAC1B,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,GAAG,MAAM,CAkBT"}
@@ -4,6 +4,37 @@ import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
4
4
  import type { PgDomainConfig } from '../../db/index.js';
5
5
  import { sanitizeJsonForPg } from '../../db/sanitize-json.js';
6
6
  export { sanitizeJsonForPg };
7
+ /**
8
+ * Schema-prefixed name of the status index, lowercased and truncated the same way Postgres
9
+ * stores it, so the init snapshot's index set answers "does it exist?" without a probe or a
10
+ * no-op `CREATE INDEX` (schema-prefixed names routinely exceed the 63-byte limit).
11
+ * Exported for tests.
12
+ */
13
+ export declare function workflowSnapshotStatusIndexName(schemaName?: string): string;
14
+ /**
15
+ * Schema-prefixed name of the threadId index (see workflowSnapshotStatusIndexName).
16
+ *
17
+ * Unlike the status index, truncation appends a collision hash: both index names share the
18
+ * long `<schema>_mastra_workflow_snapshot_` prefix, so with a schema name of 37+ bytes plain
19
+ * truncation collapses them to the same 63-byte identifier and `CREATE INDEX IF NOT EXISTS`
20
+ * silently skips this index. The status index keeps plain truncation because its truncated
21
+ * name already exists in deployed catalogs; this index is new and free to adopt the rule.
22
+ * Exported for tests.
23
+ */
24
+ export declare function workflowSnapshotThreadIdIndexName(schemaName?: string): string;
25
+ /**
26
+ * Expression extracting the thread id embedded in a snapshot (jsonb columns only). Mirrors
27
+ * the canonical extraction in `@mastra/core` (`getSnapshotMemoryInfo`), which reads one of
28
+ * two layouts:
29
+ * 1. agentic-loop: `context.<suspended step>.suspendPayload.__streamState.messageList.memoryInfo.threadId`
30
+ * 2. durable loop: `context.input.messageListState.memoryInfo.threadId`
31
+ *
32
+ * `jsonb_path_query_first(jsonb, jsonpath)` is IMMUTABLE, so the expression is valid in an
33
+ * expression index. The WHERE clause in listWorkflowRuns() must use this exact expression
34
+ * text so the planner can match it against the index. If the snapshot layout changes in
35
+ * core, this expression must be updated in lockstep or it will wrongly exclude rows.
36
+ */
37
+ export declare const WORKFLOW_SNAPSHOT_THREAD_ID_EXPR = "COALESCE(jsonb_path_query_first(snapshot, '$.context.* ? (@.status == \"suspended\").suspendPayload.__streamState.messageList.memoryInfo.threadId') #>> '{}', snapshot #>> '{context,input,messageListState,memoryInfo,threadId}')";
7
38
  export declare class WorkflowsPG extends WorkflowsStorage {
8
39
  #private;
9
40
  /** Tables managed by this domain */
@@ -81,6 +112,6 @@ export declare class WorkflowsPG extends WorkflowsStorage {
81
112
  runId: string;
82
113
  workflowName: string;
83
114
  }): Promise<void>;
84
- listWorkflowRuns({ workflowName, fromDate, toDate, perPage, page, resourceId, status, }?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
115
+ listWorkflowRuns({ workflowName, fromDate, toDate, perPage, page, resourceId, threadId, status, }?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
85
116
  }
86
117
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,EAML,gBAAgB,EAEjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,0BAA0B,EAC1B,4BAA4B,EAC5B,WAAW,EACX,YAAY,EACZ,kBAAkB,EA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R,MAAM,GACP,GAAE,4BAAiC,GAAG,OAAO,CAAC,YAAY,CAAC,CAgH3D;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/pg",
3
- "version": "1.26.0-alpha.3",
3
+ "version": "1.26.0-alpha.4",
4
4
  "description": "Postgres provider for Mastra - includes both vector and db storage capabilities",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -35,10 +35,10 @@
35
35
  "tsx": "^4.23.1",
36
36
  "typescript": "^7.0.2",
37
37
  "vitest": "4.1.11",
38
+ "@internal/lint": "0.0.133",
38
39
  "@internal/storage-test-utils": "0.0.129",
39
40
  "@internal/types-builder": "0.0.108",
40
- "@internal/lint": "0.0.133",
41
- "@mastra/core": "1.68.0-alpha.5"
41
+ "@mastra/core": "1.68.0-alpha.9"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@mastra/core": ">=1.68.0-0 <2.0.0-0"