@blueharford/scrypted-spatial-awareness 0.6.32 → 0.6.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +7 -2
- package/dist/main.nodejs.js +1 -1
- package/dist/main.nodejs.js.map +1 -1
- package/dist/plugin.zip +0 -0
- package/out/main.nodejs.js +607 -229
- package/out/main.nodejs.js.map +1 -1
- package/out/plugin.zip +0 -0
- package/package.json +4 -2
- package/src/alerts/alert-manager.ts +149 -21
- package/src/alerts/alert-utils.ts +32 -0
- package/src/core/topology-discovery.ts +181 -95
- package/src/core/tracking-engine.ts +150 -44
- package/src/main.ts +110 -19
- package/src/models/tracked-object.ts +1 -1
- package/src/state/tracking-state.ts +18 -5
- package/tests/run-tests.ts +50 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import assert from 'assert/strict';
|
|
2
|
+
import {
|
|
3
|
+
getActiveAlertKey,
|
|
4
|
+
hasMeaningfulAlertChange,
|
|
5
|
+
shouldSendUpdateNotification,
|
|
6
|
+
} from '../src/alerts/alert-utils';
|
|
7
|
+
|
|
8
|
+
async function testAlertUpdateHelpers(): Promise<void> {
|
|
9
|
+
const prev = {
|
|
10
|
+
cameraId: 'cam-1',
|
|
11
|
+
objectLabel: 'Person at front',
|
|
12
|
+
involvedLandmarks: ['Front Door'],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const same = {
|
|
16
|
+
cameraId: 'cam-1',
|
|
17
|
+
objectLabel: 'Person at front',
|
|
18
|
+
involvedLandmarks: ['Front Door'],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const changed = {
|
|
22
|
+
cameraId: 'cam-2',
|
|
23
|
+
objectLabel: 'Person moving to driveway',
|
|
24
|
+
involvedLandmarks: ['Driveway'],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
assert.equal(hasMeaningfulAlertChange(prev, same), false);
|
|
28
|
+
assert.equal(hasMeaningfulAlertChange(prev, changed), true);
|
|
29
|
+
|
|
30
|
+
const key = getActiveAlertKey('movement', 'movement', 'obj-1');
|
|
31
|
+
assert.equal(key, 'movement:movement:obj-1');
|
|
32
|
+
|
|
33
|
+
const now = Date.now();
|
|
34
|
+
assert.equal(shouldSendUpdateNotification(false, now - 100000, now, 60000), false);
|
|
35
|
+
assert.equal(shouldSendUpdateNotification(true, now - 100000, now, 60000), true);
|
|
36
|
+
assert.equal(shouldSendUpdateNotification(true, now - 1000, now, 60000), false);
|
|
37
|
+
assert.equal(shouldSendUpdateNotification(true, now - 1000, now, 0), true);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function run(): Promise<void> {
|
|
41
|
+
await testAlertUpdateHelpers();
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.log('All tests passed');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
run().catch(err => {
|
|
47
|
+
// eslint-disable-next-line no-console
|
|
48
|
+
console.error(err);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
});
|