Skip to content

Commit

Permalink
fix: devicetype start up + upgrade to latest sidecar
Browse files Browse the repository at this point in the history
  • Loading branch information
npenin committed Nov 24, 2024
1 parent 38d75ee commit 17378d1
Show file tree
Hide file tree
Showing 26 changed files with 175 additions and 121 deletions.
28 changes: 28 additions & 0 deletions .akala.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,33 @@
},
"commands": {
"sdk": "./node_modules/@akala/commands/commands.json"
},
"@domojs/devicetype": {
"store": {
"provider": "file",
"providerOptions": {
"rootDbName": "./db/devices"
},
"models": {
"DeviceInit": {
"members": {
"name": {
"isKey": true,
"type": {
"type": "string",
"length": 250
},
"generator": "business"
},
"body": {
"isKey": false,
"type": {
"type": "string"
}
}
}
}
}
}
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"packages/*"
],
"devDependencies": {
"@akala/automate": "^6.0.42",
"@akala/automate-yamlloader": "^3.0.42",
"@akala/automate": "^6.0.43",
"@akala/automate-yamlloader": "^3.0.43",
"@akala/cli": "^3.0.14",
"@akala/commands": "^11.0.8",
"@akala/pm": "^12.1.20",
"@akala/pm": "^12.1.21",
"@akala/semantic-release": "^3.0.33",
"typescript": "^5.7.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"devDependencies": {
"@akala/commands": "^11.0.8",
"@akala/pm": "^12.1.20",
"@akala/pm": "^12.1.21",
"@types/yargs": "17.0.33"
},
"gitHead": "5c8b6cb938eb920110c9a48ec210f2a65ee04176"
Expand Down
10 changes: 5 additions & 5 deletions packages/devices/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"@akala/config": "^5.0.33",
"@akala/core": "^19.0.14",
"@akala/json-rpc-ws": "^11.0.14",
"@akala/pm": "^12.1.20",
"@akala/pubsub": "^3.0.42",
"@akala/server": "^10.0.42",
"@akala/sidecar": "^5.0.12",
"@akala/pm": "^12.1.21",
"@akala/pubsub": "^3.0.43",
"@akala/server": "^10.0.43",
"@akala/sidecar": "^7.0.0",
"@akala/storage": "^6.0.14",
"@fortawesome/free-brands-svg-icons": "6.7.1",
"ws": "8.18.0"
Expand Down Expand Up @@ -59,4 +59,4 @@
},
"typings": "dist/index.d.ts",
"gitHead": "0753bdd964281fd06c89ea8a751ed1605dfd5ee8"
}
}
40 changes: 33 additions & 7 deletions packages/devices/src/server/commands/device-types/$init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { fileURLToPath } from 'url'
import Configuration, { ProxyConfiguration } from "@akala/config";


export default async function (this: devices.DeviceTypeState, context: CliContext<Record<string, OptionType>, Configuration>, container: Container<unknown>, pm: pmContainer & Container<any>)
export default async function (this: devices.DeviceTypeState, context: CliContext<Record<string, OptionType>, ProxyConfiguration<SidecarConfiguration>>, container: Container<unknown>, pm: pmContainer & Container<any>)
{
debugger;
try
Expand All @@ -24,14 +24,40 @@ export default async function (this: devices.DeviceTypeState, context: CliContex
}
this.initializing = [];
this.types = {};
let config: ProxyConfiguration<SidecarConfiguration>;
if (!context.state)
config = Configuration.new('./devicetype.json', {});
context.state = Configuration.new('./devicetype-app.json', {});
else
{
if (!context.state.has('devicetype'))
context.state.set('devicetype', {});
config = context.state.get('devicetype')
if (!context.state.has('store'))
{
context.state.set('store', {
"provider": "file",
"providerOptions": {
"rootDbName": "./db/devices"
},
"models": {
"DeviceInit": {
"members": {
"name": {
"isKey": true,
"type": {
"type": "string",
"length": 250
},
"generator": "business"
},
"body": {
"isKey": false,
"type": {
"type": "string"
}
}
}
}
}
});
await context.state.commit();
}
}
Object.assign(this, await app<{ DeviceInit: DbSet<{ name: string, body: any }> }>(context, config, pm));
Object.assign(this, await app<{ DeviceInit: DbSet<{ name: string, body: any }> }>(context, pm));
}
8 changes: 4 additions & 4 deletions packages/devices/src/server/commands/devices/$init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { State } from '../index.js';
import { CliContext, OptionType } from '@akala/cli';
import { fileURLToPath } from 'url'

