@depup/typesense 3.0.5-depup.1 → 3.1.0-depup.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 +3 -3
- package/changes.json +3 -3
- package/dist/typesense.js +2484 -1684
- package/dist/typesense.js.map +1 -1
- package/dist/typesense.min.js +1 -1
- package/dist/typesense.min.js.map +1 -1
- package/lib/Typesense/ApiCall.js +1 -1
- package/lib/Typesense/ApiCall.js.map +1 -1
- package/lib/Typesense/Collection.d.ts +0 -1
- package/lib/Typesense/Collection.js.map +1 -1
- package/lib/Typesense/Configuration.js +8 -5
- package/lib/Typesense/Configuration.js.map +1 -1
- package/lib/Typesense/CurationSetItem.d.ts +2 -1
- package/lib/Typesense/CurationSetItem.js.map +1 -1
- package/lib/Typesense/Document.d.ts +5 -1
- package/lib/Typesense/Document.js +5 -2
- package/lib/Typesense/Document.js.map +1 -1
- package/lib/Typesense/Documents.d.ts +5 -3
- package/lib/Typesense/Documents.js +16 -0
- package/lib/Typesense/Documents.js.map +1 -1
- package/lib/Typesense/MultiSearch.js +4 -1
- package/lib/Typesense/MultiSearch.js.map +1 -1
- package/lib/Typesense/Types.d.ts +10 -4
- package/package.json +21 -33
- package/src/Typesense/ApiCall.ts +1 -1
- package/src/Typesense/Collection.ts +0 -1
- package/src/Typesense/Configuration.ts +11 -7
- package/src/Typesense/CurationSetItem.ts +5 -1
- package/src/Typesense/Document.ts +10 -2
- package/src/Typesense/Documents.ts +36 -4
- package/src/Typesense/MultiSearch.ts +7 -2
- package/src/Typesense/Types.ts +25 -4
|
@@ -5,6 +5,12 @@ import Documents, {
|
|
|
5
5
|
DocumentSchema,
|
|
6
6
|
DocumentWriteParameters,
|
|
7
7
|
} from "./Documents";
|
|
8
|
+
import { normalizeArrayableParams } from "./Utils";
|
|
9
|
+
|
|
10
|
+
export interface DocumentsRetrieveParameters {
|
|
11
|
+
include_fields?: string | string[];
|
|
12
|
+
exclude_fields?: string | string[];
|
|
13
|
+
}
|
|
8
14
|
|
|
9
15
|
export class Document<T extends DocumentSchema = object> {
|
|
10
16
|
constructor(
|
|
@@ -13,8 +19,10 @@ export class Document<T extends DocumentSchema = object> {
|
|
|
13
19
|
private apiCall: ApiCall
|
|
14
20
|
) {}
|
|
15
21
|
|
|
16
|
-
async retrieve(): Promise<T> {
|
|
17
|
-
|
|
22
|
+
async retrieve(options?: DocumentsRetrieveParameters): Promise<T> {
|
|
23
|
+
const queryParams = normalizeArrayableParams(options ?? {})
|
|
24
|
+
|
|
25
|
+
return this.apiCall.get<T>(this.endpointPath(), queryParams);
|
|
18
26
|
}
|
|
19
27
|
|
|
20
28
|
async delete(options?: DeleteQuery): Promise<T> {
|
|
@@ -214,12 +214,15 @@ export default class Documents<T extends DocumentSchema = object>
|
|
|
214
214
|
super(collectionName, apiCall, configuration);
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
async create(
|
|
217
|
+
async create(
|
|
218
|
+
document: T,
|
|
219
|
+
options: Omit<DocumentWriteParameters, "action"> = {},
|
|
220
|
+
): Promise<T> {
|
|
218
221
|
if (!document) throw new Error("No document provided");
|
|
219
222
|
return this.apiCall.post<T>(this.endpointPath(), document, options);
|
|
220
223
|
}
|
|
221
224
|
|
|
222
|
-
async upsert(document: T, options: DocumentWriteParameters = {}): Promise<T> {
|
|
225
|
+
async upsert(document: T, options: Omit<DocumentWriteParameters, "action"> = {}): Promise<T> {
|
|
223
226
|
if (!document) throw new Error("No document provided");
|
|
224
227
|
return this.apiCall.post<T>(
|
|
225
228
|
this.endpointPath(),
|
|
@@ -232,10 +235,10 @@ export default class Documents<T extends DocumentSchema = object>
|
|
|
232
235
|
document: T,
|
|
233
236
|
options: UpdateByFilterParameters,
|
|
234
237
|
): Promise<UpdateByFilterResponse>;
|
|
235
|
-
async update(document: T, options: DocumentWriteParameters): Promise<T>;
|
|
238
|
+
async update(document: T, options: Omit<DocumentWriteParameters, "action">): Promise<T>;
|
|
236
239
|
async update(
|
|
237
240
|
document: T,
|
|
238
|
-
options: DocumentWriteParameters | UpdateByFilterParameters = {},
|
|
241
|
+
options: Omit<DocumentWriteParameters, "action"> | UpdateByFilterParameters = {},
|
|
239
242
|
): Promise<UpdateByFilterResponse | T> {
|
|
240
243
|
if (!document) throw new Error("No document provided");
|
|
241
244
|
|
|
@@ -254,6 +257,35 @@ export default class Documents<T extends DocumentSchema = object>
|
|
|
254
257
|
}
|
|
255
258
|
}
|
|
256
259
|
|
|
260
|
+
async emplace(
|
|
261
|
+
document: T,
|
|
262
|
+
options: UpdateByFilterParameters,
|
|
263
|
+
): Promise<UpdateByFilterResponse>;
|
|
264
|
+
async emplace(
|
|
265
|
+
document: T,
|
|
266
|
+
options: Omit<DocumentWriteParameters, "action">,
|
|
267
|
+
): Promise<T>;
|
|
268
|
+
async emplace(
|
|
269
|
+
document: T,
|
|
270
|
+
options: Omit<DocumentWriteParameters, "action"> | UpdateByFilterParameters = {},
|
|
271
|
+
): Promise<UpdateByFilterResponse | T> {
|
|
272
|
+
if (!document) throw new Error("No document provided");
|
|
273
|
+
|
|
274
|
+
if (options["filter_by"] != null) {
|
|
275
|
+
return this.apiCall.patch<T>(
|
|
276
|
+
this.endpointPath(),
|
|
277
|
+
document,
|
|
278
|
+
Object.assign({}, options),
|
|
279
|
+
);
|
|
280
|
+
} else {
|
|
281
|
+
return this.apiCall.post<T>(
|
|
282
|
+
this.endpointPath(),
|
|
283
|
+
document,
|
|
284
|
+
Object.assign({}, options, { action: "emplace" }),
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
257
289
|
async delete(
|
|
258
290
|
query: DeleteQuery = {} as DeleteQuery,
|
|
259
291
|
): Promise<DeleteResponse<T>> {
|
|
@@ -87,9 +87,14 @@ export default class MultiSearch {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
const normalizedSearchRequests: Omit<typeof searchRequests, "searches"> & {
|
|
90
|
+
remove_duplicates?: boolean;
|
|
90
91
|
searches: ExtractBaseTypes<SearchParams<T[number], Infix>>[];
|
|
91
92
|
} = {
|
|
92
93
|
union: searchRequests.union,
|
|
94
|
+
remove_duplicates:
|
|
95
|
+
"remove_duplicates" in searchRequests
|
|
96
|
+
? searchRequests.remove_duplicates
|
|
97
|
+
: undefined,
|
|
93
98
|
searches: searchRequests.searches.map(
|
|
94
99
|
normalizeArrayableParams<
|
|
95
100
|
T[number],
|
|
@@ -124,8 +129,8 @@ export default class MultiSearch {
|
|
|
124
129
|
);
|
|
125
130
|
}
|
|
126
131
|
|
|
127
|
-
private isStreamingRequest(commonParams: {
|
|
128
|
-
return commonParams.
|
|
132
|
+
private isStreamingRequest(commonParams: { conversation_stream?: boolean }) {
|
|
133
|
+
return commonParams.conversation_stream === true;
|
|
129
134
|
}
|
|
130
135
|
|
|
131
136
|
private hasAnySearchObjectPagination(searchRequests: MultiSearchRequestsSchema<DocumentSchema, string>) {
|
package/src/Typesense/Types.ts
CHANGED
|
@@ -202,9 +202,22 @@ export interface SearchableDocuments<
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
export interface WriteableDocuments<T> {
|
|
205
|
-
create(
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
create(
|
|
206
|
+
document: T,
|
|
207
|
+
options: Omit<DocumentWriteParameters, "action">,
|
|
208
|
+
): Promise<T>;
|
|
209
|
+
upsert(
|
|
210
|
+
document: T,
|
|
211
|
+
options: Omit<DocumentWriteParameters, "action">,
|
|
212
|
+
): Promise<T>;
|
|
213
|
+
update(
|
|
214
|
+
document: T,
|
|
215
|
+
options: Omit<DocumentWriteParameters, "action">,
|
|
216
|
+
): Promise<T>;
|
|
217
|
+
emplace(
|
|
218
|
+
document: T,
|
|
219
|
+
options: Omit<DocumentWriteParameters, "action">,
|
|
220
|
+
): Promise<T>;
|
|
208
221
|
delete(query: DeleteQuery): Promise<DeleteResponse>;
|
|
209
222
|
import(
|
|
210
223
|
documents: T[] | string,
|
|
@@ -245,6 +258,7 @@ export interface MultiSearchRequestsWithUnionSchema<
|
|
|
245
258
|
Infix extends string,
|
|
246
259
|
> extends SearchesMultiSearchesRequestSchema<T, Infix> {
|
|
247
260
|
union: true;
|
|
261
|
+
remove_duplicates?: boolean;
|
|
248
262
|
}
|
|
249
263
|
|
|
250
264
|
export interface MultiSearchRequestsWithoutUnionSchema<
|
|
@@ -263,7 +277,14 @@ export type MultiSearchRequestsSchema<
|
|
|
263
277
|
|
|
264
278
|
export interface UnionSearchResponse<T extends DocumentSchema>
|
|
265
279
|
extends Omit<SearchResponse<T>, "request_params"> {
|
|
266
|
-
union_request_params:
|
|
280
|
+
union_request_params: UnionSearchResponseRequestParams[];
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
type AllRequiredBut<T, K extends keyof T> = Required<Omit<T, K>> & Pick<T, K>;
|
|
284
|
+
|
|
285
|
+
export interface UnionSearchResponseRequestParams
|
|
286
|
+
extends AllRequiredBut<SearchResponseRequestParams, "voice_query"> {
|
|
287
|
+
found: number;
|
|
267
288
|
}
|
|
268
289
|
|
|
269
290
|
export type MultiSearchResponse<
|