@@ -23,10 +23,14 @@ import {
23
23
CaptureInterval ,
24
24
ConfigureDatabaseUserRequest ,
25
25
ConfigureDatabaseUserResponse ,
26
+ CreateIndexRequest ,
27
+ CreateIndexResponse ,
26
28
DataRequest ,
27
29
DeleteBinaryDataByFilterRequest ,
28
30
DeleteBinaryDataByFilterResponse ,
29
31
DeleteBinaryDataByIDsResponse ,
32
+ DeleteIndexRequest ,
33
+ DeleteIndexResponse ,
30
34
DeleteTabularDataResponse ,
31
35
ExportTabularDataRequest ,
32
36
ExportTabularDataResponse ,
@@ -35,6 +39,11 @@ import {
35
39
GetDatabaseConnectionResponse ,
36
40
GetLatestTabularDataRequest ,
37
41
GetLatestTabularDataResponse ,
42
+ Index ,
43
+ IndexableCollection ,
44
+ IndexCreator ,
45
+ ListIndexesRequest ,
46
+ ListIndexesResponse ,
38
47
RemoveBinaryDataFromDatasetByIDsRequest ,
39
48
RemoveBinaryDataFromDatasetByIDsResponse ,
40
49
RemoveBoundingBoxFromImageByIDRequest ,
@@ -46,6 +55,7 @@ import {
46
55
TabularData ,
47
56
TabularDataByFilterRequest ,
48
57
TabularDataByFilterResponse ,
58
+ TabularDataByMQLRequest ,
49
59
TabularDataByMQLResponse ,
50
60
TabularDataBySQLResponse ,
51
61
TabularDataSourceType ,
@@ -325,6 +335,36 @@ describe('DataClient tests', () => {
325
335
expect ( result [ 0 ] ?. key1 ) . toBeInstanceOf ( Date ) ;
326
336
expect ( promise ) . toEqual ( data ) ;
327
337
} ) ;
338
+
339
+ it ( 'get tabular data from MQL with queryPrefixName' , async ( ) => {
340
+ const expectedRequest = new TabularDataByMQLRequest ( {
341
+ organizationId : 'some_org_id' ,
342
+ mqlBinary : [ BSON . serialize ( { query : 'some_mql_query' } ) ] ,
343
+ queryPrefixName : 'my_prefix' ,
344
+ } ) ;
345
+ let capReq : TabularDataByMQLRequest | undefined = undefined ;
346
+ mockTransport = createRouterTransport ( ( { service } ) => {
347
+ service ( DataService , {
348
+ tabularDataByMQL : ( req ) => {
349
+ capReq = req ;
350
+ return new TabularDataByMQLResponse ( {
351
+ rawData : data . map ( ( x ) => BSON . serialize ( x ) ) ,
352
+ } ) ;
353
+ } ,
354
+ } ) ;
355
+ } ) ;
356
+ const promise = await subject ( ) . tabularDataByMQL (
357
+ 'some_org_id' ,
358
+ [ { query : 'some_mql_query' } ] ,
359
+ false ,
360
+ undefined ,
361
+ 'my_prefix'
362
+ ) ;
363
+ expect ( capReq ) . toStrictEqual ( expectedRequest ) ;
364
+ const result = promise as typeof data ;
365
+ expect ( result [ 0 ] ?. key1 ) . toBeInstanceOf ( Date ) ;
366
+ expect ( promise ) . toEqual ( data ) ;
367
+ } ) ;
328
368
} ) ;
329
369
330
370
describe ( 'tabularDataByFilter tests' , ( ) => {
@@ -486,7 +526,7 @@ describe('DataClient tests', () => {
486
526
expect ( promise [ 1 ] ?. binary ) . toEqual ( bin2 ) ;
487
527
} ) ;
488
528
489
- it ( 'get binary data by ids ' , async ( ) => {
529
+ it ( 'get binary data by id ' , async ( ) => {
490
530
const promise = await subject ( ) . binaryDataByIds ( [ binaryId1 , binaryId2 ] ) ;
491
531
expect ( promise . length ) . toEqual ( 2 ) ;
492
532
expect ( promise [ 0 ] ?. binary ) . toEqual ( bin1 ) ;
@@ -1040,6 +1080,161 @@ describe('DataClient tests', () => {
1040
1080
} ) ;
1041
1081
} ) ;
1042
1082
1083
+ describe ( 'createIndex tests' , ( ) => {
1084
+ let capReq : CreateIndexRequest ;
1085
+ beforeEach ( ( ) => {
1086
+ mockTransport = createRouterTransport ( ( { service } ) => {
1087
+ service ( DataService , {
1088
+ createIndex : ( req ) => {
1089
+ capReq = req ;
1090
+ return new CreateIndexResponse ( ) ;
1091
+ } ,
1092
+ } ) ;
1093
+ } ) ;
1094
+ } ) ;
1095
+ it ( 'creates an index' , async ( ) => {
1096
+ const organizationId = 'orgId' ;
1097
+ const collectionType = IndexableCollection . HOT_STORE ;
1098
+ const indexSpec = [
1099
+ new TextEncoder ( ) . encode ( JSON . stringify ( { field : 1 } ) ) ,
1100
+ ] ;
1101
+ const pipelineName = 'pipeline1' ;
1102
+ const expectedRequest = new CreateIndexRequest ( {
1103
+ organizationId,
1104
+ collectionType,
1105
+ indexSpec,
1106
+ pipelineName,
1107
+ } ) ;
1108
+ await subject ( ) . createIndex (
1109
+ organizationId ,
1110
+ collectionType ,
1111
+ indexSpec ,
1112
+ pipelineName
1113
+ ) ;
1114
+ expect ( capReq ) . toStrictEqual ( expectedRequest ) ;
1115
+ } ) ;
1116
+ it ( 'creates an index without pipeline name' , async ( ) => {
1117
+ const organizationId = 'orgId' ;
1118
+ const collectionType = IndexableCollection . HOT_STORE ;
1119
+ const indexSpec = [
1120
+ new TextEncoder ( ) . encode ( JSON . stringify ( { field : 1 } ) ) ,
1121
+ ] ;
1122
+ const expectedRequest = new CreateIndexRequest ( {
1123
+ organizationId,
1124
+ collectionType,
1125
+ indexSpec,
1126
+ } ) ;
1127
+ await subject ( ) . createIndex ( organizationId , collectionType , indexSpec ) ;
1128
+ expect ( capReq ) . toStrictEqual ( expectedRequest ) ;
1129
+ } ) ;
1130
+ } ) ;
1131
+ describe ( 'listIndexes tests' , ( ) => {
1132
+ let capReq : ListIndexesRequest ;
1133
+ const index1 = new Index ( {
1134
+ collectionType : IndexableCollection . HOT_STORE ,
1135
+ indexName : 'index1' ,
1136
+ indexSpec : [ new TextEncoder ( ) . encode ( JSON . stringify ( { field : 1 } ) ) ] ,
1137
+ createdBy : IndexCreator . CUSTOMER ,
1138
+ } ) ;
1139
+ const index2 = new Index ( {
1140
+ collectionType : IndexableCollection . PIPELINE_SINK ,
1141
+ pipelineName : 'pipeline1' ,
1142
+ indexName : 'index2' ,
1143
+ indexSpec : [
1144
+ new TextEncoder ( ) . encode ( JSON . stringify ( { another_field : - 1 } ) ) ,
1145
+ ] ,
1146
+ createdBy : IndexCreator . VIAM ,
1147
+ } ) ;
1148
+ const indexes = [ index1 , index2 ] ;
1149
+ beforeEach ( ( ) => {
1150
+ mockTransport = createRouterTransport ( ( { service } ) => {
1151
+ service ( DataService , {
1152
+ listIndexes : ( req ) => {
1153
+ capReq = req ;
1154
+ return new ListIndexesResponse ( {
1155
+ indexes,
1156
+ } ) ;
1157
+ } ,
1158
+ } ) ;
1159
+ } ) ;
1160
+ } ) ;
1161
+ it ( 'lists indexes' , async ( ) => {
1162
+ const organizationId = 'orgId' ;
1163
+ const collectionType = IndexableCollection . HOT_STORE ;
1164
+ const pipelineName = 'pipeline1' ;
1165
+ const expectedRequest = new ListIndexesRequest ( {
1166
+ organizationId,
1167
+ collectionType,
1168
+ pipelineName,
1169
+ } ) ;
1170
+ const result = await subject ( ) . listIndexes (
1171
+ organizationId ,
1172
+ collectionType ,
1173
+ pipelineName
1174
+ ) ;
1175
+ expect ( capReq ) . toStrictEqual ( expectedRequest ) ;
1176
+ expect ( result ) . toEqual ( indexes ) ;
1177
+ } ) ;
1178
+ it ( 'lists indexes without pipeline name' , async ( ) => {
1179
+ const organizationId = 'orgId' ;
1180
+ const collectionType = IndexableCollection . HOT_STORE ;
1181
+ const expectedRequest = new ListIndexesRequest ( {
1182
+ organizationId,
1183
+ collectionType,
1184
+ } ) ;
1185
+ const result = await subject ( ) . listIndexes (
1186
+ organizationId ,
1187
+ collectionType
1188
+ ) ;
1189
+ expect ( capReq ) . toStrictEqual ( expectedRequest ) ;
1190
+ expect ( result ) . toEqual ( indexes ) ;
1191
+ } ) ;
1192
+ } ) ;
1193
+ describe ( 'deleteIndex tests' , ( ) => {
1194
+ let capReq : DeleteIndexRequest ;
1195
+ beforeEach ( ( ) => {
1196
+ mockTransport = createRouterTransport ( ( { service } ) => {
1197
+ service ( DataService , {
1198
+ deleteIndex : ( req ) => {
1199
+ capReq = req ;
1200
+ return new DeleteIndexResponse ( ) ;
1201
+ } ,
1202
+ } ) ;
1203
+ } ) ;
1204
+ } ) ;
1205
+ it ( 'deletes an index' , async ( ) => {
1206
+ const organizationId = 'orgId' ;
1207
+ const collectionType = IndexableCollection . HOT_STORE ;
1208
+ const indexName = 'my_index' ;
1209
+ const pipelineName = 'pipeline1' ;
1210
+ const expectedRequest = new DeleteIndexRequest ( {
1211
+ organizationId,
1212
+ collectionType,
1213
+ indexName,
1214
+ pipelineName,
1215
+ } ) ;
1216
+ await subject ( ) . deleteIndex (
1217
+ organizationId ,
1218
+ collectionType ,
1219
+ indexName ,
1220
+ pipelineName
1221
+ ) ;
1222
+ expect ( capReq ) . toStrictEqual ( expectedRequest ) ;
1223
+ } ) ;
1224
+ it ( 'deletes an index without pipeline name' , async ( ) => {
1225
+ const organizationId = 'orgId' ;
1226
+ const collectionType = IndexableCollection . HOT_STORE ;
1227
+ const indexName = 'my_index' ;
1228
+ const expectedRequest = new DeleteIndexRequest ( {
1229
+ organizationId,
1230
+ collectionType,
1231
+ indexName,
1232
+ } ) ;
1233
+ await subject ( ) . deleteIndex ( organizationId , collectionType , indexName ) ;
1234
+ expect ( capReq ) . toStrictEqual ( expectedRequest ) ;
1235
+ } ) ;
1236
+ } ) ;
1237
+
1043
1238
describe ( 'createFilter tests' , ( ) => {
1044
1239
it ( 'create empty filter' , ( ) => {
1045
1240
const testFilter = DataClient . createFilter ( { } ) ;
0 commit comments