@constructive-io/graphql-codegen 4.30.0 → 4.30.2
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.
|
@@ -113,13 +113,14 @@ function buildEmbedder(config: EmbedderConfig): EmbedderFunction | null {
|
|
|
113
113
|
* @param embedder - The resolved embedder function
|
|
114
114
|
* @returns The modified where clause
|
|
115
115
|
*/
|
|
116
|
-
export async function autoEmbedWhere(
|
|
117
|
-
where:
|
|
116
|
+
export async function autoEmbedWhere<T extends object>(
|
|
117
|
+
where: T,
|
|
118
118
|
vectorFieldNames: string[],
|
|
119
119
|
embedder: EmbedderFunction,
|
|
120
|
-
): Promise<
|
|
120
|
+
): Promise<T> {
|
|
121
|
+
const rec = where as unknown as Record<string, unknown>;
|
|
121
122
|
for (const fieldName of vectorFieldNames) {
|
|
122
|
-
const fieldValue =
|
|
123
|
+
const fieldValue = rec[fieldName];
|
|
123
124
|
if (fieldValue && typeof fieldValue === 'object') {
|
|
124
125
|
const input = fieldValue as Record<string, unknown>;
|
|
125
126
|
// If 'vector' is a string, embed it
|
|
@@ -132,7 +133,7 @@ export async function autoEmbedWhere(
|
|
|
132
133
|
// Shorthand: --where.vectorEmbedding "text" with --auto-embed
|
|
133
134
|
// becomes { vector: [embedded], metric: 'COSINE' }
|
|
134
135
|
const embedding = await embedder(fieldValue);
|
|
135
|
-
|
|
136
|
+
rec[fieldName] = { vector: embedding };
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
return where;
|
|
@@ -157,17 +158,18 @@ export async function autoEmbedWhere(
|
|
|
157
158
|
* @param embedder - The resolved embedder function
|
|
158
159
|
* @returns The modified data object with text values replaced by vectors
|
|
159
160
|
*/
|
|
160
|
-
export async function autoEmbedInput(
|
|
161
|
-
data:
|
|
161
|
+
export async function autoEmbedInput<T extends object>(
|
|
162
|
+
data: T,
|
|
162
163
|
vectorFieldNames: string[],
|
|
163
164
|
embedder: EmbedderFunction,
|
|
164
|
-
): Promise<
|
|
165
|
+
): Promise<T> {
|
|
166
|
+
const rec = data as unknown as Record<string, unknown>;
|
|
165
167
|
for (const fieldName of vectorFieldNames) {
|
|
166
|
-
const fieldValue =
|
|
168
|
+
const fieldValue = rec[fieldName];
|
|
167
169
|
if (typeof fieldValue === 'string') {
|
|
168
170
|
// Text string → embed to vector array
|
|
169
171
|
const embedding = await embedder(fieldValue);
|
|
170
|
-
|
|
172
|
+
rec[fieldName] = embedding;
|
|
171
173
|
}
|
|
172
174
|
// If it's already an array (pre-computed vector), leave it as-is
|
|
173
175
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/graphql-codegen",
|
|
3
|
-
"version": "4.30.
|
|
3
|
+
"version": "4.30.2",
|
|
4
4
|
"description": "GraphQL SDK generator for Constructive databases with React Query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@0no-co/graphql.web": "^1.1.2",
|
|
57
57
|
"@babel/generator": "^7.29.1",
|
|
58
58
|
"@babel/types": "^7.29.0",
|
|
59
|
-
"@constructive-io/graphql-query": "^3.14.
|
|
59
|
+
"@constructive-io/graphql-query": "^3.14.1",
|
|
60
60
|
"@constructive-io/graphql-types": "^3.5.0",
|
|
61
61
|
"@inquirerer/utils": "^3.3.5",
|
|
62
62
|
"@pgpmjs/core": "^6.12.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"deepmerge": "^4.3.1",
|
|
65
65
|
"find-and-require-package-json": "^0.9.1",
|
|
66
66
|
"gql-ast": "^3.5.0",
|
|
67
|
-
"graphile-schema": "^1.13.
|
|
67
|
+
"graphile-schema": "^1.13.1",
|
|
68
68
|
"graphql": "16.13.0",
|
|
69
69
|
"inflekt": "^0.7.1",
|
|
70
70
|
"inquirerer": "^4.7.0",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"tsx": "^4.21.0",
|
|
101
101
|
"typescript": "^5.9.3"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "01775e13ef44c0e3b6c04a28b8b85f33f86af48b"
|
|
104
104
|
}
|