@functional-systems/lambdadb 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/client.d.ts.map +1 -1
- package/dist/commonjs/client.js +51 -3
- package/dist/commonjs/client.js.map +1 -1
- package/dist/commonjs/compat/qdrant/client.d.ts +4 -5
- package/dist/commonjs/compat/qdrant/client.d.ts.map +1 -1
- package/dist/commonjs/compat/qdrant/client.js +17 -8
- 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/collectionsDocsListDocs.js +1 -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/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/models/operations/listdocs.d.ts +60 -0
- package/dist/commonjs/models/operations/listdocs.d.ts.map +1 -1
- package/dist/commonjs/models/operations/listdocs.js +30 -1
- package/dist/commonjs/models/operations/listdocs.js.map +1 -1
- package/dist/commonjs/types/public.d.ts +6 -2
- 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.map +1 -1
- package/dist/esm/client.js +51 -3
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/compat/qdrant/client.d.ts +4 -5
- package/dist/esm/compat/qdrant/client.d.ts.map +1 -1
- package/dist/esm/compat/qdrant/client.js +17 -8
- 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/collectionsDocsListDocs.js +1 -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/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/models/operations/listdocs.d.ts +60 -0
- package/dist/esm/models/operations/listdocs.d.ts.map +1 -1
- package/dist/esm/models/operations/listdocs.js +27 -0
- package/dist/esm/models/operations/listdocs.js.map +1 -1
- package/dist/esm/types/public.d.ts +6 -2
- package/dist/esm/types/public.d.ts.map +1 -1
- package/dist/esm/types/public.js.map +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/client.ts +67 -11
- package/src/compat/qdrant/client.ts +20 -9
- package/src/compat/qdrant/filters.ts +5 -3
- package/src/funcs/collectionsDocsListDocs.ts +1 -0
- package/src/funcs/collectionsDocsListDocsExtended.ts +201 -0
- package/src/lib/config.ts +2 -2
- package/src/models/operations/listdocs.ts +100 -0
- package/src/types/public.ts +9 -2
- package/test/public-api.test.mjs +51 -0
- package/test/qdrant-compat.test.mjs +97 -5
package/src/client.ts
CHANGED
|
@@ -23,6 +23,7 @@ import { collectionsDocsDelete } from "./funcs/collectionsDocsDelete.js";
|
|
|
23
23
|
import { collectionsDocsFetch } from "./funcs/collectionsDocsFetch.js";
|
|
24
24
|
import { collectionsDocsGetBulkUpsert } from "./funcs/collectionsDocsGetBulkUpsert.js";
|
|
25
25
|
import { collectionsDocsListDocs } from "./funcs/collectionsDocsListDocs.js";
|
|
26
|
+
import { collectionsDocsListDocsExtended } from "./funcs/collectionsDocsListDocsExtended.js";
|
|
26
27
|
import { collectionsDocsUpdate } from "./funcs/collectionsDocsUpdate.js";
|
|
27
28
|
import { collectionsDocsUpsert } from "./funcs/collectionsDocsUpsert.js";
|
|
28
29
|
import type { RequestOptions } from "./lib/sdks.js";
|
|
@@ -438,12 +439,36 @@ class CollectionDocs {
|
|
|
438
439
|
params?: ListDocsInput,
|
|
439
440
|
options?: RequestOptions,
|
|
440
441
|
) {
|
|
442
|
+
const useExtendedList = params?.filter != null
|
|
443
|
+
|| params?.partitionFilter != null
|
|
444
|
+
|| params?.fields != null;
|
|
441
445
|
const result = await unwrapAsync(
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
446
|
+
useExtendedList
|
|
447
|
+
? collectionsDocsListDocsExtended(
|
|
448
|
+
this.client,
|
|
449
|
+
{
|
|
450
|
+
collectionName: this.collectionName,
|
|
451
|
+
requestBody: {
|
|
452
|
+
size: params?.size,
|
|
453
|
+
pageToken: params?.pageToken,
|
|
454
|
+
filter: params?.filter,
|
|
455
|
+
partitionFilter: params?.partitionFilter,
|
|
456
|
+
fields: params?.fields,
|
|
457
|
+
includeVectors: params?.includeVectors,
|
|
458
|
+
},
|
|
459
|
+
},
|
|
460
|
+
options,
|
|
461
|
+
)
|
|
462
|
+
: collectionsDocsListDocs(
|
|
463
|
+
this.client,
|
|
464
|
+
{
|
|
465
|
+
collectionName: this.collectionName,
|
|
466
|
+
size: params?.size,
|
|
467
|
+
pageToken: params?.pageToken,
|
|
468
|
+
includeVectors: params?.includeVectors,
|
|
469
|
+
},
|
|
470
|
+
options,
|
|
471
|
+
),
|
|
447
472
|
);
|
|
448
473
|
if (!result.isDocsInline && result.docsUrl) {
|
|
449
474
|
const docs = await fetchDocsFromUrl<ListDocsDoc>(result.docsUrl);
|
|
@@ -460,11 +485,35 @@ class CollectionDocs {
|
|
|
460
485
|
params?: ListDocsInput,
|
|
461
486
|
options?: RequestOptions,
|
|
462
487
|
): Promise<Result<ListDocsResponse, ListDocsError>> {
|
|
463
|
-
const
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
488
|
+
const useExtendedList = params?.filter != null
|
|
489
|
+
|| params?.partitionFilter != null
|
|
490
|
+
|| params?.fields != null;
|
|
491
|
+
const result = useExtendedList
|
|
492
|
+
? await collectionsDocsListDocsExtended(
|
|
493
|
+
this.client,
|
|
494
|
+
{
|
|
495
|
+
collectionName: this.collectionName,
|
|
496
|
+
requestBody: {
|
|
497
|
+
size: params?.size,
|
|
498
|
+
pageToken: params?.pageToken,
|
|
499
|
+
filter: params?.filter,
|
|
500
|
+
partitionFilter: params?.partitionFilter,
|
|
501
|
+
fields: params?.fields,
|
|
502
|
+
includeVectors: params?.includeVectors,
|
|
503
|
+
},
|
|
504
|
+
},
|
|
505
|
+
options,
|
|
506
|
+
)
|
|
507
|
+
: await collectionsDocsListDocs(
|
|
508
|
+
this.client,
|
|
509
|
+
{
|
|
510
|
+
collectionName: this.collectionName,
|
|
511
|
+
size: params?.size,
|
|
512
|
+
pageToken: params?.pageToken,
|
|
513
|
+
includeVectors: params?.includeVectors,
|
|
514
|
+
},
|
|
515
|
+
options,
|
|
516
|
+
);
|
|
468
517
|
if (!result.ok) return result;
|
|
469
518
|
if (!result.value.isDocsInline && result.value.docsUrl) {
|
|
470
519
|
try {
|
|
@@ -494,7 +543,14 @@ class CollectionDocs {
|
|
|
494
543
|
options?: RequestOptions,
|
|
495
544
|
): AsyncGenerator<ListDocsResponse> {
|
|
496
545
|
let pageToken: string | undefined = params?.pageToken;
|
|
497
|
-
const baseParams: ListDocsInput = {
|
|
546
|
+
const baseParams: ListDocsInput = {
|
|
547
|
+
size: params?.size,
|
|
548
|
+
pageToken,
|
|
549
|
+
filter: params?.filter,
|
|
550
|
+
partitionFilter: params?.partitionFilter,
|
|
551
|
+
fields: params?.fields,
|
|
552
|
+
includeVectors: params?.includeVectors,
|
|
553
|
+
};
|
|
498
554
|
while (true) {
|
|
499
555
|
const page = await this.list({ ...baseParams, pageToken }, options);
|
|
500
556
|
yield page;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LambdaDBClient, type LambdaDBClientOptions } from "../../client.js";
|
|
2
2
|
import { ResourceNotFoundError } from "../../models/errors/index.js";
|
|
3
|
-
import type { CreateCollectionInput } from "../../types/public.js";
|
|
3
|
+
import type { CreateCollectionInput, ListDocsInput } from "../../types/public.js";
|
|
4
4
|
import {
|
|
5
5
|
ORIGINAL_ID_FIELD,
|
|
6
6
|
mergeIndexConfigs,
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
} from "./errors.js";
|
|
25
25
|
|
|
26
26
|
type JsonObject = { [key: string]: unknown };
|
|
27
|
+
type ListDocsBody = ListDocsInput;
|
|
27
28
|
|
|
28
29
|
type CollectionLike = {
|
|
29
30
|
get(): Promise<{ collection: JsonObject }>;
|
|
@@ -34,7 +35,7 @@ type CollectionLike = {
|
|
|
34
35
|
upsert(body: { docs: JsonObject[] }): Promise<unknown>;
|
|
35
36
|
fetch(body: JsonObject): Promise<{ docs: unknown[] }>;
|
|
36
37
|
delete(body: { ids?: string[]; filter?: JsonObject }): Promise<unknown>;
|
|
37
|
-
list(body?:
|
|
38
|
+
list(body?: ListDocsBody): Promise<{
|
|
38
39
|
docs: unknown[];
|
|
39
40
|
nextPageToken?: string | undefined;
|
|
40
41
|
}>;
|
|
@@ -615,6 +616,7 @@ export class QdrantCompatClient {
|
|
|
615
616
|
options: {
|
|
616
617
|
scrollFilter?: models.Filter | JsonObject | null;
|
|
617
618
|
scroll_filter?: models.Filter | JsonObject | null;
|
|
619
|
+
offset?: string | number | undefined;
|
|
618
620
|
limit?: number | undefined;
|
|
619
621
|
withPayload?: PayloadSelector | undefined;
|
|
620
622
|
with_payload?: PayloadSelector | undefined;
|
|
@@ -626,6 +628,7 @@ export class QdrantCompatClient {
|
|
|
626
628
|
const {
|
|
627
629
|
scrollFilter,
|
|
628
630
|
scroll_filter: scrollFilterSnake,
|
|
631
|
+
offset,
|
|
629
632
|
limit = 10,
|
|
630
633
|
withPayload,
|
|
631
634
|
with_payload: withPayloadSnake,
|
|
@@ -634,19 +637,27 @@ export class QdrantCompatClient {
|
|
|
634
637
|
...rest
|
|
635
638
|
} = options;
|
|
636
639
|
warnIgnored(rest);
|
|
637
|
-
if (
|
|
638
|
-
throw new UnsupportedQdrantFeatureError(
|
|
640
|
+
if (offset !== undefined && typeof offset !== "string") {
|
|
641
|
+
throw new UnsupportedQdrantFeatureError(
|
|
642
|
+
"Qdrant point-id scroll offsets are not supported; use the returned LambdaDB page-token offset",
|
|
643
|
+
);
|
|
639
644
|
}
|
|
640
645
|
const payloadSelector = normalizePayloadSelector(withPayload ?? withPayloadSnake ?? true);
|
|
641
646
|
const vectorSelector = normalizeVectorSelector(withVectors ?? withVectorsSnake ?? false);
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
647
|
+
const fields = fieldsForSelectors(payloadSelector, vectorSelector);
|
|
648
|
+
const convertedFilter = filterToLambdaDB(scrollFilter ?? scrollFilterSnake);
|
|
649
|
+
const listBody: ListDocsBody = {
|
|
650
|
+
size: limit,
|
|
651
|
+
includeVectors: vectorSelector !== false,
|
|
652
|
+
};
|
|
653
|
+
if (offset !== undefined) listBody.pageToken = offset;
|
|
654
|
+
if (Object.keys(convertedFilter).length > 0) listBody.filter = convertedFilter;
|
|
655
|
+
if (fields !== undefined) listBody.fields = fields;
|
|
656
|
+
const response = await this.client.collection(collectionName).docs.list(listBody);
|
|
646
657
|
return [
|
|
647
658
|
response.docs.map((doc) => docToRecord(doc, {
|
|
648
659
|
withPayload: payloadSelector,
|
|
649
|
-
withVectors:
|
|
660
|
+
withVectors: vectorSelector,
|
|
650
661
|
})),
|
|
651
662
|
response.nextPageToken,
|
|
652
663
|
];
|
|
@@ -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(
|
|
@@ -103,6 +103,7 @@ 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,
|
|
107
108
|
"size": payload.size,
|
|
108
109
|
});
|
|
@@ -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/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.4.3",
|
|
77
77
|
genVersion: "2.798.0",
|
|
78
78
|
userAgent:
|
|
79
|
-
"speakeasy-sdk/typescript 0.
|
|
79
|
+
"speakeasy-sdk/typescript 0.4.3 2.798.0 1.1.1 @functional-systems/lambdadb",
|
|
80
80
|
} as const;
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as z from "zod/v3";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
6
7
|
import { nullToUndefined, safeParse } from "../../lib/schemas.js";
|
|
7
8
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
9
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
import * as models from "../index.js";
|
|
9
11
|
|
|
10
12
|
export type ListDocsRequest = {
|
|
11
13
|
/**
|
|
@@ -20,6 +22,10 @@ export type ListDocsRequest = {
|
|
|
20
22
|
* Next page token.
|
|
21
23
|
*/
|
|
22
24
|
pageToken?: string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Set to true to include vector values in the response. Defaults to false.
|
|
27
|
+
*/
|
|
28
|
+
includeVectors?: boolean | undefined;
|
|
23
29
|
};
|
|
24
30
|
|
|
25
31
|
export type ListDocsDoc = {
|
|
@@ -52,6 +58,7 @@ export type ListDocsRequest$Outbound = {
|
|
|
52
58
|
collectionName: string;
|
|
53
59
|
size?: number | undefined;
|
|
54
60
|
pageToken?: string | undefined;
|
|
61
|
+
includeVectors: boolean;
|
|
55
62
|
};
|
|
56
63
|
|
|
57
64
|
/** @internal */
|
|
@@ -63,6 +70,7 @@ export const ListDocsRequest$outboundSchema: z.ZodType<
|
|
|
63
70
|
collectionName: z.string(),
|
|
64
71
|
size: z.number().int().optional(),
|
|
65
72
|
pageToken: z.string().optional(),
|
|
73
|
+
includeVectors: z.boolean().default(false),
|
|
66
74
|
});
|
|
67
75
|
|
|
68
76
|
export function listDocsRequestToJSON(
|
|
@@ -71,6 +79,98 @@ export function listDocsRequestToJSON(
|
|
|
71
79
|
return JSON.stringify(ListDocsRequest$outboundSchema.parse(listDocsRequest));
|
|
72
80
|
}
|
|
73
81
|
|
|
82
|
+
export type ListDocsExtendedRequestBody = {
|
|
83
|
+
/**
|
|
84
|
+
* Max number of documents to return at once.
|
|
85
|
+
*/
|
|
86
|
+
size?: number | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Next page token.
|
|
89
|
+
*/
|
|
90
|
+
pageToken?: string | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* Filter applied before pagination.
|
|
93
|
+
*/
|
|
94
|
+
filter?: { [k: string]: any } | undefined;
|
|
95
|
+
partitionFilter?: models.PartitionFilter | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* An object to specify a list of field names to include and/or exclude in the result.
|
|
98
|
+
*/
|
|
99
|
+
fields?: models.FieldsSelectorUnion | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Set to true to include vector values in the response. Defaults to false.
|
|
102
|
+
*/
|
|
103
|
+
includeVectors?: boolean | undefined;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export type ListDocsExtendedRequest = {
|
|
107
|
+
/**
|
|
108
|
+
* Collection name.
|
|
109
|
+
*/
|
|
110
|
+
collectionName: string;
|
|
111
|
+
requestBody: ListDocsExtendedRequestBody;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/** @internal */
|
|
115
|
+
export type ListDocsExtendedRequestBody$Outbound = {
|
|
116
|
+
size?: number | undefined;
|
|
117
|
+
pageToken?: string | undefined;
|
|
118
|
+
filter?: { [k: string]: any } | undefined;
|
|
119
|
+
partitionFilter?: models.PartitionFilter$Outbound | undefined;
|
|
120
|
+
fields?: models.FieldsSelectorUnion$Outbound | undefined;
|
|
121
|
+
includeVectors: boolean;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/** @internal */
|
|
125
|
+
export const ListDocsExtendedRequestBody$outboundSchema: z.ZodType<
|
|
126
|
+
ListDocsExtendedRequestBody$Outbound,
|
|
127
|
+
z.ZodTypeDef,
|
|
128
|
+
ListDocsExtendedRequestBody
|
|
129
|
+
> = z.object({
|
|
130
|
+
size: z.number().int().optional(),
|
|
131
|
+
pageToken: z.string().optional(),
|
|
132
|
+
filter: z.record(z.any()).optional(),
|
|
133
|
+
partitionFilter: models.PartitionFilter$outboundSchema.optional(),
|
|
134
|
+
fields: models.FieldsSelectorUnion$outboundSchema.optional(),
|
|
135
|
+
includeVectors: z.boolean().default(false),
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
export function listDocsExtendedRequestBodyToJSON(
|
|
139
|
+
listDocsExtendedRequestBody: ListDocsExtendedRequestBody,
|
|
140
|
+
): string {
|
|
141
|
+
return JSON.stringify(
|
|
142
|
+
ListDocsExtendedRequestBody$outboundSchema.parse(listDocsExtendedRequestBody),
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** @internal */
|
|
147
|
+
export type ListDocsExtendedRequest$Outbound = {
|
|
148
|
+
collectionName: string;
|
|
149
|
+
RequestBody: ListDocsExtendedRequestBody$Outbound;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/** @internal */
|
|
153
|
+
export const ListDocsExtendedRequest$outboundSchema: z.ZodType<
|
|
154
|
+
ListDocsExtendedRequest$Outbound,
|
|
155
|
+
z.ZodTypeDef,
|
|
156
|
+
ListDocsExtendedRequest
|
|
157
|
+
> = z.object({
|
|
158
|
+
collectionName: z.string(),
|
|
159
|
+
requestBody: z.lazy(() => ListDocsExtendedRequestBody$outboundSchema),
|
|
160
|
+
}).transform((v) => {
|
|
161
|
+
return remap$(v, {
|
|
162
|
+
requestBody: "RequestBody",
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
export function listDocsExtendedRequestToJSON(
|
|
167
|
+
listDocsExtendedRequest: ListDocsExtendedRequest,
|
|
168
|
+
): string {
|
|
169
|
+
return JSON.stringify(
|
|
170
|
+
ListDocsExtendedRequest$outboundSchema.parse(listDocsExtendedRequest),
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
74
174
|
/** @internal */
|
|
75
175
|
export const ListDocsDoc$inboundSchema: z.ZodType<
|
|
76
176
|
ListDocsDoc,
|
package/src/types/public.ts
CHANGED
|
@@ -16,8 +16,15 @@ export type { BulkUpsertDocsRequestBody as BulkUpsertInput } from "../models/ope
|
|
|
16
16
|
import type { ListDocsRequest } from "../models/operations/listdocs.js";
|
|
17
17
|
import type { ListCollectionsRequest } from "../models/operations/listcollections.js";
|
|
18
18
|
|
|
19
|
-
/** Parameters for listing documents
|
|
20
|
-
export type ListDocsInput = Pick<
|
|
19
|
+
/** Parameters for listing documents, including extended list options. */
|
|
20
|
+
export type ListDocsInput = Pick<
|
|
21
|
+
ListDocsRequest,
|
|
22
|
+
"size" | "pageToken" | "includeVectors"
|
|
23
|
+
> & {
|
|
24
|
+
filter?: Record<string, unknown> | undefined;
|
|
25
|
+
partitionFilter?: import("../models/index.js").PartitionFilter | undefined;
|
|
26
|
+
fields?: import("../models/index.js").FieldsSelectorUnion | undefined;
|
|
27
|
+
};
|
|
21
28
|
|
|
22
29
|
/** Parameters for listing collections (size, pageToken). */
|
|
23
30
|
export type ListCollectionsInput = Pick<
|
package/test/public-api.test.mjs
CHANGED
|
@@ -391,6 +391,7 @@ test("collection docs helpers paginate through the user-facing scoped API", asyn
|
|
|
391
391
|
const { calls, client } = createClient((call, index) => {
|
|
392
392
|
assert.equal(call.method, "GET");
|
|
393
393
|
assert.equal(call.url.pathname, "/projects/project-one/collections/items/docs");
|
|
394
|
+
assert.equal(call.url.searchParams.get("includeVectors"), "false");
|
|
394
395
|
|
|
395
396
|
if (index === 0) {
|
|
396
397
|
return jsonResponse({
|
|
@@ -422,6 +423,56 @@ test("collection docs helpers paginate through the user-facing scoped API", asyn
|
|
|
422
423
|
]);
|
|
423
424
|
});
|
|
424
425
|
|
|
426
|
+
test("collection docs list supports includeVectors and extended list options", async () => {
|
|
427
|
+
const { calls, client } = createClient((call, index) => {
|
|
428
|
+
if (index === 0) {
|
|
429
|
+
assert.equal(call.method, "GET");
|
|
430
|
+
assert.equal(call.url.pathname, "/projects/project-one/collections/items/docs");
|
|
431
|
+
assert.equal(call.url.searchParams.get("size"), "10");
|
|
432
|
+
assert.equal(call.url.searchParams.get("includeVectors"), "true");
|
|
433
|
+
return jsonResponse({
|
|
434
|
+
total: 1,
|
|
435
|
+
docs: [{ collection: "items", doc: { id: "a", embedding: [0.1, 0.2] } }],
|
|
436
|
+
nextPageToken: null,
|
|
437
|
+
isDocsInline: true,
|
|
438
|
+
docsUrl: null,
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
assert.equal(call.method, "POST");
|
|
443
|
+
assert.equal(call.url.pathname, "/projects/project-one/collections/items/docs/list");
|
|
444
|
+
assert.deepEqual(JSON.parse(call.body), {
|
|
445
|
+
size: 10,
|
|
446
|
+
filter: { queryString: { query: "category:docs" } },
|
|
447
|
+
partitionFilter: { field: "tenant", in: ["acme"] },
|
|
448
|
+
fields: { include: ["id", "title"] },
|
|
449
|
+
includeVectors: false,
|
|
450
|
+
});
|
|
451
|
+
return jsonResponse({
|
|
452
|
+
total: 1,
|
|
453
|
+
docs: [{ collection: "items", doc: { id: "a", title: "LambdaDB" } }],
|
|
454
|
+
nextPageToken: null,
|
|
455
|
+
isDocsInline: true,
|
|
456
|
+
docsUrl: null,
|
|
457
|
+
});
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
const listResult = await client.collection("items").docs.list({
|
|
461
|
+
size: 10,
|
|
462
|
+
includeVectors: true,
|
|
463
|
+
});
|
|
464
|
+
const extendedResult = await client.collection("items").docs.list({
|
|
465
|
+
size: 10,
|
|
466
|
+
filter: { queryString: { query: "category:docs" } },
|
|
467
|
+
partitionFilter: { field: "tenant", in: ["acme"] },
|
|
468
|
+
fields: { include: ["id", "title"] },
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
assert.equal(calls.length, 2);
|
|
472
|
+
assert.deepEqual(listResult.docs[0].doc.embedding, [0.1, 0.2]);
|
|
473
|
+
assert.deepEqual(extendedResult.docs[0].doc, { id: "a", title: "LambdaDB" });
|
|
474
|
+
});
|
|
475
|
+
|
|
425
476
|
test("collection query fetches docsUrl and returns inline docs through the public API", async () => {
|
|
426
477
|
const originalFetch = globalThis.fetch;
|
|
427
478
|
const docsUrlCalls = [];
|