@@ -749,7 +749,8 @@ export class ClientEncryption {
749
749
expressionMode : boolean ,
750
750
options : ClientEncryptionEncryptOptions
751
751
) : Promise < Binary > {
752
- const { algorithm, keyId, keyAltName, contentionFactor, queryType, rangeOptions } = options ;
752
+ const { algorithm, keyId, keyAltName, contentionFactor, queryType, rangeOptions, textOptions } =
753
+ options ;
753
754
const contextOptions : ExplicitEncryptionContextOptions = {
754
755
expressionMode,
755
756
algorithm
@@ -782,6 +783,11 @@ export class ClientEncryption {
782
783
contextOptions . rangeOptions = serialize ( rangeOptions ) ;
783
784
}
784
785
786
+ if ( typeof textOptions === 'object' ) {
787
+ // @ts -expect-error errors until mongodb-client-encryption release
788
+ contextOptions . textOptions = serialize ( textOptions ) ;
789
+ }
790
+
785
791
const valueBuffer = serialize ( { v : value } ) ;
786
792
const stateMachine = new StateMachine ( {
787
793
proxyOptions : this . _proxyOptions ,
@@ -812,7 +818,8 @@ export interface ClientEncryptionEncryptOptions {
812
818
| 'AEAD_AES_256_CBC_HMAC_SHA_512-Random'
813
819
| 'Indexed'
814
820
| 'Unindexed'
815
- | 'Range' ;
821
+ | 'Range'
822
+ | 'TextPreview' ;
816
823
817
824
/**
818
825
* The id of the Binary dataKey to use for encryption
@@ -830,10 +837,33 @@ export interface ClientEncryptionEncryptOptions {
830
837
/**
831
838
* The query type.
832
839
*/
833
- queryType ?: 'equality' | 'range' ;
840
+ queryType ?: 'equality' | 'range' | 'prefixPreview' | 'suffixPreview' | 'substringPreview' ;
834
841
835
842
/** The index options for a Queryable Encryption field supporting "range" queries.*/
836
843
rangeOptions ?: RangeOptions ;
844
+
845
+ textOptions ?: TextQueryOptions ;
846
+ }
847
+
848
+ interface TextQueryOptions {
849
+ caseSensitive : boolean ;
850
+ diacraticSensitive : boolean ;
851
+
852
+ prefix ?: {
853
+ strMaxQueryLength : Int32 | number ;
854
+ strMinQueryLength : Int32 | number ;
855
+ } ;
856
+
857
+ suffix ?: {
858
+ strMaxQueryLength : Int32 | number ;
859
+ strMinQueryLength : Int32 | number ;
860
+ } ;
861
+
862
+ substring ?: {
863
+ strMaxLength : Int32 | number ;
864
+ strMaxQueryLength : Int32 | number ;
865
+ strMinQueryLength : Int32 | number ;
866
+ } ;
837
867
}
838
868
839
869
/**
0 commit comments