Skip to content

Commit 8dc04f2

Browse files
viambotnjooma
authored andcommitted
[WORKFLOW] AI update based on proto changes from commit b933c17
1 parent 21e4fb5 commit 8dc04f2

File tree

3 files changed

+312
-4
lines changed

3 files changed

+312
-4
lines changed

src/app/data-client.spec.ts

Lines changed: 196 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ import {
2323
CaptureInterval,
2424
ConfigureDatabaseUserRequest,
2525
ConfigureDatabaseUserResponse,
26+
CreateIndexRequest,
27+
CreateIndexResponse,
2628
DataRequest,
2729
DeleteBinaryDataByFilterRequest,
2830
DeleteBinaryDataByFilterResponse,
2931
DeleteBinaryDataByIDsResponse,
32+
DeleteIndexRequest,
33+
DeleteIndexResponse,
3034
DeleteTabularDataResponse,
3135
ExportTabularDataRequest,
3236
ExportTabularDataResponse,
@@ -35,6 +39,11 @@ import {
3539
GetDatabaseConnectionResponse,
3640
GetLatestTabularDataRequest,
3741
GetLatestTabularDataResponse,
42+
Index,
43+
IndexableCollection,
44+
IndexCreator,
45+
ListIndexesRequest,
46+
ListIndexesResponse,
3847
RemoveBinaryDataFromDatasetByIDsRequest,
3948
RemoveBinaryDataFromDatasetByIDsResponse,
4049
RemoveBoundingBoxFromImageByIDRequest,
@@ -46,6 +55,7 @@ import {
4655
TabularData,
4756
TabularDataByFilterRequest,
4857
TabularDataByFilterResponse,
58+
TabularDataByMQLRequest,
4959
TabularDataByMQLResponse,
5060
TabularDataBySQLResponse,
5161
TabularDataSourceType,
@@ -325,6 +335,36 @@ describe('DataClient tests', () => {
325335
expect(result[0]?.key1).toBeInstanceOf(Date);
326336
expect(promise).toEqual(data);
327337
});
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+
});
328368
});
329369

330370
describe('tabularDataByFilter tests', () => {
@@ -486,7 +526,7 @@ describe('DataClient tests', () => {
486526
expect(promise[1]?.binary).toEqual(bin2);
487527
});
488528

489-
it('get binary data by ids', async () => {
529+
it('get binary data by id', async () => {
490530
const promise = await subject().binaryDataByIds([binaryId1, binaryId2]);
491531
expect(promise.length).toEqual(2);
492532
expect(promise[0]?.binary).toEqual(bin1);
@@ -1040,6 +1080,161 @@ describe('DataClient tests', () => {
10401080
});
10411081
});
10421082

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+
10431238
describe('createFilter tests', () => {
10441239
it('create empty filter', () => {
10451240
const testFilter = DataClient.createFilter({});

0 commit comments

Comments
 (0)