@mastra/pg 1.0.0-beta.8 → 1.0.0-beta.9
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 +234 -0
- package/dist/index.cjs +2464 -2216
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2465 -2217
- package/dist/index.js.map +1 -1
- package/dist/shared/config.d.ts +77 -2
- package/dist/shared/config.d.ts.map +1 -1
- package/dist/storage/{domains/operations → db}/index.d.ts +77 -45
- 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 +30 -11
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts +29 -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 +25 -12
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +23 -193
- 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/package.json +2 -2
- package/dist/storage/domains/operations/index.d.ts.map +0 -1
package/dist/shared/config.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ConnectionOptions } from 'node:tls';
|
|
2
|
+
import type { CreateIndexOptions } from '@mastra/core/storage';
|
|
2
3
|
import type { ClientConfig } from 'pg';
|
|
3
4
|
import type * as pg from 'pg';
|
|
5
|
+
import type pgPromise from 'pg-promise';
|
|
4
6
|
import type { ISSLConfig } from 'pg-promise/typescript/pg-subset';
|
|
5
7
|
/**
|
|
6
8
|
* Generic PostgreSQL configuration type.
|
|
@@ -31,6 +33,35 @@ export type PostgresConfig<SSLType = ISSLConfig | ConnectionOptions> = {
|
|
|
31
33
|
* // No auto-init, tables must already exist
|
|
32
34
|
*/
|
|
33
35
|
disableInit?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* When true, default indexes will not be created during initialization.
|
|
38
|
+
* This is useful when:
|
|
39
|
+
* 1. You want to manage indexes separately or use custom indexes only
|
|
40
|
+
* 2. Default indexes don't match your query patterns
|
|
41
|
+
* 3. You want to reduce initialization time in development
|
|
42
|
+
*
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
skipDefaultIndexes?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Custom indexes to create during initialization.
|
|
48
|
+
* These indexes are created in addition to default indexes (unless skipDefaultIndexes is true).
|
|
49
|
+
*
|
|
50
|
+
* Each index must specify which table it belongs to. The store will route each index
|
|
51
|
+
* to the appropriate domain based on the table name.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const store = new PostgresStore({
|
|
56
|
+
* connectionString: '...',
|
|
57
|
+
* indexes: [
|
|
58
|
+
* { name: 'my_threads_type_idx', table: 'mastra_threads', columns: ['metadata->>\'type\''] },
|
|
59
|
+
* { name: 'my_messages_status_idx', table: 'mastra_messages', columns: ['metadata->>\'status\''] },
|
|
60
|
+
* ],
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
indexes?: CreateIndexOptions[];
|
|
34
65
|
} & ({
|
|
35
66
|
host: string;
|
|
36
67
|
port: number;
|
|
@@ -44,8 +75,41 @@ export type PostgresConfig<SSLType = ISSLConfig | ConnectionOptions> = {
|
|
|
44
75
|
} | ClientConfig);
|
|
45
76
|
/**
|
|
46
77
|
* PostgreSQL configuration for PostgresStore (uses pg-promise with ISSLConfig)
|
|
78
|
+
*
|
|
79
|
+
* Accepts either:
|
|
80
|
+
* - A pre-configured pg-promise client: `{ id, client, schemaName? }`
|
|
81
|
+
* - Connection string: `{ id, connectionString, ... }`
|
|
82
|
+
* - Host/port config: `{ id, host, port, database, user, password, ... }`
|
|
83
|
+
* - Cloud SQL connector config: `{ id, stream, ... }`
|
|
47
84
|
*/
|
|
48
|
-
export type PostgresStoreConfig = PostgresConfig<ISSLConfig
|
|
85
|
+
export type PostgresStoreConfig = PostgresConfig<ISSLConfig> | {
|
|
86
|
+
id: string;
|
|
87
|
+
/**
|
|
88
|
+
* Pre-configured pg-promise database client.
|
|
89
|
+
* Use this when you need to configure the client before initialization,
|
|
90
|
+
* e.g., to add pool listeners or set connection-level settings.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* import pgPromise from 'pg-promise';
|
|
95
|
+
*
|
|
96
|
+
* const pgp = pgPromise();
|
|
97
|
+
* const client = pgp({ connectionString: '...' });
|
|
98
|
+
*
|
|
99
|
+
* // Custom setup before using
|
|
100
|
+
* client.$pool.on('connect', async (poolClient) => {
|
|
101
|
+
* await poolClient.query('SET ROLE my_role;');
|
|
102
|
+
* });
|
|
103
|
+
*
|
|
104
|
+
* const store = new PostgresStore({ id: 'my-store', client });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
client: pgPromise.IDatabase<{}>;
|
|
108
|
+
schemaName?: string;
|
|
109
|
+
disableInit?: boolean;
|
|
110
|
+
skipDefaultIndexes?: boolean;
|
|
111
|
+
indexes?: CreateIndexOptions[];
|
|
112
|
+
};
|
|
49
113
|
/**
|
|
50
114
|
* PostgreSQL configuration for PgVector (uses pg with ConnectionOptions)
|
|
51
115
|
*/
|
|
@@ -65,5 +129,16 @@ export declare const isHostConfig: <SSLType>(cfg: PostgresConfig<SSLType>) => cf
|
|
|
65
129
|
ssl?: boolean | SSLType;
|
|
66
130
|
};
|
|
67
131
|
export declare const isCloudSqlConfig: <SSLType>(cfg: PostgresConfig<SSLType>) => cfg is PostgresConfig<SSLType> & ClientConfig;
|
|
68
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Type guard for pre-configured client config (PostgresStore only)
|
|
134
|
+
*/
|
|
135
|
+
export declare const isClientConfig: (cfg: PostgresStoreConfig) => cfg is {
|
|
136
|
+
id: string;
|
|
137
|
+
client: pgPromise.IDatabase<{}>;
|
|
138
|
+
schemaName?: string;
|
|
139
|
+
disableInit?: boolean;
|
|
140
|
+
skipDefaultIndexes?: boolean;
|
|
141
|
+
indexes?: CreateIndexOptions[];
|
|
142
|
+
};
|
|
143
|
+
export declare const validateConfig: (name: string, config: PostgresStoreConfig) => void;
|
|
69
144
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/shared/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AACvC,OAAO,KAAK,KAAK,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE;;;GAGG;AACH,MAAM,MAAM,cAAc,CAAC,OAAO,GAAG,UAAU,GAAG,iBAAiB,IAAI;IACrE,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;;;;;;;;;;;;;OAkBG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/shared/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAA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;IAC7B,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAGhC,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,QAAQ,mBAAmB,SAuCvE,CAAC"}
|
|
@@ -1,16 +1,71 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MastraBase } from '@mastra/core/base';
|
|
2
2
|
import type { StorageColumn, TABLE_NAMES, CreateIndexOptions, IndexInfo, StorageIndexStats } from '@mastra/core/storage';
|
|
3
3
|
import type { IDatabase } from 'pg-promise';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import type { ISSLConfig } from 'pg-promise/typescript/pg-subset';
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for standalone domain usage.
|
|
7
|
+
* Accepts either:
|
|
8
|
+
* 1. An existing pg-promise database instance
|
|
9
|
+
* 2. Config to create a new client internally
|
|
10
|
+
*/
|
|
11
|
+
export type PgDomainConfig = PgDomainClientConfig | PgDomainRestConfig;
|
|
12
|
+
/**
|
|
13
|
+
* Pass an existing pg-promise database instance
|
|
14
|
+
*/
|
|
15
|
+
export interface PgDomainClientConfig {
|
|
16
|
+
/** The pg-promise database instance */
|
|
6
17
|
client: IDatabase<{}>;
|
|
18
|
+
/** Optional schema name (defaults to 'public') */
|
|
7
19
|
schemaName?: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
20
|
+
/** When true, default indexes will not be created during initialization */
|
|
21
|
+
skipDefaultIndexes?: boolean;
|
|
22
|
+
/** Custom indexes to create for this domain's tables */
|
|
23
|
+
indexes?: CreateIndexOptions[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Pass config to create a new pg-promise client internally
|
|
27
|
+
*/
|
|
28
|
+
export type PgDomainRestConfig = {
|
|
29
|
+
/** Optional schema name (defaults to 'public') */
|
|
30
|
+
schemaName?: string;
|
|
31
|
+
/** When true, default indexes will not be created during initialization */
|
|
32
|
+
skipDefaultIndexes?: boolean;
|
|
33
|
+
/** Custom indexes to create for this domain's tables */
|
|
34
|
+
indexes?: CreateIndexOptions[];
|
|
35
|
+
} & ({
|
|
36
|
+
host: string;
|
|
37
|
+
port: number;
|
|
38
|
+
database: string;
|
|
39
|
+
user: string;
|
|
40
|
+
password: string;
|
|
41
|
+
ssl?: boolean | ISSLConfig;
|
|
42
|
+
} | {
|
|
43
|
+
connectionString: string;
|
|
44
|
+
ssl?: boolean | ISSLConfig;
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Resolves PgDomainConfig to a pg-promise database instance and schema.
|
|
48
|
+
* Handles creating a new client if config is provided.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolvePgConfig(config: PgDomainConfig): {
|
|
51
|
+
client: IDatabase<{}>;
|
|
52
|
+
schemaName?: string;
|
|
53
|
+
skipDefaultIndexes?: boolean;
|
|
54
|
+
indexes?: CreateIndexOptions[];
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Internal config for PgDB - accepts already-resolved client
|
|
58
|
+
*/
|
|
59
|
+
export interface PgDBInternalConfig {
|
|
60
|
+
client: IDatabase<{}>;
|
|
61
|
+
schemaName?: string;
|
|
62
|
+
skipDefaultIndexes?: boolean;
|
|
63
|
+
}
|
|
64
|
+
export declare class PgDB extends MastraBase {
|
|
65
|
+
client: IDatabase<{}>;
|
|
66
|
+
schemaName?: string;
|
|
67
|
+
skipDefaultIndexes?: boolean;
|
|
68
|
+
constructor(config: PgDBInternalConfig);
|
|
14
69
|
hasColumn(table: string, column: string): Promise<boolean>;
|
|
15
70
|
/**
|
|
16
71
|
* Prepares values for insertion, handling JSONB columns by stringifying them
|
|
@@ -21,11 +76,12 @@ export declare class StoreOperationsPG extends StoreOperations {
|
|
|
21
76
|
*/
|
|
22
77
|
private addTimestampZColumns;
|
|
23
78
|
/**
|
|
24
|
-
* Prepares a value for database operations
|
|
25
|
-
* This is schema-aware and only stringifies objects for JSONB columns
|
|
79
|
+
* Prepares a value for database operations
|
|
26
80
|
*/
|
|
27
81
|
private prepareValue;
|
|
28
82
|
private setupSchema;
|
|
83
|
+
protected getSqlType(type: StorageColumn['type']): string;
|
|
84
|
+
protected getDefaultValue(type: StorageColumn['type']): string;
|
|
29
85
|
insert({ tableName, record }: {
|
|
30
86
|
tableName: TABLE_NAMES;
|
|
31
87
|
record: Record<string, any>;
|
|
@@ -33,15 +89,16 @@ export declare class StoreOperationsPG extends StoreOperations {
|
|
|
33
89
|
clearTable({ tableName }: {
|
|
34
90
|
tableName: TABLE_NAMES;
|
|
35
91
|
}): Promise<void>;
|
|
36
|
-
protected getDefaultValue(type: StorageColumn['type']): string;
|
|
37
92
|
createTable({ tableName, schema, }: {
|
|
38
93
|
tableName: TABLE_NAMES;
|
|
39
94
|
schema: Record<string, StorageColumn>;
|
|
40
95
|
}): Promise<void>;
|
|
96
|
+
private setupTimestampTriggers;
|
|
41
97
|
/**
|
|
42
|
-
*
|
|
98
|
+
* Migrates the spans table schema from OLD_SPAN_SCHEMA to current SPAN_SCHEMA.
|
|
99
|
+
* This adds new columns that don't exist in old schema.
|
|
43
100
|
*/
|
|
44
|
-
private
|
|
101
|
+
private migrateSpansTable;
|
|
45
102
|
/**
|
|
46
103
|
* Alters table schema to add columns if they don't exist
|
|
47
104
|
* @param tableName Name of the table
|
|
@@ -64,43 +121,15 @@ export declare class StoreOperationsPG extends StoreOperations {
|
|
|
64
121
|
dropTable({ tableName }: {
|
|
65
122
|
tableName: TABLE_NAMES;
|
|
66
123
|
}): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Create a new index on a table
|
|
69
|
-
*/
|
|
70
124
|
createIndex(options: CreateIndexOptions): Promise<void>;
|
|
71
|
-
/**
|
|
72
|
-
* Drop an existing index
|
|
73
|
-
*/
|
|
74
125
|
dropIndex(indexName: string): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* List indexes for a specific table or all tables
|
|
77
|
-
*/
|
|
78
126
|
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
127
|
describeIndex(indexName: string): Promise<StorageIndexStats>;
|
|
93
|
-
/**
|
|
94
|
-
* Update a single record in the database
|
|
95
|
-
*/
|
|
96
128
|
update({ tableName, keys, data, }: {
|
|
97
129
|
tableName: TABLE_NAMES;
|
|
98
130
|
keys: Record<string, any>;
|
|
99
131
|
data: Record<string, any>;
|
|
100
132
|
}): Promise<void>;
|
|
101
|
-
/**
|
|
102
|
-
* Update multiple records in a single batch transaction
|
|
103
|
-
*/
|
|
104
133
|
batchUpdate({ tableName, updates, }: {
|
|
105
134
|
tableName: TABLE_NAMES;
|
|
106
135
|
updates: Array<{
|
|
@@ -108,12 +137,15 @@ export declare class StoreOperationsPG extends StoreOperations {
|
|
|
108
137
|
data: Record<string, any>;
|
|
109
138
|
}>;
|
|
110
139
|
}): Promise<void>;
|
|
111
|
-
/**
|
|
112
|
-
* Delete multiple records by keys
|
|
113
|
-
*/
|
|
114
140
|
batchDelete({ tableName, keys }: {
|
|
115
141
|
tableName: TABLE_NAMES;
|
|
116
142
|
keys: Record<string, any>[];
|
|
117
143
|
}): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Delete all data from a table (alias for clearTable for consistency with other stores)
|
|
146
|
+
*/
|
|
147
|
+
deleteData({ tableName }: {
|
|
148
|
+
tableName: TABLE_NAMES;
|
|
149
|
+
}): Promise<void>;
|
|
118
150
|
}
|
|
119
151
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storage/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAU/C,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG,kBAAkB,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,uCAAuC;IACvC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;IACtB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,wDAAwD;IACxD,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,wDAAwD;IACxD,OAAO,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAChC,GAAG,CACA;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;CAC5B,GACD;IACE,gBAAgB,EAAE,MAAM,CAAC;IACzB,GAA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AS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAiFrD,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAoE5D,MAAM,CAAC,EACX,SAAS,EACT,IAAI,EACJ,IAAI,GACL,EAAE;QACD,SAAS,EAAE,WAAW,CAAC;QACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC3B,GAAG,OAAO,CAAC,IAAI,CAAC;IA6CX,WAAW,CAAC,EAChB,SAAS,EACT,OAAO,GACR,EAAE;QACD,SAAS,EAAE,WAAW,CAAC;QACvB,OAAO,EAAE,KAAK,CAAC;YACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;SAC3B,CAAC,CAAC;KACJ,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBX,WAAW,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA2C9G;;OAEG;IACG,UAAU,CAAC,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3E"}
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import { AgentsStorage } from '@mastra/core/storage';
|
|
2
|
-
import type { StorageAgentType, StorageCreateAgentInput, StorageUpdateAgentInput, StorageListAgentsInput, StorageListAgentsOutput } from '@mastra/core/storage';
|
|
3
|
-
import type {
|
|
2
|
+
import type { StorageAgentType, StorageCreateAgentInput, StorageUpdateAgentInput, StorageListAgentsInput, StorageListAgentsOutput, CreateIndexOptions } from '@mastra/core/storage';
|
|
3
|
+
import type { PgDomainConfig } from '../../db/index.js';
|
|
4
4
|
export declare class AgentsPG extends AgentsStorage {
|
|
5
|
-
private
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
#private;
|
|
6
|
+
/** Tables managed by this domain */
|
|
7
|
+
static readonly MANAGED_TABLES: readonly ["mastra_agents"];
|
|
8
|
+
constructor(config: PgDomainConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Returns default index definitions for the agents domain tables.
|
|
11
|
+
* Currently no default indexes are defined for agents.
|
|
12
|
+
*/
|
|
13
|
+
getDefaultIndexDefinitions(): CreateIndexOptions[];
|
|
14
|
+
/**
|
|
15
|
+
* Creates default indexes for optimal query performance.
|
|
16
|
+
* Currently no default indexes are defined for agents.
|
|
17
|
+
*/
|
|
18
|
+
createDefaultIndexes(): Promise<void>;
|
|
19
|
+
init(): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Creates custom user-defined indexes for this domain's tables.
|
|
22
|
+
*/
|
|
23
|
+
createCustomIndexes(): Promise<void>;
|
|
24
|
+
dangerouslyClearAll(): Promise<void>;
|
|
11
25
|
private parseJson;
|
|
12
26
|
private parseRow;
|
|
13
27
|
getAgentById({ id }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/agents/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/agents/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAMd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,qBAAa,QAAS,SAAQ,aAAa;;IAMzC,oCAAoC;IACpC,MAAM,CAAC,QAAQ,CAAC,cAAc,6BAA2B;gBAE7C,MAAM,EAAE,cAAc;IAUlC;;;OAGG;IACH,0BAA0B,IAAI,kBAAkB,EAAE;IAIlD;;;OAGG;IACG,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAOrC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAM3B;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAepC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI1C,OAAO,CAAC,SAAS;IA2BjB,OAAO,CAAC,QAAQ;IAqBV,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAwBtE,WAAW,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,uBAAuB,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAoDrF,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAsInF,WAAW,CAAC,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBlD,UAAU,CAAC,IAAI,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,CAAC;CA+DlF"}
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
import type { MastraMessageContentV2 } from '@mastra/core/agent';
|
|
2
2
|
import type { MastraDBMessage, StorageThreadType } from '@mastra/core/memory';
|
|
3
3
|
import { MemoryStorage } from '@mastra/core/storage';
|
|
4
|
-
import type { StorageResourceType, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsByResourceIdInput, StorageListThreadsByResourceIdOutput } from '@mastra/core/storage';
|
|
5
|
-
import type {
|
|
6
|
-
import type { StoreOperationsPG } from '../operations/index.js';
|
|
4
|
+
import type { StorageResourceType, StorageListMessagesInput, StorageListMessagesOutput, StorageListThreadsByResourceIdInput, StorageListThreadsByResourceIdOutput, CreateIndexOptions } from '@mastra/core/storage';
|
|
5
|
+
import type { PgDomainConfig } from '../../db/index.js';
|
|
7
6
|
export declare class MemoryPG extends MemoryStorage {
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
constructor(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
#private;
|
|
8
|
+
/** Tables managed by this domain */
|
|
9
|
+
static readonly MANAGED_TABLES: readonly ["mastra_threads", "mastra_messages", "mastra_resources"];
|
|
10
|
+
constructor(config: PgDomainConfig);
|
|
11
|
+
init(): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Returns default index definitions for the memory domain tables.
|
|
14
|
+
*/
|
|
15
|
+
getDefaultIndexDefinitions(): CreateIndexOptions[];
|
|
16
|
+
/**
|
|
17
|
+
* Creates default indexes for optimal query performance.
|
|
18
|
+
*/
|
|
19
|
+
createDefaultIndexes(): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Creates custom user-defined indexes for this domain's tables.
|
|
22
|
+
*/
|
|
23
|
+
createCustomIndexes(): Promise<void>;
|
|
24
|
+
dangerouslyClearAll(): Promise<void>;
|
|
16
25
|
/**
|
|
17
26
|
* Normalizes message row from database by applying createdAtZ fallback
|
|
18
27
|
*/
|
|
@@ -32,6 +41,16 @@ export declare class MemoryPG extends MemoryStorage {
|
|
|
32
41
|
deleteThread({ threadId }: {
|
|
33
42
|
threadId: string;
|
|
34
43
|
}): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Fetches messages around target messages using cursor-based pagination.
|
|
46
|
+
*
|
|
47
|
+
* This replaces the previous ROW_NUMBER() approach which caused severe performance
|
|
48
|
+
* issues on large tables (see GitHub issue #11150). The old approach required
|
|
49
|
+
* scanning and sorting ALL messages in a thread to assign row numbers.
|
|
50
|
+
*
|
|
51
|
+
* The new approach uses the existing (thread_id, createdAt) index to efficiently
|
|
52
|
+
* fetch only the messages needed by using createdAt as a cursor.
|
|
53
|
+
*/
|
|
35
54
|
private _getIncludedMessages;
|
|
36
55
|
private parseRow;
|
|
37
56
|
listMessagesById({ messageIds }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/memory/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAmB,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EACL,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/memory/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,KAAK,EAAmB,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EACL,aAAa,EAQd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,mCAAmC,EACnC,oCAAoC,EACpC,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAuB/C,qBAAa,QAAS,SAAQ,aAAa;;IAMzC,oCAAoC;IACpC,MAAM,CAAC,QAAQ,CAAC,cAAc,qEAA6D;gBAE/E,MAAM,EAAE,cAAc;IAU5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAa3B;;OAEG;IACH,0BAA0B,IAAI,kBAAkB,EA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KAAE,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,eAAe,EAAE,CAAA;KAAE,CAAC;IAwGrG,cAAc,CAAC,EACnB,QAAQ,GACT,EAAE;QACD,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,GAAG;YACvD,EAAE,EAAE,MAAM,CAAC;YACX,OAAO,CAAC,EAAE;gBACR,QAAQ,CAAC,EAAE,sBAAsB,CAAC,UAAU,CAAC,CAAC;gBAC9C,OAAO,CAAC,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;aAC7C,CAAC;SACH,CAAC,EAAE,CAAC;KACN,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAkHxB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAwCnD,eAAe,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAoB5F,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,mBAAmB,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAY3F,cAAc,CAAC,EACnB,UAAU,EACV,aAAa,EACb,QAAQ,GACT,EAAE;QACD,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAuDjC"}
|
|
@@ -1,44 +1,37 @@
|
|
|
1
|
-
import type { TracingStorageStrategy } from '@mastra/core/observability';
|
|
2
1
|
import { ObservabilityStorage } from '@mastra/core/storage';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { StoreOperationsPG } from '../operations/index.js';
|
|
2
|
+
import type { TracingStorageStrategy, ListTracesArgs, UpdateSpanArgs, BatchDeleteTracesArgs, BatchUpdateSpansArgs, BatchCreateSpansArgs, CreateSpanArgs, GetSpanArgs, GetSpanResponse, GetRootSpanArgs, GetRootSpanResponse, GetTraceArgs, GetTraceResponse, ListTracesResponse, CreateIndexOptions } from '@mastra/core/storage';
|
|
3
|
+
import type { PgDomainConfig } from '../../db/index.js';
|
|
6
4
|
export declare class ObservabilityPG extends ObservabilityStorage {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
constructor(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
#private;
|
|
6
|
+
/** Tables managed by this domain */
|
|
7
|
+
static readonly MANAGED_TABLES: readonly ["mastra_ai_spans"];
|
|
8
|
+
constructor(config: PgDomainConfig);
|
|
9
|
+
init(): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Returns default index definitions for the observability domain tables.
|
|
12
|
+
*/
|
|
13
|
+
getDefaultIndexDefinitions(): CreateIndexOptions[];
|
|
14
|
+
/**
|
|
15
|
+
* Creates default indexes for optimal query performance.
|
|
16
|
+
*/
|
|
17
|
+
createDefaultIndexes(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Creates custom user-defined indexes for this domain's tables.
|
|
20
|
+
*/
|
|
21
|
+
createCustomIndexes(): Promise<void>;
|
|
22
|
+
dangerouslyClearAll(): Promise<void>;
|
|
15
23
|
get tracingStrategy(): {
|
|
16
24
|
preferred: TracingStorageStrategy;
|
|
17
25
|
supported: TracingStorageStrategy[];
|
|
18
26
|
};
|
|
19
|
-
createSpan(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
spans: SpanRecord[];
|
|
29
|
-
}>;
|
|
30
|
-
batchCreateSpans(args: {
|
|
31
|
-
records: CreateSpanRecord[];
|
|
32
|
-
}): Promise<void>;
|
|
33
|
-
batchUpdateSpans(args: {
|
|
34
|
-
records: {
|
|
35
|
-
traceId: string;
|
|
36
|
-
spanId: string;
|
|
37
|
-
updates: Partial<UpdateSpanRecord>;
|
|
38
|
-
}[];
|
|
39
|
-
}): Promise<void>;
|
|
40
|
-
batchDeleteTraces(args: {
|
|
41
|
-
traceIds: string[];
|
|
42
|
-
}): Promise<void>;
|
|
27
|
+
createSpan(args: CreateSpanArgs): Promise<void>;
|
|
28
|
+
getSpan(args: GetSpanArgs): Promise<GetSpanResponse | null>;
|
|
29
|
+
getRootSpan(args: GetRootSpanArgs): Promise<GetRootSpanResponse | null>;
|
|
30
|
+
getTrace(args: GetTraceArgs): Promise<GetTraceResponse | null>;
|
|
31
|
+
updateSpan(args: UpdateSpanArgs): Promise<void>;
|
|
32
|
+
listTraces(args: ListTracesArgs): Promise<ListTracesResponse>;
|
|
33
|
+
batchCreateSpans(args: BatchCreateSpansArgs): Promise<void>;
|
|
34
|
+
batchUpdateSpans(args: BatchUpdateSpansArgs): Promise<void>;
|
|
35
|
+
batchDeleteTraces(args: BatchDeleteTracesArgs): Promise<void>;
|
|
43
36
|
}
|
|
44
37
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/observability/index.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/observability/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,oBAAoB,EAIrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAEV,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AA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 -1,17 +1,26 @@
|
|
|
1
|
-
import type { SaveScorePayload, ScoreRowData, ScoringSource } from '@mastra/core/evals';
|
|
2
|
-
import type {
|
|
1
|
+
import type { ListScoresResponse, SaveScorePayload, ScoreRowData, ScoringSource } from '@mastra/core/evals';
|
|
2
|
+
import type { StoragePagination, CreateIndexOptions } from '@mastra/core/storage';
|
|
3
3
|
import { ScoresStorage } from '@mastra/core/storage';
|
|
4
|
-
import type {
|
|
5
|
-
import type { StoreOperationsPG } from '../operations/index.js';
|
|
4
|
+
import type { PgDomainConfig } from '../../db/index.js';
|
|
6
5
|
export declare class ScoresPG extends ScoresStorage {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
constructor(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
#private;
|
|
7
|
+
/** Tables managed by this domain */
|
|
8
|
+
static readonly MANAGED_TABLES: readonly ["mastra_scorers"];
|
|
9
|
+
constructor(config: PgDomainConfig);
|
|
10
|
+
init(): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Returns default index definitions for the scores domain tables.
|
|
13
|
+
*/
|
|
14
|
+
getDefaultIndexDefinitions(): CreateIndexOptions[];
|
|
15
|
+
/**
|
|
16
|
+
* Creates default indexes for optimal query performance.
|
|
17
|
+
*/
|
|
18
|
+
createDefaultIndexes(): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Creates custom user-defined indexes for this domain's tables.
|
|
21
|
+
*/
|
|
22
|
+
createCustomIndexes(): Promise<void>;
|
|
23
|
+
dangerouslyClearAll(): Promise<void>;
|
|
15
24
|
getScoreById({ id }: {
|
|
16
25
|
id: string;
|
|
17
26
|
}): Promise<ScoreRowData | null>;
|
|
@@ -21,35 +30,23 @@ export declare class ScoresPG extends ScoresStorage {
|
|
|
21
30
|
entityId?: string;
|
|
22
31
|
entityType?: string;
|
|
23
32
|
source?: ScoringSource;
|
|
24
|
-
}): Promise<
|
|
25
|
-
pagination: PaginationInfo;
|
|
26
|
-
scores: ScoreRowData[];
|
|
27
|
-
}>;
|
|
33
|
+
}): Promise<ListScoresResponse>;
|
|
28
34
|
saveScore(score: SaveScorePayload): Promise<{
|
|
29
35
|
score: ScoreRowData;
|
|
30
36
|
}>;
|
|
31
37
|
listScoresByRunId({ runId, pagination, }: {
|
|
32
38
|
runId: string;
|
|
33
39
|
pagination: StoragePagination;
|
|
34
|
-
}): Promise<
|
|
35
|
-
pagination: PaginationInfo;
|
|
36
|
-
scores: ScoreRowData[];
|
|
37
|
-
}>;
|
|
40
|
+
}): Promise<ListScoresResponse>;
|
|
38
41
|
listScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
39
42
|
pagination: StoragePagination;
|
|
40
43
|
entityId: string;
|
|
41
44
|
entityType: string;
|
|
42
|
-
}): Promise<
|
|
43
|
-
pagination: PaginationInfo;
|
|
44
|
-
scores: ScoreRowData[];
|
|
45
|
-
}>;
|
|
45
|
+
}): Promise<ListScoresResponse>;
|
|
46
46
|
listScoresBySpan({ traceId, spanId, pagination, }: {
|
|
47
47
|
traceId: string;
|
|
48
48
|
spanId: string;
|
|
49
49
|
pagination: StoragePagination;
|
|
50
|
-
}): Promise<
|
|
51
|
-
pagination: PaginationInfo;
|
|
52
|
-
scores: ScoreRowData[];
|
|
53
|
-
}>;
|
|
50
|
+
}): Promise<ListScoresResponse>;
|
|
54
51
|
}
|
|
55
52
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/scores/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,o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AC,kBAAkB,CAAC;IAkDzB,oBAAoB,CAAC,EACzB,QAAQ,EACR,UAAU,EACV,UAAU,GACX,EAAE;QACD,UAAU,EAAE,iBAAiB,CAAC;QAC9B,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAkDzB,gBAAgB,CAAC,EACrB,OAAO,EACP,MAAM,EACN,UAAU,GACX,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,iBAAiB,CAAC;KAC/B,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA0ChC"}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StorageColumn, TABLE_NAMES } from '@mastra/core/storage';
|
|
2
2
|
export declare function getSchemaName(schema?: string): string | undefined;
|
|
3
3
|
export declare function getTableName({ indexName, schemaName }: {
|
|
4
4
|
indexName: string;
|
|
5
5
|
schemaName?: string;
|
|
6
6
|
}): string;
|
|
7
|
-
/**
|
|
8
|
-
* Build date range filter for queries
|
|
9
|
-
*/
|
|
10
|
-
export declare function buildDateRangeFilter(dateRange: PaginationArgs['dateRange'], fieldName: string): Record<string, any>;
|
|
11
7
|
/**
|
|
12
8
|
* Prepare WHERE clause for PostgreSQL queries
|
|
13
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/storage/domains/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/storage/domains/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIvE,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,sBAE5C;AAED,wBAAgB,YAAY,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,UAKjG;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GACtC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,EAAE,CAAA;CAAE,CA6B9B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,EACrC,SAAS,EACT,MAAM,GACP,EAAE;IACD,SAAS,EAAE,WAAW,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B,GAAG,CAAC,CA+BJ"}
|