@@ -129,63 +129,71 @@ export class CollectionClassificationResultObject {
129129@external ( "hypermode" , "upsertToCollection_v2" )
130130declare function hostUpsertToCollection (
131131 collection : string ,
132+ namespace : string ,
132133 keys : string [ ] ,
133134 texts : string [ ] ,
134135 labels : string [ ] [ ] ,
135136) : CollectionMutationResult ;
136137
137138// @ts -expect-error: decorator
138- @external ( "hypermode" , "deleteFromCollection " )
139+ @external ( "hypermode" , "deleteFromCollection_v2 " )
139140declare function hostDeleteFromCollection (
140141 collection : string ,
142+ namespace : string ,
141143 key : string ,
142144) : CollectionMutationResult ;
143145
144146// @ts -expect-error: decorator
145- @external ( "hypermode" , "searchCollection " )
147+ @external ( "hypermode" , "searchCollection_v2 " )
146148declare function hostSearchCollection (
147149 collection : string ,
150+ namespace : string ,
148151 searchMethod : string ,
149152 text : string ,
150153 limit : i32 ,
151154 returnText : bool ,
152155) : CollectionSearchResult ;
153156
154157// @ts -expect-error: decorator
155- @external ( "hypermode" , "nnClassifyCollection " )
158+ @external ( "hypermode" , "nnClassifyCollection_v2 " )
156159declare function hostNnClassifyCollection (
157160 collection : string ,
161+ namespace : string ,
158162 searchMethod : string ,
159163 text : string ,
160164) : CollectionClassificationResult ;
161165
162166// @ts -expect-error: decorator
163- @external ( "hypermode" , "recomputeSearchMethod " )
167+ @external ( "hypermode" , "recomputeSearchMethod_v2 " )
164168declare function hostRecomputeSearchMethod (
165169 collection : string ,
170+ namespace : string ,
166171 searchMethod : string ,
167172) : SearchMethodMutationResult ;
168173
169174// @ts -expect-error: decorator
170- @external ( "hypermode" , "computeDistance " )
175+ @external ( "hypermode" , "computeDistance_v2 " )
171176declare function hostComputeDistance (
172177 collection : string ,
178+ namespace : string ,
173179 searchMethod : string ,
174180 key1 : string ,
175181 key2 : string ,
176182) : CollectionSearchResultObject ;
177183
178184// @ts -expect-error: decorator
179- @external ( "hypermode" , "getTextFromCollection " )
185+ @external ( "hypermode" , "getTextFromCollection_v2 " )
180186declare function hostGetTextFromCollection (
181187 collection : string ,
188+ namespace : string ,
182189 key : string ,
183190) : string ;
184191
185192// @ts -expect-error: decorator
186- @external ( "hypermode" , "getTextsFromCollection " )
193+ @external ( "hypermode" , "getTextsFromCollection_v2 " )
187194declare function hostGetTextsFromCollection (
188195 collection : string ,
196+ namespace : string ,
189197) : Map < string , string > ;
190198
191199// add batch upsert
@@ -194,6 +202,7 @@ export function upsertBatch(
194202 keys : string [ ] | null ,
195203 texts : string [ ] ,
196204 labelsArr : string [ ] [ ] = [ ] ,
205+ namespace : string = "" ,
197206) : CollectionMutationResult {
198207 if ( collection . length == 0 ) {
199208 console . error ( "Collection is empty." ) ;
@@ -218,7 +227,13 @@ export function upsertBatch(
218227 keysArr = keys ;
219228 }
220229
221- const result = hostUpsertToCollection ( collection , keysArr , texts , labelsArr ) ;
230+ const result = hostUpsertToCollection (
231+ collection ,
232+ namespace ,
233+ keysArr ,
234+ texts ,
235+ labelsArr ,
236+ ) ;
222237 if ( utils . resultIsInvalid ( result ) ) {
223238 console . error ( "Error upserting to Text index." ) ;
224239 return new CollectionMutationResult (
@@ -238,6 +253,7 @@ export function upsert(
238253 key : string | null ,
239254 text : string ,
240255 labels : string [ ] = [ ] ,
256+ namespace : string = "" ,
241257) : CollectionMutationResult {
242258 if ( collection . length == 0 ) {
243259 console . error ( "Collection is empty." ) ;
@@ -266,7 +282,13 @@ export function upsert(
266282
267283 const labelsArr : string [ ] [ ] = [ labels ] ;
268284
269- const result = hostUpsertToCollection ( collection , keys , texts , labelsArr ) ;
285+ const result = hostUpsertToCollection (
286+ collection ,
287+ namespace ,
288+ keys ,
289+ texts ,
290+ labelsArr ,
291+ ) ;
270292 if ( utils . resultIsInvalid ( result ) ) {
271293 console . error ( "Error upserting to Text index." ) ;
272294 return new CollectionMutationResult (
@@ -283,6 +305,7 @@ export function upsert(
283305export function remove (
284306 collection : string ,
285307 key : string ,
308+ namespace : string = "" ,
286309) : CollectionMutationResult {
287310 if ( collection . length == 0 ) {
288311 console . error ( "Collection is empty." ) ;
@@ -302,7 +325,7 @@ export function remove(
302325 "delete" ,
303326 ) ;
304327 }
305- const result = hostDeleteFromCollection ( collection , key ) ;
328+ const result = hostDeleteFromCollection ( collection , namespace , key ) ;
306329 if ( utils . resultIsInvalid ( result ) ) {
307330 console . error ( "Error deleting from Text index." ) ;
308331 return new CollectionMutationResult (
@@ -324,6 +347,7 @@ export function search(
324347 text : string ,
325348 limit : i32 ,
326349 returnText : bool = false ,
350+ namespace : string = "" ,
327351) : CollectionSearchResult {
328352 if ( text . length == 0 ) {
329353 console . error ( "Text is empty." ) ;
@@ -337,6 +361,7 @@ export function search(
337361 }
338362 const result = hostSearchCollection (
339363 collection ,
364+ namespace ,
340365 searchMethod ,
341366 text ,
342367 limit ,
@@ -361,6 +386,7 @@ export function nnClassify(
361386 collection : string ,
362387 searchMethod : string ,
363388 text : string ,
389+ namespace : string = "" ,
364390) : CollectionClassificationResult {
365391 if ( text . length == 0 ) {
366392 console . error ( "Text is empty." ) ;
@@ -373,7 +399,12 @@ export function nnClassify(
373399 [ ] ,
374400 ) ;
375401 }
376- const result = hostNnClassifyCollection ( collection , searchMethod , text ) ;
402+ const result = hostNnClassifyCollection (
403+ collection ,
404+ namespace ,
405+ searchMethod ,
406+ text ,
407+ ) ;
377408 if ( utils . resultIsInvalid ( result ) ) {
378409 console . error ( "Error classifying Text index." ) ;
379410 return new CollectionClassificationResult (
@@ -391,6 +422,7 @@ export function nnClassify(
391422export function recomputeSearchMethod (
392423 collection : string ,
393424 searchMethod : string ,
425+ namespace : string = "" ,
394426) : SearchMethodMutationResult {
395427 if ( collection . length == 0 ) {
396428 console . error ( "Collection is empty." ) ;
@@ -412,7 +444,7 @@ export function recomputeSearchMethod(
412444 searchMethod ,
413445 ) ;
414446 }
415- const result = hostRecomputeSearchMethod ( collection , searchMethod ) ;
447+ const result = hostRecomputeSearchMethod ( collection , namespace , searchMethod ) ;
416448 if ( utils . resultIsInvalid ( result ) ) {
417449 console . error ( "Error recomputing Text index." ) ;
418450 return new SearchMethodMutationResult (
@@ -434,15 +466,17 @@ export function computeSimilarity(
434466 searchMethod : string ,
435467 key1 : string ,
436468 key2 : string ,
469+ namespace : string = "" ,
437470) : CollectionSearchResultObject {
438- return computeDistance ( collection , searchMethod , key1 , key2 ) ;
471+ return computeDistance ( collection , searchMethod , key1 , key2 , namespace ) ;
439472}
440473
441474export function computeDistance (
442475 collection : string ,
443476 searchMethod : string ,
444477 key1 : string ,
445478 key2 : string ,
479+ namespace : string = "" ,
446480) : CollectionSearchResultObject {
447481 if ( collection . length == 0 ) {
448482 console . error ( "Collection is empty." ) ;
@@ -460,10 +494,14 @@ export function computeDistance(
460494 console . error ( "Key2 is empty." ) ;
461495 return new CollectionSearchResultObject ( "" , "" , 0.0 , 0.0 ) ;
462496 }
463- return hostComputeDistance ( collection , searchMethod , key1 , key2 ) ;
497+ return hostComputeDistance ( collection , namespace , searchMethod , key1 , key2 ) ;
464498}
465499
466- export function getText ( collection : string , key : string ) : string {
500+ export function getText (
501+ collection : string ,
502+ key : string ,
503+ namespace : string = "" ,
504+ ) : string {
467505 if ( collection . length == 0 ) {
468506 console . error ( "Collection is empty." ) ;
469507 return "" ;
@@ -472,13 +510,16 @@ export function getText(collection: string, key: string): string {
472510 console . error ( "Key is empty." ) ;
473511 return "" ;
474512 }
475- return hostGetTextFromCollection ( collection , key ) ;
513+ return hostGetTextFromCollection ( collection , namespace , key ) ;
476514}
477515
478- export function getTexts ( collection : string ) : Map < string , string > {
516+ export function getTexts (
517+ collection : string ,
518+ namespace : string = "" ,
519+ ) : Map < string , string > {
479520 if ( collection . length == 0 ) {
480521 console . error ( "Collection is empty." ) ;
481522 return new Map < string , string > ( ) ;
482523 }
483- return hostGetTextsFromCollection ( collection ) ;
524+ return hostGetTextsFromCollection ( collection , namespace ) ;
484525}
0 commit comments