@@ -129,63 +129,71 @@ export class CollectionClassificationResultObject {
129
129
@external ( "hypermode" , "upsertToCollection_v2" )
130
130
declare function hostUpsertToCollection (
131
131
collection : string ,
132
+ namespace : string ,
132
133
keys : string [ ] ,
133
134
texts : string [ ] ,
134
135
labels : string [ ] [ ] ,
135
136
) : CollectionMutationResult ;
136
137
137
138
// @ts -expect-error: decorator
138
- @external ( "hypermode" , "deleteFromCollection " )
139
+ @external ( "hypermode" , "deleteFromCollection_v2 " )
139
140
declare function hostDeleteFromCollection (
140
141
collection : string ,
142
+ namespace : string ,
141
143
key : string ,
142
144
) : CollectionMutationResult ;
143
145
144
146
// @ts -expect-error: decorator
145
- @external ( "hypermode" , "searchCollection " )
147
+ @external ( "hypermode" , "searchCollection_v2 " )
146
148
declare function hostSearchCollection (
147
149
collection : string ,
150
+ namespace : string ,
148
151
searchMethod : string ,
149
152
text : string ,
150
153
limit : i32 ,
151
154
returnText : bool ,
152
155
) : CollectionSearchResult ;
153
156
154
157
// @ts -expect-error: decorator
155
- @external ( "hypermode" , "nnClassifyCollection " )
158
+ @external ( "hypermode" , "nnClassifyCollection_v2 " )
156
159
declare function hostNnClassifyCollection (
157
160
collection : string ,
161
+ namespace : string ,
158
162
searchMethod : string ,
159
163
text : string ,
160
164
) : CollectionClassificationResult ;
161
165
162
166
// @ts -expect-error: decorator
163
- @external ( "hypermode" , "recomputeSearchMethod " )
167
+ @external ( "hypermode" , "recomputeSearchMethod_v2 " )
164
168
declare function hostRecomputeSearchMethod (
165
169
collection : string ,
170
+ namespace : string ,
166
171
searchMethod : string ,
167
172
) : SearchMethodMutationResult ;
168
173
169
174
// @ts -expect-error: decorator
170
- @external ( "hypermode" , "computeDistance " )
175
+ @external ( "hypermode" , "computeDistance_v2 " )
171
176
declare function hostComputeDistance (
172
177
collection : string ,
178
+ namespace : string ,
173
179
searchMethod : string ,
174
180
key1 : string ,
175
181
key2 : string ,
176
182
) : CollectionSearchResultObject ;
177
183
178
184
// @ts -expect-error: decorator
179
- @external ( "hypermode" , "getTextFromCollection " )
185
+ @external ( "hypermode" , "getTextFromCollection_v2 " )
180
186
declare function hostGetTextFromCollection (
181
187
collection : string ,
188
+ namespace : string ,
182
189
key : string ,
183
190
) : string ;
184
191
185
192
// @ts -expect-error: decorator
186
- @external ( "hypermode" , "getTextsFromCollection " )
193
+ @external ( "hypermode" , "getTextsFromCollection_v2 " )
187
194
declare function hostGetTextsFromCollection (
188
195
collection : string ,
196
+ namespace : string ,
189
197
) : Map < string , string > ;
190
198
191
199
// add batch upsert
@@ -194,6 +202,7 @@ export function upsertBatch(
194
202
keys : string [ ] | null ,
195
203
texts : string [ ] ,
196
204
labelsArr : string [ ] [ ] = [ ] ,
205
+ namespace : string = "" ,
197
206
) : CollectionMutationResult {
198
207
if ( collection . length == 0 ) {
199
208
console . error ( "Collection is empty." ) ;
@@ -218,7 +227,13 @@ export function upsertBatch(
218
227
keysArr = keys ;
219
228
}
220
229
221
- const result = hostUpsertToCollection ( collection , keysArr , texts , labelsArr ) ;
230
+ const result = hostUpsertToCollection (
231
+ collection ,
232
+ namespace ,
233
+ keysArr ,
234
+ texts ,
235
+ labelsArr ,
236
+ ) ;
222
237
if ( utils . resultIsInvalid ( result ) ) {
223
238
console . error ( "Error upserting to Text index." ) ;
224
239
return new CollectionMutationResult (
@@ -238,6 +253,7 @@ export function upsert(
238
253
key : string | null ,
239
254
text : string ,
240
255
labels : string [ ] = [ ] ,
256
+ namespace : string = "" ,
241
257
) : CollectionMutationResult {
242
258
if ( collection . length == 0 ) {
243
259
console . error ( "Collection is empty." ) ;
@@ -266,7 +282,13 @@ export function upsert(
266
282
267
283
const labelsArr : string [ ] [ ] = [ labels ] ;
268
284
269
- const result = hostUpsertToCollection ( collection , keys , texts , labelsArr ) ;
285
+ const result = hostUpsertToCollection (
286
+ collection ,
287
+ namespace ,
288
+ keys ,
289
+ texts ,
290
+ labelsArr ,
291
+ ) ;
270
292
if ( utils . resultIsInvalid ( result ) ) {
271
293
console . error ( "Error upserting to Text index." ) ;
272
294
return new CollectionMutationResult (
@@ -283,6 +305,7 @@ export function upsert(
283
305
export function remove (
284
306
collection : string ,
285
307
key : string ,
308
+ namespace : string = "" ,
286
309
) : CollectionMutationResult {
287
310
if ( collection . length == 0 ) {
288
311
console . error ( "Collection is empty." ) ;
@@ -302,7 +325,7 @@ export function remove(
302
325
"delete" ,
303
326
) ;
304
327
}
305
- const result = hostDeleteFromCollection ( collection , key ) ;
328
+ const result = hostDeleteFromCollection ( collection , namespace , key ) ;
306
329
if ( utils . resultIsInvalid ( result ) ) {
307
330
console . error ( "Error deleting from Text index." ) ;
308
331
return new CollectionMutationResult (
@@ -324,6 +347,7 @@ export function search(
324
347
text : string ,
325
348
limit : i32 ,
326
349
returnText : bool = false ,
350
+ namespace : string = "" ,
327
351
) : CollectionSearchResult {
328
352
if ( text . length == 0 ) {
329
353
console . error ( "Text is empty." ) ;
@@ -337,6 +361,7 @@ export function search(
337
361
}
338
362
const result = hostSearchCollection (
339
363
collection ,
364
+ namespace ,
340
365
searchMethod ,
341
366
text ,
342
367
limit ,
@@ -361,6 +386,7 @@ export function nnClassify(
361
386
collection : string ,
362
387
searchMethod : string ,
363
388
text : string ,
389
+ namespace : string = "" ,
364
390
) : CollectionClassificationResult {
365
391
if ( text . length == 0 ) {
366
392
console . error ( "Text is empty." ) ;
@@ -373,7 +399,12 @@ export function nnClassify(
373
399
[ ] ,
374
400
) ;
375
401
}
376
- const result = hostNnClassifyCollection ( collection , searchMethod , text ) ;
402
+ const result = hostNnClassifyCollection (
403
+ collection ,
404
+ namespace ,
405
+ searchMethod ,
406
+ text ,
407
+ ) ;
377
408
if ( utils . resultIsInvalid ( result ) ) {
378
409
console . error ( "Error classifying Text index." ) ;
379
410
return new CollectionClassificationResult (
@@ -391,6 +422,7 @@ export function nnClassify(
391
422
export function recomputeSearchMethod (
392
423
collection : string ,
393
424
searchMethod : string ,
425
+ namespace : string = "" ,
394
426
) : SearchMethodMutationResult {
395
427
if ( collection . length == 0 ) {
396
428
console . error ( "Collection is empty." ) ;
@@ -412,7 +444,7 @@ export function recomputeSearchMethod(
412
444
searchMethod ,
413
445
) ;
414
446
}
415
- const result = hostRecomputeSearchMethod ( collection , searchMethod ) ;
447
+ const result = hostRecomputeSearchMethod ( collection , namespace , searchMethod ) ;
416
448
if ( utils . resultIsInvalid ( result ) ) {
417
449
console . error ( "Error recomputing Text index." ) ;
418
450
return new SearchMethodMutationResult (
@@ -434,15 +466,17 @@ export function computeSimilarity(
434
466
searchMethod : string ,
435
467
key1 : string ,
436
468
key2 : string ,
469
+ namespace : string = "" ,
437
470
) : CollectionSearchResultObject {
438
- return computeDistance ( collection , searchMethod , key1 , key2 ) ;
471
+ return computeDistance ( collection , searchMethod , key1 , key2 , namespace ) ;
439
472
}
440
473
441
474
export function computeDistance (
442
475
collection : string ,
443
476
searchMethod : string ,
444
477
key1 : string ,
445
478
key2 : string ,
479
+ namespace : string = "" ,
446
480
) : CollectionSearchResultObject {
447
481
if ( collection . length == 0 ) {
448
482
console . error ( "Collection is empty." ) ;
@@ -460,10 +494,14 @@ export function computeDistance(
460
494
console . error ( "Key2 is empty." ) ;
461
495
return new CollectionSearchResultObject ( "" , "" , 0.0 , 0.0 ) ;
462
496
}
463
- return hostComputeDistance ( collection , searchMethod , key1 , key2 ) ;
497
+ return hostComputeDistance ( collection , namespace , searchMethod , key1 , key2 ) ;
464
498
}
465
499
466
- export function getText ( collection : string , key : string ) : string {
500
+ export function getText (
501
+ collection : string ,
502
+ key : string ,
503
+ namespace : string = "" ,
504
+ ) : string {
467
505
if ( collection . length == 0 ) {
468
506
console . error ( "Collection is empty." ) ;
469
507
return "" ;
@@ -472,13 +510,16 @@ export function getText(collection: string, key: string): string {
472
510
console . error ( "Key is empty." ) ;
473
511
return "" ;
474
512
}
475
- return hostGetTextFromCollection ( collection , key ) ;
513
+ return hostGetTextFromCollection ( collection , namespace , key ) ;
476
514
}
477
515
478
- export function getTexts ( collection : string ) : Map < string , string > {
516
+ export function getTexts (
517
+ collection : string ,
518
+ namespace : string = "" ,
519
+ ) : Map < string , string > {
479
520
if ( collection . length == 0 ) {
480
521
console . error ( "Collection is empty." ) ;
481
522
return new Map < string , string > ( ) ;
482
523
}
483
- return hostGetTextsFromCollection ( collection ) ;
524
+ return hostGetTextsFromCollection ( collection , namespace ) ;
484
525
}
0 commit comments