/** * @mixin @node-red/runtime_plugins */ var runtime; var api = module.exports = { init: function(_runtime) { runtime = _runtime; }, /** * Gets the editor content for an individual plugin * @param {Object} opts * @param {User} opts.user - the user calling the api * @param {Object} opts.req - the request to log (optional) * @return {Promise} - the node information * @memberof @node-red/runtime_nodes */ getPluginList: async function(opts) { runtime.log.audit({event: "plugins.list.get"}, opts.req); return runtime.plugins.getPluginList(); }, getPluginConfigs: async function(opts) { runtime.log.audit({event: "plugins.configs.get"}, opts.req); return runtime.plugins.getPluginConfigs(opts.lang); }, /** * Gets all registered module message catalogs * @param {Object} opts * @param {User} opts.user - the user calling the api * @param {User} opts.lang - the i18n language to return. If not set, uses runtime default (en-US) * @param {Object} opts.req - the request to log (optional) * @return {Promise} - the message catalogs * @memberof @node-red/runtime_nodes */ getPluginCatalogs: async function(opts) { var lang = opts.lang; var prevLang = runtime.i18n.i.language; // Trigger a load from disk of the language if it is not the default return new Promise( (resolve,reject) => { runtime.i18n.i.changeLanguage(lang, function(){ var nodeList = runtime.plugins.getPluginList(); var result = {}; nodeList.forEach(function(n) { if (n.module !== "node-red") { result[n.id] = runtime.i18n.i.getResourceBundle(lang, n.id)||{}; } }); runtime.i18n.i.changeLanguage(prevLang); resolve(result); }); }); }, }