Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
/ js-client Public archive

Commit

Permalink
Merge pull request #418 from gravwell/release/2.1.0
Browse files Browse the repository at this point in the history
chore: Merge release/2.1.0 to main
  • Loading branch information
ashnwade authored Sep 29, 2023
2 parents e337393 + 3e76e96 commit 5352d27
Show file tree
Hide file tree
Showing 66 changed files with 520 additions and 252 deletions.
42 changes: 7 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@types/node": "14.14.27",
"base-64": "^1.0.0",
"date-fns": "^2.17.0",
"decoders": "^1.25.5",
"decoders": "^2.0.4",
"form-data": "^3.0.0",
"isomorphic-ws": "^4.0.1",
"lodash": "^4.17.15",
Expand Down
6 changes: 3 additions & 3 deletions src/functions/groups/create-one-group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* license. See the LICENSE file for details.
*/

import { CreatableGroup, isGroup } from '~/models';
import { CreatableGroup, groupDecoder } from '~/models';
import { integrationTest, integrationTestSpecDef, TEST_BASE_API_CONTEXT } from '~/tests';
import { makeCreateOneGroup } from './create-one-group';
import { makeDeleteOneGroup } from './delete-one-group';
Expand Down Expand Up @@ -46,7 +46,7 @@ describe(
};

const group = await createOneGroup(data);
expect(isGroup(group)).toBeTrue();
expect(groupDecoder.guard(group)).toBeTrue();
expect(group).toEqual(jasmine.objectContaining(data));

const currentGroups = await getAllGroups();
Expand All @@ -63,7 +63,7 @@ describe(
};

const group = await createOneGroup(data);
expect(isGroup(group)).toBeTrue();
expect(groupDecoder.guard(group)).toBeTrue();
expect(group).toEqual(jasmine.objectContaining(data));

const currentGroups = await getAllGroups();
Expand Down
4 changes: 2 additions & 2 deletions src/functions/groups/get-all-groups.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* license. See the LICENSE file for details.
*/

import { CreatableGroup, isGroup } from '~/models';
import { CreatableGroup, groupDecoder } from '~/models';
import { integrationTest, integrationTestSpecDef, TEST_BASE_API_CONTEXT } from '~/tests';
import { makeCreateOneGroup } from './create-one-group';
import { makeDeleteOneGroup } from './delete-one-group';
Expand Down Expand Up @@ -47,7 +47,7 @@ describe(

const groups = await getAllGroups();
expect(groups.length).toBe(2);
expect(groups.every(isGroup)).toBeTrue();
expect(groups.every(group => groupDecoder.guard(group))).toBeTrue();
}),
);

Expand Down
4 changes: 2 additions & 2 deletions src/functions/groups/get-groups-by-user.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* license. See the LICENSE file for details.
*/

import { CreatableGroup, CreatableUser, isGroup, User } from '~/models';
import { CreatableGroup, CreatableUser, groupDecoder, User } from '~/models';
import { integrationTest, integrationTestSpecDef, TEST_BASE_API_CONTEXT } from '~/tests';
import { NumericID } from '~/value-objects';
import { makeCreateOneUser, makeDeleteOneUser } from '../users';
Expand Down Expand Up @@ -94,7 +94,7 @@ describe(

const groups = await getGroupsByUser(user.id);
expect(groups.length).toBe(addedGroupIDs.length);
expect(groups.every(isGroup)).toBeTrue();
expect(groups.every(group => groupDecoder.guard(group))).toBeTrue();
expect(groups.map(g => g.id).sort()).toEqual(addedGroupIDs.sort());

// const _user = await getOneUser( user.id);
Expand Down
4 changes: 2 additions & 2 deletions src/functions/groups/get-one-group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* license. See the LICENSE file for details.
*/

import { CreatableGroup, isGroup } from '~/models';
import { CreatableGroup, groupDecoder } from '~/models';
import { integrationTest, integrationTestSpecDef, TEST_BASE_API_CONTEXT } from '~/tests';
import { NumericID } from '~/value-objects';
import { makeCreateOneGroup } from './create-one-group';
Expand Down Expand Up @@ -48,7 +48,7 @@ describe(
'Should return a group',
integrationTest(async () => {
const group = await getOneGroup(groupID);
expect(isGroup(group)).toBeTrue();
expect(groupDecoder.guard(group)).toBeTrue();
}),
);
}),
Expand Down
4 changes: 2 additions & 2 deletions src/functions/groups/update-one-group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* license. See the LICENSE file for details.
*/

