server/sdk: fix bugs from decouple sdk and types

This commit is contained in:
Koushik Dutta
2022-02-05 14:26:20 -08:00
parent e31071b8ea
commit ca64b58d4f
11 changed files with 1497 additions and 1164 deletions

View File

@@ -1,7 +1,7 @@
import stringifyObject from 'stringify-object';
import { ScryptedInterface, ScryptedInterfaceDescriptor } from "./types.input";
import path from 'path';
import fs from "fs";
import fs, { mkdir } from "fs";
const schema = JSON.parse(fs.readFileSync(path.join(__dirname, '../schema.json')).toString());
const ScryptedInterfaceDescriptors: { [scryptedInterface: string]: ScryptedInterfaceDescriptor } = {};
@@ -216,9 +216,7 @@ class ${td.name}(TypedDict):
seen = newSeen;
}
fs.writeFileSync(path.join(__dirname, '../scrypted_python/scrypted_sdk/types.py'),
`from __future__ import annotations
const pythonTypes = `from __future__ import annotations
from enum import Enum
from typing_extensions import TypedDict
from typing import Any
@@ -228,4 +226,8 @@ from .other import *
${pythonEnums}
${python}
`);
`
fs.writeFileSync(path.join(__dirname, '../scrypted_python/scrypted_sdk/types.py'), pythonTypes);
fs.writeFileSync(path.join(__dirname, '../types/scrypted_python/scrypted_sdk/types.py'), pythonTypes);
fs.copyFileSync(path.join(__dirname, '../scrypted_python/scrypted_sdk/other.py'), path.join(__dirname, '../types/scrypted_python/scrypted_sdk/other.py'));

4
sdk/package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/sdk",
"version": "0.0.163",
"version": "0.0.164",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/sdk",
"version": "0.0.163",
"version": "0.0.164",
"license": "ISC",
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.14.5",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/sdk",
"version": "0.0.163",
"version": "0.0.164",
"description": "",
"main": "index.js",
"scripts": {

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/types",
"version": "0.0.2",
"version": "0.0.3",
"description": "",
"main": "index.js",
"author": "",

View File

@@ -0,0 +1,15 @@
from __future__ import annotations
from typing import Any
from typing import Callable
SettingValue = str
EventListener = Callable[[Any, Any, Any], None]
class Console:
pass
class Storage:
pass
class MediaObject:
mimeType: str

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
// could be useful for vscode ssh remote debugging. it forwards 10443, etc. to the remote host.
"remote.autoForwardPorts": false,
"python.analysis.extraPaths": [
"./node_modules/@scrypted/sdk",
"./node_modules/@scrypted/types",
"./python",
]
}

1299
server/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,7 +5,7 @@
"dependencies": {
"@mapbox/node-pre-gyp": "^1.0.8",
"@scrypted/ffmpeg": "^1.0.9",
"@scrypted/types": "^0.0.2",
"@scrypted/types": "^0.0.3",
"adm-zip": "^0.5.3",
"axios": "^0.21.1",
"body-parser": "^1.19.0",
@@ -20,6 +20,7 @@
"memfs": "^3.2.2",
"mime-db": "^1.51.0",
"mkdirp": "^1.0.4",
"nan": "^2.15.0",
"node-dijkstra": "^2.5.0",
"node-forge": "^1.2.0",
"node-pty": "^0.10.1",
@@ -29,8 +30,7 @@
"tar": "^6.1.11",
"tmp": "^0.2.1",
"tslib": "^2.3.1",
"typescript": "^4.4.4",
"werift": "^0.14.5",
"typescript": "^4.5.5",
"whatwg-mimetype": "^2.3.0",
"ws": "^8.2.3"
},

View File

@@ -15,7 +15,7 @@ import asyncio
import rpc
from collections.abc import Mapping
from scrypted_python.scrypted_sdk.types import DeviceManifest, MediaManager, ScryptedInterfaceProperty
import scrypted_python.scrypted_sdk
import scrypted_python.scrypted_sdk.types
from asyncio.futures import Future
from asyncio.streams import StreamReader, StreamWriter
import os
@@ -30,7 +30,7 @@ class SystemDeviceState(TypedDict):
value: any
class SystemManager(scrypted_python.scrypted_sdk.SystemManager):
class SystemManager(scrypted_python.scrypted_sdk.types.SystemManager):
def __init__(self, api: Any, systemState: Mapping[str, Mapping[str, SystemDeviceState]]) -> None:
super().__init__()
self.api = api
@@ -39,8 +39,8 @@ class SystemManager(scrypted_python.scrypted_sdk.SystemManager):
async def getComponent(self, id: str) -> Any:
return await self.api.getComponent(id)
class DeviceState(scrypted_python.scrypted_sdk.DeviceState):
def __init__(self, id: str, nativeId: str, systemManager: SystemManager, deviceManager: scrypted_python.scrypted_sdk.DeviceManager) -> None:
class DeviceState(scrypted_python.scrypted_sdk.types.DeviceState):
def __init__(self, id: str, nativeId: str, systemManager: SystemManager, deviceManager: scrypted_python.scrypted_sdk.types.DeviceManager) -> None:
super().__init__()
self._id = id
self.nativeId = nativeId
@@ -80,7 +80,7 @@ class DeviceStorage:
storage: Mapping[str, str] = {}
class DeviceManager(scrypted_python.scrypted_sdk.DeviceManager):
class DeviceManager(scrypted_python.scrypted_sdk.types.DeviceManager):
def __init__(self, nativeIds: Mapping[str, DeviceStorage], systemManager: SystemManager) -> None:
super().__init__()
self.nativeIds = nativeIds

View File

@@ -259,7 +259,7 @@ export class PluginHost {
// stdin, stdout, stderr, peer in, peer out
stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe'],
env: Object.assign({
PYTHONPATH: path.join(process.cwd(), 'node_modules/@scrypted/sdk'),
PYTHONPATH: path.join(process.cwd(), 'node_modules/@scrypted/types'),
}, process.env, env),
});