@mastra/upstash 0.1.6-alpha.1 → 0.1.6-alpha.3
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 +11 -6
- package/CHANGELOG.md +25 -0
- package/README.md +20 -1
- package/dist/_tsup-dts-rollup.d.cts +133 -0
- package/dist/_tsup-dts-rollup.d.ts +12 -8
- package/dist/index.cjs +480 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.js +8 -4
- package/package.json +9 -5
- package/src/storage/upstash.test.ts +332 -330
- package/src/vector/filter.ts +5 -5
- package/src/vector/index.test.ts +440 -150
- package/src/vector/index.ts +20 -21
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/upstash@0.1.6-alpha.
|
|
3
|
-
> tsup src/index.ts --format esm --experimental-dts --clean --treeshake
|
|
2
|
+
> @mastra/upstash@0.1.6-alpha.3 build /home/runner/work/mastra/mastra/stores/upstash
|
|
3
|
+
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake
|
|
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.3.6
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 7823ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.7.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/upstash/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
|
-
|
|
14
|
+
Analysis will use the bundled TypeScript version 5.7.3
|
|
15
|
+
[36mWriting package typings: /home/runner/work/mastra/mastra/stores/upstash/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 10302ms
|
|
15
17
|
[34mCLI[39m Cleaning output folder
|
|
16
18
|
[34mESM[39m Build start
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
+
[34mCJS[39m Build start
|
|
20
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m16.25 KB[39m
|
|
21
|
+
[32mCJS[39m ⚡️ Build success in 793ms
|
|
22
|
+
[32mESM[39m [1mdist/index.js [22m[32m16.12 KB[39m
|
|
23
|
+
[32mESM[39m ⚡️ Build success in 793ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @mastra/upstash
|
|
2
2
|
|
|
3
|
+
## 0.1.6-alpha.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0fd78ac: Update vector store functions to use object params
|
|
8
|
+
- fd14a3f: Updating filter location from @mastra/core/filter to @mastra/core/vector/filter
|
|
9
|
+
- c4fdac3: Updated tests for upstash and astra
|
|
10
|
+
- 4d4e1e1: Updated vector tests and pinecone
|
|
11
|
+
- bb4f447: Add support for commonjs
|
|
12
|
+
- Updated dependencies [0fd78ac]
|
|
13
|
+
- Updated dependencies [0d25b75]
|
|
14
|
+
- Updated dependencies [fd14a3f]
|
|
15
|
+
- Updated dependencies [3f369a2]
|
|
16
|
+
- Updated dependencies [4d4e1e1]
|
|
17
|
+
- Updated dependencies [bb4f447]
|
|
18
|
+
- @mastra/core@0.4.3-alpha.3
|
|
19
|
+
|
|
20
|
+
## 0.1.6-alpha.2
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [2512a93]
|
|
25
|
+
- Updated dependencies [e62de74]
|
|
26
|
+
- @mastra/core@0.4.3-alpha.2
|
|
27
|
+
|
|
3
28
|
## 0.1.6-alpha.1
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -14,7 +14,26 @@ npm install @mastra/upstash
|
|
|
14
14
|
import { UpstashVector } from '@mastra/upstash';
|
|
15
15
|
|
|
16
16
|
const vectorStore = new UpstashVector({
|
|
17
|
-
|
|
17
|
+
url: process.env.UPSTASH_VECTOR_REST_URL,
|
|
18
|
+
token: process.env.UPSTASH_VECTOR_TOKEN
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Add vectors
|
|
22
|
+
const vectors = [[0.1, 0.2, ...], [0.3, 0.4, ...]];
|
|
23
|
+
const metadata = [{ text: 'doc1' }, { text: 'doc2' }];
|
|
24
|
+
const ids = await vectorStore.upsert({
|
|
25
|
+
indexName: 'my-namespace',
|
|
26
|
+
vectors,
|
|
27
|
+
metadata
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Query vectors
|
|
31
|
+
const results = await vectorStore.query({
|
|
32
|
+
indexName: 'my-namespace',
|
|
33
|
+
queryVector: [0.1, 0.2, ...],
|
|
34
|
+
topK: 10,
|
|
35
|
+
filter: { text: { $eq: 'doc1' } },
|
|
36
|
+
includeVector: false
|
|
18
37
|
});
|
|
19
38
|
```
|
|
20
39
|
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
2
|
+
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
3
|
+
import type { EvalRow } from '@mastra/core/storage';
|
|
4
|
+
import { MastraStorage } from '@mastra/core/storage';
|
|
5
|
+
import { MastraVector } from '@mastra/core/vector';
|
|
6
|
+
import type { MessageType } from '@mastra/core/memory';
|
|
7
|
+
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
8
|
+
import type { ParamsToArgs } from '@mastra/core/vector';
|
|
9
|
+
import type { QueryResult } from '@mastra/core/vector';
|
|
10
|
+
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
11
|
+
import type { StorageColumn } from '@mastra/core/storage';
|
|
12
|
+
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
13
|
+
import type { StorageThreadType } from '@mastra/core/memory';
|
|
14
|
+
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
15
|
+
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
16
|
+
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
17
|
+
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
18
|
+
|
|
19
|
+
declare interface UpstashConfig {
|
|
20
|
+
url: string;
|
|
21
|
+
token: string;
|
|
22
|
+
}
|
|
23
|
+
export { UpstashConfig }
|
|
24
|
+
export { UpstashConfig as UpstashConfig_alias_1 }
|
|
25
|
+
|
|
26
|
+
export declare class UpstashFilterTranslator extends BaseFilterTranslator {
|
|
27
|
+
protected getSupportedOperators(): OperatorSupport;
|
|
28
|
+
translate(filter?: VectorFilter): string | undefined;
|
|
29
|
+
private translateNode;
|
|
30
|
+
private readonly COMPARISON_OPS;
|
|
31
|
+
private translateOperator;
|
|
32
|
+
private readonly NEGATED_OPERATORS;
|
|
33
|
+
private formatNot;
|
|
34
|
+
private formatValue;
|
|
35
|
+
private formatArray;
|
|
36
|
+
private formatComparison;
|
|
37
|
+
private joinConditions;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare class UpstashStore extends MastraStorage {
|
|
41
|
+
batchInsert(_input: {
|
|
42
|
+
tableName: TABLE_NAMES;
|
|
43
|
+
records: Record<string, any>[];
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
getEvalsByAgentName(_agentName: string, _type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
46
|
+
getTraces(_input: {
|
|
47
|
+
name?: string;
|
|
48
|
+
scope?: string;
|
|
49
|
+
page: number;
|
|
50
|
+
perPage: number;
|
|
51
|
+
attributes?: Record<string, string>;
|
|
52
|
+
}): Promise<any[]>;
|
|
53
|
+
private redis;
|
|
54
|
+
constructor(config: UpstashConfig);
|
|
55
|
+
private getKey;
|
|
56
|
+
private ensureDate;
|
|
57
|
+
private serializeDate;
|
|
58
|
+
createTable({ tableName, schema, }: {
|
|
59
|
+
tableName: TABLE_NAMES;
|
|
60
|
+
schema: Record<string, StorageColumn>;
|
|
61
|
+
}): Promise<void>;
|
|
62
|
+
clearTable({ tableName }: {
|
|
63
|
+
tableName: TABLE_NAMES;
|
|
64
|
+
}): Promise<void>;
|
|
65
|
+
insert({ tableName, record }: {
|
|
66
|
+
tableName: TABLE_NAMES;
|
|
67
|
+
record: Record<string, any>;
|
|
68
|
+
}): Promise<void>;
|
|
69
|
+
load<R>({ tableName, keys }: {
|
|
70
|
+
tableName: TABLE_NAMES;
|
|
71
|
+
keys: Record<string, string>;
|
|
72
|
+
}): Promise<R | null>;
|
|
73
|
+
getThreadById({ threadId }: {
|
|
74
|
+
threadId: string;
|
|
75
|
+
}): Promise<StorageThreadType | null>;
|
|
76
|
+
getThreadsByResourceId({ resourceId }: {
|
|
77
|
+
resourceId: string;
|
|
78
|
+
}): Promise<StorageThreadType[]>;
|
|
79
|
+
saveThread({ thread }: {
|
|
80
|
+
thread: StorageThreadType;
|
|
81
|
+
}): Promise<StorageThreadType>;
|
|
82
|
+
updateThread({ id, title, metadata, }: {
|
|
83
|
+
id: string;
|
|
84
|
+
title: string;
|
|
85
|
+
metadata: Record<string, unknown>;
|
|
86
|
+
}): Promise<StorageThreadType>;
|
|
87
|
+
deleteThread({ threadId }: {
|
|
88
|
+
threadId: string;
|
|
89
|
+
}): Promise<void>;
|
|
90
|
+
private getMessageKey;
|
|
91
|
+
private getThreadMessagesKey;
|
|
92
|
+
saveMessages({ messages }: {
|
|
93
|
+
messages: MessageType[];
|
|
94
|
+
}): Promise<MessageType[]>;
|
|
95
|
+
getMessages<T = unknown>({ threadId, selectBy }: StorageGetMessagesArg): Promise<T[]>;
|
|
96
|
+
persistWorkflowSnapshot(params: {
|
|
97
|
+
namespace: string;
|
|
98
|
+
workflowName: string;
|
|
99
|
+
runId: string;
|
|
100
|
+
snapshot: WorkflowRunState;
|
|
101
|
+
}): Promise<void>;
|
|
102
|
+
loadWorkflowSnapshot(params: {
|
|
103
|
+
namespace: string;
|
|
104
|
+
workflowName: string;
|
|
105
|
+
runId: string;
|
|
106
|
+
}): Promise<WorkflowRunState | null>;
|
|
107
|
+
close(): Promise<void>;
|
|
108
|
+
}
|
|
109
|
+
export { UpstashStore }
|
|
110
|
+
export { UpstashStore as UpstashStore_alias_1 }
|
|
111
|
+
|
|
112
|
+
declare class UpstashVector extends MastraVector {
|
|
113
|
+
private client;
|
|
114
|
+
constructor({ url, token }: {
|
|
115
|
+
url: string;
|
|
116
|
+
token: string;
|
|
117
|
+
});
|
|
118
|
+
upsert(...args: ParamsToArgs<UpsertVectorParams>): Promise<string[]>;
|
|
119
|
+
transformFilter(filter?: VectorFilter): string | undefined;
|
|
120
|
+
createIndex(..._args: ParamsToArgs<CreateIndexParams>): Promise<void>;
|
|
121
|
+
query(...args: ParamsToArgs<QueryVectorParams>): Promise<QueryResult[]>;
|
|
122
|
+
listIndexes(): Promise<string[]>;
|
|
123
|
+
describeIndex(indexName: string): Promise<{
|
|
124
|
+
dimension: number;
|
|
125
|
+
count: number;
|
|
126
|
+
metric: "cosine" | "euclidean" | "dotproduct";
|
|
127
|
+
}>;
|
|
128
|
+
deleteIndex(indexName: string): Promise<void>;
|
|
129
|
+
}
|
|
130
|
+
export { UpstashVector }
|
|
131
|
+
export { UpstashVector as UpstashVector_alias_1 }
|
|
132
|
+
|
|
133
|
+
export { }
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import { BaseFilterTranslator } from '@mastra/core/filter';
|
|
1
|
+
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
2
|
+
import type { CreateIndexParams } from '@mastra/core/vector';
|
|
2
3
|
import type { EvalRow } from '@mastra/core/storage';
|
|
3
|
-
import type { Filter } from '@mastra/core/filter';
|
|
4
4
|
import { MastraStorage } from '@mastra/core/storage';
|
|
5
5
|
import { MastraVector } from '@mastra/core/vector';
|
|
6
6
|
import type { MessageType } from '@mastra/core/memory';
|
|
7
|
-
import type { OperatorSupport } from '@mastra/core/filter';
|
|
7
|
+
import type { OperatorSupport } from '@mastra/core/vector/filter';
|
|
8
|
+
import type { ParamsToArgs } from '@mastra/core/vector';
|
|
8
9
|
import type { QueryResult } from '@mastra/core/vector';
|
|
10
|
+
import type { QueryVectorParams } from '@mastra/core/vector';
|
|
9
11
|
import type { StorageColumn } from '@mastra/core/storage';
|
|
10
12
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
11
13
|
import type { StorageThreadType } from '@mastra/core/memory';
|
|
12
14
|
import type { TABLE_NAMES } from '@mastra/core/storage';
|
|
15
|
+
import type { UpsertVectorParams } from '@mastra/core/vector';
|
|
16
|
+
import type { VectorFilter } from '@mastra/core/vector/filter';
|
|
13
17
|
import type { WorkflowRunState } from '@mastra/core/workflows';
|
|
14
18
|
|
|
15
19
|
declare interface UpstashConfig {
|
|
@@ -21,7 +25,7 @@ export { UpstashConfig as UpstashConfig_alias_1 }
|
|
|
21
25
|
|
|
22
26
|
export declare class UpstashFilterTranslator extends BaseFilterTranslator {
|
|
23
27
|
protected getSupportedOperators(): OperatorSupport;
|
|
24
|
-
translate(filter?:
|
|
28
|
+
translate(filter?: VectorFilter): string | undefined;
|
|
25
29
|
private translateNode;
|
|
26
30
|
private readonly COMPARISON_OPS;
|
|
27
31
|
private translateOperator;
|
|
@@ -111,10 +115,10 @@ declare class UpstashVector extends MastraVector {
|
|
|
111
115
|
url: string;
|
|
112
116
|
token: string;
|
|
113
117
|
});
|
|
114
|
-
upsert(
|
|
115
|
-
transformFilter(filter?:
|
|
116
|
-
createIndex(
|
|
117
|
-
query(
|
|
118
|
+
upsert(...args: ParamsToArgs<UpsertVectorParams>): Promise<string[]>;
|
|
119
|
+
transformFilter(filter?: VectorFilter): string | undefined;
|
|
120
|
+
createIndex(..._args: ParamsToArgs<CreateIndexParams>): Promise<void>;
|
|
121
|
+
query(...args: ParamsToArgs<QueryVectorParams>): Promise<QueryResult[]>;
|
|
118
122
|
listIndexes(): Promise<string[]>;
|
|
119
123
|
describeIndex(indexName: string): Promise<{
|
|
120
124
|
dimension: number;
|