@iobroker/js-controller-adapter 7.2.3 → 8.0.0-alpha.1-20260921-e5941ca8a

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.
Files changed (101) hide show
  1. package/build/cjs/index.d.ts +0 -1
  2. package/build/cjs/index.js +5 -8
  3. package/build/cjs/index.js.map +2 -2
  4. package/build/cjs/lib/_Types.d.ts +394 -63
  5. package/build/cjs/lib/adapter/adapter.d.ts +1818 -177
  6. package/build/cjs/lib/adapter/adapter.js +715 -1035
  7. package/build/cjs/lib/adapter/adapter.js.map +2 -2
  8. package/build/cjs/lib/adapter/asyncAdapter.d.ts +124 -0
  9. package/build/cjs/lib/adapter/asyncAdapter.js +184 -0
  10. package/build/cjs/lib/adapter/asyncAdapter.js.map +7 -0
  11. package/build/cjs/lib/adapter/context.d.ts +34 -0
  12. package/build/cjs/lib/adapter/context.js +17 -0
  13. package/build/cjs/lib/adapter/context.js.map +7 -0
  14. package/build/cjs/lib/adapter/defaultObjs.d.ts +5 -0
  15. package/build/cjs/lib/adapter/defaultObjs.js +2 -0
  16. package/build/cjs/lib/adapter/defaultObjs.js.map +2 -2
  17. package/build/cjs/lib/adapter/log.d.ts +25 -0
  18. package/build/cjs/lib/adapter/log.js +29 -0
  19. package/build/cjs/lib/adapter/log.js.map +2 -2
  20. package/build/cjs/lib/adapter/managers/AdapterContextBase.d.ts +49 -0
  21. package/build/cjs/lib/adapter/managers/AdapterContextBase.js +98 -0
  22. package/build/cjs/lib/adapter/managers/AdapterContextBase.js.map +7 -0
  23. package/build/cjs/lib/adapter/managers/AliasManager.d.ts +103 -0
  24. package/build/cjs/lib/adapter/managers/AliasManager.js +293 -0
  25. package/build/cjs/lib/adapter/managers/AliasManager.js.map +7 -0
  26. package/build/cjs/lib/adapter/managers/CertificateManager.d.ts +50 -0
  27. package/build/cjs/lib/adapter/managers/CertificateManager.js +174 -0
  28. package/build/cjs/lib/adapter/managers/CertificateManager.js.map +7 -0
  29. package/build/cjs/lib/adapter/managers/MessagingManager.d.ts +58 -0
  30. package/build/cjs/lib/adapter/managers/MessagingManager.js +289 -0
  31. package/build/cjs/lib/adapter/managers/MessagingManager.js.map +7 -0
  32. package/build/cjs/lib/adapter/managers/SubscriptionManager.d.ts +107 -0
  33. package/build/cjs/lib/adapter/managers/SubscriptionManager.js +349 -0
  34. package/build/cjs/lib/adapter/managers/SubscriptionManager.js.map +7 -0
  35. package/build/cjs/lib/adapter/userInterfaceMessagingController.d.ts +10 -0
  36. package/build/cjs/lib/adapter/userInterfaceMessagingController.js +9 -2
  37. package/build/cjs/lib/adapter/userInterfaceMessagingController.js.map +2 -2
  38. package/build/cjs/lib/adapter/utils.js +15 -1
  39. package/build/cjs/lib/adapter/utils.js.map +2 -2
  40. package/build/cjs/lib/adapter/validator.d.ts +10 -5
  41. package/build/cjs/lib/adapter/validator.js +6 -5
  42. package/build/cjs/lib/adapter/validator.js.map +2 -2
  43. package/build/esm/index.d.ts +0 -1
  44. package/build/esm/index.d.ts.map +1 -1
  45. package/build/esm/index.js +0 -1
  46. package/build/esm/index.js.map +1 -1
  47. package/build/esm/lib/_Types.d.ts +394 -63
  48. package/build/esm/lib/_Types.d.ts.map +1 -1
  49. package/build/esm/lib/adapter/adapter.d.ts +1818 -177
  50. package/build/esm/lib/adapter/adapter.d.ts.map +1 -1
  51. package/build/esm/lib/adapter/adapter.js +827 -1215
  52. package/build/esm/lib/adapter/adapter.js.map +1 -1
  53. package/build/esm/lib/adapter/asyncAdapter.d.ts +124 -0
  54. package/build/esm/lib/adapter/asyncAdapter.d.ts.map +1 -0
  55. package/build/esm/lib/adapter/asyncAdapter.js +157 -0
  56. package/build/esm/lib/adapter/asyncAdapter.js.map +1 -0
  57. package/build/esm/lib/adapter/context.d.ts +34 -0
  58. package/build/esm/lib/adapter/context.d.ts.map +1 -0
  59. package/build/esm/lib/adapter/context.js +2 -0
  60. package/build/esm/lib/adapter/context.js.map +1 -0
  61. package/build/esm/lib/adapter/defaultObjs.d.ts +5 -0
  62. package/build/esm/lib/adapter/defaultObjs.d.ts.map +1 -1
  63. package/build/esm/lib/adapter/defaultObjs.js +5 -0
  64. package/build/esm/lib/adapter/defaultObjs.js.map +1 -1
  65. package/build/esm/lib/adapter/log.d.ts +25 -0
  66. package/build/esm/lib/adapter/log.d.ts.map +1 -1
  67. package/build/esm/lib/adapter/log.js +25 -0
  68. package/build/esm/lib/adapter/log.js.map +1 -1
  69. package/build/esm/lib/adapter/managers/AdapterContextBase.d.ts +49 -0
  70. package/build/esm/lib/adapter/managers/AdapterContextBase.d.ts.map +1 -0
  71. package/build/esm/lib/adapter/managers/AdapterContextBase.js +77 -0
  72. package/build/esm/lib/adapter/managers/AdapterContextBase.js.map +1 -0
  73. package/build/esm/lib/adapter/managers/AliasManager.d.ts +103 -0
  74. package/build/esm/lib/adapter/managers/AliasManager.d.ts.map +1 -0
  75. package/build/esm/lib/adapter/managers/AliasManager.js +269 -0
  76. package/build/esm/lib/adapter/managers/AliasManager.js.map +1 -0
  77. package/build/esm/lib/adapter/managers/CertificateManager.d.ts +50 -0
  78. package/build/esm/lib/adapter/managers/CertificateManager.d.ts.map +1 -0
  79. package/build/esm/lib/adapter/managers/CertificateManager.js +142 -0
  80. package/build/esm/lib/adapter/managers/CertificateManager.js.map +1 -0
  81. package/build/esm/lib/adapter/managers/MessagingManager.d.ts +58 -0
  82. package/build/esm/lib/adapter/managers/MessagingManager.d.ts.map +1 -0
  83. package/build/esm/lib/adapter/managers/MessagingManager.js +267 -0
  84. package/build/esm/lib/adapter/managers/MessagingManager.js.map +1 -0
  85. package/build/esm/lib/adapter/managers/SubscriptionManager.d.ts +107 -0
  86. package/build/esm/lib/adapter/managers/SubscriptionManager.d.ts.map +1 -0
  87. package/build/esm/lib/adapter/managers/SubscriptionManager.js +374 -0
  88. package/build/esm/lib/adapter/managers/SubscriptionManager.js.map +1 -0
  89. package/build/esm/lib/adapter/userInterfaceMessagingController.d.ts +10 -0
  90. package/build/esm/lib/adapter/userInterfaceMessagingController.d.ts.map +1 -1
  91. package/build/esm/lib/adapter/userInterfaceMessagingController.js +8 -2
  92. package/build/esm/lib/adapter/userInterfaceMessagingController.js.map +1 -1
  93. package/build/esm/lib/adapter/utils.d.ts.map +1 -1
  94. package/build/esm/lib/adapter/utils.js +1 -1
  95. package/build/esm/lib/adapter/utils.js.map +1 -1
  96. package/build/esm/lib/adapter/validator.d.ts +10 -5
  97. package/build/esm/lib/adapter/validator.d.ts.map +1 -1
  98. package/build/esm/lib/adapter/validator.js +8 -5
  99. package/build/esm/lib/adapter/validator.js.map +1 -1
  100. package/build/tsconfig.build.tsbuildinfo +1 -1
  101. package/package.json +25 -20