export default async function (this: State, context: CliContext<Record<string, OptionType>, Configuration>, container: Container<any> & deviceContainer.container, pm: Container<any> & pmContainer)
export default async function (this: State, context: CliContext<Record<string, OptionType>, ProxyConfiguration<SidecarConfiguration>>, container: Container<any> & deviceContainer.container, pm: Container<any> & pmContainer)
{
if (!context.state.has('devices'))
context.state.set('devices', {});
const sidecar = await app(context, context.state.get<SidecarConfiguration>('devices'), pm);
// if (!context.state.has('devices'))
// context.state.set('devices', {});
const sidecar = await app(context, pm);

container.register('pm', pm);
var mdule = akala.module('@domojs/devices');
Expand Down
4 changes: 2 additions & 2 deletions packages/homekit-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@akala/config": "^5.0.33",
"@akala/core": "^19.0.14",
"@akala/protocol-parser": "^2.8.6",
"@akala/sidecar": "^5.0.12",
"@akala/sidecar": "^7.0.0",
"@domojs/devices": "workspace:^",
"fast-srp-hap": "^2.0.4",
"hap-nodejs": "^1.1.0"
Expand All @@ -27,4 +27,4 @@
"@akala/commands": "^11.0.8",
"@domojs/mdns": "workspace:^"
}
}
}
10 changes: 5 additions & 5 deletions packages/homekit-controller/src/commands/$init.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { CliContext, OptionType } from '@akala/cli';
import { Container, helper } from '@akala/commands';
import Configuration from '@akala/config';
import Configuration, { ProxyConfiguration } from '@akala/config';
import app, { SidecarConfiguration } from '@akala/sidecar'
import State from '../state.js';
import { DeviceType } from '@domojs/devices';

export default async function (this: State, context: CliContext<Record<string, OptionType>, Configuration>, container: Container<State>)
export default async function (this: State, context: CliContext<Record<string, OptionType>, ProxyConfiguration<SidecarConfiguration>>, container: Container<State>)
{
this.pairedAccessories = {};
Object.assign(this, helper(container));

if (!context.state.has('homekit'))
context.state.set('homekit', {});
const self = await app(context, context.state.get<SidecarConfiguration>('homekit'));
// if (!context.state.has('homekit'))
// context.state.set('homekit', {});
const self = await app(context);
self.pubsub?.subscribe(container, 'device-discovered', '/zeroconf/_hap');

await (await self.sidecars['@domojs/devicetype']).dispatch('register', { name: 'homekit' } as DeviceType);
Expand Down
2 changes: 1 addition & 1 deletion packages/homekit-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"dependencies": {
"@domojs/devices": "workspace:^"
}
}
}
4 changes: 2 additions & 2 deletions packages/iscp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"devDependencies": {
"@akala/commands": "^11.0.8",
"@akala/core": "^19.0.14",
"@akala/server": "^10.0.42",
"@akala/server": "^10.0.43",
"@types/ws": "8.5.13"
},
"deprecated": false,
Expand All @@ -41,4 +41,4 @@
"typings": "dist/index.d.ts",
"version": "4.0.27",
"gitHead": "0753bdd964281fd06c89ea8a751ed1605dfd5ee8"
}
}
2 changes: 1 addition & 1 deletion packages/lifttt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
"@types/debug": "4.1.12",
"typescript": "5.7.2"
}
}
}
2 changes: 1 addition & 1 deletion packages/mdns/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@akala/commands": "^11.0.8",
"@akala/config": "^5.0.33",
"@akala/core": "^19.0.14",
"@akala/sidecar": "^5.0.12",
"@akala/sidecar": "^7.0.0",
"multicast-dns": "^7.2.5"
},
"devDependencies": {
Expand Down
12 changes: 6 additions & 6 deletions packages/mdns/src/commands/$init.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import mDNS from 'multicast-dns';
import { StringAnswer } from 'dns-packet'
import app from '@akala/sidecar';
import app, { SidecarConfiguration } from '@akala/sidecar';
import { CliContext, OptionType } from '@akala/cli';
import { Configuration } from '@akala/config'
import { Configuration, ProxyConfiguration } from '@akala/config'
import { SerializableObject, logger } from '@akala/core'
import { State } from '../state.js';
import { Service } from '../index.js';
Expand Down Expand Up @@ -68,13 +68,13 @@ export const decodeTxt = (function ()
}
})();

