@mastra/pg 1.0.0-beta.8 → 1.0.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/CHANGELOG.md +1638 -0
- package/dist/docs/README.md +36 -0
- package/dist/docs/SKILL.md +37 -0
- package/dist/docs/SOURCE_MAP.json +6 -0
- package/dist/docs/memory/01-storage.md +233 -0
- package/dist/docs/memory/02-working-memory.md +390 -0
- package/dist/docs/memory/03-semantic-recall.md +233 -0
- package/dist/docs/memory/04-reference.md +133 -0
- package/dist/docs/processors/01-reference.md +297 -0
- package/dist/docs/rag/01-overview.md +74 -0
- package/dist/docs/rag/02-vector-databases.md +643 -0
- package/dist/docs/rag/03-retrieval.md +548 -0
- package/dist/docs/rag/04-reference.md +369 -0
- package/dist/docs/storage/01-reference.md +828 -0
- package/dist/docs/tools/01-reference.md +440 -0
- package/dist/docs/vectors/01-reference.md +307 -0
- package/dist/index.cjs +3253 -2225
- 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 +3250 -2227
- package/dist/index.js.map +1 -1
- package/dist/shared/config.d.ts +102 -32
- 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/index.d.ts +216 -0
- package/dist/storage/db/index.d.ts.map +1 -0
- package/dist/storage/domains/agents/index.d.ts +22 -8
- package/dist/storage/domains/agents/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +32 -12
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts +52 -36
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +25 -28
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- 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 +26 -12
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +52 -195
- 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.map +1 -1
- package/dist/vector/sql-builder.d.ts.map +1 -1
- package/package.json +11 -11
- package/dist/storage/domains/operations/index.d.ts +0 -119
- package/dist/storage/domains/operations/index.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-builder.d.ts","sourceRoot":"","sources":["../../src/vector/sql-builder.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"sql-builder.d.ts","sourceRoot":"","sources":["../../src/vector/sql-builder.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AA2P/C,UAAU,YAAY;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,GAAG,EAAE,CAAC;CACf;AAWD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,YAAY,CA6J3E;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CA6JrG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/pg",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Postgres provider for Mastra - includes both vector and db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,22 +22,21 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"async-mutex": "^0.5.0",
|
|
24
24
|
"pg": "^8.16.3",
|
|
25
|
-
"pg-promise": "^11.15.0",
|
|
26
25
|
"xxhash-wasm": "^1.1.0"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
|
29
28
|
"@types/node": "22.13.17",
|
|
30
|
-
"@types/pg": "^8.
|
|
29
|
+
"@types/pg": "^8.16.0",
|
|
31
30
|
"@vitest/coverage-v8": "4.0.12",
|
|
32
31
|
"@vitest/ui": "4.0.12",
|
|
33
32
|
"eslint": "^9.37.0",
|
|
34
33
|
"tsup": "^8.5.0",
|
|
35
|
-
"typescript": "^5.
|
|
36
|
-
"vitest": "4.0.
|
|
37
|
-
"@internal/lint": "0.0.
|
|
38
|
-
"@internal/
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
34
|
+
"typescript": "^5.9.3",
|
|
35
|
+
"vitest": "4.0.16",
|
|
36
|
+
"@internal/lint": "0.0.54",
|
|
37
|
+
"@internal/types-builder": "0.0.29",
|
|
38
|
+
"@mastra/core": "1.0.0",
|
|
39
|
+
"@internal/storage-test-utils": "0.0.50"
|
|
41
40
|
},
|
|
42
41
|
"peerDependencies": {
|
|
43
42
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0"
|
|
@@ -59,8 +58,9 @@
|
|
|
59
58
|
"node": ">=22.13.0"
|
|
60
59
|
},
|
|
61
60
|
"scripts": {
|
|
62
|
-
"build": "tsup --silent --config tsup.config.ts",
|
|
63
|
-
"build:
|
|
61
|
+
"build:lib": "tsup --silent --config tsup.config.ts",
|
|
62
|
+
"build:docs": "pnpx tsx ../../scripts/generate-package-docs.ts stores/pg",
|
|
63
|
+
"build:watch": "pnpm build:lib --watch",
|
|
64
64
|
"pretest": "docker compose up -d && (for i in $(seq 1 30); do docker compose exec -T db pg_isready -U postgres && break || (sleep 1; [ $i -eq 30 ] && exit 1); done)",
|
|
65
65
|
"test": "vitest run",
|
|
66
66
|
"pretest:perf": "docker compose -f docker-compose.perf.yaml up -d && (for i in $(seq 1 30); do docker compose -f docker-compose.perf.yaml exec -T db pg_isready -U postgres && break || (sleep 1; [ $i -eq 30 ] && exit 1); done)",
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { StoreOperations } from '@mastra/core/storage';
|
|
2
|
-
import type { StorageColumn, TABLE_NAMES, CreateIndexOptions, IndexInfo, StorageIndexStats } from '@mastra/core/storage';
|
|
3
|
-
import type { IDatabase } from 'pg-promise';
|
|
4
|
-
export type { CreateIndexOptions, IndexInfo, StorageIndexStats };
|
|
5
|
-
export declare class StoreOperationsPG extends StoreOperations {
|
|
6
|
-
client: IDatabase<{}>;
|
|
7
|
-
schemaName?: string;
|
|
8
|
-
private setupSchemaPromise;
|
|
9
|
-
private schemaSetupComplete;
|
|
10
|
-
constructor({ client, schemaName }: {
|
|
11
|
-
client: IDatabase<{}>;
|
|
12
|
-
schemaName?: string;
|
|
13
|
-
});
|
|
14
|
-
hasColumn(table: string, column: string): Promise<boolean>;
|
|
15
|
-
/**
|
|
16
|
-
* Prepares values for insertion, handling JSONB columns by stringifying them
|
|
17
|
-
*/
|
|
18
|
-
private prepareValuesForInsert;
|
|
19
|
-
/**
|
|
20
|
-
* Adds timestamp Z columns to a record if timestamp columns exist
|
|
21
|
-
*/
|
|
22
|
-
private addTimestampZColumns;
|
|
23
|
-
/**
|
|
24
|
-
* Prepares a value for database operations, handling Date objects and JSON serialization
|
|
25
|
-
* This is schema-aware and only stringifies objects for JSONB columns
|
|
26
|
-
*/
|
|
27
|
-
private prepareValue;
|
|
28
|
-
private setupSchema;
|
|
29
|
-
insert({ tableName, record }: {
|
|
30
|
-
tableName: TABLE_NAMES;
|
|
31
|
-
record: Record<string, any>;
|
|
32
|
-
}): Promise<void>;
|
|
33
|
-
clearTable({ tableName }: {
|
|
34
|
-
tableName: TABLE_NAMES;
|
|
35
|
-
}): Promise<void>;
|
|
36
|
-
protected getDefaultValue(type: StorageColumn['type']): string;
|
|
37
|
-
createTable({ tableName, schema, }: {
|
|
38
|
-
tableName: TABLE_NAMES;
|
|
39
|
-
schema: Record<string, StorageColumn>;
|
|
40
|
-
}): Promise<void>;
|
|
41
|
-
/**
|
|
42
|
-
* Set up timestamp triggers for a table to automatically manage createdAt/updatedAt
|
|
43
|
-
*/
|
|
44
|
-
private setupTimestampTriggers;
|
|
45
|
-
/**
|
|
46
|
-
* Alters table schema to add columns if they don't exist
|
|
47
|
-
* @param tableName Name of the table
|
|
48
|
-
* @param schema Schema of the table
|
|
49
|
-
* @param ifNotExists Array of column names to add if they don't exist
|
|
50
|
-
*/
|
|
51
|
-
alterTable({ tableName, schema, ifNotExists, }: {
|
|
52
|
-
tableName: TABLE_NAMES;
|
|
53
|
-
schema: Record<string, StorageColumn>;
|
|
54
|
-
ifNotExists: string[];
|
|
55
|
-
}): Promise<void>;
|
|
56
|
-
load<R>({ tableName, keys }: {
|
|
57
|
-
tableName: TABLE_NAMES;
|
|
58
|
-
keys: Record<string, string>;
|
|
59
|
-
}): Promise<R | null>;
|
|
60
|
-
batchInsert({ tableName, records }: {
|
|
61
|
-
tableName: TABLE_NAMES;
|
|
62
|
-
records: Record<string, any>[];
|
|
63
|
-
}): Promise<void>;
|
|
64
|
-
dropTable({ tableName }: {
|
|
65
|
-
tableName: TABLE_NAMES;
|
|
66
|
-
}): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Create a new index on a table
|
|
69
|
-
*/
|
|
70
|
-
createIndex(options: CreateIndexOptions): Promise<void>;
|
|
71
|
-
/**
|
|
72
|
-
* Drop an existing index
|
|
73
|
-
*/
|
|
74
|
-
dropIndex(indexName: string): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* List indexes for a specific table or all tables
|
|
77
|
-
*/
|
|
78
|
-
listIndexes(tableName?: string): Promise<IndexInfo[]>;
|
|
79
|
-
/**
|
|
80
|
-
* Returns definitions for automatic performance indexes
|
|
81
|
-
* These composite indexes cover both filtering and sorting in single index
|
|
82
|
-
*/
|
|
83
|
-
protected getAutomaticIndexDefinitions(): CreateIndexOptions[];
|
|
84
|
-
/**
|
|
85
|
-
* Creates automatic indexes for optimal query performance
|
|
86
|
-
* Uses getAutomaticIndexDefinitions() to determine which indexes to create
|
|
87
|
-
*/
|
|
88
|
-
createAutomaticIndexes(): Promise<void>;
|
|
89
|
-
/**
|
|
90
|
-
* Get detailed statistics for a specific index
|
|
91
|
-
*/
|
|
92
|
-
describeIndex(indexName: string): Promise<StorageIndexStats>;
|
|
93
|
-
/**
|
|
94
|
-
* Update a single record in the database
|
|
95
|
-
*/
|
|
96
|
-
update({ tableName, keys, data, }: {
|
|
97
|
-
tableName: TABLE_NAMES;
|
|
98
|
-
keys: Record<string, any>;
|
|
99
|
-
data: Record<string, any>;
|
|
100
|
-
}): Promise<void>;
|
|
101
|
-
/**
|
|
102
|
-
* Update multiple records in a single batch transaction
|
|
103
|
-
*/
|
|
104
|
-
batchUpdate({ tableName, updates, }: {
|
|
105
|
-
tableName: TABLE_NAMES;
|
|
106
|
-
updates: Array<{
|
|
107
|
-
keys: Record<string, any>;
|
|
108
|
-
data: Record<string, any>;
|
|
109
|
-
}>;
|
|
110
|
-
}): Promise<void>;
|
|
111
|
-
/**
|
|
112
|
-
* Delete multiple records by keys
|
|
113
|
-
*/
|
|
114
|
-
batchDelete({ tableName, keys }: {
|
|
115
|
-
tableName: TABLE_NAMES;
|
|
116
|
-
keys: Record<string, any>[];
|
|
117
|
-
}): Promise<void>;
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/operations/index.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,eAAe,EAQhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAA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