diff --git a/packages/controller/test/lib/testObjects.ts b/packages/controller/test/lib/testObjects.ts index 0f4cf8b69..cf684cbd6 100644 --- a/packages/controller/test/lib/testObjects.ts +++ b/packages/controller/test/lib/testObjects.ts @@ -10,36 +10,27 @@ export function register(it: Mocha.TestFunction, expect: Chai.ExpectStatic, cont const namespace = 'testObject.0'; const testId = `${namespace}.test2`; - it(`${testName}should create and read object`, done => { + it(`${testName}should create and read object`, async (): Promise => { const objects = context.objects; - objects.setObject( - testId, - { - type: 'state', - common: { - type: 'string', - name: 'test2', - read: true, - write: true, - role: 'state', - }, - native: {}, - }, - (err, res) => { - expect(err).to.be.not.ok; - expect(res).to.be.ok; - expect(res!.id).to.be.equal(testId); - - objects.getObject(testId, (err, obj) => { - expect(err).to.be.not.ok; - expect(obj).to.be.ok; - expect(obj!.common.name).to.be.equal('test2'); - expect(obj!._id).to.be.equal(testId); - console.log(JSON.stringify(obj)); - done(); - }); + const res = await objects.setObjectAsync(testId, { + type: 'state', + common: { + type: 'string', + name: 'test2', + read: true, + write: true, + role: 'state', }, - ); + native: {}, + }); + expect(res).to.be.ok; + expect(res!.id).to.be.equal(testId); + + const obj = await objects.getObjectAsync(testId); + expect(obj).to.be.ok; + expect(obj!.common.name).to.be.equal('test2'); + expect(obj!._id).to.be.equal(testId); + console.log(JSON.stringify(obj)); }); it(`${testName}should create object async`, done => { diff --git a/packages/types-dev/objects.d.ts b/packages/types-dev/objects.d.ts index fece1c2c1..5c03ba3a9 100644 --- a/packages/types-dev/objects.d.ts +++ b/packages/types-dev/objects.d.ts @@ -89,6 +89,8 @@ declare global { type Host = `system.host.${string}`; // Guaranteed repository object type Repository = 'system.repositories'; + // Guaranteed repository object + type DockerConfigs = 'system.dockers'; // Guaranteed config objects type Config = 'system.certificates'; // Guaranteed system config objects @@ -147,13 +149,15 @@ declare global { ? RepositoryObject : T extends ObjectIDs.SystemConfig ? SystemConfigObject - : T extends ObjectIDs.Config - ? OtherObject & { type: 'config' } - : T extends ObjectIDs.AdapterScoped - ? AdapterScopedObject - : Read extends 'read' - ? ioBroker.Object - : AnyObject; + : T extends ObjectIDs.DockerConfigs + ? DockerApiObject + : T extends ObjectIDs.Config + ? OtherObject & { type: 'config' } + : T extends ObjectIDs.AdapterScoped + ? AdapterScopedObject + : Read extends 'read' + ? ioBroker.Object + : AnyObject; type Languages = 'en' | 'de' | 'ru' | 'pt' | 'nl' | 'fr' | 'it' | 'es' | 'pl' | 'uk' | 'zh-cn'; type Translated = { en: string } & { [lang in Languages]?: string }; @@ -1104,6 +1108,31 @@ declare global { common: RepositoryCommon; } + interface DockerApiConfig { + socketPath?: string; + host?: string; + port?: number | string; + username?: string; + /** Filename, name in ioBroker certificate or base64 certificate */ + ca?: string; + cert?: string; + key?: string; + protocol?: 'https' | 'http'; + } + + /** Docker API configuration */ + interface DockerApiObject extends BaseObject { + _id: ObjectIDs.DockerConfigs; + type: 'config'; + native: { + dockerApis: { + [configName: string]: DockerApiConfig; + }; + }; + // Make it possible to narrow the object type using the custom property + common: ObjectCommon & { custom?: undefined }; + } + interface InstanceObject extends Omit, BaseObject { _id: ObjectIDs.Instance; type: 'instance';