een-api-toolkit 0.3.15 → 0.3.20
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 +45 -6
- package/README.md +1 -0
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +585 -0
- package/dist/index.js +485 -261
- package/dist/index.js.map +1 -1
- package/docs/AI-CONTEXT.md +144 -1
- package/examples/vue-alerts-metrics/e2e/auth.spec.ts +8 -1
- package/examples/vue-alerts-metrics/package-lock.json +8 -1
- package/examples/vue-alerts-metrics/package.json +4 -3
- package/examples/vue-alerts-metrics/src/components/AlertsList.vue +567 -16
- package/examples/vue-alerts-metrics/src/components/CameraSelector.vue +16 -6
- package/examples/vue-alerts-metrics/src/components/MetricsChart.vue +23 -9
- package/examples/vue-alerts-metrics/src/components/NotificationsList.vue +579 -17
- package/examples/vue-alerts-metrics/src/components/TimeRangeSelector.vue +197 -12
- package/examples/vue-alerts-metrics/src/composables/useHlsPlayer.ts +285 -0
- package/examples/vue-alerts-metrics/src/views/Dashboard.vue +31 -9
- package/examples/vue-alerts-metrics/src/views/Home.vue +56 -7
- package/examples/vue-event-subscriptions/.env.example +15 -0
- package/examples/vue-event-subscriptions/README.md +103 -0
- package/examples/vue-event-subscriptions/e2e/app.spec.ts +71 -0
- package/examples/vue-event-subscriptions/e2e/auth.spec.ts +290 -0
- package/examples/vue-event-subscriptions/index.html +13 -0
- package/examples/vue-event-subscriptions/package-lock.json +1719 -0
- package/examples/vue-event-subscriptions/package.json +28 -0
- package/examples/vue-event-subscriptions/playwright.config.ts +47 -0
- package/examples/vue-event-subscriptions/src/App.vue +233 -0
- package/examples/vue-event-subscriptions/src/main.ts +25 -0
- package/examples/vue-event-subscriptions/src/router/index.ts +68 -0
- package/examples/vue-event-subscriptions/src/views/Callback.vue +76 -0
- package/examples/vue-event-subscriptions/src/views/Home.vue +192 -0
- package/examples/vue-event-subscriptions/src/views/LiveEvents.vue +640 -0
- package/examples/vue-event-subscriptions/src/views/Login.vue +33 -0
- package/examples/vue-event-subscriptions/src/views/Logout.vue +59 -0
- package/examples/vue-event-subscriptions/src/views/Subscriptions.vue +402 -0
- package/examples/vue-event-subscriptions/src/vite-env.d.ts +12 -0
- package/examples/vue-event-subscriptions/tsconfig.json +21 -0
- package/examples/vue-event-subscriptions/tsconfig.node.json +10 -0
- package/examples/vue-event-subscriptions/vite.config.ts +12 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -514,6 +514,187 @@ export declare interface CameraStreamUrls {
|
|
|
514
514
|
jpeg?: string;
|
|
515
515
|
}
|
|
516
516
|
|
|
517
|
+
/**
|
|
518
|
+
* Connect to an SSE event subscription to receive real-time events.
|
|
519
|
+
*
|
|
520
|
+
* @remarks
|
|
521
|
+
* Opens an SSE connection to the provided URL and calls the `onEvent` callback
|
|
522
|
+
* for each event received. The connection automatically handles reconnection
|
|
523
|
+
* on errors.
|
|
524
|
+
*
|
|
525
|
+
* Note: SSE connections require authentication. The token is passed via the
|
|
526
|
+
* `Authorization` header. Since EventSource doesn't support custom headers,
|
|
527
|
+
* we use fetch with ReadableStream to implement SSE.
|
|
528
|
+
*
|
|
529
|
+
* @param sseUrl - The SSE URL from the event subscription's deliveryConfig
|
|
530
|
+
* @param options - Connection options including event and error callbacks
|
|
531
|
+
* @returns A Result containing the SSE connection handle or an error
|
|
532
|
+
*
|
|
533
|
+
* @example
|
|
534
|
+
* ```typescript
|
|
535
|
+
* import { createEventSubscription, connectToEventSubscription } from 'een-api-toolkit'
|
|
536
|
+
*
|
|
537
|
+
* // First create a subscription
|
|
538
|
+
* const { data: subscription } = await createEventSubscription({
|
|
539
|
+
* deliveryConfig: { type: 'serverSentEvents.v1' },
|
|
540
|
+
* filters: [{
|
|
541
|
+
* actors: ['camera:100d4c41'],
|
|
542
|
+
* types: [{ id: 'een.motionDetectionEvent.v1' }]
|
|
543
|
+
* }]
|
|
544
|
+
* })
|
|
545
|
+
*
|
|
546
|
+
* if (subscription?.deliveryConfig.type === 'serverSentEvents.v1') {
|
|
547
|
+
* // Connect to SSE stream
|
|
548
|
+
* const { data: connection, error } = connectToEventSubscription(
|
|
549
|
+
* subscription.deliveryConfig.sseUrl!,
|
|
550
|
+
* {
|
|
551
|
+
* onEvent: (event) => {
|
|
552
|
+
* console.log(`Event: ${event.type} from ${event.actorId}`)
|
|
553
|
+
* },
|
|
554
|
+
* onError: (err) => {
|
|
555
|
+
* console.error('SSE error:', err.message)
|
|
556
|
+
* },
|
|
557
|
+
* onStatusChange: (status) => {
|
|
558
|
+
* console.log('Connection status:', status)
|
|
559
|
+
* }
|
|
560
|
+
* }
|
|
561
|
+
* )
|
|
562
|
+
*
|
|
563
|
+
* // Later, disconnect
|
|
564
|
+
* if (connection) {
|
|
565
|
+
* connection.close()
|
|
566
|
+
* }
|
|
567
|
+
* }
|
|
568
|
+
* ```
|
|
569
|
+
*
|
|
570
|
+
* @category EventSubscriptions
|
|
571
|
+
*/
|
|
572
|
+
export declare function connectToEventSubscription(sseUrl: string, options: SSEConnectionOptions): Result<SSEConnection>;
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Create a new event subscription.
|
|
576
|
+
*
|
|
577
|
+
* @remarks
|
|
578
|
+
* Creates a new event subscription at `/api/v3.0/eventSubscriptions`.
|
|
579
|
+
* For SSE subscriptions, use `connectToEventSubscription()` with the returned
|
|
580
|
+
* `sseUrl` to start receiving events.
|
|
581
|
+
*
|
|
582
|
+
* For more details, see the
|
|
583
|
+
* [EEN API Documentation](https://developer.eagleeyenetworks.com/reference/createeventsubscription).
|
|
584
|
+
*
|
|
585
|
+
* @param params - Parameters for creating the subscription
|
|
586
|
+
* @returns A Result containing the created event subscription or an error
|
|
587
|
+
*
|
|
588
|
+
* @example
|
|
589
|
+
* ```typescript
|
|
590
|
+
* import { createEventSubscription, connectToEventSubscription } from 'een-api-toolkit'
|
|
591
|
+
*
|
|
592
|
+
* // Create an SSE subscription for motion events
|
|
593
|
+
* const { data, error } = await createEventSubscription({
|
|
594
|
+
* deliveryConfig: { type: 'serverSentEvents.v1' },
|
|
595
|
+
* filters: [{
|
|
596
|
+
* actors: ['camera:100d4c41'],
|
|
597
|
+
* types: [{ id: 'een.motionDetectionEvent.v1' }]
|
|
598
|
+
* }]
|
|
599
|
+
* })
|
|
600
|
+
*
|
|
601
|
+
* if (data && data.deliveryConfig.type === 'serverSentEvents.v1') {
|
|
602
|
+
* // Connect to the SSE stream
|
|
603
|
+
* const { data: connection } = connectToEventSubscription(
|
|
604
|
+
* data.deliveryConfig.sseUrl!,
|
|
605
|
+
* { onEvent: (event) => console.log('Event:', event) }
|
|
606
|
+
* )
|
|
607
|
+
* }
|
|
608
|
+
* ```
|
|
609
|
+
*
|
|
610
|
+
* @category EventSubscriptions
|
|
611
|
+
*/
|
|
612
|
+
export declare function createEventSubscription(params: CreateEventSubscriptionParams): Promise<Result<EventSubscription>>;
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Parameters for creating an event subscription.
|
|
616
|
+
*
|
|
617
|
+
* @remarks
|
|
618
|
+
* Creates a new subscription with the specified delivery type and filters.
|
|
619
|
+
* For SSE subscriptions, use `connectToEventSubscription()` to start receiving events.
|
|
620
|
+
*
|
|
621
|
+
* @example
|
|
622
|
+
* ```typescript
|
|
623
|
+
* import { createEventSubscription } from 'een-api-toolkit'
|
|
624
|
+
*
|
|
625
|
+
* // Create an SSE subscription for motion events from a camera
|
|
626
|
+
* const { data, error } = await createEventSubscription({
|
|
627
|
+
* deliveryConfig: { type: 'serverSentEvents.v1' },
|
|
628
|
+
* filters: [{
|
|
629
|
+
* actors: ['camera:100d4c41'],
|
|
630
|
+
* types: [{ id: 'een.motionDetectionEvent.v1' }]
|
|
631
|
+
* }]
|
|
632
|
+
* })
|
|
633
|
+
*
|
|
634
|
+
* if (data) {
|
|
635
|
+
* console.log(`Created subscription: ${data.id}`)
|
|
636
|
+
* // For SSE subscriptions, connect to the sseUrl
|
|
637
|
+
* if (data.deliveryConfig.type === 'serverSentEvents.v1') {
|
|
638
|
+
* console.log(`SSE URL: ${data.deliveryConfig.sseUrl}`)
|
|
639
|
+
* }
|
|
640
|
+
* }
|
|
641
|
+
* ```
|
|
642
|
+
*
|
|
643
|
+
* @category EventSubscriptions
|
|
644
|
+
*/
|
|
645
|
+
export declare interface CreateEventSubscriptionParams {
|
|
646
|
+
/** Delivery configuration */
|
|
647
|
+
deliveryConfig: DeliveryConfigCreate;
|
|
648
|
+
/** List of filters for the subscription */
|
|
649
|
+
filters: FilterCreate[];
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Delete an event subscription.
|
|
654
|
+
*
|
|
655
|
+
* @remarks
|
|
656
|
+
* Deletes an event subscription at `/api/v3.0/eventSubscriptions/{id}`.
|
|
657
|
+
* Any active SSE connections to this subscription will be closed.
|
|
658
|
+
*
|
|
659
|
+
* For more details, see the
|
|
660
|
+
* [EEN API Documentation](https://developer.eagleeyenetworks.com/reference/deleteeventsubscription).
|
|
661
|
+
*
|
|
662
|
+
* @param subscriptionId - The unique identifier of the subscription to delete
|
|
663
|
+
* @returns A Result with void data on success or an error
|
|
664
|
+
*
|
|
665
|
+
* @example
|
|
666
|
+
* ```typescript
|
|
667
|
+
* import { deleteEventSubscription } from 'een-api-toolkit'
|
|
668
|
+
*
|
|
669
|
+
* const { error } = await deleteEventSubscription('f3d6f55d5ba546168758a309508f4419')
|
|
670
|
+
* if (error) {
|
|
671
|
+
* console.error('Failed to delete:', error.message)
|
|
672
|
+
* } else {
|
|
673
|
+
* console.log('Subscription deleted successfully')
|
|
674
|
+
* }
|
|
675
|
+
* ```
|
|
676
|
+
*
|
|
677
|
+
* @category EventSubscriptions
|
|
678
|
+
*/
|
|
679
|
+
export declare function deleteEventSubscription(subscriptionId: string): Promise<Result<void>>;
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Delivery configuration (union type).
|
|
683
|
+
*
|
|
684
|
+
* @remarks
|
|
685
|
+
* Describes how events will be delivered to the subscriber.
|
|
686
|
+
*
|
|
687
|
+
* @category EventSubscriptions
|
|
688
|
+
*/
|
|
689
|
+
export declare type DeliveryConfig = SSEDeliveryConfig | WebhookDeliveryConfig;
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Delivery configuration for creation (union type).
|
|
693
|
+
*
|
|
694
|
+
* @category EventSubscriptions
|
|
695
|
+
*/
|
|
696
|
+
export declare type DeliveryConfigCreate = SSEDeliveryConfigCreate | WebhookDeliveryConfigCreate;
|
|
697
|
+
|
|
517
698
|
/**
|
|
518
699
|
* Error object returned when an operation fails.
|
|
519
700
|
*
|
|
@@ -738,6 +919,99 @@ export declare interface EventMetric {
|
|
|
738
919
|
[key: string]: unknown;
|
|
739
920
|
}
|
|
740
921
|
|
|
922
|
+
/**
|
|
923
|
+
* Event subscription entity from EEN API v3.0.
|
|
924
|
+
*
|
|
925
|
+
* @remarks
|
|
926
|
+
* Represents an event subscription in the Eagle Eye Networks platform.
|
|
927
|
+
* Subscriptions allow receiving real-time events via SSE or webhooks.
|
|
928
|
+
*
|
|
929
|
+
* For more details, see the
|
|
930
|
+
* [EEN API Documentation](https://developer.eagleeyenetworks.com/reference/listeventsubscriptions).
|
|
931
|
+
*
|
|
932
|
+
* @example
|
|
933
|
+
* ```typescript
|
|
934
|
+
* import { listEventSubscriptions, type EventSubscription } from 'een-api-toolkit'
|
|
935
|
+
*
|
|
936
|
+
* const { data, error } = await listEventSubscriptions()
|
|
937
|
+
* if (data) {
|
|
938
|
+
* data.results.forEach((sub: EventSubscription) => {
|
|
939
|
+
* console.log(`Subscription ${sub.id}: ${sub.deliveryConfig.type}`)
|
|
940
|
+
* if (sub.deliveryConfig.type === 'serverSentEvents.v1') {
|
|
941
|
+
* console.log(` SSE URL: ${sub.deliveryConfig.sseUrl}`)
|
|
942
|
+
* }
|
|
943
|
+
* })
|
|
944
|
+
* }
|
|
945
|
+
* ```
|
|
946
|
+
*
|
|
947
|
+
* @category EventSubscriptions
|
|
948
|
+
*/
|
|
949
|
+
export declare interface EventSubscription {
|
|
950
|
+
/** Unique identifier for the subscription */
|
|
951
|
+
id: string;
|
|
952
|
+
/** Subscription configuration (lifecycle, TTL) */
|
|
953
|
+
subscriptionConfig?: EventSubscriptionConfig;
|
|
954
|
+
/** Delivery configuration (SSE or webhook) */
|
|
955
|
+
deliveryConfig: DeliveryConfig;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* Event subscription configuration.
|
|
960
|
+
*
|
|
961
|
+
* @remarks
|
|
962
|
+
* Contains lifecycle and TTL settings for the subscription.
|
|
963
|
+
* This is read-only and set by the server based on delivery type.
|
|
964
|
+
*
|
|
965
|
+
* @category EventSubscriptions
|
|
966
|
+
*/
|
|
967
|
+
export declare interface EventSubscriptionConfig {
|
|
968
|
+
/** Subscription lifecycle type */
|
|
969
|
+
lifeCycle: EventSubscriptionLifecycle;
|
|
970
|
+
/** Time-to-live in seconds for temporary subscriptions */
|
|
971
|
+
timeToLiveSeconds?: number;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
/**
|
|
975
|
+
* Delivery type for event subscriptions.
|
|
976
|
+
*
|
|
977
|
+
* @remarks
|
|
978
|
+
* - `serverSentEvents.v1`: Connect via SSE to receive events in real-time
|
|
979
|
+
* - `webhook.v1`: Events are pushed to a client-provided URL
|
|
980
|
+
*
|
|
981
|
+
* @category EventSubscriptions
|
|
982
|
+
*/
|
|
983
|
+
export declare type EventSubscriptionDeliveryType = 'serverSentEvents.v1' | 'webhook.v1';
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Filter for event subscriptions.
|
|
987
|
+
*
|
|
988
|
+
* @remarks
|
|
989
|
+
* A filter defines which events will be delivered. Events must match
|
|
990
|
+
* all conditions within a filter to be delivered. The subscription
|
|
991
|
+
* receives events matching any of its filters.
|
|
992
|
+
*
|
|
993
|
+
* @category EventSubscriptions
|
|
994
|
+
*/
|
|
995
|
+
export declare interface EventSubscriptionFilter {
|
|
996
|
+
/** Unique filter ID within the subscription */
|
|
997
|
+
id: string;
|
|
998
|
+
/** List of actors to filter (format: "type:id", e.g., "camera:100d4c41") */
|
|
999
|
+
actors: string[];
|
|
1000
|
+
/** List of event types to filter */
|
|
1001
|
+
types: EventTypeFilter[];
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
* Subscription lifecycle type.
|
|
1006
|
+
*
|
|
1007
|
+
* @remarks
|
|
1008
|
+
* - `temporary`: Removed when deleted or when no client uses it for timeToLiveSeconds
|
|
1009
|
+
* - `persistent`: Remains active indefinitely until explicitly deleted
|
|
1010
|
+
*
|
|
1011
|
+
* @category EventSubscriptions
|
|
1012
|
+
*/
|
|
1013
|
+
export declare type EventSubscriptionLifecycle = 'temporary' | 'persistent';
|
|
1014
|
+
|
|
741
1015
|
/**
|
|
742
1016
|
* Event type definition from EEN API v3.0.
|
|
743
1017
|
*
|
|
@@ -756,6 +1030,27 @@ export declare interface EventType {
|
|
|
756
1030
|
description: string;
|
|
757
1031
|
}
|
|
758
1032
|
|
|
1033
|
+
/**
|
|
1034
|
+
* Event type filter for subscriptions.
|
|
1035
|
+
*
|
|
1036
|
+
* @remarks
|
|
1037
|
+
* Specifies which event types should trigger the subscription.
|
|
1038
|
+
* Use `listEventTypes()` to get available event type IDs.
|
|
1039
|
+
*
|
|
1040
|
+
* @example
|
|
1041
|
+
* ```typescript
|
|
1042
|
+
* const typeFilter: EventTypeFilter = {
|
|
1043
|
+
* id: 'een.motionDetectionEvent.v1'
|
|
1044
|
+
* }
|
|
1045
|
+
* ```
|
|
1046
|
+
*
|
|
1047
|
+
* @category EventSubscriptions
|
|
1048
|
+
*/
|
|
1049
|
+
export declare interface EventTypeFilter {
|
|
1050
|
+
/** Event type identifier (e.g., "een.motionDetectionEvent.v1") */
|
|
1051
|
+
id: string;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
759
1054
|
/* Excluded from this release type: failure */
|
|
760
1055
|
|
|
761
1056
|
/**
|
|
@@ -868,6 +1163,53 @@ export declare type FeedMediaType = 'video' | 'audio' | 'image' | 'halfDuplex' |
|
|
|
868
1163
|
*/
|
|
869
1164
|
export declare type FeedStreamType = 'main' | 'preview' | 'talkdown';
|
|
870
1165
|
|
|
1166
|
+
/**
|
|
1167
|
+
* Filter creation parameters.
|
|
1168
|
+
*
|
|
1169
|
+
* @remarks
|
|
1170
|
+
* Used when creating filters inline with a subscription.
|
|
1171
|
+
*
|
|
1172
|
+
* @example
|
|
1173
|
+
* ```typescript
|
|
1174
|
+
* const filter: FilterCreate = {
|
|
1175
|
+
* actors: ['camera:100d4c41'],
|
|
1176
|
+
* types: [{ id: 'een.motionDetectionEvent.v1' }]
|
|
1177
|
+
* }
|
|
1178
|
+
* ```
|
|
1179
|
+
*
|
|
1180
|
+
* @category EventSubscriptions
|
|
1181
|
+
*/
|
|
1182
|
+
export declare interface FilterCreate {
|
|
1183
|
+
/** List of actors to filter (format: "type:id", e.g., "camera:100d4c41") */
|
|
1184
|
+
actors: string[];
|
|
1185
|
+
/** List of event types to filter */
|
|
1186
|
+
types: EventTypeFilter[];
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* Convert ISO 8601 timestamp from Z format to +00:00 format.
|
|
1191
|
+
*
|
|
1192
|
+
* @remarks
|
|
1193
|
+
* The EEN API requires timestamps in +00:00 format, not Z format.
|
|
1194
|
+
* This function converts timestamps like `2024-01-01T00:00:00.000Z`
|
|
1195
|
+
* to `2024-01-01T00:00:00.000+00:00`.
|
|
1196
|
+
*
|
|
1197
|
+
* @param timestamp - ISO 8601 timestamp string
|
|
1198
|
+
* @returns Timestamp in +00:00 format
|
|
1199
|
+
*
|
|
1200
|
+
* @example
|
|
1201
|
+
* ```typescript
|
|
1202
|
+
* formatTimestamp('2024-01-01T00:00:00.000Z')
|
|
1203
|
+
* // Returns: '2024-01-01T00:00:00.000+00:00'
|
|
1204
|
+
*
|
|
1205
|
+
* formatTimestamp(new Date().toISOString())
|
|
1206
|
+
* // Returns: timestamp with +00:00 suffix
|
|
1207
|
+
* ```
|
|
1208
|
+
*
|
|
1209
|
+
* @category Utilities
|
|
1210
|
+
*/
|
|
1211
|
+
export declare function formatTimestamp(timestamp: string): string;
|
|
1212
|
+
|
|
871
1213
|
/**
|
|
872
1214
|
* Exchange authorization code for access token
|
|
873
1215
|
*/
|
|
@@ -1361,6 +1703,35 @@ export declare interface GetEventParams {
|
|
|
1361
1703
|
include?: string[];
|
|
1362
1704
|
}
|
|
1363
1705
|
|
|
1706
|
+
/**
|
|
1707
|
+
* Get a specific event subscription by ID.
|
|
1708
|
+
*
|
|
1709
|
+
* @remarks
|
|
1710
|
+
* Fetches a single event subscription from `/api/v3.0/eventSubscriptions/{id}`.
|
|
1711
|
+
*
|
|
1712
|
+
* For more details, see the
|
|
1713
|
+
* [EEN API Documentation](https://developer.eagleeyenetworks.com/reference/geteventsubscription).
|
|
1714
|
+
*
|
|
1715
|
+
* @param subscriptionId - The unique identifier of the subscription to fetch
|
|
1716
|
+
* @returns A Result containing the event subscription or an error
|
|
1717
|
+
*
|
|
1718
|
+
* @example
|
|
1719
|
+
* ```typescript
|
|
1720
|
+
* import { getEventSubscription } from 'een-api-toolkit'
|
|
1721
|
+
*
|
|
1722
|
+
* const { data, error } = await getEventSubscription('f3d6f55d5ba546168758a309508f4419')
|
|
1723
|
+
* if (data) {
|
|
1724
|
+
* console.log(`Subscription: ${data.id}`)
|
|
1725
|
+
* if (data.deliveryConfig.type === 'serverSentEvents.v1') {
|
|
1726
|
+
* console.log(`SSE URL: ${data.deliveryConfig.sseUrl}`)
|
|
1727
|
+
* }
|
|
1728
|
+
* }
|
|
1729
|
+
* ```
|
|
1730
|
+
*
|
|
1731
|
+
* @category EventSubscriptions
|
|
1732
|
+
*/
|
|
1733
|
+
export declare function getEventSubscription(subscriptionId: string): Promise<Result<EventSubscription>>;
|
|
1734
|
+
|
|
1364
1735
|
/**
|
|
1365
1736
|
* Get a live image from a camera.
|
|
1366
1737
|
*
|
|
@@ -2343,6 +2714,66 @@ export declare interface ListEventsParams {
|
|
|
2343
2714
|
include?: string[];
|
|
2344
2715
|
}
|
|
2345
2716
|
|
|
2717
|
+
/**
|
|
2718
|
+
* List all event subscriptions for the current account.
|
|
2719
|
+
*
|
|
2720
|
+
* @remarks
|
|
2721
|
+
* Fetches a paginated list of event subscriptions from `/api/v3.0/eventSubscriptions`.
|
|
2722
|
+
*
|
|
2723
|
+
* For more details, see the
|
|
2724
|
+
* [EEN API Documentation](https://developer.eagleeyenetworks.com/reference/listeventsubscriptions).
|
|
2725
|
+
*
|
|
2726
|
+
* @param params - Optional pagination parameters
|
|
2727
|
+
* @returns A Result containing a paginated list of event subscriptions or an error
|
|
2728
|
+
*
|
|
2729
|
+
* @example
|
|
2730
|
+
* ```typescript
|
|
2731
|
+
* import { listEventSubscriptions } from 'een-api-toolkit'
|
|
2732
|
+
*
|
|
2733
|
+
* const { data, error } = await listEventSubscriptions()
|
|
2734
|
+
* if (data) {
|
|
2735
|
+
* console.log(`Found ${data.results.length} subscriptions`)
|
|
2736
|
+
* data.results.forEach(sub => {
|
|
2737
|
+
* console.log(`${sub.id}: ${sub.deliveryConfig.type}`)
|
|
2738
|
+
* })
|
|
2739
|
+
* }
|
|
2740
|
+
* ```
|
|
2741
|
+
*
|
|
2742
|
+
* @category EventSubscriptions
|
|
2743
|
+
*/
|
|
2744
|
+
export declare function listEventSubscriptions(params?: ListEventSubscriptionsParams): Promise<Result<PaginatedResult<EventSubscription>>>;
|
|
2745
|
+
|
|
2746
|
+
/**
|
|
2747
|
+
* Parameters for listing event subscriptions.
|
|
2748
|
+
*
|
|
2749
|
+
* @remarks
|
|
2750
|
+
* Supports pagination via pageSize and pageToken.
|
|
2751
|
+
*
|
|
2752
|
+
* @example
|
|
2753
|
+
* ```typescript
|
|
2754
|
+
* import { listEventSubscriptions } from 'een-api-toolkit'
|
|
2755
|
+
*
|
|
2756
|
+
* // Get first page
|
|
2757
|
+
* const { data } = await listEventSubscriptions({ pageSize: 10 })
|
|
2758
|
+
*
|
|
2759
|
+
* // Get next page
|
|
2760
|
+
* if (data?.nextPageToken) {
|
|
2761
|
+
* const { data: page2 } = await listEventSubscriptions({
|
|
2762
|
+
* pageSize: 10,
|
|
2763
|
+
* pageToken: data.nextPageToken
|
|
2764
|
+
* })
|
|
2765
|
+
* }
|
|
2766
|
+
* ```
|
|
2767
|
+
*
|
|
2768
|
+
* @category EventSubscriptions
|
|
2769
|
+
*/
|
|
2770
|
+
export declare interface ListEventSubscriptionsParams {
|
|
2771
|
+
/** Number of results per page */
|
|
2772
|
+
pageSize?: number;
|
|
2773
|
+
/** Token for fetching a specific page */
|
|
2774
|
+
pageToken?: string;
|
|
2775
|
+
}
|
|
2776
|
+
|
|
2346
2777
|
/**
|
|
2347
2778
|
* List all available event types.
|
|
2348
2779
|
*
|
|
@@ -3114,6 +3545,125 @@ export declare type Result<T> = {
|
|
|
3114
3545
|
*/
|
|
3115
3546
|
export declare function revokeToken(): Promise<Result<void>>;
|
|
3116
3547
|
|
|
3548
|
+
/**
|
|
3549
|
+
* SSE connection handle.
|
|
3550
|
+
*
|
|
3551
|
+
* @remarks
|
|
3552
|
+
* Returned by `connectToEventSubscription()`. Use `close()` to disconnect
|
|
3553
|
+
* and `status` to check the current connection state.
|
|
3554
|
+
*
|
|
3555
|
+
* @example
|
|
3556
|
+
* ```typescript
|
|
3557
|
+
* const { data: connection } = connectToEventSubscription(sseUrl, {
|
|
3558
|
+
* onEvent: (event) => console.log('Event:', event),
|
|
3559
|
+
* onStatusChange: (status) => console.log('Status:', status)
|
|
3560
|
+
* })
|
|
3561
|
+
*
|
|
3562
|
+
* // Later, disconnect
|
|
3563
|
+
* if (connection) {
|
|
3564
|
+
* connection.close()
|
|
3565
|
+
* }
|
|
3566
|
+
* ```
|
|
3567
|
+
*
|
|
3568
|
+
* @category EventSubscriptions
|
|
3569
|
+
*/
|
|
3570
|
+
export declare interface SSEConnection {
|
|
3571
|
+
/** Close the SSE connection */
|
|
3572
|
+
close: () => void;
|
|
3573
|
+
/** Current connection status */
|
|
3574
|
+
status: SSEConnectionStatus;
|
|
3575
|
+
}
|
|
3576
|
+
|
|
3577
|
+
/**
|
|
3578
|
+
* Options for connecting to an SSE event subscription.
|
|
3579
|
+
*
|
|
3580
|
+
* @category EventSubscriptions
|
|
3581
|
+
*/
|
|
3582
|
+
export declare interface SSEConnectionOptions {
|
|
3583
|
+
/** Callback when an event is received */
|
|
3584
|
+
onEvent: (event: SSEEvent) => void;
|
|
3585
|
+
/** Callback when an error occurs */
|
|
3586
|
+
onError?: (error: Error) => void;
|
|
3587
|
+
/** Callback when connection status changes */
|
|
3588
|
+
onStatusChange?: (status: SSEConnectionStatus) => void;
|
|
3589
|
+
}
|
|
3590
|
+
|
|
3591
|
+
/**
|
|
3592
|
+
* SSE connection status.
|
|
3593
|
+
*
|
|
3594
|
+
* @category EventSubscriptions
|
|
3595
|
+
*/
|
|
3596
|
+
export declare type SSEConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
3597
|
+
|
|
3598
|
+
/**
|
|
3599
|
+
* SSE delivery configuration.
|
|
3600
|
+
*
|
|
3601
|
+
* @remarks
|
|
3602
|
+
* Configuration for Server-Sent Events delivery type.
|
|
3603
|
+
* The `sseUrl` is provided by the server after subscription creation.
|
|
3604
|
+
*
|
|
3605
|
+
* @category EventSubscriptions
|
|
3606
|
+
*/
|
|
3607
|
+
export declare interface SSEDeliveryConfig {
|
|
3608
|
+
/** Delivery type identifier */
|
|
3609
|
+
type: 'serverSentEvents.v1';
|
|
3610
|
+
/** URL to connect for receiving SSE events (read-only, provided by server) */
|
|
3611
|
+
sseUrl?: string;
|
|
3612
|
+
}
|
|
3613
|
+
|
|
3614
|
+
/**
|
|
3615
|
+
* SSE delivery configuration for creation.
|
|
3616
|
+
*
|
|
3617
|
+
* @remarks
|
|
3618
|
+
* Used when creating a subscription with SSE delivery.
|
|
3619
|
+
*
|
|
3620
|
+
* @category EventSubscriptions
|
|
3621
|
+
*/
|
|
3622
|
+
export declare interface SSEDeliveryConfigCreate {
|
|
3623
|
+
/** Delivery type identifier */
|
|
3624
|
+
type: 'serverSentEvents.v1';
|
|
3625
|
+
}
|
|
3626
|
+
|
|
3627
|
+
/**
|
|
3628
|
+
* Event received via SSE.
|
|
3629
|
+
*
|
|
3630
|
+
* @remarks
|
|
3631
|
+
* This is the event payload delivered through the SSE connection.
|
|
3632
|
+
* The structure matches the Event type from the events API.
|
|
3633
|
+
*
|
|
3634
|
+
* @category EventSubscriptions
|
|
3635
|
+
*/
|
|
3636
|
+
export declare interface SSEEvent {
|
|
3637
|
+
/** Unique identifier for the event */
|
|
3638
|
+
id: string;
|
|
3639
|
+
/** ISO 8601 timestamp when the event started */
|
|
3640
|
+
startTimestamp: string;
|
|
3641
|
+
/** ISO 8601 timestamp when the event ended (null for point-in-time events) */
|
|
3642
|
+
endTimestamp?: string | null;
|
|
3643
|
+
/** Whether this is a span event (has duration) or point-in-time event */
|
|
3644
|
+
span?: boolean;
|
|
3645
|
+
/** ID of the account this event belongs to */
|
|
3646
|
+
accountId?: string;
|
|
3647
|
+
/** ID of the actor (device/entity) that generated the event */
|
|
3648
|
+
actorId: string;
|
|
3649
|
+
/** Account ID of the actor */
|
|
3650
|
+
actorAccountId?: string;
|
|
3651
|
+
/** Type of actor that generated the event */
|
|
3652
|
+
actorType?: string;
|
|
3653
|
+
/** ID of the entity that created the event */
|
|
3654
|
+
creatorId?: string;
|
|
3655
|
+
/** Event type identifier (e.g., "een.motionDetectionEvent.v1") */
|
|
3656
|
+
type: string;
|
|
3657
|
+
/** List of data schema types included in this event */
|
|
3658
|
+
dataSchemas?: string[];
|
|
3659
|
+
/** Event data objects (varies by event type) */
|
|
3660
|
+
data?: Array<{
|
|
3661
|
+
type: string;
|
|
3662
|
+
creatorId?: string;
|
|
3663
|
+
[key: string]: unknown;
|
|
3664
|
+
}>;
|
|
3665
|
+
}
|
|
3666
|
+
|
|
3117
3667
|
/**
|
|
3118
3668
|
* Human-readable descriptions for each storage strategy.
|
|
3119
3669
|
* Useful for displaying storage information in UI components.
|
|
@@ -3376,4 +3926,39 @@ export declare interface UserProfile {
|
|
|
3376
3926
|
language?: string;
|
|
3377
3927
|
}
|
|
3378
3928
|
|
|
3929
|
+
/**
|
|
3930
|
+
* Webhook delivery configuration.
|
|
3931
|
+
*
|
|
3932
|
+
* @remarks
|
|
3933
|
+
* Configuration for webhook delivery type.
|
|
3934
|
+
* The `secret` is provided by the server for signature verification.
|
|
3935
|
+
*
|
|
3936
|
+
* @category EventSubscriptions
|
|
3937
|
+
*/
|
|
3938
|
+
export declare interface WebhookDeliveryConfig {
|
|
3939
|
+
/** Delivery type identifier */
|
|
3940
|
+
type: 'webhook.v1';
|
|
3941
|
+
/** Base64 encoded secret for signature verification (read-only) */
|
|
3942
|
+
secret?: string;
|
|
3943
|
+
}
|
|
3944
|
+
|
|
3945
|
+
/**
|
|
3946
|
+
* Webhook delivery configuration for creation.
|
|
3947
|
+
*
|
|
3948
|
+
* @remarks
|
|
3949
|
+
* Used when creating a subscription with webhook delivery.
|
|
3950
|
+
*
|
|
3951
|
+
* @category EventSubscriptions
|
|
3952
|
+
*/
|
|
3953
|
+
export declare interface WebhookDeliveryConfigCreate {
|
|
3954
|
+
/** Delivery type identifier */
|
|
3955
|
+
type: 'webhook.v1';
|
|
3956
|
+
/** HTTPS URL where webhook events will be sent */
|
|
3957
|
+
webhookUrl: string;
|
|
3958
|
+
/** Email address of technical contact */
|
|
3959
|
+
technicalContactEmail: string;
|
|
3960
|
+
/** Name of technical contact */
|
|
3961
|
+
technicalContactName: string;
|
|
3962
|
+
}
|
|
3963
|
+
|
|
3379
3964
|
export { }
|