export default async function (this: State, context: CliContext<Record<string, OptionType>, Configuration>, signal: AbortSignal)
export default async function (this: State, context: CliContext<Record<string, OptionType>, ProxyConfiguration<SidecarConfiguration>>, signal: AbortSignal)
{

if (!context.state.has('mdns'))
context.state.set('mdns', {});
// if (!context.state.has('mdns'))
// context.state.set('mdns', {});

const self = await app(context, context.state.get('mdns'))
const self = await app(context)

this.services = {};

Expand Down
2 changes: 1 addition & 1 deletion packages/media-chromecast/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"url": "https://github.com/npenin/domojs/issues"
},
"gitHead": "0753bdd964281fd06c89ea8a751ed1605dfd5ee8"
}
}
2 changes: 1 addition & 1 deletion packages/media-crunchyroll/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
"devDependencies": {
"@akala/cli": "^3.0.14"
}
}
}
2 changes: 1 addition & 1 deletion packages/media-yt-music/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
"scripts": {
"test": "echo \"Error: no test specified\""
}
}
}
6 changes: 3 additions & 3 deletions packages/media/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"devDependencies": {
"@akala/cli": "^3.0.14",
"@akala/json-rpc-ws": "^11.0.14",
"@akala/pm": "^12.1.20",
"@akala/server": "^10.0.42",
"@akala/pm": "^12.1.21",
"@akala/server": "^10.0.43",
"@akala/storage": "^6.0.14",
"@domojs/theme-default": "workspace:*",
"@types/debug": "4.1.12",
Expand All @@ -55,4 +55,4 @@
"@types/ws": "8.5.13",
"typescript": "5.7.2"
}
}
}
2 changes: 1 addition & 1 deletion packages/mqtt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"@types/request": "2.48.12"
},
"gitHead": "0753bdd964281fd06c89ea8a751ed1605dfd5ee8"
}
}
2 changes: 1 addition & 1 deletion packages/rfx-parsers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
"author": "Nicolas Penin <[email protected]>",
"license": "MIT",
"gitHead": "0753bdd964281fd06c89ea8a751ed1605dfd5ee8"
}
}
4 changes: 2 additions & 2 deletions packages/rfx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"deprecated": false,
"description": "",
"devDependencies": {
"@akala/pm": "^12.1.20",
"@akala/pm": "^12.1.21",
"@domojs/devices": "workspace:*",
"@types/debug": "^4.1.12",
"@types/usb": "^2.0.5",
Expand All @@ -55,4 +55,4 @@
"typings": "dist/index.d.ts",
"version": "4.0.31",
"gitHead": "0753bdd964281fd06c89ea8a751ed1605dfd5ee8"
}
}
6 changes: 3 additions & 3 deletions packages/theme-default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"@akala/commands": "^11.0.8",
"@akala/core": "^19.0.14",
"@akala/json-rpc-ws": "^11.0.14",
"@akala/pm": "^12.1.20",
"@akala/server": "^10.0.42",
"@akala/pm": "^12.1.21",
"@akala/server": "^10.0.43",
"@akala/web-ui": "^1.0.36",
"@fortawesome/fontawesome-common-types": "^6.7.1",
"@fortawesome/fontawesome-svg-core": "^6.7.1",
Expand Down Expand Up @@ -43,4 +43,4 @@
"version": "3.0.38",
"commands": "./commands.json",
"gitHead": "0753bdd964281fd06c89ea8a751ed1605dfd5ee8"
}
}
6 changes: 3 additions & 3 deletions packages/weather/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
},
"devDependencies": {
"@akala/json-rpc-ws": "^11.0.14",
"@akala/pm": "^12.1.20",
"@akala/server": "^10.0.42",
"@akala/pm": "^12.1.21",
"@akala/server": "^10.0.43",
"@domojs/devices": "workspace:*"
},
"dependencies": {
Expand All @@ -24,4 +24,4 @@
"@akala/core": "^19.0.14"
},
"gitHead": "0753bdd964281fd06c89ea8a751ed1605dfd5ee8"
}
}
6 changes: 3 additions & 3 deletions packages/webscrapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
},
"devDependencies": {
"@akala/json-rpc-ws": "^11.0.14",
"@akala/pm": "^12.1.20",
"@akala/server": "^10.0.42",
"@akala/pm": "^12.1.21",
"@akala/server": "^10.0.43",
"@domojs/devices": "workspace:*"
},
"dependencies": {
Expand All @@ -26,4 +26,4 @@
"htmlparser2": "^9.1.0"
},
"gitHead": "0753bdd964281fd06c89ea8a751ed1605dfd5ee8"
}
}
2 changes: 1 addition & 1 deletion packages/zigate-parsers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
"usb": "2.14.0"
},
"gitHead": "0753bdd964281fd06c89ea8a751ed1605dfd5ee8"
}
}
Loading

0 comments on commit 17378d1

Please sign in to comment.