@kedem/okdb 2.1.1 → 2.2.0
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.
- package/algorithm-worker-thread.js +1 -1
- package/bin/okdb.js +1 -1
- package/docs/embeddings.md +3 -3
- package/docs/querying.md +20 -0
- package/docs/views.md +32 -32
- package/okdb-functions-sandbox-worker.js +1 -1
- package/okdb-http-worker-child.js +1 -1
- package/okdb-views-bootstrap-worker.js +1 -1
- package/okdb.js +1 -1
- package/package.json +1 -1
- package/public/sections/engines/index.ok.html +1 -1
- package/types/environment.d.ts +4 -2
- package/types/features/views.d.ts +38 -4
- package/types/index.d.ts +4 -2
- package/types/options.d.ts +25 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kedem/okdb",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "A fast, type-oriented database — strong consistency and rich indexing at the core, with sync, vector embeddings, full-text search, and AI tooling built in. Designed for the AI era.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"engines": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<script type="module">import e from"../embeddings/parts/engines-overview.ok.js";import i from"../embeddings/parts/pipeline-create-panel.ok.js";import t from"../../stores/events-store.js";import{memberDocCounts as s}from"./engine-ui-utils.js";export default{tag:"engines-index",unwrap:!0,dependencies:[e,i],context:e=>({embedEngines:[],embedPipelines:[],fileEngines:{},view:"overview",mode:"pipelines",pipelineType:"all",engineType:"",status:"all",search:"",sourceTypeFilter:"",selectedPipelineName:"",createKind:"",busy:!1,_unsubs:[],_pollTimer:null,get selectedEnv(){return e.$ok.stores.okdb.selectedEnv||"default"},normalizeView:e=>["overview","create"].includes(e)?e:"overview",normalizeMode:e=>["pipelines","engines"].includes(e)?e:"pipelines",normalizePipelineType:e=>["all","embedding","file"].includes(e)?e:"all",normalizeEngineType:e=>String(e||"").trim(),legacyFilterState(e){switch(e){case"pipelines":default:return{mode:"pipelines",pipelineType:"all",engineType:""};case"standalone":case"runtime":return{mode:"engines",pipelineType:"all",engineType:""};case"embedding":return{mode:"pipelines",pipelineType:"embedding",engineType:""};case"file":return{mode:"pipelines",pipelineType:"file",engineType:""}}},normalizeStatus:e=>["all","running","attention","stopped"].includes(e)?e:"all",normalizeCreateKind:e=>["processor","materializer","queue-worker","embedding"].includes(e)?e:"",setView(e){const i=this.normalizeView(e);this.view!==i&&(this.view=i,this.syncRouteState())},setModeFilter(e){const i=this.normalizeMode(e);this.mode!==i&&(this.mode=i,"pipelines"===i&&(this.engineType=""),"engines"===i&&(this.pipelineType="all",this.selectedPipelineName=""),this.syncRouteState())},setPipelineTypeFilter(e){const i=this.normalizePipelineType(e);this.pipelineType!==i&&(this.pipelineType=i,this.syncRouteState())},setEngineTypeFilter(e){const i=this.normalizeEngineType(e);this.engineType!==i&&(this.engineType=i,this.syncRouteState())},setSourceTypeFilter(e){const i=String(e??"");this.sourceTypeFilter!==i&&(this.sourceTypeFilter=i,this.syncRouteState())},get availableSourceTypes(){const e=new Set;for(const i of this.embedEngines??[])i?.config?.source_type&&e.add(i.config.source_type),i?.runtime?.source_type&&e.add(i.runtime.source_type),i?.stats?.source_type&&e.add(i.stats.source_type),i?.stats?.indexer?.source_type&&e.add(i.stats.indexer.source_type),i?.config?.target_type&&e.add(i.config.target_type);const i=this.fileEngines??{};for(const t of[...i.extractors??[],...i.collections??[],...i.workers??[]])t?.config?.source_type&&e.add(t.config.source_type);return[...e].sort()},get availableEngineTypes(){const e=new Set;for(const i of this.embedEngines??[])i?.type&&e.add(i.type);const i=this.fileEngines??{};for(const t of[...i.extractors??[],...i.collections??[],...i.workers??[]])t?.type&&e.add(t.type);return[...e].sort()},get workspaceCount(){const e=this.fileEngines??{},i=(this.embedEngines??[]).length+(e.extractors??[]).length+(e.collections??[]).length+(e.workers??[]).length,t=(this.embedPipelines??[]).length+(e.collections??[]).length;return"engines"===this.mode?i:t},get searchPlaceholder(){return"engines"===this.mode?"Search engines…":"Search pipelines…"},get routeSearch(){return e.$vars?.$route?.search??e.$vars?.$router?._search??{}},applyRouteState(){const e=this.routeSearch,i=this.legacyFilterState(e.family||""),t=this.normalizeView(e.view||"overview"),s=this.normalizeMode(e.mode||i.mode||"pipelines"),n=this.normalizePipelineType(e.pipelineType||i.pipelineType||"all"),l=this.normalizeEngineType(e.engineType||i.engineType||""),r=this.normalizeStatus(e.status||"all"),o=String(e.search||""),a=String(e.sourceType||""),p=String(e.pipeline||""),h=this.normalizeCreateKind(e.kind||"");this.view!==t&&(this.view=t),this.mode!==s&&(this.mode=s),this.pipelineType!==n&&(this.pipelineType=n),this.engineType!==l&&(this.engineType=l),this.status!==r&&(this.status=r),this.search!==o&&(this.search=o),this.sourceTypeFilter!==a&&(this.sourceTypeFilter=a),this.selectedPipelineName!==p&&(this.selectedPipelineName=p),this.createKind!==h&&(this.createKind=h)},syncRouteState(){const i=e.$vars?.$router;if(!i?.resolve||!i?.replace)return;const t=this.routeSearch,s={...t};this.view&&"overview"!==this.view?s.view=this.view:delete s.view,this.mode&&"pipelines"!==this.mode?s.mode=this.mode:delete s.mode,this.pipelineType&&"all"!==this.pipelineType?s.pipelineType=this.pipelineType:delete s.pipelineType,this.engineType?s.engineType=this.engineType:delete s.engineType,this.status&&"all"!==this.status?s.status=this.status:delete s.status,this.search?.trim()?s.search=this.search.trim():delete s.search,this.sourceTypeFilter?.trim()?s.sourceType=this.sourceTypeFilter.trim():delete s.sourceType,this.selectedPipelineName?.trim()?s.pipeline=this.selectedPipelineName.trim():delete s.pipeline,"create"===this.view&&this.createKind?s.kind=this.createKind:delete s.kind,delete s.family;const n=this.legacyFilterState(t.family||""),l=this.normalizeView(t.view||"overview"),r=this.normalizeMode(t.mode||n.mode||"pipelines"),o=this.normalizePipelineType(t.pipelineType||n.pipelineType||"all"),a=this.normalizeEngineType(t.engineType||n.engineType||""),p=this.normalizeStatus(t.status||"all"),h=String(t.search||""),c=String(t.sourceType||""),d=String(t.pipeline||""),u=this.normalizeCreateKind(t.kind||"");if(l===this.view&&r===this.mode&&o===this.pipelineType&&a===this.engineType&&p===this.status&&h===(this.search||"")&&c===(this.sourceTypeFilter||"")&&d===(this.selectedPipelineName||"")&&u===(this.createKind||""))return;const y=e.$vars?.$route?.location||i._path||"/engines";i.replace(i.resolve(y,s,i._anchor||""))},clearFilters(){("all"!==this.pipelineType||this.engineType||"all"!==this.status||this.search||this.sourceTypeFilter)&&(this.pipelineType="all",this.engineType="",this.status="all",this.search="",this.sourceTypeFilter="",this.syncRouteState())},setSearchTerm(e){const i=String(e??"");this.search!==i&&(this.search=i,this.syncRouteState())},setStatusFilter(e){const i=this.normalizeStatus(e);this.status!==i&&(this.status=i,this.syncRouteState())},clearSourceTypeFilter(){this.sourceTypeFilter&&(this.sourceTypeFilter="",this.syncRouteState())},onPipelineSelected(e){const i=e?.name??"";this.selectedPipelineName!==i&&(this.selectedPipelineName=i,this.syncRouteState())},async load(){this.busy=!0;const e=this.selectedEnv;try{const[i,t,s]=await Promise.allSettled([fetch(`${__ENV__.API}/env/${encodeURIComponent(e)}/engines`).then(e=>e.json()),fetch(`${__ENV__.API}/embeddings/embedders`).then(e=>e.json()),fetch(`${__ENV__.API}/env/${encodeURIComponent(e)}/pipelines`).then(e=>e.json())]),n="fulfilled"===i.status?i.value?.data??[]:[],l="fulfilled"===t.status?t.value?.data??[]:[];this.embedEngines=[...n,...l],this.embedPipelines="fulfilled"===s.status?s.value?.data??(Array.isArray(s.value)?s.value:[]):[],this.fileEngines={extractors:n.filter(e=>"file-extractor"===e.type),collections:n.filter(e=>"file-collection"===e.type),workers:n.filter(e=>"file-extractor-worker"===e.type)}}catch{}finally{this.busy=!1,this._scheduleProgressPoll()}},anyPipelineFlowing(){return(this.embedPipelines||[]).some(e=>{const i=(e.engines||[]).find(e=>"indexer"===e?.type||"indexer"===e?.role);return(s(i)?.pending??0)>0})},_scheduleProgressPoll(){this._pollTimer||this.anyPipelineFlowing()&&(this._pollTimer=setTimeout(async()=>{this._pollTimer=null,await this.load()},2e3))},async onCreated(){this.view="overview",this.syncRouteState(),await this.load()}}),async init(e){this.applyRouteState(),await this.load();const i=()=>this.load();this._unsubs=[t.on("engine:started",i),t.on("engine:stopped",i),t.on("engine:error",i),t.on("pipeline:start",i),t.on("pipeline:stop",i),t.on("pipeline:delete",i)],e.$watch(()=>e.$ok.stores.okdb.selectedEnv,()=>this.load()),e.$watch(()=>JSON.stringify(this.routeSearch),()=>this.applyRouteState())},unmount(){for(const e of this._unsubs)e();this._unsubs=[],this._pollTimer&&clearTimeout(this._pollTimer),this._pollTimer=null}};</script><style>.eng-nav-row{display:flex;align-items:center;gap:8px;width:100%;text-align:left;padding:6px 10px;border-radius:6px;border:1px solid transparent;background:0 0;color:var(--okdb-app-fg-muted);font-size:12px;cursor:pointer;transition:background .12s,border-color .12s,color .12s}.eng-nav-row:hover{background:var(--okdb-app-surface);border-color:var(--okdb-app-border);color:var(--okdb-app-fg-strong)}.eng-nav-row--on{background:var(--okdb-app-surface);border-color:var(--okdb-accent);color:var(--okdb-app-fg-strong)}.eng-nav-sep{font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:.08em;color:var(--okdb-app-fg-subtle);padding:6px 10px 2px}.eng-filter-card{display:flex;flex-direction:column;gap:10px;padding:10px;border:1px solid var(--okdb-app-border);border-radius:10px;background:var(--okdb-app-bg-deep);min-width:0}.eng-field{display:flex;flex-direction:column;gap:4px;min-width:0}.eng-field__label{font-size:11px;color:var(--okdb-app-fg-muted)}.eng-control{width:100%;min-width:0;box-sizing:border-box;font-size:12px}.eng-segment{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;width:100%}.eng-segment__btn{min-width:0;width:100%;padding:6px 10px;border-radius:8px;border:1px solid var(--okdb-app-border);background:var(--okdb-app-bg-deep);color:var(--okdb-app-fg-muted);font-size:11px;font-weight:600;cursor:pointer;transition:background .12s,border-color .12s,color .12s,box-shadow .12s}.eng-segment__btn:hover{background:var(--okdb-app-surface);border-color:var(--okdb-app-border);color:var(--okdb-app-fg-strong)}.eng-segment__btn--active{border-color:var(--okdb-accent);background:color-mix(in srgb,var(--okdb-accent) 7%,transparent);color:var(--okdb-accent);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--okdb-accent) 13%,transparent)}.eng-filter-actions{display:flex;justify-content:flex-end}.eng-clear-btn{font-size:11px;padding:5px 10px;border-radius:999px;border:1px solid var(--okdb-app-border);color:var(--okdb-app-fg-muted);background:var(--okdb-app-bg-deep);cursor:pointer}.eng-clear-btn:hover{border-color:var(--okdb-app-border-strong);color:var(--okdb-app-fg-strong);background:var(--okdb-app-surface)}</style><template><component import="../../layouts/_default.ok.html"><template name="sidebar"><div style="display:flex;flex-direction:column;gap:8px;height:100%;min-height:0;overflow-y:auto"><button :class="view === 'create' ? 'eng-nav-row eng-nav-row--on' : 'eng-nav-row'" @click="setView('create')" title="Create a pipeline, which provisions and wires together one or more engines."><span style="width:14px;text-align:center;flex-shrink:0;opacity:.9;color:var(--okdb-accent)">+</span> <span style="color:var(--okdb-accent)">New Pipeline</span></button><div class="eng-nav-sep">Engines</div><button :class="view === 'overview' ? 'eng-nav-row eng-nav-row--on' : 'eng-nav-row'" @click="setView('overview')"><span style="width:14px;text-align:center;flex-shrink:0;opacity:.7">⊛</span> <span>Workspace</span> <span style="margin-left:auto;font-size:10px;opacity:.4">{{ workspaceCount }}</span></button><if :="view === 'overview'"><div style="height:1px;background:var(--okdb-app-border);margin:2px 0"></div><div class="eng-nav-sep" style="padding-top:4px">Filters</div><div class="eng-filter-card"><label class="eng-field"><span class="eng-field__label" title="Search by name, type, handler, env, pipeline, or source type">Search</span> <input class="eng-control" :value="search" @input:debounce.250="setSearchTerm($event.target.value)" :placeholder="searchPlaceholder"/></label><div class="eng-field"><span class="eng-field__label" title="Switch between the grouped pipeline view and the flat engine inventory.">Mode</span><div class="eng-segment"><button @click="setModeFilter('pipelines')" :class="mode === 'pipelines' ? 'eng-segment__btn eng-segment__btn--active' : 'eng-segment__btn'" title="Show grouped pipelines">Pipelines</button> <button @click="setModeFilter('engines')" :class="mode === 'engines' ? 'eng-segment__btn eng-segment__btn--active' : 'eng-segment__btn'" title="Show individual engines">Engines</button></div></div><if :="mode === 'pipelines'"><label class="eng-field"><span class="eng-field__label" title="Filter grouped pipelines by pipeline type.">Pipeline Type</span> <select class="eng-control" @change="setPipelineTypeFilter($event.target.value)"><option value="all" :selected="pipelineType === 'all'">All pipelines</option><option value="embedding" :selected="pipelineType === 'embedding'">Env</option><option value="file" :selected="pipelineType === 'file'">Files</option></select></label></if><if :="mode === 'engines'"><label class="eng-field"><span class="eng-field__label" title="Filter the flat engine list by engine type.">Engine Type</span> <select class="eng-control" @change="setEngineTypeFilter($event.target.value)"><option value="" :selected="!engineType">All engines</option><each :of="availableEngineTypes" let:item="t"><option :value="t" :selected="engineType === t">{{ t }}</option></each></select></label></if><label class="eng-field"><span class="eng-field__label">Status</span> <select class="eng-control" @change="setStatusFilter($event.target.value)"><option value="all" :selected="status === 'all'">Any</option><option value="running" :selected="status === 'running'">Running</option><option value="attention" :selected="status === 'attention'">Needs attention</option><option value="stopped" :selected="status === 'stopped'">Stopped</option></select></label><if :="availableSourceTypes.length > 0"><label class="eng-field" title="Filter by the data type engines process or index"><span class="eng-field__label">Source Type</span> <select class="eng-control" @change="setSourceTypeFilter($event.target.value)"><option value="" :selected="!sourceTypeFilter">All types</option><each :of="availableSourceTypes" let:item="st"><option :value="st" :selected="sourceTypeFilter === st">{{ st }}</option></each></select></label></if><if :="pipelineType !== 'all' || engineType || status !== 'all' || search || sourceTypeFilter"><div class="eng-filter-actions"><button @click="clearFilters()" class="eng-clear-btn">Clear filters</button></div></if></div></if></div></template><template name="default"><if :="view === 'create'"><pipeline-create-panel :locktype="sourceTypeFilter" :lockenv="selectedEnv" :initialkind="createKind" @created="onCreated()"/></if><if :="view === 'overview'"><engines-overview :embed-engines="embedEngines" :embed-pipelines="embedPipelines" :file-engines="fileEngines" :mode="mode" :pipelinetype="pipelineType" :enginetype="engineType" :status="status" :search="search" :sourcetype="sourceTypeFilter" :selectedpipeline="selectedPipelineName" @select="onPipelineSelected($event.detail)" @refresh="load()" @create-pipeline="setView('create')"/></if></template></component></template>
|
|
1
|
+
<script type="module">import e from"../embeddings/parts/engines-overview.ok.js";import i from"../embeddings/parts/pipeline-create-panel.ok.js";import t from"../../stores/events-store.js";export default{tag:"engines-index",unwrap:!0,dependencies:[e,i],context:e=>({embedEngines:[],embedPipelines:[],fileEngines:{},view:"overview",mode:"pipelines",pipelineType:"all",engineType:"",status:"all",search:"",sourceTypeFilter:"",selectedPipelineName:"",createKind:"",busy:!1,_unsubs:[],_pollTimer:null,get selectedEnv(){return e.$ok.stores.okdb.selectedEnv||"default"},normalizeView:e=>["overview","create"].includes(e)?e:"overview",normalizeMode:e=>["pipelines","engines"].includes(e)?e:"pipelines",normalizePipelineType:e=>["all","embedding","file"].includes(e)?e:"all",normalizeEngineType:e=>String(e||"").trim(),legacyFilterState(e){switch(e){case"pipelines":default:return{mode:"pipelines",pipelineType:"all",engineType:""};case"standalone":case"runtime":return{mode:"engines",pipelineType:"all",engineType:""};case"embedding":return{mode:"pipelines",pipelineType:"embedding",engineType:""};case"file":return{mode:"pipelines",pipelineType:"file",engineType:""}}},normalizeStatus:e=>["all","running","attention","stopped"].includes(e)?e:"all",normalizeCreateKind:e=>["processor","materializer","queue-worker","embedding"].includes(e)?e:"",setView(e){const i=this.normalizeView(e);this.view!==i&&(this.view=i,this.syncRouteState())},setModeFilter(e){const i=this.normalizeMode(e);this.mode!==i&&(this.mode=i,"pipelines"===i&&(this.engineType=""),"engines"===i&&(this.pipelineType="all",this.selectedPipelineName=""),this.syncRouteState())},setPipelineTypeFilter(e){const i=this.normalizePipelineType(e);this.pipelineType!==i&&(this.pipelineType=i,this.syncRouteState())},setEngineTypeFilter(e){const i=this.normalizeEngineType(e);this.engineType!==i&&(this.engineType=i,this.syncRouteState())},setSourceTypeFilter(e){const i=String(e??"");this.sourceTypeFilter!==i&&(this.sourceTypeFilter=i,this.syncRouteState())},get availableSourceTypes(){const e=new Set;for(const i of this.embedEngines??[])i?.config?.source_type&&e.add(i.config.source_type),i?.runtime?.source_type&&e.add(i.runtime.source_type),i?.stats?.source_type&&e.add(i.stats.source_type),i?.stats?.indexer?.source_type&&e.add(i.stats.indexer.source_type),i?.config?.target_type&&e.add(i.config.target_type);const i=this.fileEngines??{};for(const t of[...i.extractors??[],...i.collections??[],...i.workers??[]])t?.config?.source_type&&e.add(t.config.source_type);return[...e].sort()},get availableEngineTypes(){const e=new Set;for(const i of this.embedEngines??[])i?.type&&e.add(i.type);const i=this.fileEngines??{};for(const t of[...i.extractors??[],...i.collections??[],...i.workers??[]])t?.type&&e.add(t.type);return[...e].sort()},get workspaceCount(){const e=this.fileEngines??{},i=(this.embedEngines??[]).length+(e.extractors??[]).length+(e.collections??[]).length+(e.workers??[]).length,t=(this.embedPipelines??[]).length+(e.collections??[]).length;return"engines"===this.mode?i:t},get searchPlaceholder(){return"engines"===this.mode?"Search engines…":"Search pipelines…"},get routeSearch(){return e.$vars?.$route?.search??e.$vars?.$router?._search??{}},applyRouteState(){const e=this.routeSearch,i=this.legacyFilterState(e.family||""),t=this.normalizeView(e.view||"overview"),s=this.normalizeMode(e.mode||i.mode||"pipelines"),n=this.normalizePipelineType(e.pipelineType||i.pipelineType||"all"),l=this.normalizeEngineType(e.engineType||i.engineType||""),r=this.normalizeStatus(e.status||"all"),o=String(e.search||""),a=String(e.sourceType||""),p=String(e.pipeline||""),h=this.normalizeCreateKind(e.kind||"");this.view!==t&&(this.view=t),this.mode!==s&&(this.mode=s),this.pipelineType!==n&&(this.pipelineType=n),this.engineType!==l&&(this.engineType=l),this.status!==r&&(this.status=r),this.search!==o&&(this.search=o),this.sourceTypeFilter!==a&&(this.sourceTypeFilter=a),this.selectedPipelineName!==p&&(this.selectedPipelineName=p),this.createKind!==h&&(this.createKind=h)},syncRouteState(){const i=e.$vars?.$router;if(!i?.resolve||!i?.replace)return;const t=this.routeSearch,s={...t};this.view&&"overview"!==this.view?s.view=this.view:delete s.view,this.mode&&"pipelines"!==this.mode?s.mode=this.mode:delete s.mode,this.pipelineType&&"all"!==this.pipelineType?s.pipelineType=this.pipelineType:delete s.pipelineType,this.engineType?s.engineType=this.engineType:delete s.engineType,this.status&&"all"!==this.status?s.status=this.status:delete s.status,this.search?.trim()?s.search=this.search.trim():delete s.search,this.sourceTypeFilter?.trim()?s.sourceType=this.sourceTypeFilter.trim():delete s.sourceType,this.selectedPipelineName?.trim()?s.pipeline=this.selectedPipelineName.trim():delete s.pipeline,"create"===this.view&&this.createKind?s.kind=this.createKind:delete s.kind,delete s.family;const n=this.legacyFilterState(t.family||""),l=this.normalizeView(t.view||"overview"),r=this.normalizeMode(t.mode||n.mode||"pipelines"),o=this.normalizePipelineType(t.pipelineType||n.pipelineType||"all"),a=this.normalizeEngineType(t.engineType||n.engineType||""),p=this.normalizeStatus(t.status||"all"),h=String(t.search||""),c=String(t.sourceType||""),d=String(t.pipeline||""),u=this.normalizeCreateKind(t.kind||"");if(l===this.view&&r===this.mode&&o===this.pipelineType&&a===this.engineType&&p===this.status&&h===(this.search||"")&&c===(this.sourceTypeFilter||"")&&d===(this.selectedPipelineName||"")&&u===(this.createKind||""))return;const y=e.$vars?.$route?.location||i._path||"/engines";i.replace(i.resolve(y,s,i._anchor||""))},clearFilters(){("all"!==this.pipelineType||this.engineType||"all"!==this.status||this.search||this.sourceTypeFilter)&&(this.pipelineType="all",this.engineType="",this.status="all",this.search="",this.sourceTypeFilter="",this.syncRouteState())},setSearchTerm(e){const i=String(e??"");this.search!==i&&(this.search=i,this.syncRouteState())},setStatusFilter(e){const i=this.normalizeStatus(e);this.status!==i&&(this.status=i,this.syncRouteState())},clearSourceTypeFilter(){this.sourceTypeFilter&&(this.sourceTypeFilter="",this.syncRouteState())},onPipelineSelected(e){const i=e?.name??"";this.selectedPipelineName!==i&&(this.selectedPipelineName=i,this.syncRouteState())},async load(){this.busy=!0;const e=this.selectedEnv;try{const[i,t,s]=await Promise.allSettled([fetch(`${__ENV__.API}/env/${encodeURIComponent(e)}/engines`).then(e=>e.json()),fetch(`${__ENV__.API}/embeddings/embedders`).then(e=>e.json()),fetch(`${__ENV__.API}/env/${encodeURIComponent(e)}/pipelines`).then(e=>e.json())]),n="fulfilled"===i.status?i.value?.data??[]:[],l="fulfilled"===t.status?t.value?.data??[]:[];this.embedEngines=[...n,...l],this.embedPipelines="fulfilled"===s.status?s.value?.data??(Array.isArray(s.value)?s.value:[]):[],this.fileEngines={extractors:n.filter(e=>"file-extractor"===e.type),collections:n.filter(e=>"file-collection"===e.type),workers:n.filter(e=>"file-extractor-worker"===e.type)}}catch{}finally{this.busy=!1,this._scheduleProgressPoll()}},anyPipelineFlowing(){return(this.embedPipelines||[]).some(e=>{const i=(e.engines||[]).find(e=>"indexer"===e?.type||"indexer"===e?.role),t=i?.stats?.doc_counts??i?.runtime?.doc_counts??null;return(t?.pending??0)>0})},_scheduleProgressPoll(){this._pollTimer||this.anyPipelineFlowing()&&(this._pollTimer=setTimeout(async()=>{this._pollTimer=null,await this.load()},2e3))},async onCreated(){this.view="overview",this.syncRouteState(),await this.load()}}),async init(e){this.applyRouteState(),await this.load();const i=()=>this.load();this._unsubs=[t.on("engine:started",i),t.on("engine:stopped",i),t.on("engine:error",i),t.on("pipeline:start",i),t.on("pipeline:stop",i),t.on("pipeline:delete",i)],e.$watch(()=>e.$ok.stores.okdb.selectedEnv,()=>this.load()),e.$watch(()=>JSON.stringify(this.routeSearch),()=>this.applyRouteState())},unmount(){for(const e of this._unsubs)e();this._unsubs=[],this._pollTimer&&clearTimeout(this._pollTimer),this._pollTimer=null}};</script><style>.eng-nav-row{display:flex;align-items:center;gap:8px;width:100%;text-align:left;padding:6px 10px;border-radius:6px;border:1px solid transparent;background:0 0;color:var(--okdb-app-fg-muted);font-size:12px;cursor:pointer;transition:background .12s,border-color .12s,color .12s}.eng-nav-row:hover{background:var(--okdb-app-surface);border-color:var(--okdb-app-border);color:var(--okdb-app-fg-strong)}.eng-nav-row--on{background:var(--okdb-app-surface);border-color:var(--okdb-accent);color:var(--okdb-app-fg-strong)}.eng-nav-sep{font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:.08em;color:var(--okdb-app-fg-subtle);padding:6px 10px 2px}.eng-filter-card{display:flex;flex-direction:column;gap:10px;padding:10px;border:1px solid var(--okdb-app-border);border-radius:10px;background:var(--okdb-app-bg-deep);min-width:0}.eng-field{display:flex;flex-direction:column;gap:4px;min-width:0}.eng-field__label{font-size:11px;color:var(--okdb-app-fg-muted)}.eng-control{width:100%;min-width:0;box-sizing:border-box;font-size:12px}.eng-segment{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;width:100%}.eng-segment__btn{min-width:0;width:100%;padding:6px 10px;border-radius:8px;border:1px solid var(--okdb-app-border);background:var(--okdb-app-bg-deep);color:var(--okdb-app-fg-muted);font-size:11px;font-weight:600;cursor:pointer;transition:background .12s,border-color .12s,color .12s,box-shadow .12s}.eng-segment__btn:hover{background:var(--okdb-app-surface);border-color:var(--okdb-app-border);color:var(--okdb-app-fg-strong)}.eng-segment__btn--active{border-color:var(--okdb-accent);background:color-mix(in srgb,var(--okdb-accent) 7%,transparent);color:var(--okdb-accent);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--okdb-accent) 13%,transparent)}.eng-filter-actions{display:flex;justify-content:flex-end}.eng-clear-btn{font-size:11px;padding:5px 10px;border-radius:999px;border:1px solid var(--okdb-app-border);color:var(--okdb-app-fg-muted);background:var(--okdb-app-bg-deep);cursor:pointer}.eng-clear-btn:hover{border-color:var(--okdb-app-border-strong);color:var(--okdb-app-fg-strong);background:var(--okdb-app-surface)}</style><template><component import="../../layouts/_default.ok.html"><template name="sidebar"><div style="display:flex;flex-direction:column;gap:8px;height:100%;min-height:0;overflow-y:auto"><button :class="view === 'create' ? 'eng-nav-row eng-nav-row--on' : 'eng-nav-row'" @click="setView('create')" title="Create a pipeline, which provisions and wires together one or more engines."><span style="width:14px;text-align:center;flex-shrink:0;opacity:.9;color:var(--okdb-accent)">+</span> <span style="color:var(--okdb-accent)">New Pipeline</span></button><div class="eng-nav-sep">Engines</div><button :class="view === 'overview' ? 'eng-nav-row eng-nav-row--on' : 'eng-nav-row'" @click="setView('overview')"><span style="width:14px;text-align:center;flex-shrink:0;opacity:.7">⊛</span> <span>Workspace</span> <span style="margin-left:auto;font-size:10px;opacity:.4">{{ workspaceCount }}</span></button><if :="view === 'overview'"><div style="height:1px;background:var(--okdb-app-border);margin:2px 0"></div><div class="eng-nav-sep" style="padding-top:4px">Filters</div><div class="eng-filter-card"><label class="eng-field"><span class="eng-field__label" title="Search by name, type, handler, env, pipeline, or source type">Search</span> <input class="eng-control" :value="search" @input:debounce.250="setSearchTerm($event.target.value)" :placeholder="searchPlaceholder"/></label><div class="eng-field"><span class="eng-field__label" title="Switch between the grouped pipeline view and the flat engine inventory.">Mode</span><div class="eng-segment"><button @click="setModeFilter('pipelines')" :class="mode === 'pipelines' ? 'eng-segment__btn eng-segment__btn--active' : 'eng-segment__btn'" title="Show grouped pipelines">Pipelines</button> <button @click="setModeFilter('engines')" :class="mode === 'engines' ? 'eng-segment__btn eng-segment__btn--active' : 'eng-segment__btn'" title="Show individual engines">Engines</button></div></div><if :="mode === 'pipelines'"><label class="eng-field"><span class="eng-field__label" title="Filter grouped pipelines by pipeline type.">Pipeline Type</span> <select class="eng-control" @change="setPipelineTypeFilter($event.target.value)"><option value="all" :selected="pipelineType === 'all'">All pipelines</option><option value="embedding" :selected="pipelineType === 'embedding'">Env</option><option value="file" :selected="pipelineType === 'file'">Files</option></select></label></if><if :="mode === 'engines'"><label class="eng-field"><span class="eng-field__label" title="Filter the flat engine list by engine type.">Engine Type</span> <select class="eng-control" @change="setEngineTypeFilter($event.target.value)"><option value="" :selected="!engineType">All engines</option><each :of="availableEngineTypes" let:item="t"><option :value="t" :selected="engineType === t">{{ t }}</option></each></select></label></if><label class="eng-field"><span class="eng-field__label">Status</span> <select class="eng-control" @change="setStatusFilter($event.target.value)"><option value="all" :selected="status === 'all'">Any</option><option value="running" :selected="status === 'running'">Running</option><option value="attention" :selected="status === 'attention'">Needs attention</option><option value="stopped" :selected="status === 'stopped'">Stopped</option></select></label><if :="availableSourceTypes.length > 0"><label class="eng-field" title="Filter by the data type engines process or index"><span class="eng-field__label">Source Type</span> <select class="eng-control" @change="setSourceTypeFilter($event.target.value)"><option value="" :selected="!sourceTypeFilter">All types</option><each :of="availableSourceTypes" let:item="st"><option :value="st" :selected="sourceTypeFilter === st">{{ st }}</option></each></select></label></if><if :="pipelineType !== 'all' || engineType || status !== 'all' || search || sourceTypeFilter"><div class="eng-filter-actions"><button @click="clearFilters()" class="eng-clear-btn">Clear filters</button></div></if></div></if></div></template><template name="default"><if :="view === 'create'"><pipeline-create-panel :locktype="sourceTypeFilter" :lockenv="selectedEnv" :initialkind="createKind" @created="onCreated()"/></if><if :="view === 'overview'"><engines-overview :embed-engines="embedEngines" :embed-pipelines="embedPipelines" :file-engines="fileEngines" :mode="mode" :pipelinetype="pipelineType" :enginetype="engineType" :status="status" :search="search" :sourcetype="sourceTypeFilter" :selectedpipeline="selectedPipelineName" @select="onPipelineSelected($event.detail)" @refresh="load()" @create-pipeline="setView('create')"/></if></template></component></template>
|
package/types/environment.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
OKDBFilter,
|
|
5
5
|
OKDBRangeOptions,
|
|
6
6
|
OKDBQueryOptions,
|
|
7
|
+
OKDBIndexRangeOptions,
|
|
7
8
|
OKDBGeoQueryOptions,
|
|
8
9
|
OKDBFtsQueryOptions,
|
|
9
10
|
OKDBWriteOptions,
|
|
@@ -81,8 +82,9 @@ export interface OKDBEnvironment {
|
|
|
81
82
|
getByPrefix<T = unknown>(type: string, prefix: OKDBPrimaryKey, options?: OKDBRangeOptions): Iterable<OKDBEntry<T>>;
|
|
82
83
|
|
|
83
84
|
// ── Index queries ─────────────────────────────────────────────────────────
|
|
84
|
-
getIndex<T = unknown>(type: string, index: string[], options?:
|
|
85
|
-
byIndex<T = unknown>(type: string, index: string[], options?:
|
|
85
|
+
getIndex<T = unknown>(type: string, index: string[], options?: OKDBIndexRangeOptions): Iterable<OKDBIndexEntry<T>>;
|
|
86
|
+
byIndex<T = unknown>(type: string, index: string[], options?: OKDBIndexRangeOptions): Iterable<OKDBIndexEntry<T>>;
|
|
87
|
+
countByIndex(type: string, index: string[], options?: OKDBIndexRangeOptions): number;
|
|
86
88
|
query<T = unknown>(type: string, filter: OKDBFilter, options?: OKDBQueryOptions): Iterable<OKDBIndexEntry<T>>;
|
|
87
89
|
geoQuery<T = unknown>(type: string, field: string, options: OKDBGeoQueryOptions): Iterable<OKDBEntry<T>>;
|
|
88
90
|
ftsQuery<T = unknown>(
|
|
@@ -73,6 +73,8 @@ export interface OKDBBucketRangeOptions {
|
|
|
73
73
|
granularity?: string;
|
|
74
74
|
/** When true, includes the bucket containing Date.now(). Default false. */
|
|
75
75
|
includePartial?: boolean;
|
|
76
|
+
/** Pagination controls applied to any grouped ($countBy) reducer in the result. */
|
|
77
|
+
preview?: OKDBViewPreviewOptions;
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
/** A single entry in the array returned by views.range() */
|
|
@@ -80,7 +82,7 @@ export interface OKDBBucketRangeEntry {
|
|
|
80
82
|
/** Canonical string key for this bucket (ISO date string for preset:'time'). */
|
|
81
83
|
bucketKey: string;
|
|
82
84
|
granularity: string;
|
|
83
|
-
/** Per-reducer aggregated values. Scalar → { value: N }; $countBy → {
|
|
85
|
+
/** Per-reducer aggregated values. Scalar → { value: N }; $countBy → { totalGroups, preview, hasMore, cursor }. */
|
|
84
86
|
reducers: Record<string, OKDBScalarResult | OKDBCountByResult>;
|
|
85
87
|
/** Per-$ref sub-view aggregated values. */
|
|
86
88
|
refs: Record<string, Record<string, OKDBScalarResult | OKDBCountByResult>>;
|
|
@@ -131,8 +133,40 @@ export interface OKDBScalarResult {
|
|
|
131
133
|
items?: () => unknown[];
|
|
132
134
|
}
|
|
133
135
|
|
|
134
|
-
/**
|
|
135
|
-
export
|
|
136
|
+
/** Pagination controls for a grouped ($countBy) reducer's preview page */
|
|
137
|
+
export interface OKDBViewPreviewOptions {
|
|
138
|
+
/** Max groups per page. Default 50. */
|
|
139
|
+
limit?: number;
|
|
140
|
+
/** Sort direction. Default 'desc' for $countBy (by count). */
|
|
141
|
+
order?: 'asc' | 'desc';
|
|
142
|
+
/** Sort axis. Default 'count' for $countBy. */
|
|
143
|
+
axis?: string;
|
|
144
|
+
/** Opaque cursor from a previous page's `cursor` field. */
|
|
145
|
+
cursor?: string;
|
|
146
|
+
/** Per-reducer override, keyed by the reduce field name. */
|
|
147
|
+
perReducer?: Record<string, { limit?: number; order?: 'asc' | 'desc'; axis?: string; cursor?: string }>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** A single group entry within a $countBy preview page */
|
|
151
|
+
export interface OKDBCountByPreviewEntry {
|
|
152
|
+
key: string;
|
|
153
|
+
value: number;
|
|
154
|
+
/** Present when items:true was set — returns the live source docs for this group */
|
|
155
|
+
items?: () => unknown[];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Shape returned for a $countBy reducer output.
|
|
160
|
+
* Paginated — `preview` holds at most `limit` groups (default 50), sorted by
|
|
161
|
+
* count descending. Pass `{ preview: { limit, order, axis, cursor } }` to
|
|
162
|
+
* views.get()/range() to page through the rest via `hasMore`/`cursor`.
|
|
163
|
+
*/
|
|
164
|
+
export interface OKDBCountByResult {
|
|
165
|
+
totalGroups: number;
|
|
166
|
+
preview: OKDBCountByPreviewEntry[];
|
|
167
|
+
hasMore: boolean;
|
|
168
|
+
cursor: string | null;
|
|
169
|
+
}
|
|
136
170
|
|
|
137
171
|
/** Shape returned for a $ref slot */
|
|
138
172
|
export type OKDBRefResult = Record<string, OKDBScalarResult | OKDBCountByResult>;
|
|
@@ -180,7 +214,7 @@ export declare class OKDBViews {
|
|
|
180
214
|
* Read the current view output. Synchronous and O(1).
|
|
181
215
|
* Returns null if the view does not exist.
|
|
182
216
|
*/
|
|
183
|
-
get(name: string): OKDBViewOutput | null;
|
|
217
|
+
get(name: string, options?: { preview?: OKDBViewPreviewOptions }): OKDBViewOutput | null;
|
|
184
218
|
|
|
185
219
|
/**
|
|
186
220
|
* Get view lifecycle meta (state, clock, error).
|
package/types/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ import type {
|
|
|
38
38
|
OKDBFilter,
|
|
39
39
|
OKDBRangeOptions,
|
|
40
40
|
OKDBQueryOptions,
|
|
41
|
+
OKDBIndexRangeOptions,
|
|
41
42
|
OKDBGeoQueryOptions,
|
|
42
43
|
OKDBFtsQueryOptions,
|
|
43
44
|
OKDBWriteOptions,
|
|
@@ -169,8 +170,9 @@ export declare class OKDB {
|
|
|
169
170
|
getByPrefix<T = unknown>(type: string, prefix: OKDBPrimaryKey, options?: OKDBRangeOptions): Iterable<OKDBEntry<T>>;
|
|
170
171
|
|
|
171
172
|
// ── Index queries ─────────────────────────────────────────────────────────
|
|
172
|
-
getIndex<T = unknown>(type: string, index: string[], options?:
|
|
173
|
-
byIndex<T = unknown>(type: string, index: string[], options?:
|
|
173
|
+
getIndex<T = unknown>(type: string, index: string[], options?: OKDBIndexRangeOptions): Iterable<OKDBIndexEntry<T>>;
|
|
174
|
+
byIndex<T = unknown>(type: string, index: string[], options?: OKDBIndexRangeOptions): Iterable<OKDBIndexEntry<T>>;
|
|
175
|
+
countByIndex(type: string, index: string[], options?: OKDBIndexRangeOptions): number;
|
|
174
176
|
query<T = unknown>(type: string, filter: OKDBFilter, options?: OKDBQueryOptions): Iterable<OKDBIndexEntry<T>>;
|
|
175
177
|
geoQuery<T = unknown>(type: string, field: string, options: OKDBGeoQueryOptions): Iterable<OKDBEntry<T>>;
|
|
176
178
|
ftsQuery<T = unknown>(
|
package/types/options.d.ts
CHANGED
|
@@ -120,16 +120,38 @@ export interface OKDBRangeOptions {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
export interface OKDBQueryOptions {
|
|
123
|
-
index?: string[];
|
|
123
|
+
index?: string[] | { fields: string[]; prefix?: OKDBIndexKey; start?: OKDBIndexKey; end?: OKDBIndexKey };
|
|
124
124
|
prefix?: OKDBIndexKey;
|
|
125
|
-
start
|
|
126
|
-
|
|
125
|
+
/** Inclusive index-key lower/upper bound. NOT `start`/`end` — those are byIndex/getRange
|
|
126
|
+
* names and are not implemented by query(); passing them throws. */
|
|
127
127
|
startIndex?: OKDBIndexKey;
|
|
128
|
+
endIndex?: OKDBIndexKey;
|
|
129
|
+
/** Primary-key page-boundary hint (cursor-style pagination), as an alternative to startIndex/endIndex. */
|
|
130
|
+
startKey?: OKDBPrimaryKey;
|
|
131
|
+
endKey?: OKDBPrimaryKey;
|
|
128
132
|
limit?: number;
|
|
129
133
|
reverse?: boolean;
|
|
130
134
|
offset?: number;
|
|
131
135
|
}
|
|
132
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Options for byIndex/getIndex/countByIndex. Distinct from OKDBQueryOptions: these forward
|
|
139
|
+
* directly to lmdb-js's own range scan, so `start`/`end` ARE the real (direction-independent)
|
|
140
|
+
* index-key bounds here — unlike query(), which uses startIndex/endIndex instead.
|
|
141
|
+
*/
|
|
142
|
+
export interface OKDBIndexRangeOptions {
|
|
143
|
+
prefix?: OKDBIndexKey;
|
|
144
|
+
start?: OKDBIndexKey;
|
|
145
|
+
end?: OKDBIndexKey;
|
|
146
|
+
reverse?: boolean;
|
|
147
|
+
limit?: number;
|
|
148
|
+
offset?: number;
|
|
149
|
+
snapshot?: boolean;
|
|
150
|
+
transaction?: unknown;
|
|
151
|
+
/** byIndex only: include all entries violating a unique index instead of just the winner. */
|
|
152
|
+
includeViolations?: boolean;
|
|
153
|
+
}
|
|
154
|
+
|
|
133
155
|
export interface OKDBGeoQueryOptions {
|
|
134
156
|
lat: number;
|
|
135
157
|
lon: number;
|