@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.2 kB
JavaScript
import { createError } from '../errors.js';
export const AVAILABLE_PLUGIN_HOOKS = [
'beforeInsert',
'afterInsert',
'beforeRemove',
'afterRemove',
'beforeUpdate',
'afterUpdate',
'beforeUpsert',
'afterUpsert',
'beforeSearch',
'afterSearch',
'beforeInsertMultiple',
'afterInsertMultiple',
'beforeRemoveMultiple',
'afterRemoveMultiple',
'beforeUpdateMultiple',
'afterUpdateMultiple',
'beforeUpsertMultiple',
'afterUpsertMultiple',
'beforeLoad',
'afterLoad',
'afterCreate'
];
export 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 createError('PLUGIN_CRASHED');
}
}
return pluginsToRun;
}
//# sourceMappingURL=plugins.js.map