iobroker.javascript 10.1.2 → 10.1.4

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 (95) hide show
  1. package/README.md +20 -8
  2. package/admin/assets/AiChatPanel-D93BBufl.js +242 -0
  3. package/admin/assets/AiDiffView-D5QZDwuC.js +1 -0
  4. package/admin/assets/{AiInlineProvider-CaHd2G2Q.js → AiInlineProvider-CRU2J938.js} +1 -1
  5. package/admin/assets/Debugger-BLzsRkue.js +15 -0
  6. package/admin/assets/Error-BWXtkB6H.js +1 -0
  7. package/admin/assets/Import-D_RBSmNU.js +1 -0
  8. package/admin/assets/RulesEditor-DpKr8byp.js +1 -0
  9. package/admin/assets/RulesEditor-QNWIRnqB.css +1 -0
  10. package/admin/assets/{ScriptEditor-DNcGhbcU.js → ScriptEditor-DK6nNmcp.js} +2 -2
  11. package/admin/assets/{ScriptEditorVanillaMonaco-BBoOLFln.js → ScriptEditorVanillaMonaco-BVIwadsl.js} +3 -3
  12. package/admin/assets/{_virtual_mf-localSharedImportMap___mfe_internal__iobroker_javascript__mf_owner__1-BK6m6sZx.js → _virtual_mf-localSharedImportMap___mfe_internal__iobroker_javascript__mf_owner__1-v3-PYsgp.js} +1 -1
  13. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-GB0oxSwG.js +1217 -0
  14. package/admin/assets/{_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__1__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-_q6w9ugW.js → _virtual_mf___mfe_internal__iobroker_javascript__mf_owner__1__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-SF46owzN.js} +1 -1
  15. package/admin/assets/aiPromptBuilder-CtijdvYL.js +1 -0
  16. package/admin/assets/blocks_action-Dflw8PyN.js +1 -0
  17. package/admin/assets/{blocks_convert-DS1wCMO_.js → blocks_convert-XTqMxB04.js} +1 -1
  18. package/admin/assets/{blocks_logic-DQaroQTu.js → blocks_logic-JaZOQj6_.js} +1 -1
  19. package/admin/assets/{blocks_number-C998FOz6.js → blocks_number-TU4dV-Ia.js} +1 -1
  20. package/admin/assets/{blocks_object-BGYvC_4Y.js → blocks_object-V6ojF22C.js} +1 -1
  21. package/admin/assets/{blocks_procedures-BZFhrnZ3.js → blocks_procedures-Cu8VeJhw.js} +1 -1
  22. package/admin/assets/{blocks_sendto-BoOZkX-e.js → blocks_sendto-BnDWzP0n.js} +1 -1
  23. package/admin/assets/{blocks_switch-CfjY75wV.js → blocks_switch-DKUc060E.js} +1 -1
  24. package/admin/assets/{blocks_system-C69gZMAz.js → blocks_system-BW_UpMW-.js} +1 -1
  25. package/admin/assets/{blocks_text-Dp6RaJ_p.js → blocks_text-BIU2kf_V.js} +1 -1
  26. package/admin/assets/{blocks_time-CmECitUh.js → blocks_time-2vgvS4_j.js} +1 -1
  27. package/admin/assets/{blocks_timeout-BI8OyiNa.js → blocks_timeout-BPzmWif8.js} +1 -1
  28. package/admin/assets/{blocks_trigger-X7O3INGz.js → blocks_trigger-BSFZEWEO.js} +1 -1
  29. package/admin/assets/blocks_words-bpwd7Ia0.js +1 -0
  30. package/admin/assets/{cronHoverProvider-BhX-SvkB.js → cronHoverProvider-BMVsvVuG.js} +1 -1
  31. package/admin/assets/dist-BF-PlO2i.js +4 -0
  32. package/admin/assets/{field_cron-BJLkgNzf.js → field_cron-Br4hxeLb.js} +1 -1
  33. package/admin/assets/{field_oid-CJZIeruf.js → field_oid-ojNnLVGL.js} +1 -1
  34. package/admin/assets/{field_script-4IGidWJ7.js → field_script-Bs925umq.js} +1 -1
  35. package/admin/assets/{helpers-DaSC8t53.js → helpers-BFQD9R82.js} +1 -1
  36. package/admin/assets/{hostInit-B3IjMQKW.js → hostInit-B_aW3Wuw.js} +1 -1
  37. package/admin/assets/index-BnLv569U.js +871 -0
  38. package/admin/assets/{inlineChatWidget-CBVgT6FZ.js → inlineChatWidget-BcLIwfEH.js} +1 -1
  39. package/admin/assets/{inlineDiffController-DianrKl1.js → inlineDiffController-DGl5rDYU.js} +1 -1
  40. package/admin/assets/{mf-entry-bootstrap-0-a65094d3.js → mf-entry-bootstrap-0-ec2e487a.js} +2 -2
  41. package/admin/assets/{stateHoverProvider-CIFNrLee.js → stateHoverProvider-XKm8a_93.js} +1 -1
  42. package/admin/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__iobroker_javascript__remoteEntry_js-IRf47UYM.js +1 -0
  43. package/admin/custom/assets/Components-BpxzAzc7.js +1 -0
  44. package/admin/custom/assets/{_virtual_mf-localSharedImportMap___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1-BuAc8OyX.js → _virtual_mf-localSharedImportMap___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1-wwYTJNxa.js} +1 -1
  45. package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_emotion_mf_1_react__loadShare__.js-BGJv4zZP.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_emotion_mf_1_react__loadShare__.js-DzaRKfE_.js} +1 -1
  46. package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_emotion_mf_1_styled__loadShare__.js-B4E6MFJ4.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_emotion_mf_1_styled__loadShare__.js-B9fjpXOq.js} +1 -1
  47. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-QxUxIFgP.js +1217 -0
  48. package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_json_mf_2_config__loadShare__.js-DQwzYx75.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_json_mf_2_config__loadShare__.js-BUk3WHjQ.js} +65 -65
  49. package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-xxszBNje.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-DqjU6PXX.js} +1 -1
  50. package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__prebuild__date_mf_2_fns__prebuild__-Tq7tesSS.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__prebuild__date_mf_2_fns__prebuild__-CXAEcWml.js} +1 -1
  51. package/admin/custom/assets/{hostInit-CHwrowP4.js → hostInit-CkdLQZaZ.js} +1 -1
  52. package/admin/custom/assets/{index-Cm6xl9K4.js → index-D2qJNee0.js} +1 -1
  53. package/admin/custom/assets/{lib-bhrFL6jR.js → lib-D9tipKpE.js} +2 -2
  54. package/admin/custom/assets/{mf-entry-bootstrap-0-f08941e2.js → mf-entry-bootstrap-0-ff278fef.js} +2 -2
  55. package/admin/custom/assets/{setYear-DzTZ2h9A.js → setYear-DXk_Jooa.js} +1 -1
  56. package/admin/custom/assets/virtualExposes-vH26J8jF.js +1 -0
  57. package/admin/custom/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__ConfigCustomJavascriptSet__customComponents_js-qdaLIbFV.js +1 -0
  58. package/admin/custom/assets/{virtual_mf-exposes___mfe_internal__ConfigCustomJavascriptSet__customComponents_js-C3ImybiM.js → virtual_mf-exposes___mfe_internal__ConfigCustomJavascriptSet__customComponents_js-C1DpedFv.js} +2 -2
  59. package/admin/custom/customComponents.js +2 -2
  60. package/admin/jsonConfig.json +1 -1
  61. package/admin/mf-manifest.json +1 -1
  62. package/admin/mf-stats.json +1 -1
  63. package/admin/remoteEntry.js +2 -2
  64. package/admin/tab.html +4 -4
  65. package/build/lib/aiProviderResolver.js +18 -6
  66. package/build/lib/aiProviderResolver.js.map +1 -1
  67. package/build/lib/mirror.js +21 -4
  68. package/build/lib/mirror.js.map +1 -1
  69. package/build/lib/sandbox.js +59 -31
  70. package/build/lib/sandbox.js.map +1 -1
  71. package/build/lib/tools.js +13 -0
  72. package/build/lib/tools.js.map +1 -1
  73. package/build/main.js +29 -0
  74. package/build/main.js.map +1 -1
  75. package/docs/en/javascript.md +11 -0
  76. package/io-package.json +27 -27
  77. package/package.json +4 -4
  78. package/admin/assets/AiChatPanel-D3eFcu56.js +0 -242
  79. package/admin/assets/AiDiffView-DtbcD6Yx.js +0 -1
  80. package/admin/assets/Debugger-DsoSdux9.js +0 -15
  81. package/admin/assets/Error-1oeF0cix.js +0 -1
  82. package/admin/assets/Import-BH2X_ziv.js +0 -1
  83. package/admin/assets/RulesEditor-BcGsf9n4.css +0 -1
  84. package/admin/assets/RulesEditor-CJ9TvZtR.js +0 -1
  85. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-DezK0U6r.js +0 -1243
  86. package/admin/assets/aiPromptBuilder-DSYziAVr.js +0 -1
  87. package/admin/assets/blocks_action-Bpe-Zvqj.js +0 -1
  88. package/admin/assets/blocks_words-BhHIf_1o.js +0 -1
  89. package/admin/assets/dist-CaOsN0XW.js +0 -4
  90. package/admin/assets/index-DKhQ45Yn.js +0 -871
  91. package/admin/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__iobroker_javascript__remoteEntry_js-BO-WKj5V.js +0 -1
  92. package/admin/custom/assets/Components-BCQTjBgm.js +0 -1
  93. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-aRlxyEhq.js +0 -1243
  94. package/admin/custom/assets/virtualExposes-B5LJmnfO.js +0 -1
  95. package/admin/custom/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__ConfigCustomJavascriptSet__customComponents_js-ML-chjs6.js +0 -1
