@functional-systems/lambdadb 0.3.3 → 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.
Files changed (58) hide show
  1. package/README.md +44 -2
  2. package/dist/commonjs/client.d.ts +6 -6
  3. package/dist/commonjs/client.js +6 -6
  4. package/dist/commonjs/funcs/collectionsDocsBulkUpsert.d.ts +1 -1
  5. package/dist/commonjs/funcs/collectionsDocsBulkUpsert.js +1 -1
  6. package/dist/commonjs/funcs/collectionsDocsGetBulkUpsert.d.ts +2 -2
  7. package/dist/commonjs/funcs/collectionsDocsGetBulkUpsert.d.ts.map +1 -1
  8. package/dist/commonjs/funcs/collectionsDocsGetBulkUpsert.js +3 -3
  9. package/dist/commonjs/funcs/collectionsDocsGetBulkUpsert.js.map +1 -1
  10. package/dist/commonjs/models/indexconfigsunion.d.ts +76 -4
  11. package/dist/commonjs/models/indexconfigsunion.d.ts.map +1 -1
  12. package/dist/commonjs/models/indexconfigsunion.js +56 -1
  13. package/dist/commonjs/models/indexconfigsunion.js.map +1 -1
  14. package/dist/commonjs/models/operations/querycollection.d.ts +1 -1
  15. package/dist/commonjs/models/operations/updatedocs.d.ts +1 -1
  16. package/dist/commonjs/models/operations/upsertdocs.d.ts +1 -1
  17. package/dist/commonjs/sdk/docs.d.ts +2 -2
  18. package/dist/commonjs/sdk/docs.js +2 -2
  19. package/dist/commonjs/types/errors.d.ts +1 -1
  20. package/dist/commonjs/types/errors.d.ts.map +1 -1
  21. package/dist/commonjs/types/public.d.ts +1 -1
  22. package/dist/commonjs/types/public.d.ts.map +1 -1
  23. package/dist/commonjs/types/public.js.map +1 -1
  24. package/dist/esm/client.d.ts +6 -6
  25. package/dist/esm/client.js +6 -6
  26. package/dist/esm/funcs/collectionsDocsBulkUpsert.d.ts +1 -1
  27. package/dist/esm/funcs/collectionsDocsBulkUpsert.js +1 -1
  28. package/dist/esm/funcs/collectionsDocsGetBulkUpsert.d.ts +2 -2
  29. package/dist/esm/funcs/collectionsDocsGetBulkUpsert.d.ts.map +1 -1
  30. package/dist/esm/funcs/collectionsDocsGetBulkUpsert.js +3 -3
  31. package/dist/esm/funcs/collectionsDocsGetBulkUpsert.js.map +1 -1
  32. package/dist/esm/models/indexconfigsunion.d.ts +76 -4
  33. package/dist/esm/models/indexconfigsunion.d.ts.map +1 -1
  34. package/dist/esm/models/indexconfigsunion.js +51 -0
  35. package/dist/esm/models/indexconfigsunion.js.map +1 -1
  36. package/dist/esm/models/operations/querycollection.d.ts +1 -1
  37. package/dist/esm/models/operations/updatedocs.d.ts +1 -1
  38. package/dist/esm/models/operations/upsertdocs.d.ts +1 -1
  39. package/dist/esm/sdk/docs.d.ts +2 -2
  40. package/dist/esm/sdk/docs.js +2 -2
  41. package/dist/esm/types/errors.d.ts +1 -1
  42. package/dist/esm/types/errors.d.ts.map +1 -1
  43. package/dist/esm/types/public.d.ts +1 -1
  44. package/dist/esm/types/public.d.ts.map +1 -1
  45. package/dist/esm/types/public.js.map +1 -1
  46. package/package.json +1 -1
  47. package/src/client.ts +6 -6
  48. package/src/funcs/collectionsDocsBulkUpsert.ts +1 -1
  49. package/src/funcs/collectionsDocsGetBulkUpsert.ts +6 -2
  50. package/src/models/indexconfigsunion.ts +159 -2
  51. package/src/models/operations/querycollection.ts +1 -1
  52. package/src/models/operations/updatedocs.ts +1 -1
  53. package/src/models/operations/upsertdocs.ts +1 -1
  54. package/src/sdk/docs.ts +2 -2
  55. package/src/types/errors.ts +3 -1
  56. package/src/types/public.ts +3 -0
  57. package/test/public-api.test.mjs +138 -0
  58. package/tsconfig.json +1 -2
