@iobroker/js-controller-adapter 7.2.3 → 8.0.0-alpha.2-20260923-99da17fcc

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 (108) 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 +1896 -177
  6. package/build/cjs/lib/adapter/adapter.js +788 -1035
  7. package/build/cjs/lib/adapter/adapter.js.map +2 -2
  8. package/build/cjs/lib/adapter/asyncAdapter.d.ts +167 -0
  9. package/build/cjs/lib/adapter/asyncAdapter.js +252 -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/ResourceManager.d.ts +69 -0
  33. package/build/cjs/lib/adapter/managers/ResourceManager.js +170 -0
  34. package/build/cjs/lib/adapter/managers/ResourceManager.js.map +7 -0
  35. package/build/cjs/lib/adapter/managers/SubscriptionManager.d.ts +107 -0
  36. package/build/cjs/lib/adapter/managers/SubscriptionManager.js +349 -0
  37. package/build/cjs/lib/adapter/managers/SubscriptionManager.js.map +7 -0
  38. package/build/cjs/lib/adapter/userInterfaceMessagingController.d.ts +10 -0
  39. package/build/cjs/lib/adapter/userInterfaceMessagingController.js +9 -2
  40. package/build/cjs/lib/adapter/userInterfaceMessagingController.js.map +2 -2
  41. package/build/cjs/lib/adapter/utils.js +15 -1
  42. package/build/cjs/lib/adapter/utils.js.map +2 -2
  43. package/build/cjs/lib/adapter/validator.d.ts +10 -5
  44. package/build/cjs/lib/adapter/validator.js +6 -5
  45. package/build/cjs/lib/adapter/validator.js.map +2 -2
  46. package/build/esm/index.d.ts +0 -1
  47. package/build/esm/index.d.ts.map +1 -1
  48. package/build/esm/index.js +0 -1
  49. package/build/esm/index.js.map +1 -1
  50. package/build/esm/lib/_Types.d.ts +394 -63
  51. package/build/esm/lib/_Types.d.ts.map +1 -1
  52. package/build/esm/lib/adapter/adapter.d.ts +1896 -177
  53. package/build/esm/lib/adapter/adapter.d.ts.map +1 -1
  54. package/build/esm/lib/adapter/adapter.js +900 -1215
  55. package/build/esm/lib/adapter/adapter.js.map +1 -1
  56. package/build/esm/lib/adapter/asyncAdapter.d.ts +167 -0
  57. package/build/esm/lib/adapter/asyncAdapter.d.ts.map +1 -0
  58. package/build/esm/lib/adapter/asyncAdapter.js +225 -0
  59. package/build/esm/lib/adapter/asyncAdapter.js.map +1 -0
  60. package/build/esm/lib/adapter/context.d.ts +34 -0
  61. package/build/esm/lib/adapter/context.d.ts.map +1 -0
  62. package/build/esm/lib/adapter/context.js +2 -0
  63. package/build/esm/lib/adapter/context.js.map +1 -0
  64. package/build/esm/lib/adapter/defaultObjs.d.ts +5 -0
  65. package/build/esm/lib/adapter/defaultObjs.d.ts.map +1 -1
  66. package/build/esm/lib/adapter/defaultObjs.js +5 -0
  67. package/build/esm/lib/adapter/defaultObjs.js.map +1 -1
  68. package/build/esm/lib/adapter/log.d.ts +25 -0
  69. package/build/esm/lib/adapter/log.d.ts.map +1 -1
  70. package/build/esm/lib/adapter/log.js +25 -0
  71. package/build/esm/lib/adapter/log.js.map +1 -1
  72. package/build/esm/lib/adapter/managers/AdapterContextBase.d.ts +49 -0
  73. package/build/esm/lib/adapter/managers/AdapterContextBase.d.ts.map +1 -0
  74. package/build/esm/lib/adapter/managers/AdapterContextBase.js +77 -0
  75. package/build/esm/lib/adapter/managers/AdapterContextBase.js.map +1 -0
  76. package/build/esm/lib/adapter/managers/AliasManager.d.ts +103 -0
  77. package/build/esm/lib/adapter/managers/AliasManager.d.ts.map +1 -0
  78. package/build/esm/lib/adapter/managers/AliasManager.js +269 -0
  79. package/build/esm/lib/adapter/managers/AliasManager.js.map +1 -0
  80. package/build/esm/lib/adapter/managers/CertificateManager.d.ts +50 -0
  81. package/build/esm/lib/adapter/managers/CertificateManager.d.ts.map +1 -0
  82. package/build/esm/lib/adapter/managers/CertificateManager.js +142 -0
  83. package/build/esm/lib/adapter/managers/CertificateManager.js.map +1 -0
  84. package/build/esm/lib/adapter/managers/MessagingManager.d.ts +58 -0
  85. package/build/esm/lib/adapter/managers/MessagingManager.d.ts.map +1 -0
  86. package/build/esm/lib/adapter/managers/MessagingManager.js +267 -0
  87. package/build/esm/lib/adapter/managers/MessagingManager.js.map +1 -0
  88. package/build/esm/lib/adapter/managers/ResourceManager.d.ts +69 -0
  89. package/build/esm/lib/adapter/managers/ResourceManager.d.ts.map +1 -0
  90. package/build/esm/lib/adapter/managers/ResourceManager.js +151 -0
  91. package/build/esm/lib/adapter/managers/ResourceManager.js.map +1 -0
  92. package/build/esm/lib/adapter/managers/SubscriptionManager.d.ts +107 -0
  93. package/build/esm/lib/adapter/managers/SubscriptionManager.d.ts.map +1 -0
  94. package/build/esm/lib/adapter/managers/SubscriptionManager.js +374 -0
  95. package/build/esm/lib/adapter/managers/SubscriptionManager.js.map +1 -0
  96. package/build/esm/lib/adapter/userInterfaceMessagingController.d.ts +10 -0
  97. package/build/esm/lib/adapter/userInterfaceMessagingController.d.ts.map +1 -1
  98. package/build/esm/lib/adapter/userInterfaceMessagingController.js +8 -2
  99. package/build/esm/lib/adapter/userInterfaceMessagingController.js.map +1 -1
  100. package/build/esm/lib/adapter/utils.d.ts.map +1 -1
  101. package/build/esm/lib/adapter/utils.js +1 -1
  102. package/build/esm/lib/adapter/utils.js.map +1 -1
  103. package/build/esm/lib/adapter/validator.d.ts +10 -5
  104. package/build/esm/lib/adapter/validator.d.ts.map +1 -1
  105. package/build/esm/lib/adapter/validator.js +8 -5
  106. package/build/esm/lib/adapter/validator.js.map +1 -1
  107. package/build/tsconfig.build.tsbuildinfo +1 -1
  108. package/package.json +25 -20
