@mastra/pg 0.0.0-error-handler-fix-20251020202607 → 0.0.0-execa-dynamic-import-20260304221256
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/CHANGELOG.md +3220 -3
- package/LICENSE.md +15 -0
- package/README.md +72 -20
- package/dist/docs/SKILL.md +40 -0
- package/dist/docs/assets/SOURCE_MAP.json +6 -0
- package/dist/docs/references/docs-memory-semantic-recall.md +288 -0
- package/dist/docs/references/docs-memory-storage.md +261 -0
- package/dist/docs/references/docs-memory-working-memory.md +400 -0
- package/dist/docs/references/docs-rag-overview.md +72 -0
- package/dist/docs/references/docs-rag-retrieval.md +515 -0
- package/dist/docs/references/docs-rag-vector-databases.md +645 -0
- package/dist/docs/references/reference-memory-memory-class.md +147 -0
- package/dist/docs/references/reference-processors-message-history-processor.md +85 -0
- package/dist/docs/references/reference-processors-semantic-recall-processor.md +117 -0
- package/dist/docs/references/reference-processors-working-memory-processor.md +152 -0
- package/dist/docs/references/reference-rag-metadata-filters.md +216 -0
- package/dist/docs/references/reference-storage-composite.md +235 -0
- package/dist/docs/references/reference-storage-dynamodb.md +282 -0
- package/dist/docs/references/reference-storage-postgresql.md +526 -0
- package/dist/docs/references/reference-tools-vector-query-tool.md +459 -0
- package/dist/docs/references/reference-vectors-pg.md +408 -0
- package/dist/index.cjs +11374 -2692
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11362 -2694
- package/dist/index.js.map +1 -1
- package/dist/shared/config.d.ts +122 -31
- package/dist/shared/config.d.ts.map +1 -1
- package/dist/storage/client.d.ts +91 -0
- package/dist/storage/client.d.ts.map +1 -0
- package/dist/storage/db/constraint-utils.d.ts +16 -0
- package/dist/storage/db/constraint-utils.d.ts.map +1 -0
- package/dist/storage/db/index.d.ts +235 -0
- package/dist/storage/db/index.d.ts.map +1 -0
- package/dist/storage/domains/agents/index.d.ts +52 -0
- package/dist/storage/domains/agents/index.d.ts.map +1 -0
- package/dist/storage/domains/blobs/index.d.ts +17 -0
- package/dist/storage/domains/blobs/index.d.ts.map +1 -0
- package/dist/storage/domains/datasets/index.d.ts +48 -0
- package/dist/storage/domains/datasets/index.d.ts.map +1 -0
- package/dist/storage/domains/experiments/index.d.ts +34 -0
- package/dist/storage/domains/experiments/index.d.ts.map +1 -0
- package/dist/storage/domains/mcp-clients/index.d.ts +33 -0
- package/dist/storage/domains/mcp-clients/index.d.ts.map +1 -0
- package/dist/storage/domains/mcp-servers/index.d.ts +33 -0
- package/dist/storage/domains/mcp-servers/index.d.ts.map +1 -0
- package/dist/storage/domains/memory/index.d.ts +74 -55
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts +65 -39
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/prompt-blocks/index.d.ts +43 -0
- package/dist/storage/domains/prompt-blocks/index.d.ts.map +1 -0
- package/dist/storage/domains/scorer-definitions/index.d.ts +43 -0
- package/dist/storage/domains/scorer-definitions/index.d.ts.map +1 -0
- package/dist/storage/domains/scores/index.d.ts +40 -33
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/skills/index.d.ts +33 -0
- package/dist/storage/domains/skills/index.d.ts.map +1 -0
- package/dist/storage/domains/utils.d.ts +1 -5
- package/dist/storage/domains/utils.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +42 -30
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/domains/workspaces/index.d.ts +33 -0
- package/dist/storage/domains/workspaces/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +66 -255
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/performance-indexes/performance-test.d.ts +3 -1
- package/dist/storage/performance-indexes/performance-test.d.ts.map +1 -1
- package/dist/storage/test-utils.d.ts.map +1 -1
- package/dist/vector/index.d.ts +45 -7
- package/dist/vector/index.d.ts.map +1 -1
- package/dist/vector/sql-builder.d.ts +4 -0
- package/dist/vector/sql-builder.d.ts.map +1 -1
- package/dist/vector/types.d.ts +10 -0
- package/dist/vector/types.d.ts.map +1 -1
- package/package.json +18 -15
- package/dist/storage/domains/legacy-evals/index.d.ts +0 -20
- package/dist/storage/domains/legacy-evals/index.d.ts.map +0 -1
- package/dist/storage/domains/operations/index.d.ts +0 -118
- package/dist/storage/domains/operations/index.d.ts.map +0 -1
- package/dist/storage/domains/traces/index.d.ts +0 -23
- package/dist/storage/domains/traces/index.d.ts.map +0 -1
package/dist/shared/config.d.ts
CHANGED
|
@@ -1,48 +1,139 @@
|
|
|
1
|
-
import type { ConnectionOptions } from 'tls';
|
|
2
|
-
import type {
|
|
3
|
-
import type
|
|
4
|
-
import type { ISSLConfig } from 'pg-promise/typescript/pg-subset';
|
|
1
|
+
import type { ConnectionOptions } from 'node:tls';
|
|
2
|
+
import type { CreateIndexOptions } from '@mastra/core/storage';
|
|
3
|
+
import type { ClientConfig, Pool, PoolConfig } from 'pg';
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @template SSLType - The SSL configuration type (ISSLConfig for pg-promise, ConnectionOptions for pg)
|
|
5
|
+
* Base configuration options shared across PostgreSQL configs.
|
|
8
6
|
*/
|
|
9
|
-
export
|
|
7
|
+
export interface PostgresBaseConfig {
|
|
8
|
+
id: string;
|
|
10
9
|
schemaName?: string;
|
|
10
|
+
/**
|
|
11
|
+
* When true, automatic initialization (table creation/migrations) is disabled.
|
|
12
|
+
* This is useful for CI/CD pipelines where you want to:
|
|
13
|
+
* 1. Run migrations explicitly during deployment (not at runtime)
|
|
14
|
+
* 2. Use different credentials for schema changes vs runtime operations
|
|
15
|
+
*
|
|
16
|
+
* When disableInit is true:
|
|
17
|
+
* - The storage will not automatically create/alter tables on first use
|
|
18
|
+
* - You must call `storage.init()` explicitly in your CI/CD scripts
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // In CI/CD script:
|
|
22
|
+
* const storage = new PostgresStore({ ...config, disableInit: false });
|
|
23
|
+
* await storage.init(); // Explicitly run migrations
|
|
24
|
+
*
|
|
25
|
+
* // In runtime application:
|
|
26
|
+
* const storage = new PostgresStore({ ...config, disableInit: true });
|
|
27
|
+
* // No auto-init, tables must already exist
|
|
28
|
+
*/
|
|
29
|
+
disableInit?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* When true, default indexes will not be created during initialization.
|
|
32
|
+
* This is useful when:
|
|
33
|
+
* 1. You want to manage indexes separately or use custom indexes only
|
|
34
|
+
* 2. Default indexes don't match your query patterns
|
|
35
|
+
* 3. You want to reduce initialization time in development
|
|
36
|
+
*
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
skipDefaultIndexes?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Custom indexes to create during initialization.
|
|
42
|
+
* These indexes are created in addition to default indexes (unless skipDefaultIndexes is true).
|
|
43
|
+
*
|
|
44
|
+
* Each index must specify which table it belongs to. The store will route each index
|
|
45
|
+
* to the appropriate domain based on the table name.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const store = new PostgresStore({
|
|
50
|
+
* connectionString: '...',
|
|
51
|
+
* indexes: [
|
|
52
|
+
* { name: 'my_threads_type_idx', table: 'mastra_threads', columns: ['metadata->>\'type\''] },
|
|
53
|
+
* { name: 'my_messages_status_idx', table: 'mastra_messages', columns: ['metadata->>\'status\''] },
|
|
54
|
+
* ],
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
indexes?: CreateIndexOptions[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Connection string configuration.
|
|
62
|
+
*/
|
|
63
|
+
export interface ConnectionStringConfig extends PostgresBaseConfig {
|
|
64
|
+
connectionString: string;
|
|
65
|
+
ssl?: boolean | ConnectionOptions;
|
|
11
66
|
max?: number;
|
|
12
67
|
idleTimeoutMillis?: number;
|
|
13
|
-
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Host-based configuration.
|
|
71
|
+
*/
|
|
72
|
+
export interface HostConfig extends PostgresBaseConfig {
|
|
14
73
|
host: string;
|
|
15
74
|
port: number;
|
|
16
75
|
database: string;
|
|
17
76
|
user: string;
|
|
18
77
|
password: string;
|
|
19
|
-
ssl?: boolean |
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
78
|
+
ssl?: boolean | ConnectionOptions;
|
|
79
|
+
max?: number;
|
|
80
|
+
idleTimeoutMillis?: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Pre-configured pg.Pool configuration.
|
|
84
|
+
*/
|
|
85
|
+
export interface PoolInstanceConfig extends PostgresBaseConfig {
|
|
86
|
+
/**
|
|
87
|
+
* Pre-configured pg.Pool instance.
|
|
88
|
+
* Use this for direct control over the connection pool, or for
|
|
89
|
+
* integration with libraries that expect a pg.Pool.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* import { Pool } from 'pg';
|
|
94
|
+
*
|
|
95
|
+
* const pool = new Pool({ connectionString: '...' });
|
|
96
|
+
* const store = new PostgresStore({ id: 'my-store', pool });
|
|
97
|
+
*
|
|
98
|
+
* // Use store.pool for other libraries that need a pg.Pool
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
pool: Pool;
|
|
102
|
+
}
|
|
24
103
|
/**
|
|
25
|
-
* PostgreSQL configuration for PostgresStore
|
|
104
|
+
* PostgreSQL configuration for PostgresStore.
|
|
105
|
+
*
|
|
106
|
+
* Accepts either:
|
|
107
|
+
* - A pre-configured pg.Pool: `{ id, pool, schemaName? }`
|
|
108
|
+
* - Connection string: `{ id, connectionString, ... }`
|
|
109
|
+
* - Host/port config: `{ id, host, port, database, user, password, ... }`
|
|
110
|
+
* - Cloud SQL connector config: `{ id, stream, ... }` (via pg.ClientConfig)
|
|
26
111
|
*/
|
|
27
|
-
export type PostgresStoreConfig =
|
|
112
|
+
export type PostgresStoreConfig = PoolInstanceConfig | ConnectionStringConfig | HostConfig | (PostgresBaseConfig & ClientConfig);
|
|
28
113
|
/**
|
|
29
114
|
* PostgreSQL configuration for PgVector (uses pg with ConnectionOptions)
|
|
30
115
|
*/
|
|
31
|
-
export type PgVectorConfig =
|
|
32
|
-
pgPoolOptions?: Omit<
|
|
33
|
-
};
|
|
34
|
-
export declare const isConnectionStringConfig: <SSLType>(cfg: PostgresConfig<SSLType>) => cfg is PostgresConfig<SSLType> & {
|
|
35
|
-
connectionString: string;
|
|
36
|
-
ssl?: boolean | SSLType;
|
|
37
|
-
};
|
|
38
|
-
export declare const isHostConfig: <SSLType>(cfg: PostgresConfig<SSLType>) => cfg is PostgresConfig<SSLType> & {
|
|
39
|
-
host: string;
|
|
40
|
-
port: number;
|
|
41
|
-
database: string;
|
|
42
|
-
user: string;
|
|
43
|
-
password: string;
|
|
44
|
-
ssl?: boolean | SSLType;
|
|
116
|
+
export type PgVectorConfig = (ConnectionStringConfig | HostConfig | (PostgresBaseConfig & ClientConfig)) & {
|
|
117
|
+
pgPoolOptions?: Omit<PoolConfig, 'connectionString'>;
|
|
45
118
|
};
|
|
46
|
-
|
|
47
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Type guard for pre-configured pg.Pool config
|
|
121
|
+
*/
|
|
122
|
+
export declare const isPoolConfig: (cfg: PostgresStoreConfig) => cfg is PoolInstanceConfig;
|
|
123
|
+
/**
|
|
124
|
+
* Type guard for connection string config
|
|
125
|
+
*/
|
|
126
|
+
export declare const isConnectionStringConfig: (cfg: PostgresStoreConfig) => cfg is ConnectionStringConfig;
|
|
127
|
+
/**
|
|
128
|
+
* Type guard for host-based config
|
|
129
|
+
*/
|
|
130
|
+
export declare const isHostConfig: (cfg: PostgresStoreConfig) => cfg is HostConfig;
|
|
131
|
+
/**
|
|
132
|
+
* Type guard for Cloud SQL connector config
|
|
133
|
+
*/
|
|
134
|
+
export declare const isCloudSqlConfig: (cfg: PostgresStoreConfig) => cfg is PostgresBaseConfig & ClientConfig;
|
|
135
|
+
/**
|
|
136
|
+
* Validate PostgresStore configuration.
|
|
137
|
+
*/
|
|
138
|
+
export declare const validateConfig: (name: string, config: PostgresStoreConfig) => void;
|
|
48
139
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/shared/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/shared/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;;;;;;;;;;;OAkBG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,gBAAgB,EAAE,MAAM,CAAC;IACzB,GAAG,CAAC,EAAE,OAAO,GAAG,iBAAiB,CAAC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,kBAAkB;IACp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pool, PoolClient, QueryResult } from 'pg';
|
|
2
|
+
export type { Pool, PoolClient, QueryResult } from 'pg';
|
|
3
|
+
/**
|
|
4
|
+
* Values array for parameterized queries.
|
|
5
|
+
*/
|
|
6
|
+
export type QueryValues = unknown[];
|
|
7
|
+
/**
|
|
8
|
+
* Common interface for database clients.
|
|
9
|
+
* PoolAdapter implements this interface by wrapping a pg.Pool.
|
|
10
|
+
*/
|
|
11
|
+
export interface DbClient {
|
|
12
|
+
/**
|
|
13
|
+
* The underlying connection pool.
|
|
14
|
+
*/
|
|
15
|
+
readonly $pool: Pool;
|
|
16
|
+
/**
|
|
17
|
+
* Acquire a client from the pool for manual query execution.
|
|
18
|
+
* Remember to call client.release() when done.
|
|
19
|
+
*/
|
|
20
|
+
connect(): Promise<PoolClient>;
|
|
21
|
+
/**
|
|
22
|
+
* Execute a query that returns no data.
|
|
23
|
+
* Use for INSERT, UPDATE, DELETE without RETURNING.
|
|
24
|
+
*/
|
|
25
|
+
none(query: string, values?: QueryValues): Promise<null>;
|
|
26
|
+
/**
|
|
27
|
+
* Execute a query that returns exactly one row.
|
|
28
|
+
* @throws Error if zero or more than one row is returned
|
|
29
|
+
*/
|
|
30
|
+
one<T = any>(query: string, values?: QueryValues): Promise<T>;
|
|
31
|
+
/**
|
|
32
|
+
* Execute a query that returns zero or one row.
|
|
33
|
+
* @returns The row, or null if no rows returned
|
|
34
|
+
* @throws Error if more than one row is returned
|
|
35
|
+
*/
|
|
36
|
+
oneOrNone<T = any>(query: string, values?: QueryValues): Promise<T | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Execute a query that returns any number of rows (including zero).
|
|
39
|
+
* Alias for manyOrNone.
|
|
40
|
+
*/
|
|
41
|
+
any<T = any>(query: string, values?: QueryValues): Promise<T[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Execute a query that returns zero or more rows.
|
|
44
|
+
*/
|
|
45
|
+
manyOrNone<T = any>(query: string, values?: QueryValues): Promise<T[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Execute a query that returns at least one row.
|
|
48
|
+
* @throws Error if no rows are returned
|
|
49
|
+
*/
|
|
50
|
+
many<T = any>(query: string, values?: QueryValues): Promise<T[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Execute a raw query, returning the full result object.
|
|
53
|
+
*/
|
|
54
|
+
query(query: string, values?: QueryValues): Promise<QueryResult>;
|
|
55
|
+
/**
|
|
56
|
+
* Execute a function within a transaction.
|
|
57
|
+
* Automatically handles BEGIN, COMMIT, and ROLLBACK.
|
|
58
|
+
*/
|
|
59
|
+
tx<T>(callback: (t: TxClient) => Promise<T>): Promise<T>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Transaction client interface for executing queries within a transaction.
|
|
63
|
+
*/
|
|
64
|
+
export interface TxClient {
|
|
65
|
+
none(query: string, values?: QueryValues): Promise<null>;
|
|
66
|
+
one<T = any>(query: string, values?: QueryValues): Promise<T>;
|
|
67
|
+
oneOrNone<T = any>(query: string, values?: QueryValues): Promise<T | null>;
|
|
68
|
+
any<T = any>(query: string, values?: QueryValues): Promise<T[]>;
|
|
69
|
+
manyOrNone<T = any>(query: string, values?: QueryValues): Promise<T[]>;
|
|
70
|
+
many<T = any>(query: string, values?: QueryValues): Promise<T[]>;
|
|
71
|
+
query(query: string, values?: QueryValues): Promise<QueryResult>;
|
|
72
|
+
/** Execute multiple promises in parallel */
|
|
73
|
+
batch<T>(promises: Promise<T>[]): Promise<T[]>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Adapter that wraps a pg.Pool to implement DbClient.
|
|
77
|
+
*/
|
|
78
|
+
export declare class PoolAdapter implements DbClient {
|
|
79
|
+
readonly $pool: Pool;
|
|
80
|
+
constructor($pool: Pool);
|
|
81
|
+
connect(): Promise<PoolClient>;
|
|
82
|
+
none(query: string, values?: QueryValues): Promise<null>;
|
|
83
|
+
one<T = any>(query: string, values?: QueryValues): Promise<T>;
|
|
84
|
+
oneOrNone<T = any>(query: string, values?: QueryValues): Promise<T | null>;
|
|
85
|
+
any<T = any>(query: string, values?: QueryValues): Promise<T[]>;
|
|
86
|
+
manyOrNone<T = any>(query: string, values?: QueryValues): Promise<T[]>;
|
|
87
|
+
many<T = any>(query: string, values?: QueryValues): Promise<T[]>;
|
|
88
|
+
query(query: string, values?: QueryValues): Promise<QueryResult>;
|
|
89
|
+
tx<T>(callback: (t: TxClient) => Promise<T>): Promise<T>;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/storage/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAGxD,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,EAAE,CAAC;AAEpC;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;IAErB;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IAE/B;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzD;;;OAGG;IACH,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE9D;;;;OAIG;IACH,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAE3E;;;OAGG;IACH,GAAG,CAAC,CAA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E,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAQhE,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAIhE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAoB/D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const POSTGRES_IDENTIFIER_MAX_LENGTH = 63;
|
|
2
|
+
export declare function truncateIdentifier(value: string, maxLength?: number): string;
|
|
3
|
+
/**
|
|
4
|
+
* Builds a constraint name with an optional schema prefix, truncated to fit
|
|
5
|
+
* within Postgres' identifier length limit. The result is always lowercased
|
|
6
|
+
* because PostgreSQL folds unquoted identifiers to lowercase when storing them
|
|
7
|
+
* in system catalogs (pg_constraint.conname, pg_indexes.indexname, etc.).
|
|
8
|
+
* Without this normalisation, runtime lookups that compare a mixed-case name
|
|
9
|
+
* against the catalog would silently fail.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildConstraintName({ baseName, schemaName, maxLength, }: {
|
|
12
|
+
baseName: string;
|
|
13
|
+
schemaName?: string;
|
|
14
|
+
maxLength?: number;
|
|
15
|
+
}): string;
|
|
16
|
+
//# sourceMappingURL=constraint-utils.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import type { ConnectionOptions } from 'node:tls';
|
|
2
|
+
import { MastraBase } from '@mastra/core/base';
|
|
3
|
+
import type { StorageColumn, TABLE_NAMES, CreateIndexOptions, IndexInfo, StorageIndexStats } from '@mastra/core/storage';
|
|
4
|
+
import { Pool } from 'pg';
|
|
5
|
+
import type { DbClient } from '../client.js';
|
|
6
|
+
export type { DbClient } from '../client.js';
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for standalone domain usage.
|
|
9
|
+
* Accepts either:
|
|
10
|
+
* 1. An existing database client (Pool or PoolAdapter)
|
|
11
|
+
* 2. Config to create a new pool internally
|
|
12
|
+
*/
|
|
13
|
+
export type PgDomainConfig = PgDomainClientConfig | PgDomainPoolConfig | PgDomainRestConfig;
|
|
14
|
+
/**
|
|
15
|
+
* Pass an existing database client (DbClient)
|
|
16
|
+
*/
|
|
17
|
+
export interface PgDomainClientConfig {
|
|
18
|
+
/** The database client */
|
|
19
|
+
client: DbClient;
|
|
20
|
+
/** Optional schema name (defaults to 'public') */
|
|
21
|
+
schemaName?: string;
|
|
22
|
+
/** When true, default indexes will not be created during initialization */
|
|
23
|
+
skipDefaultIndexes?: boolean;
|
|
24
|
+
/** Custom indexes to create for this domain's tables */
|
|
25
|
+
indexes?: CreateIndexOptions[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Pass an existing pg.Pool
|
|
29
|
+
*/
|
|
30
|
+
export interface PgDomainPoolConfig {
|
|
31
|
+
/** Pre-configured pg.Pool */
|
|
32
|
+
pool: Pool;
|
|
33
|
+
/** Optional schema name (defaults to 'public') */
|
|
34
|
+
schemaName?: string;
|
|
35
|
+
/** When true, default indexes will not be created during initialization */
|
|
36
|
+
skipDefaultIndexes?: boolean;
|
|
37
|
+
/** Custom indexes to create for this domain's tables */
|
|
38
|
+
indexes?: CreateIndexOptions[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Pass config to create a new pg.Pool internally
|
|
42
|
+
*/
|
|
43
|
+
export type PgDomainRestConfig = {
|
|
44
|
+
/** Optional schema name (defaults to 'public') */
|
|
45
|
+
schemaName?: string;
|
|
46
|
+
/** When true, default indexes will not be created during initialization */
|
|
47
|
+
skipDefaultIndexes?: boolean;
|
|
48
|
+
/** Custom indexes to create for this domain's tables */
|
|
49
|
+
indexes?: CreateIndexOptions[];
|
|
50
|
+
} & ({
|
|
51
|
+
host: string;
|
|
52
|
+
port: number;
|
|
53
|
+
database: string;
|
|
54
|
+
user: string;
|
|
55
|
+
password: string;
|
|
56
|
+
ssl?: boolean | ConnectionOptions;
|
|
57
|
+
} | {
|
|
58
|
+
connectionString: string;
|
|
59
|
+
ssl?: boolean | ConnectionOptions;
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* Resolves PgDomainConfig to a database client and schema.
|
|
63
|
+
* Handles creating a new pool if config is provided.
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolvePgConfig(config: PgDomainConfig): {
|
|
66
|
+
client: DbClient;
|
|
67
|
+
schemaName?: string;
|
|
68
|
+
skipDefaultIndexes?: boolean;
|
|
69
|
+
indexes?: CreateIndexOptions[];
|
|
70
|
+
};
|
|
71
|
+
export declare function getSchemaName(schema?: string): string;
|
|
72
|
+
export declare function getTableName({ indexName, schemaName }: {
|
|
73
|
+
indexName: string;
|
|
74
|
+
schemaName?: string;
|
|
75
|
+
}): string;
|
|
76
|
+
export declare function generateTableSQL({ tableName, schema, schemaName, compositePrimaryKey, includeAllConstraints, }: {
|
|
77
|
+
tableName: TABLE_NAMES;
|
|
78
|
+
schema: Record<string, StorageColumn>;
|
|
79
|
+
schemaName?: string;
|
|
80
|
+
compositePrimaryKey?: string[];
|
|
81
|
+
/** When true, includes all constraints in the SQL (for exports). When false, some constraints are added at runtime after data migration. */
|
|
82
|
+
includeAllConstraints?: boolean;
|
|
83
|
+
}): string;
|
|
84
|
+
/**
|
|
85
|
+
* Generates a CREATE INDEX SQL statement from index options.
|
|
86
|
+
* Used by exportSchemas to produce index DDL without a database connection.
|
|
87
|
+
*/
|
|
88
|
+
export declare function generateIndexSQL(options: CreateIndexOptions, schemaName?: string): string;
|
|
89
|
+
/**
|
|
90
|
+
* Generates the SQL for a timestamp trigger function and trigger on a table.
|
|
91
|
+
* Returns the DDL string without executing it.
|
|
92
|
+
*/
|
|
93
|
+
export declare function generateTimestampTriggerSQL(tableName: string, schemaName?: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Internal config for PgDB - accepts already-resolved client
|
|
96
|
+
*/
|
|
97
|
+
export interface PgDBInternalConfig {
|
|
98
|
+
client: DbClient;
|
|
99
|
+
schemaName?: string;
|
|
100
|
+
skipDefaultIndexes?: boolean;
|
|
101
|
+
}
|
|
102
|
+
export declare class PgDB extends MastraBase {
|
|
103
|
+
client: DbClient;
|
|
104
|
+
schemaName?: string;
|
|
105
|
+
skipDefaultIndexes?: boolean;
|
|
106
|
+
constructor(config: PgDBInternalConfig);
|
|
107
|
+
hasColumn(table: string, column: string): Promise<boolean>;
|
|
108
|
+
/**
|
|
109
|
+
* Prepares values for insertion, handling JSONB columns by stringifying them
|
|
110
|
+
*/
|
|
111
|
+
private prepareValuesForInsert;
|
|
112
|
+
/**
|
|
113
|
+
* Adds timestamp Z columns to a record if timestamp columns exist
|
|
114
|
+
*/
|
|
115
|
+
private addTimestampZColumns;
|
|
116
|
+
/**
|
|
117
|
+
* Prepares a value for database operations
|
|
118
|
+
*/
|
|
119
|
+
private prepareValue;
|
|
120
|
+
private setupSchema;
|
|
121
|
+
protected getDefaultValue(type: StorageColumn['type']): string;
|
|
122
|
+
insert({ tableName, record }: {
|
|
123
|
+
tableName: TABLE_NAMES;
|
|
124
|
+
record: Record<string, any>;
|
|
125
|
+
}): Promise<void>;
|
|
126
|
+
clearTable({ tableName }: {
|
|
127
|
+
tableName: TABLE_NAMES;
|
|
128
|
+
}): Promise<void>;
|
|
129
|
+
createTable({ tableName, schema, compositePrimaryKey, }: {
|
|
130
|
+
tableName: TABLE_NAMES;
|
|
131
|
+
schema: Record<string, StorageColumn>;
|
|
132
|
+
compositePrimaryKey?: string[];
|
|
133
|
+
}): Promise<void>;
|
|
134
|
+
private setupTimestampTriggers;
|
|
135
|
+
/**
|
|
136
|
+
* Migrates the spans table schema from OLD_SPAN_SCHEMA to current SPAN_SCHEMA.
|
|
137
|
+
* This adds new columns that don't exist in old schema.
|
|
138
|
+
*/
|
|
139
|
+
private migrateSpansTable;
|
|
140
|
+
/**
|
|
141
|
+
* Deduplicates spans in the mastra_ai_spans table before adding the PRIMARY KEY constraint.
|
|
142
|
+
* Keeps spans based on priority: completed (endedAt NOT NULL) > most recent updatedAt > most recent createdAt.
|
|
143
|
+
*
|
|
144
|
+
* Note: This prioritizes migration completion over perfect data preservation.
|
|
145
|
+
* Old trace data may be lost, which is acceptable for this use case.
|
|
146
|
+
*/
|
|
147
|
+
private deduplicateSpans;
|
|
148
|
+
/**
|
|
149
|
+
* Checks for duplicate (traceId, spanId) combinations in the spans table.
|
|
150
|
+
* Returns information about duplicates for logging/CLI purposes.
|
|
151
|
+
*/
|
|
152
|
+
private checkForDuplicateSpans;
|
|
153
|
+
/**
|
|
154
|
+
* Checks if the PRIMARY KEY constraint on (traceId, spanId) already exists on the spans table.
|
|
155
|
+
* Used to skip deduplication when the constraint already exists (migration already complete).
|
|
156
|
+
*/
|
|
157
|
+
private spansPrimaryKeyExists;
|
|
158
|
+
/**
|
|
159
|
+
* Adds the PRIMARY KEY constraint on (traceId, spanId) to the spans table.
|
|
160
|
+
* Should be called AFTER deduplication to ensure no duplicate key violations.
|
|
161
|
+
*/
|
|
162
|
+
private addSpansPrimaryKey;
|
|
163
|
+
/**
|
|
164
|
+
* Manually run the spans migration to deduplicate and add the unique constraint.
|
|
165
|
+
* This is intended to be called from the CLI when duplicates are detected.
|
|
166
|
+
*
|
|
167
|
+
* @returns Migration result with status and details
|
|
168
|
+
*/
|
|
169
|
+
migrateSpans(): Promise<{
|
|
170
|
+
success: boolean;
|
|
171
|
+
alreadyMigrated: boolean;
|
|
172
|
+
duplicatesRemoved: number;
|
|
173
|
+
message: string;
|
|
174
|
+
}>;
|
|
175
|
+
/**
|
|
176
|
+
* Check migration status for the spans table.
|
|
177
|
+
* Returns information about whether migration is needed.
|
|
178
|
+
*/
|
|
179
|
+
checkSpansMigrationStatus(): Promise<{
|
|
180
|
+
needsMigration: boolean;
|
|
181
|
+
hasDuplicates: boolean;
|
|
182
|
+
duplicateCount: number;
|
|
183
|
+
constraintExists: boolean;
|
|
184
|
+
tableName: string;
|
|
185
|
+
}>;
|
|
186
|
+
/**
|
|
187
|
+
* Alters table schema to add columns if they don't exist
|
|
188
|
+
* @param tableName Name of the table
|
|
189
|
+
* @param schema Schema of the table
|
|
190
|
+
* @param ifNotExists Array of column names to add if they don't exist
|
|
191
|
+
*/
|
|
192
|
+
alterTable({ tableName, schema, ifNotExists, }: {
|
|
193
|
+
tableName: TABLE_NAMES;
|
|
194
|
+
schema: Record<string, StorageColumn>;
|
|
195
|
+
ifNotExists: string[];
|
|
196
|
+
}): Promise<void>;
|
|
197
|
+
load<R>({ tableName, keys }: {
|
|
198
|
+
tableName: TABLE_NAMES;
|
|
199
|
+
keys: Record<string, string>;
|
|
200
|
+
}): Promise<R | null>;
|
|
201
|
+
batchInsert({ tableName, records }: {
|
|
202
|
+
tableName: TABLE_NAMES;
|
|
203
|
+
records: Record<string, any>[];
|
|
204
|
+
}): Promise<void>;
|
|
205
|
+
dropTable({ tableName }: {
|
|
206
|
+
tableName: TABLE_NAMES;
|
|
207
|
+
}): Promise<void>;
|
|
208
|
+
createIndex(options: CreateIndexOptions): Promise<void>;
|
|
209
|
+
dropIndex(indexName: string): Promise<void>;
|
|
210
|
+
listIndexes(tableName?: string): Promise<IndexInfo[]>;
|
|
211
|
+
describeIndex(indexName: string): Promise<StorageIndexStats>;
|
|
212
|
+
update({ tableName, keys, data, }: {
|
|
213
|
+
tableName: TABLE_NAMES;
|
|
214
|
+
keys: Record<string, any>;
|
|
215
|
+
data: Record<string, any>;
|
|
216
|
+
}): Promise<void>;
|
|
217
|
+
batchUpdate({ tableName, updates, }: {
|
|
218
|
+
tableName: TABLE_NAMES;
|
|
219
|
+
updates: Array<{
|
|
220
|
+
keys: Record<string, any>;
|
|
221
|
+
data: Record<string, any>;
|
|
222
|
+
}>;
|
|
223
|
+
}): Promise<void>;
|
|
224
|
+
batchDelete({ tableName, keys }: {
|
|
225
|
+
tableName: TABLE_NAMES;
|
|
226
|
+
keys: Record<string, any>[];
|
|
227
|
+
}): Promise<void>;
|
|
228
|
+
/**
|
|
229
|
+
* Delete all data from a table (alias for clearTable for consistency with other stores)
|
|
230
|
+
*/
|
|
231
|
+
deleteData({ tableName }: {
|
|
232
|
+
tableName: TABLE_NAMES;
|
|
233
|
+
}): Promise<void>;
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAU/C,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAK1C,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,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QACD,SAAS,EAAE,WAAW,CAAC;QACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC3B,GAAG,OAAO,CAAC,IAAI,CAAC;IA6CX,WAAW,CAAC,EAChB,SAAS,EACT,OAAO,GACR,EAAE;QACD,SAAS,EAAE,WAAW,CAAC;QACvB,OAAO,EAAE,KAAK,CAAC;YACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;SAC3B,CAAC,CAAC;KACJ,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBX,WAAW,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA2C9G;;OAEG;IACG,UAAU,CAAC,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3E"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AgentsStorage } from '@mastra/core/storage';
|
|
2
|
+
import type { StorageAgentType, StorageCreateAgentInput, StorageUpdateAgentInput, StorageListAgentsInput, StorageListAgentsOutput, CreateIndexOptions } from '@mastra/core/storage';
|
|
3
|
+
import type { AgentVersion, CreateVersionInput, ListVersionsInput, ListVersionsOutput } from '@mastra/core/storage/domains/agents';
|
|
4
|
+
import type { PgDomainConfig } from '../../db/index.js';
|
|
5
|
+
export declare class AgentsPG extends AgentsStorage {
|
|
6
|
+
#private;
|
|
7
|
+
/** Tables managed by this domain */
|
|
8
|
+
static readonly MANAGED_TABLES: readonly ["mastra_agents", "mastra_agent_versions"];
|
|
9
|
+
constructor(config: PgDomainConfig);
|
|
10
|
+
/**
|
|
11
|
+
* Returns all DDL statements for this domain: tables.
|
|
12
|
+
* Used by exportSchemas to produce a complete, reproducible schema export.
|
|
13
|
+
*/
|
|
14
|
+
static getExportDDL(schemaName?: string): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Returns default index definitions for the agents domain tables.
|
|
17
|
+
* Currently no default indexes are defined for agents.
|
|
18
|
+
*/
|
|
19
|
+
getDefaultIndexDefinitions(): CreateIndexOptions[];
|
|
20
|
+
/**
|
|
21
|
+
* Creates default indexes for optimal query performance.
|
|
22
|
+
* Currently no default indexes are defined for agents.
|
|
23
|
+
*/
|
|
24
|
+
createDefaultIndexes(): Promise<void>;
|
|
25
|
+
init(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Creates custom user-defined indexes for this domain's tables.
|
|
28
|
+
*/
|
|
29
|
+
createCustomIndexes(): Promise<void>;
|
|
30
|
+
dangerouslyClearAll(): Promise<void>;
|
|
31
|
+
private parseJson;
|
|
32
|
+
private parseRow;
|
|
33
|
+
getById(id: string): Promise<StorageAgentType | null>;
|
|
34
|
+
create(input: {
|
|
35
|
+
agent: StorageCreateAgentInput;
|
|
36
|
+
}): Promise<StorageAgentType>;
|
|
37
|
+
update(input: StorageUpdateAgentInput): Promise<StorageAgentType>;
|
|
38
|
+
delete(id: string): Promise<void>;
|
|
39
|
+
list(args?: StorageListAgentsInput): Promise<StorageListAgentsOutput>;
|
|
40
|
+
createVersion(input: CreateVersionInput): Promise<AgentVersion>;
|
|
41
|
+
getVersion(id: string): Promise<AgentVersion | null>;
|
|
42
|
+
getVersionByNumber(agentId: string, versionNumber: number): Promise<AgentVersion | null>;
|
|
43
|
+
getLatestVersion(agentId: string): Promise<AgentVersion | null>;
|
|
44
|
+
listVersions(input: ListVersionsInput): Promise<ListVersionsOutput>;
|
|
45
|
+
deleteVersion(id: string): Promise<void>;
|
|
46
|
+
deleteVersionsByParentId(entityId: string): Promise<void>;
|
|
47
|
+
countVersions(agentId: string): Promise<number>;
|
|
48
|
+
private serializeInstructions;
|
|
49
|
+
private deserializeInstructions;
|
|
50
|
+
private parseVersionRow;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/agents/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAOd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAEnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,qBAAa,QAAS,SAAQ,aAAa;;IAMzC,oCAAoC;IACpC,MAAM,CAAC,QAAQ,CAAC,cAAc,sDAAiD;gBAEnE,MAAM,EAAE,cAAc;IAUlC;;;OAGG;IACH,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE;IAkBlD;;;OAGG;IACH,0BAA0B,IAAI,kBAAkB,EAAE;IAIlD;;;OAGG;IACG,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAOrC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAmN3B;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAepC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAK1C,OAAO,CAAC,SAAS;IA4BjB,OAAO,CAAC,QAAQ;IAYV,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAyBrD,MAAM,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,uBAAuB,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA4E5E,MAAM,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAwFjE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBjC,IAAI,CAAC,IAAI,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IA8FrE,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC;IA+D/D,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAwBpD,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IA2BxF,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IA2B/D,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAoEnE,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBxC,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBzD,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAyBrD,OAAO,CAAC,qBAAqB;IAK7B,OAAO,CAAC,uBAAuB;IAW/B,OAAO,CAAC,eAAe;CA4BxB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BlobStore } from '@mastra/core/storage';
|
|
2
|
+
import type { StorageBlobEntry } from '@mastra/core/storage';
|
|
3
|
+
import type { PgDomainConfig } from '../../db/index.js';
|
|
4
|
+
export declare class BlobsPG extends BlobStore {
|
|
5
|
+
#private;
|
|
6
|
+
static readonly MANAGED_TABLES: readonly ["mastra_skill_blobs"];
|
|
7
|
+
constructor(config: PgDomainConfig);
|
|
8
|
+
init(): Promise<void>;
|
|
9
|
+
put(entry: StorageBlobEntry): Promise<void>;
|
|
10
|
+
get(hash: string): Promise<StorageBlobEntry | null>;
|
|
11
|
+
has(hash: string): Promise<boolean>;
|
|
12
|
+
delete(hash: string): Promise<boolean>;
|
|
13
|
+
putMany(entries: StorageBlobEntry[]): Promise<void>;
|
|
14
|
+
getMany(hashes: string[]): Promise<Map<string, StorageBlobEntry>>;
|
|
15
|
+
dangerouslyClearAll(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/blobs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoC,MAAM,sBAAsB,CAAC;AACnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,qBAAa,OAAQ,SAAQ,SAAS;;IAIpC,MAAM,CAAC,QAAQ,CAAC,cAAc,kCAAgC;gBAElD,MAAM,EAAE,cAAc;IAO5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAOrB,GAAG,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAY3C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAOnD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMnC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAMtC,OAAO,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAOnD,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAiBjE,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;CAa3C"}
|