sst 0.0.532 → 0.0.534
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/dist/aws/realtime.d.ts +7 -6
- package/dist/aws/realtime.js +3 -2
- package/dist/vector/index.d.ts +71 -31
- package/dist/vector/index.js +9 -3
- package/package.json +6 -6
package/dist/aws/realtime.d.ts
CHANGED
|
@@ -4,14 +4,14 @@ export declare namespace realtime {
|
|
|
4
4
|
/**
|
|
5
5
|
* The topics the client can subscribe to.
|
|
6
6
|
* @example
|
|
7
|
-
* For example, this subscribes to specific topics.
|
|
7
|
+
* For example, this subscribes to two specific topics.
|
|
8
8
|
* ```js
|
|
9
9
|
* {
|
|
10
10
|
* subscribe: ["chat/room1", "chat/room2"]
|
|
11
11
|
* }
|
|
12
12
|
* ```
|
|
13
13
|
*
|
|
14
|
-
* And to subscribe to all topics under a
|
|
14
|
+
* And to subscribe to all topics under a given prefix.
|
|
15
15
|
* ```js
|
|
16
16
|
* {
|
|
17
17
|
* subscribe: ["chat/*"]
|
|
@@ -22,13 +22,13 @@ export declare namespace realtime {
|
|
|
22
22
|
/**
|
|
23
23
|
* The topics the client can publish to.
|
|
24
24
|
* @example
|
|
25
|
-
* For example, this publishes to specific topics.
|
|
25
|
+
* For example, this publishes to two specific topics.
|
|
26
26
|
* ```js
|
|
27
27
|
* {
|
|
28
28
|
* publish: ["chat/room1", "chat/room2"]
|
|
29
29
|
* }
|
|
30
30
|
* ```
|
|
31
|
-
* And to publish to all topics under a
|
|
31
|
+
* And to publish to all topics under a given prefix.
|
|
32
32
|
* ```js
|
|
33
33
|
* {
|
|
34
34
|
* publish: ["chat/*"]
|
|
@@ -38,11 +38,12 @@ export declare namespace realtime {
|
|
|
38
38
|
publish?: string[];
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* Creates an authorization handler for the `Realtime` component
|
|
41
|
+
* Creates an authorization handler for the `Realtime` component. It validates
|
|
42
42
|
* the token and grants permissions for the topics the client can subscribe and publish to.
|
|
43
43
|
*
|
|
44
44
|
* @example
|
|
45
|
-
* ```js
|
|
45
|
+
* ```js title="src/authorizer.ts" "realtime.authorizer"
|
|
46
|
+
* import { Resource } from "sst/aws";
|
|
46
47
|
* import { realtime } from "sst/aws/realtime";
|
|
47
48
|
*
|
|
48
49
|
* export const handler = realtime.authorizer(async (token) => {
|
package/dist/aws/realtime.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export var realtime;
|
|
2
2
|
(function (realtime) {
|
|
3
3
|
/**
|
|
4
|
-
* Creates an authorization handler for the `Realtime` component
|
|
4
|
+
* Creates an authorization handler for the `Realtime` component. It validates
|
|
5
5
|
* the token and grants permissions for the topics the client can subscribe and publish to.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
* ```js
|
|
8
|
+
* ```js title="src/authorizer.ts" "realtime.authorizer"
|
|
9
|
+
* import { Resource } from "sst/aws";
|
|
9
10
|
* import { realtime } from "sst/aws/realtime";
|
|
10
11
|
*
|
|
11
12
|
* export const handler = realtime.authorizer(async (token) => {
|
package/dist/vector/index.d.ts
CHANGED
|
@@ -5,21 +5,21 @@ export interface PutEvent {
|
|
|
5
5
|
* @example
|
|
6
6
|
* ```js
|
|
7
7
|
* {
|
|
8
|
-
* vector: [32.4, 6.55, 11.2, 10.3, 87.9]
|
|
8
|
+
* vector: [32.4, 6.55, 11.2, 10.3, 87.9]
|
|
9
9
|
* }
|
|
10
10
|
* ```
|
|
11
11
|
*/
|
|
12
12
|
vector: number[];
|
|
13
13
|
/**
|
|
14
|
-
* Metadata for the event
|
|
15
|
-
* This
|
|
14
|
+
* Metadata for the event as JSON.
|
|
15
|
+
* This will be used to filter when querying and removing vectors.
|
|
16
16
|
* @example
|
|
17
17
|
* ```js
|
|
18
18
|
* {
|
|
19
19
|
* metadata: {
|
|
20
20
|
* type: "movie",
|
|
21
21
|
* id: "movie-123",
|
|
22
|
-
* name: "Spiderman"
|
|
22
|
+
* name: "Spiderman"
|
|
23
23
|
* }
|
|
24
24
|
* }
|
|
25
25
|
* ```
|
|
@@ -32,7 +32,7 @@ export interface QueryEvent {
|
|
|
32
32
|
* @example
|
|
33
33
|
* ```js
|
|
34
34
|
* {
|
|
35
|
-
* vector: [32.4, 6.55, 11.2, 10.3, 87.9]
|
|
35
|
+
* vector: [32.4, 6.55, 11.2, 10.3, 87.9]
|
|
36
36
|
* }
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
@@ -41,29 +41,30 @@ export interface QueryEvent {
|
|
|
41
41
|
* The metadata used to filter the vectors.
|
|
42
42
|
* Only vectors that match the provided fields will be returned.
|
|
43
43
|
* @example
|
|
44
|
+
* Given this filter.
|
|
44
45
|
* ```js
|
|
45
46
|
* {
|
|
46
47
|
* include: {
|
|
47
48
|
* type: "movie",
|
|
48
|
-
* release: "2001"
|
|
49
|
+
* release: "2001"
|
|
49
50
|
* }
|
|
50
51
|
* }
|
|
51
52
|
* ```
|
|
52
|
-
*
|
|
53
|
+
* It will match a vector with the metadata:
|
|
53
54
|
* ```js
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
55
|
+
* {
|
|
56
|
+
* type: "movie",
|
|
57
|
+
* name: "Spiderman",
|
|
58
|
+
* release: "2001"
|
|
59
|
+
* }
|
|
59
60
|
* ```
|
|
60
61
|
*
|
|
61
|
-
* But not
|
|
62
|
+
* But not a vector with this metadata:
|
|
62
63
|
* ```js
|
|
63
64
|
* {
|
|
64
65
|
* type: "book",
|
|
65
66
|
* name: "Spiderman",
|
|
66
|
-
* release: "2001"
|
|
67
|
+
* release: "2001"
|
|
67
68
|
* }
|
|
68
69
|
* ```
|
|
69
70
|
*/
|
|
@@ -71,32 +72,33 @@ export interface QueryEvent {
|
|
|
71
72
|
/**
|
|
72
73
|
* Exclude vectors with metadata that match the provided fields.
|
|
73
74
|
* @example
|
|
75
|
+
* Given this filter.
|
|
74
76
|
* ```js
|
|
75
77
|
* {
|
|
76
78
|
* include: {
|
|
77
79
|
* type: "movie",
|
|
78
|
-
* release: "2001"
|
|
80
|
+
* release: "2001"
|
|
79
81
|
* },
|
|
80
82
|
* exclude: {
|
|
81
|
-
* name: "Spiderman"
|
|
83
|
+
* name: "Spiderman"
|
|
82
84
|
* }
|
|
83
85
|
* }
|
|
84
86
|
* ```
|
|
85
|
-
* This will match
|
|
87
|
+
* This will match a vector with metadata:
|
|
86
88
|
* ```js
|
|
87
89
|
* {
|
|
88
90
|
* type: "movie",
|
|
89
91
|
* name: "A Beautiful Mind",
|
|
90
|
-
* release: "2001"
|
|
92
|
+
* release: "2001"
|
|
91
93
|
* }
|
|
92
94
|
* ```
|
|
93
95
|
*
|
|
94
|
-
* But not
|
|
96
|
+
* But not a vector with the metadata:
|
|
95
97
|
* ```js
|
|
96
98
|
* {
|
|
97
99
|
* type: "book",
|
|
98
100
|
* name: "Spiderman",
|
|
99
|
-
* release: "2001"
|
|
101
|
+
* release: "2001"
|
|
100
102
|
* }
|
|
101
103
|
* ```
|
|
102
104
|
*/
|
|
@@ -104,14 +106,16 @@ export interface QueryEvent {
|
|
|
104
106
|
/**
|
|
105
107
|
* The threshold of similarity between the prompt and the queried vectors.
|
|
106
108
|
* Only vectors with a similarity score higher than the threshold will be returned.
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* -
|
|
109
|
+
*
|
|
110
|
+
* This will return values is between 0 and 1.
|
|
111
|
+
* - `0` means the prompt and the queried vectors are completely different.
|
|
112
|
+
* - `1` means the prompt and the queried vectors are identical.
|
|
113
|
+
*
|
|
110
114
|
* @default `0`
|
|
111
115
|
* @example
|
|
112
116
|
* ```js
|
|
113
117
|
* {
|
|
114
|
-
* threshold: 0.5
|
|
118
|
+
* threshold: 0.5
|
|
115
119
|
* }
|
|
116
120
|
* ```
|
|
117
121
|
*/
|
|
@@ -122,7 +126,7 @@ export interface QueryEvent {
|
|
|
122
126
|
* @example
|
|
123
127
|
* ```js
|
|
124
128
|
* {
|
|
125
|
-
* count: 10
|
|
129
|
+
* count: 10
|
|
126
130
|
* }
|
|
127
131
|
* ```
|
|
128
132
|
*/
|
|
@@ -133,7 +137,7 @@ export interface RemoveEvent {
|
|
|
133
137
|
* The metadata used to filter the removal of vectors.
|
|
134
138
|
* Only vectors with metadata that match the provided fields will be removed.
|
|
135
139
|
* @example
|
|
136
|
-
* To remove vectors for movie with id
|
|
140
|
+
* To remove vectors for movie with id `movie-123`:
|
|
137
141
|
* ```js
|
|
138
142
|
* {
|
|
139
143
|
* include: {
|
|
@@ -141,7 +145,7 @@ export interface RemoveEvent {
|
|
|
141
145
|
* }
|
|
142
146
|
* }
|
|
143
147
|
* ```
|
|
144
|
-
* To remove vectors for all
|
|
148
|
+
* To remove vectors for all _movies_:
|
|
145
149
|
* ```js
|
|
146
150
|
* {
|
|
147
151
|
* include: {
|
|
@@ -154,7 +158,7 @@ export interface RemoveEvent {
|
|
|
154
158
|
}
|
|
155
159
|
export interface QueryResponse {
|
|
156
160
|
/**
|
|
157
|
-
* Metadata for the event
|
|
161
|
+
* Metadata for the event that was provided when storing the vector.
|
|
158
162
|
*/
|
|
159
163
|
metadata: Record<string, any>;
|
|
160
164
|
/**
|
|
@@ -163,24 +167,60 @@ export interface QueryResponse {
|
|
|
163
167
|
score: number;
|
|
164
168
|
}
|
|
165
169
|
export interface VectorClientResponse {
|
|
170
|
+
/**
|
|
171
|
+
* Store a vector into the database.
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts title="src/lambda.ts"
|
|
174
|
+
* await client.put({
|
|
175
|
+
* vector: [32.4, 6.55, 11.2, 10.3, 87.9],
|
|
176
|
+
* metadata: { type: "movie", genre: "comedy" },
|
|
177
|
+
* });
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
166
180
|
put: (event: PutEvent) => Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Query vectors that are similar to the given vector
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts title="src/lambda.ts"
|
|
185
|
+
* const result = await client.query({
|
|
186
|
+
* vector: [32.4, 6.55, 11.2, 10.3, 87.9],
|
|
187
|
+
* include: { type: "movie" },
|
|
188
|
+
* exclude: { genre: "thriller" },
|
|
189
|
+
* });
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
167
192
|
query: (event: QueryEvent) => Promise<QueryResponse>;
|
|
193
|
+
/**
|
|
194
|
+
* Remove vectors from the database.
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts title="src/lambda.ts"
|
|
197
|
+
* await client.remove({
|
|
198
|
+
* include: { type: "movie" },
|
|
199
|
+
* });
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
168
202
|
remove: (event: RemoveEvent) => Promise<void>;
|
|
169
203
|
}
|
|
170
204
|
/**
|
|
171
205
|
* Create a client to interact with the Vector database.
|
|
172
206
|
* @example
|
|
173
|
-
* ```
|
|
207
|
+
* ```ts title="src/lambda.ts"
|
|
174
208
|
* import { VectorClient } from "sst";
|
|
175
209
|
* const client = VectorClient("MyVectorDB");
|
|
210
|
+
* ```
|
|
176
211
|
*
|
|
177
|
-
*
|
|
212
|
+
* Store a vector into the db
|
|
213
|
+
*
|
|
214
|
+
* ```ts title="src/lambda.ts"
|
|
178
215
|
* await client.put({
|
|
179
216
|
* vector: [32.4, 6.55, 11.2, 10.3, 87.9],
|
|
180
217
|
* metadata: { type: "movie", genre: "comedy" },
|
|
181
218
|
* });
|
|
219
|
+
* ```
|
|
220
|
+
*
|
|
221
|
+
* Query vectors that are similar to the given vector
|
|
182
222
|
*
|
|
183
|
-
*
|
|
223
|
+
* ```ts title="src/lambda.ts"
|
|
184
224
|
* const result = await client.query({
|
|
185
225
|
* vector: [32.4, 6.55, 11.2, 10.3, 87.9],
|
|
186
226
|
* include: { type: "movie" },
|
package/dist/vector/index.js
CHANGED
|
@@ -4,17 +4,23 @@ const lambda = new LambdaClient();
|
|
|
4
4
|
/**
|
|
5
5
|
* Create a client to interact with the Vector database.
|
|
6
6
|
* @example
|
|
7
|
-
* ```
|
|
7
|
+
* ```ts title="src/lambda.ts"
|
|
8
8
|
* import { VectorClient } from "sst";
|
|
9
9
|
* const client = VectorClient("MyVectorDB");
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Store a vector into the db
|
|
10
13
|
*
|
|
11
|
-
*
|
|
14
|
+
* ```ts title="src/lambda.ts"
|
|
12
15
|
* await client.put({
|
|
13
16
|
* vector: [32.4, 6.55, 11.2, 10.3, 87.9],
|
|
14
17
|
* metadata: { type: "movie", genre: "comedy" },
|
|
15
18
|
* });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Query vectors that are similar to the given vector
|
|
16
22
|
*
|
|
17
|
-
*
|
|
23
|
+
* ```ts title="src/lambda.ts"
|
|
18
24
|
* const result = await client.query({
|
|
19
25
|
* vector: [32.4, 6.55, 11.2, 10.3, 87.9],
|
|
20
26
|
* include: { type: "movie" },
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "sst",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.534",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": "./dist/index.js",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"optionalDependencies": {
|
|
50
|
-
"sst-linux-x64": "0.0.
|
|
51
|
-
"sst-linux-x86": "0.0.
|
|
52
|
-
"sst-linux-arm64": "0.0.
|
|
53
|
-
"sst-darwin-x64": "0.0.
|
|
54
|
-
"sst-darwin-arm64": "0.0.
|
|
50
|
+
"sst-linux-x64": "0.0.534",
|
|
51
|
+
"sst-linux-x86": "0.0.534",
|
|
52
|
+
"sst-linux-arm64": "0.0.534",
|
|
53
|
+
"sst-darwin-x64": "0.0.534",
|
|
54
|
+
"sst-darwin-arm64": "0.0.534"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@aws-sdk/client-lambda": "3.478.0",
|