package/src/client.ts CHANGED
@@ -675,7 +675,7 @@ class CollectionDocs {
675
675
  }
676
676
 
677
677
  /**
678
- * Get presigned URL and metadata for bulk upload (up to 200MB).
678
+ * Get presigned URL and metadata for bulk upload (up to 200MB). Not supported for collections with managed embedding vector fields.
679
679
  */
680
680
  async getBulkUpsert(options?: RequestOptions) {
681
681
  return unwrapAsync(
@@ -688,7 +688,7 @@ class CollectionDocs {
688
688
  }
689
689
 
690
690
  /**
691
- * Get presigned URL and metadata for bulk upload (Safe: returns Result instead of throwing).
691
+ * Get presigned URL and metadata for bulk upload (Safe: returns Result instead of throwing). Not supported for collections with managed embedding vector fields.
692
692
  */
693
693
  async getBulkUpsertSafe(
694
694
  options?: RequestOptions,
@@ -701,7 +701,7 @@ class CollectionDocs {
701
701
  }
702
702
 
703
703
  /**
704
- * Trigger bulk upsert with an object key from getBulkUpsert().
704
+ * Trigger bulk upsert with an object key from getBulkUpsert(). Not supported for collections with managed embedding vector fields.
705
705
  */
706
706
  async bulkUpsert(
707
707
  body: BulkUpsertInput,
@@ -720,7 +720,7 @@ class CollectionDocs {
720
720
  }
721
721
 
722
722
  /**
723
- * Trigger bulk upsert (Safe: returns Result instead of throwing).
723
+ * Trigger bulk upsert (Safe: returns Result instead of throwing). Not supported for collections with managed embedding vector fields.
724
724
  */
725
725
  async bulkUpsertSafe(
726
726
  body: BulkUpsertInput,
@@ -734,7 +734,7 @@ class CollectionDocs {
734
734
  }
735
735
 
736
736
  /**
737
- * Bulk upsert documents in one call (up to 200MB). Abstracts getBulkUpsert,
737
+ * Bulk upsert documents in one call (up to 200MB). Not supported for collections with managed embedding vector fields. Abstracts getBulkUpsert,
738
738
  * S3 upload via presigned URL, and bulkUpsert. Use this for better DX when
739
739
  * you have a document list; use getBulkUpsert + bulkUpsert for low-level control.
740
740
  */
@@ -770,7 +770,7 @@ class CollectionDocs {
770
770
  }
771
771
 
772
772
  /**
773
- * Bulk upsert documents in one call (Safe: returns Result instead of throwing).
773
+ * Bulk upsert documents in one call (Safe: returns Result instead of throwing). Not supported for collections with managed embedding vector fields.
774
774
  * May return Error for local failures (payload size, upload). API errors use GetBulkUpsertDocsError or BulkUpsertDocsError.
775
775
  */
776
776
  async bulkUpsertDocsSafe(
@@ -27,7 +27,7 @@ import { APICall, APIPromise } from "../types/async.js";
27
27
  import { Result } from "../types/fp.js";
28
28
 
29
29
  /**
30
- * Bulk upsert documents into a collection. Note that the maximum supported object size is 200MB.
30
+ * 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.
31
31
  */
32
32
  export function collectionsDocsBulkUpsert(
33
33
  client: LambdaDBCore,
@@ -26,7 +26,7 @@ import { APICall, APIPromise } from "../types/async.js";
26
26
  import { Result } from "../types/fp.js";
27
27
 
28
28
  /**
29
- * Request required info to upload documents.
29
+ * Request required info to upload documents. Bulk upsert is not supported for collections with managed embedding vector fields.
30
30
  */
31
31
  export function collectionsDocsGetBulkUpsert(
32
32
  client: LambdaDBCore,
@@ -35,6 +35,7 @@ export function collectionsDocsGetBulkUpsert(
35
35
  ): APIPromise<
36
36
  Result<
37
37
  operations.GetBulkUpsertDocsResponse,
38
+ | errors.BadRequestError
38
39
  | errors.UnauthenticatedError
39
40
  | errors.ResourceNotFoundError
40
41
  | errors.TooManyRequestsError
@@ -64,6 +65,7 @@ async function $do(
64
65
  [
65
66
  Result<
66
67
  operations.GetBulkUpsertDocsResponse,
68
+ | errors.BadRequestError
67
69
  | errors.UnauthenticatedError
68
70
  | errors.ResourceNotFoundError
69
71
  | errors.TooManyRequestsError
@@ -152,7 +154,7 @@ async function $do(
152
154
 
153
155
  const doResult = await client._do(req, {
154
156
  context,
155
- errorCodes: ["401", "404", "429", "4XX", "500", "5XX"],
157
+ errorCodes: ["400", "401", "404", "429", "4XX", "500", "5XX"],
156
158
  retryConfig: context.retryConfig,
157
159
  retryCodes: context.retryCodes,
158
160
  });
@@ -167,6 +169,7 @@ async function $do(
167
169
 
168
170
  const [result] = await M.match<
169
171
  operations.GetBulkUpsertDocsResponse,
172
+ | errors.BadRequestError
170
173
  | errors.UnauthenticatedError
171
174
  | errors.ResourceNotFoundError
172
175
  | errors.TooManyRequestsError
@@ -181,6 +184,7 @@ async function $do(
181
184
  | SDKValidationError
182
185
  >(
183
186
  M.json(200, operations.GetBulkUpsertDocsResponse$inboundSchema),
187
+ M.jsonErr(400, errors.BadRequestError$inboundSchema),
184
188
  M.jsonErr(401, errors.UnauthenticatedError$inboundSchema),
185
189
  M.jsonErr(404, errors.ResourceNotFoundError$inboundSchema),
186
190
  M.jsonErr(429, errors.TooManyRequestsError$inboundSchema),
@@ -47,15 +47,59 @@ export type Similarity = ClosedEnum<typeof Similarity>;
47
47
  export type IndexConfigsVector = {
48
48
  type: "vector";
49
49
  /**
50
- * Vector dimensions.
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
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);
@@ -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
  ),
@@ -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
  /**
@@ -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
  };
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,
@@ -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 = ListCollectionsError;
97
+ export type GetBulkUpsertDocsError =
98
+ | errors.BadRequestError
99
+ | ListCollectionsError;
@@ -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,
@@ -83,6 +83,144 @@ test("public client lists collections with project URL, auth header, and Date co
83
83
  assert.equal(result.collections[0].createdAt.toISOString(), "2023-11-14T22:13:20.000Z");
84
84
  });
85
85
 
86
+ test("public client supports managed embedding vector index configs", async () => {
87
+ const managedIndexConfigs = {
88
+ body: {
89
+ type: "text",
90
+ analyzers: ["english"],
91
+ },
92
+ bodyEmbedding: {
93
+ type: "vector",
94
+ managedEmbedding: true,
95
+ embedding: {
96
+ provider: "openai",
97
+ model: "text-embedding-3-small",
98
+ sourceField: "body",
99
+ },
100
+ },
101
+ };
102
+
103
+ const { calls, client } = createClient((call) => {
104
+ assert.equal(call.method, "POST");
105
+ assert.equal(call.url.pathname, "/projects/project-one/collections");
106
+ assert.deepEqual(JSON.parse(call.body), {
107
+ collectionName: "semantic-items",
108
+ indexConfigs: {
109
+ body: {
110
+ type: "text",
111
+ analyzers: ["english"],
112
+ },
113
+ bodyEmbedding: {
114
+ type: "vector",
115
+ managedEmbedding: true,
116
+ embedding: {
117
+ provider: "openai",
118
+ model: "text-embedding-3-small",
119
+ sourceField: "body",
120
+ },
121
+ },
122
+ },
123
+ });
124
+
125
+ return jsonResponse(
126
+ {
127
+ collection: collectionFixture("semantic-items", {
128
+ indexConfigs: {
129
+ ...managedIndexConfigs,
130
+ bodyEmbedding: {
131
+ ...managedIndexConfigs.bodyEmbedding,
132
+ embedding: {
133
+ ...managedIndexConfigs.bodyEmbedding.embedding,
134
+ dimensions: 1536,
135
+ similarity: "cosine",
136
+ },
137
+ },
138
+ },
139
+ }),
140
+ },
141
+ { status: 202 },
142
+ );
143
+ });
144
+
145
+ const result = await client.createCollection({
146
+ collectionName: "semantic-items",
147
+ indexConfigs: managedIndexConfigs,
148
+ });
149
+
150
+ assert.equal(calls.length, 1);
151
+ assert.equal(
152
+ result.collection.indexConfigs.bodyEmbedding.embedding.dimensions,
153
+ 1536,
154
+ );
155
+ assert.equal(
156
+ result.collection.indexConfigs.bodyEmbedding.embedding.similarity,
157
+ "cosine",
158
+ );
159
+ });
160
+
161
+ test("collection query supports managed embedding queryText KNN payloads", async () => {
162
+ const { calls, client } = createClient((call) => {
163
+ assert.equal(call.method, "POST");
164
+ assert.equal(call.url.pathname, "/projects/project-one/collections/items/query");
165
+ assert.deepEqual(JSON.parse(call.body), {
166
+ size: 10,
167
+ query: {
168
+ knn: {
169
+ field: "bodyEmbedding",
170
+ queryText: "refund policy",
171
+ k: 10,
172
+ },
173
+ },
174
+ consistentRead: false,
175
+ includeVectors: false,
176
+ });
177
+
178
+ return jsonResponse({
179
+ took: 3,
180
+ maxScore: 0.98,
181
+ total: 1,
182
+ docs: [{ collection: "items", score: 0.98, doc: { id: "a" } }],
183
+ isDocsInline: true,
184
+ docsUrl: null,
185
+ });
186
+ });
187
+
188
+ const result = await client.collection("items").query({
189
+ size: 10,
190
+ query: {
191
+ knn: {
192
+ field: "bodyEmbedding",
193
+ queryText: "refund policy",
194
+ k: 10,
195
+ },
196
+ },
197
+ });
198
+
199
+ assert.equal(calls.length, 1);
200
+ assert.equal(result.total, 1);
201
+ });
202
+
203
+ test("getBulkUpsertSafe exposes managed embedding unsupported bad requests", async () => {
204
+ const { client } = createClient((call) => {
205
+ assert.equal(call.method, "GET");
206
+ assert.equal(call.url.pathname, "/projects/project-one/collections/items/docs/bulk-upsert");
207
+
208
+ return jsonResponse(
209
+ { message: "Bulk upsert is not supported for collections with managed embedding fields" },
210
+ { status: 400 },
211
+ );
212
+ });
213
+
214
+ const result = await client.collection("items").docs.getBulkUpsertSafe();
215
+
216
+ assert.equal(result.ok, false);
217
+ assert.ok(result.error instanceof BadRequestError);
218
+ assert.equal(
219
+ result.error.data$.message,
220
+ "Bulk upsert is not supported for collections with managed embedding fields",
221
+ );
222
+ });
223
+
86
224
  test("public pagination helpers collect all collection pages", async () => {
87
225
  const { calls, client } = createClient((call, index) => {
88
226
  if (index === 0) {
package/tsconfig.json CHANGED
@@ -14,9 +14,8 @@
14
14
  "declarationMap": true,
15
15
  "sourceMap": true,
16
16
  "outDir": ".",
17
-
17
+ "rootDir": "src",
18
18
 
19
- // https://github.com/tsconfig/bases/blob/a1bf7c0fa2e094b068ca3e1448ca2ece4157977e/bases/strictest.json
20
19
  "strict": true,
21
20
  "allowUnusedLabels": false,
22
21
  "allowUnreachableCode": false,