@@ -0,0 +1,167 @@
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
+ * Registers an exclusive resource (serial port, TCP/UDP port, USB device, ...) as used by this
114
+ * instance. The registration is forwarded to the host, which stores it under
115
+ * `system.host.<hostname>.usedResources.<type>`.
116
+ *
117
+ * @param type the kind of resource, e.g. "serialPort" or "tcpPort"
118
+ * @param data payload describing the resource
119
+ * @throws {Error} when the host refuses the registration or does not answer
120
+ */
121
+ registerUsedResource<T extends ioBroker.UsedResourceType>(type: T, data: ioBroker.UsedResourceData<T>): Promise<void>;
122
+ /**
123
+ * Asks the host whether another instance currently holds a resource, without registering it.
124
+ *
125
+ * @param type the kind of resource, e.g. "serialPort" or "tcpPort"
126
+ * @param data description of the resource that is about to be used
127
+ * @returns the entries of other instances that currently hold it
128
+ * @throws {Error} when the host refuses the request or does not answer
129
+ */
130
+ checkUsedResource<T extends ioBroker.UsedResourceType>(type: T, data?: Partial<ioBroker.UsedResourceData<T>>): Promise<ioBroker.RegisteredResource[]>;
131
+ /**
132
+ * Frees all exclusive resources this instance registered, across all types.
133
+ *
134
+ * @throws {Error} when the host refuses the command or does not answer
135
+ */
136
+ clearUsedResources(): Promise<void>;
137
+ /**
138
+ * Frees previously registered exclusive resources of this instance. `data` is a filter: every field it
139
+ * names must match. If it is omitted, all registered resources of the given `type` are freed.
140
+ *
141
+ * @param type the kind of resource, e.g. "serialPort" or "tcpPort"
142
+ * @param data fields identifying the resources to free; if omitted, all resources of `type` are freed
143
+ * @throws {Error} when the host refuses the command or does not answer
144
+ */
145
+ freeUsedResource<T extends ioBroker.UsedResourceType>(type: T, data?: Partial<ioBroker.UsedResourceData<T>>): Promise<void>;
146
+ /**
147
+ * Reads the exclusive resources of the given type registered on this instance's host, across all
148
+ * instances of that host.
149
+ *
150
+ * @param type resource type to read, e.g. "serialPort"
151
+ */
152
+ getHostUsedResources<T extends ioBroker.UsedResourceType>(type: T): Promise<ioBroker.RegisteredResource<T>[]>;
153
+ /** Reads the exclusive resources of every type registered on this instance's host. */
154
+ getHostUsedResources(): Promise<ioBroker.RegisteredResource[]>;
155
+ /**
156
+ * Resolves a pending reply promise for an acked messagebox message.
157
+ * Returns true if a pending entry was found and consumed.
158
+ *
159
+ * @param obj incoming message object from the messagebox
160
+ */
161
+ resolveReply(obj: ioBroker.Message): boolean;
162
+ /**
163
+ * Rejects all pending reply promises and clears their timers (used on stop).
164
+ */
165
+ clearPending(): void;
166
+ }
167
+ //# sourceMappingURL=asy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S,QAAQ,CAAC,gBAAgB,EACvD,IAAI,EAAE,CAAC,EACP,IAAI,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAC7C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;IAQzC;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzC;;;;;;;OAOG;IACG,gBAAgB,CAAC,CAAC,SAAS,QAAQ,CAAC,gBAAgB,EACtD,IAAI,EAAE,CAAC,EACP,IAAI,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAC7C,OAAO,CAAC,IAAI,CAAC;IAQhB;;;;;OAKG;IACH,oBAAoB,CAAC,CAAC,SAAS,QAAQ,CAAC,gBAAgB,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7G,sFAAsF;IACtF,oBAAoB,IAAI,OAAO,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC;IAa9D;;;;;OAKG;IACH,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC,OAAO,GAAG,OAAO;IAI5C;;OAEG;IACH,YAAY,IAAI,IAAI;CAGvB"}
@@ -0,0 +1,225 @@
1
+ import { CertificateManager } from '../../lib/adapter/managers/CertificateManager.js';
2
+ import { MessagingManager } from '../../lib/adapter/managers/MessagingManager.js';
3
+ import { ResourceManager } from '../../lib/adapter/managers/ResourceManager.js';
4
+ import { Validator } from '../../lib/adapter/validator.js';
5
+ /**
6
+ * Clean async-only facade for the adapter's outbound messaging. Owns the {@link MessagingManager}
7
+ * and exposes promise-based methods without the legacy `*Async` postfix.
8
+ */
9
+ export class AsyncAdapter {
10
+ #ctx;
11
+ #messagingInstance;
12
+ #certificatesInstance;
13
+ #resourcesInstance;
14
+ /**
15
+ * @param ctx Shared adapter context providing live runtime state
16
+ */
17
+ constructor(ctx) {
18
+ this.#ctx = ctx;
19
+ }
20
+ /** Lazily-constructed outbound messaging manager. */
21
+ get #messaging() {
22
+ return (this.#messagingInstance ??= new MessagingManager(this.#ctx));
23
+ }
24
+ /** Lazily-constructed certificate manager. */
25
+ get #certificates() {
26
+ return (this.#certificatesInstance ??= new CertificateManager(this.#ctx));
27
+ }
28
+ /** Lazily-constructed exclusive-resource manager. */
29
+ get #resources() {
30
+ return (this.#resourcesInstance ??= new ResourceManager(this.#ctx, () => this.#messaging));
31
+ }
32
+ /**
33
+ * @param instanceName name of the instance to send the message to
34
+ * @param command command name
35
+ * @param message message payload
36
+ * @param options send options
37
+ */
38
+ async sendTo(instanceName, command, message, options) {
39
+ Validator.assertString(instanceName, 'instanceName');
40
+ Validator.assertString(command, 'command');
41
+ if (options !== undefined) {
42
+ Validator.assertObject(options, 'options');
43
+ }
44
+ const { expectReply, callback, ...sendOptions } = options ?? {};
45
+ return this.#messaging.sendTo({
46
+ instanceName,
47
+ command,
48
+ message,
49
+ callback,
50
+ options: Object.keys(sendOptions).length ? sendOptions : undefined,
51
+ expectReply: callback ? false : (expectReply ?? true),
52
+ });
53
+ }
54
+ /**
55
+ * @param hostName name of the host, or `null` to broadcast to all hosts
56
+ * @param command command name
57
+ * @param message message payload
58
+ * @param options send options
59
+ */
60
+ async sendToHost(hostName, command, message, options) {
61
+ if (hostName !== null) {
62
+ Validator.assertString(hostName, 'hostName');
63
+ }
64
+ Validator.assertString(command, 'command');
65
+ if (options !== undefined) {
66
+ Validator.assertObject(options, 'options');
67
+ }
68
+ const { expectReply, callback, ...sendOptions } = options ?? {};
69
+ return this.#messaging.sendToHost({
70
+ hostName,
71
+ command,
72
+ message,
73
+ callback,
74
+ options: Object.keys(sendOptions).length ? sendOptions : undefined,
75
+ // broadcast (null host) yields many responses → never wait for a reply
76
+ expectReply: hostName !== null && !callback && (expectReply ?? true),
77
+ });
78
+ }
79
+ /**
80
+ * Sends a message to a single UI client, or broadcasts to all connected UI clients when `clientId` is omitted.
81
+ *
82
+ * @param options clientId and data options
83
+ */
84
+ sendToUI(options) {
85
+ const { clientId, data } = options;
86
+ if (clientId !== undefined) {
87
+ Validator.assertString(clientId, 'clientId');
88
+ }
89
+ return this.#messaging.sendToUI({ clientId, data });
90
+ }
91
+ /**
92
+ * @param scope notification scope
93
+ * @param category notification category
94
+ * @param message notification message
95
+ * @param options additional notification options
96
+ */
97
+ async registerNotification(scope, category, message, options) {
98
+ Validator.assertString(scope, 'scope');
99
+ if (category !== null) {
100
+ Validator.assertString(category, 'category');
101
+ }
102
+ Validator.assertString(message, 'message');
103
+ if (options !== undefined) {
104
+ Validator.assertObject(options, 'options');
105
+ }
106
+ return this.#messaging.registerNotification(scope, category, message, options);
107
+ }
108
+ /**
109
+ * @param publicName public certificate name
110
+ * @param privateName private key name
111
+ * @param chainedName chained certificate name
112
+ */
113
+ async getCertificates(publicName, privateName, chainedName) {
114
+ const config = this.#ctx.config;
115
+ publicName = publicName || config.certPublic;
116
+ privateName = privateName || config.certPrivate;
117
+ chainedName = chainedName || config.certChained;
118
+ if (publicName !== undefined) {
119
+ Validator.assertString(publicName, 'publicName');
120
+ }
121
+ if (privateName !== undefined) {
122
+ Validator.assertString(privateName, 'privateName');
123
+ }
124
+ if (chainedName !== undefined) {
125
+ Validator.assertString(chainedName, 'chainedName');
126
+ }
127
+ return this.#certificates.getCertificates({ publicName, privateName, chainedName });
128
+ }
129
+ /**
130
+ * Tells whether a new version of the `system.certificates` object changes one of the certificates
131
+ * handed out by the last {@link getCertificates} call. Returns false if certificates were never
132
+ * requested, so unrelated certificate edits do not concern this adapter.
133
+ *
134
+ * @param obj the new `system.certificates` object, or null/undefined if it was deleted
135
+ */
136
+ hasRelevantCertificateChange(obj) {
137
+ return this.#certificatesInstance?.hasRelevantChange(obj) ?? false;
138
+ }
139
+ /**
140
+ * Forgets the certificates handed out by the last {@link getCertificates} call, so
141
+ * {@link hasRelevantCertificateChange} no longer reports changes to them. Used when the adapter
142
+ * stops watching its certificates.
143
+ */
144
+ stopWatchingCertificates() {
145
+ this.#certificatesInstance?.stopWatching();
146
+ }
147
+ /**
148
+ * Registers an exclusive resource (serial port, TCP/UDP port, USB device, ...) as used by this
149
+ * instance. The registration is forwarded to the host, which stores it under
150
+ * `system.host.<hostname>.usedResources.<type>`.
151
+ *
152
+ * @param type the kind of resource, e.g. "serialPort" or "tcpPort"
153
+ * @param data payload describing the resource
154
+ * @throws {Error} when the host refuses the registration or does not answer
155
+ */
156
+ async registerUsedResource(type, data) {
157
+ Validator.assertString(type, 'type');
158
+ Validator.assertObject(data, 'data');
159
+ return this.#resources.registerUsedResource(type, data);
160
+ }
161
+ /**
162
+ * Asks the host whether another instance currently holds a resource, without registering it.
163
+ *
164
+ * @param type the kind of resource, e.g. "serialPort" or "tcpPort"
165
+ * @param data description of the resource that is about to be used
166
+ * @returns the entries of other instances that currently hold it
167
+ * @throws {Error} when the host refuses the request or does not answer
168
+ */
169
+ async checkUsedResource(type, data) {
170
+ Validator.assertString(type, 'type');
171
+ if (data !== undefined) {
172
+ Validator.assertObject(data, 'data');
173
+ }
174
+ return this.#resources.checkUsedResource(type, data);
175
+ }
176
+ /**
177
+ * Frees all exclusive resources this instance registered, across all types.
178
+ *
179
+ * @throws {Error} when the host refuses the command or does not answer
180
+ */
181
+ async clearUsedResources() {
182
+ return this.#resources.clearUsedResources();
183
+ }
184
+ /**
185
+ * Frees previously registered exclusive resources of this instance. `data` is a filter: every field it
186
+ * names must match. If it is omitted, all registered resources of the given `type` are freed.
187
+ *
188
+ * @param type the kind of resource, e.g. "serialPort" or "tcpPort"
189
+ * @param data fields identifying the resources to free; if omitted, all resources of `type` are freed
190
+ * @throws {Error} when the host refuses the command or does not answer
191
+ */
192
+ async freeUsedResource(type, data) {
193
+ Validator.assertString(type, 'type');
194
+ if (data !== undefined) {
195
+ Validator.assertObject(data, 'data');
196
+ }
197
+ return this.#resources.freeUsedResource(type, data);
198
+ }
199
+ /**
200
+ * @param type resource type to read; if omitted, the resources of every type are read
201
+ */
202
+ getHostUsedResources(type) {
203
+ if (type !== undefined) {
204
+ Validator.assertString(type, 'type');
205
+ return this.#resources.getHostUsedResources(type);
206
+ }
207
+ return this.#resources.getHostUsedResources();
208
+ }
209
+ /**
210
+ * Resolves a pending reply promise for an acked messagebox message.
211
+ * Returns true if a pending entry was found and consumed.
212
+ *
213
+ * @param obj incoming message object from the messagebox
214
+ */
215
+ resolveReply(obj) {
216
+ return this.#messagingInstance?.resolveCallback(obj) ?? false;
217
+ }
218
+ /**
219
+ * Rejects all pending reply promises and clears their timers (used on stop).
220
+ */
221
+ clearPending() {
222
+ this.#messagingInstance?.clearPendingCallbacks();
223
+ }
224
+ }
225
+ //# sourceMappingURL=asyncAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncAdapter.js","sourceRoot":"","sources":["../../../../src/lib/adapter/asyncAdapter.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD;;;GAGG;AACH,MAAM,OAAO,YAAY;IACZ,IAAI,CAAiB;IAC9B,kBAAkB,CAAoB;IACtC,qBAAqB,CAAsB;IAC3C,kBAAkB,CAAmB;IAErC;;OAEG;IACH,YAAY,GAAmB;QAC3B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IACpB,CAAC;IAED,qDAAqD;IACrD,IAAI,UAAU;QACV,OAAO,CAAC,IAAI,CAAC,kBAAkB,KAAK,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACzE,CAAC;IAED,8CAA8C;IAC9C,IAAI,aAAa;QACb,OAAO,CAAC,IAAI,CAAC,qBAAqB,KAAK,IAAI,kBAAkB,CA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BAAoB,CAAC,IAAI,CAAC,CAAC;QACtD,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACH,YAAY,CAAC,GAAqB;QAC9B,OAAO,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC;IAClE,CAAC;IAED;;OAEG;IACH,YAAY;QACR,IAAI,CAAC,kBAAkB,EAAE,qBAAqB,EAAE,CAAC;IACrD,CAAC;CACJ"}
@@ -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 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/lib/adapter/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAE,MAAM,IAAI,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,KAAK,EAAE,MAAM,IAAI,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,mDAAmD,CAAC;AAE1G;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC3B,+BAA+B;IAC/B,QAAQ,CAAC,MAAM,EAAE,mBAAmB,GAAG,IAAI,GAAG,SAAS,CAAC;IACxD,gCAAgC;IAChC,QAAQ,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1D,oCAAoC;IACpC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,cAAc,GAAG,SAAS,CAAC;IACrD,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,aAAa,CAAC;IACxC,uDAAuD;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,oDAAoD;IACpD,QAAQ,CAAC,SAAS,EAAE,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;IAC1C,oDAAoD;IACpD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,sBAAsB;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC;IAChC,kCAAkC;IAClC,QAAQ,CAAC,qBAAqB,EAAE,gCAAgC,CAAC;IACjE,sDAAsD;IACtD,QAAQ,CAAC,WAAW,EAAE,MAAM,IAAI,CAAC;CACpC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/lib/adapter/context.ts"],"names":[],"mappings":""}
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"defaultObjs.d.ts","sourceRoot":"","sources":["../../../../src/lib/adapter/defaultObjs.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CA0C9E"}
1
+ {"version":3,"file":"defaultObjs.d.ts","sourceRoot":"","sources":["../../../../src/lib/adapter/defaultObjs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CA0C9E"}
@@ -1,3 +1,8 @@
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 function createDefaults() {
2
7
  return {
3
8
  'level.dimmer': {
@@ -1 +1 @@
1
- {"version":3,"file":"defaultObjs.js","sourceRoot":"","sources":["../../../../src/lib/adapter/defaultObjs.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc;IAC1B,OAAO;QACH,cAAc,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,IAAI;YACX,GAAG,EAAE,CAAC;YACN,GAAG,EAAE,GAAG;YACR,IAAI,EAAE,GAAG;SACZ;QACD,mBAAmB,EAAE;YACjB,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK;SACf;QACD,uBAAuB,EAAE;YACrB,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK;SACf;QACD,8BAA8B,EAAE;YAC5B,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,aAAa;SACtB;QACD,+BAA+B,EAAE;YAC7B,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,oBAAoB;SAC7B;QACD,MAAM,EAAE;YACJ,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,IAAI;SACd;KACK,CAAC;AACf,CAAC"}
1
+ {"version":3,"file":"defaultObjs.js","sourceRoot":"","sources":["../../../../src/lib/adapter/defaultObjs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC1B,OAAO;QACH,cAAc,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,IAAI;YACX,GAAG,EAAE,CAAC;YACN,GAAG,EAAE,GAAG;YACR,IAAI,EAAE,GAAG;SACZ;QACD,mBAAmB,EAAE;YACjB,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK;SACf;QACD,uBAAuB,EAAE;YACrB,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK;SACf;QACD,8BAA8B,EAAE;YAC5B,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,aAAa;SACtB;QACD,+BAA+B,EAAE;YAC7B,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE,oBAAoB;SAC7B;QACD,MAAM,EAAE;YACJ,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,IAAI;SACd;KACK,CAAC;AACf,CAAC"}
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../../src/lib/adapter/log.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,qBAAa,GAAI,YAAW,QAAQ,CAAC,MAAM;IACvC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAElC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAMrB;IAEF;;;;OAIG;gBACS,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG;IAgBvE,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIxB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIxB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIvB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIxB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAG1B"}
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../../src/lib/adapter/log.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,qBAAa,GAAI,YAAW,QAAQ,CAAC,MAAM;IACvC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAElC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAMrB;IAEF;;;;OAIG;gBACS,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG;IAgBvE;;;;OAIG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIxB;;;;OAIG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIxB;;;;OAIG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIvB;;;;OAIG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIxB;;;;OAIG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAG1B"}
@@ -28,18 +28,43 @@ export class Log {
28
28
  this.error = this.error.bind(this);
29
29
  this.warn = this.warn.bind(this);
30
30
  }
31
+ /**
32
+ * Log a message at the silly level, prefixed with the adapter namespace
33
+ *
34
+ * @param msg the message to log
35
+ */
31
36
  silly(msg) {
32
37
  this.logger.silly(`${this.namespaceLog} ${msg}`);
33
38
  }
39
+ /**
40
+ * Log a message at the debug level, prefixed with the adapter namespace
41
+ *
42
+ * @param msg the message to log
43
+ */
34
44
  debug(msg) {
35
45
  this.logger.debug(`${this.namespaceLog} ${msg}`);
36
46
  }
47
+ /**
48
+ * Log a message at the info level, prefixed with the adapter namespace
49
+ *
50
+ * @param msg the message to log
51
+ */
37
52
  info(msg) {
38
53
  this.logger.info(`${this.namespaceLog} ${msg}`);
39
54
  }
55
+ /**
56
+ * Log a message at the error level, prefixed with the adapter namespace
57
+ *
58
+ * @param msg the message to log
59
+ */
40
60
  error(msg) {
41
61
  this.logger.error(`${this.namespaceLog} ${msg}`);
42
62
  }
63
+ /**
64
+ * Log a message at the warn level, prefixed with the adapter namespace
65
+ *
66
+ * @param msg the message to log
67
+ */
43
68
  warn(msg) {
44
69
  this.logger.warn(`${this.namespaceLog} ${msg}`);
45
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"log.js","sourceRoot":"","sources":["../../../../src/lib/adapter/log.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,GAAG;IACK,YAAY,CAAS;IAC7B,KAAK,CAAoB;IAClC,2IAA2I;IAC1H,MAAM,CAMrB;IAEF;;;;OAIG;IACH,YAAY,YAAoB,EAAE,KAAwB,EAAE,MAAW;QACnE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,4EAA4E;QAC5E,uFAAuF;QACvF,8BAA8B;QAC9B,2BAA2B;QAC3B,YAAY;QACZ,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,K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esInRedisClient } 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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdapterContextBase.d.ts","sourceRoot":"","sources":["../../../../../src/lib/adapter/managers/AdapterContextBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,KAAK,EAAE,MAAM,IAAI,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D;;;;;;;;;GASG;AACH,8BAAsB,kBAAkB;;IAGpC;;OAEG;gBACS,GAAG,EAAE,cAAc;IAI/B;;;;OAIG;IACH,SAAS,KAAK,MAAM,IAAI,mBAAmB,CAM1C;IAED;;;;OAIG;IACH,SAAS,KAAK,OAAO,IAAI,oBAAoB,CAM5C;IAED,oCAAoC;IACpC,SAAS,KAAK,MAAM,IAAI,QAAQ,CAAC,cAAc,GAAG,SAAS,CAE1D;IAED,+CAA+C;IAC/C,SAAS,KAAK,MAAM,IAAI,QAAQ,CAAC,aAAa,CAE7C;IAED,uDAAuD;IACvD,SAAS,KAAK,IAAI,IAAI,MAAM,GAAG,SAAS,CAEvC;IAED,oDAAoD;IACpD,SAAS,KAAK,SAAS,IAAI,GAAG,MAAM,IAAI,MAAM,EAAE,CAE/C;IAED,oDAAoD;IACpD,SAAS,KAAK,YAAY,IAAI,MAAM,CAEnC;IAED,sBAAsB;IACtB,SAAS,KAAK,MAAM,IAAI,cAAc,CAAC,QAAQ,CAAC,CAE/C;IAED,kCAAkC;IAClC,SAAS,KAAK,qBAAqB,IAAI,cAAc,CAAC,uBAAuB,CAAC,CAE7E;IAED,sDAAsD;IACtD,SAAS,CAAC,WAAW,IAAI,IAAI;CAGhC"}