@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/storage/index.d.ts
CHANGED
|
@@ -1,270 +1,81 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
import
|
|
4
|
-
import { MastraStorage } from '@mastra/core/storage';
|
|
5
|
-
import type { EvalRow, PaginationInfo, StorageColumn, StorageGetMessagesArg, StorageGetTracesArg, StorageGetTracesPaginatedArg, StorageResourceType, TABLE_NAMES, WorkflowRun, WorkflowRuns, PaginationArgs, StoragePagination, StorageDomains, ThreadSortOptions, AISpanRecord, AITraceRecord, AITracesPaginatedArg } from '@mastra/core/storage';
|
|
6
|
-
import type { Trace } from '@mastra/core/telemetry';
|
|
7
|
-
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
8
|
-
import pgPromise from 'pg-promise';
|
|
1
|
+
import { MastraCompositeStore } from '@mastra/core/storage';
|
|
2
|
+
import type { StorageDomains } from '@mastra/core/storage';
|
|
3
|
+
import { Pool } from 'pg';
|
|
9
4
|
import type { PostgresStoreConfig } from '../shared/config.js';
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
import type { DbClient } from './client.js';
|
|
6
|
+
import { AgentsPG } from './domains/agents/index.js';
|
|
7
|
+
import { BlobsPG } from './domains/blobs/index.js';
|
|
8
|
+
import { DatasetsPG } from './domains/datasets/index.js';
|
|
9
|
+
import { ExperimentsPG } from './domains/experiments/index.js';
|
|
10
|
+
import { MCPClientsPG } from './domains/mcp-clients/index.js';
|
|
11
|
+
import { MCPServersPG } from './domains/mcp-servers/index.js';
|
|
12
|
+
import { MemoryPG } from './domains/memory/index.js';
|
|
13
|
+
import { ObservabilityPG } from './domains/observability/index.js';
|
|
14
|
+
import { PromptBlocksPG } from './domains/prompt-blocks/index.js';
|
|
15
|
+
import { ScorerDefinitionsPG } from './domains/scorer-definitions/index.js';
|
|
16
|
+
import { ScoresPG } from './domains/scores/index.js';
|
|
17
|
+
import { SkillsPG } from './domains/skills/index.js';
|
|
18
|
+
import { WorkflowsPG } from './domains/workflows/index.js';
|
|
19
|
+
import { WorkspacesPG } from './domains/workspaces/index.js';
|
|
20
|
+
/**
|
|
21
|
+
* Exports the Mastra database schema as SQL DDL statements, including tables, indexes, and triggers.
|
|
22
|
+
* Does not require a database connection. Each domain class provides its own DDL contribution
|
|
23
|
+
* via a static getExportDDL method, ensuring a single source of truth.
|
|
24
|
+
*/
|
|
25
|
+
export declare function exportSchemas(schemaName?: string): string;
|
|
26
|
+
export { AgentsPG, BlobsPG, DatasetsPG, ExperimentsPG, MCPClientsPG, MCPServersPG, MemoryPG, ObservabilityPG, PromptBlocksPG, ScorerDefinitionsPG, ScoresPG, SkillsPG, WorkflowsPG, WorkspacesPG, };
|
|
27
|
+
export { PoolAdapter } from './client.js';
|
|
28
|
+
export type { DbClient, TxClient, QueryValues, Pool, PoolClient, QueryResult } from './client.js';
|
|
29
|
+
export type { PgDomainConfig, PgDomainClientConfig, PgDomainPoolConfig, PgDomainRestConfig } from './db/index.js';
|
|
30
|
+
/**
|
|
31
|
+
* PostgreSQL storage adapter for Mastra.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // Option 1: Connection string
|
|
36
|
+
* const store = new PostgresStore({
|
|
37
|
+
* id: 'my-store',
|
|
38
|
+
* connectionString: 'postgresql://...',
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* // Option 2: Pre-configured pool
|
|
42
|
+
* const pool = new Pool({ connectionString: 'postgresql://...' });
|
|
43
|
+
* const store = new PostgresStore({ id: 'my-store', pool });
|
|
44
|
+
*
|
|
45
|
+
* // Access domain storage
|
|
46
|
+
* const memory = await store.getStore('memory');
|
|
47
|
+
* await memory?.saveThread({ thread });
|
|
48
|
+
*
|
|
49
|
+
* // Execute custom queries
|
|
50
|
+
* const rows = await store.db.any('SELECT * FROM my_table');
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare class PostgresStore extends MastraCompositeStore {
|
|
12
54
|
#private;
|
|
13
55
|
private schema;
|
|
14
|
-
private
|
|
56
|
+
private isInitialized;
|
|
15
57
|
stores: StorageDomains;
|
|
16
58
|
constructor(config: PostgresStoreConfig);
|
|
59
|
+
private createPool;
|
|
17
60
|
init(): Promise<void>;
|
|
18
|
-
get db(): pgPromise.IDatabase<{}, import("pg-promise/typescript/pg-subset").IClient>;
|
|
19
|
-
get pgp(): pgPromise.IMain<{}, import("pg-promise/typescript/pg-subset").IClient>;
|
|
20
|
-
get supports(): {
|
|
21
|
-
selectByIncludeResourceScope: boolean;
|
|
22
|
-
resourceWorkingMemory: boolean;
|
|
23
|
-
hasColumn: boolean;
|
|
24
|
-
createTable: boolean;
|
|
25
|
-
deleteMessages: boolean;
|
|
26
|
-
aiTracing: boolean;
|
|
27
|
-
indexManagement: boolean;
|
|
28
|
-
getScoresBySpan: boolean;
|
|
29
|
-
};
|
|
30
|
-
/** @deprecated use getEvals instead */
|
|
31
|
-
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
32
|
-
getEvals(options?: {
|
|
33
|
-
agentName?: string;
|
|
34
|
-
type?: 'test' | 'live';
|
|
35
|
-
} & PaginationArgs): Promise<PaginationInfo & {
|
|
36
|
-
evals: EvalRow[];
|
|
37
|
-
}>;
|
|
38
61
|
/**
|
|
39
|
-
*
|
|
62
|
+
* Database client for executing queries.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const rows = await store.db.any('SELECT * FROM users WHERE active = $1', [true]);
|
|
67
|
+
* const user = await store.db.one('SELECT * FROM users WHERE id = $1', [userId]);
|
|
68
|
+
* ```
|
|
40
69
|
*/
|
|
41
|
-
|
|
42
|
-
getTracesPaginated(args: StorageGetTracesPaginatedArg): Promise<PaginationInfo & {
|
|
43
|
-
traces: Trace[];
|
|
44
|
-
}>;
|
|
45
|
-
batchTraceInsert({ records }: {
|
|
46
|
-
records: Record<string, any>[];
|
|
47
|
-
}): Promise<void>;
|
|
48
|
-
createTable({ tableName, schema, }: {
|
|
49
|
-
tableName: TABLE_NAMES;
|
|
50
|
-
schema: Record<string, StorageColumn>;
|
|
51
|
-
}): Promise<void>;
|
|
52
|
-
alterTable({ tableName, schema, ifNotExists, }: {
|
|
53
|
-
tableName: TABLE_NAMES;
|
|
54
|
-
schema: Record<string, StorageColumn>;
|
|
55
|
-
ifNotExists: string[];
|
|
56
|
-
}): Promise<void>;
|
|
57
|
-
clearTable({ tableName }: {
|
|
58
|
-
tableName: TABLE_NAMES;
|
|
59
|
-
}): Promise<void>;
|
|
60
|
-
dropTable({ tableName }: {
|
|
61
|
-
tableName: TABLE_NAMES;
|
|
62
|
-
}): Promise<void>;
|
|
63
|
-
insert({ tableName, record }: {
|
|
64
|
-
tableName: TABLE_NAMES;
|
|
65
|
-
record: Record<string, any>;
|
|
66
|
-
}): Promise<void>;
|
|
67
|
-
batchInsert({ tableName, records }: {
|
|
68
|
-
tableName: TABLE_NAMES;
|
|
69
|
-
records: Record<string, any>[];
|
|
70
|
-
}): Promise<void>;
|
|
71
|
-
load<R>({ tableName, keys }: {
|
|
72
|
-
tableName: TABLE_NAMES;
|
|
73
|
-
keys: Record<string, string>;
|
|
74
|
-
}): Promise<R | null>;
|
|
70
|
+
get db(): DbClient;
|
|
75
71
|
/**
|
|
76
|
-
*
|
|
72
|
+
* The underlying pg.Pool for direct database access or ORM integration.
|
|
77
73
|
*/
|
|
78
|
-
|
|
79
|
-
threadId: string;
|
|
80
|
-
}): Promise<StorageThreadType | null>;
|
|
74
|
+
get pool(): Pool;
|
|
81
75
|
/**
|
|
82
|
-
*
|
|
76
|
+
* Closes the connection pool if it was created by this store.
|
|
77
|
+
* If a pool was passed in via config, it will not be closed.
|
|
83
78
|
*/
|
|
84
|
-
getThreadsByResourceId(args: {
|
|
85
|
-
resourceId: string;
|
|
86
|
-
} & ThreadSortOptions): Promise<StorageThreadType[]>;
|
|
87
|
-
getThreadsByResourceIdPaginated(args: {
|
|
88
|
-
resourceId: string;
|
|
89
|
-
page: number;
|
|
90
|
-
perPage: number;
|
|
91
|
-
} & ThreadSortOptions): Promise<PaginationInfo & {
|
|
92
|
-
threads: StorageThreadType[];
|
|
93
|
-
}>;
|
|
94
|
-
saveThread({ thread }: {
|
|
95
|
-
thread: StorageThreadType;
|
|
96
|
-
}): Promise<StorageThreadType>;
|
|
97
|
-
updateThread({ id, title, metadata, }: {
|
|
98
|
-
id: string;
|
|
99
|
-
title: string;
|
|
100
|
-
metadata: Record<string, unknown>;
|
|
101
|
-
}): Promise<StorageThreadType>;
|
|
102
|
-
deleteThread({ threadId }: {
|
|
103
|
-
threadId: string;
|
|
104
|
-
}): Promise<void>;
|
|
105
|
-
/**
|
|
106
|
-
* @deprecated use getMessagesPaginated instead
|
|
107
|
-
*/
|
|
108
|
-
getMessages(args: StorageGetMessagesArg & {
|
|
109
|
-
format?: 'v1';
|
|
110
|
-
}): Promise<MastraMessageV1[]>;
|
|
111
|
-
getMessages(args: StorageGetMessagesArg & {
|
|
112
|
-
format: 'v2';
|
|
113
|
-
}): Promise<MastraMessageV2[]>;
|
|
114
|
-
getMessagesById({ messageIds, format }: {
|
|
115
|
-
messageIds: string[];
|
|
116
|
-
format: 'v1';
|
|
117
|
-
}): Promise<MastraMessageV1[]>;
|
|
118
|
-
getMessagesById({ messageIds, format }: {
|
|
119
|
-
messageIds: string[];
|
|
120
|
-
format?: 'v2';
|
|
121
|
-
}): Promise<MastraMessageV2[]>;
|
|
122
|
-
getMessagesPaginated(args: StorageGetMessagesArg & {
|
|
123
|
-
format?: 'v1' | 'v2';
|
|
124
|
-
}): Promise<PaginationInfo & {
|
|
125
|
-
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
126
|
-
}>;
|
|
127
|
-
saveMessages(args: {
|
|
128
|
-
messages: MastraMessageV1[];
|
|
129
|
-
format?: undefined | 'v1';
|
|
130
|
-
}): Promise<MastraMessageV1[]>;
|
|
131
|
-
saveMessages(args: {
|
|
132
|
-
messages: MastraMessageV2[];
|
|
133
|
-
format: 'v2';
|
|
134
|
-
}): Promise<MastraMessageV2[]>;
|
|
135
|
-
updateMessages({ messages, }: {
|
|
136
|
-
messages: (Partial<Omit<MastraMessageV2, 'createdAt'>> & {
|
|
137
|
-
id: string;
|
|
138
|
-
content?: {
|
|
139
|
-
metadata?: MastraMessageContentV2['metadata'];
|
|
140
|
-
content?: MastraMessageContentV2['content'];
|
|
141
|
-
};
|
|
142
|
-
})[];
|
|
143
|
-
}): Promise<MastraMessageV2[]>;
|
|
144
|
-
deleteMessages(messageIds: string[]): Promise<void>;
|
|
145
|
-
getResourceById({ resourceId }: {
|
|
146
|
-
resourceId: string;
|
|
147
|
-
}): Promise<StorageResourceType | null>;
|
|
148
|
-
saveResource({ resource }: {
|
|
149
|
-
resource: StorageResourceType;
|
|
150
|
-
}): Promise<StorageResourceType>;
|
|
151
|
-
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
152
|
-
resourceId: string;
|
|
153
|
-
workingMemory?: string;
|
|
154
|
-
metadata?: Record<string, unknown>;
|
|
155
|
-
}): Promise<StorageResourceType>;
|
|
156
|
-
/**
|
|
157
|
-
* Workflows
|
|
158
|
-
*/
|
|
159
|
-
updateWorkflowResults({ workflowName, runId, stepId, result, runtimeContext, }: {
|
|
160
|
-
workflowName: string;
|
|
161
|
-
runId: string;
|
|
162
|
-
stepId: string;
|
|
163
|
-
result: StepResult<any, any, any, any>;
|
|
164
|
-
runtimeContext: Record<string, any>;
|
|
165
|
-
}): Promise<Record<string, StepResult<any, any, any, any>>>;
|
|
166
|
-
updateWorkflowState({ workflowName, runId, opts, }: {
|
|
167
|
-
workflowName: string;
|
|
168
|
-
runId: string;
|
|
169
|
-
opts: {
|
|
170
|
-
status: string;
|
|
171
|
-
result?: StepResult<any, any, any, any>;
|
|
172
|
-
error?: string;
|
|
173
|
-
suspendedPaths?: Record<string, number[]>;
|
|
174
|
-
waitingPaths?: Record<string, number[]>;
|
|
175
|
-
};
|
|
176
|
-
}): Promise<WorkflowRunState | undefined>;
|
|
177
|
-
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
|
|
178
|
-
workflowName: string;
|
|
179
|
-
runId: string;
|
|
180
|
-
resourceId?: string;
|
|
181
|
-
snapshot: WorkflowRunState;
|
|
182
|
-
}): Promise<void>;
|
|
183
|
-
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
184
|
-
workflowName: string;
|
|
185
|
-
runId: string;
|
|
186
|
-
}): Promise<WorkflowRunState | null>;
|
|
187
|
-
getWorkflowRuns({ workflowName, fromDate, toDate, limit, offset, resourceId, }?: {
|
|
188
|
-
workflowName?: string;
|
|
189
|
-
fromDate?: Date;
|
|
190
|
-
toDate?: Date;
|
|
191
|
-
limit?: number;
|
|
192
|
-
offset?: number;
|
|
193
|
-
resourceId?: string;
|
|
194
|
-
}): Promise<WorkflowRuns>;
|
|
195
|
-
getWorkflowRunById({ runId, workflowName, }: {
|
|
196
|
-
runId: string;
|
|
197
|
-
workflowName?: string;
|
|
198
|
-
}): Promise<WorkflowRun | null>;
|
|
199
79
|
close(): Promise<void>;
|
|
200
|
-
/**
|
|
201
|
-
* AI Tracing / Observability
|
|
202
|
-
*/
|
|
203
|
-
createAISpan(span: AISpanRecord): Promise<void>;
|
|
204
|
-
updateAISpan({ spanId, traceId, updates, }: {
|
|
205
|
-
spanId: string;
|
|
206
|
-
traceId: string;
|
|
207
|
-
updates: Partial<Omit<AISpanRecord, 'spanId' | 'traceId'>>;
|
|
208
|
-
}): Promise<void>;
|
|
209
|
-
getAITrace(traceId: string): Promise<AITraceRecord | null>;
|
|
210
|
-
getAITracesPaginated(args: AITracesPaginatedArg): Promise<{
|
|
211
|
-
pagination: PaginationInfo;
|
|
212
|
-
spans: AISpanRecord[];
|
|
213
|
-
}>;
|
|
214
|
-
batchCreateAISpans(args: {
|
|
215
|
-
records: AISpanRecord[];
|
|
216
|
-
}): Promise<void>;
|
|
217
|
-
batchUpdateAISpans(args: {
|
|
218
|
-
records: {
|
|
219
|
-
traceId: string;
|
|
220
|
-
spanId: string;
|
|
221
|
-
updates: Partial<Omit<AISpanRecord, 'spanId' | 'traceId'>>;
|
|
222
|
-
}[];
|
|
223
|
-
}): Promise<void>;
|
|
224
|
-
batchDeleteAITraces(args: {
|
|
225
|
-
traceIds: string[];
|
|
226
|
-
}): Promise<void>;
|
|
227
|
-
/**
|
|
228
|
-
* Scorers
|
|
229
|
-
*/
|
|
230
|
-
getScoreById({ id }: {
|
|
231
|
-
id: string;
|
|
232
|
-
}): Promise<ScoreRowData | null>;
|
|
233
|
-
getScoresByScorerId({ scorerId, pagination, entityId, entityType, source, }: {
|
|
234
|
-
scorerId: string;
|
|
235
|
-
pagination: StoragePagination;
|
|
236
|
-
entityId?: string;
|
|
237
|
-
entityType?: string;
|
|
238
|
-
source?: ScoringSource;
|
|
239
|
-
}): Promise<{
|
|
240
|
-
pagination: PaginationInfo;
|
|
241
|
-
scores: ScoreRowData[];
|
|
242
|
-
}>;
|
|
243
|
-
saveScore(score: ScoreRowData): Promise<{
|
|
244
|
-
score: ScoreRowData;
|
|
245
|
-
}>;
|
|
246
|
-
getScoresByRunId({ runId, pagination, }: {
|
|
247
|
-
runId: string;
|
|
248
|
-
pagination: StoragePagination;
|
|
249
|
-
}): Promise<{
|
|
250
|
-
pagination: PaginationInfo;
|
|
251
|
-
scores: ScoreRowData[];
|
|
252
|
-
}>;
|
|
253
|
-
getScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
254
|
-
pagination: StoragePagination;
|
|
255
|
-
entityId: string;
|
|
256
|
-
entityType: string;
|
|
257
|
-
}): Promise<{
|
|
258
|
-
pagination: PaginationInfo;
|
|
259
|
-
scores: ScoreRowData[];
|
|
260
|
-
}>;
|
|
261
|
-
getScoresBySpan({ traceId, spanId, pagination, }: {
|
|
262
|
-
traceId: string;
|
|
263
|
-
spanId: string;
|
|
264
|
-
pagination: StoragePagination;
|
|
265
|
-
}): Promise<{
|
|
266
|
-
pagination: PaginationInfo;
|
|
267
|
-
scores: ScoreRowData[];
|
|
268
|
-
}>;
|
|
269
80
|
}
|
|
270
81
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAQ1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,C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AAW,IAAI,IAAI,IAAI,CAEtB;IAED;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAK7B"}
|
|
@@ -26,13 +26,15 @@ interface PerformanceComparison {
|
|
|
26
26
|
}
|
|
27
27
|
export declare class PostgresPerformanceTest {
|
|
28
28
|
private store;
|
|
29
|
+
private memory;
|
|
30
|
+
private dbOps;
|
|
29
31
|
private config;
|
|
30
32
|
constructor(config: PerformanceTestConfig);
|
|
31
33
|
init(): Promise<void>;
|
|
32
34
|
cleanup(): Promise<void>;
|
|
33
35
|
resetDatabase(): Promise<void>;
|
|
34
36
|
dropPerformanceIndexes(): Promise<void>;
|
|
35
|
-
|
|
37
|
+
createDefaultIndexes(): Promise<void>;
|
|
36
38
|
seedTestData(): Promise<void>;
|
|
37
39
|
measureOperation(name: string, operation: () => Promise<any>, scenario: 'without_indexes' | 'with_indexes'): Promise<PerformanceResult>;
|
|
38
40
|
runPerformanceTests(scenario: 'without_indexes' | 'with_indexes'): Promise<PerformanceResult[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"performance-test.d.ts","sourceRoot":"","sources":["../../../src/storage/performance-indexes/performance-test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"performance-test.d.ts","sourceRoot":"","sources":["../../../src/storage/performance-indexes/performance-test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,UAAU,qBAAqB;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,iBAAiB,GAAG,cAAc,CAAC;CAC9C;AAED,UA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":["../../src/storage/test-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../src/storage/test-utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAK5D,eAAO,MAAM,WAAW,EAAE,mBAOF,CAAC;AAEzB,eAAO,MAAM,gBAAgB,QAA0K,CAAC;AAExM,wBAAgB,OAAO,SAo4BtB"}
|
package/dist/vector/index.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { MastraVector } from '@mastra/core/vector';
|
|
2
|
-
import type { IndexStats, QueryResult, QueryVectorParams, CreateIndexParams, UpsertVectorParams, DescribeIndexParams, DeleteIndexParams, DeleteVectorParams, UpdateVectorParams } from '@mastra/core/vector';
|
|
2
|
+
import type { IndexStats, QueryResult, QueryVectorParams, CreateIndexParams, UpsertVectorParams, DescribeIndexParams, DeleteIndexParams, DeleteVectorParams, DeleteVectorsParams, UpdateVectorParams } from '@mastra/core/vector';
|
|
3
3
|
import * as pg from 'pg';
|
|
4
4
|
import type { PgVectorConfig } from '../shared/config.js';
|
|
5
5
|
import type { PGVectorFilter } from './filter.js';
|
|
6
|
-
import type { IndexConfig, IndexType } from './types.js';
|
|
6
|
+
import type { IndexConfig, IndexType, VectorType } from './types.js';
|
|
7
7
|
export interface PGIndexStats extends IndexStats {
|
|
8
8
|
type: IndexType;
|
|
9
|
+
/**
|
|
10
|
+
* The pgvector storage type used for this index.
|
|
11
|
+
* - 'vector': Full precision (4 bytes per dimension)
|
|
12
|
+
* - 'halfvec': Half precision (2 bytes per dimension)
|
|
13
|
+
*/
|
|
14
|
+
vectorType: VectorType;
|
|
9
15
|
config: {
|
|
10
16
|
m?: number;
|
|
11
17
|
efConstruction?: number;
|
|
@@ -29,45 +35,69 @@ interface PgQueryVectorParams extends QueryVectorParams<PGVectorFilter> {
|
|
|
29
35
|
interface PgCreateIndexParams extends CreateIndexParams {
|
|
30
36
|
indexConfig?: IndexConfig;
|
|
31
37
|
buildIndex?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The pgvector storage type for embeddings.
|
|
40
|
+
* - 'vector': Full precision (4 bytes per dimension), max 2000 dimensions for indexes (default)
|
|
41
|
+
* - 'halfvec': Half precision (2 bytes per dimension), max 4000 dimensions for indexes
|
|
42
|
+
*
|
|
43
|
+
* Use 'halfvec' for large dimension models like text-embedding-3-large (3072 dimensions)
|
|
44
|
+
*/
|
|
45
|
+
vectorType?: VectorType;
|
|
32
46
|
}
|
|
33
47
|
interface PgDefineIndexParams {
|
|
34
48
|
indexName: string;
|
|
35
49
|
metric: 'cosine' | 'euclidean' | 'dotproduct';
|
|
36
50
|
indexConfig: IndexConfig;
|
|
51
|
+
vectorType?: VectorType;
|
|
37
52
|
}
|
|
38
53
|
export declare class PgVector extends MastraVector<PGVectorFilter> {
|
|
39
54
|
pool: pg.Pool;
|
|
40
55
|
private describeIndexCache;
|
|
41
56
|
private createdIndexes;
|
|
57
|
+
private indexVectorTypes;
|
|
42
58
|
private mutexesByName;
|
|
43
59
|
private schema?;
|
|
44
60
|
private setupSchemaPromise;
|
|
45
61
|
private installVectorExtensionPromise;
|
|
46
62
|
private vectorExtensionInstalled;
|
|
47
63
|
private vectorExtensionSchema;
|
|
64
|
+
private vectorExtensionVersion;
|
|
48
65
|
private schemaSetupComplete;
|
|
49
66
|
private cacheWarmupPromise;
|
|
50
|
-
constructor(config: PgVectorConfig
|
|
67
|
+
constructor(config: PgVectorConfig & {
|
|
68
|
+
id: string;
|
|
69
|
+
});
|
|
51
70
|
private getMutexByName;
|
|
52
71
|
/**
|
|
53
|
-
* Detects which schema contains the vector extension
|
|
72
|
+
* Detects which schema contains the vector extension and its version
|
|
54
73
|
*/
|
|
55
74
|
private detectVectorExtensionSchema;
|
|
75
|
+
/**
|
|
76
|
+
* Checks if the installed pgvector version supports halfvec type.
|
|
77
|
+
* halfvec was introduced in pgvector 0.7.0.
|
|
78
|
+
*/
|
|
79
|
+
private supportsHalfvec;
|
|
56
80
|
/**
|
|
57
81
|
* Gets the properly qualified vector type name
|
|
82
|
+
* @param vectorType - The type of vector storage ('vector' or 'halfvec')
|
|
58
83
|
*/
|
|
59
84
|
private getVectorTypeName;
|
|
85
|
+
/**
|
|
86
|
+
* Gets the operator class for index creation based on metric and vector type.
|
|
87
|
+
* pgvector uses different operator classes for vector vs halfvec types.
|
|
88
|
+
*/
|
|
89
|
+
private getMetricOperatorClass;
|
|
60
90
|
private getTableName;
|
|
61
91
|
private getSchemaName;
|
|
62
92
|
transformFilter(filter?: PGVectorFilter): PGVectorFilter;
|
|
63
93
|
getIndexInfo({ indexName }: DescribeIndexParams): Promise<PGIndexStats>;
|
|
64
94
|
query({ indexName, queryVector, topK, filter, includeVector, minScore, ef, probes, }: PgQueryVectorParams): Promise<QueryResult[]>;
|
|
65
|
-
upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
|
|
95
|
+
upsert({ indexName, vectors, metadata, ids, deleteFilter, }: UpsertVectorParams<PGVectorFilter>): Promise<string[]>;
|
|
66
96
|
private hasher;
|
|
67
97
|
private getIndexCacheKey;
|
|
68
98
|
private cachedIndexExists;
|
|
69
99
|
private setupSchema;
|
|
70
|
-
createIndex({ indexName, dimension, metric, indexConfig, buildIndex, }: PgCreateIndexParams): Promise<void>;
|
|
100
|
+
createIndex({ indexName, dimension, metric, indexConfig, buildIndex, vectorType, }: PgCreateIndexParams): Promise<void>;
|
|
71
101
|
buildIndex({ indexName, metric, indexConfig }: PgDefineIndexParams): Promise<void>;
|
|
72
102
|
private setupIndex;
|
|
73
103
|
private installVectorExtension;
|
|
@@ -92,7 +122,7 @@ export declare class PgVector extends MastraVector<PGVectorFilter> {
|
|
|
92
122
|
* @returns A promise that resolves when the update is complete.
|
|
93
123
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
94
124
|
*/
|
|
95
|
-
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
125
|
+
updateVector({ indexName, id, filter, update }: UpdateVectorParams<PGVectorFilter>): Promise<void>;
|
|
96
126
|
/**
|
|
97
127
|
* Deletes a vector by its ID.
|
|
98
128
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -101,6 +131,14 @@ export declare class PgVector extends MastraVector<PGVectorFilter> {
|
|
|
101
131
|
* @throws Will throw an error if the deletion operation fails.
|
|
102
132
|
*/
|
|
103
133
|
deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Delete vectors matching a metadata filter.
|
|
136
|
+
* @param indexName - The name of the index containing the vectors.
|
|
137
|
+
* @param filter - The filter to match vectors for deletion.
|
|
138
|
+
* @returns A promise that resolves when the deletion is complete.
|
|
139
|
+
* @throws Will throw an error if the deletion operation fails.
|
|
140
|
+
*/
|
|
141
|
+
deleteVectors({ indexName, filter, ids }: DeleteVectorsParams<PGVectorFilter>): Promise<void>;
|
|
104
142
|
}
|
|
105
143
|
export {};
|
|
106
144
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAqC,MAAM,qBAAqB,CAAC;AACtF,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAIzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;A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MAAiB,EAAE,WAAW,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;YAuBrF,UAAU;YA+HV,sBAAsB;IAoF9B,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAoDtC;;;;;OAKG;IACG,aAAa,CAAC,EAAE,SAAS,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC;IA8GxE,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IA6B5D,aAAa,CAAC,EAAE,SAAS,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB9D,UAAU;IAchB;;;;;;;;;OASG;IACG,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,kBAAkB,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IA0IxG;;;;;;OAMG;IACG,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IA8BxE;;;;;;OAMG;IACG,aAAa,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,mBAAmB,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAkHpG"}
|
|
@@ -3,6 +3,10 @@ interface FilterResult {
|
|
|
3
3
|
sql: string;
|
|
4
4
|
values: any[];
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Build a filter query for DELETE operations (no minScore/topK parameters)
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildDeleteFilterQuery(filter: PGVectorFilter): FilterResult;
|
|
6
10
|
export declare function buildFilterQuery(filter: PGVectorFilter, minScore: number, topK: number): FilterResult;
|
|
7
11
|
export {};
|
|
8
12
|
//# sourceMappingURL=sql-builder.d.ts.map
|
|
@@ -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/dist/vector/types.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
export type IndexType = 'ivfflat' | 'hnsw' | 'flat';
|
|
2
|
+
/**
|
|
3
|
+
* pgvector storage types for embeddings.
|
|
4
|
+
* - 'vector': Full precision (4 bytes per dimension), max 2000 dimensions for indexes
|
|
5
|
+
* - 'halfvec': Half precision (2 bytes per dimension), max 4000 dimensions for indexes
|
|
6
|
+
*
|
|
7
|
+
* Use 'halfvec' for large dimension models like text-embedding-3-large (3072 dimensions)
|
|
8
|
+
*
|
|
9
|
+
* Note: 'halfvec' requires pgvector >= 0.7.0
|
|
10
|
+
*/
|
|
11
|
+
export type VectorType = 'vector' | 'halfvec';
|
|
2
12
|
interface IVFConfig {
|
|
3
13
|
lists?: number;
|
|
4
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/vector/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpD,UAAU,SAAS;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,UAAU;IAClB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/vector/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE9C,UAAU,SAAS;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,UAAU;IAClB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,GAAG,CAAC,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/pg",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-execa-dynamic-import-20260304221256",
|
|
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,24 +22,24 @@
|
|
|
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
|
-
"@
|
|
30
|
-
"@types/
|
|
31
|
-
"@
|
|
28
|
+
"@types/node": "22.19.7",
|
|
29
|
+
"@types/pg": "^8.16.0",
|
|
30
|
+
"@vitest/coverage-v8": "4.0.18",
|
|
31
|
+
"@vitest/ui": "4.0.18",
|
|
32
32
|
"eslint": "^9.37.0",
|
|
33
|
-
"tsup": "^8.5.
|
|
34
|
-
"typescript": "^5.
|
|
35
|
-
"vitest": "
|
|
36
|
-
"@internal/
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@internal/lint": "0.0.0-
|
|
33
|
+
"tsup": "^8.5.1",
|
|
34
|
+
"typescript": "^5.9.3",
|
|
35
|
+
"vitest": "4.0.18",
|
|
36
|
+
"@internal/types-builder": "0.0.0-execa-dynamic-import-20260304221256",
|
|
37
|
+
"@mastra/core": "0.0.0-execa-dynamic-import-20260304221256",
|
|
38
|
+
"@internal/storage-test-utils": "0.0.61",
|
|
39
|
+
"@internal/lint": "0.0.0-execa-dynamic-import-20260304221256"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@mastra/core": "0.0.0-
|
|
42
|
+
"@mastra/core": "0.0.0-execa-dynamic-import-20260304221256"
|
|
43
43
|
},
|
|
44
44
|
"files": [
|
|
45
45
|
"dist",
|
|
@@ -54,9 +54,12 @@
|
|
|
54
54
|
"bugs": {
|
|
55
55
|
"url": "https://github.com/mastra-ai/mastra/issues"
|
|
56
56
|
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=22.13.0"
|
|
59
|
+
},
|
|
57
60
|
"scripts": {
|
|
58
|
-
"build": "tsup --silent --config tsup.config.ts",
|
|
59
|
-
"build:watch": "pnpm build --watch",
|
|
61
|
+
"build:lib": "tsup --silent --config tsup.config.ts",
|
|
62
|
+
"build:watch": "pnpm build:lib --watch",
|
|
60
63
|
"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)",
|
|
61
64
|
"test": "vitest run",
|
|
62
65
|
"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)",
|