@3deye-toolkit/core 0.0.1-alpha.8 → 0.0.1

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/dist/core.d.ts ADDED
@@ -0,0 +1,1001 @@
1
+ /// <reference types="react" />
2
+
3
+ import { BehaviorSubject } from 'rxjs';
4
+ import crossfilter from 'crossfilter2';
5
+ import type { IReactionDisposer } from 'mobx';
6
+ import { Observable } from 'rxjs';
7
+ import { default as React_2 } from 'react';
8
+ import { Subject } from 'rxjs';
9
+ import { Subscription } from 'rxjs';
10
+
11
+ declare class AccountStore extends ApiStore {
12
+ private notification?;
13
+ user: User | null;
14
+ auth: Auth;
15
+ constructor(notification?: NotificationService | undefined);
16
+ get userDisplayName(): string | null;
17
+ protected afterInit(): void;
18
+ loadUser$(): Observable<RawUser | null>;
19
+ setUser: (user: User | null) => void;
20
+ setAuthStore(auth: Auth): void;
21
+ updateUserPassword(passwordData: {
22
+ previous: string;
23
+ new: string;
24
+ }): Promise<void>;
25
+ updateUserSettings({ firstName, lastName }: {
26
+ firstName: string;
27
+ lastName: string;
28
+ }): Observable<RawUser>;
29
+ updateCustomPreferences: (preferences: Record<string, any>) => Observable<RawUser>;
30
+ setDefaultGroup(groupId: number): Observable<RawUser> | undefined;
31
+ getPreference: (key: string) => any;
32
+ private retryOnVersionMismatch;
33
+ }
34
+
35
+ declare class Api<T> {
36
+ [key: string]: any;
37
+ static create<T extends PartialApi>(apiConfig: T | null, authStore: Auth, createConnection: (accessToken: string) => Connection): Api<T> & ExtractHubs<IApi, T>;
38
+ connectionShutdown$: Subject<null>;
39
+ connection$: BehaviorSubject<Connection | null>;
40
+ events: Subject<{
41
+ hub: keyof typeof events;
42
+ event: string;
43
+ data: any;
44
+ }>;
45
+ logging: boolean;
46
+ authStore: Auth;
47
+ createConnection: (accessToken: string) => Connection;
48
+ apiConfig: PartialApi;
49
+ constructor(apiConfig: T, authStore: Auth, createConnection: (accessToken: string) => Connection);
50
+ connect(token: Token): void;
51
+ shutdownConnection(): void;
52
+ private init;
53
+ private createHubMethod;
54
+ private subscribeToEvents;
55
+ }
56
+
57
+ declare type ApiPageResult<T> = {
58
+ success: true;
59
+ resultItems: T[];
60
+ pageInfo: PageInfo;
61
+ } | {
62
+ success: false;
63
+ error: {
64
+ code: number;
65
+ message: string;
66
+ };
67
+ };
68
+
69
+ declare type ApiResult<T> = {
70
+ success: true;
71
+ resultItems: T[];
72
+ } | {
73
+ success: false;
74
+ error: {
75
+ code: number;
76
+ message: string;
77
+ };
78
+ };
79
+
80
+ declare abstract class ApiStore {
81
+ api: Api<IApi> & IApi;
82
+ disposables: (IReactionDisposer | Subscription)[];
83
+ protected afterInit?(): void;
84
+ initWith(api: Api<IApi> & IApi): void;
85
+ dispose(): void;
86
+ }
87
+
88
+ /**
89
+ * @alpha
90
+ */
91
+ export declare const app: ToolkitApp;
92
+
93
+ export declare const AppContext: React_2.Context<ToolkitApp | null>;
94
+
95
+ declare class ArchiveChunk implements Chunk {
96
+ json?: string;
97
+ startTime: Date;
98
+ endTime: Date;
99
+ streamUrl: string;
100
+ duration?: number;
101
+ isLive: false;
102
+ cameraId: number;
103
+ id: number;
104
+ constructor(raw: any);
105
+ }
106
+
107
+ declare class ArchivesStore extends ApiStore {
108
+ private camerasStore;
109
+ data: crossfilter.Crossfilter<ArchiveChunk>;
110
+ chunksByCameraId: crossfilter.Dimension<ArchiveChunk, number>;
111
+ chunksByStart: crossfilter.Dimension<ArchiveChunk, number>;
112
+ chunksByEnd: crossfilter.Dimension<ArchiveChunk, number>;
113
+ chunksById: Map<number, ArchiveChunk>;
114
+ private pendingRequests;
115
+ private pendingRequestsByEnd;
116
+ private pendingRequestsByStart;
117
+ private pendingRequestsByCameraId;
118
+ knownIntervals: Map<number, [Date, Date]>;
119
+ updates: number;
120
+ constructor(camerasStore: CamerasStore);
121
+ /**
122
+ * Fetches archive chunks for given camera and period
123
+ * @param cameraId - camera id
124
+ * @param startTime - start of the period
125
+ * @param endTime - end of the period
126
+ * TODO: add support for null endTime in order to remove requestedArchivesSince logic from player controller
127
+ * TODO: add error handling
128
+ */
129
+ fetch(cameraId: number, startTime: Date, endTime: Date): Observable<ArchiveChunk[]>;
130
+ extendKnownInterval(cameraId: number, startTime: Date, chunks: ArchiveChunk[]): void;
131
+ add(chunks: ArchiveChunk[]): void;
132
+ getChunks({ cameraId, from, to }: ChunksQuery): ArchiveChunk[];
133
+ /**
134
+ * Returns chunk that either contain the given time or is right adjacent to it
135
+ * @param camera - camera id
136
+ * @param time - time to search for
137
+ * @returns ArchiveChunk or undefined if there is no such chunk in the current archive
138
+ */
139
+ getClosestChunkRight: ({ cameraId, time }: {
140
+ cameraId: number;
141
+ time: Date;
142
+ }) => ArchiveChunk;
143
+ /**
144
+ * Return chunks that either contain the given time or is left adjacent to it
145
+ * @param camera - camera id
146
+ * @param time - time to search for
147
+ * @returns ArchiveChunk or undefined if there is no such chunk in the current archive
148
+ */
149
+ getClosestChunkLeft: ({ cameraId, time }: {
150
+ cameraId: number;
151
+ time: Date;
152
+ }) => ArchiveChunk;
153
+ fetchNextChunk: ({ cameraId, time }: {
154
+ cameraId: number;
155
+ time: Date;
156
+ }) => Observable<ArchiveChunk | undefined>;
157
+ fetchPrevChunk: ({ cameraId, time }: {
158
+ cameraId: number;
159
+ time: Date;
160
+ }) => Observable<ArchiveChunk | undefined>;
161
+ protected afterInit(): void;
162
+ }
163
+
164
+ declare class Auth {
165
+ token: Token | null;
166
+ isAuthenticating: boolean;
167
+ storage: Storage_2;
168
+ tokenServiceUrl: string;
169
+ tokenStorageKey: string;
170
+ deviceInfo: string | null;
171
+ clientId: string;
172
+ private pendingUpdateTokenRequest;
173
+ get isAuthenticated(): boolean;
174
+ constructor({ tokenServiceUrl, storage, tokenStorageKey, deviceInfo, clientId }: AuthStoreOptions);
175
+ signOut: () => void;
176
+ signIn: (options: {
177
+ username: string;
178
+ password: string;
179
+ replaceToken?: string;
180
+ agreedWithTerms?: boolean;
181
+ code?: string;
182
+ }) => Promise<Token> | undefined;
183
+ invalidateToken: () => void;
184
+ getTokenFromStorage(): Promise<Token | null>;
185
+ private storeToken;
186
+ private getInitialToken;
187
+ private fetchToken;
188
+ private updateToken;
189
+ private fetchWidgetToken;
190
+ }
191
+
192
+ declare interface AuthStoreOptions {
193
+ tokenServiceUrl: string;
194
+ storage: Storage_2;
195
+ tokenStorageKey: string;
196
+ deviceInfo: any;
197
+ clientId: string;
198
+ }
199
+
200
+ declare interface Box {
201
+ Top: number;
202
+ Left: number;
203
+ Bottom: number;
204
+ Right: number;
205
+ }
206
+
207
+ declare class Camera {
208
+ id: number;
209
+ name: string;
210
+ imageUrl: string;
211
+ streamUrl: string;
212
+ dashStreamUrl: string;
213
+ address: {
214
+ Lat: number;
215
+ Lng: number;
216
+ } | null;
217
+ archiveDuration: number;
218
+ dvrWindowLength: number;
219
+ stateUpdatedAt: Date;
220
+ raw: RawCamera;
221
+ enabled: boolean;
222
+ isMicEnabled: boolean;
223
+ state: string;
224
+ pin: string;
225
+ webRtcUrl: string;
226
+ isPtz: boolean;
227
+ permissions: number;
228
+ get isOnline(): boolean;
229
+ get supportsWebRTC(): boolean;
230
+ constructor(raw: RawCamera);
231
+ update: (raw: RawCamera) => void;
232
+ }
233
+
234
+ declare class CameraEvent {
235
+ cameraId: number;
236
+ type: EventType;
237
+ raw: RawSensorEvent;
238
+ thumbnailUrl: string;
239
+ detectedObjects: DetectedObject[];
240
+ faces: Face[];
241
+ instant: boolean;
242
+ get id(): number;
243
+ get startTime(): Date;
244
+ get endTime(): Date;
245
+ get isLive(): boolean;
246
+ get acknowledged(): boolean;
247
+ constructor(raw: RawSensorEvent);
248
+ }
249
+
250
+ declare class CamerasStore extends ApiStore {
251
+ camerasById: Map<number, Camera>;
252
+ data: Camera[];
253
+ loading: boolean;
254
+ loaded: boolean;
255
+ constructor();
256
+ load: () => Observable<RawCamera[]> | undefined;
257
+ add: (cameras: RawCamera[]) => void;
258
+ sync: () => Observable<RawCamera[]>;
259
+ protected afterInit(): void;
260
+ dispose(): void;
261
+ }
262
+
263
+ declare interface CameraStatistics {
264
+ id: number;
265
+ month: number;
266
+ trafficOutMBytes: number;
267
+ archiveStorageMBytes: number;
268
+ clipStorageMBytes: number;
269
+ }
270
+
271
+ declare interface CamgroupItem {
272
+ id: number;
273
+ order: number;
274
+ }
275
+
276
+ declare interface Chunk {
277
+ json?: string;
278
+ startTime: Date;
279
+ endTime: Date;
280
+ streamUrl: string;
281
+ duration?: number;
282
+ }
283
+
284
+ declare interface ChunksQuery {
285
+ cameraId: number;
286
+ from: Date;
287
+ to: Date;
288
+ }
289
+
290
+ declare interface Connection {
291
+ state: CONNECTION_STATE;
292
+ stop: () => void;
293
+ start: () => Connection;
294
+ done: (callback: () => void) => Connection;
295
+ fail: (callback: (err: any) => void) => Connection;
296
+ error: (callback: (err: any) => void) => Connection;
297
+ disconnected: (callback: () => void) => Connection;
298
+ reconnecting: (callback: () => void) => Connection;
299
+ reconnected: (callback: () => void) => Connection;
300
+ proxies: {
301
+ [P in keyof typeof FULL_API_CONFIG]: {
302
+ on: (eventName: string, callback: (data: any) => void) => void;
303
+ invoke: any;
304
+ };
305
+ };
306
+ createHubProxy: (hubName: string) => void;
307
+ lastError: any;
308
+ qs: {
309
+ access_token: string;
310
+ };
311
+ }
312
+
313
+ declare enum CONNECTION_STATE {
314
+ CONNECTING = 0,
315
+ CONNECTED = 1,
316
+ RECONNECTING = 2,
317
+ DISCONNECTED = 3
318
+ }
319
+
320
+ declare type DeepPartial<T> = {
321
+ [K in keyof T]?: DeepPartial<T[K]>;
322
+ };
323
+
324
+ declare interface DetectedObject {
325
+ Type: string;
326
+ Value?: string;
327
+ Number?: string;
328
+ Box: {
329
+ Left: number;
330
+ Top: number;
331
+ Right: number;
332
+ Bottom: number;
333
+ };
334
+ Probability: number;
335
+ Colors?: {
336
+ Color: string;
337
+ }[];
338
+ }
339
+
340
+ declare interface DetectedObjectOption {
341
+ id: string;
342
+ name: string;
343
+ color: string;
344
+ highlightColor: string;
345
+ type: 'detectedObject';
346
+ }
347
+
348
+ declare const events: {
349
+ [P in keyof PartialApi]: {
350
+ name: string;
351
+ explicit?: boolean;
352
+ }[];
353
+ };
354
+
355
+ declare class EventSchemaStore extends ApiStore {
356
+ schemaDescription: SchemaDescriptionParameter[];
357
+ constructor();
358
+ get foundObjectTypes(): string[];
359
+ get foundObjectTypesForSelect(): DetectedObjectOption[];
360
+ get colorsByFoundObjectType(): Map<string, string>;
361
+ fetchAnalyticEventSchema: () => void;
362
+ protected afterInit(): void;
363
+ dispose(): void;
364
+ }
365
+
366
+ declare interface EventsQuery {
367
+ cameraIds?: number[];
368
+ eventTypes?: EventType[];
369
+ from: Date;
370
+ to: Date | null;
371
+ detectedObjectTypes?: string[];
372
+ colors?: Set<string>;
373
+ probability?: number;
374
+ }
375
+
376
+ declare class EventsStore extends ApiStore {
377
+ private camerasStore;
378
+ data: crossfilter.Crossfilter<CameraEvent>;
379
+ eventsByCameraId: crossfilter.Dimension<CameraEvent, number>;
380
+ eventsByStart: crossfilter.Dimension<CameraEvent, number>;
381
+ eventsByEnd: crossfilter.Dimension<CameraEvent, number>;
382
+ eventsByType: crossfilter.Dimension<CameraEvent, EventType>;
383
+ eventsByFoundObjects: crossfilter.Dimension<CameraEvent, string>;
384
+ eventsByColor: crossfilter.Dimension<CameraEvent, string>;
385
+ eventsByLiveliness: crossfilter.Dimension<CameraEvent, boolean>;
386
+ pendingRequests: crossfilter.Crossfilter<PendingRequest>;
387
+ pendingRequestsByEnd: crossfilter.Dimension<PendingRequest, number>;
388
+ pendingRequestsByStart: crossfilter.Dimension<PendingRequest, number>;
389
+ pendingRequestsByCameraId: crossfilter.Dimension<PendingRequest, number>;
390
+ knownIntervals: crossfilter.Crossfilter<Interval_2>;
391
+ knownIntervalsByCameraId: crossfilter.Dimension<Interval_2, number>;
392
+ knownIntervalsByStart: crossfilter.Dimension<Interval_2, number>;
393
+ knownIntervalsByEnd: crossfilter.Dimension<Interval_2, number>;
394
+ eventsById: Map<number, CameraEvent>;
395
+ updates: number;
396
+ /**
397
+ * Contains recent additions to the store as list of event ids
398
+ * NOTE: do not update several times in single action as we lose info about intermediate additions that way
399
+ */
400
+ recentAdditions: number[];
401
+ constructor(camerasStore: CamerasStore);
402
+ /**
403
+ * Populates store with the events for given camera and period
404
+ * @param cameraId - camera id or -1 to fetch all available events for given period
405
+ * @param startTime - start of the period
406
+ * @param endTime - end of the period
407
+ */
408
+ populateEvents(cameraId: number, startTime: Date, endTime: Date): void;
409
+ update: (data: CameraEvent[]) => void;
410
+ add: (data: CameraEvent[]) => void;
411
+ getEvents({ cameraIds, from, to, detectedObjectTypes, eventTypes, colors, probability }: EventsQuery): CameraEvent[];
412
+ getOverlappedEvents({ cameraId, from, to }: {
413
+ cameraId: number;
414
+ from: Date;
415
+ to: Date;
416
+ }): CameraEvent[];
417
+ getLastNonAnalyticEventBefore({ cameraId, date }: {
418
+ cameraId: number;
419
+ date: Date;
420
+ }): CameraEvent;
421
+ getLastObjectBefore({ cameraId, date, objectFilters }: {
422
+ cameraId: number;
423
+ date: Date;
424
+ objectFilters: {
425
+ people: boolean;
426
+ cars: boolean;
427
+ misc: boolean;
428
+ };
429
+ }): CameraEvent;
430
+ getFirstNonAnalyticEventAfter({ cameraId, date }: {
431
+ cameraId: number;
432
+ date: Date;
433
+ }): CameraEvent;
434
+ getFirstObjectAfter({ cameraId, date, objectFilters }: {
435
+ cameraId: number;
436
+ date: Date;
437
+ objectFilters: {
438
+ people: boolean;
439
+ cars: boolean;
440
+ misc: boolean;
441
+ };
442
+ }): CameraEvent;
443
+ protected afterInit(): void;
444
+ processNewEvents: ({ data }: {
445
+ data: RawSensorEvent[];
446
+ }) => void;
447
+ dispose(): void;
448
+ }
449
+
450
+ declare type EventType = 'Motion' | 'Tampering' | 'PanTiltZoom' | 'CrossLine' | 'Intrusion' | 'LicensePlate' | 'FaceDetection' | 'Audio' | 'Analytic' | 'SpeedDetection' | 'PeopleCounter' | 'Temperature' | 'PoS' | 'GPS' | 'DigitalInput' | 'Normal' | 'Suspicious' | 'Loitering' | 'Vandalism' | 'Trespass' | 'Emergency' | 'LifeInDanger' | 'ErroneousAlert' | 'Misidentification' | 'Fire' | 'MedicalDuress' | 'HoldUp' | 'CheckIn' | 'CheckOut' | 'ClockIn' | 'ClockOut' | 'ParkingStart' | 'ParkingEnd' | 'ParkingViolation' | 'GateAccess' | 'DoorAccess' | 'TemperatureCheck' | 'IDCheck' | 'PPECheck' | 'WelfareCheck' | 'Uncategorized' | 'Unknown';
451
+
452
+ declare type ExtractHubs<T, K> = {
453
+ [P in keyof ExtractMethods<T, K>]: ExtractMethods<T[P], K[P]>;
454
+ };
455
+
456
+ declare type ExtractMethods<T, K> = Pick<T, Extract<keyof T, keyof K>>;
457
+
458
+ declare interface Face {
459
+ PersonId: number;
460
+ Name: string;
461
+ Box: {
462
+ Left: number;
463
+ Top: number;
464
+ Right: number;
465
+ Bottom: number;
466
+ };
467
+ Probability: number;
468
+ }
469
+
470
+ declare const FULL_API_CONFIG: IApi;
471
+
472
+ declare interface GetThumbnailParams {
473
+ cameraId: number;
474
+ from: Date;
475
+ to: Date;
476
+ size?: {
477
+ width: number;
478
+ height: number;
479
+ };
480
+ }
481
+
482
+ declare interface IApi {
483
+ archives: {
484
+ PopulateArchive: (params: {
485
+ cameraId: number;
486
+ endTime: Date;
487
+ startTime: Date;
488
+ }) => Observable<any>;
489
+ GetArchives: (params: Record<string, never>) => Observable<ApiResult<RawClip>>;
490
+ GetClips: () => Observable<any>;
491
+ UpdateClip: (params: any) => Observable<any>;
492
+ DeleteClip: (params: any) => Observable<any>;
493
+ SaveClip: (params: any) => Observable<any>;
494
+ SaveTimelaps: (params: any) => Observable<any>;
495
+ SaveArchive: (params: any) => Observable<any>;
496
+ DeleteArchive: (params: any) => Observable<any>;
497
+ ShareClip: (sharedClip: RawSharedClip) => Observable<ApiResult<RawSharedClip>>;
498
+ GetSharedClips: (recordId: number | null) => Observable<ApiResult<RawSharedClip>>;
499
+ UpdateSharedClip: (sharedClip: RawSharedClip) => Observable<ApiResult<RawSharedClip>>;
500
+ DeleteSharedClip: (recordId: number) => Observable<ApiResult<RawSharedClip>>;
501
+ };
502
+ cameras: {
503
+ GetCameras: (camera: {
504
+ id?: number;
505
+ } | null, since: Date | null) => Observable<ApiResult<RawCamera>>;
506
+ UpdateCamera: (camera: RawCamera) => Observable<ApiResult<RawCamera>>;
507
+ GetSensorDataSchema: (eventType: EventType) => Observable<any>;
508
+ GetSensorEvents: (params: SensorEventsParams, filter: string, box: Box) => Observable<ApiResult<RawSensorEvent>>;
509
+ GetSensorEventsPage: (request: SensorEventsRequest, filter: string | null, searchPolygons: string[]) => Observable<ApiPageResult<RawSensorEvent>>;
510
+ AddUserSensorEvent: (event: PartialExcept<RawSensorEvent, 'id' | 'eventType' | 'message'>) => Observable<ApiResult<RawSensorEvent>>;
511
+ AcknowledgeSensorEvent: (event: PartialExcept<RawSensorEvent, 'id' | 'ackEventType' | 'message'>) => Observable<ApiResult<RawSensorEvent>>;
512
+ MoveCamera: (camera: {
513
+ id: number;
514
+ }, x: number, y: number, zoom: number, moveSpeed: number, zoomSpeed: number) => Observable<any>;
515
+ MoveCameraContinuousStart: ({ id }: {
516
+ id: number;
517
+ }, x: number, y: number, zoom: number, timeout: number) => Observable<any>;
518
+ MoveCameraContinuousStop: ({ id }: {
519
+ id: number;
520
+ }) => Observable<any>;
521
+ GoHomePtzCamera: ({ id }: {
522
+ id: number;
523
+ }) => Observable<any>;
524
+ SetHomePtzCamera: ({ id }: {
525
+ id: number;
526
+ }) => Observable<any>;
527
+ };
528
+ camgroups: {
529
+ GetCamgroups: () => Observable<ApiResult<RawCamgroup>>;
530
+ DeleteCamgroup: (params: any) => Observable<ApiResult<RawCamgroup>>;
531
+ AddCamgroup: (params: any) => Observable<ApiResult<RawCamgroup>>;
532
+ UpdateCamgroup: (params: any) => Observable<ApiResult<RawCamgroup>>;
533
+ };
534
+ sound: {
535
+ GetPushSoundServiceUrl: (id: number) => Observable<any>;
536
+ };
537
+ thumbnails: {
538
+ GetThumbnailsInfo: (params: {
539
+ cameraId: number;
540
+ from: Date;
541
+ to: Date;
542
+ count: number;
543
+ }) => Observable<any>;
544
+ GetThumbnailInfo: (params: {
545
+ cameraId: number;
546
+ from: Date;
547
+ to: Date;
548
+ }) => Observable<any>;
549
+ GetHeatMapsInfo: (params: {
550
+ cameraId: number;
551
+ from: Date;
552
+ to: Date;
553
+ count: number;
554
+ }) => Observable<any>;
555
+ };
556
+ users: {
557
+ GetUser: () => Observable<ApiResult<RawUser>>;
558
+ UserUpdateProfile: (user: Partial<RawUser>) => Observable<ApiResult<RawUser>>;
559
+ };
560
+ }
561
+
562
+ declare interface InitParams {
563
+ token?: RawToken | {
564
+ widgetId: string;
565
+ widgetToken: string;
566
+ };
567
+ tokenStorage?: Storage_2;
568
+ tokenStorageKey?: string;
569
+ apiUrl?: string;
570
+ tokenServiceUrl?: string;
571
+ }
572
+
573
+ declare interface Interval_2 {
574
+ cameraId: number;
575
+ from: Date;
576
+ to: Date;
577
+ }
578
+
579
+ declare type IntervalState = {
580
+ state: 'fullfilled';
581
+ data: Thumbnail;
582
+ } | {
583
+ state: 'pending';
584
+ request: Observable<any>;
585
+ };
586
+
587
+ declare interface NotificationOptions_2 {
588
+ autoClose: number | false | undefined;
589
+ }
590
+
591
+ declare class NotificationService implements Notifier {
592
+ private notifier;
593
+ constructor(notifier: Notifier);
594
+ error(message: string | {
595
+ title: string;
596
+ text: string;
597
+ }): void;
598
+ success(message: string | {
599
+ title: string;
600
+ text: string;
601
+ }, options?: NotificationOptions_2): void;
602
+ warn(message: string | {
603
+ title: string;
604
+ text: string;
605
+ }): void;
606
+ }
607
+
608
+ declare interface Notifier {
609
+ success: (message: string | {
610
+ title: string;
611
+ text: string;
612
+ }, options?: NotificationOptions_2) => void;
613
+ warn: (message: string | {
614
+ title: string;
615
+ text: string;
616
+ }) => void;
617
+ error: (message: string | {
618
+ title: string;
619
+ text: string;
620
+ }) => void;
621
+ }
622
+
623
+ declare interface PageInfo {
624
+ isDescending: boolean;
625
+ nextPageToken: number;
626
+ haveMore: boolean;
627
+ }
628
+
629
+ declare type PartialApi = DeepPartial<IApi>;
630
+
631
+ declare type PartialExcept<T, K extends keyof T> = Pick<T, K> & Partial<T>;
632
+
633
+ declare interface PendingRequest {
634
+ cameraId: number;
635
+ startTime: Date;
636
+ endTime: Date;
637
+ request: Observable<any>;
638
+ }
639
+
640
+ declare interface PendingRequest_2 {
641
+ cameraId: number;
642
+ from: Date;
643
+ to: Date;
644
+ count: number;
645
+ request: Observable<any>;
646
+ }
647
+
648
+ declare interface RawCamera {
649
+ id: number;
650
+ customerId: number;
651
+ name: string;
652
+ description: string;
653
+ cameraBrand: string;
654
+ cameraModel: string;
655
+ enabled: boolean;
656
+ cameraUserName: string;
657
+ cameraPassword: null;
658
+ serialNum: string;
659
+ isOnvif: boolean;
660
+ isP2P: boolean;
661
+ p2pRegistrationCode: null;
662
+ planId: null;
663
+ p2pState: string;
664
+ cameraVideoFormat: string;
665
+ cameraState: string;
666
+ cameraStateChangedTime: string;
667
+ cameraError: null;
668
+ cameraAddress: string;
669
+ isMicEnabled: boolean;
670
+ imageQuality: number;
671
+ cameraSourceChannel: string;
672
+ pin: string;
673
+ streamUrl: string;
674
+ dashStreamUrl: string;
675
+ rtmpUrl: string;
676
+ webRtcStreamHost: string;
677
+ webRtcUrl: string;
678
+ cameraHttpSourceUrl: string;
679
+ cameraRtspSourceUrl: string;
680
+ supportedResolutions: string;
681
+ cameraType: string;
682
+ isCloud: boolean;
683
+ generateImageUrl: null;
684
+ imageUrl: string;
685
+ qualityProfile: string;
686
+ encodingProfile: null;
687
+ width: number;
688
+ height: number;
689
+ bitRate: number;
690
+ frameRate: number;
691
+ archiveDuration: number;
692
+ isArchiveByMotionEvent: boolean;
693
+ isAnalyticsEnabled: boolean;
694
+ isTimelapseAvailable: boolean;
695
+ motionEnabled: boolean;
696
+ isPTZ: boolean;
697
+ motionDuration: number;
698
+ dvrWindowLength: number;
699
+ jsonField: string;
700
+ dtUpdUtc: string;
701
+ version: string;
702
+ statistics: CameraStatistics;
703
+ }
704
+
705
+ declare interface RawCamgroup {
706
+ id: number;
707
+ name: string | null;
708
+ text: null;
709
+ description: null;
710
+ iconUrl: null;
711
+ iconCls: null;
712
+ dynamic: boolean;
713
+ allowDuplicates: boolean;
714
+ allowDrop: boolean;
715
+ allowNodeDropInView: boolean;
716
+ visible: boolean;
717
+ layout_id: string;
718
+ contentFilter: null;
719
+ customerWideGroup: boolean;
720
+ cameras: CamgroupItem[];
721
+ camgroups: CamgroupItem[];
722
+ version: string;
723
+ order: number;
724
+ }
725
+
726
+ declare interface RawClip {
727
+ id: number;
728
+ recordType: string;
729
+ isReady: boolean;
730
+ name: string;
731
+ description: string;
732
+ tagName: null;
733
+ cameraId: number;
734
+ clipUrl: string;
735
+ thumbnailUrl: string;
736
+ startTime: string;
737
+ endTime: string;
738
+ duration: number;
739
+ validTo: string;
740
+ timeCreated: string;
741
+ timeUpdated: string;
742
+ version: string;
743
+ }
744
+
745
+ declare interface RawSensorEvent {
746
+ message: string;
747
+ data: string | null;
748
+ id: number;
749
+ customerId: number;
750
+ sensorId: number;
751
+ sensorType: 'CameraSensor' | 'MotionSensor' | 'IntrusionSensor' | 'AudioSensor' | 'TemperatureSensor' | 'SpeedSensor' | 'Unknown';
752
+ eventType: EventType;
753
+ ackEventType: string;
754
+ description?: any;
755
+ tags?: any;
756
+ customerData?: any;
757
+ startTime: string;
758
+ endTime: string;
759
+ userId: string;
760
+ }
761
+
762
+ declare interface RawSharedClip {
763
+ id: number;
764
+ recordId: number;
765
+ creatorUserId: number;
766
+ cameraId: number;
767
+ startTime: string | Date;
768
+ endTime: string | Date;
769
+ duration: number;
770
+ fileSize: number;
771
+ password: string;
772
+ name: string;
773
+ description: string;
774
+ url: string;
775
+ validTo: string | Date;
776
+ }
777
+
778
+ declare type RawToken = {
779
+ accessToken: string;
780
+ accessTokenExpires: string;
781
+ accessTokenIssued: string;
782
+ clientId: string;
783
+ expiresIn: number;
784
+ refreshToken: string;
785
+ refreshTokenExpires: string;
786
+ refreshTokenIssued: string;
787
+ tokenType: string;
788
+ userName: string;
789
+ } & {
790
+ access_token: string;
791
+ access_token_expires: string;
792
+ access_token_issued: string;
793
+ client_id: string;
794
+ expires_in: number;
795
+ refresh_token: string;
796
+ refresh_token_expires: string;
797
+ refresh_token_issued: string;
798
+ token_type: string;
799
+ userName: string;
800
+ } & {
801
+ widgetId?: string;
802
+ widgetToken?: string;
803
+ };
804
+
805
+ declare interface RawUser {
806
+ id: number;
807
+ customerId: number;
808
+ userName: string;
809
+ firstName?: string;
810
+ lastName?: string;
811
+ email: string;
812
+ languageCode: string;
813
+ layoutStartId: number | null;
814
+ layoutStartType: 'camera' | 'camgroup' | '';
815
+ timeZoneOffset: string;
816
+ connectionId: string;
817
+ ipAddress: string;
818
+ userRoles: string[];
819
+ lastLoginAt: Date;
820
+ createdAt: Date;
821
+ jsonField: string;
822
+ imageUrl: null;
823
+ uiPermissions: string[];
824
+ version: string;
825
+ }
826
+
827
+ declare interface SchemaDescriptionParameter {
828
+ schemaId: number;
829
+ eventType: string;
830
+ description: string;
831
+ fieldName: string;
832
+ parameterType: string;
833
+ possibleValues: string;
834
+ valueSet: string;
835
+ values?: string[];
836
+ }
837
+
838
+ declare interface SensorEventsParams {
839
+ sensorId: number;
840
+ sensorType: 'CameraSensor' | 'MotionSensor' | 'IntrusionSensor' | 'AudioSensor' | 'TemperatureSensor' | 'SpeedSensor' | 'Unknown';
841
+ startTime: Date;
842
+ endTime: Date;
843
+ eventType: EventType;
844
+ }
845
+
846
+ declare interface SensorEventsRequest {
847
+ sensorIds: number[];
848
+ sensorType: string;
849
+ sensorEventTypes: SensorEventType[];
850
+ startTime?: Date;
851
+ endTime?: Date;
852
+ isDescending: boolean;
853
+ rowsLimit: number;
854
+ pageToken?: number;
855
+ }
856
+
857
+ declare enum SensorEventType {
858
+ Motion = 0,
859
+ Tampering = 1,
860
+ PanTiltZoom = 2,
861
+ CrossLine = 3,
862
+ Intrusion = 4,
863
+ LicensePlate = 5,
864
+ FaceDetection = 6,
865
+ Audio = 7,
866
+ Analytic = 8,
867
+ SpeedDetection = 9,
868
+ PeopleCounter = 10,
869
+ Temperature = 11,
870
+ PoS = 12,
871
+ GPS = 13,
872
+ DigitalInput = 14,
873
+ Normal = 15,
874
+ Suspicious = 16,
875
+ Loitering = 17,
876
+ Vandalism = 18,
877
+ Trespass = 19,
878
+ Emergency = 20,
879
+ LifeInDanger = 21,
880
+ ErroneousAlert = 22,
881
+ Misidentification = 23,
882
+ Fire = 24,
883
+ MedicalDuress = 25,
884
+ HoldUp = 26,
885
+ CheckIn = 27,
886
+ CheckOut = 28,
887
+ ClockIn = 29,
888
+ ClockOut = 30,
889
+ ParkingStart = 31,
890
+ ParkingEnd = 32,
891
+ ParkingViolation = 33,
892
+ GateAccess = 34,
893
+ DoorAccess = 35,
894
+ TemperatureCheck = 36,
895
+ IDCheck = 37,
896
+ PPECheck = 38,
897
+ WelfareCheck = 39,
898
+ Uncategorized = 40,
899
+ Unknown = 999
900
+ }
901
+
902
+ declare interface Storage_2 {
903
+ setItem: (key: string, value: string) => void | Promise<undefined>;
904
+ getItem: (key: string) => (string | null) | Promise<string | null>;
905
+ removeItem: (key: string) => void | Promise<undefined>;
906
+ }
907
+
908
+ declare interface Thumbnail {
909
+ cameraId: number;
910
+ timestamp: Date;
911
+ realTimestamp: Date;
912
+ url: string;
913
+ width: number;
914
+ height: number;
915
+ }
916
+
917
+ declare class ThumbnailsStore extends ApiStore {
918
+ thumbnails: crossfilter.Crossfilter<Thumbnail>;
919
+ thumbnailsByCameraId: crossfilter.Dimension<Thumbnail, number>;
920
+ thumbnailsByDate: crossfilter.Dimension<Thumbnail, number>;
921
+ pendingRequests: crossfilter.Crossfilter<PendingRequest_2>;
922
+ pendingRequestsByEnd: crossfilter.Dimension<PendingRequest_2, number>;
923
+ pendingRequestsByStart: crossfilter.Dimension<PendingRequest_2, number>;
924
+ pendingRequestsByCameraId: crossfilter.Dimension<PendingRequest_2, number>;
925
+ pendingRequestsByCount: crossfilter.Dimension<PendingRequest_2, number>;
926
+ constructor();
927
+ /**
928
+ * Fetches thumbnails for given camera and period.
929
+ * Given period is evenly divided by number of smaller periods that equals to `count`.
930
+ * Server returns first available thumbnail in each period
931
+ * @param cameraId - camera id
932
+ * @param from - start of the period
933
+ * @param to - end of the period
934
+ * @param count - number of thumbnails
935
+ */
936
+ fetchThumbnails(cameraId: number, from: Date, to: Date, count: number): Observable<any>;
937
+ getIntervalState(cameraId: number, from: Date, to: Date): IntervalState | null;
938
+ fetchThumbnail(cameraId: number, from: Date, to: Date): Observable<Thumbnail>;
939
+ /**
940
+ * Returns first available thumbnail for given camera within period
941
+ */
942
+ getThumbnail({ cameraId, from, to }: GetThumbnailParams): Thumbnail;
943
+ /**
944
+ * Returns previously obtained thumbnails for given camera within period
945
+ */
946
+ getThumbnails({ cameraId, from, to }: GetThumbnailParams): Thumbnail[];
947
+ toThumbnail: (cameraId: number) => ({ realtimestamp, url, width, height }: {
948
+ realtimestamp: string;
949
+ url: string;
950
+ width: number;
951
+ height: number;
952
+ }) => Thumbnail;
953
+ }
954
+
955
+ declare class Token {
956
+ accessToken: string;
957
+ accessTokenExpires: Date;
958
+ accessTokenIssued: Date;
959
+ clientId: string;
960
+ expiresIn: number;
961
+ refreshToken: string;
962
+ refreshTokenExpires: Date;
963
+ refreshTokenIssued: Date;
964
+ tokenType: string;
965
+ userName: string;
966
+ invalid: boolean;
967
+ widgetId?: string;
968
+ widgetToken?: string;
969
+ json: RawToken;
970
+ constructor(raw: RawToken);
971
+ }
972
+
973
+ declare class ToolkitApp {
974
+ readonly name: string;
975
+ initialized: boolean;
976
+ cameras: CamerasStore;
977
+ archives: ArchivesStore;
978
+ events: EventsStore;
979
+ eventSchema: EventSchemaStore;
980
+ thumbnails: ThumbnailsStore;
981
+ account: AccountStore;
982
+ notification: NotificationService;
983
+ auth: Auth;
984
+ api: Api<IApi> & IApi;
985
+ private disposables;
986
+ private tokenUpdateReactions;
987
+ constructor(name: string);
988
+ init({ token, tokenStorage: storage, tokenStorageKey, apiUrl, tokenServiceUrl }: InitParams, name?: string): ToolkitApp;
989
+ dispose: () => void;
990
+ /**
991
+ * Adds a reaction to token changes
992
+ * If token passed to the callback is null, then the user is signed out
993
+ * and you should react accordingly
994
+ * @param cb
995
+ */
996
+ onTokenUpdate: (cb: (token: RawToken | null) => void) => () => void;
997
+ }
998
+
999
+ declare type User = RawUser;
1000
+
1001
+ export { }