@functional-systems/lambdadb 0.3.2 → 0.3.4-dev.0
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/README.md +44 -2
- package/dist/commonjs/client.d.ts +6 -6
- package/dist/commonjs/client.d.ts.map +1 -1
- package/dist/commonjs/client.js +33 -9
- package/dist/commonjs/client.js.map +1 -1
- package/dist/commonjs/funcs/collectionsDocsBulkUpsert.d.ts +1 -1
- package/dist/commonjs/funcs/collectionsDocsBulkUpsert.js +1 -1
- package/dist/commonjs/funcs/collectionsDocsGetBulkUpsert.d.ts +2 -2
- package/dist/commonjs/funcs/collectionsDocsGetBulkUpsert.d.ts.map +1 -1
- package/dist/commonjs/funcs/collectionsDocsGetBulkUpsert.js +3 -3
- package/dist/commonjs/funcs/collectionsDocsGetBulkUpsert.js.map +1 -1
- package/dist/commonjs/lib/matchers.d.ts.map +1 -1
- package/dist/commonjs/lib/matchers.js +17 -1
- package/dist/commonjs/lib/matchers.js.map +1 -1
- package/dist/commonjs/lib/schemas.d.ts +6 -0
- package/dist/commonjs/lib/schemas.d.ts.map +1 -1
- package/dist/commonjs/lib/schemas.js +9 -0
- package/dist/commonjs/lib/schemas.js.map +1 -1
- package/dist/commonjs/models/collectionresponse.js +4 -4
- package/dist/commonjs/models/collectionresponse.js.map +1 -1
- package/dist/commonjs/models/errors/badrequesterror.d.ts.map +1 -1
- package/dist/commonjs/models/errors/badrequesterror.js +2 -1
- package/dist/commonjs/models/errors/badrequesterror.js.map +1 -1
- package/dist/commonjs/models/errors/internalservererror.d.ts.map +1 -1
- package/dist/commonjs/models/errors/internalservererror.js +2 -1
- package/dist/commonjs/models/errors/internalservererror.js.map +1 -1
- package/dist/commonjs/models/errors/resourcealreadyexistserror.d.ts.map +1 -1
- package/dist/commonjs/models/errors/resourcealreadyexistserror.js +2 -1
- package/dist/commonjs/models/errors/resourcealreadyexistserror.js.map +1 -1
- package/dist/commonjs/models/errors/resourcenotfounderror.d.ts.map +1 -1
- package/dist/commonjs/models/errors/resourcenotfounderror.js +2 -1
- package/dist/commonjs/models/errors/resourcenotfounderror.js.map +1 -1
- package/dist/commonjs/models/errors/toomanyrequestserror.d.ts.map +1 -1
- package/dist/commonjs/models/errors/toomanyrequestserror.js +2 -1
- package/dist/commonjs/models/errors/toomanyrequestserror.js.map +1 -1
- package/dist/commonjs/models/errors/unauthenticatederror.d.ts.map +1 -1
- package/dist/commonjs/models/errors/unauthenticatederror.js +2 -1
- package/dist/commonjs/models/errors/unauthenticatederror.js.map +1 -1
- package/dist/commonjs/models/indexconfigsunion.d.ts +76 -4
- package/dist/commonjs/models/indexconfigsunion.d.ts.map +1 -1
- package/dist/commonjs/models/indexconfigsunion.js +58 -3
- package/dist/commonjs/models/indexconfigsunion.js.map +1 -1
- package/dist/commonjs/models/operations/fetchdocs.js +1 -1
- package/dist/commonjs/models/operations/fetchdocs.js.map +1 -1
- package/dist/commonjs/models/operations/getbulkupsertdocs.js +3 -3
- package/dist/commonjs/models/operations/getbulkupsertdocs.js.map +1 -1
- package/dist/commonjs/models/operations/listcollections.js +1 -1
- package/dist/commonjs/models/operations/listcollections.js.map +1 -1
- package/dist/commonjs/models/operations/listdocs.js +2 -2
- package/dist/commonjs/models/operations/listdocs.js.map +1 -1
- package/dist/commonjs/models/operations/querycollection.d.ts +1 -1
- package/dist/commonjs/models/operations/querycollection.js +3 -3
- package/dist/commonjs/models/operations/querycollection.js.map +1 -1
- package/dist/commonjs/models/operations/updatedocs.d.ts +1 -1
- package/dist/commonjs/models/operations/upsertdocs.d.ts +1 -1
- package/dist/commonjs/models/partitionconfig.js +3 -3
- package/dist/commonjs/models/partitionconfig.js.map +1 -1
- package/dist/commonjs/sdk/docs.d.ts +2 -2
- package/dist/commonjs/sdk/docs.js +2 -2
- package/dist/commonjs/types/errors.d.ts +1 -1
- package/dist/commonjs/types/errors.d.ts.map +1 -1
- package/dist/commonjs/types/public.d.ts +1 -1
- package/dist/commonjs/types/public.d.ts.map +1 -1
- package/dist/commonjs/types/public.js.map +1 -1
- package/dist/esm/client.d.ts +6 -6
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +33 -9
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/funcs/collectionsDocsBulkUpsert.d.ts +1 -1
- package/dist/esm/funcs/collectionsDocsBulkUpsert.js +1 -1
- package/dist/esm/funcs/collectionsDocsGetBulkUpsert.d.ts +2 -2
- package/dist/esm/funcs/collectionsDocsGetBulkUpsert.d.ts.map +1 -1
- package/dist/esm/funcs/collectionsDocsGetBulkUpsert.js +3 -3
- package/dist/esm/funcs/collectionsDocsGetBulkUpsert.js.map +1 -1
- package/dist/esm/lib/matchers.d.ts.map +1 -1
- package/dist/esm/lib/matchers.js +17 -1
- package/dist/esm/lib/matchers.js.map +1 -1
- package/dist/esm/lib/schemas.d.ts +6 -0
- package/dist/esm/lib/schemas.d.ts.map +1 -1
- package/dist/esm/lib/schemas.js +9 -1
- package/dist/esm/lib/schemas.js.map +1 -1
- package/dist/esm/models/collectionresponse.js +5 -5
- package/dist/esm/models/collectionresponse.js.map +1 -1
- package/dist/esm/models/errors/badrequesterror.d.ts.map +1 -1
- package/dist/esm/models/errors/badrequesterror.js +2 -1
- package/dist/esm/models/errors/badrequesterror.js.map +1 -1
- package/dist/esm/models/errors/internalservererror.d.ts.map +1 -1
- package/dist/esm/models/errors/internalservererror.js +2 -1
- package/dist/esm/models/errors/internalservererror.js.map +1 -1
- package/dist/esm/models/errors/resourcealreadyexistserror.d.ts.map +1 -1
- package/dist/esm/models/errors/resourcealreadyexistserror.js +2 -1
- package/dist/esm/models/errors/resourcealreadyexistserror.js.map +1 -1
- package/dist/esm/models/errors/resourcenotfounderror.d.ts.map +1 -1
- package/dist/esm/models/errors/resourcenotfounderror.js +2 -1
- package/dist/esm/models/errors/resourcenotfounderror.js.map +1 -1
- package/dist/esm/models/errors/toomanyrequestserror.d.ts.map +1 -1
- package/dist/esm/models/errors/toomanyrequestserror.js +2 -1
- package/dist/esm/models/errors/toomanyrequestserror.js.map +1 -1
- package/dist/esm/models/errors/unauthenticatederror.d.ts.map +1 -1
- package/dist/esm/models/errors/unauthenticatederror.js +2 -1
- package/dist/esm/models/errors/unauthenticatederror.js.map +1 -1
- package/dist/esm/models/indexconfigsunion.d.ts +76 -4
- package/dist/esm/models/indexconfigsunion.d.ts.map +1 -1
- package/dist/esm/models/indexconfigsunion.js +54 -3
- package/dist/esm/models/indexconfigsunion.js.map +1 -1
- package/dist/esm/models/operations/fetchdocs.js +2 -2
- package/dist/esm/models/operations/fetchdocs.js.map +1 -1
- package/dist/esm/models/operations/getbulkupsertdocs.js +4 -4
- package/dist/esm/models/operations/getbulkupsertdocs.js.map +1 -1
- package/dist/esm/models/operations/listcollections.js +2 -2
- package/dist/esm/models/operations/listcollections.js.map +1 -1
- package/dist/esm/models/operations/listdocs.js +3 -3
- package/dist/esm/models/operations/listdocs.js.map +1 -1
- package/dist/esm/models/operations/querycollection.d.ts +1 -1
- package/dist/esm/models/operations/querycollection.js +4 -4
- package/dist/esm/models/operations/querycollection.js.map +1 -1
- package/dist/esm/models/operations/updatedocs.d.ts +1 -1
- package/dist/esm/models/operations/upsertdocs.d.ts +1 -1
- package/dist/esm/models/partitionconfig.js +4 -4
- package/dist/esm/models/partitionconfig.js.map +1 -1
- package/dist/esm/sdk/docs.d.ts +2 -2
- package/dist/esm/sdk/docs.js +2 -2
- package/dist/esm/types/errors.d.ts +1 -1
- package/dist/esm/types/errors.d.ts.map +1 -1
- package/dist/esm/types/public.d.ts +1 -1
- package/dist/esm/types/public.d.ts.map +1 -1
- package/dist/esm/types/public.js.map +1 -1
- package/package.json +2 -2
- package/src/client.ts +38 -9
- package/src/funcs/collectionsDocsBulkUpsert.ts +1 -1
- package/src/funcs/collectionsDocsGetBulkUpsert.ts +6 -2
- package/src/lib/matchers.ts +18 -1
- package/src/lib/schemas.ts +12 -0
- package/src/models/collectionresponse.ts +5 -5
- package/src/models/errors/badrequesterror.ts +2 -1
- package/src/models/errors/internalservererror.ts +2 -1
- package/src/models/errors/resourcealreadyexistserror.ts +2 -1
- package/src/models/errors/resourcenotfounderror.ts +2 -1
- package/src/models/errors/toomanyrequestserror.ts +2 -1
- package/src/models/errors/unauthenticatederror.ts +2 -1
- package/src/models/indexconfigsunion.ts +162 -5
- package/src/models/operations/fetchdocs.ts +2 -2
- package/src/models/operations/getbulkupsertdocs.ts +4 -4
- package/src/models/operations/listcollections.ts +2 -2
- package/src/models/operations/listdocs.ts +3 -3
- package/src/models/operations/querycollection.ts +5 -5
- package/src/models/operations/updatedocs.ts +1 -1
- package/src/models/operations/upsertdocs.ts +1 -1
- package/src/models/partitionconfig.ts +4 -4
- package/src/sdk/docs.ts +2 -2
- package/src/types/errors.ts +3 -1
- package/src/types/public.ts +3 -0
- package/test/null-response.test.mjs +73 -0
- package/test/public-api.test.mjs +348 -0
- package/tsconfig.json +1 -2
- package/.devcontainer/devcontainer.json +0 -45
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as z from "zod/v3";
|
|
6
|
-
import { safeParse } from "../lib/schemas.js";
|
|
6
|
+
import { nullToUndefined, safeParse } from "../lib/schemas.js";
|
|
7
7
|
import { ClosedEnum } from "../types/enums.js";
|
|
8
8
|
import { Result as SafeParseResult } from "../types/fp.js";
|
|
9
9
|
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
@@ -47,15 +47,59 @@ export type Similarity = ClosedEnum<typeof Similarity>;
|
|
|
47
47
|
export type IndexConfigsVector = {
|
|
48
48
|
type: "vector";
|
|
49
49
|
/**
|
|
50
|
-
*
|
|
50
|
+
* Set to false or omit for unmanaged vector fields.
|
|
51
|
+
*/
|
|
52
|
+
managedEmbedding?: false | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Vector dimensions for unmanaged vector fields.
|
|
51
55
|
*/
|
|
52
56
|
dimensions: number;
|
|
53
57
|
/**
|
|
54
|
-
* Vector similarity metric.
|
|
58
|
+
* Vector similarity metric for unmanaged vector fields.
|
|
59
|
+
*/
|
|
60
|
+
similarity?: Similarity | undefined;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const EmbeddingProvider = {
|
|
64
|
+
Openai: "openai",
|
|
65
|
+
} as const;
|
|
66
|
+
export type EmbeddingProvider = ClosedEnum<typeof EmbeddingProvider>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Managed embedding configuration for vector fields.
|
|
70
|
+
*/
|
|
71
|
+
export type EmbeddingConfig = {
|
|
72
|
+
/**
|
|
73
|
+
* Embedding provider.
|
|
74
|
+
*/
|
|
75
|
+
provider: EmbeddingProvider;
|
|
76
|
+
/**
|
|
77
|
+
* Embedding model name. See /guides/collections/managed-embeddings for the current supported providers and models.
|
|
78
|
+
*/
|
|
79
|
+
model: string;
|
|
80
|
+
/**
|
|
81
|
+
* Source text field name used to generate embeddings.
|
|
82
|
+
*/
|
|
83
|
+
sourceField: string;
|
|
84
|
+
/**
|
|
85
|
+
* Resolved embedding dimensions. Optional in requests and resolved in stored collection metadata.
|
|
86
|
+
*/
|
|
87
|
+
dimensions?: number | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Resolved vector similarity metric. Optional in requests and resolved in stored collection metadata.
|
|
55
90
|
*/
|
|
56
91
|
similarity?: Similarity | undefined;
|
|
57
92
|
};
|
|
58
93
|
|
|
94
|
+
export type IndexConfigsManagedEmbeddingVector = {
|
|
95
|
+
type: "vector";
|
|
96
|
+
/**
|
|
97
|
+
* Managed embedding vector field.
|
|
98
|
+
*/
|
|
99
|
+
managedEmbedding: true;
|
|
100
|
+
embedding: EmbeddingConfig;
|
|
101
|
+
};
|
|
102
|
+
|
|
59
103
|
export const Analyzer = {
|
|
60
104
|
Standard: "standard",
|
|
61
105
|
Korean: "korean",
|
|
@@ -75,6 +119,7 @@ export type IndexConfigsText = {
|
|
|
75
119
|
export type IndexConfigsUnion =
|
|
76
120
|
| IndexConfigsText
|
|
77
121
|
| IndexConfigsVector
|
|
122
|
+
| IndexConfigsManagedEmbeddingVector
|
|
78
123
|
| (IndexConfigs & { type: "keyword" })
|
|
79
124
|
| (IndexConfigs & { type: "long" })
|
|
80
125
|
| (IndexConfigs & { type: "double" })
|
|
@@ -181,12 +226,14 @@ export const IndexConfigsVector$inboundSchema: z.ZodType<
|
|
|
181
226
|
unknown
|
|
182
227
|
> = z.object({
|
|
183
228
|
type: z.literal("vector"),
|
|
229
|
+
managedEmbedding: nullToUndefined(z.literal(false).optional()),
|
|
184
230
|
dimensions: z.number().int(),
|
|
185
|
-
similarity: Similarity$inboundSchema.default("cosine"),
|
|
231
|
+
similarity: nullToUndefined(Similarity$inboundSchema.default("cosine")),
|
|
186
232
|
});
|
|
187
233
|
/** @internal */
|
|
188
234
|
export type IndexConfigsVector$Outbound = {
|
|
189
235
|
type: "vector";
|
|
236
|
+
managedEmbedding?: false | undefined;
|
|
190
237
|
dimensions: number;
|
|
191
238
|
similarity: string;
|
|
192
239
|
};
|
|
@@ -198,6 +245,7 @@ export const IndexConfigsVector$outboundSchema: z.ZodType<
|
|
|
198
245
|
IndexConfigsVector
|
|
199
246
|
> = z.object({
|
|
200
247
|
type: z.literal("vector"),
|
|
248
|
+
managedEmbedding: z.literal(false).optional(),
|
|
201
249
|
dimensions: z.number().int(),
|
|
202
250
|
similarity: Similarity$outboundSchema.default("cosine"),
|
|
203
251
|
});
|
|
@@ -219,6 +267,112 @@ export function indexConfigsVectorFromJSON(
|
|
|
219
267
|
);
|
|
220
268
|
}
|
|
221
269
|
|
|
270
|
+
/** @internal */
|
|
271
|
+
export const EmbeddingProvider$inboundSchema: z.ZodNativeEnum<
|
|
272
|
+
typeof EmbeddingProvider
|
|
273
|
+
> = z.nativeEnum(EmbeddingProvider);
|
|
274
|
+
/** @internal */
|
|
275
|
+
export const EmbeddingProvider$outboundSchema: z.ZodNativeEnum<
|
|
276
|
+
typeof EmbeddingProvider
|
|
277
|
+
> = EmbeddingProvider$inboundSchema;
|
|
278
|
+
|
|
279
|
+
/** @internal */
|
|
280
|
+
export const EmbeddingConfig$inboundSchema: z.ZodType<
|
|
281
|
+
EmbeddingConfig,
|
|
282
|
+
z.ZodTypeDef,
|
|
283
|
+
unknown
|
|
284
|
+
> = z.object({
|
|
285
|
+
provider: EmbeddingProvider$inboundSchema,
|
|
286
|
+
model: z.string(),
|
|
287
|
+
sourceField: z.string(),
|
|
288
|
+
dimensions: nullToUndefined(z.number().int().optional()),
|
|
289
|
+
similarity: nullToUndefined(Similarity$inboundSchema.default("cosine")),
|
|
290
|
+
});
|
|
291
|
+
/** @internal */
|
|
292
|
+
export type EmbeddingConfig$Outbound = {
|
|
293
|
+
provider: string;
|
|
294
|
+
model: string;
|
|
295
|
+
sourceField: string;
|
|
296
|
+
dimensions?: number | undefined;
|
|
297
|
+
similarity?: string | undefined;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
/** @internal */
|
|
301
|
+
export const EmbeddingConfig$outboundSchema: z.ZodType<
|
|
302
|
+
EmbeddingConfig$Outbound,
|
|
303
|
+
z.ZodTypeDef,
|
|
304
|
+
EmbeddingConfig
|
|
305
|
+
> = z.object({
|
|
306
|
+
provider: EmbeddingProvider$outboundSchema,
|
|
307
|
+
model: z.string(),
|
|
308
|
+
sourceField: z.string(),
|
|
309
|
+
dimensions: z.number().int().optional(),
|
|
310
|
+
similarity: Similarity$outboundSchema.optional(),
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
export function embeddingConfigToJSON(
|
|
314
|
+
embeddingConfig: EmbeddingConfig,
|
|
315
|
+
): string {
|
|
316
|
+
return JSON.stringify(EmbeddingConfig$outboundSchema.parse(embeddingConfig));
|
|
317
|
+
}
|
|
318
|
+
export function embeddingConfigFromJSON(
|
|
319
|
+
jsonString: string,
|
|
320
|
+
): SafeParseResult<EmbeddingConfig, SDKValidationError> {
|
|
321
|
+
return safeParse(
|
|
322
|
+
jsonString,
|
|
323
|
+
(x) => EmbeddingConfig$inboundSchema.parse(JSON.parse(x)),
|
|
324
|
+
`Failed to parse 'EmbeddingConfig' from JSON`,
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** @internal */
|
|
329
|
+
export const IndexConfigsManagedEmbeddingVector$inboundSchema: z.ZodType<
|
|
330
|
+
IndexConfigsManagedEmbeddingVector,
|
|
331
|
+
z.ZodTypeDef,
|
|
332
|
+
unknown
|
|
333
|
+
> = z.object({
|
|
334
|
+
type: z.literal("vector"),
|
|
335
|
+
managedEmbedding: z.literal(true),
|
|
336
|
+
embedding: z.lazy(() => EmbeddingConfig$inboundSchema),
|
|
337
|
+
});
|
|
338
|
+
/** @internal */
|
|
339
|
+
export type IndexConfigsManagedEmbeddingVector$Outbound = {
|
|
340
|
+
type: "vector";
|
|
341
|
+
managedEmbedding: true;
|
|
342
|
+
embedding: EmbeddingConfig$Outbound;
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
/** @internal */
|
|
346
|
+
export const IndexConfigsManagedEmbeddingVector$outboundSchema: z.ZodType<
|
|
347
|
+
IndexConfigsManagedEmbeddingVector$Outbound,
|
|
348
|
+
z.ZodTypeDef,
|
|
349
|
+
IndexConfigsManagedEmbeddingVector
|
|
350
|
+
> = z.object({
|
|
351
|
+
type: z.literal("vector"),
|
|
352
|
+
managedEmbedding: z.literal(true),
|
|
353
|
+
embedding: z.lazy(() => EmbeddingConfig$outboundSchema),
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
export function indexConfigsManagedEmbeddingVectorToJSON(
|
|
357
|
+
indexConfigsManagedEmbeddingVector: IndexConfigsManagedEmbeddingVector,
|
|
358
|
+
): string {
|
|
359
|
+
return JSON.stringify(
|
|
360
|
+
IndexConfigsManagedEmbeddingVector$outboundSchema.parse(
|
|
361
|
+
indexConfigsManagedEmbeddingVector,
|
|
362
|
+
),
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
export function indexConfigsManagedEmbeddingVectorFromJSON(
|
|
366
|
+
jsonString: string,
|
|
367
|
+
): SafeParseResult<IndexConfigsManagedEmbeddingVector, SDKValidationError> {
|
|
368
|
+
return safeParse(
|
|
369
|
+
jsonString,
|
|
370
|
+
(x) =>
|
|
371
|
+
IndexConfigsManagedEmbeddingVector$inboundSchema.parse(JSON.parse(x)),
|
|
372
|
+
`Failed to parse 'IndexConfigsManagedEmbeddingVector' from JSON`,
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
|
|
222
376
|
/** @internal */
|
|
223
377
|
export const Analyzer$inboundSchema: z.ZodNativeEnum<typeof Analyzer> = z
|
|
224
378
|
.nativeEnum(Analyzer);
|
|
@@ -233,7 +387,7 @@ export const IndexConfigsText$inboundSchema: z.ZodType<
|
|
|
233
387
|
unknown
|
|
234
388
|
> = z.object({
|
|
235
389
|
type: z.literal("text"),
|
|
236
|
-
analyzers: z.array(Analyzer$inboundSchema).optional(),
|
|
390
|
+
analyzers: nullToUndefined(z.array(Analyzer$inboundSchema).optional()),
|
|
237
391
|
});
|
|
238
392
|
/** @internal */
|
|
239
393
|
export type IndexConfigsText$Outbound = {
|
|
@@ -276,6 +430,7 @@ export const IndexConfigsUnion$inboundSchema: z.ZodType<
|
|
|
276
430
|
> = z.union([
|
|
277
431
|
z.lazy(() => IndexConfigsText$inboundSchema),
|
|
278
432
|
z.lazy(() => IndexConfigsVector$inboundSchema),
|
|
433
|
+
z.lazy(() => IndexConfigsManagedEmbeddingVector$inboundSchema),
|
|
279
434
|
z.lazy(() => IndexConfigs$inboundSchema).and(
|
|
280
435
|
z.object({ type: z.literal("keyword") }),
|
|
281
436
|
),
|
|
@@ -300,6 +455,7 @@ export const IndexConfigsUnion$inboundSchema: z.ZodType<
|
|
|
300
455
|
export type IndexConfigsUnion$Outbound =
|
|
301
456
|
| IndexConfigsText$Outbound
|
|
302
457
|
| IndexConfigsVector$Outbound
|
|
458
|
+
| IndexConfigsManagedEmbeddingVector$Outbound
|
|
303
459
|
| (IndexConfigs$Outbound & { type: "keyword" })
|
|
304
460
|
| (IndexConfigs$Outbound & { type: "long" })
|
|
305
461
|
| (IndexConfigs$Outbound & { type: "double" })
|
|
@@ -316,6 +472,7 @@ export const IndexConfigsUnion$outboundSchema: z.ZodType<
|
|
|
316
472
|
> = z.union([
|
|
317
473
|
z.lazy(() => IndexConfigsText$outboundSchema),
|
|
318
474
|
z.lazy(() => IndexConfigsVector$outboundSchema),
|
|
475
|
+
z.lazy(() => IndexConfigsManagedEmbeddingVector$outboundSchema),
|
|
319
476
|
z.lazy(() => IndexConfigs$outboundSchema).and(
|
|
320
477
|
z.object({ type: z.literal("keyword") }),
|
|
321
478
|
),
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import * as z from "zod/v3";
|
|
6
6
|
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
-
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
import { nullToUndefined, safeParse } from "../../lib/schemas.js";
|
|
8
8
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
9
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
10
|
import * as models from "../index.js";
|
|
@@ -153,7 +153,7 @@ export const FetchDocsResponse$inboundSchema: z.ZodType<
|
|
|
153
153
|
took: z.number().int(),
|
|
154
154
|
docs: z.array(z.lazy(() => FetchDocsDoc$inboundSchema)),
|
|
155
155
|
isDocsInline: z.boolean(),
|
|
156
|
-
docsUrl: z.string().optional(),
|
|
156
|
+
docsUrl: nullToUndefined(z.string().optional()),
|
|
157
157
|
});
|
|
158
158
|
|
|
159
159
|
export function fetchDocsResponseFromJSON(
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as z from "zod/v3";
|
|
6
|
-
import { safeParse } from "../../lib/schemas.js";
|
|
6
|
+
import { nullToUndefined, safeParse } from "../../lib/schemas.js";
|
|
7
7
|
import { ClosedEnum } from "../../types/enums.js";
|
|
8
8
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
9
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
@@ -101,10 +101,10 @@ export const GetBulkUpsertDocsResponse$inboundSchema: z.ZodType<
|
|
|
101
101
|
unknown
|
|
102
102
|
> = z.object({
|
|
103
103
|
url: z.string(),
|
|
104
|
-
type: Type$inboundSchema.default("application/json"),
|
|
105
|
-
httpMethod: HttpMethod$inboundSchema.default("PUT"),
|
|
104
|
+
type: nullToUndefined(Type$inboundSchema.default("application/json")),
|
|
105
|
+
httpMethod: nullToUndefined(HttpMethod$inboundSchema.default("PUT")),
|
|
106
106
|
objectKey: z.string(),
|
|
107
|
-
sizeLimitBytes: z.number().int().default(209715200),
|
|
107
|
+
sizeLimitBytes: nullToUndefined(z.number().int().default(209715200)),
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
export function getBulkUpsertDocsResponseFromJSON(
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as z from "zod/v3";
|
|
6
|
-
import { safeParse } from "../../lib/schemas.js";
|
|
6
|
+
import { nullToUndefined, safeParse } from "../../lib/schemas.js";
|
|
7
7
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
8
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
9
9
|
import * as models from "../index.js";
|
|
@@ -50,7 +50,7 @@ export const ListCollectionsResponse$inboundSchema: z.ZodType<
|
|
|
50
50
|
unknown
|
|
51
51
|
> = z.object({
|
|
52
52
|
collections: z.array(models.CollectionResponse$inboundSchema),
|
|
53
|
-
nextPageToken: z.string().optional(),
|
|
53
|
+
nextPageToken: nullToUndefined(z.string().optional()),
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
export function listCollectionsResponseFromJSON(
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as z from "zod/v3";
|
|
6
|
-
import { safeParse } from "../../lib/schemas.js";
|
|
6
|
+
import { nullToUndefined, safeParse } from "../../lib/schemas.js";
|
|
7
7
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
8
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
9
9
|
|
|
@@ -89,9 +89,9 @@ export const ListDocsResponse$inboundSchema: z.ZodType<
|
|
|
89
89
|
> = z.object({
|
|
90
90
|
total: z.number().int(),
|
|
91
91
|
docs: z.array(ListDocsDoc$inboundSchema),
|
|
92
|
-
nextPageToken: z.string().optional(),
|
|
92
|
+
nextPageToken: nullToUndefined(z.string().optional()),
|
|
93
93
|
isDocsInline: z.boolean(),
|
|
94
|
-
docsUrl: z.string().optional(),
|
|
94
|
+
docsUrl: nullToUndefined(z.string().optional()),
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
export function listDocsResponseFromJSON(
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import * as z from "zod/v3";
|
|
6
6
|
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
-
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
import { nullToUndefined, safeParse } from "../../lib/schemas.js";
|
|
8
8
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
9
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
10
|
import * as models from "../index.js";
|
|
@@ -15,7 +15,7 @@ export type QueryCollectionRequestBody = {
|
|
|
15
15
|
*/
|
|
16
16
|
size?: number | undefined;
|
|
17
17
|
/**
|
|
18
|
-
* Query object.
|
|
18
|
+
* Query object. For managed embedding vector fields, use knn.queryText. For unmanaged vector fields, use knn.queryVector.
|
|
19
19
|
*/
|
|
20
20
|
query: { [k: string]: any };
|
|
21
21
|
/**
|
|
@@ -156,7 +156,7 @@ export const QueryCollectionDoc$inboundSchema: z.ZodType<
|
|
|
156
156
|
unknown
|
|
157
157
|
> = z.object({
|
|
158
158
|
collection: z.string(),
|
|
159
|
-
score: z.number().optional(),
|
|
159
|
+
score: nullToUndefined(z.number().optional()),
|
|
160
160
|
doc: z.record(z.any()),
|
|
161
161
|
});
|
|
162
162
|
|
|
@@ -177,11 +177,11 @@ export const QueryCollectionResponse$inboundSchema: z.ZodType<
|
|
|
177
177
|
unknown
|
|
178
178
|
> = z.object({
|
|
179
179
|
took: z.number().int(),
|
|
180
|
-
maxScore: z.number().optional(),
|
|
180
|
+
maxScore: nullToUndefined(z.number().optional()),
|
|
181
181
|
total: z.number().int(),
|
|
182
182
|
docs: z.array(z.lazy(() => QueryCollectionDoc$inboundSchema)),
|
|
183
183
|
isDocsInline: z.boolean(),
|
|
184
|
-
docsUrl: z.string().optional(),
|
|
184
|
+
docsUrl: nullToUndefined(z.string().optional()),
|
|
185
185
|
});
|
|
186
186
|
|
|
187
187
|
export function queryCollectionResponseFromJSON(
|
|
@@ -7,7 +7,7 @@ import { remap as remap$ } from "../../lib/primitives.js";
|
|
|
7
7
|
|
|
8
8
|
export type UpdateDocsRequestBody = {
|
|
9
9
|
/**
|
|
10
|
-
* A list of documents to update. Each document must contain 'id' field to be updated.
|
|
10
|
+
* A list of documents to update. Each document must contain 'id' field to be updated. For managed embedding vector fields, omit the managed vector field and update only the configured source text field.
|
|
11
11
|
*/
|
|
12
12
|
docs: Array<{ [k: string]: any }>;
|
|
13
13
|
};
|
|
@@ -7,7 +7,7 @@ import { remap as remap$ } from "../../lib/primitives.js";
|
|
|
7
7
|
|
|
8
8
|
export type UpsertDocsRequestBody = {
|
|
9
9
|
/**
|
|
10
|
-
* A list of documents to upsert.
|
|
10
|
+
* A list of documents to upsert. For managed embedding vector fields, omit the managed vector field and provide only the configured source text field.
|
|
11
11
|
*/
|
|
12
12
|
docs: Array<{ [k: string]: any }>;
|
|
13
13
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as z from "zod/v3";
|
|
6
|
-
import { safeParse } from "../lib/schemas.js";
|
|
6
|
+
import { nullToUndefined, safeParse } from "../lib/schemas.js";
|
|
7
7
|
import { ClosedEnum } from "../types/enums.js";
|
|
8
8
|
import { Result as SafeParseResult } from "../types/fp.js";
|
|
9
9
|
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
@@ -47,9 +47,9 @@ export const PartitionConfig$inboundSchema: z.ZodType<
|
|
|
47
47
|
z.ZodTypeDef,
|
|
48
48
|
unknown
|
|
49
49
|
> = z.object({
|
|
50
|
-
fieldName: z.string().optional(),
|
|
51
|
-
dataType: DataType$inboundSchema.optional(),
|
|
52
|
-
numPartitions: z.number().int().optional(),
|
|
50
|
+
fieldName: nullToUndefined(z.string().optional()),
|
|
51
|
+
dataType: nullToUndefined(DataType$inboundSchema.optional()),
|
|
52
|
+
numPartitions: nullToUndefined(z.number().int().optional()),
|
|
53
53
|
});
|
|
54
54
|
/** @internal */
|
|
55
55
|
export type PartitionConfig$Outbound = {
|
package/src/sdk/docs.ts
CHANGED
|
@@ -47,7 +47,7 @@ export class Docs extends ClientSDK {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* Request required info to upload documents.
|
|
50
|
+
* Request required info to upload documents. Bulk upsert is not supported for collections with managed embedding vector fields.
|
|
51
51
|
*/
|
|
52
52
|
async getBulkUpsert(
|
|
53
53
|
request: operations.GetBulkUpsertDocsRequest,
|
|
@@ -61,7 +61,7 @@ export class Docs extends ClientSDK {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* Bulk upsert documents into a collection. Note that the maximum supported object size is 200MB.
|
|
64
|
+
* Bulk upsert documents into a collection. Note that the maximum supported object size is 200MB. Bulk upsert is not supported for collections with managed embedding vector fields.
|
|
65
65
|
*/
|
|
66
66
|
async bulkUpsert(
|
|
67
67
|
request: operations.BulkUpsertDocsRequest,
|
package/src/types/errors.ts
CHANGED
|
@@ -94,4 +94,6 @@ export type FetchDocsError = UpdateCollectionError;
|
|
|
94
94
|
export type BulkUpsertDocsError = UpdateCollectionError;
|
|
95
95
|
|
|
96
96
|
/** Errors that can occur when getting bulk upsert docs info. */
|
|
97
|
-
export type GetBulkUpsertDocsError =
|
|
97
|
+
export type GetBulkUpsertDocsError =
|
|
98
|
+
| errors.BadRequestError
|
|
99
|
+
| ListCollectionsError;
|
package/src/types/public.ts
CHANGED
|
@@ -48,6 +48,9 @@ export type { GetBulkUpsertDocsResponse } from "../models/operations/getbulkupse
|
|
|
48
48
|
// ---- Models referenced by request/response bodies ----
|
|
49
49
|
export type {
|
|
50
50
|
IndexConfigsUnion,
|
|
51
|
+
IndexConfigsManagedEmbeddingVector,
|
|
52
|
+
EmbeddingConfig,
|
|
53
|
+
EmbeddingProvider,
|
|
51
54
|
PartitionConfig,
|
|
52
55
|
PartitionFilter,
|
|
53
56
|
FieldsSelectorUnion,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
|
|
4
|
+
import { LambdaDBClient } from "../dist/esm/index.js";
|
|
5
|
+
import { HTTPClient } from "../dist/esm/lib/http.js";
|
|
6
|
+
import { ResponseValidationError } from "../dist/esm/models/errors/responsevalidationerror.js";
|
|
7
|
+
import { QueryCollectionResponse$inboundSchema } from "../dist/esm/models/operations/querycollection.js";
|
|
8
|
+
|
|
9
|
+
function jsonResponse(body, init = {}) {
|
|
10
|
+
return new Response(JSON.stringify(body), {
|
|
11
|
+
status: 200,
|
|
12
|
+
headers: { "content-type": "application/json" },
|
|
13
|
+
...init,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
test("response schemas accept null for optional response fields", () => {
|
|
18
|
+
const parsed = QueryCollectionResponse$inboundSchema.parse({
|
|
19
|
+
took: 1,
|
|
20
|
+
maxScore: null,
|
|
21
|
+
total: 1,
|
|
22
|
+
docs: [{ collection: "items", score: null, doc: { id: "a" } }],
|
|
23
|
+
isDocsInline: false,
|
|
24
|
+
docsUrl: null,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
assert.equal(parsed.maxScore, undefined);
|
|
28
|
+
assert.equal(parsed.docsUrl, undefined);
|
|
29
|
+
assert.equal(parsed.docs[0].score, undefined);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("safe methods return ResponseValidationError for invalid JSON bodies", async () => {
|
|
33
|
+
const httpClient = new HTTPClient({
|
|
34
|
+
fetcher: async () =>
|
|
35
|
+
new Response("{", {
|
|
36
|
+
status: 200,
|
|
37
|
+
headers: { "content-type": "application/json" },
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
const client = new LambdaDBClient({ httpClient, projectApiKey: "test-key" });
|
|
41
|
+
|
|
42
|
+
const result = await client.listCollectionsSafe();
|
|
43
|
+
|
|
44
|
+
assert.equal(result.ok, false);
|
|
45
|
+
assert.ok(result.error instanceof ResponseValidationError);
|
|
46
|
+
assert.equal(result.error.rawValue, "{");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("docsUrl fetches treat null document payloads as an empty docs array", async () => {
|
|
50
|
+
const originalFetch = globalThis.fetch;
|
|
51
|
+
globalThis.fetch = async () => jsonResponse(null);
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const httpClient = new HTTPClient({
|
|
55
|
+
fetcher: async () =>
|
|
56
|
+
jsonResponse({
|
|
57
|
+
total: 1,
|
|
58
|
+
docs: [],
|
|
59
|
+
isDocsInline: false,
|
|
60
|
+
docsUrl: "https://example.test/docs.json",
|
|
61
|
+
}),
|
|
62
|
+
});
|
|
63
|
+
const client = new LambdaDBClient({ httpClient, projectApiKey: "test-key" });
|
|
64
|
+
|
|
65
|
+
const result = await client.collection("items").docs.listSafe();
|
|
66
|
+
|
|
67
|
+
assert.equal(result.ok, true);
|
|
68
|
+
assert.deepEqual(result.value.docs, []);
|
|
69
|
+
assert.equal(result.value.isDocsInline, true);
|
|
70
|
+
} finally {
|
|
71
|
+
globalThis.fetch = originalFetch;
|
|
72
|
+
}
|
|
73
|
+
});
|