@mastra/pg 0.10.2-alpha.0 → 0.10.2-alpha.1
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 +12 -0
- package/dist/_tsup-dts-rollup.d.cts +30 -40
- package/dist/_tsup-dts-rollup.d.ts +30 -40
- package/dist/index.cjs +226 -196
- package/dist/index.js +226 -196
- package/package.json +3 -3
- package/src/storage/index.test.ts +208 -190
- package/src/storage/index.ts +283 -318
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.1 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 10884ms
|
|
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 12247ms
|
|
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[32m66.09 KB[39m
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 1701ms
|
|
22
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m66.65 KB[39m
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 1701ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @mastra/pg
|
|
2
2
|
|
|
3
|
+
## 0.10.2-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0db1e1e: Fix PostgresStore paginated APIs
|
|
8
|
+
- dffb67b: updated stores to add alter table and change tests
|
|
9
|
+
- Updated dependencies [f6fd25f]
|
|
10
|
+
- Updated dependencies [dffb67b]
|
|
11
|
+
- Updated dependencies [f1309d3]
|
|
12
|
+
- Updated dependencies [f7f8293]
|
|
13
|
+
- @mastra/core@0.10.4-alpha.1
|
|
14
|
+
|
|
3
15
|
## 0.10.2-alpha.0
|
|
4
16
|
|
|
5
17
|
### 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';
|
|
@@ -278,6 +280,9 @@ declare class PostgresStore extends MastraStorage {
|
|
|
278
280
|
tableName: TABLE_NAMES;
|
|
279
281
|
records: Record<string, any>[];
|
|
280
282
|
}): Promise<void>;
|
|
283
|
+
/**
|
|
284
|
+
* @deprecated use getTracesPaginated instead
|
|
285
|
+
*/
|
|
281
286
|
getTraces(args: {
|
|
282
287
|
name?: string;
|
|
283
288
|
scope?: string;
|
|
@@ -288,28 +293,31 @@ declare class PostgresStore extends MastraStorage {
|
|
|
288
293
|
fromDate?: Date;
|
|
289
294
|
toDate?: Date;
|
|
290
295
|
}): Promise<any[]>;
|
|
291
|
-
|
|
296
|
+
getTracesPaginated(args: {
|
|
292
297
|
name?: string;
|
|
293
298
|
scope?: string;
|
|
294
|
-
page: number;
|
|
295
|
-
perPage?: number;
|
|
296
299
|
attributes?: Record<string, string>;
|
|
297
300
|
filters?: Record<string, any>;
|
|
298
|
-
|
|
299
|
-
toDate?: Date;
|
|
300
|
-
returnPaginationResults: true;
|
|
301
|
-
}): Promise<{
|
|
301
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
302
302
|
traces: any[];
|
|
303
|
-
total: number;
|
|
304
|
-
page: number;
|
|
305
|
-
perPage: number;
|
|
306
|
-
hasMore: boolean;
|
|
307
303
|
}>;
|
|
308
304
|
private setupSchema;
|
|
309
305
|
createTable({ tableName, schema, }: {
|
|
310
306
|
tableName: TABLE_NAMES;
|
|
311
307
|
schema: Record<string, StorageColumn>;
|
|
312
308
|
}): Promise<void>;
|
|
309
|
+
protected getDefaultValue(type: StorageColumn['type']): string;
|
|
310
|
+
/**
|
|
311
|
+
* Alters table schema to add columns if they don't exist
|
|
312
|
+
* @param tableName Name of the table
|
|
313
|
+
* @param schema Schema of the table
|
|
314
|
+
* @param ifNotExists Array of column names to add if they don't exist
|
|
315
|
+
*/
|
|
316
|
+
alterTable({ tableName, schema, ifNotExists, }: {
|
|
317
|
+
tableName: TABLE_NAMES;
|
|
318
|
+
schema: Record<string, StorageColumn>;
|
|
319
|
+
ifNotExists: string[];
|
|
320
|
+
}): Promise<void>;
|
|
313
321
|
clearTable({ tableName }: {
|
|
314
322
|
tableName: TABLE_NAMES;
|
|
315
323
|
}): Promise<void>;
|
|
@@ -324,19 +332,16 @@ declare class PostgresStore extends MastraStorage {
|
|
|
324
332
|
getThreadById({ threadId }: {
|
|
325
333
|
threadId: string;
|
|
326
334
|
}): Promise<StorageThreadType | null>;
|
|
335
|
+
/**
|
|
336
|
+
* @deprecated use getThreadsByResourceIdPaginated instead
|
|
337
|
+
*/
|
|
327
338
|
getThreadsByResourceId(args: {
|
|
328
339
|
resourceId: string;
|
|
329
340
|
}): Promise<StorageThreadType[]>;
|
|
330
|
-
|
|
341
|
+
getThreadsByResourceIdPaginated(args: {
|
|
331
342
|
resourceId: string;
|
|
332
|
-
|
|
333
|
-
perPage?: number;
|
|
334
|
-
}): Promise<{
|
|
343
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
335
344
|
threads: StorageThreadType[];
|
|
336
|
-
total: number;
|
|
337
|
-
page: number;
|
|
338
|
-
perPage: number;
|
|
339
|
-
hasMore: boolean;
|
|
340
345
|
}>;
|
|
341
346
|
saveThread({ thread }: {
|
|
342
347
|
thread: StorageThreadType;
|
|
@@ -349,24 +354,19 @@ declare class PostgresStore extends MastraStorage {
|
|
|
349
354
|
deleteThread({ threadId }: {
|
|
350
355
|
threadId: string;
|
|
351
356
|
}): Promise<void>;
|
|
357
|
+
/**
|
|
358
|
+
* @deprecated use getMessagesPaginated instead
|
|
359
|
+
*/
|
|
352
360
|
getMessages(args: StorageGetMessagesArg & {
|
|
353
361
|
format?: 'v1';
|
|
354
362
|
}): Promise<MastraMessageV1[]>;
|
|
355
363
|
getMessages(args: StorageGetMessagesArg & {
|
|
356
364
|
format: 'v2';
|
|
357
365
|
}): Promise<MastraMessageV2[]>;
|
|
358
|
-
|
|
366
|
+
getMessagesPaginated(args: StorageGetMessagesArg & {
|
|
359
367
|
format?: 'v1' | 'v2';
|
|
360
|
-
|
|
361
|
-
perPage?: number;
|
|
362
|
-
fromDate?: Date;
|
|
363
|
-
toDate?: Date;
|
|
364
|
-
}): Promise<{
|
|
368
|
+
}): Promise<PaginationInfo & {
|
|
365
369
|
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
366
|
-
total: number;
|
|
367
|
-
page: number;
|
|
368
|
-
perPage: number;
|
|
369
|
-
hasMore: boolean;
|
|
370
370
|
}>;
|
|
371
371
|
saveMessages(args: {
|
|
372
372
|
messages: MastraMessageV1[];
|
|
@@ -403,18 +403,8 @@ declare class PostgresStore extends MastraStorage {
|
|
|
403
403
|
getEvals(options?: {
|
|
404
404
|
agentName?: string;
|
|
405
405
|
type?: 'test' | 'live';
|
|
406
|
-
|
|
407
|
-
perPage?: number;
|
|
408
|
-
limit?: number;
|
|
409
|
-
offset?: number;
|
|
410
|
-
fromDate?: Date;
|
|
411
|
-
toDate?: Date;
|
|
412
|
-
}): Promise<{
|
|
406
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
413
407
|
evals: EvalRow[];
|
|
414
|
-
total: number;
|
|
415
|
-
page?: number;
|
|
416
|
-
perPage?: number;
|
|
417
|
-
hasMore?: boolean;
|
|
418
408
|
}>;
|
|
419
409
|
}
|
|
420
410
|
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';
|
|
@@ -278,6 +280,9 @@ declare class PostgresStore extends MastraStorage {
|
|
|
278
280
|
tableName: TABLE_NAMES;
|
|
279
281
|
records: Record<string, any>[];
|
|
280
282
|
}): Promise<void>;
|
|
283
|
+
/**
|
|
284
|
+
* @deprecated use getTracesPaginated instead
|
|
285
|
+
*/
|
|
281
286
|
getTraces(args: {
|
|
282
287
|
name?: string;
|
|
283
288
|
scope?: string;
|
|
@@ -288,28 +293,31 @@ declare class PostgresStore extends MastraStorage {
|
|
|
288
293
|
fromDate?: Date;
|
|
289
294
|
toDate?: Date;
|
|
290
295
|
}): Promise<any[]>;
|
|
291
|
-
|
|
296
|
+
getTracesPaginated(args: {
|
|
292
297
|
name?: string;
|
|
293
298
|
scope?: string;
|
|
294
|
-
page: number;
|
|
295
|
-
perPage?: number;
|
|
296
299
|
attributes?: Record<string, string>;
|
|
297
300
|
filters?: Record<string, any>;
|
|
298
|
-
|
|
299
|
-
toDate?: Date;
|
|
300
|
-
returnPaginationResults: true;
|
|
301
|
-
}): Promise<{
|
|
301
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
302
302
|
traces: any[];
|
|
303
|
-
total: number;
|
|
304
|
-
page: number;
|
|
305
|
-
perPage: number;
|
|
306
|
-
hasMore: boolean;
|
|
307
303
|
}>;
|
|
308
304
|
private setupSchema;
|
|
309
305
|
createTable({ tableName, schema, }: {
|
|
310
306
|
tableName: TABLE_NAMES;
|
|
311
307
|
schema: Record<string, StorageColumn>;
|
|
312
308
|
}): Promise<void>;
|
|
309
|
+
protected getDefaultValue(type: StorageColumn['type']): string;
|
|
310
|
+
/**
|
|
311
|
+
* Alters table schema to add columns if they don't exist
|
|
312
|
+
* @param tableName Name of the table
|
|
313
|
+
* @param schema Schema of the table
|
|
314
|
+
* @param ifNotExists Array of column names to add if they don't exist
|
|
315
|
+
*/
|
|
316
|
+
alterTable({ tableName, schema, ifNotExists, }: {
|
|
317
|
+
tableName: TABLE_NAMES;
|
|
318
|
+
schema: Record<string, StorageColumn>;
|
|
319
|
+
ifNotExists: string[];
|
|
320
|
+
}): Promise<void>;
|
|
313
321
|
clearTable({ tableName }: {
|
|
314
322
|
tableName: TABLE_NAMES;
|
|
315
323
|
}): Promise<void>;
|
|
@@ -324,19 +332,16 @@ declare class PostgresStore extends MastraStorage {
|
|
|
324
332
|
getThreadById({ threadId }: {
|
|
325
333
|
threadId: string;
|
|
326
334
|
}): Promise<StorageThreadType | null>;
|
|
335
|
+
/**
|
|
336
|
+
* @deprecated use getThreadsByResourceIdPaginated instead
|
|
337
|
+
*/
|
|
327
338
|
getThreadsByResourceId(args: {
|
|
328
339
|
resourceId: string;
|
|
329
340
|
}): Promise<StorageThreadType[]>;
|
|
330
|
-
|
|
341
|
+
getThreadsByResourceIdPaginated(args: {
|
|
331
342
|
resourceId: string;
|
|
332
|
-
|
|
333
|
-
perPage?: number;
|
|
334
|
-
}): Promise<{
|
|
343
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
335
344
|
threads: StorageThreadType[];
|
|
336
|
-
total: number;
|
|
337
|
-
page: number;
|
|
338
|
-
perPage: number;
|
|
339
|
-
hasMore: boolean;
|
|
340
345
|
}>;
|
|
341
346
|
saveThread({ thread }: {
|
|
342
347
|
thread: StorageThreadType;
|
|
@@ -349,24 +354,19 @@ declare class PostgresStore extends MastraStorage {
|
|
|
349
354
|
deleteThread({ threadId }: {
|
|
350
355
|
threadId: string;
|
|
351
356
|
}): Promise<void>;
|
|
357
|
+
/**
|
|
358
|
+
* @deprecated use getMessagesPaginated instead
|
|
359
|
+
*/
|
|
352
360
|
getMessages(args: StorageGetMessagesArg & {
|
|
353
361
|
format?: 'v1';
|
|
354
362
|
}): Promise<MastraMessageV1[]>;
|
|
355
363
|
getMessages(args: StorageGetMessagesArg & {
|
|
356
364
|
format: 'v2';
|
|
357
365
|
}): Promise<MastraMessageV2[]>;
|
|
358
|
-
|
|
366
|
+
getMessagesPaginated(args: StorageGetMessagesArg & {
|
|
359
367
|
format?: 'v1' | 'v2';
|
|
360
|
-
|
|
361
|
-
perPage?: number;
|
|
362
|
-
fromDate?: Date;
|
|
363
|
-
toDate?: Date;
|
|
364
|
-
}): Promise<{
|
|
368
|
+
}): Promise<PaginationInfo & {
|
|
365
369
|
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
366
|
-
total: number;
|
|
367
|
-
page: number;
|
|
368
|
-
perPage: number;
|
|
369
|
-
hasMore: boolean;
|
|
370
370
|
}>;
|
|
371
371
|
saveMessages(args: {
|
|
372
372
|
messages: MastraMessageV1[];
|
|
@@ -403,18 +403,8 @@ declare class PostgresStore extends MastraStorage {
|
|
|
403
403
|
getEvals(options?: {
|
|
404
404
|
agentName?: string;
|
|
405
405
|
type?: 'test' | 'live';
|
|
406
|
-
|
|
407
|
-
perPage?: number;
|
|
408
|
-
limit?: number;
|
|
409
|
-
offset?: number;
|
|
410
|
-
fromDate?: Date;
|
|
411
|
-
toDate?: Date;
|
|
412
|
-
}): Promise<{
|
|
406
|
+
} & PaginationArgs): Promise<PaginationInfo & {
|
|
413
407
|
evals: EvalRow[];
|
|
414
|
-
total: number;
|
|
415
|
-
page?: number;
|
|
416
|
-
perPage?: number;
|
|
417
|
-
hasMore?: boolean;
|
|
418
408
|
}>;
|
|
419
409
|
}
|
|
420
410
|
export { PostgresStore }
|