@@ -5,6 +5,7 @@ exports.isArray = isArray;
5
5
  exports.matchAll = matchAll;
6
6
  exports.promisify = promisify;
7
7
  exports.hashSource = hashSource;
8
+ exports.escapeRegExp = escapeRegExp;
8
9
  exports.getHttpRequestConfig = getHttpRequestConfig;
9
10
  // import { readdirSync, statSync } from 'node:fs';
10
11
  // import { join } from 'node:path';
@@ -133,6 +134,18 @@ export function promisifyNoError(fn: Function, context: any): (...args: any[]) =
133
134
  function hashSource(source) {
134
135
  return (0, node_crypto_1.createHash)('md5').update(source).digest('hex');
135
136
  }
137
+ /**
138
+ * Escapes every RegExp metacharacter, so the text can be interpolated into a pattern as a literal.
139
+ *
140
+ * Script IDs and file names are built from names the user chooses freely. A name like `Lampe (Flur)`
141
+ * is perfectly valid, but pasted into a pattern unescaped it either throws a `SyntaxError` or
142
+ * silently changes what the pattern matches.
143
+ *
144
+ * @param text The text to use literally inside a regular expression
145
+ */
146
+ function escapeRegExp(text) {
147
+ return text.replace(/[.*+?^${}()|[\]\\-]/g, '\\$&');
148
+ }
136
149
  function getHttpRequestConfig(url, options, allowSelfSignedCerts) {
137
150
  options = options || {};
138
151
  const timeoutMs = options && !isNaN(options.timeout) ? options.timeout : 2000;
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/lib/tools.ts"],"names":[],"mappings":";;AAWA,4BAMC;AAOD,0BAEC;AAQD,4BAWC;AAmCD,8BAuBC;AA6BD,gCAEC;AAED,oDAkEC;AA1MD,mDAAmD;AACnD,oCAAoC;AACpC,6CAAyC;AACzC,2CAAmC;AAGnC;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,EAAO;IAC5B,6BAA6B;IAC7B,2BAA2B;IAC3B,yBAAyB;IACzB,gCAAgC;IAChC,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CA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AED,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["// import { readdirSync, statSync } from 'node:fs';\n// import { join } from 'node:path';\nimport { createHash } from 'node:crypto';\nimport { Agent } from 'node:https';\nimport type { AxiosRequestConfig, ResponseType } from 'axios';\n\n/**\n * Tests whether the given variable is a real object and not an Array\n *\n * @param it The variable to test\n */\nexport function isObject(it: any): boolean {\n // This is necessary because:\n // typeof null === 'object'\n // typeof [] === 'object'\n // [] instanceof Object === true\n return Object.prototype.toString.call(it) === '[object Object]';\n}\n\n/**\n * Tests whether the given variable is really an Array\n *\n * @param it The variable to test\n */\nexport function isArray(it: any): boolean {\n return Array.isArray(it);\n}\n\n/**\n * Finds all matches of a regular expression and returns the matched groups\n *\n * @param regex The regular expression to match against the string\n * @param string The string to test\n */\nexport function matchAll(regex: RegExp, string: string): string[][] {\n const ret: string[][] = [];\n let match: RegExpExecArray | null;\n do {\n match = regex.exec(string);\n if (match) {\n ret.push(match.slice(1));\n }\n } while (match);\n\n return ret;\n}\n\n/**\n * Enumerates all files matching a given predicate\n *\n * @param rootDir The directory to start in\n * @param predicate A function that takes a filename and returns true if the file should be included\n */\n/*export function enumFilesRecursiveSync(rootDir: string, predicate: (filename: string) => boolean): string[] {\n const ret: string[] = [];\n try {\n const filesAndDirs = readdirSync(rootDir);\n for (const f of filesAndDirs) {\n const fullPath = join(rootDir, f);\n\n if (statSync(fullPath).isDirectory()) {\n Array.prototype.push.apply(ret, enumFilesRecursiveSync(fullPath, predicate));\n } else if (typeof predicate === 'function' && predicate(fullPath)) {\n ret.push(fullPath);\n }\n }\n } catch (err: unknown) {\n console.error(`Cannot read directory: \"${rootDir}\": ${err as Error}`);\n }\n\n return ret;\n}*/\n\n/**\n * Promisifies a callback-style function with parameters (err, result)\n *\n * @param fn The callback-style function to promisify\n * @param context The value of `this` in the function\n */\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport function promisify(fn: Function, context?: any): (...args: any[]) => Promise<any> {\n return function (...args) {\n // @ts-expect-error We want this behavior\n context = context || this;\n return new Promise((resolve, reject) => {\n try {\n fn.apply(context, [\n ...args,\n (error: Error | string | null, result: null) => {\n if (error) {\n if (typeof error === 'string') {\n return reject(new Error(error));\n }\n return reject(error);\n }\n return resolve(result);\n },\n ]);\n } catch (error: unknown) {\n reject(error instanceof Error ? error : new Error(String(error)));\n }\n });\n };\n}\n\n/**\n * Promisifies a callback-style function without an error parameter\n *\n * @param fn The callback-style function to promisify\n * @param context The value of `this` in the function\n */\n/*\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport function promisifyNoError(fn: Function, context: any): (...args: any[]) => Promise<any> {\n return function (...args) {\n // @ts-expect-error We want this behavior\n context = context || this;\n return new Promise(resolve => {\n try {\n fn.apply(context, [...args, (result: any) => resolve(result)]);\n } catch {\n resolve(null); // what to do in this case??\n }\n });\n };\n}*/\n\n/**\n * Creates an MD5 hash of a script source which can be used to check whether the source of a compiled language changed\n *\n * @param source The source code to hash\n */\nexport function hashSource(source: string | Buffer): string {\n return createHash('md5').update(source).digest('hex');\n}\n\nexport function getHttpRequestConfig(\n url: string,\n options?: {\n timeout?: number;\n responseType?: ResponseType;\n headers?: Record<string, string>;\n basicAuth?: { user: string; password: string } | null;\n bearerAuth?: string;\n validateCertificate?: boolean;\n },\n allowSelfSignedCerts?: boolean,\n): AxiosRequestConfig {\n options = options || {};\n const timeoutMs = options && !isNaN(options.timeout as number) ? options.timeout : 2000;\n\n const config: AxiosRequestConfig = {\n method: 'get',\n url,\n validateStatus: (status: number): boolean => status >= 200,\n responseType: options && options.responseType ? options.responseType : 'text',\n responseEncoding: 'utf8',\n timeout: timeoutMs,\n //signal: AbortSignal.timeout(timeoutMs), // connection related timeouts\n };\n\n options.headers = options.headers || {};\n\n if (options && options.basicAuth) {\n config.auth = {\n username: options.basicAuth.user,\n password: options.basicAuth.password,\n };\n } else if (options.bearerAuth) {\n options.headers.Authorization = `Bearer ${options.bearerAuth}`;\n } else {\n const uri = new URL(url);\n if (uri.username && uri.password) {\n const username = decodeURIComponent(uri.username);\n const password = decodeURIComponent(uri.password);\n\n config.url = (config.url || '').replace(`${uri.protocol}//${username}:${password}@`, `${uri.protocol}//`);\n config.auth = {\n username,\n password,\n };\n }\n }\n\n // Set default headers\n config.headers = {\n 'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:109.0) Gecko/20100101 Firefox/121.0',\n ...options.headers,\n };\n\n // Certificate validation: per-request option takes priority, then adapter-level setting\n if (options && typeof options?.validateCertificate !== 'undefined') {\n config.httpsAgent = new Agent({\n rejectUnauthorized: options.validateCertificate,\n });\n } else if (allowSelfSignedCerts) {\n config.httpsAgent = new Agent({\n rejectUnauthorized: false,\n });\n }\n\n return config;\n}\n"]}
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/lib/tools.ts"],"names":[],"mappings":";;AAWA,4BAMC;AAOD,0BAEC;AAQD,4BAWC;AAmCD,8BAuBC;AA6BD,gCAEC;AAWD,oCAEC;AAED,oDAkEC;AAvND,mDAAmD;AACnD,oCAAoC;AACpC,6CAAyC;AACzC,2CAAmC;AAGnC;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,EAAO;IAC5B,6BAA6B;IAC7B,2BAA2B;IAC3B,yBAAyB;IACzB,gCAAgC;IAChC,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,iBAAiB,CAAC;AACpE,CAAC;AAED;;;;GAIG;AACH,SAAgB,OAAO,CAAC,EAAO;IAC3B,OAAO,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,KAAa,EAAE,MAAc;IAClD,MAAM,GAAG,GAAe,EAAE,CAAC;IAC3B,IAAI,KAA6B,CAAC;IAClC,GAAG,CAAC;QACA,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAI,KAAK,EAAE,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AG,CAAC,CAAC;QACzB,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;YAC/B,MAAM,QAAQ,GAAG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAClD,MAAM,QAAQ,GAAG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAElD,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,QAAQ,GAAG,EAAE,GAAG,GAAG,CAAC,QAAQ,IAAI,CAAC,CAAC;YAC1G,MAAM,CAAC,IAAI,GAAG;gBACV,QAAQ;gBACR,QAAQ;aACX,CAAC;QACN,CAAC;IACL,CAAC;IAED,sBAAsB;IACtB,MAAM,CAAC,OAAO,GAAG;QACb,YAAY,EAAE,sEAAsE;QACpF,GAAG,OAAO,CAAC,OAAO;KACrB,CAAC;IAEF,wFAAwF;IACxF,IAAI,OAAO,IAAI,OAAO,OAAO,EAAE,mBAAmB,KAAK,WAAW,EAAE,CAAC;QACjE,MAAM,CAAC,UAAU,GAAG,IAAI,kBAAK,CAAC;YAC1B,kBAAkB,EAAE,OAAO,CAAC,mBAAmB;SAClD,CAAC,CAAC;IACP,CAAC;SAAM,IAAI,oBAAoB,EAAE,CAAC;QAC9B,MAAM,CAAC,UAAU,GAAG,IAAI,kBAAK,CAAC;YAC1B,kBAAkB,EAAE,KAAK;SAC5B,CAAC,CAAC;IACP,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["// import { readdirSync, statSync } from 'node:fs';\n// import { join } from 'node:path';\nimport { createHash } from 'node:crypto';\nimport { Agent } from 'node:https';\nimport type { AxiosRequestConfig, ResponseType } from 'axios';\n\n/**\n * Tests whether the given variable is a real object and not an Array\n *\n * @param it The variable to test\n */\nexport function isObject(it: any): boolean {\n // This is necessary because:\n // typeof null === 'object'\n // typeof [] === 'object'\n // [] instanceof Object === true\n return Object.prototype.toString.call(it) === '[object Object]';\n}\n\n/**\n * Tests whether the given variable is really an Array\n *\n * @param it The variable to test\n */\nexport function isArray(it: any): boolean {\n return Array.isArray(it);\n}\n\n/**\n * Finds all matches of a regular expression and returns the matched groups\n *\n * @param regex The regular expression to match against the string\n * @param string The string to test\n */\nexport function matchAll(regex: RegExp, string: string): string[][] {\n const ret: string[][] = [];\n let match: RegExpExecArray | null;\n do {\n match = regex.exec(string);\n if (match) {\n ret.push(match.slice(1));\n }\n } while (match);\n\n return ret;\n}\n\n/**\n * Enumerates all files matching a given predicate\n *\n * @param rootDir The directory to start in\n * @param predicate A function that takes a filename and returns true if the file should be included\n */\n/*export function enumFilesRecursiveSync(rootDir: string, predicate: (filename: string) => boolean): string[] {\n const ret: string[] = [];\n try {\n const filesAndDirs = readdirSync(rootDir);\n for (const f of filesAndDirs) {\n const fullPath = join(rootDir, f);\n\n if (statSync(fullPath).isDirectory()) {\n Array.prototype.push.apply(ret, enumFilesRecursiveSync(fullPath, predicate));\n } else if (typeof predicate === 'function' && predicate(fullPath)) {\n ret.push(fullPath);\n }\n }\n } catch (err: unknown) {\n console.error(`Cannot read directory: \"${rootDir}\": ${err as Error}`);\n }\n\n return ret;\n}*/\n\n/**\n * Promisifies a callback-style function with parameters (err, result)\n *\n * @param fn The callback-style function to promisify\n * @param context The value of `this` in the function\n */\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport function promisify(fn: Function, context?: any): (...args: any[]) => Promise<any> {\n return function (...args) {\n // @ts-expect-error We want this behavior\n context = context || this;\n return new Promise((resolve, reject) => {\n try {\n fn.apply(context, [\n ...args,\n (error: Error | string | null, result: null) => {\n if (error) {\n if (typeof error === 'string') {\n return reject(new Error(error));\n }\n return reject(error);\n }\n return resolve(result);\n },\n ]);\n } catch (error: unknown) {\n reject(error instanceof Error ? error : new Error(String(error)));\n }\n });\n };\n}\n\n/**\n * Promisifies a callback-style function without an error parameter\n *\n * @param fn The callback-style function to promisify\n * @param context The value of `this` in the function\n */\n/*\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport function promisifyNoError(fn: Function, context: any): (...args: any[]) => Promise<any> {\n return function (...args) {\n // @ts-expect-error We want this behavior\n context = context || this;\n return new Promise(resolve => {\n try {\n fn.apply(context, [...args, (result: any) => resolve(result)]);\n } catch {\n resolve(null); // what to do in this case??\n }\n });\n };\n}*/\n\n/**\n * Creates an MD5 hash of a script source which can be used to check whether the source of a compiled language changed\n *\n * @param source The source code to hash\n */\nexport function hashSource(source: string | Buffer): string {\n return createHash('md5').update(source).digest('hex');\n}\n\n/**\n * Escapes every RegExp metacharacter, so the text can be interpolated into a pattern as a literal.\n *\n * Script IDs and file names are built from names the user chooses freely. A name like `Lampe (Flur)`\n * is perfectly valid, but pasted into a pattern unescaped it either throws a `SyntaxError` or\n * silently changes what the pattern matches.\n *\n * @param text The text to use literally inside a regular expression\n */\nexport function escapeRegExp(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\-]/g, '\\\\$&');\n}\n\nexport function getHttpRequestConfig(\n url: string,\n options?: {\n timeout?: number;\n responseType?: ResponseType;\n headers?: Record<string, string>;\n basicAuth?: { user: string; password: string } | null;\n bearerAuth?: string;\n validateCertificate?: boolean;\n },\n allowSelfSignedCerts?: boolean,\n): AxiosRequestConfig {\n options = options || {};\n const timeoutMs = options && !isNaN(options.timeout as number) ? options.timeout : 2000;\n\n const config: AxiosRequestConfig = {\n method: 'get',\n url,\n validateStatus: (status: number): boolean => status >= 200,\n responseType: options && options.responseType ? options.responseType : 'text',\n responseEncoding: 'utf8',\n timeout: timeoutMs,\n //signal: AbortSignal.timeout(timeoutMs), // connection related timeouts\n };\n\n options.headers = options.headers || {};\n\n if (options && options.basicAuth) {\n config.auth = {\n username: options.basicAuth.user,\n password: options.basicAuth.password,\n };\n } else if (options.bearerAuth) {\n options.headers.Authorization = `Bearer ${options.bearerAuth}`;\n } else {\n const uri = new URL(url);\n if (uri.username && uri.password) {\n const username = decodeURIComponent(uri.username);\n const password = decodeURIComponent(uri.password);\n\n config.url = (config.url || '').replace(`${uri.protocol}//${username}:${password}@`, `${uri.protocol}//`);\n config.auth = {\n username,\n password,\n };\n }\n }\n\n // Set default headers\n config.headers = {\n 'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:109.0) Gecko/20100101 Firefox/121.0',\n ...options.headers,\n };\n\n // Certificate validation: per-request option takes priority, then adapter-level setting\n if (options && typeof options?.validateCertificate !== 'undefined') {\n config.httpsAgent = new Agent({\n rejectUnauthorized: options.validateCertificate,\n });\n } else if (allowSelfSignedCerts) {\n config.httpsAgent = new Agent({\n rejectUnauthorized: false,\n });\n }\n\n return config;\n}\n"]}
package/build/main.js CHANGED
@@ -891,6 +891,31 @@ class JavaScript extends adapter_core_1.Adapter {
891
891
  }
