@functional-systems/lambdadb 0.4.2 → 0.5.0-rc.1
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/CHANGELOG.md +71 -0
- package/FUNCTIONS.md +7 -2
- package/README.md +60 -2
- package/RUNTIMES.md +7 -0
- package/USAGE.md +20 -0
- package/dist/commonjs/client.d.ts +25 -10
- package/dist/commonjs/client.d.ts.map +1 -1
- package/dist/commonjs/client.js +233 -59
- package/dist/commonjs/client.js.map +1 -1
- package/dist/commonjs/compat/qdrant/client.d.ts +6 -10
- package/dist/commonjs/compat/qdrant/client.d.ts.map +1 -1
- package/dist/commonjs/compat/qdrant/client.js +33 -15
- package/dist/commonjs/compat/qdrant/client.js.map +1 -1
- package/dist/commonjs/compat/qdrant/filters.js +5 -1
- package/dist/commonjs/compat/qdrant/filters.js.map +1 -1
- package/dist/commonjs/funcs/collectionsCreate.js +1 -1
- package/dist/commonjs/funcs/collectionsDelete.js +1 -1
- package/dist/commonjs/funcs/collectionsDocsGetBulkUpsert.js +4 -0
- package/dist/commonjs/funcs/collectionsDocsGetBulkUpsert.js.map +1 -1
- package/dist/commonjs/funcs/collectionsDocsListDocs.js +3 -0
- package/dist/commonjs/funcs/collectionsDocsListDocs.js.map +1 -1
- package/dist/commonjs/funcs/collectionsDocsListDocsExtended.d.ts +15 -0
- package/dist/commonjs/funcs/collectionsDocsListDocsExtended.d.ts.map +1 -0
- package/dist/commonjs/funcs/collectionsDocsListDocsExtended.js +131 -0
- package/dist/commonjs/funcs/collectionsDocsListDocsExtended.js.map +1 -0
- package/dist/commonjs/index.d.ts +4 -1
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +15 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/lib/config.js.map +1 -1
- package/dist/commonjs/lib/queryInput.d.ts +3 -11
- package/dist/commonjs/lib/queryInput.d.ts.map +1 -1
- package/dist/commonjs/lib/queryInput.js.map +1 -1
- package/dist/commonjs/models/collectionresponse.d.ts +12 -21
- package/dist/commonjs/models/collectionresponse.d.ts.map +1 -1
- package/dist/commonjs/models/collectionresponse.js +5 -6
- package/dist/commonjs/models/collectionresponse.js.map +1 -1
- package/dist/commonjs/models/index.d.ts +1 -0
- package/dist/commonjs/models/index.d.ts.map +1 -1
- package/dist/commonjs/models/index.js +1 -0
- package/dist/commonjs/models/index.js.map +1 -1
- package/dist/commonjs/models/operations/bulkupsertdocs.d.ts +6 -0
- package/dist/commonjs/models/operations/bulkupsertdocs.d.ts.map +1 -1
- package/dist/commonjs/models/operations/bulkupsertdocs.js +2 -0
- package/dist/commonjs/models/operations/bulkupsertdocs.js.map +1 -1
- package/dist/commonjs/models/operations/createcollection.d.ts +20 -13
- package/dist/commonjs/models/operations/createcollection.d.ts.map +1 -1
- package/dist/commonjs/models/operations/createcollection.js +15 -7
- package/dist/commonjs/models/operations/createcollection.js.map +1 -1
- package/dist/commonjs/models/operations/deletedocs.d.ts +3 -0
- package/dist/commonjs/models/operations/deletedocs.d.ts.map +1 -1
- package/dist/commonjs/models/operations/deletedocs.js +1 -0
- package/dist/commonjs/models/operations/deletedocs.js.map +1 -1
- package/dist/commonjs/models/operations/fetchdocs.d.ts +3 -0
- package/dist/commonjs/models/operations/fetchdocs.d.ts.map +1 -1
- package/dist/commonjs/models/operations/fetchdocs.js +9 -0
- package/dist/commonjs/models/operations/fetchdocs.js.map +1 -1
- package/dist/commonjs/models/operations/getbulkupsertdocs.d.ts +5 -0
- package/dist/commonjs/models/operations/getbulkupsertdocs.d.ts.map +1 -1
- package/dist/commonjs/models/operations/getbulkupsertdocs.js +5 -3
- package/dist/commonjs/models/operations/getbulkupsertdocs.js.map +1 -1
- package/dist/commonjs/models/operations/listdocs.d.ts +69 -0
- package/dist/commonjs/models/operations/listdocs.d.ts.map +1 -1
- package/dist/commonjs/models/operations/listdocs.js +41 -1
- package/dist/commonjs/models/operations/listdocs.js.map +1 -1
- package/dist/commonjs/models/operations/querycollection.d.ts +3 -0
- package/dist/commonjs/models/operations/querycollection.d.ts.map +1 -1
- package/dist/commonjs/models/operations/querycollection.js +9 -0
- package/dist/commonjs/models/operations/querycollection.js.map +1 -1
- package/dist/commonjs/models/operations/updatecollection.d.ts +10 -4
- package/dist/commonjs/models/operations/updatecollection.d.ts.map +1 -1
- package/dist/commonjs/models/operations/updatecollection.js +8 -1
- package/dist/commonjs/models/operations/updatecollection.js.map +1 -1
- package/dist/commonjs/models/operations/updatedocs.d.ts +3 -0
- package/dist/commonjs/models/operations/updatedocs.d.ts.map +1 -1
- package/dist/commonjs/models/operations/updatedocs.js +1 -0
- package/dist/commonjs/models/operations/updatedocs.js.map +1 -1
- package/dist/commonjs/models/operations/upsertdocs.d.ts +3 -0
- package/dist/commonjs/models/operations/upsertdocs.d.ts.map +1 -1
- package/dist/commonjs/models/operations/upsertdocs.js +1 -0
- package/dist/commonjs/models/operations/upsertdocs.js.map +1 -1
- package/dist/commonjs/models/versioning.d.ts +100 -0
- package/dist/commonjs/models/versioning.d.ts.map +1 -0
- package/dist/commonjs/models/versioning.js +93 -0
- package/dist/commonjs/models/versioning.js.map +1 -0
- package/dist/commonjs/types/public.d.ts +86 -8
- package/dist/commonjs/types/public.d.ts.map +1 -1
- package/dist/commonjs/types/public.js +30 -7
- package/dist/commonjs/types/public.js.map +1 -1
- package/dist/commonjs/versioning.d.ts +63 -0
- package/dist/commonjs/versioning.d.ts.map +1 -0
- package/dist/commonjs/versioning.js +390 -0
- package/dist/commonjs/versioning.js.map +1 -0
- package/dist/esm/client.d.ts +25 -10
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +234 -61
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/compat/qdrant/client.d.ts +6 -10
- package/dist/esm/compat/qdrant/client.d.ts.map +1 -1
- package/dist/esm/compat/qdrant/client.js +33 -15
- package/dist/esm/compat/qdrant/client.js.map +1 -1
- package/dist/esm/compat/qdrant/filters.js +5 -1
- package/dist/esm/compat/qdrant/filters.js.map +1 -1
- package/dist/esm/funcs/collectionsCreate.js +1 -1
- package/dist/esm/funcs/collectionsDelete.js +1 -1
- package/dist/esm/funcs/collectionsDocsGetBulkUpsert.js +5 -1
- package/dist/esm/funcs/collectionsDocsGetBulkUpsert.js.map +1 -1
- package/dist/esm/funcs/collectionsDocsListDocs.js +3 -0
- package/dist/esm/funcs/collectionsDocsListDocs.js.map +1 -1
- package/dist/esm/funcs/collectionsDocsListDocsExtended.d.ts +15 -0
- package/dist/esm/funcs/collectionsDocsListDocsExtended.d.ts.map +1 -0
- package/dist/esm/funcs/collectionsDocsListDocsExtended.js +95 -0
- package/dist/esm/funcs/collectionsDocsListDocsExtended.js.map +1 -0
- package/dist/esm/index.d.ts +4 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/lib/config.js.map +1 -1
- package/dist/esm/lib/queryInput.d.ts +3 -11
- package/dist/esm/lib/queryInput.d.ts.map +1 -1
- package/dist/esm/lib/queryInput.js.map +1 -1
- package/dist/esm/models/collectionresponse.d.ts +12 -21
- package/dist/esm/models/collectionresponse.d.ts.map +1 -1
- package/dist/esm/models/collectionresponse.js +5 -6
- package/dist/esm/models/collectionresponse.js.map +1 -1
- package/dist/esm/models/index.d.ts +1 -0
- package/dist/esm/models/index.d.ts.map +1 -1
- package/dist/esm/models/index.js +1 -0
- package/dist/esm/models/index.js.map +1 -1
- package/dist/esm/models/operations/bulkupsertdocs.d.ts +6 -0
- package/dist/esm/models/operations/bulkupsertdocs.d.ts.map +1 -1
- package/dist/esm/models/operations/bulkupsertdocs.js +2 -0
- package/dist/esm/models/operations/bulkupsertdocs.js.map +1 -1
- package/dist/esm/models/operations/createcollection.d.ts +20 -13
- package/dist/esm/models/operations/createcollection.d.ts.map +1 -1
- package/dist/esm/models/operations/createcollection.js +15 -7
- package/dist/esm/models/operations/createcollection.js.map +1 -1
- package/dist/esm/models/operations/deletedocs.d.ts +3 -0
- package/dist/esm/models/operations/deletedocs.d.ts.map +1 -1
- package/dist/esm/models/operations/deletedocs.js +1 -0
- package/dist/esm/models/operations/deletedocs.js.map +1 -1
- package/dist/esm/models/operations/fetchdocs.d.ts +3 -0
- package/dist/esm/models/operations/fetchdocs.d.ts.map +1 -1
- package/dist/esm/models/operations/fetchdocs.js +9 -0
- package/dist/esm/models/operations/fetchdocs.js.map +1 -1
- package/dist/esm/models/operations/getbulkupsertdocs.d.ts +5 -0
- package/dist/esm/models/operations/getbulkupsertdocs.d.ts.map +1 -1
- package/dist/esm/models/operations/getbulkupsertdocs.js +6 -4
- package/dist/esm/models/operations/getbulkupsertdocs.js.map +1 -1
- package/dist/esm/models/operations/listdocs.d.ts +69 -0
- package/dist/esm/models/operations/listdocs.d.ts.map +1 -1
- package/dist/esm/models/operations/listdocs.js +38 -0
- package/dist/esm/models/operations/listdocs.js.map +1 -1
- package/dist/esm/models/operations/querycollection.d.ts +3 -0
- package/dist/esm/models/operations/querycollection.d.ts.map +1 -1
- package/dist/esm/models/operations/querycollection.js +9 -0
- package/dist/esm/models/operations/querycollection.js.map +1 -1
- package/dist/esm/models/operations/updatecollection.d.ts +10 -4
- package/dist/esm/models/operations/updatecollection.d.ts.map +1 -1
- package/dist/esm/models/operations/updatecollection.js +8 -1
- package/dist/esm/models/operations/updatecollection.js.map +1 -1
- package/dist/esm/models/operations/updatedocs.d.ts +3 -0
- package/dist/esm/models/operations/updatedocs.d.ts.map +1 -1
- package/dist/esm/models/operations/updatedocs.js +1 -0
- package/dist/esm/models/operations/updatedocs.js.map +1 -1
- package/dist/esm/models/operations/upsertdocs.d.ts +3 -0
- package/dist/esm/models/operations/upsertdocs.d.ts.map +1 -1
- package/dist/esm/models/operations/upsertdocs.js +1 -0
- package/dist/esm/models/operations/upsertdocs.js.map +1 -1
- package/dist/esm/models/versioning.d.ts +100 -0
- package/dist/esm/models/versioning.d.ts.map +1 -0
- package/dist/esm/models/versioning.js +57 -0
- package/dist/esm/models/versioning.js.map +1 -0
- package/dist/esm/types/public.d.ts +86 -8
- package/dist/esm/types/public.d.ts.map +1 -1
- package/dist/esm/types/public.js +26 -7
- package/dist/esm/types/public.js.map +1 -1
- package/dist/esm/versioning.d.ts +63 -0
- package/dist/esm/versioning.d.ts.map +1 -0
- package/dist/esm/versioning.js +344 -0
- package/dist/esm/versioning.js.map +1 -0
- package/jsr.json +3 -1
- package/package.json +14 -2
- package/src/client.ts +367 -72
- package/src/compat/qdrant/client.ts +46 -20
- package/src/compat/qdrant/filters.ts +5 -3
- package/src/funcs/collectionsCreate.ts +1 -1
- package/src/funcs/collectionsDelete.ts +1 -1
- package/src/funcs/collectionsDocsGetBulkUpsert.ts +6 -1
- package/src/funcs/collectionsDocsListDocs.ts +3 -0
- package/src/funcs/collectionsDocsListDocsExtended.ts +201 -0
- package/src/index.ts +17 -0
- package/src/lib/config.ts +2 -2
- package/src/lib/queryInput.ts +3 -10
- package/src/models/collectionresponse.ts +17 -26
- package/src/models/index.ts +1 -0
- package/src/models/operations/bulkupsertdocs.ts +8 -0
- package/src/models/operations/createcollection.ts +39 -18
- package/src/models/operations/deletedocs.ts +4 -0
- package/src/models/operations/fetchdocs.ts +12 -0
- package/src/models/operations/getbulkupsertdocs.ts +11 -4
- package/src/models/operations/listdocs.ts +120 -0
- package/src/models/operations/querycollection.ts +12 -0
- package/src/models/operations/updatecollection.ts +21 -3
- package/src/models/operations/updatedocs.ts +4 -0
- package/src/models/operations/upsertdocs.ts +4 -0
- package/src/models/versioning.ts +118 -0
- package/src/types/public.ts +136 -16
- package/src/versioning.ts +490 -0
- package/examples/collectionScoped.example.ts +0 -38
- package/examples/collectionsList.example.ts +0 -25
- package/examples/package-lock.json +0 -612
- package/examples/package.json +0 -18
- package/test/integration/qdrant-compat-external.test.mjs +0 -351
- package/test/integration/qdrant-compat-live.test.mjs +0 -122
- package/test/null-response.test.mjs +0 -73
- package/test/public-api.test.mjs +0 -489
- package/test/qdrant-compat.test.mjs +0 -467
- package/tsconfig.json +0 -39
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { LambdaDBClient, type LambdaDBClientOptions } from "../../client.js";
|
|
2
2
|
import { ResourceNotFoundError } from "../../models/errors/index.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
CreateCollectionInput,
|
|
5
|
+
ListDocsInput,
|
|
6
|
+
UpdateCollectionInput,
|
|
7
|
+
} from "../../types/public.js";
|
|
4
8
|
import {
|
|
5
9
|
ORIGINAL_ID_FIELD,
|
|
6
10
|
mergeIndexConfigs,
|
|
@@ -24,17 +28,18 @@ import {
|
|
|
24
28
|
} from "./errors.js";
|
|
25
29
|
|
|
26
30
|
type JsonObject = { [key: string]: unknown };
|
|
31
|
+
type ListDocsBody = ListDocsInput;
|
|
27
32
|
|
|
28
33
|
type CollectionLike = {
|
|
29
34
|
get(): Promise<{ collection: JsonObject }>;
|
|
30
|
-
update(body:
|
|
35
|
+
update(body: UpdateCollectionInput): Promise<unknown>;
|
|
31
36
|
delete(): Promise<unknown>;
|
|
32
37
|
query(body: JsonObject): Promise<{ docs: unknown[] }>;
|
|
33
38
|
docs: {
|
|
34
39
|
upsert(body: { docs: JsonObject[] }): Promise<unknown>;
|
|
35
40
|
fetch(body: JsonObject): Promise<{ docs: unknown[] }>;
|
|
36
41
|
delete(body: { ids?: string[]; filter?: JsonObject }): Promise<unknown>;
|
|
37
|
-
list(body?:
|
|
42
|
+
list(body?: ListDocsBody): Promise<{
|
|
38
43
|
docs: unknown[];
|
|
39
44
|
nextPageToken?: string | undefined;
|
|
40
45
|
}>;
|
|
@@ -183,7 +188,7 @@ export class QdrantCompatClient {
|
|
|
183
188
|
collectionName,
|
|
184
189
|
indexConfigs: indexConfigs as CreateCollectionInput["indexConfigs"],
|
|
185
190
|
});
|
|
186
|
-
await this.
|
|
191
|
+
await this.waitForCollectionAvailable(collectionName, body.timeout);
|
|
187
192
|
return true;
|
|
188
193
|
}
|
|
189
194
|
|
|
@@ -254,9 +259,12 @@ export class QdrantCompatClient {
|
|
|
254
259
|
}
|
|
255
260
|
|
|
256
261
|
await this.client.collection(collectionName).update({
|
|
257
|
-
indexConfigs: mergeIndexConfigs(
|
|
262
|
+
indexConfigs: mergeIndexConfigs(
|
|
263
|
+
existingIndexConfigs,
|
|
264
|
+
payloadIndexConfig,
|
|
265
|
+
) as UpdateCollectionInput["indexConfigs"],
|
|
258
266
|
});
|
|
259
|
-
await this.
|
|
267
|
+
await this.waitForCollectionAvailable(collectionName, timeout);
|
|
260
268
|
return true;
|
|
261
269
|
}
|
|
262
270
|
|
|
@@ -615,6 +623,7 @@ export class QdrantCompatClient {
|
|
|
615
623
|
options: {
|
|
616
624
|
scrollFilter?: models.Filter | JsonObject | null;
|
|
617
625
|
scroll_filter?: models.Filter | JsonObject | null;
|
|
626
|
+
offset?: string | number | undefined;
|
|
618
627
|
limit?: number | undefined;
|
|
619
628
|
withPayload?: PayloadSelector | undefined;
|
|
620
629
|
with_payload?: PayloadSelector | undefined;
|
|
@@ -626,6 +635,7 @@ export class QdrantCompatClient {
|
|
|
626
635
|
const {
|
|
627
636
|
scrollFilter,
|
|
628
637
|
scroll_filter: scrollFilterSnake,
|
|
638
|
+
offset,
|
|
629
639
|
limit = 10,
|
|
630
640
|
withPayload,
|
|
631
641
|
with_payload: withPayloadSnake,
|
|
@@ -634,12 +644,23 @@ export class QdrantCompatClient {
|
|
|
634
644
|
...rest
|
|
635
645
|
} = options;
|
|
636
646
|
warnIgnored(rest);
|
|
637
|
-
if (
|
|
638
|
-
throw new UnsupportedQdrantFeatureError(
|
|
647
|
+
if (offset !== undefined && typeof offset !== "string") {
|
|
648
|
+
throw new UnsupportedQdrantFeatureError(
|
|
649
|
+
"Qdrant point-id scroll offsets are not supported; use the returned LambdaDB page-token offset",
|
|
650
|
+
);
|
|
639
651
|
}
|
|
640
652
|
const payloadSelector = normalizePayloadSelector(withPayload ?? withPayloadSnake ?? true);
|
|
641
653
|
const vectorSelector = normalizeVectorSelector(withVectors ?? withVectorsSnake ?? false);
|
|
642
|
-
const
|
|
654
|
+
const fields = fieldsForSelectors(payloadSelector, vectorSelector);
|
|
655
|
+
const convertedFilter = filterToLambdaDB(scrollFilter ?? scrollFilterSnake);
|
|
656
|
+
const listBody: ListDocsBody = {
|
|
657
|
+
size: limit,
|
|
658
|
+
includeVectors: vectorSelector !== false,
|
|
659
|
+
};
|
|
660
|
+
if (offset !== undefined) listBody.pageToken = offset;
|
|
661
|
+
if (Object.keys(convertedFilter).length > 0) listBody.filter = convertedFilter;
|
|
662
|
+
if (fields !== undefined) listBody.fields = fields;
|
|
663
|
+
const response = await this.client.collection(collectionName).docs.list(listBody);
|
|
643
664
|
return [
|
|
644
665
|
response.docs.map((doc) => docToRecord(doc, {
|
|
645
666
|
withPayload: payloadSelector,
|
|
@@ -676,24 +697,25 @@ export class QdrantCompatClient {
|
|
|
676
697
|
return response.collection;
|
|
677
698
|
}
|
|
678
699
|
|
|
679
|
-
private async
|
|
700
|
+
private async waitForCollectionAvailable(
|
|
680
701
|
collectionName: string,
|
|
681
702
|
timeoutSeconds: unknown,
|
|
682
703
|
): Promise<void> {
|
|
683
704
|
const timeout = typeof timeoutSeconds === "number" ? timeoutSeconds : 60;
|
|
684
705
|
const deadline = Date.now() + timeout * 1000;
|
|
685
|
-
let lastStatus = "unknown";
|
|
686
706
|
while (true) {
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
707
|
+
try {
|
|
708
|
+
await this.currentCollection(collectionName);
|
|
709
|
+
return;
|
|
710
|
+
} catch (error) {
|
|
711
|
+
if (!isNotFoundError(error)) throw error;
|
|
712
|
+
if (Date.now() >= deadline) {
|
|
713
|
+
throw new QdrantCompatError(
|
|
714
|
+
`Collection ${collectionName} was not available within ${timeout}s`,
|
|
715
|
+
);
|
|
716
|
+
}
|
|
717
|
+
await sleep(500);
|
|
695
718
|
}
|
|
696
|
-
await sleep(500);
|
|
697
719
|
}
|
|
698
720
|
}
|
|
699
721
|
}
|
|
@@ -723,6 +745,7 @@ function normalizeConstructorOptions(
|
|
|
723
745
|
"timeoutMs",
|
|
724
746
|
"retryConfig",
|
|
725
747
|
"httpClient",
|
|
748
|
+
"transferClient",
|
|
726
749
|
"serverURL",
|
|
727
750
|
"projectHost",
|
|
728
751
|
"path",
|
|
@@ -765,6 +788,9 @@ function normalizeConstructorOptions(
|
|
|
765
788
|
if (timeoutMs !== undefined) normalized.timeoutMs = timeoutMs;
|
|
766
789
|
if (options.retryConfig !== undefined) normalized.retryConfig = options.retryConfig;
|
|
767
790
|
if (options.httpClient !== undefined) normalized.httpClient = options.httpClient;
|
|
791
|
+
if (options.transferClient !== undefined) {
|
|
792
|
+
normalized.transferClient = options.transferClient;
|
|
793
|
+
}
|
|
768
794
|
if (options.serverURL !== undefined) normalized.serverURL = options.serverURL;
|
|
769
795
|
if (options.projectHost !== undefined) normalized.projectHost = options.projectHost;
|
|
770
796
|
return normalized;
|
|
@@ -92,9 +92,11 @@ function matchQueries(field: string, rawMatch: unknown): LambdaDBQuery[] {
|
|
|
92
92
|
return match.except.map((value) => queryString(`${field}:${formatScalar(value)}`));
|
|
93
93
|
}
|
|
94
94
|
if (match instanceof MatchText) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
const terms = match.text.split(/\s+/).filter(Boolean);
|
|
96
|
+
if (terms.length === 0) {
|
|
97
|
+
throw new QdrantCompatValidationError("MatchText text must not be empty");
|
|
98
|
+
}
|
|
99
|
+
return terms.map((term) => queryString(`${field}:${formatScalar(term)}`));
|
|
98
100
|
}
|
|
99
101
|
|
|
100
102
|
throw new UnsupportedQdrantFeatureError(
|
|
@@ -175,7 +175,7 @@ async function $do(
|
|
|
175
175
|
| UnexpectedClientError
|
|
176
176
|
| SDKValidationError
|
|
177
177
|
>(
|
|
178
|
-
M.json(
|
|
178
|
+
M.json(201, operations.CreateCollectionResponse$inboundSchema),
|
|
179
179
|
M.jsonErr(400, errors.BadRequestError$inboundSchema),
|
|
180
180
|
M.jsonErr(401, errors.UnauthenticatedError$inboundSchema),
|
|
181
181
|
M.jsonErr(409, errors.ResourceAlreadyExistsError$inboundSchema),
|
|
@@ -179,7 +179,7 @@ async function $do(
|
|
|
179
179
|
| UnexpectedClientError
|
|
180
180
|
| SDKValidationError
|
|
181
181
|
>(
|
|
182
|
-
M.json(
|
|
182
|
+
M.json(200, models.MessageResponse$inboundSchema),
|
|
183
183
|
M.jsonErr(401, errors.UnauthenticatedError$inboundSchema),
|
|
184
184
|
M.jsonErr(404, errors.ResourceNotFoundError$inboundSchema),
|
|
185
185
|
M.jsonErr(429, errors.TooManyRequestsError$inboundSchema),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { LambdaDBCore } from "../core.js";
|
|
6
|
-
import { encodeSimple } from "../lib/encodings.js";
|
|
6
|
+
import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
|
|
7
7
|
import * as M from "../lib/matchers.js";
|
|
8
8
|
import { compactMap } from "../lib/primitives.js";
|
|
9
9
|
import { safeParse } from "../lib/schemas.js";
|
|
@@ -104,6 +104,10 @@ async function $do(
|
|
|
104
104
|
pathParams,
|
|
105
105
|
);
|
|
106
106
|
|
|
107
|
+
const query = encodeFormQuery({
|
|
108
|
+
"branch": payload.branch,
|
|
109
|
+
});
|
|
110
|
+
|
|
107
111
|
const headers = new Headers(compactMap({
|
|
108
112
|
Accept: "application/json",
|
|
109
113
|
}));
|
|
@@ -142,6 +146,7 @@ async function $do(
|
|
|
142
146
|
method: "GET",
|
|
143
147
|
baseURL: options?.serverURL,
|
|
144
148
|
path: path,
|
|
149
|
+
query: query,
|
|
145
150
|
headers: headers,
|
|
146
151
|
body: body,
|
|
147
152
|
userAgent: client._options.userAgent,
|
|
@@ -103,7 +103,10 @@ async function $do(
|
|
|
103
103
|
const path = pathToFunc("/collections/{collectionName}/docs")(pathParams);
|
|
104
104
|
|
|
105
105
|
const query = encodeFormQuery({
|
|
106
|
+
"includeVectors": payload.includeVectors,
|
|
106
107
|
"pageToken": payload.pageToken,
|
|
108
|
+
"refKind": payload.refKind,
|
|
109
|
+
"refName": payload.refName,
|
|
107
110
|
"size": payload.size,
|
|
108
111
|
});
|
|
109
112
|
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { LambdaDBCore } from "../core.js";
|
|
6
|
+
import { encodeJSON, encodeSimple } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import {
|
|
14
|
+
ConnectionError,
|
|
15
|
+
InvalidRequestError,
|
|
16
|
+
RequestAbortedError,
|
|
17
|
+
RequestTimeoutError,
|
|
18
|
+
UnexpectedClientError,
|
|
19
|
+
} from "../models/errors/httpclienterrors.js";
|
|
20
|
+
import * as errors from "../models/errors/index.js";
|
|
21
|
+
import { LambdaDBError } from "../models/errors/lambdadberror.js";
|
|
22
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
23
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
24
|
+
import * as operations from "../models/operations/index.js";
|
|
25
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
26
|
+
import { Result } from "../types/fp.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* List documents in a collection with optional filters, field selection, and vector inclusion.
|
|
30
|
+
*/
|
|
31
|
+
export function collectionsDocsListDocsExtended(
|
|
32
|
+
client: LambdaDBCore,
|
|
33
|
+
request: operations.ListDocsExtendedRequest,
|
|
34
|
+
options?: RequestOptions,
|
|
35
|
+
): APIPromise<
|
|
36
|
+
Result<
|
|
37
|
+
operations.ListDocsResponse,
|
|
38
|
+
| errors.BadRequestError
|
|
39
|
+
| errors.UnauthenticatedError
|
|
40
|
+
| errors.ResourceNotFoundError
|
|
41
|
+
| errors.TooManyRequestsError
|
|
42
|
+
| errors.InternalServerError
|
|
43
|
+
| LambdaDBError
|
|
44
|
+
| ResponseValidationError
|
|
45
|
+
| ConnectionError
|
|
46
|
+
| RequestAbortedError
|
|
47
|
+
| RequestTimeoutError
|
|
48
|
+
| InvalidRequestError
|
|
49
|
+
| UnexpectedClientError
|
|
50
|
+
| SDKValidationError
|
|
51
|
+
>
|
|
52
|
+
> {
|
|
53
|
+
return new APIPromise($do(
|
|
54
|
+
client,
|
|
55
|
+
request,
|
|
56
|
+
options,
|
|
57
|
+
));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function $do(
|
|
61
|
+
client: LambdaDBCore,
|
|
62
|
+
request: operations.ListDocsExtendedRequest,
|
|
63
|
+
options?: RequestOptions,
|
|
64
|
+
): Promise<
|
|
65
|
+
[
|
|
66
|
+
Result<
|
|
67
|
+
operations.ListDocsResponse,
|
|
68
|
+
| errors.BadRequestError
|
|
69
|
+
| errors.UnauthenticatedError
|
|
70
|
+
| errors.ResourceNotFoundError
|
|
71
|
+
| errors.TooManyRequestsError
|
|
72
|
+
| errors.InternalServerError
|
|
73
|
+
| LambdaDBError
|
|
74
|
+
| ResponseValidationError
|
|
75
|
+
| ConnectionError
|
|
76
|
+
| RequestAbortedError
|
|
77
|
+
| RequestTimeoutError
|
|
78
|
+
| InvalidRequestError
|
|
79
|
+
| UnexpectedClientError
|
|
80
|
+
| SDKValidationError
|
|
81
|
+
>,
|
|
82
|
+
APICall,
|
|
83
|
+
]
|
|
84
|
+
> {
|
|
85
|
+
const parsed = safeParse(
|
|
86
|
+
request,
|
|
87
|
+
(value) => operations.ListDocsExtendedRequest$outboundSchema.parse(value),
|
|
88
|
+
"Input validation failed",
|
|
89
|
+
);
|
|
90
|
+
if (!parsed.ok) {
|
|
91
|
+
return [parsed, { status: "invalid" }];
|
|
92
|
+
}
|
|
93
|
+
const payload = parsed.value;
|
|
94
|
+
const body = encodeJSON("body", payload.RequestBody, { explode: true });
|
|
95
|
+
|
|
96
|
+
const pathParams = {
|
|
97
|
+
collectionName: encodeSimple("collectionName", payload.collectionName, {
|
|
98
|
+
explode: false,
|
|
99
|
+
charEncoding: "percent",
|
|
100
|
+
}),
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const path = pathToFunc("/collections/{collectionName}/docs/list")(
|
|
104
|
+
pathParams,
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const headers = new Headers(compactMap({
|
|
108
|
+
"Content-Type": "application/json",
|
|
109
|
+
Accept: "application/json",
|
|
110
|
+
}));
|
|
111
|
+
|
|
112
|
+
const secConfig = await extractSecurity(client._options.projectApiKey);
|
|
113
|
+
const securityInput = secConfig == null ? {} : { projectApiKey: secConfig };
|
|
114
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
115
|
+
|
|
116
|
+
const context = {
|
|
117
|
+
options: client._options,
|
|
118
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
119
|
+
operationID: "listDocsExtended",
|
|
120
|
+
oAuth2Scopes: null,
|
|
121
|
+
|
|
122
|
+
resolvedSecurity: requestSecurity,
|
|
123
|
+
|
|
124
|
+
securitySource: client._options.projectApiKey,
|
|
125
|
+
retryConfig: options?.retries
|
|
126
|
+
|| client._options.retryConfig
|
|
127
|
+
|| {
|
|
128
|
+
strategy: "backoff",
|
|
129
|
+
backoff: {
|
|
130
|
+
initialInterval: 500,
|
|
131
|
+
maxInterval: 60000,
|
|
132
|
+
exponent: 1.5,
|
|
133
|
+
maxElapsedTime: 3600000,
|
|
134
|
+
},
|
|
135
|
+
retryConnectionErrors: true,
|
|
136
|
+
}
|
|
137
|
+
|| { strategy: "none" },
|
|
138
|
+
retryCodes: options?.retryCodes || ["429", "5XX"],
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const requestRes = client._createRequest(context, {
|
|
142
|
+
security: requestSecurity,
|
|
143
|
+
method: "POST",
|
|
144
|
+
baseURL: options?.serverURL,
|
|
145
|
+
path: path,
|
|
146
|
+
headers: headers,
|
|
147
|
+
body: body,
|
|
148
|
+
userAgent: client._options.userAgent,
|
|
149
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
150
|
+
}, options);
|
|
151
|
+
if (!requestRes.ok) {
|
|
152
|
+
return [requestRes, { status: "invalid" }];
|
|
153
|
+
}
|
|
154
|
+
const req = requestRes.value;
|
|
155
|
+
|
|
156
|
+
const doResult = await client._do(req, {
|
|
157
|
+
context,
|
|
158
|
+
errorCodes: ["400", "401", "404", "429", "4XX", "500", "5XX"],
|
|
159
|
+
retryConfig: context.retryConfig,
|
|
160
|
+
retryCodes: context.retryCodes,
|
|
161
|
+
});
|
|
162
|
+
if (!doResult.ok) {
|
|
163
|
+
return [doResult, { status: "request-error", request: req }];
|
|
164
|
+
}
|
|
165
|
+
const response = doResult.value;
|
|
166
|
+
|
|
167
|
+
const responseFields = {
|
|
168
|
+
HttpMeta: { Response: response, Request: req },
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const [result] = await M.match<
|
|
172
|
+
operations.ListDocsResponse,
|
|
173
|
+
| errors.BadRequestError
|
|
174
|
+
| errors.UnauthenticatedError
|
|
175
|
+
| errors.ResourceNotFoundError
|
|
176
|
+
| errors.TooManyRequestsError
|
|
177
|
+
| errors.InternalServerError
|
|
178
|
+
| LambdaDBError
|
|
179
|
+
| ResponseValidationError
|
|
180
|
+
| ConnectionError
|
|
181
|
+
| RequestAbortedError
|
|
182
|
+
| RequestTimeoutError
|
|
183
|
+
| InvalidRequestError
|
|
184
|
+
| UnexpectedClientError
|
|
185
|
+
| SDKValidationError
|
|
186
|
+
>(
|
|
187
|
+
M.json(200, operations.ListDocsResponse$inboundSchema),
|
|
188
|
+
M.jsonErr(400, errors.BadRequestError$inboundSchema),
|
|
189
|
+
M.jsonErr(401, errors.UnauthenticatedError$inboundSchema),
|
|
190
|
+
M.jsonErr(404, errors.ResourceNotFoundError$inboundSchema),
|
|
191
|
+
M.jsonErr(429, errors.TooManyRequestsError$inboundSchema),
|
|
192
|
+
M.jsonErr(500, errors.InternalServerError$inboundSchema),
|
|
193
|
+
M.fail("4XX"),
|
|
194
|
+
M.fail("5XX"),
|
|
195
|
+
)(response, req, { extraFields: responseFields });
|
|
196
|
+
if (!result.ok) {
|
|
197
|
+
return [result, { status: "complete", request: req, response }];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return [result, { status: "complete", request: req, response }];
|
|
201
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -12,12 +12,29 @@ export * from "./sdk/sdk.js";
|
|
|
12
12
|
export {
|
|
13
13
|
LambdaDBClient,
|
|
14
14
|
CollectionHandle,
|
|
15
|
+
CollectionDocs,
|
|
15
16
|
DEFAULT_BASE_URL,
|
|
16
17
|
DEFAULT_PROJECT_NAME,
|
|
17
18
|
type RequestOptions as ClientRequestOptions,
|
|
18
19
|
type LambdaDBClientOptions,
|
|
19
20
|
} from "./client.js";
|
|
20
21
|
|
|
22
|
+
/** Data Versioning lifecycle clients and validated ref/source/target helpers. */
|
|
23
|
+
export {
|
|
24
|
+
CollectionAliases,
|
|
25
|
+
CollectionBranches,
|
|
26
|
+
CollectionTags,
|
|
27
|
+
DATA_VERSIONING_CONTRACT_REVISION,
|
|
28
|
+
aliasRef,
|
|
29
|
+
branchRef,
|
|
30
|
+
branchSource,
|
|
31
|
+
branchTarget,
|
|
32
|
+
tagRef,
|
|
33
|
+
tagSource,
|
|
34
|
+
tagTarget,
|
|
35
|
+
} from "./versioning.js";
|
|
36
|
+
export type { VersioningError } from "./versioning.js";
|
|
37
|
+
|
|
21
38
|
/** Public API types (inputs and responses for the collection-scoped client). */
|
|
22
39
|
export type * from "./types/public.js";
|
|
23
40
|
|
package/src/lib/config.ts
CHANGED
|
@@ -73,8 +73,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
73
73
|
export const SDK_METADATA = {
|
|
74
74
|
language: "typescript",
|
|
75
75
|
openapiDocVersion: "1.1.1",
|
|
76
|
-
sdkVersion: "0.
|
|
76
|
+
sdkVersion: "0.5.0-rc.1",
|
|
77
77
|
genVersion: "2.798.0",
|
|
78
78
|
userAgent:
|
|
79
|
-
"speakeasy-sdk/typescript 0.
|
|
79
|
+
"speakeasy-sdk/typescript 0.5.0-rc.1 2.798.0 1.1.1 @functional-systems/lambdadb",
|
|
80
80
|
} as const;
|
package/src/lib/queryInput.ts
CHANGED
|
@@ -2,20 +2,13 @@
|
|
|
2
2
|
* Helper to build QueryCollectionInput for collection.query() / collection.querySafe().
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { FieldsSelectorUnion, PartitionFilter } from "../models/index.js";
|
|
6
5
|
import type { QueryCollectionInput } from "../types/public.js";
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Options for createQueryInput (all optional except query).
|
|
10
9
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
consistentRead?: boolean;
|
|
14
|
-
includeVectors?: boolean;
|
|
15
|
-
sort?: Array<{ [k: string]: unknown }>;
|
|
16
|
-
fields?: FieldsSelectorUnion;
|
|
17
|
-
partitionFilter?: PartitionFilter;
|
|
18
|
-
};
|
|
10
|
+
type WithoutQuery<T> = T extends unknown ? Omit<T, "query"> : never;
|
|
11
|
+
export type CreateQueryInputOptions = WithoutQuery<QueryCollectionInput>;
|
|
19
12
|
|
|
20
13
|
/**
|
|
21
14
|
* Build a query input object for collection.query() or collection.querySafe().
|
|
@@ -29,5 +22,5 @@ export function createQueryInput(
|
|
|
29
22
|
query: { [k: string]: unknown },
|
|
30
23
|
options?: CreateQueryInputOptions,
|
|
31
24
|
): QueryCollectionInput {
|
|
32
|
-
return { query, ...options };
|
|
25
|
+
return { query, ...options } as QueryCollectionInput;
|
|
33
26
|
}
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
PartitionConfig,
|
|
15
15
|
PartitionConfig$inboundSchema,
|
|
16
16
|
} from "./partitionconfig.js";
|
|
17
|
-
import { Status, Status$inboundSchema } from "./status.js";
|
|
18
17
|
|
|
19
18
|
export type CollectionResponse = {
|
|
20
19
|
/**
|
|
@@ -26,6 +25,10 @@ export type CollectionResponse = {
|
|
|
26
25
|
*/
|
|
27
26
|
collectionName: string;
|
|
28
27
|
indexConfigs: { [k: string]: IndexConfigsUnion };
|
|
28
|
+
/** Collection description. */
|
|
29
|
+
description: string;
|
|
30
|
+
/** Collection metadata tags. */
|
|
31
|
+
tags: Record<string, string>;
|
|
29
32
|
partitionConfig?: PartitionConfig | undefined;
|
|
30
33
|
/**
|
|
31
34
|
* Total number of partitions including the default partition.
|
|
@@ -35,34 +38,22 @@ export type CollectionResponse = {
|
|
|
35
38
|
* Total number of documents.
|
|
36
39
|
*/
|
|
37
40
|
numDocs: number;
|
|
41
|
+
/** Default writable Branch. */
|
|
42
|
+
defaultBranchName: "main";
|
|
43
|
+
/** Number of days that committed snapshots are retained. */
|
|
44
|
+
snapshotRetentionInDays: number;
|
|
38
45
|
/**
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
sourceProjectName?: string | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* Source collection name.
|
|
44
|
-
*/
|
|
45
|
-
sourceCollectionName?: string | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* Source collection version.
|
|
48
|
-
*/
|
|
49
|
-
sourceCollectionVersionId?: string | undefined;
|
|
50
|
-
/**
|
|
51
|
-
* Status
|
|
52
|
-
*/
|
|
53
|
-
collectionStatus: Status;
|
|
54
|
-
/**
|
|
55
|
-
* Collection creation time in seconds since the Unix epoch.
|
|
46
|
+
* Collection creation time in milliseconds since the Unix epoch.
|
|
56
47
|
*/
|
|
57
48
|
createdAt: number;
|
|
58
49
|
/**
|
|
59
|
-
* Collection last update time in
|
|
50
|
+
* Collection last update time in milliseconds since the Unix epoch.
|
|
60
51
|
*/
|
|
61
52
|
updatedAt: number;
|
|
62
53
|
/**
|
|
63
|
-
* Collection data last update time in
|
|
54
|
+
* Collection data last update time in milliseconds since the Unix epoch.
|
|
64
55
|
*/
|
|
65
|
-
dataUpdatedAt
|
|
56
|
+
dataUpdatedAt?: number | undefined;
|
|
66
57
|
};
|
|
67
58
|
|
|
68
59
|
/** @internal */
|
|
@@ -74,16 +65,16 @@ export const CollectionResponse$inboundSchema: z.ZodType<
|
|
|
74
65
|
projectName: z.string(),
|
|
75
66
|
collectionName: z.string(),
|
|
76
67
|
indexConfigs: z.record(IndexConfigsUnion$inboundSchema),
|
|
68
|
+
description: z.string(),
|
|
69
|
+
tags: z.record(z.string()),
|
|
77
70
|
partitionConfig: nullToUndefined(PartitionConfig$inboundSchema.optional()),
|
|
78
71
|
numPartitions: z.number().int(),
|
|
79
72
|
numDocs: z.number().int(),
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
sourceCollectionVersionId: nullToUndefined(z.string().optional()),
|
|
83
|
-
collectionStatus: Status$inboundSchema,
|
|
73
|
+
defaultBranchName: z.literal("main"),
|
|
74
|
+
snapshotRetentionInDays: z.number().int().min(1).max(31),
|
|
84
75
|
createdAt: z.number().int(),
|
|
85
76
|
updatedAt: z.number().int(),
|
|
86
|
-
dataUpdatedAt: z.number().int(),
|
|
77
|
+
dataUpdatedAt: nullToUndefined(z.number().int().optional()),
|
|
87
78
|
});
|
|
88
79
|
|
|
89
80
|
export function collectionResponseFromJSON(
|
package/src/models/index.ts
CHANGED
|
@@ -10,6 +10,10 @@ export type BulkUpsertDocsRequestBody = {
|
|
|
10
10
|
* Object key uploaded based on bulk upsert info.
|
|
11
11
|
*/
|
|
12
12
|
objectKey: string;
|
|
13
|
+
/** Content type supplied by the bulk-upload info response. */
|
|
14
|
+
type?: "application/json" | undefined;
|
|
15
|
+
/** Write target Branch. Must match the bulk-upload info request. */
|
|
16
|
+
branch?: string | undefined;
|
|
13
17
|
};
|
|
14
18
|
|
|
15
19
|
export type BulkUpsertDocsRequest = {
|
|
@@ -23,6 +27,8 @@ export type BulkUpsertDocsRequest = {
|
|
|
23
27
|
/** @internal */
|
|
24
28
|
export type BulkUpsertDocsRequestBody$Outbound = {
|
|
25
29
|
objectKey: string;
|
|
30
|
+
type: "application/json";
|
|
31
|
+
branch?: string | undefined;
|
|
26
32
|
};
|
|
27
33
|
|
|
28
34
|
/** @internal */
|
|
@@ -32,6 +38,8 @@ export const BulkUpsertDocsRequestBody$outboundSchema: z.ZodType<
|
|
|
32
38
|
BulkUpsertDocsRequestBody
|
|
33
39
|
> = z.object({
|
|
34
40
|
objectKey: z.string(),
|
|
41
|
+
type: z.literal("application/json").default("application/json"),
|
|
42
|
+
branch: z.string().regex(/^[a-zA-Z0-9_-]{3,52}$/).optional(),
|
|
35
43
|
});
|
|
36
44
|
|
|
37
45
|
export function bulkUpsertDocsRequestBodyToJSON(
|