@mastra/pg 0.10.2-alpha.0 → 0.10.2-alpha.2
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +20 -0
- package/dist/_tsup-dts-rollup.d.cts +33 -40
- package/dist/_tsup-dts-rollup.d.ts +33 -40
- package/dist/index.cjs +286 -225
- package/dist/index.js +286 -225
- package/package.json +4 -4
- package/src/storage/index.test.ts +308 -191
- package/src/storage/index.ts +348 -345
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/pg@0.10.2-alpha.
|
|
2
|
+
> @mastra/pg@0.10.2-alpha.2 build /home/runner/work/mastra/mastra/stores/pg
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.5.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 10152ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/pg/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/pg/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 12410ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
20
|
+
[32mESM[39m [1mdist/index.js [22m[32m67.23 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 1748ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m67.79 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 1748ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @mastra/pg
|
|
2
2
|
|
|
3
|
+
## 0.10.2-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 48eddb9: update filter logic in Memory class to support semantic recall search scope
|
|
8
|
+
- Updated dependencies [48eddb9]
|
|
9
|
+
- @mastra/core@0.10.4-alpha.2
|
|
10
|
+
|
|
11
|
+
## 0.10.2-alpha.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 0db1e1e: Fix PostgresStore paginated APIs
|
|
16
|
+
- dffb67b: updated stores to add alter table and change tests
|
|
17
|
+
- Updated dependencies [f6fd25f]
|
|
18
|
+
- Updated dependencies [dffb67b]
|
|
19
|
+
- Updated dependencies [f1309d3]
|
|
20
|
+
- Updated dependencies [f7f8293]
|
|
21
|
+
- @mastra/core@0.10.4-alpha.1
|
|
22
|
+
|
|
3
23
|
## 0.10.2-alpha.0
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -11,6 +11,8 @@ import type { MastraMessageV2 } from '@mastra/core/agent';
|
|
|
11
11
|
import { MastraStorage } from '@mastra/core/storage';
|
|
12
12
|
import { MastraVector } from '@mastra/core/vector';
|
|
13
13
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
14
|
+
import type { PaginationArgs } from '@mastra/core/storage';
|
|
15
|
+
import type { PaginationInfo } from '@mastra/core/storage';
|
|
14
16
|
import pg from 'pg';
|
|
15
17
|
import type { QueryResult } from '@mastra/core/vector';
|
|
16
18
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
@@ -270,6 +272,9 @@ declare class PostgresStore extends MastraStorage {
|
|
|
270
272
|
private setupSchemaPromise;
|
|
271
273
|
private schemaSetupComplete;
|
|
272
274
|
constructor(config: PostgresConfig);
|
|
275
|
+
get supports(): {
|
|
276
|
+
selectByIncludeResourceScope: boolean;
|
|
277
|
+
};
|
|
273
278
|
private getTableName;
|
|
274
279
|
/** @deprecated use getEvals instead */
|
|
275
280
|
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
@@ -278,6 +283,9 @@ declare class PostgresStore extends MastraStorage {
|
|
|
278
283
|
tableName: TABLE_NAMES;
|
|
279
284
|
records: Record<string, any>[];
|
|
280
285
|
}): Promise<void>;
|
|
286
|
+
/**
|
|
287
|
+
* @deprecated use getTracesPaginated instead
|
|
288
|
+
*/
|
|
281
289
|
getTraces(args: {
|
|
282
290
|
name?: string;
|
|
283
291
|
scope?: string;
|
|
@@ -288,28 +296,31 @@ declare class PostgresStore extends MastraStorage {
|
|
|
288
296
|
fromDate?: Date;
|
|
289
297
|
toDate?: Date;
|
|
290
298
|
}): Promise<any[]>;
|
|
291
|
-
|
|
299
|
+
getTracesPaginated(args: {
|
|
292
300
|
name?: string;
|
|
293
301
|
scope?: string;
|
|
294
|
-
page: number;
|
|
295
|
-
perPage?: number;
|
|
296
302
|
attributes?: Record<string, string>;
|
|
297
303
|
filters?: Record<string, any>;
|
|
298
|
-
|
|
299
|
-
toDate?: Date;
|
|
300
|
-
returnPaginationResults: true;
|
|
301
|
-
}): Promise<{
|
|
304
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
302
305
|
traces: any[];
|
|
303
|
-
total: number;
|
|
304
|
-
page: number;
|
|
305
|
-
perPage: number;
|
|
306
|
-
hasMore: boolean;
|
|
307
306
|
}>;
|
|
308
307
|
private setupSchema;
|
|
309
308
|
createTable({ tableName, schema, }: {
|
|
310
309
|
tableName: TABLE_NAMES;
|
|
311
310
|
schema: Record<string, StorageColumn>;
|
|
312
311
|
}): Promise<void>;
|
|
312
|
+
protected getDefaultValue(type: StorageColumn['type']): string;
|
|
313
|
+
/**
|
|
314
|
+
* Alters table schema to add columns if they don't exist
|
|
315
|
+
* @param tableName Name of the table
|
|
316
|
+
* @param schema Schema of the table
|
|
317
|
+
* @param ifNotExists Array of column names to add if they don't exist
|
|
318
|
+
*/
|
|
319
|
+
alterTable({ tableName, schema, ifNotExists, }: {
|
|
320
|
+
tableName: TABLE_NAMES;
|
|
321
|
+
schema: Record<string, StorageColumn>;
|
|
322
|
+
ifNotExists: string[];
|
|
323
|
+
}): Promise<void>;
|
|
313
324
|
clearTable({ tableName }: {
|
|
314
325
|
tableName: TABLE_NAMES;
|
|
315
326
|
}): Promise<void>;
|
|
@@ -324,19 +335,16 @@ declare class PostgresStore extends MastraStorage {
|
|
|
324
335
|
getThreadById({ threadId }: {
|
|
325
336
|
threadId: string;
|
|
326
337
|
}): Promise<StorageThreadType | null>;
|
|
338
|
+
/**
|
|
339
|
+
* @deprecated use getThreadsByResourceIdPaginated instead
|
|
340
|
+
*/
|
|
327
341
|
getThreadsByResourceId(args: {
|
|
328
342
|
resourceId: string;
|
|
329
343
|
}): Promise<StorageThreadType[]>;
|
|
330
|
-
|
|
344
|
+
getThreadsByResourceIdPaginated(args: {
|
|
331
345
|
resourceId: string;
|
|
332
|
-
|
|
333
|
-
perPage?: number;
|
|
334
|
-
}): Promise<{
|
|
346
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
335
347
|
threads: StorageThreadType[];
|
|
336
|
-
total: number;
|
|
337
|
-
page: number;
|
|
338
|
-
perPage: number;
|
|
339
|
-
hasMore: boolean;
|
|
340
348
|
}>;
|
|
341
349
|
saveThread({ thread }: {
|
|
342
350
|
thread: StorageThreadType;
|
|
@@ -349,24 +357,19 @@ declare class PostgresStore extends MastraStorage {
|
|
|
349
357
|
deleteThread({ threadId }: {
|
|
350
358
|
threadId: string;
|
|
351
359
|
}): Promise<void>;
|
|
360
|
+
/**
|
|
361
|
+
* @deprecated use getMessagesPaginated instead
|
|
362
|
+
*/
|
|
352
363
|
getMessages(args: StorageGetMessagesArg & {
|
|
353
364
|
format?: 'v1';
|
|
354
365
|
}): Promise<MastraMessageV1[]>;
|
|
355
366
|
getMessages(args: StorageGetMessagesArg & {
|
|
356
367
|
format: 'v2';
|
|
357
368
|
}): Promise<MastraMessageV2[]>;
|
|
358
|
-
|
|
369
|
+
getMessagesPaginated(args: StorageGetMessagesArg & {
|
|
359
370
|
format?: 'v1' | 'v2';
|
|
360
|
-
|
|
361
|
-
perPage?: number;
|
|
362
|
-
fromDate?: Date;
|
|
363
|
-
toDate?: Date;
|
|
364
|
-
}): Promise<{
|
|
371
|
+
}): Promise<PaginationInfo & {
|
|
365
372
|
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
366
|
-
total: number;
|
|
367
|
-
page: number;
|
|
368
|
-
perPage: number;
|
|
369
|
-
hasMore: boolean;
|
|
370
373
|
}>;
|
|
371
374
|
saveMessages(args: {
|
|
372
375
|
messages: MastraMessageV1[];
|
|
@@ -403,18 +406,8 @@ declare class PostgresStore extends MastraStorage {
|
|
|
403
406
|
getEvals(options?: {
|
|
404
407
|
agentName?: string;
|
|
405
408
|
type?: 'test' | 'live';
|
|
406
|
-
|
|
407
|
-
perPage?: number;
|
|
408
|
-
limit?: number;
|
|
409
|
-
offset?: number;
|
|
410
|
-
fromDate?: Date;
|
|
411
|
-
toDate?: Date;
|
|
412
|
-
}): Promise<{
|
|
409
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
413
410
|
evals: EvalRow[];
|
|
414
|
-
total: number;
|
|
415
|
-
page?: number;
|
|
416
|
-
perPage?: number;
|
|
417
|
-
hasMore?: boolean;
|
|
418
411
|
}>;
|
|
419
412
|
}
|
|
420
413
|
export { PostgresStore }
|
|
@@ -11,6 +11,8 @@ import type { MastraMessageV2 } from '@mastra/core/agent';
|
|
|
11
11
|
import { MastraStorage } from '@mastra/core/storage';
|
|
12
12
|
import { MastraVector } from '@mastra/core/vector';
|
|
13
13
|
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
14
|
+
import type { PaginationArgs } from '@mastra/core/storage';
|
|
15
|
+
import type { PaginationInfo } from '@mastra/core/storage';
|
|
14
16
|
import pg from 'pg';
|
|
15
17
|
import type { QueryResult } from '@mastra/core/vector';
|
|
16
18
|
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
@@ -270,6 +272,9 @@ declare class PostgresStore extends MastraStorage {
|
|
|
270
272
|
private setupSchemaPromise;
|
|
271
273
|
private schemaSetupComplete;
|
|
272
274
|
constructor(config: PostgresConfig);
|
|
275
|
+
get supports(): {
|
|
276
|
+
selectByIncludeResourceScope: boolean;
|
|
277
|
+
};
|
|
273
278
|
private getTableName;
|
|
274
279
|
/** @deprecated use getEvals instead */
|
|
275
280
|
getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
@@ -278,6 +283,9 @@ declare class PostgresStore extends MastraStorage {
|
|
|
278
283
|
tableName: TABLE_NAMES;
|
|
279
284
|
records: Record<string, any>[];
|
|
280
285
|
}): Promise<void>;
|
|
286
|
+
/**
|
|
287
|
+
* @deprecated use getTracesPaginated instead
|
|
288
|
+
*/
|
|
281
289
|
getTraces(args: {
|
|
282
290
|
name?: string;
|
|
283
291
|
scope?: string;
|
|
@@ -288,28 +296,31 @@ declare class PostgresStore extends MastraStorage {
|
|
|
288
296
|
fromDate?: Date;
|
|
289
297
|
toDate?: Date;
|
|
290
298
|
}): Promise<any[]>;
|
|
291
|
-
|
|
299
|
+
getTracesPaginated(args: {
|
|
292
300
|
name?: string;
|
|
293
301
|
scope?: string;
|
|
294
|
-
page: number;
|
|
295
|
-
perPage?: number;
|
|
296
302
|
attributes?: Record<string, string>;
|
|
297
303
|
filters?: Record<string, any>;
|
|
298
|
-
|
|
299
|
-
toDate?: Date;
|
|
300
|
-
returnPaginationResults: true;
|
|
301
|
-
}): Promise<{
|
|
304
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
302
305
|
traces: any[];
|
|
303
|
-
total: number;
|
|
304
|
-
page: number;
|
|
305
|
-
perPage: number;
|
|
306
|
-
hasMore: boolean;
|
|
307
306
|
}>;
|
|
308
307
|
private setupSchema;
|
|
309
308
|
createTable({ tableName, schema, }: {
|
|
310
309
|
tableName: TABLE_NAMES;
|
|
311
310
|
schema: Record<string, StorageColumn>;
|
|
312
311
|
}): Promise<void>;
|
|
312
|
+
protected getDefaultValue(type: StorageColumn['type']): string;
|
|
313
|
+
/**
|
|
314
|
+
* Alters table schema to add columns if they don't exist
|
|
315
|
+
* @param tableName Name of the table
|
|
316
|
+
* @param schema Schema of the table
|
|
317
|
+
* @param ifNotExists Array of column names to add if they don't exist
|
|
318
|
+
*/
|
|
319
|
+
alterTable({ tableName, schema, ifNotExists, }: {
|
|
320
|
+
tableName: TABLE_NAMES;
|
|
321
|
+
schema: Record<string, StorageColumn>;
|
|
322
|
+
ifNotExists: string[];
|
|
323
|
+
}): Promise<void>;
|
|
313
324
|
clearTable({ tableName }: {
|
|
314
325
|
tableName: TABLE_NAMES;
|
|
315
326
|
}): Promise<void>;
|
|
@@ -324,19 +335,16 @@ declare class PostgresStore extends MastraStorage {
|
|
|
324
335
|
getThreadById({ threadId }: {
|
|
325
336
|
threadId: string;
|
|
326
337
|
}): Promise<StorageThreadType | null>;
|
|
338
|
+
/**
|
|
339
|
+
* @deprecated use getThreadsByResourceIdPaginated instead
|
|
340
|
+
*/
|
|
327
341
|
getThreadsByResourceId(args: {
|
|
328
342
|
resourceId: string;
|
|
329
343
|
}): Promise<StorageThreadType[]>;
|
|
330
|
-
|
|
344
|
+
getThreadsByResourceIdPaginated(args: {
|
|
331
345
|
resourceId: string;
|
|
332
|
-
|
|
333
|
-
perPage?: number;
|
|
334
|
-
}): Promise<{
|
|
346
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
335
347
|
threads: StorageThreadType[];
|
|
336
|
-
total: number;
|
|
337
|
-
page: number;
|
|
338
|
-
perPage: number;
|
|
339
|
-
hasMore: boolean;
|
|
340
348
|
}>;
|
|
341
349
|
saveThread({ thread }: {
|
|
342
350
|
thread: StorageThreadType;
|
|
@@ -349,24 +357,19 @@ declare class PostgresStore extends MastraStorage {
|
|
|
349
357
|
deleteThread({ threadId }: {
|
|
350
358
|
threadId: string;
|
|
351
359
|
}): Promise<void>;
|
|
360
|
+
/**
|
|
361
|
+
* @deprecated use getMessagesPaginated instead
|
|
362
|
+
*/
|
|
352
363
|
getMessages(args: StorageGetMessagesArg & {
|
|
353
364
|
format?: 'v1';
|
|
354
365
|
}): Promise<MastraMessageV1[]>;
|
|
355
366
|
getMessages(args: StorageGetMessagesArg & {
|
|
356
367
|
format: 'v2';
|
|
357
368
|
}): Promise<MastraMessageV2[]>;
|
|
358
|
-
|
|
369
|
+
getMessagesPaginated(args: StorageGetMessagesArg & {
|
|
359
370
|
format?: 'v1' | 'v2';
|
|
360
|
-
|
|
361
|
-
perPage?: number;
|
|
362
|
-
fromDate?: Date;
|
|
363
|
-
toDate?: Date;
|
|
364
|
-
}): Promise<{
|
|
371
|
+
}): Promise<PaginationInfo & {
|
|
365
372
|
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
366
|
-
total: number;
|
|
367
|
-
page: number;
|
|
368
|
-
perPage: number;
|
|
369
|
-
hasMore: boolean;
|
|
370
373
|
}>;
|
|
371
374
|
saveMessages(args: {
|
|
372
375
|
messages: MastraMessageV1[];
|
|
@@ -403,18 +406,8 @@ declare class PostgresStore extends MastraStorage {
|
|
|
403
406
|
getEvals(options?: {
|
|
404
407
|
agentName?: string;
|
|
405
408
|
type?: 'test' | 'live';
|
|
406
|
-
|
|
407
|
-
perPage?: number;
|
|
408
|
-
limit?: number;
|
|
409
|
-
offset?: number;
|
|
410
|
-
fromDate?: Date;
|
|
411
|
-
toDate?: Date;
|
|
412
|
-
}): Promise<{
|
|
409
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
413
410
|
evals: EvalRow[];
|
|
414
|
-
total: number;
|
|
415
|
-
page?: number;
|
|
416
|
-
perPage?: number;
|
|
417
|
-
hasMore?: boolean;
|
|
418
411
|
}>;
|
|
419
412
|
}
|
|
420
413
|
export { PostgresStore }
|