892
892
  return (0, aiProviderResolver_1.resolveProviderCredentials)(this.config, provider, opts.messageBaseUrl);
893
893
  }
894
+ /**
895
+ * Warns about the one setup that the fix for #2369 stops working.
896
+ *
897
+ * Until 10.1.3 a custom OpenAI-compatible endpoint was addressed as `provider: 'openai'`, so its
898
+ * requests were signed with the OpenAI key and routed to the custom URL. The documented
899
+ * workaround was therefore to put the *custom* endpoint's key into the OpenAI field. Both halves
900
+ * of that are gone now - the two providers no longer share a key or a URL - and such a setup
901
+ * would silently start answering 401. Deliberately no fallback to `gptKey`: that is what used to
902
+ * hand a real OpenAI key to a third-party host.
903
+ */
904
+ warnAboutMisplacedCustomAiKey() {
905
+ if (!(this.config.gptBaseUrl || '').trim()) {
906
+ return;
907
+ }
908
+ const manager = this.config.credentialType === 'manager';
909
+ const custom = manager
910
+ ? (0, aiProviderResolver_1.getProviderCredentialId)(this.config, 'custom')
911
+ : (this.config.gptBaseUrlKey || '').trim();
912
+ const openai = manager ? (0, aiProviderResolver_1.getProviderCredentialId)(this.config, 'openai') : (this.config.gptKey || '').trim();
913
+ if (!custom && openai) {
914
+ this.log.warn(`A custom AI endpoint ("${this.config.gptBaseUrl}") is configured, but its own API key is empty. ` +
915
+ `Requests to it are no longer signed with the OpenAI key - move the key of that endpoint into ` +
916
+ `the "Custom API key" field of the adapter settings.`);
917
+ }
918
+ }
894
919
  /**
895
920
  * In `manager` mode, subscribe to all configured AI credentials so that edits made in the
896
921
  * admin credential manager (Settings → Credentials) are picked up live, without restarting
@@ -1618,6 +1643,7 @@ class JavaScript extends adapter_core_1.Adapter {
1618
1643
  // In `manager` credential mode, subscribe to the configured AI credentials so changes in the
1619
1644
  // central credential store are picked up live (the keys are cached for the AI sendTo handlers).
1620
1645
  await this.subscribeAiCredentials();
1646
+ this.warnAboutMisplacedCustomAiKey();
1621
1647
  // Read the central credential store, so the scripts can use `SECRETS.<name>.<field>`.
1622
1648
  // Later changes are picked up in `onObjectChange`.
1623
1649
  await this.secretsManager.load(this.config.enableSecrets !== false);
@@ -2809,6 +2835,8 @@ class JavaScript extends adapter_core_1.Adapter {
2809
2835
  }
2810
2836
  }
2811
2837
  }
2838
+ // The jobs are canceled => an onStop callback must not see them anymore via getSchedules()
2839
+ this.scripts[name].schedules = [];
2812
2840
  // Stop all time wizards jobs
2813
2841
  if (this.context.scheduler) {
2814
2842
  for (let i = 0; i < this.scripts[name].wizards.length; i++) {
@@ -2817,6 +2845,7 @@ class JavaScript extends adapter_core_1.Adapter {
2817
2845
  }
2818
2846
  }
2819
2847
  }
2848
+ this.scripts[name].wizards = [];
2820
2849
  // if callback for on stop
2821
2850
  if (typeof this.scripts[name].onStopCb === 'function') {
2822
2851
  this.scripts[name].onStopTimeout =