@@ -0,0 +1,124 @@
1
+ import type { AllPropsUnknown, InternalGetCertificatesResult, NotificationOptions, SendToOptions, SendToUserInterfaceClientOptions } from '../../lib/_Types.js';
2
+ import type { AdapterContext } from '../../lib/adapter/context.js';
3
+ /**
4
+ * Clean async-only facade for the adapter's outbound messaging. Owns the {@link MessagingManager}
5
+ * and exposes promise-based methods without the legacy `*Async` postfix.
6
+ */
7
+ export declare class AsyncAdapter {
8
+ #private;
9
+ /**
10
+ * @param ctx Shared adapter context providing live runtime state
11
+ */
12
+ constructor(ctx: AdapterContext);
13
+ /**
14
+ * Sends a message to another adapter instance and, unless `options.expectReply` is `false`,
15
+ * resolves with the reply when it arrives (or rejects with `Error('Timeout exceeded')` on timeout).
16
+ *
17
+ * Broadcast targets (instance name without a trailing `.<number>`) resolve void regardless.
18
+ *
19
+ * @param instanceName name of the instance to send the message to
20
+ * @param command command name
21
+ * @param message message payload
22
+ * @param options send options; set `expectReply: false` for fire-and-forget, or pass a legacy
23
+ * `callback` info header (mutually exclusive with `expectReply`)
24
+ */
25
+ sendTo(instanceName: string, command: string, message: any, options?: SendToOptions & {
26
+ expectReply?: boolean;
27
+ callback?: ioBroker.MessageCallbackInfo;
28
+ }): Promise<any>;
29
+ /**
30
+ * @internal
31
+ * @param instanceName name of the instance to send the message to
32
+ * @param command command name
33
+ * @param message message payload
34
+ * @param options send options
35
+ */
36
+ sendTo(instanceName: unknown, command: unknown, message?: unknown, options?: unknown): Promise<any>;
37
+ /**
38
+ * Sends a message to a host, or broadcasts to all hosts when `hostName` is `null`.
39
+ * For a specific host, resolves with the reply unless `options.expectReply` is `false`.
40
+ * Broadcasts resolve void.
41
+ *
42
+ * @param hostName name of the host, or `null` to broadcast to all hosts
43
+ * @param command command name
44
+ * @param message message payload
45
+ * @param options send options; set `expectReply: false` for fire-and-forget
46
+ */
47
+ sendToHost(hostName: string | null, command: string, message: any, options?: SendToOptions & {
48
+ expectReply?: boolean;
49
+ callback?: ioBroker.MessageCallbackInfo;
50
+ }): Promise<any>;
51
+ /**
52
+ * @internal
53
+ * @param hostName name of the host, or `null` to broadcast to all hosts
54
+ * @param command command name
55
+ * @param message message payload
56
+ * @param options send options
57
+ */
58
+ sendToHost(hostName: unknown, command: unknown, message?: unknown, options?: unknown): Promise<any>;
59
+ /**
60
+ * Sends a message to a single UI client, or broadcasts to all connected UI clients when `clientId` is omitted.
61
+ *
62
+ * @param options clientId and data options
63
+ */
64
+ sendToUI(options: AllPropsUnknown<SendToUserInterfaceClientOptions>): Promise<void>;
65
+ /**
66
+ * Sends an addNotification command to the host of this adapter instance.
67
+ *
68
+ * @param scope notification scope
69
+ * @param category notification category, or `null` to match by scope regex
70
+ * @param message notification message
71
+ * @param options additional notification options
72
+ */
73
+ registerNotification<Scope extends keyof ioBroker.NotificationScopes>(scope: Scope, category: ioBroker.NotificationScopes[Scope] | null, message: string, options?: NotificationOptions): Promise<void>;
74
+ /**
75
+ * @internal
76
+ * @param scope notification scope
77
+ * @param category notification category
78
+ * @param message notification message
79
+ * @param options additional notification options
80
+ */
81
+ registerNotification(scope: unknown, category: unknown, message: unknown, options?: unknown): Promise<void>;
82
+ /**
83
+ * Loads SSL certificates by name, falling back to the instance config defaults. File-backed
84
+ * certificate values are resolved to their content and their paths returned for watching.
85
+ *
86
+ * @param publicName public certificate name (defaults to `config.certPublic`)
87
+ * @param privateName private key name (defaults to `config.certPrivate`)
88
+ * @param chainedName chained certificate name (defaults to `config.certChained`)
89
+ */
90
+ getCertificates(publicName?: string, privateName?: string, chainedName?: string): Promise<InternalGetCertificatesResult>;
91
+ /**
92
+ * @internal
93
+ * @param publicName public certificate name
94
+ * @param privateName private key name
95
+ * @param chainedName chained certificate name
96
+ */
97
+ getCertificates(publicName?: unknown, privateName?: unknown, chainedName?: unknown): Promise<InternalGetCertificatesResult>;
98
+ /**
99
+ * Tells whether a new version of the `system.certificates` object changes one of the certificates
100
+ * handed out by the last {@link getCertificates} call. Returns false if certificates were never
101
+ * requested, so unrelated certificate edits do not concern this adapter.
102
+ *
103
+ * @param obj the new `system.certificates` object, or null/undefined if it was deleted
104
+ */
105
+ hasRelevantCertificateChange(obj: ioBroker.OtherObject | null | undefined): boolean;
106
+ /**
107
+ * Forgets the certificates handed out by the last {@link getCertificates} call, so
108
+ * {@link hasRelevantCertificateChange} no longer reports changes to them. Used when the adapter
109
+ * stops watching its certificates.
110
+ */
111
+ stopWatchingCertificates(): void;
112
+ /**
113
+ * Resolves a pending reply promise for an acked messagebox message.
114
+ * Returns true if a pending entry was found and consumed.
115
+ *
116
+ * @param obj incoming message object from the messagebox
117
+ */
118
+ resolveReply(obj: ioBroker.Message): boolean;
119
+ /**
120
+ * Rejects all pending reply promises and clears their timers (used on stop).
121
+ */
122
+ clearPending(): void;
123
+ }
124
+ //# sourceMappingURL=asyncAdapter.d.ts.map
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var asyncAdapter_exports = {};
21
+ __export(asyncAdapter_exports, {
22
+ AsyncAdapter: () => AsyncAdapter
23
+ });
24
+ module.exports = __toCommonJS(asyncAdapter_exports);
25
+ var import_CertificateManager = require("../../lib/adapter/managers/CertificateManager.js");
26
+ var import_MessagingManager = require("../../lib/adapter/managers/MessagingManager.js");
27
+ var import_validator = require("../../lib/adapter/validator.js");
28
+ class AsyncAdapter {
29
+ static {
30
+ __name(this, "AsyncAdapter");
31
+ }
32
+ #ctx;
33
+ #messagingInstance;
34
+ #certificatesInstance;
35
+ /**
36
+ * @param ctx Shared adapter context providing live runtime state
37
+ */
38
+ constructor(ctx) {
39
+ this.#ctx = ctx;
40
+ }
41
+ /** Lazily-constructed outbound messaging manager. */
42
+ get #messaging() {
43
+ return this.#messagingInstance ??= new import_MessagingManager.MessagingManager(this.#ctx);
44
+ }
45
+ /** Lazily-constructed certificate manager. */
46
+ get #certificates() {
47
+ return this.#certificatesInstance ??= new import_CertificateManager.CertificateManager(this.#ctx);
48
+ }
49
+ /**
50
+ * @param instanceName name of the instance to send the message to
51
+ * @param command command name
52
+ * @param message message payload
53
+ * @param options send options
54
+ */
55
+ async sendTo(instanceName, command, message, options) {
56
+ import_validator.Validator.assertString(instanceName, "instanceName");
57
+ import_validator.Validator.assertString(command, "command");
58
+ if (options !== void 0) {
59
+ import_validator.Validator.assertObject(options, "options");
60
+ }
61
+ const { expectReply, callback, ...sendOptions } = options ?? {};
62
+ return this.#messaging.sendTo({
63
+ instanceName,
64
+ command,
65
+ message,
66
+ callback,
67
+ options: Object.keys(sendOptions).length ? sendOptions : void 0,
68
+ expectReply: callback ? false : expectReply ?? true
69
+ });
70
+ }
71
+ /**
72
+ * @param hostName name of the host, or `null` to broadcast to all hosts
73
+ * @param command command name
74
+ * @param message message payload
75
+ * @param options send options
76
+ */
77
+ async sendToHost(hostName, command, message, options) {
78
+ if (hostName !== null) {
79
+ import_validator.Validator.assertString(hostName, "hostName");
80
+ }
81
+ import_validator.Validator.assertString(command, "command");
82
+ if (options !== void 0) {
83
+ import_validator.Validator.assertObject(options, "options");
84
+ }
85
+ const { expectReply, callback, ...sendOptions } = options ?? {};
86
+ return this.#messaging.sendToHost({
87
+ hostName,
88
+ command,
89
+ message,
90
+ callback,
91
+ options: Object.keys(sendOptions).length ? sendOptions : void 0,
92
+ // broadcast (null host) yields many responses → never wait for a reply
93
+ expectReply: hostName !== null && !callback && (expectReply ?? true)
94
+ });
95
+ }
96
+ /**
97
+ * Sends a message to a single UI client, or broadcasts to all connected UI clients when `clientId` is omitted.
98
+ *
99
+ * @param options clientId and data options
100
+ */
101
+ sendToUI(options) {
102
+ const { clientId, data } = options;
103
+ if (clientId !== void 0) {
104
+ import_validator.Validator.assertString(clientId, "clientId");
105
+ }
106
+ return this.#messaging.sendToUI({ clientId, data });
107
+ }
108
+ /**
109
+ * @param scope notification scope
110
+ * @param category notification category
111
+ * @param message notification message
112
+ * @param options additional notification options
113
+ */
114
+ async registerNotification(scope, category, message, options) {
115
+ import_validator.Validator.assertString(scope, "scope");
116
+ if (category !== null) {
117
+ import_validator.Validator.assertString(category, "category");
118
+ }
119
+ import_validator.Validator.assertString(message, "message");
120
+ if (options !== void 0) {
121
+ import_validator.Validator.assertObject(options, "options");
122
+ }
123
+ return this.#messaging.registerNotification(scope, category, message, options);
124
+ }
125
+ /**
126
+ * @param publicName public certificate name
127
+ * @param privateName private key name
128
+ * @param chainedName chained certificate name
129
+ */
130
+ async getCertificates(publicName, privateName, chainedName) {
131
+ const config = this.#ctx.config;
132
+ publicName = publicName || config.certPublic;
133
+ privateName = privateName || config.certPrivate;
134
+ chainedName = chainedName || config.certChained;
135
+ if (publicName !== void 0) {
136
+ import_validator.Validator.assertString(publicName, "publicName");
137
+ }
138
+ if (privateName !== void 0) {
139
+ import_validator.Validator.assertString(privateName, "privateName");
140
+ }
141
+ if (chainedName !== void 0) {
142
+ import_validator.Validator.assertString(chainedName, "chainedName");
143
+ }
144
+ return this.#certificates.getCertificates({ publicName, privateName, chainedName });
145
+ }
146
+ /**
147
+ * Tells whether a new version of the `system.certificates` object changes one of the certificates
148
+ * handed out by the last {@link getCertificates} call. Returns false if certificates were never
149
+ * requested, so unrelated certificate edits do not concern this adapter.
150
+ *
151
+ * @param obj the new `system.certificates` object, or null/undefined if it was deleted
152
+ */
153
+ hasRelevantCertificateChange(obj) {
154
+ return this.#certificatesInstance?.hasRelevantChange(obj) ?? false;
155
+ }
156
+ /**
157
+ * Forgets the certificates handed out by the last {@link getCertificates} call, so
158
+ * {@link hasRelevantCertificateChange} no longer reports changes to them. Used when the adapter
159
+ * stops watching its certificates.
160
+ */
161
+ stopWatchingCertificates() {
162
+ this.#certificatesInstance?.stopWatching();
163
+ }
164
+ /**
165
+ * Resolves a pending reply promise for an acked messagebox message.
166
+ * Returns true if a pending entry was found and consumed.
167
+ *
168
+ * @param obj incoming message object from the messagebox
169
+ */
170
+ resolveReply(obj) {
171
+ return this.#messagingInstance?.resolveCallback(obj) ?? false;
172
+ }
173
+ /**
174
+ * Rejects all pending reply promises and clears their timers (used on stop).
175
+ */
176
+ clearPending() {
177
+ this.#messagingInstance?.clearPendingCallbacks();
178
+ }
179
+ }
180
+ // Annotate the CommonJS export names for ESM import in node:
181
+ 0 && (module.exports = {
182
+ AsyncAdapter
183
+ });
184
+ //# sourceMappingURL=asyncAdapter.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/lib/adapter/asyncAdapter.ts"],
4
+ "sourcesContent": ["import type {\n AllPropsUnknown,\n InternalAdapterConfig,\n InternalGetCertificatesResult,\n NotificationOptions,\n SendToOptions,\n SendToUserInterfaceClientOptions,\n} from '@/lib/_Types.js';\nimport type { AdapterContext } from '@/lib/adapter/context.js';\nimport { CertificateManager } from '@/lib/adapter/managers/CertificateManager.js';\nimport { MessagingManager } from '@/lib/adapter/managers/MessagingManager.js';\nimport { Validator } from '@/lib/adapter/validator.js';\n\n/**\n * Clean async-only facade for the adapter's outbound messaging. Owns the {@link MessagingManager}\n * and exposes promise-based methods without the legacy `*Async` postfix.\n */\nexport class AsyncAdapter {\n readonly #ctx: AdapterContext;\n #messagingInstance?: MessagingManager;\n #certificatesInstance?: CertificateManager;\n\n /**\n * @param ctx Shared adapter context providing live runtime state\n */\n constructor(ctx: AdapterContext) {\n this.#ctx = ctx;\n }\n\n /** Lazily-constructed outbound messaging manager. */\n get #messaging(): MessagingManager {\n return (this.#messagingInstance ??= new MessagingManager(this.#ctx));\n }\n\n /** Lazily-constructed certificate manager. */\n get #certificates(): CertificateManager {\n return (this.#certificatesInstance ??= new CertificateManager(this.#ctx));\n }\n\n /**\n * Sends a message to another adapter instance and, unless `options.expectReply` is `false`,\n * resolves with the reply when it arrives (or rejects with `Error('Timeout exceeded')` on timeout).\n *\n * Broadcast targets (instance name without a trailing `.<number>`) resolve void regardless.\n *\n * @param instanceName name of the instance to send the message to\n * @param command command name\n * @param message message payload\n * @param options send options; set `expectReply: false` for fire-and-forget, or pass a legacy\n * `callback` info header (mutually exclusive with `expectReply`)\n */\n sendTo(\n instanceName: string,\n command: string,\n message: any,\n options?: SendToOptions & { expectReply?: boolean; callback?: ioBroker.MessageCallbackInfo },\n ): Promise<any>;\n /**\n * @internal\n * @param instanceName name of the instance to send the message to\n * @param command command name\n * @param message message payload\n * @param options send options\n */\n sendTo(instanceName: unknown, command: unknown, message?: unknown, options?: unknown): Promise<any>;\n /**\n * @param instanceName name of the instance to send the message to\n * @param command command name\n * @param message message payload\n * @param options send options\n */\n async sendTo(instanceName: unknown, command: unknown, message?: unknown, options?: unknown): Promise<any> {\n Validator.assertString(instanceName, 'instanceName');\n Validator.assertString(command, 'command');\n if (options !== undefined) {\n Validator.assertObject<SendToOptions & { expectReply?: boolean; callback?: ioBroker.MessageCallbackInfo }>(\n options,\n 'options',\n );\n }\n\n const { expectReply, callback, ...sendOptions } = options ?? {};\n return this.#messaging.sendTo({\n instanceName,\n command,\n message,\n callback,\n options: Object.keys(sendOptions).length ? sendOptions : undefined,\n expectReply: callback ? false : (expectReply ?? true),\n });\n }\n\n /**\n * Sends a message to a host, or broadcasts to all hosts when `hostName` is `null`.\n * For a specific host, resolves with the reply unless `options.expectReply` is `false`.\n * Broadcasts resolve void.\n *\n * @param hostName name of the host, or `null` to broadcast to all hosts\n * @param command command name\n * @param message message payload\n * @param options send options; set `expectReply: false` for fire-and-forget\n */\n sendToHost(\n hostName: string | null,\n command: string,\n message: any,\n options?: SendToOptions & { expectReply?: boolean; callback?: ioBroker.MessageCallbackInfo },\n ): Promise<any>;\n /**\n * @internal\n * @param hostName name of the host, or `null` to broadcast to all hosts\n * @param command command name\n * @param message message payload\n * @param options send options\n */\n sendToHost(hostName: unknown, command: unknown, message?: unknown, options?: unknown): Promise<any>;\n /**\n * @param hostName name of the host, or `null` to broadcast to all hosts\n * @param command command name\n * @param message message payload\n * @param options send options\n */\n async sendToHost(hostName: unknown, command: unknown, message?: unknown, options?: unknown): Promise<any> {\n if (hostName !== null) {\n Validator.assertString(hostName, 'hostName');\n }\n Validator.assertString(command, 'command');\n if (options !== undefined) {\n Validator.assertObject<SendToOptions & { expectReply?: boolean; callback?: ioBroker.MessageCallbackInfo }>(\n options,\n 'options',\n );\n }\n\n const { expectReply, callback, ...sendOptions } = options ?? {};\n return this.#messaging.sendToHost({\n hostName,\n command,\n message,\n callback,\n options: Object.keys(sendOptions).length ? sendOptions : undefined,\n // broadcast (null host) yields many responses \u2192 never wait for a reply\n expectReply: hostName !== null && !callback && (expectReply ?? true),\n });\n }\n\n /**\n * Sends a message to a single UI client, or broadcasts to all connected UI clients when `clientId` is omitted.\n *\n * @param options clientId and data options\n */\n sendToUI(options: AllPropsUnknown<SendToUserInterfaceClientOptions>): Promise<void> {\n const { clientId, data } = options;\n if (clientId !== undefined) {\n Validator.assertString(clientId, 'clientId');\n }\n return this.#messaging.sendToUI({ clientId, data });\n }\n\n /**\n * Sends an addNotification command to the host of this adapter instance.\n *\n * @param scope notification scope\n * @param category notification category, or `null` to match by scope regex\n * @param message notification message\n * @param options additional notification options\n */\n registerNotification<Scope extends keyof ioBroker.NotificationScopes>(\n scope: Scope,\n category: ioBroker.NotificationScopes[Scope] | null,\n message: string,\n options?: NotificationOptions,\n ): Promise<void>;\n /**\n * @internal\n * @param scope notification scope\n * @param category notification category\n * @param message notification message\n * @param options additional notification options\n */\n registerNotification(scope: unknown, category: unknown, message: unknown, options?: unknown): Promise<void>;\n /**\n * @param scope notification scope\n * @param category notification category\n * @param message notification message\n * @param options additional notification options\n */\n async registerNotification(scope: unknown, category: unknown, message: unknown, options?: unknown): Promise<void> {\n Validator.assertString(scope, 'scope');\n if (category !== null) {\n Validator.assertString(category, 'category');\n }\n Validator.assertString(message, 'message');\n if (options !== undefined) {\n Validator.assertObject<NotificationOptions>(options, 'options');\n }\n return this.#messaging.registerNotification(scope, category, message, options);\n }\n\n /**\n * Loads SSL certificates by name, falling back to the instance config defaults. File-backed\n * certificate values are resolved to their content and their paths returned for watching.\n *\n * @param publicName public certificate name (defaults to `config.certPublic`)\n * @param privateName private key name (defaults to `config.certPrivate`)\n * @param chainedName chained certificate name (defaults to `config.certChained`)\n */\n getCertificates(\n publicName?: string,\n privateName?: string,\n chainedName?: string,\n ): Promise<InternalGetCertificatesResult>;\n /**\n * @internal\n * @param publicName public certificate name\n * @param privateName private key name\n * @param chainedName chained certificate name\n */\n getCertificates(\n publicName?: unknown,\n privateName?: unknown,\n chainedName?: unknown,\n ): Promise<InternalGetCertificatesResult>;\n /**\n * @param publicName public certificate name\n * @param privateName private key name\n * @param chainedName chained certificate name\n */\n async getCertificates(\n publicName?: unknown,\n privateName?: unknown,\n chainedName?: unknown,\n ): Promise<InternalGetCertificatesResult> {\n const config = this.#ctx.config as InternalAdapterConfig;\n publicName = publicName || config.certPublic;\n privateName = privateName || config.certPrivate;\n chainedName = chainedName || config.certChained;\n\n if (publicName !== undefined) {\n Validator.assertString(publicName, 'publicName');\n }\n if (privateName !== undefined) {\n Validator.assertString(privateName, 'privateName');\n }\n if (chainedName !== undefined) {\n Validator.assertString(chainedName, 'chainedName');\n }\n\n return this.#certificates.getCertificates({ publicName, privateName, chainedName });\n }\n\n /**\n * Tells whether a new version of the `system.certificates` object changes one of the certificates\n * handed out by the last {@link getCertificates} call. Returns false if certificates were never\n * requested, so unrelated certificate edits do not concern this adapter.\n *\n * @param obj the new `system.certificates` object, or null/undefined if it was deleted\n */\n hasRelevantCertificateChange(obj: ioBroker.OtherObject | null | undefined): boolean {\n return this.#certificatesInstance?.hasRelevantChange(obj) ?? false;\n }\n\n /**\n * Forgets the certificates handed out by the last {@link getCertificates} call, so\n * {@link hasRelevantCertificateChange} no longer reports changes to them. Used when the adapter\n * stops watching its certificates.\n */\n stopWatchingCertificates(): void {\n this.#certificatesInstance?.stopWatching();\n }\n\n /**\n * Resolves a pending reply promise for an acked messagebox message.\n * Returns true if a pending entry was found and consumed.\n *\n * @param obj incoming message object from the messagebox\n */\n resolveReply(obj: ioBroker.Message): boolean {\n return this.#messagingInstance?.resolveCallback(obj) ?? false;\n }\n\n /**\n * Rejects all pending reply promises and clears their timers (used on stop).\n */\n clearPending(): void {\n this.#messagingInstance?.clearPendingCallbacks();\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AASA;;;;;AAAA,gCAAmC;AACnC,8BAAiC;AACjC,uBAA0B;AAMpB,MAAO,aAAY;EARzB,OAQyB;;;EACZ;EACT;EACA;;;;EAKA,YAAY,KAAmB;AAC3B,SAAK,OAAO;EAChB;;EAGA,IAAI,aAAU;AACV,WAAQ,KAAK,uBAAuB,IAAI,yCAAiB,KAAK,IAAI;EACtE;;EAGA,IAAI,gBAAa;AACb,WAAQ,KAAK,0BAA0B,IAAI,6CAAmB,KAAK,IAAI;EAC3E;;;;;;;EAkCA,MAAM,OAAO,cAAuB,SAAkB,SAAmB,SAAiB;AACtF,+BAAU,aAAa,cAAc,cAAc;AACnD,+BAAU,aAAa,SAAS,SAAS;AACzC,QAAI,YAAY,QAAW;AACvB,iCAAU,aACN,SACA,SAAS;IAEjB;AAEA,UAAM,EAAE,aAAa,UAAU,GAAG,YAAW,IAAK,WAAW,CAAA;AAC7D,WAAO,KAAK,WAAW,OAAO;MAC1B;MACA;MACA;MACA;MACA,SAAS,OAAO,KAAK,WAAW,EAAE,SAAS,cAAc;MACzD,aAAa,WAAW,QAAS,eAAe;KACnD;EACL;;;;;;;EAgCA,MAAM,WAAW,UAAmB,SAAkB,SAAmB,SAAiB;AACtF,QAAI,aAAa,MAAM;AACnB,iCAAU,aAAa,UAAU,UAAU;IAC/C;AACA,+BAAU,aAAa,SAAS,SAAS;AACzC,QAAI,YAAY,QAAW;AACvB,iCAAU,aACN,SACA,SAAS;IAEjB;AAEA,UAAM,EAAE,aAAa,UAAU,GAAG,YAAW,IAAK,WAAW,CAAA;AAC7D,WAAO,KAAK,WAAW,WAAW;MAC9B;MACA;MACA;MACA;MACA,SAAS,OAAO,KAAK,WAAW,EAAE,SAAS,cAAc;;MAEzD,aAAa,aAAa,QAAQ,CAAC,aAAa,eAAe;KAClE;EACL;;;;;;EAOA,SAAS,SAA0D;AAC/D,UAAM,EAAE,UAAU,KAAI,IAAK;AAC3B,QAAI,aAAa,QAAW;AACxB,iCAAU,aAAa,UAAU,UAAU;IAC/C;AACA,WAAO,KAAK,WAAW,SAAS,EAAE,UAAU,KAAI,CAAE;EACtD;;;;;;;EA8BA,MAAM,qBAAqB,OAAgB,UAAmB,SAAkB,SAAiB;AAC7F,+BAAU,aAAa,OAAO,OAAO;AACrC,QAAI,aAAa,MAAM;AACnB,iCAAU,aAAa,UAAU,UAAU;IAC/C;AACA,+BAAU,aAAa,SAAS,SAAS;AACzC,QAAI,YAAY,QAAW;AACvB,iCAAU,aAAkC,SAAS,SAAS;IAClE;AACA,WAAO,KAAK,WAAW,qBAAqB,OAAO,UAAU,SAAS,OAAO;EACjF;;;;;;EA+BA,MAAM,gBACF,YACA,aACA,aAAqB;AAErB,UAAM,SAAS,KAAK,KAAK;AACzB,iBAAa,cAAc,OAAO;AAClC,kBAAc,eAAe,OAAO;AACpC,kBAAc,eAAe,OAAO;AAEpC,QAAI,eAAe,QAAW;AAC1B,iCAAU,aAAa,YAAY,YAAY;IACnD;AACA,QAAI,gBAAgB,QAAW;AAC3B,iCAAU,aAAa,aAAa,aAAa;IACrD;AACA,QAAI,gBAAgB,QAAW;AAC3B,iCAAU,aAAa,aAAa,aAAa;IACrD;AAEA,WAAO,KAAK,cAAc,gBAAgB,EAAE,YAAY,aAAa,YAAW,CAAE;EACtF;;;;;;;;EASA,6BAA6B,KAA4C;AACrE,WAAO,KAAK,uBAAuB,kBAAkB,GAAG,KAAK;EACjE;;;;;;EAOA,2BAAwB;AACpB,SAAK,uBAAuB,aAAY;EAC5C;;;;;;;EAQA,aAAa,KAAqB;AAC9B,WAAO,KAAK,oBAAoB,gBAAgB,GAAG,KAAK;EAC5D;;;;EAKA,eAAY;AACR,SAAK,oBAAoB,sBAAqB;EAClD;;",
6
+ "names": []
7
+ }
@@ -0,0 +1,34 @@
1
+ import type Winston from 'winston';
2
+ import type { Client as StatesInRedisClient } from '@iobroker/db-states-redis';
3
+ import type { Client as ObjectsInRedisClient } from '@iobroker/db-objects-redis';
4
+ import type { UserInterfaceMessagingController } from '../../lib/adapter/userInterfaceMessagingController.js';
5
+ /**
6
+ * Live view of the adapter's shared runtime state, passed to managers at construction time.
7
+ *
8
+ * The mutable fields are exposed as getter properties so late-bound values (DB clients,
9
+ * namespace, host) stay live: the adapter builds one context whose getters read its own
10
+ * fields, and every manager reads the same object.
11
+ */
12
+ export interface AdapterContext {
13
+ /** Current states DB client */
14
+ readonly states: StatesInRedisClient | null | undefined;
15
+ /** Current objects DB client */
16
+ readonly objects: ObjectsInRedisClient | null | undefined;
17
+ /** Current adapter common config */
18
+ readonly common: ioBroker.InstanceCommon | undefined;
19
+ /** Current adapter instance config (native) */
20
+ readonly config: ioBroker.AdapterConfig;
21
+ /** Current host name (may be undefined before init) */
22
+ readonly host: string | undefined;
23
+ /** Current adapter namespace, e.g. `"adapter.0"` */
24
+ readonly namespace: `${string}.${number}`;
25
+ /** Current namespace string used in log messages */
26
+ readonly namespaceLog: string;
27
+ /** Logger instance */
28
+ readonly logger: Winston.Logger;
29
+ /** Controller for UI messaging */
30
+ readonly uiMessagingController: UserInterfaceMessagingController;
31
+ /** Increment the adapter's outbound-write counter. */
32
+ readonly countOutput: () => void;
33
+ }
34
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var context_exports = {};
16
+ module.exports = __toCommonJS(context_exports);
17
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../esm/lib/adapter/context.js"],
4
+ "sourcesContent": ["export {};\n//# sourceMappingURL=context.js.map"],
5
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -1,2 +1,7 @@
1
+ /**
2
+ * Create the default `common` definitions for the well-known state roles (e.g. level.dimmer, indicator.working)
3
+ *
4
+ * @returns a map of state role to its default common properties
5
+ */
1
6
  export declare function createDefaults(): Record<string, Partial<ioBroker.StateCommon>>;
