@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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/adapter/userInterfaceMessagingController.ts"],
4
- "sourcesContent": ["import type { Client as StatesInRedisClient } from '@iobroker/db-states-redis';\nimport type { AdapterClass } from '@/lib/adapter/adapter.js';\nimport type {\n UserInterfaceClientRemoveMessage,\n UserInterfaceClientSubscribeHandler,\n UserInterfaceClientSubscribeReturnType,\n UserInterfaceClientUnsubscribeHandler,\n} from '@/lib/_Types.js';\n\nexport interface HeartbeatTimer {\n /** The actual timer */\n timer: NodeJS.Timeout;\n /** The heartbeat interval */\n heartbeat: number;\n}\n\nexport interface MessagingControllerOptions {\n /** The adapter using this messaging controller */\n adapter: AdapterClass;\n /** Callback to call if successfully subscribed */\n subscribeCallback?: UserInterfaceClientSubscribeHandler;\n /** Callback to call if successfully unsubscribed */\n unsubscribeCallback?: UserInterfaceClientUnsubscribeHandler;\n}\n\nexport interface SendToClientOptions {\n /** ID of the client to send the message to, will send to all if omitted */\n clientId: string;\n /** Data to send to the client */\n data: unknown;\n /** The states db */\n states: StatesInRedisClient;\n}\n\nexport type SendToAllClientOptions = Omit<SendToClientOptions, 'clientId'>;\n\nexport interface ClientHandler {\n /** The session id of the client connection */\n sid: string;\n /** Name of the subscriber */\n from: string;\n /** Individual type which can be specified */\n type: string;\n}\n\n/**\n * The message has short keys, to save bytes for high-throughput messaging\n */\ninterface UserInterfaceMessage {\n /** The individual type of the client handler */\n m: string;\n /** The session id of the client connection */\n s: string;\n /** The actual data */\n d: unknown;\n}\n\nexport class UserInterfaceMessagingController {\n /** The adapter using this messaging controller */\n private readonly adapter: AdapterClass;\n /** Callback to call if successfully subscribed */\n private readonly unsubscribeCallback?: UserInterfaceClientUnsubscribeHandler;\n /** Callback to call if successfully unsubscribed */\n private readonly subscribeCallback?: UserInterfaceClientSubscribeHandler;\n /** All currently registered client handlers */\n private readonly handlers = new Map<string, ClientHandler>();\n /** Collection of current heartbeat timers */\n private heartbeatTimers = new Map<string, HeartbeatTimer>();\n constructor(options: MessagingControllerOptions) {\n const { adapter, unsubscribeCallback, subscribeCallback } = options;\n\n this.adapter = adapter;\n this.unsubscribeCallback = unsubscribeCallback;\n this.subscribeCallback = subscribeCallback;\n }\n\n /**\n * Send a message to the given clientId\n *\n * @param options Data, states and client information\n */\n sendToClient(options: SendToClientOptions): Promise<void> {\n const { states, clientId, data } = options;\n\n if (!this.handlers.has(clientId)) {\n throw new Error(`Client \"${clientId}\" is not registered`);\n }\n\n const handler = this.handlers.get(clientId)!;\n\n return states.pushMessage(handler.from, {\n command: 'im',\n message: { m: handler.type, s: handler.sid, d: data } satisfies UserInterfaceMessage,\n from: `system.adapter.${this.adapter.namespace}`,\n });\n }\n\n /**\n * Send a message to all active clients\n *\n * @param options Data and states options\n */\n async sendToAllClients(options: SendToAllClientOptions): Promise<void> {\n const { states, data } = options;\n\n for (const clientId of Object.keys(this.handlers)) {\n await this.sendToClient({ clientId, data, states });\n }\n }\n\n /**\n * Register subscription from new client\n *\n * @param msg The subscribe message\n */\n async registerClientSubscribeByMessage(\n msg: ioBroker.Message,\n ): Promise<UserInterfaceClientSubscribeReturnType | undefined> {\n if (!this.subscribeCallback) {\n return;\n }\n\n const handler = this.extractHandlerFromMessage(msg);\n const clientId = this.handlerToId(handler);\n\n if (this.heartbeatTimers.has(clientId)) {\n this.heartbeatTimers.get(clientId)!.timer.refresh();\n return;\n }\n\n const resOrAwaitable = this.subscribeCallback({ clientId, message: msg });\n let res: UserInterfaceClientSubscribeReturnType;\n\n if (resOrAwaitable instanceof Promise) {\n res = await resOrAwaitable;\n } else {\n res = resOrAwaitable;\n }\n\n if (!res.accepted) {\n return res;\n }\n\n this.handlers.set(clientId, handler);\n if (res.heartbeat) {\n const timer = setTimeout(() => this.heartbeatExpired(clientId), res.heartbeat);\n this.heartbeatTimers.set(clientId, { heartbeat: res.heartbeat, timer });\n }\n\n return res;\n }\n\n /**\n * Remove a client subscription, issued by message\n * It contains an array of types which should be unsubscribed\n *\n * @param msg The unsubscribe message\n */\n removeClientSubscribeByMessage(msg: UserInterfaceClientRemoveMessage): void {\n const handler = this.extractHandlerFromMessage(msg);\n const reason = msg.command === 'clientSubscribeError' ? msg.command : msg.message.reason;\n\n const types = msg.message.type;\n\n for (const type of types) {\n const clientId = this.handlerToId({ ...handler, type });\n\n if (this.heartbeatTimers.has(clientId)) {\n const timer = this.heartbeatTimers.get(clientId)!;\n\n clearTimeout(timer.timer);\n this.heartbeatTimers.delete(clientId);\n }\n\n if (!this.handlers.has(clientId)) {\n return;\n }\n\n this.handlers.delete(clientId);\n if (this.unsubscribeCallback) {\n this.unsubscribeCallback({ clientId, message: msg, reason });\n }\n }\n }\n\n /**\n * Convert handler to id\n *\n * @param handler the client handler to creat the id for\n */\n private handlerToId(handler: ClientHandler): string {\n const { sid, type, from } = handler;\n\n return `${sid}-${from}-${type}`;\n }\n\n /**\n * Extract the client handler from a given message\n *\n * @param msg the subscribe or unsubscribe message\n */\n private extractHandlerFromMessage(msg: ioBroker.Message): ClientHandler {\n return { sid: msg.message.sid, from: msg.from, type: msg.message.type };\n }\n\n /**\n * Handle expired heartbeat\n *\n * @param clientId the id of the expired client\n */\n private heartbeatExpired(clientId: string): void {\n this.handlers.delete(clientId);\n this.heartbeatTimers.delete(clientId);\n\n if (this.unsub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AAiB,UAAgB;AACrC,SAAK,SAAS,OAAO,QAAQ;AAC7B,SAAK,gBAAgB,OAAO,QAAQ;AAEpC,QAAI,KAAK,qBAAqB;AAC1B,WAAK,oBAAoB,EAAE,UAAU,QAAQ,UAAS,CAAE;IAC5D;EACJ;;",
4
+ "sourcesContent": ["import type { Client as StatesInRedisClient } from '@iobroker/db-states-redis';\nimport type { AdapterClass } from '@/lib/adapter/adapter.js';\nimport type {\n UserInterfaceClientRemoveMessage,\n UserInterfaceClientSubscribeHandler,\n UserInterfaceClientSubscribeReturnType,\n UserInterfaceClientUnsubscribeHandler,\n} from '@/lib/_Types.js';\n\n/** A heartbeat timer for a subscribed UI client */\nexport interface HeartbeatTimer {\n /** The actual timer */\n timer: NodeJS.Timeout;\n /** The heartbeat interval */\n heartbeat: number;\n}\n\n/** Options for the UI messaging controller */\nexport interface MessagingControllerOptions {\n /** The adapter using this messaging controller */\n adapter: AdapterClass;\n /** Callback to call if successfully subscribed */\n subscribeCallback?: UserInterfaceClientSubscribeHandler;\n /** Callback to call if successfully unsubscribed */\n unsubscribeCallback?: UserInterfaceClientUnsubscribeHandler;\n}\n\n/** Options for sending a message to a single UI client */\nexport interface SendToClientOptions {\n /** ID of the client to send the message to, will send to all if omitted */\n clientId: string;\n /** Data to send to the client */\n data: unknown;\n /** The states db */\n states: StatesInRedisClient;\n}\n\nexport type SendToAllClientOptions = Omit<SendToClientOptions, 'clientId'>;\n\n/** Handler describing a subscribed UI client */\nexport interface ClientHandler {\n /** The session id of the client connection */\n sid: string;\n /** Name of the subscriber */\n from: string;\n /** Individual type which can be specified */\n type: string;\n}\n\n/**\n * The message has short keys, to save bytes for high-throughput messaging\n */\ninterface UserInterfaceMessage {\n /** The individual type of the client handler */\n m: string;\n /** The session id of the client connection */\n s: string;\n /** The actual data */\n d: unknown;\n}\n\n/**\n * Controller for messaging with UI clients (subscribe, heartbeat and sending data)\n */\nexport class UserInterfaceMessagingController {\n /** The adapter using this messaging controller */\n private readonly adapter: AdapterClass;\n /** Callback to call if successfully subscribed */\n private readonly unsubscribeCallback?: UserInterfaceClientUnsubscribeHandler;\n /** Callback to call if successfully unsubscribed */\n private readonly subscribeCallback?: UserInterfaceClientSubscribeHandler;\n /** All currently registered client handlers */\n private readonly handlers = new Map<string, ClientHandler>();\n /** Collection of current heartbeat timers */\n private heartbeatTimers = new Map<string, HeartbeatTimer>();\n /**\n * @param options The adapter and the subscribe/unsubscribe callbacks\n */\n constructor(options: MessagingControllerOptions) {\n const { adapter, unsubscribeCallback, subscribeCallback } = options;\n\n this.adapter = adapter;\n this.unsubscribeCallback = unsubscribeCallback;\n this.subscribeCallback = subscribeCallback;\n }\n\n /**\n * Send a message to the given clientId\n *\n * @param options Data, states and client information\n */\n sendToClient(options: SendToClientOptions): Promise<void> {\n const { states, clientId, data } = options;\n\n if (!this.handlers.has(clientId)) {\n throw new Error(`Client \"${clientId}\" is not registered`);\n }\n\n const handler = this.handlers.get(clientId)!;\n\n return states.pushMessage(handler.from, {\n command: 'im',\n message: { m: handler.type, s: handler.sid, d: data } satisfies UserInterfaceMessage,\n from: `system.adapter.${this.adapter.namespace}`,\n });\n }\n\n /**\n * Send a message to all active clients\n *\n * @param options Data and states options\n */\n async sendToAllClients(options: SendToAllClientOptions): Promise<void> {\n const { states, data } = options;\n\n for (const clientId of Object.keys(this.handlers)) {\n await this.sendToClient({ clientId, data, states });\n }\n }\n\n /**\n * Register subscription from new client\n *\n * @param msg The subscribe message\n */\n async registerClientSubscribeByMessage(\n msg: ioBroker.Message,\n ): Promise<UserInterfaceClientSubscribeReturnType | undefined> {\n if (!this.subscribeCallback) {\n return;\n }\n\n const handler = this.extractHandlerFromMessage(msg);\n const clientId = this.handlerToId(handler);\n\n if (this.heartbeatTimers.has(clientId)) {\n this.heartbeatTimers.get(clientId)!.timer.refresh();\n return;\n }\n\n const resOrAwaitable = this.subscribeCallback({ clientId, message: msg });\n let res: UserInterfaceClientSubscribeReturnType;\n\n if (resOrAwaitable instanceof Promise) {\n res = await resOrAwaitable;\n } else {\n res = resOrAwaitable;\n }\n\n if (!res.accepted) {\n return res;\n }\n\n this.handlers.set(clientId, handler);\n if (res.heartbeat) {\n const timer = setTimeout(() => this.heartbeatExpired(clientId), res.heartbeat);\n this.heartbeatTimers.set(clientId, { heartbeat: res.heartbeat, timer });\n }\n\n return res;\n }\n\n /**\n * Remove a client subscription, issued by message\n * It contains an array of types which should be unsubscribed\n *\n * @param msg The unsubscribe message\n */\n removeClientSubscribeByMessage(msg: UserInterfaceClientRemoveMessage): void {\n const handler = this.extractHandlerFromMessage(msg);\n const reason = msg.command === 'clientSubscribeError' ? msg.command : msg.message.reason;\n\n const types = msg.message.type;\n\n for (const type of types) {\n const clientId = this.handlerToId({ ...handler, type });\n\n if (this.heartbeatTimers.has(clientId)) {\n const timer = this.heartbeatTimers.get(clientId)!;\n\n clearTimeout(timer.timer);\n this.heartbeatTimers.delete(clientId);\n }\n\n if (!this.handlers.has(clientId)) {\n return;\n }\n\n this.handlers.delete(clientId);\n if (this.unsubscribeCallback) {\n Promise.resolve(this.unsubscribeCallback({ clientId, message: msg, reason })).catch(e =>\n this.adapter.log.error(`Error in unsubscribe callback: ${e.message}`),\n );\n }\n }\n }\n\n /**\n * Convert handler to id\n *\n * @param handler the client handler to creat the id for\n */\n private handlerToId(handler: ClientHandler): string {\n const { sid, type, from } = handler;\n\n return `${sid}-${from}-${type}`;\n }\n\n /**\n * Extract the client handler from a given message\n *\n * @param msg the subscribe or unsubscribe message\n */\n private extractHandlerFromMessage(msg: ioBroker.Message): ClientHandler {\n return { sid: msg.message.sid, from: msg.from, type: msg.message.type };\n }\n\n /**\n * Handle expired heartbeat\n *\n * @param clientId the id of the expired client\n */\n private heartbeatExpired(clientId: string): void {\n this.handlers.delete(clientId);\n this.heartbeatTimers.delete(clientId);\n\n if (this.unsubscribeCallback) {\n Promise.resolve(this.unsubscribeCallback({ clientId, reason: 'timeout' })).catch(e =>\n this.adapter.log.error(`Error in unsubscribe callback: ${e.message}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AAI,QAAQ,KAAK,MAAM,IAAI,MAAM,MAAM,IAAI,QAAQ,KAAI;EACzE;;;;;;EAOQ,iBAAiB,UAAgB;AACrC,SAAK,SAAS,OAAO,QAAQ;AAC7B,SAAK,gBAAgB,OAAO,QAAQ;AAEpC,QAAI,KAAK,qBAAqB;AAC1B,cAAQ,QAAQ,KAAK,oBAAoB,EAAE,UAAU,QAAQ,UAAS,CAAE,CAAC,EAAE,MAAM,OAC7E,KAAK,QAAQ,IAAI,MAAM,kCAAkC,EAAE,OAAO,EAAE,CAAC;IAE7E;EACJ;;",
6
6
  "names": []
7
7
  }
@@ -5,6 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
9
  var __export = (target, all) => {
9
10
  for (var name in all)
10
11
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -50,9 +51,11 @@ function isMessageboxSupported(instanceCommon) {
50
51
  }
51
52
  return Object.values(instanceCommon.supportedMessages).find((val) => val !== false) !== void 0;
52
53
  }
54
+ __name(isMessageboxSupported, "isMessageboxSupported");
53
55
  function getSupportedFeatures() {
54
56
  return (0, import_js_controller_common.getSupportedFeatures)();
55
57
  }
58
+ __name(getSupportedFeatures, "getSupportedFeatures");
56
59
  function encryptArray(options) {
57
60
  const { secret, obj, keys } = options;
58
61
  for (const attr of keys) {
@@ -68,6 +71,7 @@ function encryptArray(options) {
68
71
  }
69
72
  }
70
73
  }
74
+ __name(encryptArray, "encryptArray");
71
75
  function decryptArray(options) {
72
76
  const { secret, obj, keys } = options;
73
77
  for (const attr of keys) {
@@ -83,6 +87,7 @@ function decryptArray(options) {
83
87
  }
84
88
  }
85
89
  }
90
+ __name(decryptArray, "decryptArray");
86
91
  function getAdapterScopedPackageIdentifier(options) {
87
92
  const { moduleName, namespace } = options;
88
93
  let internalModuleName = moduleName;
@@ -91,6 +96,7 @@ function getAdapterScopedPackageIdentifier(options) {
91
96
  }
92
97
  return `@${import_tools.appNameLowerCase}-${namespace}/${internalModuleName}`;
93
98
  }
99
+ __name(getAdapterScopedPackageIdentifier, "getAdapterScopedPackageIdentifier");
94
100
  async function listInstalledNodeModules(namespace) {
95
101
  const packJson = await import_fs_extra.default.readJson(import_node_path.default.join((0, import_tools.getRootDir)(), "package.json"));
96
102
  const dependencies = [];
@@ -108,13 +114,15 @@ async function listInstalledNodeModules(namespace) {
108
114
  }
109
115
  return dependencies;
110
116
  }
117
+ __name(listInstalledNodeModules, "listInstalledNodeModules");
111
118
  async function requestModuleNameByUrl(url) {
112
119
  const res = await (0, import_tools.execAsync)(`npm view ${url} name`);
113
120
  if (typeof res.stdout !== "string") {
114
- throw new Error(`Could not determine module name for url "${url}". Unexpected stdout: "${res.stdout ? res.stdout.toString() : ""}"`);
121
+ throw new Error(`Could not determine module name for url "${url}". Unexpected stdout: "${typeof res.stdout}"`);
115
122
  }
116
123
  return res.stdout.trim();
117
124
  }
125
+ __name(requestModuleNameByUrl, "requestModuleNameByUrl");
118
126
  function _getObjectAttribute(obj, attrParts, index) {
119
127
  if (index === attrParts.length - 1) {
120
128
  return obj[attrParts[index]];
@@ -131,12 +139,14 @@ function _getObjectAttribute(obj, attrParts, index) {
131
139
  }
132
140
  return _getObjectAttribute(obj[attrParts[index]], attrParts, index + 1);
133
141
  }
142
+ __name(_getObjectAttribute, "_getObjectAttribute");
134
143
  function getObjectAttribute(obj, attr) {
135
144
  if (!attr.includes(".")) {
136
145
  return obj[attr];
137
146
  }
138
147
  return _getObjectAttribute(obj, attr.split("."), 0);
139
148
  }
149
+ __name(getObjectAttribute, "getObjectAttribute");
140
150
  function _setObjectAttribute(obj, value, attrParts, index) {
141
151
  if (index === attrParts.length - 1) {
142
152
  obj[attrParts[index]] = value;
@@ -156,6 +166,7 @@ function _setObjectAttribute(obj, value, attrParts, index) {
156
166
  }
157
167
  _setObjectAttribute(obj[attrParts[index]], value, attrParts, index + 1);
158
168
  }
169
+ __name(_setObjectAttribute, "_setObjectAttribute");
159
170
  function setObjectAttribute(obj, attr, value) {
160
171
  if (!attr.includes(".")) {
161
172
  obj[attr] = value;
@@ -163,6 +174,7 @@ function setObjectAttribute(obj, attr, value) {
163
174
  }
164
175
  _setObjectAttribute(obj, value, attr.split("."), 0);
165
176
  }
177
+ __name(setObjectAttribute, "setObjectAttribute");
166
178
  function _deleteObjectAttribute(obj, attrParts, index) {
167
179
  if (index === attrParts.length - 1) {
168
180
  delete obj[attrParts[index]];
@@ -179,6 +191,7 @@ function _deleteObjectAttribute(obj, attrParts, index) {
179
191
  }
180
192
  _deleteObjectAttribute(obj[attrParts[index]], attrParts, index + 1);
181
193
  }
194
+ __name(_deleteObjectAttribute, "_deleteObjectAttribute");
182
195
  function deleteObjectAttribute(obj, attr) {
183
196
  if (!attr.includes(".")) {
184
197
  delete obj[attr];
@@ -186,6 +199,7 @@ function deleteObjectAttribute(obj, attr) {
186
199
  }
187
200
  _deleteObjectAttribute(obj, attr.split("."), 0);
188
201
  }
202
+ __name(deleteObjectAttribute, "deleteObjectAttribute");
189
203
  // Annotate the CommonJS export names for ESM import in node:
190
204
  0 && (module.exports = {
191
205
  decryptArray,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/adapter/utils.ts"],
4
- "sourcesContent": ["import {\n isObject,\n encrypt,\n decrypt,\n appNameLowerCase,\n getRootDir,\n execAsync,\n} from '@iobroker/js-controller-common-db/tools';\nimport { getSupportedFeatures as getSupportedFeaturesCommon } from '@iobroker/js-controller-common';\nimport path from 'node:path';\nimport fs from 'fs-extra';\n\ninterface EncryptArrayOptions {\n /** The objects whose values should be en/decrypted */\n obj: Record<string, unknown>;\n /** Keys which need to be en/decrypted */\n keys: string[];\n /** Secret to use for en/decryption */\n secret: string;\n}\n\ninterface GetScopedPackageIdentifierOptions {\n /** Name of the node module */\n moduleName: string;\n /** Adapter namespace */\n namespace: string;\n}\n\n/**\n * Check if messagebox is configured for given instance\n * This means, at least one of the properties has a value different from false\n *\n * @param instanceCommon Instance common\n */\nexport function isMessageboxSupported(instanceCommon: ioBroker.InstanceCommon): boolean {\n if (!isObject(instanceCommon.supportedMessages)) {\n return !!instanceCommon.messagebox;\n }\n\n return Object.values(instanceCommon.supportedMessages).find(val => val !== false) !== undefined;\n}\n\n/**\n * Get the supported features for the current running controller\n */\nexport function getSupportedFeatures(): ioBroker.SupportedFeature[] {\n return getSupportedFeaturesCommon();\n}\n\n/**\n * Encrypt given keys of given object\n *\n * @param options keys, object and secret information\n */\nexport function encryptArray(options: EncryptArrayOptions): void {\n const { secret, obj, keys } = options;\n\n for (const attr of keys) {\n const val = getObjectAttribute(obj, attr);\n if (Array.isArray(val)) {\n const encrypted: string[] = [];\n for (let i = 0; i < val.length; i++) {\n encrypted[i] = typeof val[i] === 'string' ? encrypt(secret, val[i]) : val[i];\n }\n setObjectAttribute(obj, attr, encrypted);\n } else if (typeof val === 'string') {\n setObjectAttribute(obj, attr, encrypt(secret, val));\n }\n }\n}\n\n/**\n * Decrypt given keys of given object\n *\n * @param options keys, object and secret information\n */\nexport function decryptArray(options: EncryptArrayOptions): void {\n const { secret, obj, keys } = options;\n\n for (const attr of keys) {\n const val = getObjectAttribute(obj, attr);\n if (Array.isArray(val)) {\n const decrypted: string[] = [];\n for (let i = 0; i < val.length; i++) {\n decrypted[i] = typeof val[i] === 'string' ? decrypt(secret, val[i]) : val[i];\n }\n setObjectAttribute(obj, attr, decrypted);\n } else if (typeof val === 'string') {\n setObjectAttribute(obj, attr, decrypt(secret, val));\n }\n }\n}\n\n/**\n * Transform a npm moduleName to the adapter scoped name, like `axios` to `@iobroker-javascript.0/axios`\n *\n * @param options name of the node module and namespace information\n */\nexport function getAdapterScopedPackageIdentifier(options: GetScopedPackageIdentifierOptions): string {\n const { moduleName, namespace } = options;\n\n let internalModuleName = moduleName;\n if (internalModuleName.startsWith('@')) {\n internalModuleName = internalModuleName.substring(1).replace(/\\//g, '-');\n }\n\n return `@${appNameLowerCase}-${namespace}/${internalModuleName}`;\n}\n\n/**\n * List all packages installed in the given adapter namespace\n *\n * @param namespace namespace to check installed modules for\n */\nexport async function listInstalledNodeModules(namespace: string): Promise<string[]> {\n const packJson = (await fs.readJson(path.join(getRootDir(), 'package.json'))) as {\n dependencies: Record<string, string>;\n };\n const dependencies: string[] = [];\n\n for (const [dependency, versionInfo] of Object.entries(packJson.dependencies)) {\n if (!dependency.startsWith(`@${appNameLowerCase}-${namespace}/`)) {\n continue;\n }\n\n let realDependencyName: string;\n // remove npm: and version after last @\n if (versionInfo.startsWith('npm:')) {\n realDependencyName = versionInfo.substring(4, versionInfo.lastIndexOf('@'));\n } else {\n realDependencyName = await requestModuleNameByUrl(versionInfo);\n }\n\n dependencies.push(realDependencyName);\n }\n\n return dependencies;\n}\n\n/**\n * Request a module name by given url using `npm view`\n *\n * @param url the url to the package which should be installed via npm\n */\nexport async function requestModuleNameByUrl(url: string): Promise<string> {\n const res = await execAsync(`npm view ${url} name`);\n\n if (typeof res.stdout !== 'string') {\n throw new Error(\n `Could not determine module name for url \"${url}\". Unexpected stdout: \"${res.stdout ? res.stdout.toString() : ''}\"`,\n );\n }\n\n return res.stdout.trim();\n}\n\n/**\n * Get attribute of an object with complex names\n *\n * @param obj - object to get the attribute from\n * @param attrParts - attribute parts\n * @param index - index of attribute part\n */\nfunction _getObjectAttribute(obj: Record<string, any>, attrParts: string[], index: number): any {\n if (index === attrParts.length - 1) {\n return obj[attrParts[index]];\n }\n if (!obj[attrParts[index]] || typeof obj[attrParts[index]] !== 'object') {\n return;\n }\n if (Array.isArray(obj[attrParts[index]])) {\n const result: any = [];\n for (let i = 0; i < obj[attrParts[index]].length; i++) {\n result.push(_getObjectAttribute(obj[attrParts[index]][i], attrParts, index + 1));\n }\n return result;\n }\n\n return _getObjectAttribute(obj[attrParts[index]], attrParts, index + 1);\n}\n\n/**\n * Get attribute of an object with complex or simple names\n *\n * @param obj - object to get the attribute from\n * @param attr - attribute name, can be complex like `attr1.attr2.attr3`\n * @returns could be a value or an array\n */\nexport function getObjectAttribute(obj: Record<string, any>, attr: string): any {\n // Optimization for 98% of the cases\n if (!attr.includes('.')) {\n return obj[attr];\n }\n return _getObjectAttribute(obj, attr.split('.'), 0);\n}\n\n/**\n * Set attribute in an object with complex names\n *\n * @param obj - object to get the attribute from\n * @param value - value to set (Could be an array)\n * @param attrParts - attribute parts\n * @param index - index of attribute part\n */\nfunction _setObjectAttribute(obj: Record<string, any>, value: any, attrParts: string[], index: number): any {\n if (index === attrParts.length - 1) {\n obj[attrParts[index]] = value;\n return;\n }\n if (!obj[attrParts[index]] || typeof obj[attrParts[index]] !== 'object') {\n return;\n }\n if (Array.isArray(obj[attrParts[index]])) {\n if (!Array.isArray(value)) {\n throw new Error('Value is not an array');\n }\n for (let i = 0; i < obj[attrParts[index]].length; i++) {\n _setObjectAttribute(obj[attrParts[index]][i], value[i], attrParts, index + 1);\n }\n return;\n }\n\n _setObjectAttribute(obj[attrParts[index]], value, attrParts, index + 1);\n}\n\n/**\n * Set attribute in an object with complex or simple names\n *\n * @param obj - object to get the attribute from\n * @param attr - attribute name, can be complex like `attr1.attr2.attr3`\n * @param value - value to set (could be a value or an array)\n */\nexport function setObjectAttribute(obj: Record<string, any>, attr: string, value: any): void {\n // Optimization for 98% of the cases\n if (!attr.includes('.')) {\n obj[attr] = value;\n return;\n }\n _setObjectAttribute(obj, value, attr.split('.'), 0);\n}\n\n/**\n * Delete attribute in an object with complex names\n *\n * @param obj - object to get the attribute from\n * @param attrParts - attribute parts\n * @param index - index of attribute part\n */\nfunction _deleteObjectAttribute(obj: Record<string, any>, attrParts: string[], index: number): any {\n if (index === attrParts.length - 1) {\n delete obj[attrParts[index]];\n return;\n }\n if (!obj[attrParts[index]] || typeof obj[attrParts[index]] !== 'object') {\n return;\n }\n if (Array.isArray(obj[attrParts[index]])) {\n for (let i = 0; i < obj[attrParts[index]].length; i++) {\n _deleteObjectAttribute(obj[attrParts[index]][i], attrParts, index + 1);\n }\n return;\n }\n\n _deleteObjectAttribute(obj[attrParts[index]], attrParts, index + 1);\n}\n\n/**\n * Delete attribute in an object with complex names\n *\n * @param obj - object to get the attribute from\n * @param attr - attribute name, can be complex like `attr1.attr2.attr3`\n */\nexport function deleteObjectAttribute(obj: Record<string, any>, attr: string): void {\n // Optimization for 98% of the cases\n if (!attr.includes('.')) {\n delete obj[attr];\n return;\n }\n\n _deleteObjectAttribute(obj, attr.split('.'), 0);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;AAAA,mBAOO;AACP,kCAAmE;AACnE,uBAAiB;AACjB,sBAAe;AAwBT,SAAU,sBAAsB,gBAAuC;AACzE,MAAI,KAAC,uBAAS,eAAe,iBAAiB,GAAG;AAC7C,WAAO,CAAC,CAAC,eAAe;EAC5B;AAEA,SAAO,OAAO,OAAO,eAAe,iBAAiB,EAAE,KAAK,SAAO,QAAQ,KAAK,MAAM;AAC1F;AAKM,SAAU,uBAAoB;AAChC,aAAO,4BAAAA,sBAA0B;AACrC;AAOM,SAAU,aAAa,SAA4B;AACrD,QAAM,EAAE,QAAQ,KAAK,KAAI,IAAK;AAE9B,aAAW,QAAQ,MAAM;AACrB,UAAM,MAAM,mBAAmB,KAAK,IAAI;AACxC,QAAI,MAAM,QAAQ,GAAG,GAAG;AACpB,YAAM,YAAsB,CAAA;AAC5B,eAAS,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK;AACjC,kBAAU,CAAC,IAAI,OAAO,IAAI,CAAC,MAAM,eAAW,sBAAQ,QAAQ,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC;MAC/E;AACA,yBAAmB,KAAK,MAAM,SAAS;IAC3C,WAAW,OAAO,QAAQ,UAAU;AAChC,yBAAmB,KAAK,UAAM,sBAAQ,QAAQ,GAAG,CAAC;IACt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f;EACJ;AAEA,yBAAuB,KAAK,KAAK,MAAM,GAAG,GAAG,CAAC;AAClD;",
4
+ "sourcesContent": ["import {\n isObject,\n encrypt,\n decrypt,\n appNameLowerCase,\n getRootDir,\n execAsync,\n} from '@iobroker/js-controller-common-db/tools';\nimport { getSupportedFeatures as getSupportedFeaturesCommon } from '@iobroker/js-controller-common';\nimport path from 'node:path';\nimport fs from 'fs-extra';\n\ninterface EncryptArrayOptions {\n /** The objects whose values should be en/decrypted */\n obj: Record<string, unknown>;\n /** Keys which need to be en/decrypted */\n keys: string[];\n /** Secret to use for en/decryption */\n secret: string;\n}\n\ninterface GetScopedPackageIdentifierOptions {\n /** Name of the node module */\n moduleName: string;\n /** Adapter namespace */\n namespace: string;\n}\n\n/**\n * Check if messagebox is configured for given instance\n * This means, at least one of the properties has a value different from false\n *\n * @param instanceCommon Instance common\n */\nexport function isMessageboxSupported(instanceCommon: ioBroker.InstanceCommon): boolean {\n if (!isObject(instanceCommon.supportedMessages)) {\n return !!instanceCommon.messagebox;\n }\n\n return Object.values(instanceCommon.supportedMessages).find(val => val !== false) !== undefined;\n}\n\n/**\n * Get the supported features for the current running controller\n */\nexport function getSupportedFeatures(): ioBroker.SupportedFeature[] {\n return getSupportedFeaturesCommon();\n}\n\n/**\n * Encrypt given keys of given object\n *\n * @param options keys, object and secret information\n */\nexport function encryptArray(options: EncryptArrayOptions): void {\n const { secret, obj, keys } = options;\n\n for (const attr of keys) {\n const val = getObjectAttribute(obj, attr);\n if (Array.isArray(val)) {\n const encrypted: string[] = [];\n for (let i = 0; i < val.length; i++) {\n encrypted[i] = typeof val[i] === 'string' ? encrypt(secret, val[i]) : val[i];\n }\n setObjectAttribute(obj, attr, encrypted);\n } else if (typeof val === 'string') {\n setObjectAttribute(obj, attr, encrypt(secret, val));\n }\n }\n}\n\n/**\n * Decrypt given keys of given object\n *\n * @param options keys, object and secret information\n */\nexport function decryptArray(options: EncryptArrayOptions): void {\n const { secret, obj, keys } = options;\n\n for (const attr of keys) {\n const val = getObjectAttribute(obj, attr);\n if (Array.isArray(val)) {\n const decrypted: string[] = [];\n for (let i = 0; i < val.length; i++) {\n decrypted[i] = typeof val[i] === 'string' ? decrypt(secret, val[i]) : val[i];\n }\n setObjectAttribute(obj, attr, decrypted);\n } else if (typeof val === 'string') {\n setObjectAttribute(obj, attr, decrypt(secret, val));\n }\n }\n}\n\n/**\n * Transform a npm moduleName to the adapter scoped name, like `axios` to `@iobroker-javascript.0/axios`\n *\n * @param options name of the node module and namespace information\n */\nexport function getAdapterScopedPackageIdentifier(options: GetScopedPackageIdentifierOptions): string {\n const { moduleName, namespace } = options;\n\n let internalModuleName = moduleName;\n if (internalModuleName.startsWith('@')) {\n internalModuleName = internalModuleName.substring(1).replace(/\\//g, '-');\n }\n\n return `@${appNameLowerCase}-${namespace}/${internalModuleName}`;\n}\n\n/**\n * List all packages installed in the given adapter namespace\n *\n * @param namespace namespace to check installed modules for\n */\nexport async function listInstalledNodeModules(namespace: string): Promise<string[]> {\n const packJson = (await fs.readJson(path.join(getRootDir(), 'package.json'))) as {\n dependencies: Record<string, string>;\n };\n const dependencies: string[] = [];\n\n for (const [dependency, versionInfo] of Object.entries(packJson.dependencies)) {\n if (!dependency.startsWith(`@${appNameLowerCase}-${namespace}/`)) {\n continue;\n }\n\n let realDependencyName: string;\n // remove npm: and version after last @\n if (versionInfo.startsWith('npm:')) {\n realDependencyName = versionInfo.substring(4, versionInfo.lastIndexOf('@'));\n } else {\n realDependencyName = await requestModuleNameByUrl(versionInfo);\n }\n\n dependencies.push(realDependencyName);\n }\n\n return dependencies;\n}\n\n/**\n * Request a module name by given url using `npm view`\n *\n * @param url the url to the package which should be installed via npm\n */\nexport async function requestModuleNameByUrl(url: string): Promise<string> {\n const res = await execAsync(`npm view ${url} name`);\n\n if (typeof res.stdout !== 'string') {\n throw new Error(`Could not determine module name for url \"${url}\". Unexpected stdout: \"${typeof res.stdout}\"`);\n }\n\n return res.stdout.trim();\n}\n\n/**\n * Get attribute of an object with complex names\n *\n * @param obj - object to get the attribute from\n * @param attrParts - attribute parts\n * @param index - index of attribute part\n */\nfunction _getObjectAttribute(obj: Record<string, any>, attrParts: string[], index: number): any {\n if (index === attrParts.length - 1) {\n return obj[attrParts[index]];\n }\n if (!obj[attrParts[index]] || typeof obj[attrParts[index]] !== 'object') {\n return;\n }\n if (Array.isArray(obj[attrParts[index]])) {\n const result: any = [];\n for (let i = 0; i < obj[attrParts[index]].length; i++) {\n result.push(_getObjectAttribute(obj[attrParts[index]][i], attrParts, index + 1));\n }\n return result;\n }\n\n return _getObjectAttribute(obj[attrParts[index]], attrParts, index + 1);\n}\n\n/**\n * Get attribute of an object with complex or simple names\n *\n * @param obj - object to get the attribute from\n * @param attr - attribute name, can be complex like `attr1.attr2.attr3`\n * @returns could be a value or an array\n */\nexport function getObjectAttribute(obj: Record<string, any>, attr: string): any {\n // Optimization for 98% of the cases\n if (!attr.includes('.')) {\n return obj[attr];\n }\n return _getObjectAttribute(obj, attr.split('.'), 0);\n}\n\n/**\n * Set attribute in an object with complex names\n *\n * @param obj - object to get the attribute from\n * @param value - value to set (Could be an array)\n * @param attrParts - attribute parts\n * @param index - index of attribute part\n */\nfunction _setObjectAttribute(obj: Record<string, any>, value: any, attrParts: string[], index: number): any {\n if (index === attrParts.length - 1) {\n obj[attrParts[index]] = value;\n return;\n }\n if (!obj[attrParts[index]] || typeof obj[attrParts[index]] !== 'object') {\n return;\n }\n if (Array.isArray(obj[attrParts[index]])) {\n if (!Array.isArray(value)) {\n throw new Error('Value is not an array');\n }\n for (let i = 0; i < obj[attrParts[index]].length; i++) {\n _setObjectAttribute(obj[attrParts[index]][i], value[i], attrParts, index + 1);\n }\n return;\n }\n\n _setObjectAttribute(obj[attrParts[index]], value, attrParts, index + 1);\n}\n\n/**\n * Set attribute in an object with complex or simple names\n *\n * @param obj - object to get the attribute from\n * @param attr - attribute name, can be complex like `attr1.attr2.attr3`\n * @param value - value to set (could be a value or an array)\n */\nexport function setObjectAttribute(obj: Record<string, any>, attr: string, value: any): void {\n // Optimization for 98% of the cases\n if (!attr.includes('.')) {\n obj[attr] = value;\n return;\n }\n _setObjectAttribute(obj, value, attr.split('.'), 0);\n}\n\n/**\n * Delete attribute in an object with complex names\n *\n * @param obj - object to get the attribute from\n * @param attrParts - attribute parts\n * @param index - index of attribute part\n */\nfunction _deleteObjectAttribute(obj: Record<string, any>, attrParts: string[], index: number): any {\n if (index === attrParts.length - 1) {\n delete obj[attrParts[index]];\n return;\n }\n if (!obj[attrParts[index]] || typeof obj[attrParts[index]] !== 'object') {\n return;\n }\n if (Array.isArray(obj[attrParts[index]])) {\n for (let i = 0; i < obj[attrParts[index]].length; i++) {\n _deleteObjectAttribute(obj[attrParts[index]][i], attrParts, index + 1);\n }\n return;\n }\n\n _deleteObjectAttribute(obj[attrParts[index]], attrParts, index + 1);\n}\n\n/**\n * Delete attribute in an object with complex names\n *\n * @param obj - object to get the attribute from\n * @param attr - attribute name, can be complex like `attr1.attr2.attr3`\n */\nexport function deleteObjectAttribute(obj: Record<string, any>, attr: string): void {\n // Optimization for 98% of the cases\n if (!attr.includes('.')) {\n delete obj[attr];\n return;\n }\n\n _deleteObjectAttribute(obj, attr.split('.'), 0);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;AAAA,mBAOO;AACP,kCAAmE;AACnE,uBAAiB;AACjB,sBAAe;AAwBT,SAAU,sBAAsB,gBAAuC;AACzE,MAAI,KAAC,uBAAS,eAAe,iBAAiB,GAAG;AAC7C,WAAO,CAAC,CAAC,eAAe;EAC5B;AAEA,SAAO,OAAO,OAAO,eAAe,iBAAiB,EAAE,KAAK,SAAO,QAAQ,KAAK,MAAM;AAC1F;AANgB;AAWV,SAAU,uBAAoB;AAChC,aAAO,4BAAAA,sBAA0B;AACrC;AAFgB;AASV,SAAU,aAAa,SAA4B;AACrD,QAAM,EAAE,QAAQ,KAAK,KAAI,IAAK;AAE9B,aAAW,Q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KAAK,OAAO,IAAI,UAAU,KAAK,CAAC,MAAM,UAAU;AACrE;EACJ;AACA,MAAI,MAAM,QAAQ,IAAI,UAAU,KAAK,CAAC,CAAC,GAAG;AACtC,aAAS,IAAI,GAAG,IAAI,IAAI,UAAU,KAAK,CAAC,EAAE,QAAQ,KAAK;AACnD,6BAAuB,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC,GAAG,WAAW,QAAQ,CAAC;IACzE;AACA;EACJ;AAEA,yBAAuB,IAAI,UAAU,KAAK,CAAC,GAAG,WAAW,QAAQ,CAAC;AACtE;AAhBS;AAwBH,SAAU,sBAAsB,KAA0B,MAAY;AAExE,MAAI,CAAC,KAAK,SAAS,GAAG,GAAG;AACrB,WAAO,IAAI,IAAI;AACf;EACJ;AAEA,yBAAuB,KAAK,KAAK,MAAM,GAAG,GAAG,CAAC;AAClD;AARgB;",
6
6
  "names": ["getSupportedFeaturesCommon", "fs", "path"]
7
7
  }
@@ -1,15 +1,21 @@
1
+ import type { Client as ObjectsInRedisClient } from '../../../../db-objects-redis/src/index.js';
1
2
  type Callback = (...args: any[]) => void | Promise<void>;
2
3
  type OptionalCallback = undefined | Callback;
3
4
  type Pattern = string | string[];
5
+ /** Options for validating an object/state id */
4
6
  export interface ValidateIdOptions {
5
7
  /** in maintenance mode, we can access invalid ids to delete them, only works with the admin user */
6
8
  maintenance?: boolean;
7
9
  /** User used to check for access rights */
8
10
  user?: string;
9
11
  }
12
+ /**
13
+ * Validates arguments passed to the adapter's public methods
14
+ *
15
+ * @internal
16
+ */
10
17
  export declare class Validator {
11
18
  private readonly objects;
12
- private readonly states;
13
19
  private readonly namespaceLog;
14
20
  private readonly log;
15
21
  private readonly namespace;
@@ -18,13 +24,12 @@ export declare class Validator {
18
24
  * Validator for internal adapter.js usage
19
25
  *
20
26
  * @param objects - Objects DB
21
- * @param states - States DB
22
27
  * @param namespaceLog - Log prefix
23
28
  * @param logger - Logger instance
24
29
  * @param namespace - the namespace of the adapter
25
30
  * @param namespaceRegExp - the namespace RegExp of the adapter `adapter.0`
26
31
  */
27
- constructor(objects: any, states: any, namespaceLog: string, logger: any, namespace: string, namespaceRegExp: RegExp);
32
+ constructor(objects: ObjectsInRedisClient, namespaceLog: string, logger: ioBroker.Logger, namespace: string, namespaceRegExp: RegExp);
28
33
  /**
29
34
  * Performs the strict object check, which includes checking object existence, read-only logic, type and min/max
30
35
  * additionally it rounds state values whose objects have a `common.step` attribute defined
@@ -39,9 +44,9 @@ export declare class Validator {
39
44
  * @param id id to check or object with properties device, channel and state
40
45
  * @param isForeignId true&false if the ID is a foreign/full ID or only an "adapter local" id
41
46
  * @param options optional
42
- * @throws Error when id is invalid
47
+ * @throws {Error} when id is invalid
43
48
  */
44
- validateId(id: any, isForeignId: boolean, options?: ValidateIdOptions | null): asserts id is string;
49
+ validateId(id: string, isForeignId: boolean, options?: ValidateIdOptions | null): asserts id is string;
45
50
  /**
46
51
  * Look up the error description for an error code
47
52
  *
@@ -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 });
@@ -24,8 +25,10 @@ module.exports = __toCommonJS(validator_exports);
24
25
  var import_constants = require("../../lib/adapter/constants.js");
25
26
  var import_js_controller_common = require("@iobroker/js-controller-common");
26
27
  class Validator {
28
+ static {
29
+ __name(this, "Validator");
30
+ }
27
31
  objects;
28
- states;
29
32
  namespaceLog;
30
33
  log;
31
34
  namespace;
@@ -34,15 +37,13 @@ class Validator {
34
37
  * Validator for internal adapter.js usage
35
38
  *
36
39
  * @param objects - Objects DB
37
- * @param states - States DB
38
40
  * @param namespaceLog - Log prefix
39
41
  * @param logger - Logger instance
40
42
  * @param namespace - the namespace of the adapter
41
43
  * @param namespaceRegExp - the namespace RegExp of the adapter `adapter.0`
42
44
  */
43
- constructor(objects, states, namespaceLog, logger, namespace, namespaceRegExp) {
45
+ constructor(objects, namespaceLog, logger, namespace, namespaceRegExp) {
44
46
  this.objects = objects;
45
- this.states = states;
46
47
  this.namespaceLog = namespaceLog;
47
48
  this.namespace = namespace;
48
49
  this.namespaceRegExp = namespaceRegExp;
@@ -103,7 +104,7 @@ class Validator {
103
104
  * @param id id to check or object with properties device, channel and state
104
105
  * @param isForeignId true&false if the ID is a foreign/full ID or only an "adapter local" id
105
106
  * @param options optional
106
- * @throws Error when id is invalid
107
+ * @throws {Error} when id is invalid
107
108
  */
108
109
  validateId(id, isForeignId, options) {
109
110
  if (options && options.maintenance && options.user === import_constants.SYSTEM_ADMIN_USER) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/adapter/validator.ts"],
4
- "sourcesContent": ["import { MAX_TIMEOUT, SYSTEM_ADMIN_USER } from '@/lib/adapter/constants.js';\nimport { tools, EXIT_CODES } from '@iobroker/js-controller-common';\n\ntype Callback = (...args: any[]) => void | Promise<void>;\ntype OptionalCallback = undefined | Callback;\ntype Pattern = string | string[];\n\nexport interface ValidateIdOptions {\n /** in maintenance mode, we can access invalid ids to delete them, only works with the admin user */\n maintenance?: boolean;\n /** User used to check for access rights */\n user?: string;\n}\n\nexport class Validator {\n private readonly objects: any;\n private readonly states: any;\n private readonly namespaceLog: string;\n private readonly log: any;\n private readonly namespace: string;\n private readonly namespaceRegExp: RegExp;\n\n /**\n * Validator for internal adapter.js usage\n *\n * @param objects - Objects DB\n * @param states - States DB\n * @param namespaceLog - Log prefix\n * @param logger - Logger instance\n * @param namespace - the namespace of the adapter\n * @param namespaceRegExp - the namespace RegExp of the adapter `adapter.0`\n */\n constructor(\n objects: any,\n states: any,\n namespaceLog: string,\n logger: any,\n namespace: string,\n namespaceRegExp: RegExp,\n ) {\n this.objects = objects;\n this.states = states;\n this.namespaceLog = namespaceLog;\n this.namespace = namespace;\n this.namespaceRegExp = namespaceRegExp;\n this.log = logger;\n }\n\n /**\n * Performs the strict object check, which includes checking object existence, read-only logic, type and min/max\n * additionally it rounds state values whose objects have a `common.step` attribute defined\n *\n * @param id - id of the state\n * @param state - ioBroker setState object\n */\n async performStrictObjectCheck(id: string, state: ioBroker.SettableState): Promise<void> {\n // TODO: in js-c 3.5 (or 2 releases after 3.3) we should let it throw and add tests, maybe we\n // can already let the non existing object case throw with 3.4 because this is already producing a warning\n try {\n if (state.val === undefined) {\n // only ack etc. is also possible to acknowledge the current value,\n // if only undefined provided, it should have thrown before\n return;\n }\n\n const obj = await this.objects.getObjectAsync(id);\n // at first check object existence\n if (!obj) {\n this.log.warn(\n `${this.namespaceLog} State \"${id}\" has no existing object, this might lead to an error in future versions`,\n );\n return;\n }\n\n // for a state object, we require common.type to exist\n if (obj.common?.type) {\n // check if we are allowed to write (read-only can only be written with ack: true)\n if (!state.ack && obj.common.write === false) {\n this.log.warn(\n `${this.namespaceLog} Read-only state \"${id}\" has been written without ack-flag with value \"${state.val}\"`,\n );\n }\n\n if (state.val !== null) {\n // now check if a type is correct, null is always allowed\n if (\n !(\n (obj.common.type === 'mixed' && typeof state.val !== 'object') ||\n (obj.common.type !== 'object' && obj.common.type === typeof state.val) ||\n (obj.common.type === 'array' && typeof state.val === 'string') ||\n (obj.common.type === 'json' && typeof state.val === 'string') ||\n (obj.common.type === 'object' && typeof state.val === 'string')\n )\n ) {\n // types can be 'number', 'string', 'boolean', 'array', 'object', 'mixed', 'json';\n // 'array', 'object', 'json' need to be string\n if (['object', 'json', 'array'].includes(obj.common.type)) {\n this.log.info(\n `${\n this.namespaceLog\n } State value to set for \"${id}\" has to be stringified but received type \"${typeof state.val}\"`,\n );\n } else {\n this.log.info(\n `${this.namespaceLog} State value to set for \"${id}\" has to be ${\n obj.common.type === 'mixed'\n ? `one of type \"string\", \"number\", \"boolean\"`\n : `type \"${obj.common.type}\"`\n } but received type \"${typeof state.val}\" `,\n );\n }\n }\n\n // now round step and check min/max if it's a number\n if (typeof state.val === 'number') {\n if (typeof obj.common.step === 'number' && obj.common.step > 0) {\n // round to next step\n const inv = 1 / obj.common.step;\n state.val = Math.round(state.val * inv) / inv;\n }\n\n if (obj.common.max !== undefined && state.val > obj.common.max) {\n this.log.warn(\n `${this.namespaceLog} State value to set for \"${id}\" has value \"${state.val}\" greater than max \"${obj.common.max}\"`,\n );\n }\n\n if (obj.common.min !== undefined && state.val < obj.common.min) {\n this.log.warn(\n `${this.namespaceLog} State value to set for \"${id}\" has value \"${state.val}\" less than min \"${obj.common.min}\"`,\n );\n }\n }\n }\n } else {\n this.log.warn(\n `${this.namespaceLog} Object of state \"${id}\" is missing the required property \"common.type\"`,\n );\n }\n } catch (e) {\n this.log.warn(`${this.namespaceLog} Could not perform strict object check of state ${id}: ${e.message}`);\n }\n }\n\n /**\n * Checks if a passed ID is valid. Throws an error if id is invalid\n *\n * @param id id to check or object with properties device, channel and state\n * @param isForeignId true&false if the ID is a foreign/full ID or only an \"adapter local\" id\n * @param options optional\n * @throws Error when id is invalid\n */\n validateId(id: any, isForeignId: boolean, options?: ValidateIdOptions | null): asserts id is string {\n // there is a special maintenance mode to clear the DB from invalid IDs\n if (options && options.maintenance && options.user === SYSTEM_ADMIN_USER) {\n return;\n }\n\n if (!id && id !== 0) {\n throw new Error('The id is empty! Please provide a valid id.');\n }\n\n const type = typeof id;\n\n if (!isForeignId && type === 'number') {\n this.log.warn(\n `${this.namespaceLog} The id \"${id}\" has an invalid type! Expected \"string\" or \"object\", received \"number\".`,\n );\n this.log.warn(\n `${this.namespaceLog} This will be refused in future versions. Please report this to the developer.`,\n );\n } else if (type !== 'string' && !tools.isObject(id)) {\n throw new Error(`The id \"${id}\" has an invalid type! Expected \"string\" or \"object\", received \"${type}\".`);\n }\n\n if (tools.isObject(id)) {\n // id can be an object, at least one of the following properties has to exist\n const reqProperties = ['device', 'channel', 'state'];\n let found = false;\n for (const reqProperty of reqProperties) {\n if (id[reqProperty] !== undefined) {\n if (typeof id[reqProperty] !== 'string') {\n throw new Error(\n `The id's property \"${reqProperty}\" of \"${JSON.stringify(\n id,\n )}\" has an invalid type! Expected \"string\", received \"${typeof id[reqProperty]}\".`,\n );\n }\n\n if (id[reqProperty].includes('.')) {\n throw new Error(\n `The id's property \"${reqProperty}\" of \"${JSON.stringify(\n id,\n )}\" contains the invalid character \".\"!`,\n );\n }\n found = true;\n }\n }\n if (!found) {\n throw new Error(\n `The id \"${JSON.stringify(\n id,\n )}\" is an invalid object! Expected at least one of the properties \"device\", \"channel\" or \"state\" to exist.`,\n );\n }\n } else {\n if (type !== 'string') {\n throw new Error(\n `The id \"${JSON.stringify(id)}\" has an invalid type! Expected \"string\", received \"${type}\".`,\n );\n }\n if (id.endsWith('.')) {\n throw new Error(`The id \"${id}\" is invalid. Ids are not allowed to end in \".\"`);\n }\n }\n }\n\n /**\n * Look up the error description for an error code\n *\n * @param code error code\n * @returns error description\n */\n static getErrorText(code: number): string {\n code = code || 0;\n return (EXIT_CODES[code] || code).toString();\n }\n\n /**\n * Throws if a type is not matching the expected type\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertString(value: unknown, name: string): asserts value is string {\n if (typeof value !== 'string') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"string\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Throws if a type is not a pattern\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertPattern(value: unknown, name: string): asserts value is Pattern {\n if (typeof value !== 'string' && !Array.isArray(value)) {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"string\" or an array of type \"string\", \"${typeof value}\" has been passed`,\n );\n } else if (Array.isArray(value)) {\n for (const entry of value) {\n if (typeof entry !== 'string') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"string\" or an array of type \"string\", but the array contains a value of type \"${typeof value}\"`,\n );\n }\n }\n }\n }\n\n /**\n * Throws if a type is not matching the expected type\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertBoolean(value: unknown, name: string): asserts value is boolean {\n if (typeof value !== 'boolean') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"boolean\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Throws if a type is not matching the expected type\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertNumber(value: unknown, name: string): asserts value is number {\n if (typeof value !== 'number') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"number\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Throws if a type is not matching the expected type\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertObject<T extends Record<string, any> = Record<string, any>>(\n value: unknown,\n name: string,\n ): asserts value is T {\n if (!tools.isObject(value)) {\n throw new Error(`Parameter \"${name}\" needs to be a real object but type \"${typeof value}\" has been passed`);\n }\n }\n\n /**\n * Throws if a type is not an optional callback\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertBuffer(value: unknown, name: string): asserts value is Buffer {\n if (!Buffer.isBuffer(value)) {\n throw new Error(`Parameter \"${name}\" needs to be a Buffer but type \"${typeof value}\" has been passed`);\n }\n }\n\n /**\n * Throws if a type is not an optional callback\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertOptionalCallback(value: unknown, name: string): asserts value is OptionalCallback {\n if (value && typeof value !== 'function') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"null\", \"undefined\" or \"function\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Throws if a type is not an optional callback\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertCallback(value: unknown, name: string): asserts value is Callback {\n if (typeof value !== 'function') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"function\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Adds the namespace to the ID if it is missing, if an object is passed it will be converted to an id string\n *\n * @param id id which will be fixed\n * @param isPattern if the id is a pattern\n */\n fixId(id: string | ioBroker.IdObject, isPattern = false): string {\n if (!id) {\n id = '';\n }\n\n let result = '';\n if (typeof id === 'string') {\n result = id;\n\n // if not the instance name itself and also not starts with namespace and \".\"\n if (id !== this.namespace && !this.namespaceRegExp.test(id)) {\n if (!isPattern) {\n result = this.namespace + (id ? `.${id}` : '');\n } else {\n result = `${this.namespace}.${id ? id : ''}`;\n }\n }\n } else if (tools.isObject(id)) {\n // If ID is an object\n // Add namespace + device + channel\n result = `${this.namespace}.${id.device ? `${id.device}.` : ''}${id.channel ? `${id.channel}.` : ''}${\n id.state ? id.state : ''\n }`;\n }\n return result;\n }\n\n /**\n * Validates the object-type argument that is passed to setState\n *\n * @param obj object to validate\n */\n validateSetStateObjectArgument(obj: Record<string, any>): void {\n // Check that we have at least one existing non-undefined property at all, else invalid\n if (!Object.values(obj).some(prop => prop !== undefined)) {\n throw new Error(`The state contains no properties! At least one property is expected!`);\n }\n\n /*\n The following object parameters and types are allowed:\n val: any, (optional)\n ack: boolean, (optional)\n ts: number, (optional)\n q: number, (optional)\n from: string, (optional)\n c: string, (optional)\n expire: number (optional)\n lc: number (optional)\n user: string (optional)\n\n Everything else is forbidden\n */\n const optionalProperties: Record<string, string> = {\n val: 'any',\n ack: 'boolean',\n ts: 'number',\n q: 'number',\n from: 'string',\n c: 'string',\n expire: 'number',\n lc: 'number',\n user: 'string',\n };\n\n // Are there any forbidden properties?\n const forbiddenProperties = Object.keys(obj).filter(k => !optionalProperties[k]);\n if (forbiddenProperties.length) {\n throw new Error(`The state contains the forbidden properties ${forbiddenProperties.join(', ')}!`);\n }\n // Do all properties have the correct type?\n for (const [key, type] of Object.entries(optionalProperties)) {\n // any permits all types\n if (type === 'any') {\n continue;\n }\n // don't flag optional properties when they don't exist or are undefined\n if (!(key in obj) || obj[key] === undefined) {\n continue;\n }\n if (type !== typeof obj[key]) {\n throw new Error(\n `The state property \"${key}\" has the wrong type \"${typeof obj[key]}\" (should be \"${type}\")!`,\n );\n }\n }\n }\n\n /**\n * Validates that the timeout is not exceeding a 32-bit signed integer\n *\n * @param ms milliseconds to validate\n */\n static assertTimeout(ms: number): void {\n if (ms > MAX_TIMEOUT) {\n throw new Error(`Timeout (${ms}) is larger than a 32-bit signed integer (${MAX_TIMEOUT})`);\n }\n\n if (ms < 0) {\n throw new Error(`Timeout (${ms}) is smaller than 0`);\n }\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,uBAA+C;AAC/C,kCAAkC;AAa5B,MAAO,UAAS;EACD;EACA;EACA;EACA;EACA;EACA;;;;;;;;;;;EAYjB,YACI,SACA,QACA,cACA,QACA,WACA,iBAAuB;AAEvB,SAAK,UAAU;AACf,SAAK,SAAS;AACd,SAAK,eAAe;AACpB,SAAK,YAAY;AACjB,SAAK,kBAAkB;AACvB,SAAK,MAAM;EACf;;;;;;;;EASA,MAAM,yBAAyB,IAAY,OAA6B;AAGpE,QAAI;AACA,UAAI,MAAM,QAAQ,QAAW;AAGzB;MACJ;AAEA,YAAM,MAAM,MAAM,KAAK,QAAQ,eAAe,EAAE;AAEhD,UAAI,CAAC,KAAK;AACN,aAAK,IAAI,KACL,GAAG,KAAK,YAAY,WAAW,EAAE,0EAA0E;AAE/G;MACJ;AAGA,UAAI,IAAI,QAAQ,MAAM;AAElB,YAAI,CAAC,MAAM,OAAO,IAAI,OAAO,UAAU,OAAO;AAC1C,eAAK,IAAI,KACL,GAAG,KAAK,YAAY,qBAAqB,EAAE,mDAAmD,MAAM,GAAG,GAAG;QAElH;AAEA,YAAI,MAAM,QAAQ,MAAM;AAEpB,cACI,EACK,IAAI,OAAO,SAAS,WAAW,OAAO,MAAM,QAAQ,YACpD,IAAI,OAAO,SAAS,YAAY,IAAI,OAAO,SAAS,OAAO,MAAM,OACjE,IAAI,OAAO,SAAS,WAAW,OAAO,MAAM,QAAQ,YACpD,IAAI,OAAO,SAAS,UAAU,OAA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QAAQ;AAC5B,YAAM,IAAI,MAAM,+CAA+C,oBAAoB,KAAK,IAAI,CAAC,GAAG;IACpG;AAEA,eAAW,CAAC,KAAK,IAAI,KAAK,OAAO,QAAQ,kBAAkB,GAAG;AAE1D,UAAI,SAAS,OAAO;AAChB;MACJ;AAEA,UAAI,EAAE,OAAO,QAAQ,IAAI,GAAG,MAAM,QAAW;AACzC;MACJ;AACA,UAAI,SAAS,OAAO,IAAI,GAAG,GAAG;AAC1B,cAAM,IAAI,MACN,uBAAuB,GAAG,yBAAyB,OAAO,IAAI,GAAG,CAAC,iBAAiB,IAAI,KAAK;MAEpG;IACJ;EACJ;;;;;;EAOA,OAAO,cAAc,IAAU;AAC3B,QAAI,KAAK,8BAAa;AAClB,YAAM,IAAI,MAAM,YAAY,EAAE,6CAA6C,4BAAW,GAAG;IAC7F;AAEA,QAAI,KAAK,GAAG;AACR,YAAM,IAAI,MAAM,YAAY,EAAE,qBAAqB;IACvD;EACJ;;",
4
+ "sourcesContent": ["import { MAX_TIMEOUT, SYSTEM_ADMIN_USER } from '@/lib/adapter/constants.js';\nimport { tools, EXIT_CODES } from '@iobroker/js-controller-common';\nimport type { Client as ObjectsInRedisClient } from '../../../../db-objects-redis/src/index.js';\n\ntype Callback = (...args: any[]) => void | Promise<void>;\ntype OptionalCallback = undefined | Callback;\ntype Pattern = string | string[];\n\n/** Options for validating an object/state id */\nexport interface ValidateIdOptions {\n /** in maintenance mode, we can access invalid ids to delete them, only works with the admin user */\n maintenance?: boolean;\n /** User used to check for access rights */\n user?: string;\n}\n\n/**\n * Validates arguments passed to the adapter's public methods\n *\n * @internal\n */\nexport class Validator {\n private readonly objects: ObjectsInRedisClient;\n private readonly namespaceLog: string;\n private readonly log: ioBroker.Logger;\n private readonly namespace: string;\n private readonly namespaceRegExp: RegExp;\n\n /**\n * Validator for internal adapter.js usage\n *\n * @param objects - Objects DB\n * @param namespaceLog - Log prefix\n * @param logger - Logger instance\n * @param namespace - the namespace of the adapter\n * @param namespaceRegExp - the namespace RegExp of the adapter `adapter.0`\n */\n constructor(\n objects: ObjectsInRedisClient,\n namespaceLog: string,\n logger: ioBroker.Logger,\n namespace: string,\n namespaceRegExp: RegExp,\n ) {\n this.objects = objects;\n this.namespaceLog = namespaceLog;\n this.namespace = namespace;\n this.namespaceRegExp = namespaceRegExp;\n this.log = logger;\n }\n\n /**\n * Performs the strict object check, which includes checking object existence, read-only logic, type and min/max\n * additionally it rounds state values whose objects have a `common.step` attribute defined\n *\n * @param id - id of the state\n * @param state - ioBroker setState object\n */\n async performStrictObjectCheck(id: string, state: ioBroker.SettableState): Promise<void> {\n // TODO: in js-c 3.5 (or 2 releases after 3.3) we should let it throw and add tests, maybe we\n // can already let the non existing object case throw with 3.4 because this is already producing a warning\n try {\n if (state.val === undefined) {\n // only ack etc. is also possible to acknowledge the current value,\n // if only undefined provided, it should have thrown before\n return;\n }\n\n const obj = await this.objects.getObjectAsync(id);\n // at first check object existence\n if (!obj) {\n this.log.warn(\n `${this.namespaceLog} State \"${id}\" has no existing object, this might lead to an error in future versions`,\n );\n return;\n }\n\n // for a state object, we require common.type to exist\n if (obj.common?.type) {\n // check if we are allowed to write (read-only can only be written with ack: true)\n if (!state.ack && obj.common.write === false) {\n this.log.warn(\n `${this.namespaceLog} Read-only state \"${id}\" has been written without ack-flag with value \"${state.val}\"`,\n );\n }\n\n if (state.val !== null) {\n // now check if a type is correct, null is always allowed\n if (!(\n (obj.common.type === 'mixed' && typeof state.val !== 'object') ||\n (obj.common.type !== 'object' && obj.common.type === typeof state.val) ||\n (obj.common.type === 'array' && typeof state.val === 'string') ||\n (obj.common.type === 'json' && typeof state.val === 'string') ||\n (obj.common.type === 'object' && typeof state.val === 'string')\n )) {\n // types can be 'number', 'string', 'boolean', 'array', 'object', 'mixed', 'json';\n // 'array', 'object', 'json' need to be string\n if (['object', 'json', 'array'].includes(obj.common.type)) {\n this.log.info(\n `${\n this.namespaceLog\n } State value to set for \"${id}\" has to be stringified but received type \"${typeof state.val}\"`,\n );\n } else {\n this.log.info(\n `${this.namespaceLog} State value to set for \"${id}\" has to be ${\n obj.common.type === 'mixed'\n ? `one of type \"string\", \"number\", \"boolean\"`\n : `type \"${obj.common.type}\"`\n } but received type \"${typeof state.val}\" `,\n );\n }\n }\n\n // now round step and check min/max if it's a number\n if (typeof state.val === 'number') {\n if (typeof obj.common.step === 'number' && obj.common.step > 0) {\n // round to next step\n const inv = 1 / obj.common.step;\n state.val = Math.round(state.val * inv) / inv;\n }\n\n if (obj.common.max !== undefined && state.val > obj.common.max) {\n this.log.warn(\n `${this.namespaceLog} State value to set for \"${id}\" has value \"${state.val}\" greater than max \"${obj.common.max}\"`,\n );\n }\n\n if (obj.common.min !== undefined && state.val < obj.common.min) {\n this.log.warn(\n `${this.namespaceLog} State value to set for \"${id}\" has value \"${state.val}\" less than min \"${obj.common.min}\"`,\n );\n }\n }\n }\n } else {\n this.log.warn(\n `${this.namespaceLog} Object of state \"${id}\" is missing the required property \"common.type\"`,\n );\n }\n } catch (e) {\n this.log.warn(`${this.namespaceLog} Could not perform strict object check of state ${id}: ${e.message}`);\n }\n }\n\n /**\n * Checks if a passed ID is valid. Throws an error if id is invalid\n *\n * @param id id to check or object with properties device, channel and state\n * @param isForeignId true&false if the ID is a foreign/full ID or only an \"adapter local\" id\n * @param options optional\n * @throws {Error} when id is invalid\n */\n validateId(id: string, isForeignId: boolean, options?: ValidateIdOptions | null): asserts id is string {\n // there is a special maintenance mode to clear the DB from invalid IDs\n if (options && options.maintenance && options.user === SYSTEM_ADMIN_USER) {\n return;\n }\n\n // @ts-expect-error could happen\n if (!id && id !== 0) {\n throw new Error('The id is empty! Please provide a valid id.');\n }\n\n const type = typeof id;\n\n if (!isForeignId && type === 'number') {\n this.log.warn(\n `${this.namespaceLog} The id \"${id}\" has an invalid type! Expected \"string\" or \"object\", received \"number\".`,\n );\n this.log.warn(\n `${this.namespaceLog} This will be refused in future versions. Please report this to the developer.`,\n );\n } else if (type !== 'string' && !tools.isObject(id)) {\n throw new Error(`The id \"${id}\" has an invalid type! Expected \"string\" or \"object\", received \"${type}\".`);\n }\n\n if (tools.isObject(id)) {\n // id can be an object, at least one of the following properties has to exist\n const reqProperties = ['device', 'channel', 'state'];\n let found = false;\n for (const reqProperty of reqProperties) {\n if (id[reqProperty] !== undefined) {\n if (typeof id[reqProperty] !== 'string') {\n throw new Error(\n `The id's property \"${reqProperty}\" of \"${JSON.stringify(\n id,\n )}\" has an invalid type! Expected \"string\", received \"${typeof id[reqProperty]}\".`,\n );\n }\n\n if (id[reqProperty].includes('.')) {\n throw new Error(\n `The id's property \"${reqProperty}\" of \"${JSON.stringify(\n id,\n )}\" contains the invalid character \".\"!`,\n );\n }\n found = true;\n }\n }\n if (!found) {\n throw new Error(\n `The id \"${JSON.stringify(\n id,\n )}\" is an invalid object! Expected at least one of the properties \"device\", \"channel\" or \"state\" to exist.`,\n );\n }\n } else {\n if (type !== 'string') {\n throw new Error(\n `The id \"${JSON.stringify(id)}\" has an invalid type! Expected \"string\", received \"${type}\".`,\n );\n }\n if (id.endsWith('.')) {\n throw new Error(`The id \"${id}\" is invalid. Ids are not allowed to end in \".\"`);\n }\n }\n }\n\n /**\n * Look up the error description for an error code\n *\n * @param code error code\n * @returns error description\n */\n static getErrorText(code: number): string {\n code = code || 0;\n return (EXIT_CODES[code] || code).toString();\n }\n\n /**\n * Throws if a type is not matching the expected type\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertString(value: unknown, name: string): asserts value is string {\n if (typeof value !== 'string') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"string\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Throws if a type is not a pattern\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertPattern(value: unknown, name: string): asserts value is Pattern {\n if (typeof value !== 'string' && !Array.isArray(value)) {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"string\" or an array of type \"string\", \"${typeof value}\" has been passed`,\n );\n } else if (Array.isArray(value)) {\n for (const entry of value) {\n if (typeof entry !== 'string') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"string\" or an array of type \"string\", but the array contains a value of type \"${typeof value}\"`,\n );\n }\n }\n }\n }\n\n /**\n * Throws if a type is not matching the expected type\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertBoolean(value: unknown, name: string): asserts value is boolean {\n if (typeof value !== 'boolean') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"boolean\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Throws if a type is not matching the expected type\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertNumber(value: unknown, name: string): asserts value is number {\n if (typeof value !== 'number') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"number\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Throws if a type is not matching the expected type\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertObject<T extends Record<string, any> = Record<string, any>>(\n value: unknown,\n name: string,\n ): asserts value is T {\n if (!tools.isObject(value)) {\n throw new Error(`Parameter \"${name}\" needs to be a real object but type \"${typeof value}\" has been passed`);\n }\n }\n\n /**\n * Throws if a type is not an optional callback\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertBuffer(value: unknown, name: string): asserts value is Buffer {\n if (!Buffer.isBuffer(value)) {\n throw new Error(`Parameter \"${name}\" needs to be a Buffer but type \"${typeof value}\" has been passed`);\n }\n }\n\n /**\n * Throws if a type is not an optional callback\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertOptionalCallback(value: unknown, name: string): asserts value is OptionalCallback {\n if (value && typeof value !== 'function') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"null\", \"undefined\" or \"function\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Throws if a type is not an optional callback\n *\n * @param value value to check a type of\n * @param name name of the parameter for logging\n */\n static assertCallback(value: unknown, name: string): asserts value is Callback {\n if (typeof value !== 'function') {\n throw new Error(\n `Parameter \"${name}\" needs to be of type \"function\" but type \"${typeof value}\" has been passed`,\n );\n }\n }\n\n /**\n * Adds the namespace to the ID if it is missing, if an object is passed it will be converted to an id string\n *\n * @param id id which will be fixed\n * @param isPattern if the id is a pattern\n */\n fixId(id: string | ioBroker.IdObject, isPattern = false): string {\n if (!id) {\n id = '';\n }\n\n let result = '';\n if (typeof id === 'string') {\n result = id;\n\n // if not the instance name itself and also not starts with namespace and \".\"\n if (id !== this.namespace && !this.namespaceRegExp.test(id)) {\n if (!isPattern) {\n result = this.namespace + (id ? `.${id}` : '');\n } else {\n result = `${this.namespace}.${id ? id : ''}`;\n }\n }\n } else if (tools.isObject(id)) {\n // If ID is an object\n // Add namespace + device + channel\n result = `${this.namespace}.${id.device ? `${id.device}.` : ''}${id.channel ? `${id.channel}.` : ''}${\n id.state ? id.state : ''\n }`;\n }\n return result;\n }\n\n /**\n * Validates the object-type argument that is passed to setState\n *\n * @param obj object to validate\n */\n validateSetStateObjectArgument(obj: Record<string, any>): void {\n // Check that we have at least one existing non-undefined property at all, else invalid\n if (!Object.values(obj).some(prop => prop !== undefined)) {\n throw new Error(`The state contains no properties! At least one property is expected!`);\n }\n\n /*\n The following object parameters and types are allowed:\n val: any, (optional)\n ack: boolean, (optional)\n ts: number, (optional)\n q: number, (optional)\n from: string, (optional)\n c: string, (optional)\n expire: number (optional)\n lc: number (optional)\n user: string (optional)\n\n Everything else is forbidden\n */\n const optionalProperties: Record<string, string> = {\n val: 'any',\n ack: 'boolean',\n ts: 'number',\n q: 'number',\n from: 'string',\n c: 'string',\n expire: 'number',\n lc: 'number',\n user: 'string',\n };\n\n // Are there any forbidden properties?\n const forbiddenProperties = Object.keys(obj).filter(k => !optionalProperties[k]);\n if (forbiddenProperties.length) {\n throw new Error(`The state contains the forbidden properties ${forbiddenProperties.join(', ')}!`);\n }\n // Do all properties have the correct type?\n for (const [key, type] of Object.entries(optionalProperties)) {\n // any permits all types\n if (type === 'any') {\n continue;\n }\n // don't flag optional properties when they don't exist or are undefined\n if (!(key in obj) || obj[key] === undefined) {\n continue;\n }\n if (type !== typeof obj[key]) {\n throw new Error(\n `The state property \"${key}\" has the wrong type \"${typeof obj[key]}\" (should be \"${type}\")!`,\n );\n }\n }\n }\n\n /**\n * Validates that the timeout is not exceeding a 32-bit signed integer\n *\n * @param ms milliseconds to validate\n */\n static assertTimeout(ms: number): void {\n if (ms > MAX_TIMEOUT) {\n throw new Error(`Timeout (${ms}) is larger than a 32-bit signed integer (${MAX_TIMEOUT})`);\n }\n\n if (ms < 0) {\n throw new Error(`Timeout (${ms}) is smaller than 0`);\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;AAAA,uBAA+C;AAC/C,kCAAkC;AAoB5B,MAAO,UAAS;EArBtB,OAqBsB;;;EACD;EACA;EACA;EACA;EACA;;;;;;;;;;EAWjB,YACI,SACA,cACA,QACA,WACA,iBAAuB;AAEvB,SAAK,UAAU;AACf,SAAK,eAAe;AACpB,SAAK,YAAY;AACjB,SAAK,kBAAkB;AACvB,SAAK,MAAM;EACf;;;;;;;;EASA,MAAM,yBAAyB,IAAY,OAA6B;AAGpE,QAAI;AACA,UAAI,MAAM,QAAQ,QAAW;AAGzB;MACJ;AAEA,YAAM,MAAM,MAAM,KAAK,QAAQ,eAAe,EAAE;AAEhD,UAAI,CAAC,KAAK;AACN,aAAK,IAAI,KACL,GAAG,KAAK,YAAY,WAAW,EAAE,0EAA0E;AAE/G;MACJ;AAGA,UAAI,IAAI,QAAQ,MAAM;AAElB,YAAI,CAAC,MAAM,OAAO,IAAI,OAAO,UAAU,OAAO;AAC1C,eAAK,IAAI,KACL,GAAG,KAAK,YAAY,qBAAqB,EAAE,mDAAmD,MAAM,GAAG,GAAG;QAElH;AAEA,YAAI,MAAM,QAAQ,MAAM;AAEpB,cAAI,EACC,IAAI,OAAO,SAAS,WAAW,OAAO,MAAM,QAAQ,Y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;MACH,QAAQ;MACR,IAAI;MACJ,MAAM;;AAIV,UAAM,sBAAsB,OAAO,KAAK,GAAG,EAAE,OAAO,OAAK,CAAC,mBAAmB,CAAC,CAAC;AAC/E,QAAI,oBAAoB,QAAQ;AAC5B,YAAM,IAAI,MAAM,+CAA+C,oBAAoB,KAAK,IAAI,CAAC,GAAG;IACpG;AAEA,eAAW,CAAC,KAAK,IAAI,KAAK,OAAO,QAAQ,kBAAkB,GAAG;AAE1D,UAAI,SAAS,OAAO;AAChB;MACJ;AAEA,UAAI,EAAE,OAAO,QAAQ,IAAI,GAAG,MAAM,QAAW;AACzC;MACJ;AACA,UAAI,SAAS,OAAO,IAAI,GAAG,GAAG;AAC1B,cAAM,IAAI,MACN,uBAAuB,GAAG,yBAAyB,OAAO,IAAI,GAAG,CAAC,iBAAiB,IAAI,KAAK;MAEpG;IACJ;EACJ;;;;;;EAOA,OAAO,cAAc,IAAU;AAC3B,QAAI,KAAK,8BAAa;AAClB,YAAM,IAAI,MAAM,YAAY,EAAE,6CAA6C,4BAAW,GAAG;IAC7F;AAEA,QAAI,KAAK,GAAG;AACR,YAAM,IAAI,MAAM,YAAY,EAAE,qBAAqB;IACvD;EACJ;;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,3 @@
1
1
  export { Adapter, AdapterClass } from './lib/adapter/adapter.js';
2
- export { Validator } from './lib/adapter/validator.js';
3
2
  export type * from './lib/_Types.js';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,mBAAmB,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACjE,mBAAmB,iBAAiB,CAAC"}
@@ -1,4 +1,3 @@
1
1
  /// <reference types="@iobroker/types-dev" />
2
2
  export { Adapter, AdapterClass } from './lib/adapter/adapter.js';
3
- export { Validator } from './lib/adapter/validator.js';
4
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC"}