mirror of
https://github.com/koush/scrypted.git
synced 2026-03-02 01:02:57 +00:00
sdk: add event reporting, report sdk version
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import stringifyObject from 'stringify-object';
|
||||
import { ScryptedInterface, ScryptedInterfaceDescriptor } from "./types.input";
|
||||
import path from 'path';
|
||||
import fs, { mkdir } from "fs";
|
||||
import fs from "fs";
|
||||
|
||||
const schema = JSON.parse(fs.readFileSync(path.join(__dirname, '../schema.json')).toString());
|
||||
const typesVersion = JSON.parse(fs.readFileSync(path.join(__dirname, '../types/package.json')).toString()).version;
|
||||
const ScryptedInterfaceDescriptors: { [scryptedInterface: string]: ScryptedInterfaceDescriptor } = {};
|
||||
|
||||
const allProperties: { [property: string]: any } = {};
|
||||
@@ -48,6 +49,8 @@ ${properties.map(property => ' ' + property + ' = \"' + property + '",\n').join
|
||||
`;
|
||||
|
||||
const contents = `
|
||||
export const TYPES_VERSION = "${typesVersion}";
|
||||
|
||||
${deviceStateContents}
|
||||
${propertyContents}
|
||||
|
||||
|
||||
@@ -522,6 +522,24 @@ export interface VideoRecorder {
|
||||
getRecordingStreamThumbnail(time: number): Promise<MediaObject>;
|
||||
}
|
||||
|
||||
export interface RecordedEvent {
|
||||
id: string;
|
||||
details: EventDetails;
|
||||
data: any;
|
||||
}
|
||||
|
||||
export interface RecordedEventOptions {
|
||||
startTime?: number;
|
||||
endTime?: number;
|
||||
startId?: string;
|
||||
count?: number;
|
||||
reverseOrder?: boolean;
|
||||
}
|
||||
|
||||
export interface EventRecorder {
|
||||
getRecordedEvents(options: RecordedEventOptions): Promise<RecordedEvent[]>;
|
||||
}
|
||||
|
||||
export interface VideoClip {
|
||||
id: string;
|
||||
startTime: number;
|
||||
@@ -1426,6 +1444,7 @@ export enum ScryptedInterface {
|
||||
Display = "Display",
|
||||
VideoCamera = "VideoCamera",
|
||||
VideoRecorder = "VideoRecorder",
|
||||
EventRecorder = "EventRecorder",
|
||||
VideoClips = "VideoClips",
|
||||
VideoCameraConfiguration = "VideoCameraConfiguration",
|
||||
Intercom = "Intercom",
|
||||
|
||||
@@ -9,6 +9,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
var _a, _b, _c;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MixinDeviceBase = exports.ScryptedDeviceBase = void 0;
|
||||
__exportStar(require("./types/index"), exports);
|
||||
@@ -153,6 +154,11 @@ try {
|
||||
systemManager,
|
||||
pluginHostAPI,
|
||||
});
|
||||
try {
|
||||
(_c = (_b = (_a = systemManager).setScryptedInterfaceDescriptors) === null || _b === void 0 ? void 0 : _b.call(_a, index_1.TYPES_VERSION, index_1.ScryptedInterfaceDescriptors)) === null || _c === void 0 ? void 0 : _c.catch(() => { });
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
console.error('sdk initialization error, import @scrypted/types or use @scrypted/web-sdk instead', e);
|
||||
|
||||
10
sdk/index.ts
10
sdk/index.ts
@@ -1,5 +1,5 @@
|
||||
export * from './types/index'
|
||||
import { ScryptedInterfaceProperty, DeviceBase, MediaObject } from './types/index';
|
||||
import { ScryptedInterfaceProperty, DeviceBase, MediaObject, ScryptedInterfaceDescriptors, TYPES_VERSION } from './types/index';
|
||||
import type { ScryptedNativeId, DeviceManager, SystemManager, MediaManager, EndpointManager, EventListenerRegister } from './types/index';
|
||||
import type { ScryptedInterface, ScryptedStatic, Logger, DeviceState } from './types/index';
|
||||
|
||||
@@ -191,7 +191,13 @@ try {
|
||||
mediaManager,
|
||||
systemManager,
|
||||
pluginHostAPI,
|
||||
});
|
||||
});
|
||||
|
||||
try {
|
||||
(systemManager as any).setScryptedInterfaceDescriptors?.(TYPES_VERSION, ScryptedInterfaceDescriptors)?.catch(() => {});
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
console.error('sdk initialization error, import @scrypted/types or use @scrypted/web-sdk instead', e);
|
||||
|
||||
@@ -91,6 +91,7 @@ class ScryptedInterface(Enum):
|
||||
EngineIOHandler = "EngineIOHandler"
|
||||
Entry = "Entry"
|
||||
EntrySensor = "EntrySensor"
|
||||
EventRecorder = "EventRecorder"
|
||||
Fan = "Fan"
|
||||
FloodSensor = "FloodSensor"
|
||||
HttpRequestHandler = "HttpRequestHandler"
|
||||
@@ -419,6 +420,20 @@ class RTCSessionControl(TypedDict):
|
||||
class RTCSignalingSession(TypedDict):
|
||||
pass
|
||||
|
||||
class RecordedEvent(TypedDict):
|
||||
data: Any
|
||||
details: EventDetails
|
||||
id: str
|
||||
pass
|
||||
|
||||
class RecordedEventOptions(TypedDict):
|
||||
count: float
|
||||
endTime: float
|
||||
reverseOrder: bool
|
||||
startId: str
|
||||
startTime: float
|
||||
pass
|
||||
|
||||
class RequestMediaStreamOptions(TypedDict):
|
||||
audio: AudioStreamOptions
|
||||
container: str
|
||||
@@ -662,6 +677,11 @@ class EntrySensor:
|
||||
entryOpen: bool
|
||||
pass
|
||||
|
||||
class EventRecorder:
|
||||
async def getRecordedEvents(self, options: RecordedEventOptions) -> list[RecordedEvent]:
|
||||
pass
|
||||
pass
|
||||
|
||||
class Fan:
|
||||
fan: FanStatus
|
||||
async def setFan(self, fan: FanState) -> None:
|
||||
@@ -1737,6 +1757,13 @@ ScryptedInterfaceDescriptors = {
|
||||
],
|
||||
"properties": []
|
||||
},
|
||||
"EventRecorder": {
|
||||
"name": "EventRecorder",
|
||||
"methods": [
|
||||
"getRecordedEvents"
|
||||
],
|
||||
"properties": []
|
||||
},
|
||||
"VideoClips": {
|
||||
"name": "VideoClips",
|
||||
"methods": [
|
||||
|
||||
17
sdk/types/index.d.ts
vendored
17
sdk/types/index.d.ts
vendored
@@ -1,4 +1,5 @@
|
||||
/// <reference types="node" />
|
||||
export declare const TYPES_VERSION = "0.0.47";
|
||||
export interface DeviceState {
|
||||
id?: string;
|
||||
info?: DeviceInformation;
|
||||
@@ -650,6 +651,21 @@ export interface VideoRecorder {
|
||||
getRecordingStreamOptions(): Promise<ResponseMediaStreamOptions[]>;
|
||||
getRecordingStreamThumbnail(time: number): Promise<MediaObject>;
|
||||
}
|
||||
export interface RecordedEvent {
|
||||
id: string;
|
||||
details: EventDetails;
|
||||
data: any;
|
||||
}
|
||||
export interface RecordedEventOptions {
|
||||
startTime?: number;
|
||||
endTime?: number;
|
||||
startId?: string;
|
||||
count?: number;
|
||||
reverseOrder?: boolean;
|
||||
}
|
||||
export interface EventRecorder {
|
||||
getRecordedEvents(options: RecordedEventOptions): Promise<RecordedEvent[]>;
|
||||
}
|
||||
export interface VideoClip {
|
||||
id: string;
|
||||
startTime: number;
|
||||
@@ -1466,6 +1482,7 @@ export declare enum ScryptedInterface {
|
||||
Display = "Display",
|
||||
VideoCamera = "VideoCamera",
|
||||
VideoRecorder = "VideoRecorder",
|
||||
EventRecorder = "EventRecorder",
|
||||
VideoClips = "VideoClips",
|
||||
VideoCameraConfiguration = "VideoCameraConfiguration",
|
||||
Intercom = "Intercom",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ScryptedMimeTypes = exports.ScryptedInterface = exports.MediaPlayerState = exports.SecuritySystemObstruction = exports.SecuritySystemMode = exports.AirQuality = exports.LockState = exports.ThermostatMode = exports.TemperatureUnit = exports.FanMode = exports.HumidityMode = exports.ScryptedDeviceType = exports.ScryptedInterfaceDescriptors = exports.ScryptedInterfaceProperty = exports.DeviceBase = void 0;
|
||||
exports.ScryptedMimeTypes = exports.ScryptedInterface = exports.MediaPlayerState = exports.SecuritySystemObstruction = exports.SecuritySystemMode = exports.AirQuality = exports.LockState = exports.ThermostatMode = exports.TemperatureUnit = exports.FanMode = exports.HumidityMode = exports.ScryptedDeviceType = exports.ScryptedInterfaceDescriptors = exports.ScryptedInterfaceProperty = exports.DeviceBase = exports.TYPES_VERSION = void 0;
|
||||
exports.TYPES_VERSION = "0.0.47";
|
||||
class DeviceBase {
|
||||
}
|
||||
exports.DeviceBase = DeviceBase;
|
||||
@@ -253,6 +254,13 @@ exports.ScryptedInterfaceDescriptors = {
|
||||
],
|
||||
properties: []
|
||||
},
|
||||
EventRecorder: {
|
||||
name: 'EventRecorder',
|
||||
methods: [
|
||||
'getRecordedEvents'
|
||||
],
|
||||
properties: []
|
||||
},
|
||||
VideoClips: {
|
||||
name: 'VideoClips',
|
||||
methods: [
|
||||
@@ -766,6 +774,7 @@ var ScryptedInterface;
|
||||
ScryptedInterface["Display"] = "Display";
|
||||
ScryptedInterface["VideoCamera"] = "VideoCamera";
|
||||
ScryptedInterface["VideoRecorder"] = "VideoRecorder";
|
||||
ScryptedInterface["EventRecorder"] = "EventRecorder";
|
||||
ScryptedInterface["VideoClips"] = "VideoClips";
|
||||
ScryptedInterface["VideoCameraConfiguration"] = "VideoCameraConfiguration";
|
||||
ScryptedInterface["Intercom"] = "Intercom";
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
export const TYPES_VERSION = "0.0.47";
|
||||
|
||||
|
||||
export interface DeviceState {
|
||||
id?: string
|
||||
@@ -368,6 +370,13 @@ export const ScryptedInterfaceDescriptors: { [scryptedInterface: string]: Scrypt
|
||||
],
|
||||
properties: []
|
||||
},
|
||||
EventRecorder: {
|
||||
name: 'EventRecorder',
|
||||
methods: [
|
||||
'getRecordedEvents'
|
||||
],
|
||||
properties: []
|
||||
},
|
||||
VideoClips: {
|
||||
name: 'VideoClips',
|
||||
methods: [
|
||||
@@ -1276,6 +1285,24 @@ export interface VideoRecorder {
|
||||
getRecordingStreamThumbnail(time: number): Promise<MediaObject>;
|
||||
}
|
||||
|
||||
export interface RecordedEvent {
|
||||
id: string;
|
||||
details: EventDetails;
|
||||
data: any;
|
||||
}
|
||||
|
||||
export interface RecordedEventOptions {
|
||||
startTime?: number;
|
||||
endTime?: number;
|
||||
startId?: string;
|
||||
count?: number;
|
||||
reverseOrder?: boolean;
|
||||
}
|
||||
|
||||
export interface EventRecorder {
|
||||
getRecordedEvents(options: RecordedEventOptions): Promise<RecordedEvent[]>;
|
||||
}
|
||||
|
||||
export interface VideoClip {
|
||||
id: string;
|
||||
startTime: number;
|
||||
@@ -2180,6 +2207,7 @@ export enum ScryptedInterface {
|
||||
Display = "Display",
|
||||
VideoCamera = "VideoCamera",
|
||||
VideoRecorder = "VideoRecorder",
|
||||
EventRecorder = "EventRecorder",
|
||||
VideoClips = "VideoClips",
|
||||
VideoCameraConfiguration = "VideoCameraConfiguration",
|
||||
Intercom = "Intercom",
|
||||
|
||||
@@ -91,6 +91,7 @@ class ScryptedInterface(Enum):
|
||||
EngineIOHandler = "EngineIOHandler"
|
||||
Entry = "Entry"
|
||||
EntrySensor = "EntrySensor"
|
||||
EventRecorder = "EventRecorder"
|
||||
Fan = "Fan"
|
||||
FloodSensor = "FloodSensor"
|
||||
HttpRequestHandler = "HttpRequestHandler"
|
||||
@@ -419,6 +420,20 @@ class RTCSessionControl(TypedDict):
|
||||
class RTCSignalingSession(TypedDict):
|
||||
pass
|
||||
|
||||
class RecordedEvent(TypedDict):
|
||||
data: Any
|
||||
details: EventDetails
|
||||
id: str
|
||||
pass
|
||||
|
||||
class RecordedEventOptions(TypedDict):
|
||||
count: float
|
||||
endTime: float
|
||||
reverseOrder: bool
|
||||
startId: str
|
||||
startTime: float
|
||||
pass
|
||||
|
||||
class RequestMediaStreamOptions(TypedDict):
|
||||
audio: AudioStreamOptions
|
||||
container: str
|
||||
@@ -662,6 +677,11 @@ class EntrySensor:
|
||||
entryOpen: bool
|
||||
pass
|
||||
|
||||
class EventRecorder:
|
||||
async def getRecordedEvents(self, options: RecordedEventOptions) -> list[RecordedEvent]:
|
||||
pass
|
||||
pass
|
||||
|
||||
class Fan:
|
||||
fan: FanStatus
|
||||
async def setFan(self, fan: FanState) -> None:
|
||||
@@ -1737,6 +1757,13 @@ ScryptedInterfaceDescriptors = {
|
||||
],
|
||||
"properties": []
|
||||
},
|
||||
"EventRecorder": {
|
||||
"name": "EventRecorder",
|
||||
"methods": [
|
||||
"getRecordedEvents"
|
||||
],
|
||||
"properties": []
|
||||
},
|
||||
"VideoClips": {
|
||||
"name": "VideoClips",
|
||||
"methods": [
|
||||
|
||||
Reference in New Issue
Block a user