een-api-toolkit 0.1.4 → 0.1.7
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 +6 -5
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +370 -1
- package/dist/index.js +416 -259
- package/dist/index.js.map +1 -1
- package/docs/AI-CONTEXT.md +160 -1
- package/examples/vue-media/.env.example +5 -0
- package/examples/vue-media/e2e/app.spec.ts +55 -0
- package/examples/vue-media/e2e/auth.spec.ts +344 -0
- package/examples/vue-media/index.html +13 -0
- package/examples/vue-media/package-lock.json +1583 -0
- package/examples/vue-media/package.json +28 -0
- package/examples/vue-media/playwright.config.ts +28 -0
- package/examples/vue-media/src/App.vue +122 -0
- package/examples/vue-media/src/main.ts +22 -0
- package/examples/vue-media/src/router/index.ts +61 -0
- package/examples/vue-media/src/views/Callback.vue +76 -0
- package/examples/vue-media/src/views/Home.vue +86 -0
- package/examples/vue-media/src/views/LiveCamera.vue +330 -0
- package/examples/vue-media/src/views/Login.vue +32 -0
- package/examples/vue-media/src/views/Logout.vue +59 -0
- package/examples/vue-media/src/vite-env.d.ts +12 -0
- package/examples/vue-media/tsconfig.json +21 -0
- package/examples/vue-media/tsconfig.node.json +10 -0
- package/examples/vue-media/vite.config.ts +12 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -442,7 +442,7 @@ export declare interface EenToolkitConfig {
|
|
|
442
442
|
*
|
|
443
443
|
* @category Types
|
|
444
444
|
*/
|
|
445
|
-
export declare type ErrorCode = 'AUTH_REQUIRED' | 'AUTH_FAILED' | 'TOKEN_EXPIRED' | 'API_ERROR' | 'NETWORK_ERROR' | 'VALIDATION_ERROR' | 'NOT_FOUND' | 'FORBIDDEN' | 'RATE_LIMITED' | 'UNKNOWN_ERROR';
|
|
445
|
+
export declare type ErrorCode = 'AUTH_REQUIRED' | 'AUTH_FAILED' | 'TOKEN_EXPIRED' | 'API_ERROR' | 'NETWORK_ERROR' | 'VALIDATION_ERROR' | 'NOT_FOUND' | 'FORBIDDEN' | 'RATE_LIMITED' | 'SERVICE_UNAVAILABLE' | 'UNKNOWN_ERROR';
|
|
446
446
|
|
|
447
447
|
/* Excluded from this release type: failure */
|
|
448
448
|
|
|
@@ -724,11 +724,200 @@ export declare function getConfig(): EenToolkitConfig;
|
|
|
724
724
|
*/
|
|
725
725
|
export declare function getCurrentUser(): Promise<Result<UserProfile>>;
|
|
726
726
|
|
|
727
|
+
/**
|
|
728
|
+
* Get a live image from a camera.
|
|
729
|
+
*
|
|
730
|
+
* @remarks
|
|
731
|
+
* Fetches a new live image from the specified camera. This call waits until
|
|
732
|
+
* a new image is available from the device. The image is returned as a
|
|
733
|
+
* base64 data URL that can be used directly in an HTML img element.
|
|
734
|
+
*
|
|
735
|
+
* Note: Live images only support the 'preview' stream type.
|
|
736
|
+
*
|
|
737
|
+
* **Memory Considerations**: Images are loaded into memory and base64 encoded,
|
|
738
|
+
* adding ~33% size overhead. Typical preview images are <500KB. For high-frequency
|
|
739
|
+
* polling, consider implementing error backoff and limiting concurrent requests.
|
|
740
|
+
*
|
|
741
|
+
* For more details, see the
|
|
742
|
+
* [EEN API Documentation](https://developer.eagleeyenetworks.com/reference/getliveimage).
|
|
743
|
+
*
|
|
744
|
+
* @param params - Parameters including the required deviceId
|
|
745
|
+
* @returns A Result containing the live image data or an error
|
|
746
|
+
*
|
|
747
|
+
* @example
|
|
748
|
+
* ```typescript
|
|
749
|
+
* import { getLiveImage } from 'een-api-toolkit'
|
|
750
|
+
*
|
|
751
|
+
* const { data, error } = await getLiveImage({ deviceId: 'camera-123' })
|
|
752
|
+
*
|
|
753
|
+
* if (data) {
|
|
754
|
+
* // Display in an img element
|
|
755
|
+
* document.getElementById('cameraImage').src = data.imageData
|
|
756
|
+
* console.log('Image timestamp:', data.timestamp)
|
|
757
|
+
* }
|
|
758
|
+
*
|
|
759
|
+
* // Continuously update the image with proper error handling
|
|
760
|
+
* let isRunning = true
|
|
761
|
+
* async function refreshLoop() {
|
|
762
|
+
* const imgElement = document.getElementById('cameraImage') as HTMLImageElement
|
|
763
|
+
* while (isRunning) {
|
|
764
|
+
* const { data, error } = await getLiveImage({ deviceId: 'camera-123' })
|
|
765
|
+
* if (error) {
|
|
766
|
+
* console.error('Refresh failed:', error.message)
|
|
767
|
+
* break // Stop on error
|
|
768
|
+
* }
|
|
769
|
+
* if (data) {
|
|
770
|
+
* imgElement.src = data.imageData
|
|
771
|
+
* }
|
|
772
|
+
* await new Promise(r => setTimeout(r, 1000))
|
|
773
|
+
* }
|
|
774
|
+
* }
|
|
775
|
+
* // Call refreshLoop() to start, set isRunning = false to stop
|
|
776
|
+
* ```
|
|
777
|
+
*
|
|
778
|
+
* @category Media
|
|
779
|
+
*/
|
|
780
|
+
export declare function getLiveImage(params: GetLiveImageParams): Promise<Result<LiveImageResult>>;
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Parameters for getting a live image.
|
|
784
|
+
*
|
|
785
|
+
* @remarks
|
|
786
|
+
* Used to fetch a live image from a camera.
|
|
787
|
+
* Note: Live images only support 'preview' type.
|
|
788
|
+
*
|
|
789
|
+
* For more details, see the
|
|
790
|
+
* [EEN API Documentation](https://developer.eagleeyenetworks.com/reference/getliveimage).
|
|
791
|
+
*
|
|
792
|
+
* @example
|
|
793
|
+
* ```typescript
|
|
794
|
+
* import { getLiveImage } from 'een-api-toolkit'
|
|
795
|
+
*
|
|
796
|
+
* const { data } = await getLiveImage({
|
|
797
|
+
* deviceId: 'camera-123',
|
|
798
|
+
* type: 'preview'
|
|
799
|
+
* })
|
|
800
|
+
*
|
|
801
|
+
* if (data) {
|
|
802
|
+
* // Display the image in an <img> element
|
|
803
|
+
* imgElement.src = data.imageData
|
|
804
|
+
* }
|
|
805
|
+
* ```
|
|
806
|
+
*
|
|
807
|
+
* @category Media
|
|
808
|
+
*/
|
|
809
|
+
export declare interface GetLiveImageParams {
|
|
810
|
+
/** The ID of the device (camera) - required */
|
|
811
|
+
deviceId: string;
|
|
812
|
+
/** Stream type - only 'preview' is supported for live images */
|
|
813
|
+
type?: 'preview';
|
|
814
|
+
}
|
|
815
|
+
|
|
727
816
|
/**
|
|
728
817
|
* Get the proxy URL
|
|
729
818
|
*/
|
|
730
819
|
export declare function getProxyUrl(): string | undefined;
|
|
731
820
|
|
|
821
|
+
/**
|
|
822
|
+
* Get a recorded image from a camera.
|
|
823
|
+
*
|
|
824
|
+
* @remarks
|
|
825
|
+
* Fetches a recorded image from the specified camera at a specific timestamp.
|
|
826
|
+
* You can specify the desired timestamp using various operators (exact, gte, lte, etc.)
|
|
827
|
+
* or use a pageToken from a previous request to navigate through images.
|
|
828
|
+
*
|
|
829
|
+
* The image is returned as a base64 data URL that can be used directly in an HTML img element.
|
|
830
|
+
*
|
|
831
|
+
* Note: The 'main' type is rate-limited and requires an actual recording at the timestamp.
|
|
832
|
+
*
|
|
833
|
+
* For more details, see the
|
|
834
|
+
* [EEN API Documentation](https://developer.eagleeyenetworks.com/reference/getrecordedimage).
|
|
835
|
+
*
|
|
836
|
+
* @param params - Parameters including deviceId/pageToken and timestamp options
|
|
837
|
+
* @returns A Result containing the recorded image data or an error
|
|
838
|
+
*
|
|
839
|
+
* @example
|
|
840
|
+
* ```typescript
|
|
841
|
+
* import { getRecordedImage } from 'een-api-toolkit'
|
|
842
|
+
*
|
|
843
|
+
* // Get image at or after a specific time
|
|
844
|
+
* const { data, error } = await getRecordedImage({
|
|
845
|
+
* deviceId: 'camera-123',
|
|
846
|
+
* type: 'preview',
|
|
847
|
+
* timestamp__gte: '2024-01-15T10:00:00.000Z'
|
|
848
|
+
* })
|
|
849
|
+
*
|
|
850
|
+
* if (data) {
|
|
851
|
+
* imgElement.src = data.imageData
|
|
852
|
+
* console.log('Actual timestamp:', data.timestamp)
|
|
853
|
+
*
|
|
854
|
+
* // Get the next image using the token
|
|
855
|
+
* if (data.nextToken) {
|
|
856
|
+
* const { data: nextImage } = await getRecordedImage({
|
|
857
|
+
* pageToken: data.nextToken
|
|
858
|
+
* })
|
|
859
|
+
* }
|
|
860
|
+
* }
|
|
861
|
+
* ```
|
|
862
|
+
*
|
|
863
|
+
* @category Media
|
|
864
|
+
*/
|
|
865
|
+
export declare function getRecordedImage(params: GetRecordedImageParams): Promise<Result<RecordedImageResult>>;
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Parameters for getting a recorded image.
|
|
869
|
+
*
|
|
870
|
+
* @remarks
|
|
871
|
+
* Used to fetch a recorded image from a camera at a specific timestamp.
|
|
872
|
+
* Either deviceId with a timestamp parameter, or pageToken is required.
|
|
873
|
+
*
|
|
874
|
+
* For more details, see the
|
|
875
|
+
* [EEN API Documentation](https://developer.eagleeyenetworks.com/reference/getrecordedimage).
|
|
876
|
+
*
|
|
877
|
+
* @example
|
|
878
|
+
* ```typescript
|
|
879
|
+
* import { getRecordedImage } from 'een-api-toolkit'
|
|
880
|
+
*
|
|
881
|
+
* // Get image at or after a specific time
|
|
882
|
+
* const { data } = await getRecordedImage({
|
|
883
|
+
* deviceId: 'camera-123',
|
|
884
|
+
* type: 'preview',
|
|
885
|
+
* timestamp__gte: '2024-01-15T10:00:00.000Z'
|
|
886
|
+
* })
|
|
887
|
+
* ```
|
|
888
|
+
*
|
|
889
|
+
* @category Media
|
|
890
|
+
*/
|
|
891
|
+
export declare interface GetRecordedImageParams {
|
|
892
|
+
/** The ID of the device (camera) - required unless using pageToken */
|
|
893
|
+
deviceId?: string;
|
|
894
|
+
/** Token from previous request to fetch next/previous image */
|
|
895
|
+
pageToken?: string;
|
|
896
|
+
/** Stream type (preview or main) */
|
|
897
|
+
type?: MediaStreamType;
|
|
898
|
+
/** Return first image with timestamp less than this value */
|
|
899
|
+
timestamp__lt?: string;
|
|
900
|
+
/** Return first image with timestamp less than or equal to this value */
|
|
901
|
+
timestamp__lte?: string;
|
|
902
|
+
/** Return image at this exact timestamp */
|
|
903
|
+
timestamp?: string;
|
|
904
|
+
/** Return first image with timestamp greater than or equal to this value */
|
|
905
|
+
timestamp__gte?: string;
|
|
906
|
+
/** Return first image with timestamp greater than this value */
|
|
907
|
+
timestamp__gt?: string;
|
|
908
|
+
/** List of overlay IDs to include */
|
|
909
|
+
overlayId__in?: string[];
|
|
910
|
+
/**
|
|
911
|
+
* Include options for overlays.
|
|
912
|
+
* Valid values: overlayEmbedded, overlaySvgHeader
|
|
913
|
+
*/
|
|
914
|
+
include?: string[];
|
|
915
|
+
/** Target width for the returned image (32-7680) */
|
|
916
|
+
targetWidth?: number;
|
|
917
|
+
/** Target height for the returned image (32-4320) */
|
|
918
|
+
targetHeight?: number;
|
|
919
|
+
}
|
|
920
|
+
|
|
732
921
|
/**
|
|
733
922
|
* Get the redirect URI
|
|
734
923
|
*/
|
|
@@ -1010,6 +1199,91 @@ export declare interface ListCamerasParams {
|
|
|
1010
1199
|
status__ne?: CameraStatus;
|
|
1011
1200
|
}
|
|
1012
1201
|
|
|
1202
|
+
/**
|
|
1203
|
+
* List media intervals (recording periods) for a device.
|
|
1204
|
+
*
|
|
1205
|
+
* @remarks
|
|
1206
|
+
* Fetches a paginated list of time intervals for which recordings exist.
|
|
1207
|
+
* Use this to find available recordings for a camera.
|
|
1208
|
+
*
|
|
1209
|
+
* For more details, see the
|
|
1210
|
+
* [EEN API Documentation](https://developer.eagleeyenetworks.com/reference/listmedia).
|
|
1211
|
+
*
|
|
1212
|
+
* @param params - Required parameters including deviceId, type, mediaType, and startTimestamp
|
|
1213
|
+
* @returns A Result containing a paginated list of media intervals or an error
|
|
1214
|
+
*
|
|
1215
|
+
* @example
|
|
1216
|
+
* ```typescript
|
|
1217
|
+
* import { listMedia } from 'een-api-toolkit'
|
|
1218
|
+
*
|
|
1219
|
+
* // Get video recordings from the last hour
|
|
1220
|
+
* const { data, error } = await listMedia({
|
|
1221
|
+
* deviceId: 'camera-123',
|
|
1222
|
+
* type: 'preview',
|
|
1223
|
+
* mediaType: 'video',
|
|
1224
|
+
* startTimestamp: new Date(Date.now() - 3600000).toISOString()
|
|
1225
|
+
* })
|
|
1226
|
+
*
|
|
1227
|
+
* if (data) {
|
|
1228
|
+
* console.log(`Found ${data.results.length} recording intervals`)
|
|
1229
|
+
* data.results.forEach(interval => {
|
|
1230
|
+
* console.log(`${interval.startTimestamp} - ${interval.endTimestamp}`)
|
|
1231
|
+
* })
|
|
1232
|
+
* }
|
|
1233
|
+
* ```
|
|
1234
|
+
*
|
|
1235
|
+
* @category Media
|
|
1236
|
+
*/
|
|
1237
|
+
export declare function listMedia(params: ListMediaParams): Promise<Result<PaginatedResult<MediaInterval>>>;
|
|
1238
|
+
|
|
1239
|
+
/**
|
|
1240
|
+
* Parameters for listing media intervals.
|
|
1241
|
+
*
|
|
1242
|
+
* @remarks
|
|
1243
|
+
* Used to query recording intervals for a device.
|
|
1244
|
+
*
|
|
1245
|
+
* For more details, see the
|
|
1246
|
+
* [EEN API Documentation](https://developer.eagleeyenetworks.com/reference/listmedia).
|
|
1247
|
+
*
|
|
1248
|
+
* @example
|
|
1249
|
+
* ```typescript
|
|
1250
|
+
* import { listMedia } from 'een-api-toolkit'
|
|
1251
|
+
*
|
|
1252
|
+
* // Get video recordings from the last hour
|
|
1253
|
+
* const { data } = await listMedia({
|
|
1254
|
+
* deviceId: 'camera-123',
|
|
1255
|
+
* type: 'preview',
|
|
1256
|
+
* mediaType: 'video',
|
|
1257
|
+
* startTimestamp: new Date(Date.now() - 3600000).toISOString()
|
|
1258
|
+
* })
|
|
1259
|
+
* ```
|
|
1260
|
+
*
|
|
1261
|
+
* @category Media
|
|
1262
|
+
*/
|
|
1263
|
+
export declare interface ListMediaParams {
|
|
1264
|
+
/** The ID of the device (camera) - required */
|
|
1265
|
+
deviceId: string;
|
|
1266
|
+
/** Stream type (preview or main) - required */
|
|
1267
|
+
type: MediaStreamType;
|
|
1268
|
+
/** Media type (video or image) - required */
|
|
1269
|
+
mediaType: MediaType;
|
|
1270
|
+
/** Minimum timestamp from which to list recordings (ISO 8601) - required */
|
|
1271
|
+
startTimestamp: string;
|
|
1272
|
+
/** Maximum timestamp until which to list recordings (ISO 8601) */
|
|
1273
|
+
endTimestamp?: string;
|
|
1274
|
+
/** If true, coalesce connected intervals into a single interval (default: true) */
|
|
1275
|
+
coalesce?: boolean;
|
|
1276
|
+
/**
|
|
1277
|
+
* Additional fields to include in the response.
|
|
1278
|
+
* Valid values: flvUrl, rtspUrl, rtspsUrl, hlsUrl, multipartUrl, mp4Url, wsLiveUrl
|
|
1279
|
+
*/
|
|
1280
|
+
include?: string[];
|
|
1281
|
+
/** Token for fetching a specific page */
|
|
1282
|
+
pageToken?: string;
|
|
1283
|
+
/** Number of results per page */
|
|
1284
|
+
pageSize?: number;
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1013
1287
|
/**
|
|
1014
1288
|
* Parameters for listing users.
|
|
1015
1289
|
*
|
|
@@ -1037,6 +1311,80 @@ export declare interface ListUsersParams {
|
|
|
1037
1311
|
include?: string[];
|
|
1038
1312
|
}
|
|
1039
1313
|
|
|
1314
|
+
/**
|
|
1315
|
+
* Result of getting a live image.
|
|
1316
|
+
*
|
|
1317
|
+
* @remarks
|
|
1318
|
+
* Contains the image data as a base64 data URL and metadata from response headers.
|
|
1319
|
+
*
|
|
1320
|
+
* @category Media
|
|
1321
|
+
*/
|
|
1322
|
+
export declare interface LiveImageResult {
|
|
1323
|
+
/** Base64 encoded image data URL (data:image/jpeg;base64,...) */
|
|
1324
|
+
imageData: string;
|
|
1325
|
+
/** Timestamp of the image (from X-Een-Timestamp header) */
|
|
1326
|
+
timestamp: string | null;
|
|
1327
|
+
/** Token to fetch the previous image (from X-Een-PrevToken header) */
|
|
1328
|
+
prevToken: string | null;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* Media interval from EEN API v3.0.
|
|
1333
|
+
*
|
|
1334
|
+
* @remarks
|
|
1335
|
+
* Represents a time interval for which recordings exist.
|
|
1336
|
+
*
|
|
1337
|
+
* @category Media
|
|
1338
|
+
*/
|
|
1339
|
+
export declare interface MediaInterval {
|
|
1340
|
+
/** Stream type (preview or main) */
|
|
1341
|
+
type: MediaStreamType;
|
|
1342
|
+
/** The device ID that generated the media */
|
|
1343
|
+
deviceId: string;
|
|
1344
|
+
/** Type of media contained (video or image) */
|
|
1345
|
+
mediaType: MediaType;
|
|
1346
|
+
/** Start time of the media interval (ISO 8601) */
|
|
1347
|
+
startTimestamp: string;
|
|
1348
|
+
/** End time of the media interval (ISO 8601) */
|
|
1349
|
+
endTimestamp: string;
|
|
1350
|
+
/** Flash video URL (if requested via include) */
|
|
1351
|
+
flvUrl?: string | null;
|
|
1352
|
+
/** RTSP URL (if requested via include) */
|
|
1353
|
+
rtspUrl?: string;
|
|
1354
|
+
/** RTSPS URL (if requested via include) */
|
|
1355
|
+
rtspsUrl?: string;
|
|
1356
|
+
/** HLS URL (if requested via include) */
|
|
1357
|
+
hlsUrl?: string | null;
|
|
1358
|
+
/** Multipart URL (if requested via include) */
|
|
1359
|
+
multipartUrl?: string;
|
|
1360
|
+
/** MP4 URL (if requested via include) */
|
|
1361
|
+
mp4Url?: string | null;
|
|
1362
|
+
/** WebSocket live URL (if requested via include) */
|
|
1363
|
+
wsLiveUrl?: string;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* Stream type values from EEN API v3.0.
|
|
1368
|
+
*
|
|
1369
|
+
* @remarks
|
|
1370
|
+
* Indicates the quality/type of the media stream.
|
|
1371
|
+
* - `preview`: Low resolution, low framerate stream
|
|
1372
|
+
* - `main`: High resolution stream
|
|
1373
|
+
*
|
|
1374
|
+
* @category Media
|
|
1375
|
+
*/
|
|
1376
|
+
export declare type MediaStreamType = 'preview' | 'main';
|
|
1377
|
+
|
|
1378
|
+
/**
|
|
1379
|
+
* Media type values from EEN API v3.0.
|
|
1380
|
+
*
|
|
1381
|
+
* @remarks
|
|
1382
|
+
* Indicates the type of media content.
|
|
1383
|
+
*
|
|
1384
|
+
* @category Media
|
|
1385
|
+
*/
|
|
1386
|
+
export declare type MediaType = 'video' | 'image';
|
|
1387
|
+
|
|
1040
1388
|
/**
|
|
1041
1389
|
* Paginated response from list operations.
|
|
1042
1390
|
*
|
|
@@ -1088,6 +1436,27 @@ export declare interface PaginationParams {
|
|
|
1088
1436
|
pageToken?: string;
|
|
1089
1437
|
}
|
|
1090
1438
|
|
|
1439
|
+
/**
|
|
1440
|
+
* Result of getting a recorded image.
|
|
1441
|
+
*
|
|
1442
|
+
* @remarks
|
|
1443
|
+
* Contains the image data as a base64 data URL and metadata from response headers.
|
|
1444
|
+
*
|
|
1445
|
+
* @category Media
|
|
1446
|
+
*/
|
|
1447
|
+
export declare interface RecordedImageResult {
|
|
1448
|
+
/** Base64 encoded image data URL (data:image/jpeg;base64,...) */
|
|
1449
|
+
imageData: string;
|
|
1450
|
+
/** Timestamp of the image (from X-Een-Timestamp header) */
|
|
1451
|
+
timestamp: string | null;
|
|
1452
|
+
/** Token to fetch the next image (from X-Een-NextToken header) */
|
|
1453
|
+
nextToken: string | null;
|
|
1454
|
+
/** Token to fetch the previous image (from X-Een-PrevToken header) */
|
|
1455
|
+
prevToken: string | null;
|
|
1456
|
+
/** SVG overlay data (from X-Een-OverlaySvg header, if requested) */
|
|
1457
|
+
overlaySvg: string | null;
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1091
1460
|
/**
|
|
1092
1461
|
* Refresh the access token using stored refresh token
|
|
1093
1462
|
*/
|