import { CreatableGroup, Group, isGroup, UpdatableGroup } from '~/models';
import { CreatableGroup, Group, groupDecoder, UpdatableGroup } from '~/models';
import { integrationTest, integrationTestSpecDef, TEST_BASE_API_CONTEXT } from '~/tests';
import { makeCreateOneGroup } from './create-one-group';
import { makeDeleteOneGroup } from './delete-one-group';
Expand Down Expand Up @@ -75,7 +75,7 @@ describe(
const data: UpdatableGroup = { ...test, id: createdGroup.id };
await updateOneGroup(data);
const group = await getOneGroup(data.id);
expect(isGroup(group)).toBeTrue();
expect(groupDecoder.guard(group)).toBeTrue();
expect(group).toEqual(jasmine.objectContaining(data));
}
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import {
CreatableTargetedNotification,
CreatableTargetedNotificationByTargetType,
creatableTargetedNotificationGuard,
creatableTargetedNotificationDecoder,
TargetedNotificationTargetType,
toRawCreatableTargetedNotification,
} from '~/models';
Expand All @@ -32,7 +32,7 @@ export const makeCreateOneTargetedNotification =
try {
// There may be some trick to make {...creatable, targetType} pass as a CreatableTargetedNotification,
// but I couldn't make it work. Until someone figures that out, this guard will work.
const _creatable: CreatableTargetedNotification = creatableTargetedNotificationGuard({
const _creatable: CreatableTargetedNotification = creatableTargetedNotificationDecoder.verify({
...creatable,
targetType,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* license. See the LICENSE file for details.
*/

import { CreatableScheduledQuery, isScheduledQuery } from '~/models';
import { CreatableScheduledQuery, scheduledQueryDecoder } from '~/models';
import { integrationTest, integrationTestSpecDef, myCustomMatchers, TEST_BASE_API_CONTEXT } from '~/tests';
import { NumericID } from '~/value-objects';
import { makeCreateOneGroup } from '../groups/create-one-group';
Expand Down Expand Up @@ -71,6 +71,9 @@ describe(

oneShot: true,
isDisabled: true,

timeframeOffset: { days: 0, hours: 0, minutes: 0, seconds: 0 },
backfillEnabled: false,
},
{
groupIDs,
Expand All @@ -86,12 +89,15 @@ describe(

oneShot: false,
isDisabled: false,

timeframeOffset: { days: 0, hours: 0, minutes: 0, seconds: 0 },
backfillEnabled: false,
},
];

const scheduledQueries = await createManyScheduledQueries(data);
for (const q of scheduledQueries) {
expect(isScheduledQuery(q)).toBeTrue();
expect(scheduledQueryDecoder.guard(q)).toBeTrue();
}
expect(scheduledQueries).toPartiallyEqual(data);
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* license. See the LICENSE file for details.
*/

import { CreatableScheduledQuery, isScheduledQuery } from '~/models';
import { CreatableScheduledQuery, scheduledQueryDecoder } from '~/models';
import { integrationTest, integrationTestSpecDef, myCustomMatchers, TEST_BASE_API_CONTEXT } from '~/tests';
import { NumericID } from '~/value-objects';
import { makeCreateOneGroup } from '../groups/create-one-group';
Expand Down Expand Up @@ -70,10 +70,13 @@ describe(

oneShot: true,
isDisabled: true,

timeframeOffset: { days: 0, hours: 0, minutes: 0, seconds: 0 },
backfillEnabled: false,
};

const scheduledQuery = await createOneScheduledQuery(data);
expect(isScheduledQuery(scheduledQuery)).toBeTrue();
expect(scheduledQueryDecoder.guard(scheduledQuery)).toBeTrue();
expect(scheduledQuery).toPartiallyEqual(data);
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,17 @@ describe(
schedule: '0 1 * * *',
query: 'tag=netflow',
searchSince: { secondsAgo: 60 * 60 },
timeframeOffset: { days: 0, hours: 0, minutes: 0, seconds: 0 },
backfillEnabled: true,
},
{
name: 'Q2',
description: 'D2',
schedule: '0 1 * * *',
query: 'tag=default',
searchSince: { lastRun: true, secondsAgo: 90 },
timeframeOffset: { days: 0, hours: 0, minutes: 0, seconds: 0 },
backfillEnabled: true,
},
]);

Expand Down Expand Up @@ -90,20 +94,26 @@ describe(
schedule: '0 1 * * *',
query: 'tag=netflow',
searchSince: { secondsAgo: 60 * 60 },
timeframeOffset: { days: 0, hours: 0, minutes: 0, seconds: 0 },
backfillEnabled: true,
},
{
name: 'Q4',
description: 'D4',
schedule: '0 1 * * *',
query: 'tag=default',
searchSince: { lastRun: true, secondsAgo: 90 },
timeframeOffset: { days: 0, hours: 0, minutes: 0, seconds: 0 },
backfillEnabled: true,
},
{
name: 'Q5',
description: 'D5',
schedule: '0 1 * * *',
query: 'tag=test',
searchSince: { lastRun: true },
searchSince: { lastRun: true, secondsAgo: 60 },
timeframeOffset: { days: 0, hours: 0, minutes: 0, seconds: 0 },
backfillEnabled: true,
},
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ describe(
schedule: '0 1 * * *',
query: 'tag=netflow',
searchSince: { secondsAgo: 60 * 60 },
timeframeOffset: { days: 0, hours: 0, minutes: 0, seconds: 0 },
backfillEnabled: true,
},
{
name: 'Q2',
description: 'D2',
schedule: '0 1 * * *',
query: 'tag=default',
searchSince: { lastRun: true, secondsAgo: 90 },
timeframeOffset: { days: 0, hours: 0, minutes: 0, seconds: 0 },
backfillEnabled: true,
},
]);

Expand Down Expand Up @@ -94,20 +98,26 @@ describe(
schedule: '0 1 * * *',
query: 'tag=netflow',
searchSince: { secondsAgo: 60 * 60 },
timeframeOffset: { days: 0, hours: 0, minutes: 0, seconds: 0 },
backfillEnabled: true,
},
{
name: 'Q4',
description: 'D4',
schedule: '0 1 * * *',
query: 'tag=default',
searchSince: { lastRun: true, secondsAgo: 90 },
timeframeOffset: { days: 0, hours: 0, minutes: 0, seconds: 0 },
backfillEnabled: true,
},
{
name: 'Q5',
description: 'D5',
schedule: '0 1 * * *',
query: 'tag=test',
searchSince: { lastRun: true },
searchSince: { lastRun: true, secondsAgo: 60 },
timeframeOffset: { days: 0, hours: 0, minutes: 0, seconds: 0 },
backfillEnabled: true,
},
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ describe(
schedule: '0 1 * * *',
query: 'tag=netflow',
searchSince: { secondsAgo: 60 * 60 },
timeframeOffset: { days: 0, hours: 0, minutes: 0, seconds: 0 },
backfillEnabled: true,
},
{
name: 'Q2',
description: 'D2',
schedule: '0 1 * * *',
query: 'tag=default',
searchSince: { lastRun: true, secondsAgo: 90 },
timeframeOffset: { days: 0, hours: 0, minutes: 0, seconds: 0 },
backfillEnabled: true,
},
]);

Expand Down
Loading

0 comments on commit 5352d27

Please sign in to comment.