@mastra/pg 0.10.1 → 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.
@@ -1,23 +1,23 @@
1
1
 
2
- > @mastra/pg@0.10.1-alpha.2 build /home/runner/work/mastra/mastra/stores/pg
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
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.4.0
7
+ CLI tsup v8.5.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 8555ms
9
+ TSC ⚡️ Build success in 10884ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.3
13
13
  Writing package typings: /home/runner/work/mastra/mastra/stores/pg/dist/_tsup-dts-rollup.d.ts
14
14
  Analysis will use the bundled TypeScript version 5.8.3
15
15
  Writing package typings: /home/runner/work/mastra/mastra/stores/pg/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 11494ms
16
+ DTS ⚡️ Build success in 12247ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 57.55 KB
21
- ESM ⚡️ Build success in 996ms
22
- CJS dist/index.cjs 58.05 KB
23
- CJS ⚡️ Build success in 1541ms
20
+ ESM dist/index.js 66.09 KB
21
+ ESM ⚡️ Build success in 1701ms
22
+ CJS dist/index.cjs 66.65 KB
23
+ CJS ⚡️ Build success in 1701ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
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
+
15
+ ## 0.10.2-alpha.0
16
+
17
+ ### Patch Changes
18
+
19
+ - e95cb69: dependencies updates:
20
+ - Updated dependency [`pg@^8.16.0` ↗︎](https://www.npmjs.com/package/pg/v/8.16.0) (from `^8.13.3`, in `dependencies`)
21
+ - Updated dependency [`pg-promise@^11.13.0` ↗︎](https://www.npmjs.com/package/pg-promise/v/11.13.0) (from `^11.11.0`, in `dependencies`)
22
+ - Updated dependencies [d1ed912]
23
+ - Updated dependencies [f1f1f1b]
24
+ - Updated dependencies [f9816ae]
25
+ - Updated dependencies [82090c1]
26
+ - Updated dependencies [1b443fd]
27
+ - Updated dependencies [ce97900]
28
+ - Updated dependencies [14a2566]
29
+ - @mastra/core@0.10.4-alpha.0
30
+
3
31
  ## 0.10.1
4
32
 
5
33
  ### 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';
@@ -271,27 +273,51 @@ declare class PostgresStore extends MastraStorage {
271
273
  private schemaSetupComplete;
272
274
  constructor(config: PostgresConfig);
273
275
  private getTableName;
276
+ /** @deprecated use getEvals instead */
274
277
  getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
275
278
  private transformEvalRow;
276
279
  batchInsert({ tableName, records }: {
277
280
  tableName: TABLE_NAMES;
278
281
  records: Record<string, any>[];
279
282
  }): Promise<void>;
280
- getTraces({ name, scope, page, perPage, attributes, filters, fromDate, toDate, }: {
283
+ /**
284
+ * @deprecated use getTracesPaginated instead
285
+ */
286
+ getTraces(args: {
281
287
  name?: string;
282
288
  scope?: string;
283
- page: number;
284
- perPage: number;
285
289
  attributes?: Record<string, string>;
286
290
  filters?: Record<string, any>;
291
+ page: number;
292
+ perPage?: number;
287
293
  fromDate?: Date;
288
294
  toDate?: Date;
289
295
  }): Promise<any[]>;
296
+ getTracesPaginated(args: {
297
+ name?: string;
298
+ scope?: string;
299
+ attributes?: Record<string, string>;
300
+ filters?: Record<string, any>;
301
+ } & PaginationArgs): Promise<PaginationInfo & {
302
+ traces: any[];
303
+ }>;
290
304
  private setupSchema;
291
305
  createTable({ tableName, schema, }: {
292
306
  tableName: TABLE_NAMES;
293
307
  schema: Record<string, StorageColumn>;
294
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>;
295
321
  clearTable({ tableName }: {
296
322
  tableName: TABLE_NAMES;
297
323
  }): Promise<void>;
@@ -306,9 +332,17 @@ declare class PostgresStore extends MastraStorage {
306
332
  getThreadById({ threadId }: {
307
333
  threadId: string;
308
334
  }): Promise<StorageThreadType | null>;
309
- getThreadsByResourceId({ resourceId }: {
335
+ /**
336
+ * @deprecated use getThreadsByResourceIdPaginated instead
337
+ */
338
+ getThreadsByResourceId(args: {
310
339
  resourceId: string;
311
340
  }): Promise<StorageThreadType[]>;
341
+ getThreadsByResourceIdPaginated(args: {
342
+ resourceId: string;
343
+ } & PaginationArgs): Promise<PaginationInfo & {
344
+ threads: StorageThreadType[];
345
+ }>;
312
346
  saveThread({ thread }: {
313
347
  thread: StorageThreadType;
314
348
  }): Promise<StorageThreadType>;
@@ -320,7 +354,20 @@ declare class PostgresStore extends MastraStorage {
320
354
  deleteThread({ threadId }: {
321
355
  threadId: string;
322
356
  }): Promise<void>;
323
- getMessages<T = unknown>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T[]>;
357
+ /**
358
+ * @deprecated use getMessagesPaginated instead
359
+ */
360
+ getMessages(args: StorageGetMessagesArg & {
361
+ format?: 'v1';
362
+ }): Promise<MastraMessageV1[]>;
363
+ getMessages(args: StorageGetMessagesArg & {
364
+ format: 'v2';
365
+ }): Promise<MastraMessageV2[]>;
366
+ getMessagesPaginated(args: StorageGetMessagesArg & {
367
+ format?: 'v1' | 'v2';
368
+ }): Promise<PaginationInfo & {
369
+ messages: MastraMessageV1[] | MastraMessageV2[];
370
+ }>;
324
371
  saveMessages(args: {
325
372
  messages: MastraMessageV1[];
326
373
  format?: undefined | 'v1';
@@ -353,6 +400,12 @@ declare class PostgresStore extends MastraStorage {
353
400
  workflowName?: string;
354
401
  }): Promise<WorkflowRun | null>;
355
402
  close(): Promise<void>;
403
+ getEvals(options?: {
404
+ agentName?: string;
405
+ type?: 'test' | 'live';
406
+ } & PaginationArgs): Promise<PaginationInfo & {
407
+ evals: EvalRow[];
408
+ }>;
356
409
  }
357
410
  export { PostgresStore }
358
411
  export { PostgresStore as PostgresStore_alias_1 }
@@ -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';
@@ -271,27 +273,51 @@ declare class PostgresStore extends MastraStorage {
271
273
  private schemaSetupComplete;
272
274
  constructor(config: PostgresConfig);
273
275
  private getTableName;
276
+ /** @deprecated use getEvals instead */
274
277
  getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
275
278
  private transformEvalRow;
276
279
  batchInsert({ tableName, records }: {
277
280
  tableName: TABLE_NAMES;
278
281
  records: Record<string, any>[];
279
282
  }): Promise<void>;
280
- getTraces({ name, scope, page, perPage, attributes, filters, fromDate, toDate, }: {
283
+ /**
284
+ * @deprecated use getTracesPaginated instead
285
+ */
286
+ getTraces(args: {
281
287
  name?: string;
282
288
  scope?: string;
283
- page: number;
284
- perPage: number;
285
289
  attributes?: Record<string, string>;
286
290
  filters?: Record<string, any>;
291
+ page: number;
292
+ perPage?: number;
287
293
  fromDate?: Date;
288
294
  toDate?: Date;
289
295
  }): Promise<any[]>;
296
+ getTracesPaginated(args: {
297
+ name?: string;
298
+ scope?: string;
299
+ attributes?: Record<string, string>;
300
+ filters?: Record<string, any>;
301
+ } & PaginationArgs): Promise<PaginationInfo & {
302
+ traces: any[];
303
+ }>;
290
304
  private setupSchema;
291
305
  createTable({ tableName, schema, }: {
292
306
  tableName: TABLE_NAMES;
293
307
  schema: Record<string, StorageColumn>;
294
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>;
295
321
  clearTable({ tableName }: {
296
322
  tableName: TABLE_NAMES;
297
323
  }): Promise<void>;
@@ -306,9 +332,17 @@ declare class PostgresStore extends MastraStorage {
306
332
  getThreadById({ threadId }: {
307
333
  threadId: string;
308
334
  }): Promise<StorageThreadType | null>;
309
- getThreadsByResourceId({ resourceId }: {
335
+ /**
336
+ * @deprecated use getThreadsByResourceIdPaginated instead
337
+ */
338
+ getThreadsByResourceId(args: {
310
339
  resourceId: string;
311
340
  }): Promise<StorageThreadType[]>;
341
+ getThreadsByResourceIdPaginated(args: {
342
+ resourceId: string;
343
+ } & PaginationArgs): Promise<PaginationInfo & {
344
+ threads: StorageThreadType[];
345
+ }>;
312
346
  saveThread({ thread }: {
313
347
  thread: StorageThreadType;
314
348
  }): Promise<StorageThreadType>;
@@ -320,7 +354,20 @@ declare class PostgresStore extends MastraStorage {
320
354
  deleteThread({ threadId }: {
321
355
  threadId: string;
322
356
  }): Promise<void>;
323
- getMessages<T = unknown>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T[]>;
357
+ /**
358
+ * @deprecated use getMessagesPaginated instead
359
+ */
360
+ getMessages(args: StorageGetMessagesArg & {
361
+ format?: 'v1';
362
+ }): Promise<MastraMessageV1[]>;
363
+ getMessages(args: StorageGetMessagesArg & {
364
+ format: 'v2';
365
+ }): Promise<MastraMessageV2[]>;
366
+ getMessagesPaginated(args: StorageGetMessagesArg & {
367
+ format?: 'v1' | 'v2';
368
+ }): Promise<PaginationInfo & {
369
+ messages: MastraMessageV1[] | MastraMessageV2[];
370
+ }>;
324
371
  saveMessages(args: {
325
372
  messages: MastraMessageV1[];
326
373
  format?: undefined | 'v1';
@@ -353,6 +400,12 @@ declare class PostgresStore extends MastraStorage {
353
400
  workflowName?: string;
354
401
  }): Promise<WorkflowRun | null>;
355
402
  close(): Promise<void>;
403
+ getEvals(options?: {
404
+ agentName?: string;
405
+ type?: 'test' | 'live';
406
+ } & PaginationArgs): Promise<PaginationInfo & {
407
+ evals: EvalRow[];
408
+ }>;
356
409
  }
357
410
  export { PostgresStore }
358
411
  export { PostgresStore as PostgresStore_alias_1 }