UNPKG

@orama/orama

Version:

A complete search engine and RAG pipeline in your browser, server, or edge network with support for full-text, vector, and hybrid search in less than 2kb.

45 lines 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AVAILABLE_PLUGIN_HOOKS = void 0; exports.getAllPluginsByHook = getAllPluginsByHook; const errors_js_1 = require("../errors.js"); exports.AVAILABLE_PLUGIN_HOOKS = [ 'beforeInsert', 'afterInsert', 'beforeRemove', 'afterRemove', 'beforeUpdate', 'afterUpdate', 'beforeSearch', 'afterSearch', 'beforeInsertMultiple', 'afterInsertMultiple', 'beforeRemoveMultiple', 'afterRemoveMultiple', 'beforeUpdateMultiple', 'afterUpdateMultiple', 'beforeLoad', 'afterLoad', 'afterCreate' ]; function getAllPluginsByHook(orama, hook) { const pluginsToRun = []; const pluginsLength = orama.plugins?.length; if (!pluginsLength) { return pluginsToRun; } for (let i = 0; i < pluginsLength; i++) { try { const plugin = orama.plugins[i]; if (typeof plugin[hook] === 'function') { pluginsToRun.push(plugin[hook]); } } catch (error) { console.error('Caught error in getAllPluginsByHook:', error); throw (0, errors_js_1.createError)('PLUGIN_CRASHED'); } } return pluginsToRun; } //# sourceMappingURL=plugins.js.map