2
7
  //# sourceMappingURL=defaultObjs.d.ts.map
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -64,6 +65,7 @@ function createDefaults() {
64
65
  }
65
66
  };
66
67
  }
68
+ __name(createDefaults, "createDefaults");
67
69
  // Annotate the CommonJS export names for ESM import in node:
68
70
  0 && (module.exports = {
69
71
  createDefaults
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/adapter/defaultObjs.ts"],
4
- "sourcesContent": ["export function createDefaults(): Record<string, Partial<ioBroker.StateCommon>> {\n return {\n 'level.dimmer': {\n type: 'number',\n read: true,\n write: true,\n min: 0,\n max: 100,\n unit: '%',\n },\n 'indicator.working': {\n def: false,\n type: 'boolean',\n read: true,\n write: false,\n },\n 'indicator.maintenance': {\n def: false,\n type: 'boolean',\n read: true,\n write: false,\n },\n 'indicator.maintenance.lowbat': {\n def: false,\n type: 'boolean',\n read: true,\n write: false,\n desc: 'Low battery',\n },\n 'indicator.maintenance.unreach': {\n def: false,\n type: 'boolean',\n read: true,\n write: false,\n desc: 'Device unreachable',\n },\n switch: {\n type: 'boolean',\n read: true,\n write: true,\n },\n } as const;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;;;;;AAAM,SAAU,iBAAc;AAC1B,SAAO;IACH,gBAAgB;MACZ,MAAM;MACN,MAAM;MACN,OAAO;MACP,KAAK;MACL,KAAK;MACL,MAAM;;IAEV,qBAAqB;MACjB,KAAK;MACL,MAAM;MACN,MAAM;MACN,OAAO;;IAEX,yBAAyB;MACrB,KAAK;MACL,MAAM;MACN,MAAM;MACN,OAAO;;IAEX,gCAAgC;MAC5B,KAAK;MACL,MAAM;MACN,MAAM;MACN,OAAO;MACP,MAAM;;IAEV,iCAAiC;MAC7B,KAAK;MACL,MAAM;MACN,MAAM;MACN,OAAO;MACP,MAAM;;IAEV,QAAQ;MACJ,MAAM;MACN,MAAM;MACN,OAAO;;;AAGnB;",
4
+ "sourcesContent": ["/**\n * Create the default `common` definitions for the well-known state roles (e.g. level.dimmer, indicator.working)\n *\n * @returns a map of state role to its default common properties\n */\nexport function createDefaults(): Record<string, Partial<ioBroker.StateCommon>> {\n return {\n 'level.dimmer': {\n type: 'number',\n read: true,\n write: true,\n min: 0,\n max: 100,\n unit: '%',\n },\n 'indicator.working': {\n def: false,\n type: 'boolean',\n read: true,\n write: false,\n },\n 'indicator.maintenance': {\n def: false,\n type: 'boolean',\n read: true,\n write: false,\n },\n 'indicator.maintenance.lowbat': {\n def: false,\n type: 'boolean',\n read: true,\n write: false,\n desc: 'Low battery',\n },\n 'indicator.maintenance.unreach': {\n def: false,\n type: 'boolean',\n read: true,\n write: false,\n desc: 'Device unreachable',\n },\n switch: {\n type: 'boolean',\n read: true,\n write: true,\n },\n } as const;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;AAKM,SAAU,iBAAc;AAC1B,SAAO;IACH,gBAAgB;MACZ,MAAM;MACN,MAAM;MACN,OAAO;MACP,KAAK;MACL,KAAK;MACL,MAAM;;IAEV,qBAAqB;MACjB,KAAK;MACL,MAAM;MACN,MAAM;MACN,OAAO;;IAEX,yBAAyB;MACrB,KAAK;MACL,MAAM;MACN,MAAM;MACN,OAAO;;IAEX,gCAAgC;MAC5B,KAAK;MACL,MAAM;MACN,MAAM;MACN,OAAO;MACP,MAAM;;IAEV,iCAAiC;MAC7B,KAAK;MACL,MAAM;MACN,MAAM;MACN,OAAO;MACP,MAAM;;IAEV,QAAQ;MACJ,MAAM;MACN,MAAM;MACN,OAAO;;;AAGnB;AA1CgB;",
6
6
  "names": []
7
7
  }
@@ -13,10 +13,35 @@ export declare class Log implements ioBroker.Logger {
13
13
  * @param logger logger instance
14
14
  */
15
15
  constructor(namespaceLog: string, level: ioBroker.LogLevel, logger: any);
16
+ /**
17
+ * Log a message at the silly level, prefixed with the adapter namespace
18
+ *
19
+ * @param msg the message to log
20
+ */
16
21
  silly(msg: string): void;
22
+ /**
23
+ * Log a message at the debug level, prefixed with the adapter namespace
24
+ *
25
+ * @param msg the message to log
26
+ */
17
27
  debug(msg: string): void;
28
+ /**
29
+ * Log a message at the info level, prefixed with the adapter namespace
30
+ *
31
+ * @param msg the message to log
32
+ */
18
33
  info(msg: string): void;
34
+ /**
35
+ * Log a message at the error level, prefixed with the adapter namespace
36
+ *
37
+ * @param msg the message to log
38
+ */
19
39
  error(msg: string): void;
40
+ /**
41
+ * Log a message at the warn level, prefixed with the adapter namespace
42
+ *
43
+ * @param msg the message to log
44
+ */
20
45
  warn(msg: string): void;
21
46
  }
22
47
  //# sourceMappingURL=log.d.ts.map
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -22,6 +23,9 @@ __export(log_exports, {
22
23
  });
23
24
  module.exports = __toCommonJS(log_exports);
24
25
  class Log {
26
+ static {
27
+ __name(this, "Log");
28
+ }
25
29
  namespaceLog;
26
30
  level;
27
31
  // TODO: this should be a winston.Logger, but the exported types will mess up because of https://github.com/microsoft/rushstack/issues/2220
@@ -41,18 +45,43 @@ class Log {
41
45
  this.error = this.error.bind(this);
42
46
  this.warn = this.warn.bind(this);
43
47
  }
48
+ /**
49
+ * Log a message at the silly level, prefixed with the adapter namespace
50
+ *
51
+ * @param msg the message to log
52
+ */
44
53
  silly(msg) {
45
54
  this.logger.silly(`${this.namespaceLog} ${msg}`);
46
55
  }
56
+ /**
57
+ * Log a message at the debug level, prefixed with the adapter namespace
58
+ *
59
+ * @param msg the message to log
60
+ */
47
61
  debug(msg) {
48
62
  this.logger.debug(`${this.namespaceLog} ${msg}`);
49
63
  }
64
+ /**
65
+ * Log a message at the info level, prefixed with the adapter namespace
66
+ *
67
+ * @param msg the message to log
68
+ */
50
69
  info(msg) {
51
70
  this.logger.info(`${this.namespaceLog} ${msg}`);
52
71
  }
72
+ /**
73
+ * Log a message at the error level, prefixed with the adapter namespace
74
+ *
75
+ * @param msg the message to log
76
+ */
53
77
  error(msg) {
54
78
  this.logger.error(`${this.namespaceLog} ${msg}`);
55
79
  }
80
+ /**
81
+ * Log a message at the warn level, prefixed with the adapter namespace
82
+ *
83
+ * @param msg the message to log
84
+ */
56
85
  warn(msg) {
57
86
  this.logger.warn(`${this.namespaceLog} ${msg}`);
58
87
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/adapter/log.ts"],
4
- "sourcesContent": ["type LogFunction = (msg: string) => void;\n\n/**\n * Log class for adapter.js\n *\n * It prefixes every message with the given namespace\n */\nexport class Log implements ioBroker.Logger {\n private readonly namespaceLog: string;\n readonly level: ioBroker.LogLevel;\n // TODO: this should be a winston.Logger, but the exported types will mess up because of https://github.com/microsoft/rushstack/issues/2220\n private readonly logger: {\n silly: LogFunction;\n debug: LogFunction;\n info: LogFunction;\n warn: LogFunction;\n error: LogFunction;\n };\n\n /**\n * @param namespaceLog Logging namespace to prefix\n * @param level The log level\n * @param logger logger instance\n */\n constructor(namespaceLog: string, level: ioBroker.LogLevel, logger: any) {\n this.namespaceLog = namespaceLog;\n this.level = level;\n // We have to bind the `this` context here, or it is possible that `this` is\n // undefined when passing around the logger methods. This happens e.g. when doing this:\n // const log = new Log(...);\n // const test = log.info;\n // test();\n this.logger = logger;\n this.silly = this.silly.bind(this);\n this.debug = this.debug.bind(this);\n this.info = this.info.bind(this);\n this.error = this.error.bind(this);\n this.warn = this.warn.bind(this);\n }\n\n silly(msg: string): void {\n this.logger.silly(`${this.namespaceLog} ${msg}`);\n }\n\n debug(msg: string): void {\n this.logger.debug(`${this.namespaceLog} ${msg}`);\n }\n\n info(msg: string): void {\n this.logger.info(`${this.namespaceLog} ${msg}`);\n }\n\n error(msg: string): void {\n this.logger.error(`${this.namespaceLog} ${msg}`);\n }\n\n warn(msg: string): void {\n this.logger.warn(`${this.namespaceLog} ${msg}`);\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAEA;;;;;AAKM,MAAO,IAAG;EACK;EACR;;EAEQ;;;;;;EAajB,YAAY,cAAsB,OAA0B,QAAW;AACnE,SAAK,eAAe;AACpB,SAAK,QAAQ;AAMb,SAAK,SAAS;AACd,SAAK,QAAQ,KAAK,MAAM,KAAK,IAAI;AACjC,SAAK,QAAQ,KAAK,MAAM,KAAK,IAAI;AACjC,SAAK,OAAO,KAAK,KAAK,KAAK,IAAI;AAC/B,SAAK,QAAQ,KAAK,MAAM,KAAK,IAAI;AACjC,SAAK,OAAO,KAAK,KAAK,KAAK,IAAI;EACnC;EAEA,MAAM,KAAW;AACb,SAAK,OAAO,MAAM,GAAG,KAAK,YAAY,IAAI,GAAG,EAAE;EACnD;EAEA,MAAM,KAAW;AACb,SAAK,OAAO,MAAM,GAAG,KAAK,YAAY,IAAI,GAAG,EAAE;EACnD;EAEA,KAAK,KAAW;AACZ,SAAK,OAAO,KAAK,GAAG,KAAK,YAAY,IAAI,GAAG,EAAE;EAClD;EAEA,MAAM,KAAW;AACb,SAAK,OAAO,MAAM,GAAG,KAAK,YAAY,IAAI,GAAG,EAAE;EACnD;EAEA,KAAK,KAAW;AACZ,SAAK,OAAO,KAAK,GAAG,KAAK,YAAY,IAAI,GAAG,EAAE;EAClD;;",
4
+ "sourcesContent": ["type LogFunction = (msg: string) => void;\n\n/**\n * Log class for adapter.js\n *\n * It prefixes every message with the given namespace\n */\nexport class Log implements ioBroker.Logger {\n private readonly namespaceLog: string;\n readonly level: ioBroker.LogLevel;\n // TODO: this should be a winston.Logger, but the exported types will mess up because of https://github.com/microsoft/rushstack/issues/2220\n private readonly logger: {\n silly: LogFunction;\n debug: LogFunction;\n info: LogFunction;\n warn: LogFunction;\n error: LogFunction;\n };\n\n /**\n * @param namespaceLog Logging namespace to prefix\n * @param level The log level\n * @param logger logger instance\n */\n constructor(namespaceLog: string, level: ioBroker.LogLevel, logger: any) {\n this.namespaceLog = namespaceLog;\n this.level = level;\n // We have to bind the `this` context here, or it is possible that `this` is\n // undefined when passing around the logger methods. This happens e.g. when doing this:\n // const log = new Log(...);\n // const test = log.info;\n // test();\n this.logger = logger;\n this.silly = this.silly.bind(this);\n this.debug = this.debug.bind(this);\n this.info = this.info.bind(this);\n this.error = this.error.bind(this);\n this.warn = this.warn.bind(this);\n }\n\n /**\n * Log a message at the silly level, prefixed with the adapter namespace\n *\n * @param msg the message to log\n */\n silly(msg: string): void {\n this.logger.silly(`${this.namespaceLog} ${msg}`);\n }\n\n /**\n * Log a message at the debug level, prefixed with the adapter namespace\n *\n * @param msg the message to log\n */\n debug(msg: string): void {\n this.logger.debug(`${this.namespaceLog} ${msg}`);\n }\n\n /**\n * Log a message at the info level, prefixed with the adapter namespace\n *\n * @param msg the message to log\n */\n info(msg: string): void {\n this.logger.info(`${this.namespaceLog} ${msg}`);\n }\n\n /**\n * Log a message at the error level, prefixed with the adapter namespace\n *\n * @param msg the message to log\n */\n error(msg: string): void {\n this.logger.error(`${this.namespaceLog} ${msg}`);\n }\n\n /**\n * Log a message at the warn level, prefixed with the adapter namespace\n *\n * @param msg the message to log\n */\n warn(msg: string): void {\n this.logger.warn(`${this.namespaceLog} ${msg}`);\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAEA;;;;;AAKM,MAAO,IAAG;EALhB,OAKgB;;;EACK;EACR;;EAEQ;;;;;;EAajB,YAAY,cAAsB,OAA0B,QAAW;AACnE,SAAK,eAAe;AACpB,SAAK,QAAQ;AAMb,SAAK,SAAS;AACd,SAAK,QAAQ,KAAK,MAAM,KAAK,IAAI;AACjC,SAAK,QAAQ,KAAK,MAAM,KAAK,IAAI;AACjC,SAAK,OAAO,KAAK,KAAK,KAAK,IAAI;AAC/B,SAAK,QAAQ,KAAK,MAAM,KAAK,IAAI;AACjC,SAAK,OAAO,KAAK,KAAK,KAAK,IAAI;EACnC;;;;;;EAOA,MAAM,KAAW;AACb,SAAK,OAAO,MAAM,GAAG,KAAK,YAAY,IAAI,GAAG,EAAE;EACnD;;;;;;EAOA,MAAM,KAAW;AACb,SAAK,OAAO,MAAM,GAAG,KAAK,YAAY,IAAI,GAAG,EAAE;EACnD;;;;;;EAOA,KAAK,KAAW;AACZ,SAAK,OAAO,KAAK,GAAG,KAAK,YAAY,IAAI,GAAG,EAAE;EAClD;;;;;;EAOA,MAAM,KAAW;AACb,SAAK,OAAO,MAAM,GAAG,KAAK,YAAY,IAAI,GAAG,EAAE;EACnD;;;;;;EAOA,KAAK,KAAW;AACZ,SAAK,OAAO,KAAK,GAAG,KAAK,YAAY,IAAI,GAAG,EAAE;EAClD;;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,49 @@
1
+ import type { Client as StatesInRedisClient } from '@iobroker/db-states-redis';
2
+ import type { Client as ObjectsInRedisClient } from '@iobroker/db-objects-redis';
3
+ import type { AdapterContext } from '../../../lib/adapter/context.js';
4
+ /**
5
+ * Base class for adapter managers that read from the shared {@link AdapterContext}.
6
+ *
7
+ * Holds the context in a private `#ctx` field so subclasses cannot bypass the connection-checked
8
+ * getters and reach the raw (possibly null) DB clients directly. Access to `states`/`objects` goes
9
+ * through the throwing getters, which raise `ERROR_DB_CLOSED` when the respective database is not
10
+ * connected; the other getters pass ctx values through unchanged.
11
+ *
12
+ * Getters are `protected` because `#` privates are not visible to subclasses.
13
+ */
14
+ export declare abstract class AdapterContextBase {
15
+ #private;
16
+ /**
17
+ * @param ctx Shared adapter context providing live runtime state
18
+ */
19
+ constructor(ctx: AdapterContext);
20
+ /**
21
+ * The connected states DB client.
22
+ *
23
+ * @throws {Error} `ERROR_DB_CLOSED` when the states database is not connected.
24
+ */
25
+ protected get states(): StatesInRedisClient;
26
+ /**
27
+ * The connected objects DB client.
28
+ *
29
+ * @throws {Error} `ERROR_DB_CLOSED` when the objects database is not connected.
30
+ */
31
+ protected get objects(): ObjectsInRedisClient;
32
+ /** Current adapter common config */
33
+ protected get common(): ioBroker.InstanceCommon | undefined;
34
+ /** Current adapter instance config (native) */
35
+ protected get config(): ioBroker.AdapterConfig;
36
+ /** Current host name (may be undefined before init) */
37
+ protected get host(): string | undefined;
38
+ /** Current adapter namespace, e.g. `"adapter.0"` */
39
+ protected get namespace(): `${string}.${number}`;
40
+ /** Current namespace string used in log messages */
41
+ protected get namespaceLog(): string;
42
+ /** Logger instance */
43
+ protected get logger(): AdapterContext['logger'];
44
+ /** Controller for UI messaging */
45
+ protected get uiMessagingController(): AdapterContext['uiMessagingController'];
46
+ /** Increment the adapter's outbound-write counter. */
47
+ protected countOutput(): void;
48
+ }
49
+ //# sourceMappingURL=AdapterContextBase.d.ts.map