@mastra/pg 1.0.0-beta.0 → 1.0.0-beta.10
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 +495 -0
- package/README.md +3 -0
- package/dist/index.cjs +2976 -2039
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2960 -2028
- package/dist/index.js.map +1 -1
- package/dist/shared/config.d.ts +98 -3
- 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 +39 -0
- package/dist/storage/domains/agents/index.d.ts.map +1 -0
- 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 +26 -29
- 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 +31 -20
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +30 -195
- 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 +42 -6
- 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 +8 -7
- package/dist/storage/domains/operations/index.d.ts.map +0 -1
|
@@ -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"}
|
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
import { WorkflowsStorage } from '@mastra/core/storage';
|
|
2
|
-
import type { StorageListWorkflowRunsInput, WorkflowRun, WorkflowRuns } from '@mastra/core/storage';
|
|
2
|
+
import type { UpdateWorkflowStateOptions, StorageListWorkflowRunsInput, WorkflowRun, WorkflowRuns, CreateIndexOptions } from '@mastra/core/storage';
|
|
3
3
|
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
4
|
-
import type {
|
|
5
|
-
import type { StoreOperationsPG } from '../operations/index.js';
|
|
4
|
+
import type { PgDomainConfig } from '../../db/index.js';
|
|
6
5
|
export declare class WorkflowsPG extends WorkflowsStorage {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
constructor(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
#private;
|
|
7
|
+
/** Tables managed by this domain */
|
|
8
|
+
static readonly MANAGED_TABLES: readonly ["mastra_workflow_snapshot"];
|
|
9
|
+
constructor(config: PgDomainConfig);
|
|
10
|
+
/**
|
|
11
|
+
* Returns default index definitions for the workflows domain tables.
|
|
12
|
+
* Currently no default indexes are defined for workflows.
|
|
13
|
+
*/
|
|
14
|
+
getDefaultIndexDefinitions(): CreateIndexOptions[];
|
|
15
|
+
/**
|
|
16
|
+
* Creates default indexes for optimal query performance.
|
|
17
|
+
* Currently no default indexes are defined for workflows.
|
|
18
|
+
*/
|
|
19
|
+
createDefaultIndexes(): Promise<void>;
|
|
20
|
+
init(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Creates custom user-defined indexes for this domain's tables.
|
|
23
|
+
*/
|
|
24
|
+
createCustomIndexes(): Promise<void>;
|
|
25
|
+
dangerouslyClearAll(): Promise<void>;
|
|
15
26
|
updateWorkflowResults({}: {
|
|
16
27
|
workflowName: string;
|
|
17
28
|
runId: string;
|
|
@@ -22,19 +33,15 @@ export declare class WorkflowsPG extends WorkflowsStorage {
|
|
|
22
33
|
updateWorkflowState({}: {
|
|
23
34
|
workflowName: string;
|
|
24
35
|
runId: string;
|
|
25
|
-
opts:
|
|
26
|
-
status: string;
|
|
27
|
-
result?: StepResult<any, any, any, any>;
|
|
28
|
-
error?: string;
|
|
29
|
-
suspendedPaths?: Record<string, number[]>;
|
|
30
|
-
waitingPaths?: Record<string, number[]>;
|
|
31
|
-
};
|
|
36
|
+
opts: UpdateWorkflowStateOptions;
|
|
32
37
|
}): Promise<WorkflowRunState | undefined>;
|
|
33
|
-
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
|
|
38
|
+
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, createdAt, updatedAt, }: {
|
|
34
39
|
workflowName: string;
|
|
35
40
|
runId: string;
|
|
36
41
|
resourceId?: string;
|
|
37
42
|
snapshot: WorkflowRunState;
|
|
43
|
+
createdAt?: Date;
|
|
44
|
+
updatedAt?: Date;
|
|
38
45
|
}): Promise<void>;
|
|
39
46
|
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
40
47
|
workflowName: string;
|
|
@@ -44,6 +51,10 @@ export declare class WorkflowsPG extends WorkflowsStorage {
|
|
|
44
51
|
runId: string;
|
|
45
52
|
workflowName?: string;
|
|
46
53
|
}): Promise<WorkflowRun | null>;
|
|
47
|
-
|
|
54
|
+
deleteWorkflowRunById({ runId, workflowName }: {
|
|
55
|
+
runId: string;
|
|
56
|
+
workflowName: string;
|
|
57
|
+
}): Promise<void>;
|
|
58
|
+
listWorkflowRuns({ workflowName, fromDate, toDate, perPage, page, resourceId, status, }?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
|
|
48
59
|
}
|
|
49
60
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/workflows/index.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,gBAAgB,EAEjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,0BAA0B,EAC1B,4BAA4B,EAC5B,WAAW,EACX,YAAY,EACZ,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AA8B/C,qBAAa,WAAY,SAAQ,gBAAgB;;IAM/C,oCAAoC;IACpC,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AAC,EACzB,YAAY,EACZ,KAAK,GACN,EAAE;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAoB9B,kBAAkB,CAAC,EACvB,KAAK,EACL,YAAY,GACb,EAAE;QACD,KAAK,EAAE,MAAM,CAAC;QACd,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAmDzB,qBAAqB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBtG,gBAAgB,CAAC,EACrB,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,OAAO,EACP,IAAI,EACJ,UAAU,EACV,MAAM,GACP,GAAE,4BAAiC,GAAG,OAAO,CAAC,YAAY,CAAC;CAqF7D"}
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,211 +1,46 @@
|
|
|
1
|
-
import type { MastraMessageContentV2, MastraDBMessage } from '@mastra/core/agent';
|
|
2
|
-
import type { ScoreRowData, ScoringSource } from '@mastra/core/evals';
|
|
3
|
-
import type { StorageThreadType } from '@mastra/core/memory';
|
|
4
1
|
import { MastraStorage } from '@mastra/core/storage';
|
|
5
|
-
import type {
|
|
6
|
-
import type { StepResult, WorkflowRunState } from '@mastra/core/workflows';
|
|
2
|
+
import type { StorageDomains } from '@mastra/core/storage';
|
|
7
3
|
import pgPromise from 'pg-promise';
|
|
8
4
|
import type { PostgresStoreConfig } from '../shared/config.js';
|
|
9
|
-
|
|
5
|
+
import { AgentsPG } from './domains/agents/index.js';
|
|
6
|
+
import { MemoryPG } from './domains/memory/index.js';
|
|
7
|
+
import { ObservabilityPG } from './domains/observability/index.js';
|
|
8
|
+
import { ScoresPG } from './domains/scores/index.js';
|
|
9
|
+
import { WorkflowsPG } from './domains/workflows/index.js';
|
|
10
|
+
export { AgentsPG, MemoryPG, ObservabilityPG, ScoresPG, WorkflowsPG };
|
|
11
|
+
export type { PgDomainConfig } from './db/index.js';
|
|
12
|
+
/**
|
|
13
|
+
* PostgreSQL storage adapter for Mastra.
|
|
14
|
+
*
|
|
15
|
+
* Access domain-specific storage via `getStore()`:
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const storage = new PostgresStore({ connectionString: '...' });
|
|
20
|
+
*
|
|
21
|
+
* // Access memory domain
|
|
22
|
+
* const memory = await storage.getStore('memory');
|
|
23
|
+
* await memory?.saveThread({ thread });
|
|
24
|
+
*
|
|
25
|
+
* // Access workflows domain
|
|
26
|
+
* const workflows = await storage.getStore('workflows');
|
|
27
|
+
* await workflows?.persistWorkflowSnapshot({ workflowName, runId, snapshot });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
10
30
|
export declare class PostgresStore extends MastraStorage {
|
|
11
31
|
#private;
|
|
12
32
|
private schema;
|
|
13
|
-
private
|
|
33
|
+
private isInitialized;
|
|
14
34
|
stores: StorageDomains;
|
|
15
35
|
constructor(config: PostgresStoreConfig);
|
|
16
36
|
init(): Promise<void>;
|
|
17
37
|
get db(): pgPromise.IDatabase<{}, import("pg-promise/typescript/pg-subset").IClient>;
|
|
18
38
|
get pgp(): pgPromise.IMain<{}, import("pg-promise/typescript/pg-subset").IClient>;
|
|
19
|
-
get supports(): {
|
|
20
|
-
selectByIncludeResourceScope: boolean;
|
|
21
|
-
resourceWorkingMemory: boolean;
|
|
22
|
-
hasColumn: boolean;
|
|
23
|
-
createTable: boolean;
|
|
24
|
-
deleteMessages: boolean;
|
|
25
|
-
observabilityInstance: boolean;
|
|
26
|
-
indexManagement: boolean;
|
|
27
|
-
listScoresBySpan: boolean;
|
|
28
|
-
};
|
|
29
|
-
createTable({ tableName, schema, }: {
|
|
30
|
-
tableName: TABLE_NAMES;
|
|
31
|
-
schema: Record<string, StorageColumn>;
|
|
32
|
-
}): Promise<void>;
|
|
33
|
-
alterTable({ tableName, schema, ifNotExists, }: {
|
|
34
|
-
tableName: TABLE_NAMES;
|
|
35
|
-
schema: Record<string, StorageColumn>;
|
|
36
|
-
ifNotExists: string[];
|
|
37
|
-
}): Promise<void>;
|
|
38
|
-
clearTable({ tableName }: {
|
|
39
|
-
tableName: TABLE_NAMES;
|
|
40
|
-
}): Promise<void>;
|
|
41
|
-
dropTable({ tableName }: {
|
|
42
|
-
tableName: TABLE_NAMES;
|
|
43
|
-
}): Promise<void>;
|
|
44
|
-
insert({ tableName, record }: {
|
|
45
|
-
tableName: TABLE_NAMES;
|
|
46
|
-
record: Record<string, any>;
|
|
47
|
-
}): Promise<void>;
|
|
48
|
-
batchInsert({ tableName, records }: {
|
|
49
|
-
tableName: TABLE_NAMES;
|
|
50
|
-
records: Record<string, any>[];
|
|
51
|
-
}): Promise<void>;
|
|
52
|
-
load<R>({ tableName, keys }: {
|
|
53
|
-
tableName: TABLE_NAMES;
|
|
54
|
-
keys: Record<string, string>;
|
|
55
|
-
}): Promise<R | null>;
|
|
56
39
|
/**
|
|
57
|
-
*
|
|
40
|
+
* Closes the pg-promise connection pool.
|
|
41
|
+
*
|
|
42
|
+
* This will close ALL connections in the pool, including pre-configured clients.
|
|
58
43
|
*/
|
|
59
|
-
getThreadById({ threadId }: {
|
|
60
|
-
threadId: string;
|
|
61
|
-
}): Promise<StorageThreadType | null>;
|
|
62
|
-
saveThread({ thread }: {
|
|
63
|
-
thread: StorageThreadType;
|
|
64
|
-
}): Promise<StorageThreadType>;
|
|
65
|
-
updateThread({ id, title, metadata, }: {
|
|
66
|
-
id: string;
|
|
67
|
-
title: string;
|
|
68
|
-
metadata: Record<string, unknown>;
|
|
69
|
-
}): Promise<StorageThreadType>;
|
|
70
|
-
deleteThread({ threadId }: {
|
|
71
|
-
threadId: string;
|
|
72
|
-
}): Promise<void>;
|
|
73
|
-
listMessagesById({ messageIds }: {
|
|
74
|
-
messageIds: string[];
|
|
75
|
-
}): Promise<{
|
|
76
|
-
messages: MastraDBMessage[];
|
|
77
|
-
}>;
|
|
78
|
-
saveMessages(args: {
|
|
79
|
-
messages: MastraDBMessage[];
|
|
80
|
-
}): Promise<{
|
|
81
|
-
messages: MastraDBMessage[];
|
|
82
|
-
}>;
|
|
83
|
-
updateMessages({ messages, }: {
|
|
84
|
-
messages: (Partial<Omit<MastraDBMessage, 'createdAt'>> & {
|
|
85
|
-
id: string;
|
|
86
|
-
content?: {
|
|
87
|
-
metadata?: MastraMessageContentV2['metadata'];
|
|
88
|
-
content?: MastraMessageContentV2['content'];
|
|
89
|
-
};
|
|
90
|
-
})[];
|
|
91
|
-
}): Promise<MastraDBMessage[]>;
|
|
92
|
-
deleteMessages(messageIds: string[]): Promise<void>;
|
|
93
|
-
getResourceById({ resourceId }: {
|
|
94
|
-
resourceId: string;
|
|
95
|
-
}): Promise<StorageResourceType | null>;
|
|
96
|
-
saveResource({ resource }: {
|
|
97
|
-
resource: StorageResourceType;
|
|
98
|
-
}): Promise<StorageResourceType>;
|
|
99
|
-
updateResource({ resourceId, workingMemory, metadata, }: {
|
|
100
|
-
resourceId: string;
|
|
101
|
-
workingMemory?: string;
|
|
102
|
-
metadata?: Record<string, unknown>;
|
|
103
|
-
}): Promise<StorageResourceType>;
|
|
104
|
-
/**
|
|
105
|
-
* Workflows
|
|
106
|
-
*/
|
|
107
|
-
updateWorkflowResults({ workflowName, runId, stepId, result, requestContext, }: {
|
|
108
|
-
workflowName: string;
|
|
109
|
-
runId: string;
|
|
110
|
-
stepId: string;
|
|
111
|
-
result: StepResult<any, any, any, any>;
|
|
112
|
-
requestContext: Record<string, any>;
|
|
113
|
-
}): Promise<Record<string, StepResult<any, any, any, any>>>;
|
|
114
|
-
updateWorkflowState({ workflowName, runId, opts, }: {
|
|
115
|
-
workflowName: string;
|
|
116
|
-
runId: string;
|
|
117
|
-
opts: {
|
|
118
|
-
status: string;
|
|
119
|
-
result?: StepResult<any, any, any, any>;
|
|
120
|
-
error?: string;
|
|
121
|
-
suspendedPaths?: Record<string, number[]>;
|
|
122
|
-
waitingPaths?: Record<string, number[]>;
|
|
123
|
-
};
|
|
124
|
-
}): Promise<WorkflowRunState | undefined>;
|
|
125
|
-
persistWorkflowSnapshot({ workflowName, runId, resourceId, snapshot, }: {
|
|
126
|
-
workflowName: string;
|
|
127
|
-
runId: string;
|
|
128
|
-
resourceId?: string;
|
|
129
|
-
snapshot: WorkflowRunState;
|
|
130
|
-
}): Promise<void>;
|
|
131
|
-
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
132
|
-
workflowName: string;
|
|
133
|
-
runId: string;
|
|
134
|
-
}): Promise<WorkflowRunState | null>;
|
|
135
|
-
listWorkflowRuns({ workflowName, fromDate, toDate, perPage, page, resourceId, }?: StorageListWorkflowRunsInput): Promise<WorkflowRuns>;
|
|
136
|
-
getWorkflowRunById({ runId, workflowName, }: {
|
|
137
|
-
runId: string;
|
|
138
|
-
workflowName?: string;
|
|
139
|
-
}): Promise<WorkflowRun | null>;
|
|
140
44
|
close(): Promise<void>;
|
|
141
|
-
/**
|
|
142
|
-
* Tracing / Observability
|
|
143
|
-
*/
|
|
144
|
-
createSpan(span: SpanRecord): Promise<void>;
|
|
145
|
-
updateSpan({ spanId, traceId, updates, }: {
|
|
146
|
-
spanId: string;
|
|
147
|
-
traceId: string;
|
|
148
|
-
updates: Partial<Omit<SpanRecord, 'spanId' | 'traceId'>>;
|
|
149
|
-
}): Promise<void>;
|
|
150
|
-
getTrace(traceId: string): Promise<TraceRecord | null>;
|
|
151
|
-
getTracesPaginated(args: TracesPaginatedArg): Promise<{
|
|
152
|
-
pagination: PaginationInfo;
|
|
153
|
-
spans: SpanRecord[];
|
|
154
|
-
}>;
|
|
155
|
-
batchCreateSpans(args: {
|
|
156
|
-
records: SpanRecord[];
|
|
157
|
-
}): Promise<void>;
|
|
158
|
-
batchUpdateSpans(args: {
|
|
159
|
-
records: {
|
|
160
|
-
traceId: string;
|
|
161
|
-
spanId: string;
|
|
162
|
-
updates: Partial<Omit<SpanRecord, 'spanId' | 'traceId'>>;
|
|
163
|
-
}[];
|
|
164
|
-
}): Promise<void>;
|
|
165
|
-
batchDeleteTraces(args: {
|
|
166
|
-
traceIds: string[];
|
|
167
|
-
}): Promise<void>;
|
|
168
|
-
/**
|
|
169
|
-
* Scorers
|
|
170
|
-
*/
|
|
171
|
-
getScoreById({ id }: {
|
|
172
|
-
id: string;
|
|
173
|
-
}): Promise<ScoreRowData | null>;
|
|
174
|
-
listScoresByScorerId({ scorerId, pagination, entityId, entityType, source, }: {
|
|
175
|
-
scorerId: string;
|
|
176
|
-
pagination: StoragePagination;
|
|
177
|
-
entityId?: string;
|
|
178
|
-
entityType?: string;
|
|
179
|
-
source?: ScoringSource;
|
|
180
|
-
}): Promise<{
|
|
181
|
-
pagination: PaginationInfo;
|
|
182
|
-
scores: ScoreRowData[];
|
|
183
|
-
}>;
|
|
184
|
-
saveScore(score: ScoreRowData): Promise<{
|
|
185
|
-
score: ScoreRowData;
|
|
186
|
-
}>;
|
|
187
|
-
listScoresByRunId({ runId, pagination, }: {
|
|
188
|
-
runId: string;
|
|
189
|
-
pagination: StoragePagination;
|
|
190
|
-
}): Promise<{
|
|
191
|
-
pagination: PaginationInfo;
|
|
192
|
-
scores: ScoreRowData[];
|
|
193
|
-
}>;
|
|
194
|
-
listScoresByEntityId({ entityId, entityType, pagination, }: {
|
|
195
|
-
pagination: StoragePagination;
|
|
196
|
-
entityId: string;
|
|
197
|
-
entityType: string;
|
|
198
|
-
}): Promise<{
|
|
199
|
-
pagination: PaginationInfo;
|
|
200
|
-
scores: ScoreRowData[];
|
|
201
|
-
}>;
|
|
202
|
-
listScoresBySpan({ traceId, spanId, pagination, }: {
|
|
203
|
-
traceId: string;
|
|
204
|
-
spanId: string;
|
|
205
|
-
pagination: StoragePagination;
|
|
206
|
-
}): Promise<{
|
|
207
|
-
pagination: PaginationInfo;
|
|
208
|
-
scores: ScoreRowData[];
|
|
209
|
-
}>;
|
|
210
45
|
}
|
|
211
46
|
//# 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,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,SAAS,MAAM,YAAY,CAAC;AAQnC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AACtE,YAAY,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE3C;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,aAAc,SAAQ,aAAa;;IAG9C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAkB;IAEvC,MAAM,EAAE,cAAc,CAAC;gBAEX,MAAM,EAAE,mBAAmB;IAyFjC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAuB3B,IAAW,EAAE,+EAEZ;IAED,IAAW,GAAG,2EAEb;IAED;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
|
|
@@ -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,UAAU,qBAAqB;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,iBAAiB,CAAC;IAClC,WAAW,EAAE,iBAAiB,CAAC;IAC/B,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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,SA+qBtB"}
|
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,22 +35,33 @@ 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
67
|
constructor(config: PgVectorConfig & {
|
|
@@ -52,24 +69,35 @@ export declare class PgVector extends MastraVector<PGVectorFilter> {
|
|
|
52
69
|
});
|
|
53
70
|
private getMutexByName;
|
|
54
71
|
/**
|
|
55
|
-
* Detects which schema contains the vector extension
|
|
72
|
+
* Detects which schema contains the vector extension and its version
|
|
56
73
|
*/
|
|
57
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;
|
|
58
80
|
/**
|
|
59
81
|
* Gets the properly qualified vector type name
|
|
82
|
+
* @param vectorType - The type of vector storage ('vector' or 'halfvec')
|
|
60
83
|
*/
|
|
61
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;
|
|
62
90
|
private getTableName;
|
|
63
91
|
private getSchemaName;
|
|
64
92
|
transformFilter(filter?: PGVectorFilter): PGVectorFilter;
|
|
65
93
|
getIndexInfo({ indexName }: DescribeIndexParams): Promise<PGIndexStats>;
|
|
66
94
|
query({ indexName, queryVector, topK, filter, includeVector, minScore, ef, probes, }: PgQueryVectorParams): Promise<QueryResult[]>;
|
|
67
|
-
upsert({ indexName, vectors, metadata, ids }: UpsertVectorParams): Promise<string[]>;
|
|
95
|
+
upsert({ indexName, vectors, metadata, ids, deleteFilter, }: UpsertVectorParams<PGVectorFilter>): Promise<string[]>;
|
|
68
96
|
private hasher;
|
|
69
97
|
private getIndexCacheKey;
|
|
70
98
|
private cachedIndexExists;
|
|
71
99
|
private setupSchema;
|
|
72
|
-
createIndex({ indexName, dimension, metric, indexConfig, buildIndex, }: PgCreateIndexParams): Promise<void>;
|
|
100
|
+
createIndex({ indexName, dimension, metric, indexConfig, buildIndex, vectorType, }: PgCreateIndexParams): Promise<void>;
|
|
73
101
|
buildIndex({ indexName, metric, indexConfig }: PgDefineIndexParams): Promise<void>;
|
|
74
102
|
private setupIndex;
|
|
75
103
|
private installVectorExtension;
|
|
@@ -94,7 +122,7 @@ export declare class PgVector extends MastraVector<PGVectorFilter> {
|
|
|
94
122
|
* @returns A promise that resolves when the update is complete.
|
|
95
123
|
* @throws Will throw an error if no updates are provided or if the update operation fails.
|
|
96
124
|
*/
|
|
97
|
-
updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
|
|
125
|
+
updateVector({ indexName, id, filter, update }: UpdateVectorParams<PGVectorFilter>): Promise<void>;
|
|
98
126
|
/**
|
|
99
127
|
* Deletes a vector by its ID.
|
|
100
128
|
* @param indexName - The name of the index containing the vector.
|
|
@@ -103,6 +131,14 @@ export declare class PgVector extends MastraVector<PGVectorFilter> {
|
|
|
103
131
|
* @throws Will throw an error if the deletion operation fails.
|
|
104
132
|
*/
|
|
105
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>;
|
|
106
142
|
}
|
|
107
143
|
export {};
|
|
108
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,EAAE,MAAM,qBAAqB,CAAC;AACnD,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;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,UA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B,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAoDtC;;;;;OAKG;IACG,aAAa,CAAC,EAAE,SAAS,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC;IAgHxE,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;AAmP/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,CAwG3E;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAwGrG"}
|
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": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.10",
|
|
4
4
|
"description": "Postgres provider for Mastra - includes both vector and db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,17 +26,18 @@
|
|
|
26
26
|
"xxhash-wasm": "^1.1.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@types/
|
|
31
|
-
"@
|
|
29
|
+
"@types/node": "22.13.17",
|
|
30
|
+
"@types/pg": "^8.15.6",
|
|
31
|
+
"@vitest/coverage-v8": "4.0.12",
|
|
32
|
+
"@vitest/ui": "4.0.12",
|
|
32
33
|
"eslint": "^9.37.0",
|
|
33
34
|
"tsup": "^8.5.0",
|
|
34
35
|
"typescript": "^5.8.3",
|
|
35
|
-
"vitest": "
|
|
36
|
+
"vitest": "4.0.12",
|
|
36
37
|
"@internal/lint": "0.0.53",
|
|
37
38
|
"@internal/storage-test-utils": "0.0.49",
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
39
|
+
"@internal/types-builder": "0.0.28",
|
|
40
|
+
"@mastra/core": "1.0.0-beta.16"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
42
43
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/operations/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAQhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAI5C,YAAY,EAAE,kBAAkB,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;AAEjE,qBAAa,iBAAkB,SAAQ,eAAe;IAC7C,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,kBAAkB,CAA8B;IACxD,OAAO,CAAC,mBAAmB,CAAkC;gBAEjD,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE;QAAE,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;IAM5E,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAYhE;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAe9B;;OAEG;IACH,OAAO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