@kedem/okdb 2.5.0 → 2.6.1
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/CHANGELOG.md +90 -0
- package/algorithm-worker-thread.js +1 -1
- package/bin/okdb.js +1 -1
- package/docs/auth-permissions.md +31 -5
- 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/admin-app.js +1 -1
- package/public/components/schema-edit-modal.ok.js +1 -0
- package/public/core/db/db-section.ok.html +1 -0
- package/public/core/db/modals/add-item-modal.ok.js +1 -0
- package/public/core/db/modals/create-fts-modal.ok.js +1 -0
- package/public/core/db/modals/create-index-modal.ok.js +1 -0
- package/public/core/db/parts/db-overview.ok.js +1 -0
- package/public/core/db/parts/edit-row.ok.js +1 -0
- package/public/core/db/parts/type-changelog.ok.js +1 -0
- package/public/core/db/parts/type-data-tab.ok.js +1 -0
- package/public/core/db/parts/type-list.ok.js +1 -0
- package/public/core/db/parts/type-manage-tab.ok.js +1 -0
- package/public/core/db/parts/type-schema-tab.ok.js +1 -0
- package/public/core/db/parts/type-viewer.ok.js +1 -0
- package/public/core/db/type-ops.js +1 -0
- package/public/core/docs/docs-page.ok.html +1 -0
- package/public/core/license/license-panel.ok.js +1 -0
- package/public/core/system/parts/system-log.ok.js +1 -0
- package/public/core/system/parts/system-processing-panel.ok.js +1 -0
- package/public/core/system/parts/system-storage-panel.ok.js +1 -0
- package/public/core/system/system-events-page.ok.js +1 -0
- package/public/core/system/system-logs-page.ok.js +1 -0
- package/public/core/system/system-overview-page.ok.html +1 -0
- package/public/core/system/system-runtime-page.ok.js +1 -0
- package/public/core/system/system-section.ok.html +1 -0
- package/public/features/api/api-panel.ok.js +1 -0
- package/public/features/api/index.js +1 -0
- package/public/features/auth/auth-panel.ok.js +1 -0
- package/public/features/auth/index.js +1 -0
- package/public/features/files/files-section.ok.html +1 -0
- package/public/features/files/index.js +1 -0
- package/public/features/files/parts/files-file-list.ok.js +1 -0
- package/public/features/files/parts/files-path-browser.ok.js +1 -0
- package/public/features/files/parts/files-preview.ok.js +1 -0
- package/public/features/files/parts/files-upload-panel.ok.js +1 -0
- package/public/features/functions/exports.js +1 -0
- package/public/features/functions/functions-section.ok.html +1 -0
- package/public/features/functions/functions-store.js +1 -0
- package/public/features/functions/index.js +1 -0
- package/public/features/functions/modals/function-modal.ok.js +1 -0
- package/public/features/functions/parts/function-detail.ok.js +1 -0
- package/public/features/functions/parts/function-logs.ok.js +1 -0
- package/public/features/functions/parts/function-runner.ok.js +1 -0
- package/public/features/pipelines/engine-ui-utils.js +1 -0
- package/public/features/pipelines/exports.js +1 -0
- package/public/features/pipelines/index.js +1 -0
- package/public/features/pipelines/modals/create-pipeline-modal.ok.js +1 -0
- package/public/features/pipelines/modals/edit-pipeline-modal.ok.js +1 -0
- package/public/features/pipelines/modals/engine-modal.ok.js +1 -0
- package/public/features/pipelines/parts/embed-create-panel.ok.js +1 -0
- package/public/features/pipelines/parts/embed-embedder-panel.ok.js +1 -0
- package/public/features/pipelines/parts/embed-indexer-panel.ok.js +1 -0
- package/public/features/pipelines/parts/embed-search-panel.ok.js +1 -0
- package/public/features/pipelines/parts/embed-worker-panel.ok.js +1 -0
- package/public/features/pipelines/parts/embeddings-engine-panel.ok.js +1 -0
- package/public/features/pipelines/parts/engine-declaration-editor.ok.js +1 -0
- package/public/features/pipelines/parts/engines-overview.ok.js +1 -0
- package/public/features/pipelines/parts/generic-engine-panel.ok.js +1 -0
- package/public/features/pipelines/parts/pipeline-create-panel.ok.js +1 -0
- package/public/features/pipelines/parts/pipeline-flow-strip.ok.js +1 -0
- package/public/features/pipelines/parts/type-pipelines-tab.ok.js +1 -0
- package/public/features/pipelines/pipelines-section.ok.html +1 -0
- package/public/features/queue/index.js +1 -0
- package/public/features/queue/modals/create-bucket-modal.ok.js +1 -0
- package/public/features/queue/modals/edit-bucket-modal.ok.js +1 -0
- package/public/features/queue/modals/edit-job-modal.ok.js +1 -0
- package/public/features/queue/modals/enqueue-job-modal.ok.js +1 -0
- package/public/features/queue/modals/job-type-modal.ok.js +1 -0
- package/public/features/queue/parts/job-log-panel.ok.js +1 -0
- package/public/features/queue/parts/queue-buckets.ok.js +1 -0
- package/public/features/queue/parts/queue-job-types.ok.js +1 -0
- package/public/features/queue/parts/queue-jobs.ok.js +1 -0
- package/public/features/queue/parts/queue-types.ok.js +1 -0
- package/public/features/queue/parts/queue-workers.ok.js +1 -0
- package/public/features/queue/queue-section.ok.html +1 -0
- package/public/features/sync/index.js +1 -0
- package/public/features/sync/sync-panel.ok.js +1 -0
- package/public/features/views/index.js +1 -0
- package/public/features/views/modals/create-view-modal.ok.js +1 -0
- package/public/features/views/parts/views-list.ok.js +1 -0
- package/public/features/views/parts/views-overview.ok.js +1 -0
- package/public/features/views/views-section.ok.html +1 -0
- package/public/features/views/views-store.js +1 -0
- package/public/index.html +9 -3
- package/public/modules/ok.js +1 -1
- package/public/shell/admin-shell.ok.html +3 -0
- package/public/shell/core-manifest.js +1 -0
- package/public/shell/shell-piece.ok.js +1 -0
- package/public/shell/shell-section-host.ok.js +1 -0
- package/public/shell/shell-section.ok.js +1 -0
- package/public/shell/shell-store.js +1 -0
- package/public/stores/auth-store.js +1 -1
- package/public/stores/okdb-store.js +1 -1
- package/public/stores/storage-store.js +1 -0
- package/public/styles.css +1 -1
- package/public/vendor/okjs/ok.esm.min.js +1 -1
- package/public/vendor/okjs/toolkit/components/ok-chart.ok.js +1 -1
- package/public/vendor/okjs/toolkit/components/ok-doc-viewer.ok.js +1 -1
- package/public/vendor/okjs/toolkit/components/ok-marked.ok.js +1 -1
- package/public/vendor/okjs/toolkit/components/ok-monaco.ok.js +1 -1
- package/public/vendor/okjs/toolkit/core/virtualized.ok.js +1 -1
- package/public/vendor/okjs/toolkit/editor/ok-live-shell.ok.js +1 -1
- package/public/vendor/okjs/toolkit/elements/ok-select.ok.js +1 -1
- package/public/vendor/okjs/toolkit/elements/ok-table.ok.js +1 -1
- package/public/components/admin-route-host.ok.js +0 -1
- package/public/components/field.html +0 -158
- package/public/layouts/_default.ok.html +0 -3
- package/public/sections/api/index.ok.html +0 -1
- package/public/sections/auth/index.ok.html +0 -1
- package/public/sections/auth/modals/perm-info-popover.ok.js +0 -1
- package/public/sections/db/index.ok.html +0 -1
- package/public/sections/db/modals/add-item-modal.ok.js +0 -1
- package/public/sections/db/modals/create-fts-modal.ok.js +0 -1
- package/public/sections/db/modals/create-index-modal.ok.js +0 -1
- package/public/sections/db/modals/create-pipeline-modal.ok.js +0 -1
- package/public/sections/db/modals/schema-edit-modal.ok.js +0 -1
- package/public/sections/db/parts/db-overview.ok.js +0 -1
- package/public/sections/db/parts/edit-row.ok.js +0 -1
- package/public/sections/db/parts/type-changelog.ok.js +0 -1
- package/public/sections/db/parts/type-list.ok.js +0 -1
- package/public/sections/db/parts/type-pipelines-tab.ok.js +0 -1
- package/public/sections/db/parts/type-schema-tab.ok.js +0 -1
- package/public/sections/db/parts/type-viewer.ok.js +0 -1
- package/public/sections/db/parts/type-violations-tab.ok.js +0 -1
- package/public/sections/docs/index.ok.html +0 -1
- package/public/sections/embeddings/index.ok.html +0 -1
- package/public/sections/embeddings/modals/edit-pipeline-modal.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-create-panel.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-embedder-panel.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-engine-declaration-editor.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-engine-list.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-indexer-panel.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-lifecycle-bar.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-overview.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-search-panel.ok.js +0 -1
- package/public/sections/embeddings/parts/embed-worker-panel.ok.js +0 -1
- package/public/sections/embeddings/parts/embeddings-engine-panel.ok.js +0 -1
- package/public/sections/embeddings/parts/engines-overview.ok.js +0 -1
- package/public/sections/embeddings/parts/pipeline-create-panel.ok.js +0 -1
- package/public/sections/embeddings/parts/pipeline-flow-strip.ok.js +0 -1
- package/public/sections/engines/engine-ui-utils.js +0 -1
- package/public/sections/engines/index.ok.html +0 -1
- package/public/sections/engines/modals/engine-modal.ok.js +0 -1
- package/public/sections/engines/parts/engine-declaration-editor.ok.js +0 -1
- package/public/sections/engines/parts/generic-engine-panel.ok.js +0 -1
- package/public/sections/files/index.ok.html +0 -1
- package/public/sections/files/parts/files-collection-list.ok.js +0 -1
- package/public/sections/files/parts/files-collection-panel.ok.js +0 -1
- package/public/sections/files/parts/files-file-list.ok.js +0 -1
- package/public/sections/files/parts/files-path-browser.ok.js +0 -1
- package/public/sections/files/parts/files-preview.ok.js +0 -1
- package/public/sections/files/parts/files-upload-panel.ok.js +0 -1
- package/public/sections/functions/index.ok.html +0 -1
- package/public/sections/functions/modals/function-modal.ok.js +0 -1
- package/public/sections/functions/parts/function-detail.ok.js +0 -1
- package/public/sections/functions/parts/function-logs.ok.js +0 -1
- package/public/sections/functions/parts/function-runner.ok.js +0 -1
- package/public/sections/license/index.ok.html +0 -1
- package/public/sections/license/parts/license-panel.ok.js +0 -1
- package/public/sections/queue/index.ok.html +0 -1
- package/public/sections/queue/modals/create-bucket-modal.ok.js +0 -1
- package/public/sections/queue/modals/edit-bucket-modal.ok.js +0 -1
- package/public/sections/queue/modals/edit-job-modal.ok.js +0 -1
- package/public/sections/queue/modals/enqueue-job-modal.ok.js +0 -1
- package/public/sections/queue/modals/job-type-modal.ok.js +0 -1
- package/public/sections/queue/parts/job-log-panel.ok.js +0 -1
- package/public/sections/queue/parts/ok-job-form.ok.js +0 -1
- package/public/sections/queue/parts/queue-buckets.ok.js +0 -1
- package/public/sections/queue/parts/queue-job-types.ok.js +0 -1
- package/public/sections/queue/parts/queue-jobs.ok.js +0 -1
- package/public/sections/queue/parts/queue-types.ok.js +0 -1
- package/public/sections/queue/parts/queue-workers.ok.js +0 -1
- package/public/sections/sync/index.ok.html +0 -5
- package/public/sections/sync/parts/sync-node-detail.ok.js +0 -1
- package/public/sections/system/index.ok.html +0 -1
- package/public/sections/system/parts/system-api-panel.ok.js +0 -1
- package/public/sections/system/parts/system-auth-panel.ok.js +0 -1
- package/public/sections/system/parts/system-log.ok.js +0 -1
- package/public/sections/system/parts/system-processing-panel.ok.js +0 -1
- package/public/sections/system/parts/system-status.ok.js +0 -1
- package/public/sections/system/parts/system-storage-panel.ok.js +0 -1
- package/public/sections/system/parts/system-sync-panel.ok.js +0 -1
- package/public/sections/views/index.ok.html +0 -1
- package/public/sections/views/modals/create-view-modal.ok.js +0 -1
- package/public/sections/views/parts/views-list.ok.js +0 -1
- package/public/sections/views/parts/views-overview.ok.js +0 -1
- package/public/stores/functions-store.js +0 -1
- /package/public/{sections → core}/db/parts/tm-timeline.ok.js +0 -0
- /package/public/{util → core/db}/sift-schema.js +0 -0
- /package/public/{view-models → core/db}/type-query-vm.js +0 -0
- /package/public/{sections → core}/system/modals/data-ops-modal.ok.js +0 -0
- /package/public/{sections → core}/system/parts/system-locks-panel.ok.js +0 -0
- /package/public/{sections → core}/system/parts/system-log-history.ok.js +0 -0
- /package/public/{sections → core}/system/parts/system-process-panel.ok.js +0 -0
- /package/public/{sections → core}/system/parts/system-runtime-overview.ok.js +0 -0
- /package/public/{sections → features}/api/parts/api-endpoint.ok.js +0 -0
- /package/public/{sections → features}/auth/modals/create-token-modal.ok.js +0 -0
- /package/public/{sections → features}/auth/modals/edit-token-modal.ok.js +0 -0
- /package/public/{sections → features}/auth/parts/token-detail.ok.js +0 -0
- /package/public/{sections → features}/auth/parts/token-list.ok.js +0 -0
- /package/public/{sections → features}/files/parts/files-blob-status.ok.js +0 -0
- /package/public/{sections → features}/files/parts/files-overview.ok.js +0 -0
- /package/public/{sections → features}/functions/parts/functions-list.ok.js +0 -0
- /package/public/{sections/engines → features/pipelines}/engine-panel-shared-style.js +0 -0
- /package/public/{sections/embeddings → features/pipelines}/modals/register-model-modal.ok.js +0 -0
- /package/public/{sections/embeddings → features/pipelines}/modals/replace-embedder-modal.ok.js +0 -0
- /package/public/{sections/embeddings → features/pipelines}/parts/embed-model-catalog.ok.js +0 -0
- /package/public/{sections/engines → features/pipelines}/parts/engine-lifecycle-actions.ok.js +0 -0
- /package/public/{sections/engines → features/pipelines}/parts/engine-panel-shell.ok.js +0 -0
- /package/public/{sections/engines → features/pipelines}/parts/engine-resource-card.ok.js +0 -0
- /package/public/{sections/engines → features/pipelines}/parts/engine-row-item.ok.js +0 -0
- /package/public/{sections/embeddings → features/pipelines}/parts/pipeline-try-search.ok.js +0 -0
- /package/public/{sections → features}/queue/parts/code-panel.ok.js +0 -0
- /package/public/{sections → features}/sync/modals/connect-peer-modal.ok.js +0 -0
- /package/public/{sections → features}/sync/parts/sync-retention.ok.js +0 -0
- /package/public/{sections → features}/sync/parts/sync-topology.ok.js +0 -0
- /package/public/{sections → features}/views/parts/view-detail.ok.js +0 -0
- /package/public/{sections/db → shell}/modals/create-env-modal.ok.js +0 -0
- /package/public/{sections/db → shell}/modals/demo-env-modal.ok.js +0 -0
- /package/public/{sections/db → shell}/modals/remove-env-modal.ok.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const EMBEDDINGS_ENGINE_TYPES=new Set(["embedder","indexer","embed-worker","vector-search"]);export function isEmbeddingsEngineType(e){return EMBEDDINGS_ENGINE_TYPES.has(e)}export function isEmbeddingsEngine(e){return isEmbeddingsEngineType(e?.type)}export function memberDocCounts(e){return e?.stats?.doc_counts??e?.runtime?.doc_counts??null}export function cloneValue(e,n={}){try{return JSON.parse(JSON.stringify(e??n))}catch{return JSON.parse(JSON.stringify(n))}}export function normalizeEngineState(e=null){const n=e?.stats??{},t=e?.runtime??{},r=!0===firstDefined(n?.paused,t?.paused,e?.paused),o=firstDefined(n?.state,t?.state,e?.state,e?.status);return!1===e?.exists||"missing"===o?{key:"missing",label:"missing",color:"var(--okdb-danger)"}:r?{key:"paused",label:"paused",color:"var(--okdb-warning)"}:"error"===o||"error"===e?.status?{key:"error",label:"error",color:"var(--okdb-danger)"}:"inactive"===o||"inactive"===e?.status?{key:"inactive",label:"inactive",color:"var(--okdb-warning)"}:"building"===o?{key:"building",label:"building",color:"var(--okdb-info)"}:"remote"===o?{key:"remote",label:"running elsewhere",color:"var(--okdb-info)"}:e?.isRunning||"online"===o||"running"===o?{key:"running",label:"running",color:"var(--okdb-success)"}:"degraded"===o?{key:"degraded",label:"degraded",color:"var(--okdb-warning)"}:"created"===o?{key:"created",label:"created",color:"var(--okdb-app-fg-muted)"}:"stopped"!==o&&"idle"!==o&&o?{key:String(o),label:String(o),color:"var(--okdb-app-fg-muted)"}:{key:"stopped",label:"stopped",color:"var(--okdb-app-fg-muted)"}}export function engineStateBucket(e=null){const{key:n}=normalizeEngineState(e);return"running"===n||"remote"===n?"running":["error","missing","inactive","paused","building","degraded"].includes(n)?"attention":"stopped"}export function statusTone(e=null){return normalizeEngineState(e).color}export function readableReason(e){return e?String(e).replace(/_/g," "):null}export function formatJsonValue(e){try{return JSON.stringify(e,null,2)}catch{return String(e??"")}}export function resolveEngineEnvName(e=null,n=null){return n??e?.env??e?._uiEnv??e?.storeEnv??e?.config?.source_env??null}export function getEnginePipelineName(e=null){return e?.meta?.pipeline??null}export function buildFunctionsRoute(e,n=null){const t=new URLSearchParams,r=e?.$ok?.stores?.okdb?.selectedEnv??null;r&&t.set("env",r),n&&t.set("name",n);const o=t.toString();return"/functions"+(o?`?${o}`:"")}export function openFunctionRoute(e,n,{beforeNavigate:t}={}){if(!n)return!1;const r=e?.$vars?.$router;if("function"==typeof t&&t(),r?.push){const t={...r._search||{}},o=e?.$ok?.stores?.okdb?.selectedEnv??null;o?t.env=o:delete t.env,t.name=n;const u="function"==typeof r.resolve?r.resolve("/functions",t):buildFunctionsRoute(e,n);return r.push(u),!0}return!!globalThis.location&&(globalThis.location.hash=`#${buildFunctionsRoute(e,n)}`,!0)}export function dispatchEnginePipelineSelection(e,n=null){const t=getEnginePipelineName(n);return!!t&&(e.$dispatch("select-pipeline",t),!0)}function matchesLinkedEngine(e=null,n=null){return!!n&&(e?.name===n||e?.key===n)}function matchesLinkedFunction(e=null,n=null){return!!n&&(e?.config?.handler?.name===n||e?.runtime?.handler?.name===n)}function linkedMemberSourceType(e=null){return e?.config?.source_type??e?.runtime?.source_type??null}function linkedMemberJobType(e=null){return e?.config?.job_type??e?.runtime?.job_type??null}function linkedMemberQueueEnv(e=null){return e?.config?.queue_env??e?.runtime?.queue_env??null}export async function resolveLinkedPipeline(e,{envName:n=null,pipelineName:t=null,ownerEngine:r=null,functionName:o=null}={}){const u=n??e?.$ok?.stores?.okdb?.selectedEnv??null;if(!u||!t&&!r&&!o)return null;let c=[],i=null,s=null,a=null,l="pipelines";try{const e=await fetch(`${__ENV__.API}/env/${encodeURIComponent(u)}/pipelines`);if(e.ok){const n=await e.json().catch(()=>({}));c=n?.data??n?.result??[],i=c.find(e=>!!e&&(!(!t||e.name!==t)||(e.engines??[]).some(e=>matchesLinkedEngine(e,r)||matchesLinkedFunction(e,o))))??null,s=(i?.engines??[]).find(e=>matchesLinkedEngine(e,r))??(i?.engines??[]).find(e=>matchesLinkedFunction(e,o))??(i?.engines??[]).find(e=>linkedMemberSourceType(e)&&["processor","materializer","queue-worker"].includes(e?.type))??(i?.engines??[]).find(e=>linkedMemberSourceType(e))??(i?.engines??[]).find(e=>e?.config?.job_type)??null,["processor","materializer","queue-worker"].includes(s?.type)&&(l="engines")}}catch{}if(!s&&(r||o))try{const e=await fetch(`${__ENV__.API}/env/${encodeURIComponent(u)}/engines`);if(e.ok){const n=await e.json().catch(()=>({})),t=n?.data??n?.result??[];a=t.find(e=>e?.name===r||e?.key===r)??t.find(e=>e?.config?.handler?.name===o)??null,!i&&a&&(i=c.find(e=>(e?.engines??[]).some(e=>matchesLinkedEngine(e,a?.name)||matchesLinkedEngine(e,a?.key)||matchesLinkedFunction(e,o)))??null),!s&&i&&(s=(i?.engines??[]).find(e=>matchesLinkedEngine(e,a?.name))??(i?.engines??[]).find(e=>matchesLinkedEngine(e,a?.key))??(i?.engines??[]).find(e=>matchesLinkedFunction(e,o))??null),["processor","materializer","queue-worker"].includes((s??a)?.type)&&(l="engines")}}catch{}const p=linkedMemberSourceType(s)??a?.config?.source_type??a?.runtime?.source_type??(i?.engines??[]).map(linkedMemberSourceType).find(Boolean)??null,d=linkedMemberJobType(s)??a?.config?.job_type??a?.runtime?.job_type??(i?.engines??[]).map(linkedMemberJobType).find(Boolean)??null,m=linkedMemberQueueEnv(s)??a?.config?.queue_env??a?.runtime?.queue_env??u;return"queue-worker"===(s??a)?.type||d?{envName:m,pipelineName:t??i?.name??null,ownerEngine:r??s?.name??s?.key??a?.name??a?.key??null,sourceType:null,jobType:d,targetTab:"workers",targetSection:"queue"}:p?{envName:u,pipelineName:t??i?.name??null,ownerEngine:r??s?.name??s?.key??a?.name??a?.key??null,sourceType:p,jobType:null,targetTab:l,targetSection:"db"}:null}export async function openLinkedPipelineRoute(e,{envName:n=null,pipelineName:t=null,ownerEngine:r=null,functionName:o=null,beforeNavigate:u}={}){const c=e?.$vars?.$router,i=await resolveLinkedPipeline(e,{envName:n,pipelineName:t,ownerEngine:r,functionName:o});if(!i)return!1;if("function"==typeof u&&u(),e?.$ok?.stores?.okdb?.selectedEnv&&e.$ok.stores.okdb.selectedEnv!==i.envName&&e.$ok.stores.okdb.selectEnv(i.envName),c?.push&&"function"==typeof c.resolve){if("queue"===i.targetSection){const e={env:i.envName,view:i.targetTab??"workers"};return i.jobType&&(e.type=i.jobType),c.push(c.resolve("/queue",e)),!0}if(i.pipelineName){const e={env:i.envName,pipeline:i.pipelineName};return i.sourceType&&(e.sourceType=i.sourceType),c.push(c.resolve("/engines",e)),!0}return!!i.sourceType&&(c.push(c.resolve("/db",{env:i.envName,type:i.sourceType,tab:i.targetTab})),!0)}if(globalThis.location){if("queue"===i.targetSection){const e=new URLSearchParams({env:i.envName,view:i.targetTab??"workers"});return i.jobType&&e.set("type",i.jobType),globalThis.location.hash=`#/queue?${e.toString()}`,!0}if(i.pipelineName){const e=new URLSearchParams({env:i.envName,pipeline:i.pipelineName});return i.sourceType&&e.set("sourceType",i.sourceType),globalThis.location.hash=`#/engines?${e.toString()}`,!0}if(!i.sourceType)return!1;const e=new URLSearchParams({env:i.envName,type:i.sourceType,tab:i.targetTab});return globalThis.location.hash=`#/db?${e.toString()}`,!0}return!1}export function buildEmbeddingsPipelineUrl(e=null,n=null){const t=e?.config??{},r=encodeURIComponent(t.source_env??"default"),o=encodeURIComponent(t.source_type??""),u=encodeURIComponent(t.storage_key??n??e?.name??"");return`${__ENV__.API}/env/${r}/type/${o}/pipelines/${u}`}export function maskSensitiveConfig(e={}){if(Array.isArray(e))return e.map(e=>maskSensitiveConfig(e));if(!e||"object"!=typeof e)return e;const n={};for(const[t,r]of Object.entries(e))n[t]=/key|secret|pass|token/i.test(t)?"***":maskSensitiveConfig(r);return n}export function summarizeValidationDetails(e=[]){if(!Array.isArray(e)||0===e.length)return null;const n=e.slice(0,3).map((e={})=>`${e.field?`${e.field} `:""}${e.message||"is invalid"}`.trim()).join("; ");return e.length>3?`${n} (+${e.length-3} more)`:n}export function getApiErrorMessage(e=null,n="Request failed"){const t=e?.error??null,r=summarizeValidationDetails(t?.details??e?.details??null);return"string"==typeof t?e?.message?e.message:r&&/^[A-Z0-9_]+$/.test(t)?`Validation failed: ${r}`:t||n:t?.message?r&&"VALIDATION_ERROR"===t.code&&!t.message.includes(r)?`${t.message} — ${r}`:t.message:e?.message?r&&!e.message.includes(r)?`${e.message} — ${r}`:e.message:r?`Validation failed: ${r}`:n}export function buildEngineBasePath(e=null,n=null){if(!e)return null;if(isEmbeddingsEngine(e))return e.key?`${__ENV__.API}/embeddings/engines/${encodeURIComponent(e.key)}`:null;const t=resolveEngineEnvName(e,n);return t&&e.type&&e.name?`${__ENV__.API}/env/${encodeURIComponent(t)}/engines/${encodeURIComponent(e.type)}/${encodeURIComponent(e.name)}`:null}function compactCount(e){if(null==e||""===e)return null;const n=Number(e);return Number.isFinite(n)&&Number.isInteger(n)?n.toLocaleString():String(e)}function firstDefined(...e){for(const n of e)if(null!=n&&""!==n)return n;return null}function pushBadge(e,n,t="var(--okdb-app-fg-muted)",r=null){null!=n&&""!==n&&e.push({text:String(n),color:t,title:r??String(n)})}function pushMetric(e,n,t,r={}){null!=n&&""!==n&&null!=t&&""!==t&&"—"!==t&&e.push({label:String(n),value:String(t),tone:r.tone??"neutral",title:r.title??`${n}: ${t}`})}function buildStatusMeta(e,n,t=null){return{label:e,color:n,title:t??`Status: ${e}`}}function formatClockBadge(e,n){const t=compactCount(e),r=compactCount(n);return null==t&&null==r?null:`clock ${t??"—"} / ${r??"—"}`}function inferLag(e,n,t){if(null!=e&&""!==e)return e;const r=Number(n),o=Number(t);return Number.isFinite(r)&&Number.isFinite(o)?Math.max(0,o-r):null}function formatBool(e,n="yes",t="no"){return null==e||""===e?null:e?n:t}function formatChunkConfig(e=null){if(!e||"object"!=typeof e)return null;const n=[e.strategy??e.type??"chunked"];return null!=e.size&&n.push(`${compactCount(e.size)} chars`),null!=e.overlap&&n.push(`${compactCount(e.overlap)} overlap`),null!=e.storeText&&n.push(`store text ${formatBool(e.storeText,"on","off")}`),n.filter(Boolean).join(" / ")}function formatIndexerProgress(e=null){if(!e||"object"!=typeof e)return null;const n=Number(e.done??0),t=Number(e.pending??0),r=Number(e.failed??0),o=Number(e.total??n+t+r+Number(e.deleted??0));if(!Number.isFinite(o)||o<=0)return null;const u=Math.round(Math.max(0,n)/o*100);return{value:`${compactCount(n)}/${compactCount(o)} (${u}%)`,tone:r>0?"danger":t>0?"warning":"success"}}function formatClockProgress(e,n){const t=Number(e),r=Number(n);if(!Number.isFinite(t)||!Number.isFinite(r)||r<=0)return null;const o=Math.max(0,Math.min(t,r)),u=Math.round(o/r*100);return{value:`${compactCount(o)}/${compactCount(r)} (${u}%)`,tone:o>=r?"success":"warning"}}export function compactEngineErrorText(e=null,n=160){const t=firstDefined(e?.stats?.error,e?.runtime?.error,e?.error);if(null==t)return null;const r=String(t).replace(/\s+/g," ").trim();return r?r.length>n?`${r.slice(0,Math.max(0,n-1)).trimEnd()}…`:r:null}export function compactEngineStatusMeta(e=null){const{label:n,color:t}=normalizeEngineState(e);return"missing"===n?buildStatusMeta(n,t,"Referenced engine does not exist"):buildStatusMeta(n,t)}export function compactEngineRowStatusBadges(e=null){const n=e?.stats??{},t=[],r=compactEngineStatusMeta(e),o=readableReason(e?.reason);return pushBadge(t,r.label,r.color,r.title),"embedder"===e?.type&&(!0===n?.ok&&pushBadge(t,"healthy","var(--okdb-success)","Provider health check is healthy"),!1===n?.ok&&pushBadge(t,"unhealthy","var(--okdb-danger)","Provider health check failed")),!1===e?.enabled&&pushBadge(t,"disabled","var(--okdb-app-fg-muted)","Engine is disabled"),o&&o!==r.label&&pushBadge(t,o,"var(--okdb-app-fg-muted)",`Reason: ${o}`),t}export function compactEngineRowSummary(e=null){const n=e?.config??{},t=e?.stats??{},r=t?.indexer??t??{},o=t?.search??t??{},u=t?.handler?.name??n?.handler?.name??null;switch(e?.type){case"queue-worker":return`Consumes ${t?.job_type??n?.job_type??"queue jobs"}`;case"processor":return`Watches ${t?.source_type??n?.source_type??"source changes"}`;case"materializer":return`${t?.source_type??n?.source_type??"source"} → ${t?.target_type??n?.target_type??"target"}`;case"embedder":return`${t?.model??n?.model??e?.name??"Embedder"} on ${t?.type??n?.type??n?.provider??"provider"}`;case"indexer":return`Indexes ${r?.source_type??n?.source_type??"source docs"}`;case"vector-search":return`Searches ${o?.storage_key??n?.storage_key??e?.name??"vector index"}`;case"embed-worker":return"Runs queued embedding jobs"+(t?.indexer??n?.indexer?` for ${t?.indexer??n.indexer}`:"");default:return u?`Uses ƒ ${u}`:e?.name??e?.key??"Engine"}}export function compactEngineRowMetrics(e=null){const n=e?.config??{},t=e?.stats??{},r={...t?.indexer??t??{}};!r.doc_counts&&e?.runtime?.doc_counts&&(r.doc_counts=e.runtime.doc_counts),null==r.vector_count&&null!=e?.runtime?.vector_count&&(r.vector_count=e.runtime.vector_count);const o=t?.search??t??{},u=[],c=firstDefined(t?.lastClock,e?.runtime?.lastClock,e?.lastClock,r?.last_seen_clock,o?.last_seen_clock),i=firstDefined(t?.headClock,e?.runtime?.headClock,e?.headClock,r?.head_clock,o?.head_clock),s=inferLag(firstDefined(t?.lag,e?.runtime?.lag,e?.lag,r?.lag,o?.lag),c,i),a=formatClockBadge(c,i);switch(e?.type){case"queue-worker":pushMetric(u,"Done",compactCount(t?.processed??0),{tone:"success"}),pushMetric(u,"Error",compactCount(t?.failed??0),{tone:(t?.failed??0)>0?"danger":"neutral"}),pushMetric(u,"Queue",t?.queue_env??n?.queue_env??e?.env??"default"),pushMetric(u,"Handler",t?.handler?.name??n?.handler?.name,{title:"Queue worker handler"});break;case"processor":null!=t?.processedChanges&&pushMetric(u,"Changes",compactCount(t.processedChanges)),null!=t?.failedBatches&&pushMetric(u,"Error",compactCount(t.failedBatches),{tone:(t?.failedBatches??0)>0?"danger":"neutral",title:"Failed batches"}),null!=t?.runningBatches&&pushMetric(u,"Active",compactCount(t.runningBatches),{tone:(t?.runningBatches??0)>0?"accent":"neutral",title:"Running batches"}),null!=s&&pushMetric(u,"Lag",0===s?"caught up":compactCount(s),{tone:Number(s)>0?"warning":"success"}),a&&pushMetric(u,"Clock",a.replace(/^clock\s+/i,"")),pushMetric(u,"Mode",t?.mode??n?.mode??"async");break;case"materializer":null!=t?.targetCount&&pushMetric(u,"Rows",compactCount(t.targetCount),{tone:"success"}),null!=t?.appliedOps&&pushMetric(u,"Ops",compactCount(t.appliedOps)),null!=t?.failedBatches&&pushMetric(u,"Error",compactCount(t.failedBatches),{tone:(t?.failedBatches??0)>0?"danger":"neutral",title:"Failed batches"}),null!=t?.runningBatches&&pushMetric(u,"Active",compactCount(t.runningBatches),{tone:(t?.runningBatches??0)>0?"accent":"neutral",title:"Running batches"}),null!=s&&pushMetric(u,"Lag",0===s?"caught up":compactCount(s),{tone:Number(s)>0?"warning":"success"}),a&&pushMetric(u,"Clock",a.replace(/^clock\s+/i,""));break;case"embedder":pushMetric(u,"Provider",t?.type??n?.type??n?.provider),pushMetric(u,"Model",t?.model??n?.model),null!=t?.latency&&pushMetric(u,"Latency",`${compactCount(t.latency)} ms`,{tone:"accent"});break;case"indexer":if(r.doc_counts&&pushMetric(u,"Done",compactCount(r.doc_counts.done??0),{tone:"success"}),r.doc_counts){const e=formatIndexerProgress(r.doc_counts);e&&pushMetric(u,"Progress",e.value,{tone:e.tone,title:"Indexed documents / total tracked documents"})}else{const e=formatClockProgress(c,i);e&&pushMetric(u,"Progress",e.value,{tone:e.tone,title:"Indexer cursor / source head clock"})}r.doc_counts&&pushMetric(u,"Pending",compactCount(r.doc_counts.pending??0),{tone:(r.doc_counts.pending??0)>0?"warning":"neutral"}),r.doc_counts&&pushMetric(u,"Error",compactCount(r.doc_counts.failed??0),{tone:(r.doc_counts.failed??0)>0?"danger":"neutral"}),null!=r?.vector_count&&pushMetric(u,"Vectors",compactCount(r.vector_count),{tone:"success"}),a&&pushMetric(u,"Clock",a.replace(/^clock\s+/i,"")),null!=s&&pushMetric(u,"Lag",0===s?"caught up":compactCount(s),{tone:Number(s)>0?"warning":"success"}),pushMetric(u,"Field",r.field??n?.field??"whole record"),pushMetric(u,"Mode",r.mode??n?.mode),pushMetric(u,"Prepare",r.prepare??n?.prepare),pushMetric(u,"Chunk",formatChunkConfig(r.chunk??n?.chunk)),pushMetric(u,"Embedder",r.embedder??n?.embedder);break;case"vector-search":null==o.count&&null==o.vector_count||pushMetric(u,"Vectors",compactCount(o.count??o.vector_count),{tone:"success"}),null!=o.dims&&pushMetric(u,"Dims",compactCount(o.dims)),pushMetric(u,"Algorithm",o.algorithm??n?.algorithm);break;case"embed-worker":{const r={...t??{}};null==r.queue_depth&&null!=e?.runtime?.queue_depth&&(r.queue_depth=e.runtime.queue_depth),null==r.concurrency&&null!=e?.runtime?.concurrency&&(r.concurrency=e.runtime.concurrency),null==r.indexer&&null!=e?.runtime?.indexer&&(r.indexer=e.runtime.indexer),null!=r.processed&&pushMetric(u,"Done",compactCount(r.processed),{tone:"success"}),null!=r.failed&&pushMetric(u,"Error",compactCount(r.failed),{tone:(r.failed??0)>0?"danger":"neutral"}),null!=r.in_flight&&pushMetric(u,"Active",compactCount(r.in_flight),{tone:(r.in_flight??0)>0?"accent":"neutral"}),null!=r.queue_depth&&pushMetric(u,"Queue",compactCount(r.queue_depth),{tone:(r.queue_depth??0)>0?"warning":"neutral",title:"Durable queue backlog for this job type"}),null!=r.concurrency&&pushMetric(u,"Workers",compactCount(r.concurrency),{tone:"accent"}),pushMetric(u,"Indexer",r.indexer??n?.indexer);break}default:null!=s&&pushMetric(u,"Lag",0===s?"caught up":compactCount(s),{tone:Number(s)>0?"warning":"success"}),pushMetric(u,"Type",n?.source_type)}return u}export function compactEngineRowPreview(e=null){const n=compactEngineRowMetrics(e),t=new Map(n.map(e=>[e.label,e])),r=[],o=e=>{const n=t.get(e);n&&(r.push(n),t.delete(e))};switch(e?.type){case"indexer":["Progress","Lag","Pending","Error","Vectors","Chunk"].forEach(o);break;case"embed-worker":case"queue-worker":["Done","Error","Active","Workers"].forEach(o);break;case"processor":["Changes","Error","Active","Lag"].forEach(o);break;case"materializer":["Rows","Ops","Error","Active","Lag"].forEach(o);break;case"vector-search":["Vectors","Dims","Algorithm"].forEach(o);break;case"embedder":["Model","Provider","Latency"].forEach(o);break;default:["Error","Lag","Type"].forEach(o)}return r.slice(0,3)}export function compactEngineConfigMetrics(e=null){const n=e?.config??{},t=e?.stats??{},r=e?.runtime??{},o=[],u=n?.handler??r?.handler??t?.handler??null;switch(e?.type){case"processor":pushMetric(o,"Source",n?.source_type??t?.source_type),pushMetric(o,"Source env",n?.source_env??r?.source_env),pushMetric(o,"Mode",n?.mode??t?.mode??"async"),pushMetric(o,"Bootstrap",n?.bootstrap),pushMetric(o,"Batch",compactCount(n?.batchSize)),pushMetric(o,"Origin",n?.originMode);break;case"materializer":pushMetric(o,"Source",n?.source_type??t?.source_type),pushMetric(o,"Target",n?.target_type??t?.target_type),pushMetric(o,"Source env",n?.source_env??r?.source_env),pushMetric(o,"Target env",n?.target_env??r?.target_env),pushMetric(o,"Bootstrap",n?.bootstrap),pushMetric(o,"Batch",compactCount(n?.batchSize)),pushMetric(o,"Origin",n?.originMode),pushMetric(o,"Clear target",formatBool(n?.clearTargetOnRebuild,"on","off"));break;case"queue-worker":pushMetric(o,"Job type",n?.job_type??t?.job_type),pushMetric(o,"Queue env",n?.queue_env??t?.queue_env),pushMetric(o,"Concurrency",compactCount(n?.concurrency??t?.concurrency));break;case"embedder":pushMetric(o,"Provider",n?.type??n?.provider??t?.type),pushMetric(o,"Model",n?.model??t?.model),pushMetric(o,"Dims",compactCount(n?.dims??t?.dims));break;case"indexer":pushMetric(o,"Source",n?.source_type??t?.source_type),pushMetric(o,"Source env",n?.source_env??r?.source_env),pushMetric(o,"Field",n?.field??t?.field??"whole record"),pushMetric(o,"Mode",n?.mode??t?.mode),pushMetric(o,"Storage",n?.storage_key??t?.storage_key),pushMetric(o,"Dims",compactCount(n?.dims??t?.dims)),pushMetric(o,"Prepare",n?.prepare??t?.prepare),pushMetric(o,"Chunk",formatChunkConfig(n?.chunk??t?.chunk)),pushMetric(o,"Embedder",n?.embedder??t?.embedder);break;case"vector-search":if(pushMetric(o,"Source",n?.source_type??t?.source_type),pushMetric(o,"Source env",n?.source_env??r?.source_env),pushMetric(o,"Storage",n?.storage_key??t?.storage_key),pushMetric(o,"Dims",compactCount(n?.dims??t?.dims)),pushMetric(o,"Algorithm",n?.algorithm??t?.algorithm??"flat"),n?.algorithm_config&&"object"==typeof n.algorithm_config)for(const[e,t]of Object.entries(n.algorithm_config))pushMetric(o,e,compactCount(t));pushMetric(o,"Embedder",n?.embedder??t?.embedder);break;case"embed-worker":pushMetric(o,"Job type",n?.job_type??t?.job_type),pushMetric(o,"Indexer",n?.indexer??t?.indexer),pushMetric(o,"Embedder",n?.embedder??t?.embedder),pushMetric(o,"Concurrency",compactCount(n?.concurrency??t?.concurrency)),pushMetric(o,"Poll",null!=n?.pollInterval?`${compactCount(n.pollInterval)} ms`:null),pushMetric(o,"TTL",null!=n?.ttl?`${compactCount(n.ttl)} ms`:null);break;default:pushMetric(o,"Source",n?.source_type??t?.source_type),pushMetric(o,"Target",n?.target_type??t?.target_type),pushMetric(o,"Mode",n?.mode??t?.mode)}return u?.name&&pushMetric(o,"Handler",u.name,{title:"Configured handler function"}),u?.recordRuns&&pushMetric(o,"Run log",u.recordRuns,{title:"Function run recording policy"}),o}
|
|
@@ -1 +0,0 @@
|
|
|
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>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"../../embeddings/parts/embeddings-engine-panel.ok.js";import n from"../parts/generic-engine-panel.ok.js";import{formatJsonValue as t,isEmbeddingsEngine as i,maskSensitiveConfig as a}from"../engine-ui-utils.js";export default{tag:"engine-modal",dependencies:[n,e],attr:{modal:{},engine:{},env:{},onDone:{}},context:e=>({engineState:e.$attr.engine??null,get eng(){return this.engineState??{}},get envName(){return e.$attr.env??this.eng.env??null},get isEmbeddings(){return i(this.eng)},get isQueueWorker(){return"queue-worker"===this.eng?.type},get hasConfig(){return!!this.eng?.config&&Object.keys(this.eng.config).length>0},get configJson(){return this.hasConfig?t(a(this.eng.config)):""},get modalStyle(){return this.isQueueWorker?"width:min(920px, calc(100vw - 48px));max-width:calc(100vw - 48px);min-width:720px;max-height:calc(100vh - 60px);display:flex;flex-direction:column;gap:14px;":"width:min(1180px, calc(100vw - 48px));max-width:calc(100vw - 48px);min-width:860px;max-height:calc(100vh - 60px);display:flex;flex-direction:column;gap:14px;"},setEngine(e){e&&(this.engineState={...this.engineState??{},...e})},async notifyDone(n=null){await(e.$attr.onDone?.(n??this.engineState))},async handleEngineUpdated(e){this.setEngine(e),await this.notifyDone(this.engineState)},async handleRefresh(){await this.notifyDone(this.engineState)},async handleDeleted(){await this.notifyDone({...this.engineState??{},_deleted:!0}),await(e.$attr.modal?.close?.())},close(){e.$attr.modal?.close?.()}}),init(e){e.$watch(()=>e.$attr.engine,()=>{this.engineState=e.$attr.engine??null})},template:'\n<div :style="modalStyle">\n <div style="min-height:0;padding-right:4px;display:flex;flex-direction:column;gap:14px;">\n <if :="!isEmbeddings">\n <generic-engine-panel\n :engine="eng"\n :env="envName"\n :modal="$attr.modal"\n @engine-updated="handleEngineUpdated($event.detail)"\n @refresh="handleRefresh()"\n @deleted="handleDeleted()"\n />\n </if>\n\n <if :="isEmbeddings">\n <embeddings-engine-panel\n :engine="eng"\n @engine-updated="handleEngineUpdated($event.detail)"\n @refresh="handleRefresh()"\n @deleted="handleDeleted()"\n />\n </if>\n\n <if :="hasConfig && isEmbeddings">\n <details style="border:1px solid var(--okdb-app-surface-2);border-radius:10px;background:var(--okdb-app-bg-deep);padding:8px 10px;">\n <summary style="display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--okdb-app-fg-muted);cursor:pointer;user-select:none;">\n <span>► Configuration</span>\n </summary>\n <pre style="margin:8px 0 0;max-height:260px;overflow:auto;padding:10px;border-radius:8px;background:var(--okdb-app-bg-deep);border:1px solid var(--okdb-app-surface-2);font-size:11px;line-height:1.55;white-space:pre-wrap;word-break:break-word;color:var(--okdb-app-fg-muted);">{{ configJson }}</pre>\n </details>\n </if>\n </div>\n</div>\n'};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"../../../components/ok-json-input.ok.js";import{buildEngineBasePath as t,cloneValue as n,getApiErrorMessage as i}from"../engine-ui-utils.js";export default{tag:"engine-declaration-editor",dependencies:[e],attr:{engine:{},env:{}},context:e=>({saving:!1,error:null,open:!1,enabledDraft:!0,metaDraft:{},configDraft:{},_configSeed:"null",get eng(){return e.$attr.engine??{}},get basePath(){return t(this.eng,e.$attr.env??null)},get canEdit(){return!!this.basePath},get metaSummary(){const e=this.eng?.meta??{},t="object"==typeof e&&e&&!Array.isArray(e)?Object.keys(e).length:0;return t?`${t} field${1===t?"":"s"}`:"empty"},syncDrafts(e=null){const t=e??this.eng??{};this.enabledDraft=!1!==t.enabled,this.metaDraft=n(t.meta,{}),this.configDraft=this._maskSecrets(n(t.config,{})),this._configSeed=JSON.stringify(this.configDraft),this.error=null},_maskSecrets(e){if(!e||"object"!=typeof e||Array.isArray(e))return e??{};const t={};for(const[n,i]of Object.entries(e))"key"!==n&&!/api_?key|secret|password|token/i.test(n)||"string"!=typeof i?i&&"object"==typeof i&&!Array.isArray(i)?t[n]=this._maskSecrets(i):t[n]=i:t[n]="***";return t},get configChanged(){try{return JSON.stringify(this.configDraft)!==this._configSeed}catch{return!1}},cloneMeta:e=>n(e,{}),toggleOpen(){this.open=!this.open},async save(){if(this.canEdit&&!this.saving){this.saving=!0,this.error=null;try{const t={enabled:this.enabledDraft,meta:n(this.metaDraft,{})};this.configChanged&&(t.config=n(this.configDraft,{}));const a=await fetch(this.basePath,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),s=await a.json().catch(()=>({}));if(!a.ok)throw new Error(i(s,`Failed (${a.status})`));const r=s?.data??s?.result??null;r&&(this.syncDrafts(r),e.$dispatch("engine-updated",r)),this.open=!1,e.$dispatch("refresh"),e.$ok.shared?.toast?.success?.("Engine declaration saved")}catch(t){this.error=t?.message||String(t),this.open=!0,e.$ok.shared?.toast?.error?.(this.error)}finally{this.saving=!1}}}}),init(e){this.syncDrafts(e.$attr.engine),e.$watch(()=>e.$attr.engine,()=>this.syncDrafts(e.$attr.engine))},template:'\n<div style="display:flex; flex-direction:column; gap:12px; padding:14px; border:1px solid var(--okdb-app-border); border-radius:12px; background:var(--okdb-app-bg-deep);">\n <div style="display:flex; align-items:center; gap:8px; flex-wrap:wrap;">\n <div style="font-weight:600; font-size:13px;">Advanced declaration</div>\n <div style="font-size:11px; opacity:.45;">enablement and synced meta</div>\n <div style="flex:1;"></div>\n <button @click="toggleOpen()" style="font-size:11px; padding:4px 10px; opacity:.8;">\n {{ open ? \'Hide\' : \'Edit declaration\' }}\n </button>\n </div>\n\n <div class="kv-grid kv-grid--compact">\n <span class="kv-key">enabled</span><span class="kv-val">{{ eng.enabled === false ? \'no\' : \'yes\' }}</span>\n <span class="kv-key">meta</span><span class="kv-val">{{ metaSummary }}</span>\n </div>\n\n <if :="open">\n <div style="display:flex; flex-direction:column; gap:12px; padding-top:4px; border-top:1px solid var(--okdb-app-border);">\n <div style="display:flex; align-items:center; gap:8px; flex-wrap:wrap;">\n <div style="font-size:11px; opacity:.5;">These values are persisted and synced.</div>\n <div style="flex:1;"></div>\n <button @click="save()" :disabled="saving || !canEdit" style="font-size:11px; padding:4px 10px; color:var(--okdb-accent); border-color:color-mix(in srgb, var(--okdb-accent) 33%, transparent);">\n {{ saving ? \'Saving…\' : \'Save declaration\' }}\n </button>\n </div>\n\n <label style="display:flex; align-items:center; gap:8px; font-size:12px;">\n <input type="checkbox" :checked="enabledDraft" @change="enabledDraft = $event.target.checked" />\n <span>Enabled on eligible nodes</span>\n </label>\n\n <div style="display:flex; flex-direction:column; gap:6px; min-height:0;">\n <div style="font-size:10px; opacity:.45; text-transform:uppercase; letter-spacing:.05em;">Meta</div>\n <div style="min-height:160px; border:1px solid var(--okdb-app-border); border-radius:8px; overflow:hidden; background:var(--okdb-app-bg-deep);">\n <ok-json-input mode="textbox" :value="metaDraft" @edit="metaDraft = cloneMeta($event.detail)" style="height:100%; display:flex; min-height:160px;" />\n </div>\n </div>\n\n <div style="display:flex; flex-direction:column; gap:6px; min-height:0;">\n <div style="font-size:10px; opacity:.45; text-transform:uppercase; letter-spacing:.05em;">Config</div>\n <div style="font-size:11px; opacity:.5;">\n Saving a config change restarts the engine. Identity fields (source, storage key, dims) are immutable —\n secret values show as *** and keep their stored value unless replaced.\n </div>\n <div style="min-height:160px; border:1px solid var(--okdb-app-border); border-radius:8px; overflow:hidden; background:var(--okdb-app-bg-deep);">\n <ok-json-input mode="textbox" :value="configDraft" @edit="configDraft = cloneMeta($event.detail)" style="height:100%; display:flex; min-height:160px;" />\n </div>\n <if :="configChanged">\n <div style="font-size:11px; color:var(--okdb-warning);">Config edited — will be applied with a restart on save.</div>\n </if>\n </div>\n\n <if :="error">\n <div style="font-size:12px; color:var(--okdb-danger);">{{ error }}</div>\n </if>\n </div>\n </if>\n</div>\n'};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"./engine-panel-shell.ok.js";import n from"../../functions/modals/function-modal.ok.js";import{ENGINE_PANEL_SHARED_STYLE as t}from"../engine-panel-shared-style.js";import{buildEngineBasePath as i,formatJsonValue as r,getApiErrorMessage as a,openFunctionRoute as s,resolveEngineEnvName as l}from"../engine-ui-utils.js";function o(e,n="—"){return null==e||""===e?n:Array.isArray(e)?e.length?e.join(", "):n:"boolean"==typeof e?e?"yes":"no":String(e)}function c(e,n=[]){return function(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}(e)?Object.entries(e).filter(([e,t])=>!n.includes(e)&&(null==t||["string","number","boolean"].includes(typeof t))):[]}function d(e,n){if(""===e||null==e)return null;const t=Math.trunc(Number(e));if(!Number.isFinite(t)||t<1)throw new Error(`${n} must be a positive integer`);return t}function p(e){if(null==e||""===e)return"—";const n=Number(e);if(!Number.isFinite(n))return String(e);const t=n<=1?100*n:n;return`${Math.round(t)}%`}export default{tag:"generic-engine-panel",dependencies:[e,n],attr:{engine:{},env:{},modal:{}},context:e=>({saveConfigBusy:!1,saveConfigError:null,materializerRepairBusy:!1,materializerRepairError:null,showRawRuntime:!1,showRawStats:!1,showRawConfig:!1,workerConfigDraft:{concurrency:"",pollInterval:"",ttl:""},get eng(){return e.$attr.engine??{}},get envName(){return l(this.eng,e.$attr.env??null)},get basePath(){return i(this.eng,this.envName)},get isQueueWorker(){return"queue-worker"===this.eng.type},get isProcessor(){return"processor"===this.eng.type},get isMaterializer(){return"materializer"===this.eng.type},get hasSpecializedPipelineView(){return this.isQueueWorker||this.isProcessor||this.isMaterializer},get stateText(){return"error"===this.eng.status?"error":"inactive"===this.eng.status?"inactive":this.eng.isRunning||"online"===this.eng.status?"running":this.eng.status||"stopped"},get reasonText(){const e=this.eng.reason??null;return e&&e!==this.stateText?String(e).replace(/_/g," "):"—"},get updatedText(){return function(e){if(!e)return"—";try{return new Date(e).toLocaleString()}catch{return String(e)}}(this.eng.runtime?.updated)},get runtimePreviewEntries(){return c(this.eng.runtime,["state","reason","error","running","updated"])},get statsPreviewEntries(){return c(this.eng.stats,["engine_key","job_type","queue_env","handler","concurrency","processed","failed","running"])},get configPreviewEntries(){return c(this.eng.config,["job_type","queue_env","handler","concurrency","pollInterval","ttl"])},get workerStats(){return this.eng.stats??{}},get pipelineStats(){return this.eng.stats??{}},get workerHandler(){return this.workerStats.handler??this.eng.config?.handler??null},get pipelineHandler(){return this.pipelineStats.handler??this.eng.config?.handler??null},get handlerName(){return this.pipelineHandler?.name??null},get handlerEnv(){return this.pipelineHandler?.env??this.envName??"—"},get canOpenHandlerFunction(){return!!this.handlerName},get workerJobType(){return this.workerStats.job_type??this.eng.config?.job_type??"—"},get workerQueueEnv(){return this.workerStats.queue_env??this.eng.config?.queue_env??this.envName??"—"},get workerFunctionEnv(){return this.workerHandler?.env??this.envName??"—"},get workerRecordRuns(){return this.eng.config?.handler?.recordRuns??"all"},get workerProcessed(){return this.workerStats.processed??0},get workerFailed(){return this.workerStats.failed??0},get workerRunning(){return this.workerStats.running??0},get workerConcurrency(){return this.workerStats.concurrency??this.eng.config?.concurrency??1},get workerPollInterval(){return this.eng.config?.pollInterval??1e3},get workerTtl(){return this.eng.config?.ttl??3e4},get canOpenWorkerFunction(){return!!this.workerHandler?.name},get showWorkerReason(){return"—"!==this.reasonText&&"running"!==this.reasonText},get processorSourceType(){return this.pipelineStats.source_type??this.eng.config?.source_type??"—"},get processorSourceEnv(){return this.pipelineStats.source_env??this.eng.config?.source_env??this.envName??"—"},get processorMode(){return this.pipelineStats.mode??this.eng.config?.mode??"async"},get processorBootstrap(){return this.pipelineStats.bootstrap??this.eng.config?.bootstrap??"snapshot"},get processorOriginMode(){return this.pipelineStats.originMode??this.eng.config?.originMode??"all"},get processorBatchSize(){return this.pipelineStats.batchSize??this.eng.config?.batchSize??256},get processorCursorKey(){return this.pipelineStats.cursorKey??this.eng.config?.cursorKey??this.eng.key??"—"},get processorLockMode(){return this.pipelineStats.lockMode??this.eng.config?.lockMode??"exclusive"},get processorHydrateValues(){return o(this.pipelineStats.hydrateValues??this.eng.config?.hydrateValues??!0)},get processorFailOnHandlerError(){return o(this.pipelineStats.failOnHandlerError??this.eng.config?.failOnHandlerError??!0)},get processorInvocations(){return this.pipelineStats.invocations??0},get processorProcessedChanges(){return this.pipelineStats.processedChanges??0},get processorFailedBatches(){return this.pipelineStats.failedBatches??0},get processorRunningBatches(){return this.pipelineStats.runningBatches??0},get processorLag(){return this.pipelineStats.lag??"—"},get processorProgress(){return p(this.pipelineStats.progress)},get processorPaused(){return!0===this.pipelineStats.paused},get materializerSourceType(){return this.pipelineStats.source_type??this.eng.config?.source_type??"—"},get materializerTargetType(){return this.pipelineStats.target_type??this.eng.config?.target_type??"—"},get materializerSourceEnv(){return this.pipelineStats.source_env??this.eng.config?.source_env??this.envName??"—"},get materializerTargetEnv(){return this.pipelineStats.target_env??this.eng.config?.target_env??this.envName??"—"},get materializerBootstrap(){return this.pipelineStats.bootstrap??this.eng.config?.bootstrap??"snapshot"},get materializerOriginMode(){return this.pipelineStats.originMode??this.eng.config?.originMode??"all"},get materializerBatchSize(){return this.pipelineStats.batchSize??this.eng.config?.batchSize??128},get materializerCursorKey(){return this.pipelineStats.cursorKey??this.eng.config?.cursorKey??this.eng.key??"—"},get materializerClearTargetOnRebuild(){return o(this.pipelineStats.clearTargetOnRebuild??this.eng.config?.clearTargetOnRebuild??!0)},get materializerProcessedChanges(){return this.pipelineStats.processedChanges??0},get materializerAppliedOps(){return this.pipelineStats.appliedOps??0},get materializerFailedBatches(){return this.pipelineStats.failedBatches??0},get materializerRunningBatches(){return this.pipelineStats.runningBatches??0},get materializerTargetCount(){return this.pipelineStats.targetCount??"—"},get materializerLag(){return this.pipelineStats.lag??"—"},get materializerProgress(){return p(this.pipelineStats.progress)},get materializerPaused(){return!0===this.pipelineStats.paused},get materializerErrorText(){return this.pipelineStats.error??this.eng.error??null},get materializerPreviewPayload(){return[{action:"put",key:"example-1",value:{sample:!0,title:"Example source row",sourceType:this.materializerSourceType},clock:null},{action:"remove",key:"example-2",clock:123}]},get materializerPreviewContext(){return{mode:"online"===this.pipelineStats.state?"live":"build",sourceType:this.materializerSourceType,targetType:this.materializerTargetType,sourceEnv:this.materializerSourceEnv,targetEnv:this.materializerTargetEnv,engineKey:this.eng.key??null,cursorKey:this.materializerCursorKey}},formatJson:r,labelize:e=>String(e||"").replace(/_/g," "),humanValue:o,rawToggleStyle:e=>e?"border-color:color-mix(in srgb, var(--okdb-accent) 40%, transparent);color:var(--okdb-accent);background:color-mix(in srgb, var(--okdb-accent) 7%, transparent);":"",syncWorkerConfig(e=null){const n=e?.config??{};this.workerConfigDraft={concurrency:null==n.concurrency?"":String(n.concurrency),pollInterval:null==n.pollInterval?"":String(n.pollInterval),ttl:null==n.ttl?"":String(n.ttl)},this.saveConfigError=null},buildWorkerConfigPatch(){const e=this.eng.config??{},n={concurrency:d(this.workerConfigDraft.concurrency,"Concurrency"),pollInterval:d(this.workerConfigDraft.pollInterval,"Poll interval"),ttl:d(this.workerConfigDraft.ttl,"Job TTL")},t={};for(const[i,r]of Object.entries(n))null==r?void 0!==e[i]&&(t[i]=null):e[i]!==r&&(t[i]=r);return t},resetWorkerConfig(){this.syncWorkerConfig(this.eng)},inspectWorkerFunction(){this.openHandlerFunction(this.workerHandler?.name??null)},openHandlerFunction(n=null){const t=n??this.handlerName;t&&s(e,t,{beforeNavigate:()=>e.$attr.modal?.close?.()})},async openHandlerEditor(){if(!this.handlerName)return;const n=e.$ok.stores.okdb,t=e.$ok.stores.functions,i=this.handlerEnv&&"—"!==this.handlerEnv?this.handlerEnv:this.envName;i?(n.selectedEnv!==i&&n.selectEnv(i),await t.onEnvChanged(),await t.select(this.handlerName),t.beginEditDraft(),t.setModalPayloadDraft(this.formatJson(this.materializerPreviewPayload)),t.setModalPreviewContext({materializerContext:this.materializerPreviewContext}),await e.$ok.shared.modal.open({owner:e,title:`Edit Function · ${this.handlerName}`,canDrag:!0,content:'<function-modal :modal="modal" mode="edit" :on-done="onDone" />',context:n=>({modal:n,onDone:async()=>{await t.select(this.handlerName),await t.loadOverviewRuns(),e.$dispatch("refresh")}})})):this.openHandlerFunction()},async runMaterializerRepairAction(n,t,i=null){if(this.isMaterializer&&this.basePath&&!this.materializerRepairBusy){if(i&&!await e.$ok.shared.modal.confirm(i))return;this.materializerRepairBusy=!0,this.materializerRepairError=null;try{const i=await fetch(`${this.basePath}${n}`,{method:"POST"}),r=await i.json().catch(()=>({}));if(!i.ok)throw new Error(a(r,`Failed (${i.status})`));const s=r?.data??r?.result??null;s&&e.$dispatch("engine-updated",s),e.$dispatch("refresh"),e.$ok.shared?.toast?.success?.(t)}catch(n){this.materializerRepairError=n?.message||String(n),e.$ok.shared?.toast?.error?.(this.materializerRepairError)}finally{this.materializerRepairBusy=!1}}},retryMaterializer(){return this.runMaterializerRepairAction("/retry","Materializer retry started")},resetMaterializerCursor(){return this.runMaterializerRepairAction("/reset-cursor","Materializer cursor reset",`Reset cursor for materializer "${this.eng.name}"?`)},rebuildMaterializer(){return this.runMaterializerRepairAction("/rebuild","Materializer rebuild started",`Rebuild materializer "${this.eng.name}"?`)},async saveWorkerConfig(){if(this.isQueueWorker&&this.basePath&&!this.saveConfigBusy){this.saveConfigBusy=!0,this.saveConfigError=null;try{const n=this.buildWorkerConfigPatch();if(!Object.keys(n).length)return void e.$ok.shared?.toast?.info?.("No worker setting changes to save");const t=await fetch(this.basePath,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:n})}),i=await t.json().catch(()=>({}));if(!t.ok)throw new Error(a(i,`Failed (${t.status})`));const r=i?.data??i?.result??null;r&&(this.syncWorkerConfig(r),e.$dispatch("engine-updated",r)),e.$dispatch("refresh"),e.$ok.shared?.toast?.success?.("Worker settings saved")}catch(n){this.saveConfigError=n?.message||String(n),e.$ok.shared?.toast?.error?.(this.saveConfigError)}finally{this.saveConfigBusy=!1}}}}),init(e){this.syncWorkerConfig(e.$attr.engine),e.$watch(()=>e.$attr.engine,()=>this.syncWorkerConfig(e.$attr.engine))},template:'\n<engine-panel-shell\n :engine="eng"\n :env="envName"\n @engine-updated="$dispatch(\'engine-updated\', $event.detail)"\n @refresh="$dispatch(\'refresh\')"\n @deleted="$dispatch(\'deleted\', $event.detail)"\n>\n <if :="isQueueWorker">\n <div class="stack-compact">\n <div class="card stack-compact" style="padding:14px;gap:12px;">\n <div style="display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap;">\n <div style="display:flex;flex-direction:column;gap:8px;min-width:0;flex:1;">\n <div class="pill-row">\n <span class="info-pill" title="Queue job type this worker consumes.">{{ workerJobType }}</span>\n <span class="info-pill" title="Environment whose queue is consumed.">queue: {{ workerQueueEnv }}</span>\n <span class="info-pill" title="Function environment.">fn env: {{ workerFunctionEnv }}</span>\n <if :="showWorkerReason">\n <span class="info-pill" title="Why the worker is in its current state.">{{ reasonText }}</span>\n </if>\n </div>\n <div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap;min-width:0;">\n <span class="field-label" style="margin:0;">Function</span>\n <if :="canOpenWorkerFunction">\n <button @click="inspectWorkerFunction()" class="inline-link" title="View or edit this function in the Functions section.">\n ƒ {{ workerHandler?.name || \'—\' }} ↗\n </button>\n </if>\n <if :="!canOpenWorkerFunction">\n <span class="muted-code" style="color:var(--okdb-app-fg);">{{ workerHandler?.name || \'—\' }}</span>\n </if>\n </div>\n </div>\n\n <div class="metric-grid metric-grid--compact" style="min-width:min(100%, 360px);">\n <div class="metric-card metric-card--compact">\n <div class="metric-title">Done</div>\n <div class="metric-value" style="color:var(--okdb-success);">{{ workerProcessed }}</div>\n </div>\n <div class="metric-card metric-card--compact">\n <div class="metric-title">Error</div>\n <div class="metric-value" :style="\'color:\' + (workerFailed > 0 ? \'var(--okdb-danger)\' : \'var(--okdb-app-fg-strong)\')">{{ workerFailed }}</div>\n </div>\n <div class="metric-card metric-card--compact">\n <div class="metric-title">Active</div>\n <div class="metric-value" :style="\'color:\' + (workerRunning > 0 ? \'var(--okdb-warning)\' : \'var(--okdb-app-fg-strong)\')">{{ workerRunning }}</div>\n </div>\n <div class="metric-card metric-card--compact">\n <div class="metric-title">Concurrency</div>\n <div class="metric-value" style="color:var(--okdb-accent);">{{ workerConcurrency }}</div>\n </div>\n </div>\n </div>\n </div>\n\n <div class="card stack-compact" style="padding:14px;gap:12px;">\n <div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap;">\n <div class="field-label" style="margin:0;">Settings</div>\n <div style="flex:1;"></div>\n <span class="story-note" style="margin-right:4px;">updated {{ updatedText }}</span>\n <button @click="resetWorkerConfig()" :disabled="saveConfigBusy || !basePath" title="Discard unsaved changes." style="font-size:11px;padding:4px 10px;opacity:.75;">Reset</button>\n <button @click="saveWorkerConfig()" :disabled="saveConfigBusy || !basePath" title="Save and restart the worker with these values." style="font-size:11px;padding:4px 10px;color:var(--okdb-accent);border-color:color-mix(in srgb, var(--okdb-accent) 33%, transparent);">\n {{ saveConfigBusy ? \'Saving…\' : \'Save\' }}\n </button>\n </div>\n\n <div class="form-grid">\n <label class="field-stack">\n <span class="field-label" title="Parallel worker lanes.">Concurrency</span>\n <input class="field-input" type="number" min="1" :value="workerConfigDraft.concurrency" @input="workerConfigDraft.concurrency = $event.target.value" placeholder="1" />\n </label>\n <label class="field-stack">\n <span class="field-label" title="Milliseconds to wait before polling again when the queue is empty.">Poll</span>\n <input class="field-input" type="number" min="1" :value="workerConfigDraft.pollInterval" @input="workerConfigDraft.pollInterval = $event.target.value" placeholder="1000" />\n </label>\n <label class="field-stack">\n <span class="field-label" title="Milliseconds an in-flight claim stays reserved before it can be reclaimed.">TTL</span>\n <input class="field-input" type="number" min="1" :value="workerConfigDraft.ttl" @input="workerConfigDraft.ttl = $event.target.value" placeholder="30000" />\n </label>\n <label class="field-stack">\n <span class="field-label" title="Whether function runs are persisted.">Runs</span>\n <div class="field-input" style="display:flex;align-items:center;min-height:36px;background:var(--okdb-app-bg);">{{ workerRecordRuns }}</div>\n </label>\n </div>\n\n <if :="saveConfigError">\n <div class="alert alert--error">{{ saveConfigError }}</div>\n </if>\n </div>\n </div>\n </if>\n\n <if :="isProcessor">\n <div class="stack-compact">\n <div class="card stack-compact" style="padding:14px;gap:12px;">\n <div style="display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap;">\n <div style="display:flex;flex-direction:column;gap:8px;min-width:0;flex:1;">\n <div class="pill-row">\n <span class="info-pill" title="Source type this processor watches.">{{ processorSourceType }}</span>\n <span class="info-pill" title="Environment whose changelog is consumed.">source: {{ processorSourceEnv }}</span>\n <span class="info-pill" title="Function environment.">fn env: {{ handlerEnv }}</span>\n <span class="info-pill" title="How source changes are consumed.">mode: {{ processorMode }}</span>\n <if :="processorPaused">\n <span class="info-pill" title="Processor registration is currently paused.">paused</span>\n </if>\n <if :="showWorkerReason">\n <span class="info-pill" title="Why the processor is in its current state.">{{ reasonText }}</span>\n </if>\n </div>\n <div class="story-lead">\n Watches <strong>{{ processorSourceType }}</strong> in <strong>{{ processorSourceEnv }}</strong> and runs\n <if :="canOpenHandlerFunction">\n <button @click="openHandlerFunction()" class="inline-link" title="View or edit this function in the Functions section.">ƒ {{ handlerName }} ↗</button>\n </if>\n <if :="!canOpenHandlerFunction">\n <span class="muted-code" style="color:var(--okdb-app-fg);">{{ handlerName || \'—\' }}</span>\n </if>\n for each change batch.\n </div>\n <div class="story-note">Use this engine for side effects and projections driven by change batches without owning a dedicated target type.</div>\n </div>\n\n <div class="metric-grid metric-grid--compact" style="min-width:min(100%, 420px);">\n <div class="metric-card metric-card--compact">\n <div class="metric-title">Invocations</div>\n <div class="metric-value" style="color:var(--okdb-accent);">{{ processorInvocations }}</div>\n </div>\n <div class="metric-card metric-card--compact">\n <div class="metric-title">Changes</div>\n <div class="metric-value" style="color:var(--okdb-success);">{{ processorProcessedChanges }}</div>\n </div>\n <div class="metric-card metric-card--compact">\n <div class="metric-title">Failures</div>\n <div class="metric-value" :style="\'color:\' + (processorFailedBatches > 0 ? \'var(--okdb-danger)\' : \'var(--okdb-app-fg-strong)\')">{{ processorFailedBatches }}</div>\n </div>\n <div class="metric-card metric-card--compact">\n <div class="metric-title">Lag</div>\n <div class="metric-value" :style="\'color:\' + (processorLag === 0 ? \'var(--okdb-success)\' : \'var(--okdb-warning)\')">{{ processorLag }}</div>\n </div>\n </div>\n </div>\n </div>\n\n <div class="card stack-compact" style="padding:14px;gap:12px;">\n <div class="card-title" style="margin:0;">Processing settings</div>\n <div class="kv-grid kv-grid--compact">\n <span class="kv-key">bootstrap</span><span class="kv-val">{{ processorBootstrap }}</span>\n <span class="kv-key">origin mode</span><span class="kv-val">{{ processorOriginMode }}</span>\n <span class="kv-key">batch size</span><span class="kv-val">{{ processorBatchSize }}</span>\n <span class="kv-key">running batches</span><span class="kv-val">{{ processorRunningBatches }}</span>\n <span class="kv-key">progress</span><span class="kv-val">{{ processorProgress }}</span>\n <span class="kv-key">cursor key</span><span class="kv-val">{{ processorCursorKey }}</span>\n <span class="kv-key">lock mode</span><span class="kv-val">{{ processorLockMode }}</span>\n <span class="kv-key">hydrate values</span><span class="kv-val">{{ processorHydrateValues }}</span>\n <span class="kv-key">fail on fn error</span><span class="kv-val">{{ processorFailOnHandlerError }}</span>\n </div>\n </div>\n </div>\n </if>\n\n <if :="isMaterializer">\n <div class="stack-compact">\n <div class="card stack-compact" style="padding:14px;gap:12px;">\n <div style="display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap;">\n <div style="display:flex;flex-direction:column;gap:8px;min-width:0;flex:1;">\n <div class="pill-row">\n <span class="info-pill" title="Source type this materializer watches.">{{ materializerSourceType }}</span>\n <span class="info-pill" title="Target type updated by returned ops.">target: {{ materializerTargetType }}</span>\n <span class="info-pill" title="Source environment.">source env: {{ materializerSourceEnv }}</span>\n <span class="info-pill" title="Target environment.">target env: {{ materializerTargetEnv }}</span>\n <span class="info-pill" title="Function environment.">fn env: {{ handlerEnv }}</span>\n <if :="materializerPaused">\n <span class="info-pill" title="Materializer registration is currently paused.">paused</span>\n </if>\n </div>\n <div class="story-lead">\n Projects <strong>{{ materializerSourceType }}</strong> into <strong>{{ materializerTargetType }}</strong> using\n <if :="canOpenHandlerFunction">\n <button @click="openHandlerFunction()" class="inline-link" title="View or edit this function in the Functions section.">ƒ {{ handlerName }} ↗</button>\n </if>\n <if :="!canOpenHandlerFunction">\n <span class="muted-code" style="color:var(--okdb-app-fg);">{{ handlerName || \'—\' }}</span>\n </if>\n and applies the returned ops to the target collection.\n </div>\n <div class="story-note">Use this engine when you want deterministic, rebuildable derived records instead of free-form side effects.</div>\n </div>\n\n <div class="metric-grid metric-grid--compact" style="min-width:min(100%, 420px);">\n <div class="metric-card metric-card--compact">\n <div class="metric-title">Applied ops</div>\n <div class="metric-value" style="color:var(--okdb-success);">{{ materializerAppliedOps }}</div>\n </div>\n <div class="metric-card metric-card--compact">\n <div class="metric-title">Target rows</div>\n <div class="metric-value" style="color:var(--okdb-accent);">{{ materializerTargetCount }}</div>\n </div>\n <div class="metric-card metric-card--compact">\n <div class="metric-title">Changes</div>\n <div class="metric-value" style="color:var(--okdb-success);">{{ materializerProcessedChanges }}</div>\n </div>\n <div class="metric-card metric-card--compact">\n <div class="metric-title">Failures</div>\n <div class="metric-value" :style="\'color:\' + (materializerFailedBatches > 0 ? \'var(--okdb-danger)\' : \'var(--okdb-app-fg-strong)\')">{{ materializerFailedBatches }}</div>\n </div>\n </div>\n </div>\n </div>\n\n <div class="card stack-compact" style="padding:14px;gap:12px;">\n <div class="card-title" style="margin:0;">Materialization settings</div>\n <div class="kv-grid kv-grid--compact">\n <span class="kv-key">bootstrap</span><span class="kv-val">{{ materializerBootstrap }}</span>\n <span class="kv-key">origin mode</span><span class="kv-val">{{ materializerOriginMode }}</span>\n <span class="kv-key">batch size</span><span class="kv-val">{{ materializerBatchSize }}</span>\n <span class="kv-key">running batches</span><span class="kv-val">{{ materializerRunningBatches }}</span>\n <span class="kv-key">progress</span><span class="kv-val">{{ materializerProgress }}</span>\n <span class="kv-key">lag</span><span class="kv-val">{{ materializerLag }}</span>\n <span class="kv-key">cursor key</span><span class="kv-val">{{ materializerCursorKey }}</span>\n <span class="kv-key">clear on rebuild</span><span class="kv-val">{{ materializerClearTargetOnRebuild }}</span>\n </div>\n </div>\n\n <div class="card stack-compact" style="padding:14px;gap:12px;border-color:#244057;">\n <div style="display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap;">\n <div style="display:flex;flex-direction:column;gap:6px;min-width:0;flex:1;">\n <div class="card-title" style="margin:0;">Repair workflow</div>\n <div class="story-note" style="margin:0;">Edit the handler with seeded sample input, verify the draft run, then retry, rewind, or rebuild from here.</div>\n </div>\n <div style="display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end;">\n <button @click="openHandlerEditor()" :disabled="!canOpenHandlerFunction || materializerRepairBusy" style="font-size:12px;padding:4px 10px;color:var(--okdb-accent);border-color:color-mix(in srgb, var(--okdb-accent) 33%, transparent);">ƒ Edit handler</button>\n <button @click="retryMaterializer()" :disabled="materializerRepairBusy || !basePath" style="font-size:12px;padding:4px 10px;color:var(--okdb-orange);border-color:color-mix(in srgb, var(--okdb-orange) 33%, transparent);">↻ Retry</button>\n <button @click="resetMaterializerCursor()" :disabled="materializerRepairBusy || !basePath" style="font-size:12px;padding:4px 10px;color:var(--okdb-info);border-color:color-mix(in srgb, var(--okdb-info) 33%, transparent);">⇤ Reset cursor</button>\n <button @click="rebuildMaterializer()" :disabled="materializerRepairBusy || !basePath" style="font-size:12px;padding:4px 10px;color:var(--okdb-success);border-color:color-mix(in srgb, var(--okdb-success) 33%, transparent);">⟳ Rebuild</button>\n </div>\n </div>\n\n <if :="materializerErrorText">\n <div class="alert alert--error">\n <div style="font-weight:600;margin-bottom:4px;">Last materializer error</div>\n <div>{{ materializerErrorText }}</div>\n </div>\n </if>\n\n <if :="materializerRepairError">\n <div class="alert alert--error">{{ materializerRepairError }}</div>\n </if>\n\n <div style="display:grid;grid-template-columns:minmax(0,1fr) minmax(280px,.9fr);gap:12px;">\n <div style="display:flex;flex-direction:column;gap:8px;min-width:0;">\n <div class="field-label">Suggested <code>ctx.payload</code></div>\n <pre class="json-block" style="margin:0;max-height:220px;overflow:auto;">{{ formatJson(materializerPreviewPayload) }}</pre>\n </div>\n <div style="display:flex;flex-direction:column;gap:8px;min-width:0;">\n <div class="field-label">Suggested <code>ctx.materializer</code></div>\n <pre class="json-block" style="margin:0;max-height:220px;overflow:auto;">{{ formatJson(materializerPreviewContext) }}</pre>\n </div>\n </div>\n\n <div class="story-note" style="margin:0;">Recommended order: <strong>Edit handler</strong> → run the seeded draft preview → <strong>Retry</strong>. Use <strong>Reset cursor</strong> to replay without clearing the target, or <strong>Rebuild</strong> to clear and rematerialize from scratch.</div>\n </div>\n </div>\n </if>\n\n <if :="!hasSpecializedPipelineView">\n <div class="panel-grid panel-grid--two">\n <div class="card" style="display:flex;flex-direction:column;gap:12px;">\n <div class="card-title" style="margin:0;">Overview</div>\n <div class="kv-grid kv-grid--compact">\n <span class="kv-key">state</span><span class="kv-val">{{ stateText }}</span>\n <span class="kv-key">reason</span><span class="kv-val">{{ reasonText }}</span>\n <span class="kv-key">enabled</span><span class="kv-val">{{ eng.enabled === false ? \'no\' : \'yes\' }}</span>\n <span class="kv-key">updated</span><span class="kv-val">{{ updatedText }}</span>\n </div>\n <if :="runtimePreviewEntries.length > 0">\n <div style="display:flex;flex-direction:column;gap:8px;">\n <div class="field-label">Runtime details</div>\n <div class="kv-grid kv-grid--compact">\n <each :of="runtimePreviewEntries" let:item="entry">\n <span class="kv-key">{{ labelize(entry[0]) }}</span><span class="kv-val">{{ humanValue(entry[1]) }}</span>\n </each>\n </div>\n </div>\n </if>\n </div>\n\n <div class="card" style="display:flex;flex-direction:column;gap:12px;">\n <div class="card-title" style="margin:0;">Configuration</div>\n <if :="configPreviewEntries.length > 0">\n <div class="kv-grid kv-grid--compact">\n <each :of="configPreviewEntries" let:item="entry">\n <span class="kv-key">{{ labelize(entry[0]) }}</span><span class="kv-val">{{ humanValue(entry[1]) }}</span>\n </each>\n </div>\n </if>\n <if :="configPreviewEntries.length === 0">\n <div class="helper-text">This engine mostly uses structured config. Open the raw JSON below if you need the full payload.</div>\n </if>\n <if :="statsPreviewEntries.length > 0">\n <div style="display:flex;flex-direction:column;gap:8px;">\n <div class="field-label">Stats snapshot</div>\n <div class="kv-grid kv-grid--compact">\n <each :of="statsPreviewEntries" let:item="entry">\n <span class="kv-key">{{ labelize(entry[0]) }}</span><span class="kv-val">{{ humanValue(entry[1]) }}</span>\n </each>\n </div>\n </div>\n </if>\n </div>\n </div>\n </if>\n\n <div class="card" style="display:flex;flex-direction:column;gap:12px;">\n <div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap;">\n <div class="card-title" style="margin:0;">Raw data</div>\n <div class="card-subtitle">Keep the default view visual first. Open these only when you need the underlying JSON.</div>\n </div>\n <div class="raw-toggle-row">\n <if :="eng.runtime">\n <button class="raw-toggle" :style="rawToggleStyle(showRawRuntime)" @click="showRawRuntime = !showRawRuntime">Runtime JSON</button>\n </if>\n <if :="eng.stats">\n <button class="raw-toggle" :style="rawToggleStyle(showRawStats)" @click="showRawStats = !showRawStats">Stats JSON</button>\n </if>\n <if :="eng.config">\n <button class="raw-toggle" :style="rawToggleStyle(showRawConfig)" @click="showRawConfig = !showRawConfig">Config JSON</button>\n </if>\n </div>\n\n <if :="showRawRuntime && eng.runtime">\n <div style="display:flex;flex-direction:column;gap:6px;">\n <div class="field-label">Runtime payload</div>\n <pre class="json-block">{{ formatJson(eng.runtime) }}</pre>\n </div>\n </if>\n <if :="showRawStats && eng.stats">\n <div style="display:flex;flex-direction:column;gap:6px;">\n <div class="field-label">Stats payload</div>\n <pre class="json-block">{{ formatJson(eng.stats) }}</pre>\n </div>\n </if>\n <if :="showRawConfig && eng.config">\n <div style="display:flex;flex-direction:column;gap:6px;">\n <div class="field-label">Config payload</div>\n <pre class="json-block">{{ formatJson(eng.config) }}</pre>\n </div>\n </if>\n </div>\n</engine-panel-shell>\n',style:t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<script type="module">import e from"./parts/files-blob-status.ok.js";import t from"./parts/files-file-list.ok.js";import s from"./parts/files-overview.ok.js";import l from"./parts/files-path-browser.ok.js";export default{tag:"files-index",unwrap:!0,dependencies:[l,t,e,s],context:e=>({allFiles:[],selectedPath:null,pathBrowser:null,get showOverview(){return!this.selectedPath},get showFiles(){return this.selectedPath&&"__blobs__"!==this.selectedPath},get showBlobs(){return"__blobs__"===this.selectedPath},onFilesLoaded(e){this.allFiles=e??[]},onSelect(e){this.selectedPath=e??null},onSelectBlobs(){this.selectedPath="__blobs__",this.pathBrowser?.$scope?.$innerContext?.clearSelection?.()},async onRefresh(){await(this.pathBrowser?.$scope?.$innerContext?.load?.())},async onEnvChanged(){this.selectedPath=null,this.allFiles=[],await(this.pathBrowser?.$scope?.$innerContext?.load?.())}}),init(e){e.$watch(()=>e.$ok.stores.okdb.selectedEnv,()=>this.onEnvChanged())}};</script><style>.action-row{display:flex;align-items:center;gap:8px;padding:5px 8px;border-radius:6px;border:1px solid transparent;background:0 0;cursor:pointer;width:100%;font-size:12px;transition:background .1s}.action-row:hover{background:var(--okdb-app-surface);border-color:var(--okdb-app-border)}.action-row--on{background:var(--okdb-accent-soft-bg);border-color:var(--okdb-accent-soft-border);color:var(--okdb-accent)}</style><template><component import="../../layouts/_default.ok.html"><template name="sidebar"><div style="display:flex;flex-direction:column;gap:0;height:100%;min-height:0"><button :class="showOverview ? 'action-row action-row--on' : 'action-row'" @click="onSelect(null)" style="margin-bottom:4px;flex-shrink:0"><span style="width:15px;text-align:center;flex-shrink:0;font-size:13px">⌂</span> <span style="font-size:12px">Overview</span></button><div style="border-top:1px solid var(--okdb-app-border);margin:0 0 6px;flex-shrink:0"></div><button :class="showBlobs ? 'action-row action-row--on' : 'action-row'" @click="onSelectBlobs()" style="margin-bottom:6px;flex-shrink:0"><span style="width:15px;text-align:center;flex-shrink:0;color:var(--okdb-sky);font-size:13px">⇄</span> <span style="font-size:12px;color:var(--okdb-sky)">Blob Sync</span></button><div style="border-top:1px solid var(--okdb-app-border);margin:0 0 8px;flex-shrink:0"></div><div style="flex:1;min-height:0;overflow:hidden"><files-path-browser :ref="pathBrowser = $el" @select="onSelect($event.detail)" @loaded="onFilesLoaded($event.detail)"/></div></div></template><template name="default"><if :="showOverview"><files-overview :files="allFiles" @select="onSelect($event.detail)"/></if><if :="showFiles"><files-file-list :path="selectedPath" @refresh="onRefresh()"/></if><if :="showBlobs"><files-blob-status/></if></template></component></template>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"../../../stores/events-store.js";import t from"../../../stores/okdb-store.js";export default{tag:"files-path-browser",context:e=>({busy:!1,allFiles:[],selected:null,_unsubs:[],async load(){this.busy=!0;try{const n=await fetch(`${t.apiBase}/files?path=/&limit=5000`);if(!n.ok)throw new Error("failed");const s=await n.json();this.allFiles=s.data??[],e.$dispatch("loaded",this.allFiles)}catch(e){console.error("files-path-browser load error",e)}finally{this.busy=!1}},clearSelection(){this.selected=null},select(t){this.selected=t,e.$dispatch("select",t)},get dirs(){const e=new Map;for(const t of this.allFiles){const n=(t.path??"").match(/^(\/[^/]+)/),s=n?n[1]:"/";e.set(s,(e.get(s)??0)+1)}return[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0])).map(([e,t])=>({path:e,count:t}))},get totalFiles(){return this.allFiles.length}}),async mount(){await this.load();const t=()=>this.load();this._unsubs=[e.on("files:uploaded",t),e.on("files:removed",t)]},unmount(){for(const e of this._unsubs)e();this._unsubs=[]},template:'\n<div style="display:flex; flex-direction:column; gap:4px; height:100%; min-height:0;">\n\n \x3c!-- Header --\x3e\n <div style="display:flex; align-items:center; justify-content:space-between; gap:6px; margin-bottom:4px;">\n <div style="font-weight:600; font-size:13px; opacity:.8;">Directories</div>\n <button @click="load()" :disabled="busy" style="font-size:11px; opacity:.7;" title="Refresh">↻</button>\n </div>\n\n <if :="busy && allFiles.length === 0">\n <div style="font-size:11px; opacity:.4; padding:4px 0;">Loading…</div>\n </if>\n\n \x3c!-- All Files entry --\x3e\n <button\n :class="selected === \'/\' ? \'dir-row dir-row--on\' : \'dir-row\'"\n @click="select(\'/\')"\n >\n <span style="flex-shrink:0; font-size:12px; opacity:.6;">📁</span>\n <span style="flex:1; text-align:left; font-size:12px;">/ (all files)</span>\n <span style="font-size:10px; opacity:.4; flex-shrink:0; font-family:monospace;">{{ totalFiles }}</span>\n </button>\n\n <if :="dirs.length > 0">\n <div style="border-top:1px solid var(--okdb-app-surface-2); margin:2px 0;"></div>\n </if>\n\n \x3c!-- Dir rows --\x3e\n <each :of="dirs" let:item="dir">\n <button\n :class="selected === dir.path ? \'dir-row dir-row--on\' : \'dir-row\'"\n @click="select(dir.path)"\n :title="dir.path"\n >\n <span style="flex-shrink:0; font-size:12px; opacity:.5;">📂</span>\n <span style="flex:1; text-align:left; font-size:12px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;">\n {{ dir.path }}\n </span>\n <span style="font-size:10px; opacity:.4; flex-shrink:0; font-family:monospace;">{{ dir.count }}</span>\n </button>\n </each>\n\n <if :="allFiles.length === 0 && !busy">\n <div style="font-size:12px; opacity:.35; padding:8px 0; text-align:center;">No files yet.</div>\n </if>\n\n</div>',style:"\n[tag] .dir-row {\n display: flex;\n align-items: center;\n gap: 7px;\n padding: 5px 8px;\n border-radius: 6px;\n border: 1px solid transparent;\n background: transparent;\n cursor: pointer;\n width: 100%;\n}\n[tag] .dir-row:hover { background: var(--okdb-app-surface); border-color: var(--okdb-app-border); }\n[tag] .dir-row--on { background: var(--okdb-app-surface); border-color: var(--okdb-accent); }\n"};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"./files-file-list.ok.js";export default{tag:"files-path-panel",props:["path"],dependencies:[e],context:e=>({get path(){return e.$attr.path??"/"},onRefresh(){e.$dispatch("refresh")}}),template:'\n<div style="display:flex; flex-direction:column; gap:0; height:100%; min-height:0;">\n <files-file-list :path="path" @refresh="onRefresh()" />\n</div>'};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e,{previewKind as t}from"./files-preview.ok.js";import n from"./files-upload-panel.ok.js";import i from"../../../stores/events-store.js";import s from"../../../stores/okdb-store.js";const o="~files";function a(e,t){const n=e.toLowerCase();let i=-1,s=0;for(const e of t){const t=n.indexOf(e);t>=0&&(i<0||t<i)&&(i=t,s=e.length)}if(i<0)return null;const o=e=>e.replace(/\s+/g," "),a=Math.max(0,i-70),r=Math.min(e.length,i+s+90);return{before:(a>0?"…":"")+o(e.slice(a,i)),hit:e.slice(i,i+s),after:o(e.slice(i+s,r))+(r<e.length?"…":"")}}export default{tag:"files-file-list",props:["path"],dependencies:[n,e],context:e=>({busy:!1,files:[],error:null,showUpload:!1,page:0,pageSize:50,totalLoaded:0,_unsubs:[],searchMode:"path",pathQuery:"",contentQuery:"",ftsIndex:null,ftsChecked:!1,hits:[],hitsHidden:0,searching:!1,searchError:null,searchTime:null,_searchSeq:0,snippets:{},selected:null,highlight:"",get path(){return e.$attr.path??"/"},get filteredFiles(){const e=this.pathQuery.trim().toLowerCase();return e?this.files.filter(t=>(t.path??"").toLowerCase().includes(e)||t.id===e):this.files},get pagedFiles(){const e=this.page*this.pageSize;return this.filteredFiles.slice(e,e+this.pageSize)},get totalPages(){return Math.max(1,Math.ceil(this.filteredFiles.length/this.pageSize))},get listCapped(){return this.files.length>=2e3},get showContent(){return"content"===this.searchMode},get hasNext(){return this.page<this.totalPages-1},get hasPrev(){return this.page>0},async load(){const t=e.$attr.path;if(null!=t){this.busy=!0,this.error=null;try{const e=`${s.apiBase}/files?path=${encodeURIComponent(t)}&recursive=true&limit=2000`,n=await fetch(e),i=await n.json();if(!n.ok)throw new Error(i?.error?.message||"failed");this.files=i.data??[],this.page=0}catch(e){this.error=e?.message||String(e),this.files=[]}finally{this.busy=!1}}else this.files=[]},async deleteFile(t,n){n?.stopPropagation?.();const i=this.filename(t);if(confirm(`Delete "${i}"?\n\nThis will decrement the blob ref-count.`))try{const n=s.apiBase,i=await fetch(`${n}/files/${encodeURIComponent(t.id)}`,{method:"DELETE"});if(!i.ok){const e=await i.json().catch(()=>({}));throw new Error(e?.error?.message||"Delete failed")}this.files=this.files.filter(e=>e.id!==t.id),this.hits=this.hits.filter(e=>e.id!==t.id),this.selected?.id===t.id&&this.closePreview(),e.$dispatch("refresh")}catch(e){this.error=e?.message||String(e)}},openPreview(e,t=""){this.selected=e,this.highlight=t},closePreview(){this.selected=null,this.highlight=""},isSelected(e){return this.selected?.id===e.id},onPathFilter(e){this.pathQuery=e,this.page=0},async loadFts(){try{const e=await fetch(`${s.apiBase}/type/${encodeURIComponent(o)}/fts`),t=await e.json().catch(()=>({})),n=e.ok?t.data??t.result??[]:[],i=e=>e?.config?.fields??[],a=n.find(e=>i(e).includes("content")||i(e).includes("*"))??n[0];this.ftsIndex=a?{name:a.name,fields:i(a),lag:a.lag??0,processorState:a.processorState??null}:null}catch{this.ftsIndex=null}finally{this.ftsChecked=!0}},async setSearchMode(e){this.searchMode=e,"content"===e&&await this.loadFts()},async runContentSearch(e){void 0!==e&&(this.contentQuery=e);const t=this.contentQuery.trim(),n=++this._searchSeq;if(this.searchError=null,!t||!this.ftsIndex)return this.hits=[],this.hitsHidden=0,void(this.searchTime=null);this.searching=!0;try{const e=`${s.apiBase}/type/${encodeURIComponent(o)}/fts/${encodeURIComponent(this.ftsIndex.name)}/search`,i=await fetch(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({query:t,options:{limit:50,mode:"and",prefix:!0}})}),a=await i.json().catch(()=>({}));if(!i.ok)throw new Error(a?.error?.message||`HTTP ${i.status}`);if(n!==this._searchSeq)return;const r=(a.data??a.result??[]).map(e=>({...e.value??{},id:e.value?.id??e.key,_score:e.score})).filter(e=>e.id),l=r.filter(e=>this.inFolder(e));this.hits=l,this.hitsHidden=r.length-l.length,this.searchTime=a.meta?.time??null,this.snippets={},this.loadSnippets(l,t,n)}catch(e){n===this._searchSeq&&(this.searchError=e?.message||String(e),this.hits=[])}finally{n===this._searchSeq&&(this.searching=!1)}},inFolder(t){const n=e.$attr.path??"/";if("/"===n)return!0;const i=n.endsWith("/")?n:n+"/";return(t.path??"").startsWith(i)},async loadSnippets(e,n,i){const o=n.toLowerCase().split(/[^\p{L}\p{N}_]+/u).filter(e=>e.length>=2);if(!o.length)return;const r=e.filter(e=>"text"===t(e)&&e.size>0).slice(0,12);await Promise.all(r.map(async e=>{try{const t=await fetch(`${s.apiBase}/files/${encodeURIComponent(e.id)}?inline=1`,{headers:{range:"bytes=0-16383"}});if(!t.ok)return;const n=new TextDecoder("utf-8").decode(new Uint8Array(await t.arrayBuffer()).subarray(0,16384));if(i!==this._searchSeq)return;this.snippets={...this.snippets,[e.id]:a(n,o)}}catch{}}))},snippetOf(e){return this.snippets[e.id]??null},downloadUrl:e=>`${s.apiBase}/files/${encodeURIComponent(e.id)}`,statusUrl:e=>`${s.apiBase}/files/${encodeURIComponent(e.id)}/status`,filename(e){const t=e.path??"";return t?t.split("/").filter(Boolean).pop():e.id},displayPath(t){const n=t.path??"",i=e.$attr.path??"/";if("/"===i)return n||"/";const s=i.endsWith("/")?i:i+"/";return n.startsWith(s)?n.slice(s.length):n},onUploaded(){this.load(),e.$dispatch("refresh")},fmtSize:e=>null==e?"—":e<1024?e+" B":e<1048576?(e/1024).toFixed(1)+" KB":(e/1048576).toFixed(1)+" MB",fmtDate(e){if(!e)return"—";const t=new Date(e);return t.toLocaleDateString()+" "+t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},mimeColor:e=>e?e.startsWith("image/")?"#7c3aed":e.startsWith("video/")?"#0891b2":e.startsWith("audio/")?"#0d9488":e.startsWith("text/")?"#16a34a":e.includes("pdf")?"#dc2626":e.includes("json")||e.includes("xml")?"#d97706":e.includes("zip")||e.includes("tar")?"#ca8a04":"var(--okdb-mime-default)":"var(--okdb-mime-default)",shortMime(e){if(!e)return"—";const t=e.split("/");return t[1]??t[0]},hashShort:e=>e?e.slice(0,8)+"…":"—"}),async mount(e){e.$watch(()=>e.$attr.path,()=>{this.showUpload=!1,this.page=0,this.pathQuery="",this.closePreview(),this.load(),this.contentQuery.trim()&&this.runContentSearch()}),this.loadFts(),await this.load();const t=()=>this.load();this._unsubs=[i.on("files:uploaded",t),i.on("files:removed",t)]},unmount(){for(const e of this._unsubs)e();this._unsubs=[]},template:'\n<div style="display:flex; gap:12px; height:100%; min-height:0;">\n\n\x3c!-- ═══ List column ═══════════════════════════════════════════════════ --\x3e\n<div class="fl-col">\n\n \x3c!-- ── Toolbar ─────────────────────────────────────────────────────── --\x3e\n <div style="display:flex; align-items:center; justify-content:space-between; gap:8px; flex-wrap:wrap; margin-bottom:8px; flex-shrink:0;">\n <div style="display:flex; align-items:center; gap:8px;">\n <span style="font-family:monospace; font-size:14px; font-weight:700; color:var(--okdb-accent);">{{ path }}</span>\n <span style="font-size:11px; opacity:.4; font-family:monospace;">{{ files.length }} file(s)</span>\n </div>\n <div style="display:flex; gap:6px;">\n <button\n @click="showUpload = !showUpload"\n :style="showUpload ? \'font-size:12px; background:var(--okdb-sky-soft-bg); border-color:var(--okdb-sky-soft-border); color:var(--okdb-sky);\' : \'font-size:12px;\'"\n >{{ showUpload ? \'✕ Close upload\' : \'↑ Upload\' }}</button>\n <button @click="load()" :disabled="busy" style="font-size:12px; opacity:.7;">↻</button>\n </div>\n </div>\n\n \x3c!-- ── Search bar ──────────────────────────────────────────────────── --\x3e\n <div style="display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:10px; flex-shrink:0;">\n <div class="seg-toggle" style="font-size:11.5px;" title="Path: filter this folder by name · Content: full-text search inside files">\n <button :class="searchMode === \'path\' ? \'active\' : \'\'" @click="setSearchMode(\'path\')">Path</button>\n <button :class="searchMode === \'content\' ? \'active\' : \'\'" @click="setSearchMode(\'content\')">Content</button>\n </div>\n\n <if :="searchMode === \'path\'">\n <input\n type="text"\n class="fl-search"\n placeholder="Filter by path…"\n :value="pathQuery"\n @input:debounce.150="onPathFilter($event.target.value)"\n />\n <if :="pathQuery">\n <span style="font-size:11px; opacity:.5; font-family:monospace;">{{ filteredFiles.length }} match(es)</span>\n </if>\n </if>\n\n <if :="searchMode === \'content\' && ftsIndex">\n <input\n type="text"\n class="fl-search"\n placeholder="Search file contents…"\n :value="contentQuery"\n @input:debounce.300="runContentSearch($event.target.value)"\n @keydown:enter="runContentSearch($event.target.value)"\n />\n <span style="font-size:10.5px; opacity:.45; font-family:monospace;" :title="\'FTS index on ~files: \' + ftsIndex.name">\n fts:{{ ftsIndex.name }} [{{ ftsIndex.fields.join(\', \') }}]{{ ftsIndex.lag > 0 ? \' · indexing, \' + ftsIndex.lag + \' behind\' : \'\' }}\n </span>\n </if>\n </div>\n\n \x3c!-- ── Content search: no index yet → how to enable it ─────────────── --\x3e\n <if :="showContent && ftsChecked && !ftsIndex">\n <div class="fl-hint">\n <div style="font-weight:600; margin-bottom:4px;">Content search is not enabled in this environment</div>\n <div style="opacity:.75; margin-bottom:6px;">It needs a full-text index on <code>~files</code> that covers file contents. Once, from code:</div>\n <pre>await db.files.indexContent();\nawait db.fts.ensure(\'~files\', \'text\', { fields: [\'path\', \'content\'] });</pre>\n <div style="opacity:.6; margin-top:6px;">Text, JSON and XML are extracted out of the box; register an extractor for PDF/Office (see <code>docs/files.md</code> → Searching file contents).\n <button @click="setSearchMode(\'content\')" style="font-size:11px; padding:1px 8px; margin-left:4px;">Re-check</button>\n </div>\n </div>\n </if>\n\n \x3c!-- ── Upload panel ────────────────────────────────────────────────── --\x3e\n <if :="showUpload">\n <div style="flex-shrink:0; margin-bottom:10px; padding:12px; background:var(--okdb-app-bg-deep); border:1px solid var(--okdb-app-border); border-radius:8px;">\n <files-upload-panel\n :path="path"\n @uploaded="onUploaded()"\n />\n </div>\n </if>\n\n \x3c!-- ── Error ────────────────────────────────────────────────────────── --\x3e\n <if :="error">\n <div style="flex-shrink:0; color:var(--okdb-danger); font-size:12px; margin-bottom:8px; padding:6px 10px; border:1px solid color-mix(in srgb, var(--okdb-danger) 20%, transparent); border-radius:6px; background:var(--okdb-danger-soft-bg);">\n {{ error }}\n </div>\n </if>\n\n \x3c!-- ═══ Content search results ═════════════════════════════════════ --\x3e\n <if :="showContent && ftsIndex">\n <div style="flex:1; overflow:auto; min-height:0;">\n <if :="searchError">\n <div style="color:var(--okdb-danger); font-size:12px; padding:6px 0;">{{ searchError }}</div>\n </if>\n <if :="!contentQuery.trim()">\n <div style="font-size:12px; opacity:.45; padding:14px 2px;">Type to search inside the files{{ path === \'/\' ? \'\' : \' under \' + path }}.</div>\n </if>\n <if :="contentQuery.trim() && !searching && !searchError">\n <div style="font-size:11px; opacity:.5; font-family:monospace; padding:0 2px 6px;">\n {{ hits.length }} hit(s){{ searchTime != null ? \' · \' + searchTime + \' ms\' : \'\' }}{{ hitsHidden ? \' · \' + hitsHidden + \' more outside \' + path : \'\' }}{{ hits.length + hitsHidden >= 50 ? \' · top 50 only\' : \'\' }}\n </div>\n </if>\n <if :="searching">\n <div style="font-size:12px; opacity:.4; padding:8px 2px;">Searching…</div>\n </if>\n <each :of="hits" let:item="h">\n <button :class="isSelected(h) ? \'fl-hit fl-hit--on\' : \'fl-hit\'" @click="openPreview(h, contentQuery)">\n <div style="display:flex; align-items:center; gap:8px; min-width:0;">\n <span style="font-family:monospace; font-size:11.5px; color:var(--okdb-app-fg-strong); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; flex:1; text-align:left;" :title="h.path">{{ h.path || h.id }}</span>\n <span :style="\'flex-shrink:0; padding:1px 6px; border-radius:999px; font-size:9.5px; font-family:monospace; background:\' + mimeColor(h.mime) + \'22; color:\' + mimeColor(h.mime) + \';\'">{{ shortMime(h.mime) }}</span>\n <span style="flex-shrink:0; font-size:10px; opacity:.4; font-family:monospace;">{{ fmtSize(h.size) }}</span>\n </div>\n <if :="snippetOf(h)">\n <div class="fl-snip">{{ snippetOf(h).before }}<mark>{{ snippetOf(h).hit }}</mark>{{ snippetOf(h).after }}</div>\n </if>\n </button>\n </each>\n </div>\n </if>\n\n \x3c!-- ═══ Folder listing (path mode) ═════════════════════════════════ --\x3e\n <if :="!showContent">\n\n \x3c!-- ── Loading ──────────────────────────────────────────────────────── --\x3e\n <if :="busy">\n <div style="flex-shrink:0; font-size:12px; opacity:.4; padding:8px 0;">Loading…</div>\n </if>\n\n \x3c!-- ── Empty state ──────────────────────────────────────────────────── --\x3e\n <if :="!busy && files.length === 0 && !error">\n <div style="flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; opacity:.45;">\n <div style="font-size:32px;">📂</div>\n <div style="font-size:13px;">No files under <code>{{ path }}</code></div>\n <button @click="showUpload = true" style="font-size:12px; background:var(--okdb-sky-soft-bg); border-color:var(--okdb-sky-soft-border); color:var(--okdb-sky);">\n ↑ Upload a file\n </button>\n </div>\n </if>\n\n <if :="files.length > 0 && filteredFiles.length === 0">\n <div style="font-size:12px; opacity:.5; padding:14px 2px;">No paths under <code>{{ path }}</code> contain “{{ pathQuery }}”.</div>\n </if>\n\n \x3c!-- ── Table ────────────────────────────────────────────────────────── --\x3e\n <if :="filteredFiles.length > 0">\n <div style="flex:1; overflow:auto; min-height:0;">\n <table style="width:100%; border-collapse:collapse; font-size:12px; white-space:nowrap;">\n <thead style="position:sticky; top:0; z-index:2; background:var(--okdb-app-bg-deep);">\n <tr style="border-bottom:1px solid var(--okdb-app-border);">\n <th style="text-align:left; padding:6px 10px; font-weight:500; opacity:.6; font-size:11px;">Path / Name</th>\n <th style="text-align:left; padding:6px 8px; font-weight:500; opacity:.6; font-size:11px;">Type</th>\n <th style="text-align:right; padding:6px 8px; font-weight:500; opacity:.6; font-size:11px;">Size</th>\n <th style="text-align:left; padding:6px 8px; font-weight:500; opacity:.6; font-size:11px;">Hash</th>\n <th style="text-align:left; padding:6px 8px; font-weight:500; opacity:.6; font-size:11px;">Uploaded</th>\n <th style="text-align:center; padding:6px 8px; font-weight:500; opacity:.6; font-size:11px;">Actions</th>\n </tr>\n </thead>\n <tbody>\n <tr as="repeat" :of="pagedFiles" let:item="f" :class="isSelected(f) ? \'file-row file-row--on\' : \'file-row\'" @click="openPreview(f)" title="Click to preview">\n\n \x3c!-- Path / name --\x3e\n <td style="padding:6px 10px; max-width:300px;">\n <div style="display:flex; align-items:center; gap:6px;">\n <span style="font-size:13px; flex-shrink:0;">{{ (f.mime || \'\').startsWith(\'image/\') ? \'🖼\' : (f.mime || \'\').startsWith(\'video/\') ? \'🎬\' : (f.mime || \'\').startsWith(\'audio/\') ? \'🎵\' : (f.mime || \'\').includes(\'pdf\') ? \'📄\' : \'📎\' }}</span>\n <div style="overflow:hidden;">\n <div style="overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-family:monospace; font-size:11px; color:var(--okdb-app-fg-strong);" :title="f.path">\n {{ displayPath(f) }}\n </div>\n <div style="font-size:10px; opacity:.3; font-family:monospace; overflow:hidden; text-overflow:ellipsis;">\n {{ f.id ? f.id.slice(0,8) : \'\' }}…\n </div>\n </div>\n </div>\n </td>\n\n \x3c!-- MIME badge --\x3e\n <td style="padding:6px 8px;">\n <span :style="\'display:inline-block; padding:2px 7px; border-radius:999px; font-size:10px; font-family:monospace; background:\' + mimeColor(f.mime) + \'22; color:\' + mimeColor(f.mime) + \'; border:1px solid \' + mimeColor(f.mime) + \'44;\'">\n {{ shortMime(f.mime) }}\n </span>\n </td>\n\n \x3c!-- Size --\x3e\n <td style="padding:6px 8px; text-align:right; font-family:monospace; font-size:11px; opacity:.7;">\n {{ fmtSize(f.size) }}\n </td>\n\n \x3c!-- Hash --\x3e\n <td style="padding:6px 8px; font-family:monospace; font-size:10px; opacity:.4;" :title="f.hash">\n {{ hashShort(f.hash) }}\n </td>\n\n \x3c!-- Date --\x3e\n <td style="padding:6px 8px; font-size:11px; opacity:.5;">\n {{ fmtDate(f.createdAt) }}\n </td>\n\n \x3c!-- Actions --\x3e\n <td style="padding:6px 8px; text-align:center; white-space:nowrap;">\n <a\n :href="downloadUrl(f)"\n :download="filename(f)"\n @click="$event.stopPropagation()"\n style="display:inline-flex; align-items:center; justify-content:center; width:26px; height:22px; color:var(--okdb-sky); font-size:12px; text-decoration:none; border:1px solid var(--okdb-sky-soft-border); border-radius:4px; margin-right:4px;"\n title="Download"\n >↓</a>\n <button\n @click="deleteFile(f, $event)"\n style="width:26px; height:22px; font-size:11px; padding:0; color:var(--okdb-danger); border-color:#5a1e1e44; background:var(--okdb-danger-soft-bg);"\n title="Delete"\n >🗑</button>\n </td>\n\n </tr>\n </tbody>\n </table>\n </div>\n\n \x3c!-- ── Pagination ──────────────────────────────────────────────────── --\x3e\n <div class="ok-pager">\n <button @click="page--" :disabled="!hasPrev">‹ Prev</button>\n <span>Page {{ page + 1 }} / {{ totalPages }} · {{ filteredFiles.length }}{{ pathQuery ? \' of \' + files.length : \'\' }} total{{ listCapped ? \' (first 2000 loaded)\' : \'\' }}</span>\n <button @click="page++" :disabled="!hasNext">Next ›</button>\n </div>\n </if>\n\n </if>\n</div>\n\n\x3c!-- ═══ Preview column ═══════════════════════════════════════════════ --\x3e\n<if :="selected">\n <div class="fl-preview">\n <files-preview :file="selected" :highlight="highlight" @close="closePreview()" />\n </div>\n</if>\n\n</div>',style:"\n[tag] .fl-col { flex:1 1 55%; min-width:0; display:flex; flex-direction:column; min-height:0; }\n[tag] .fl-preview { flex:1 1 45%; min-width:320px; min-height:0; display:flex; flex-direction:column; }\n[tag] .fl-preview > files-preview { flex:1; min-height:0; display:block; }\n[tag] .fl-search { flex:1; min-width:160px; max-width:360px; font-size:12px; }\n[tag] .fl-hint { flex-shrink:0; font-size:12px; line-height:1.5; margin-bottom:10px; padding:10px 12px; border:1px dashed var(--okdb-app-border-strong); border-radius:8px; background:var(--okdb-app-bg-deep); }\n[tag] .fl-hint pre { margin:0; padding:6px 8px; font-size:11px; border-radius:5px; background:var(--okdb-app-bg); color:var(--okdb-accent); white-space:pre-wrap; }\n[tag] .fl-hint code { font-size:11px; }\n[tag] .fl-hit { display:flex; flex-direction:column; gap:4px; width:100%; text-align:left; padding:7px 10px; margin-bottom:4px; border-radius:6px; border:1px solid var(--okdb-app-border); background:var(--okdb-app-bg-deep); cursor:pointer; }\n[tag] .fl-hit:hover { background:var(--okdb-app-surface); }\n[tag] .fl-hit--on { background:var(--okdb-accent-soft-bg); border-color:var(--okdb-accent-soft-border); }\n[tag] .fl-snip { font-size:11px; line-height:1.45; opacity:.75; font-family:monospace; white-space:normal; word-break:break-word; }\n[tag] .fl-snip mark { background:color-mix(in srgb, var(--okdb-warning) 38%, transparent); color:inherit; border-radius:2px; padding:0 1px; }\n[tag] .file-row { border-bottom: 1px solid var(--okdb-app-bg); transition: background .1s; cursor: pointer; }\n[tag] .file-row:hover { background: var(--okdb-app-bg-deep); }\n[tag] .file-row--on, [tag] .file-row--on:hover { background: var(--okdb-accent-soft-bg); }\n@media (max-width: 900px) {\n [tag] > div { flex-direction: column; }\n [tag] .fl-preview { min-width:0; flex-basis:auto; max-height:60vh; }\n}\n"};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"../../../stores/events-store.js";import t from"../../../stores/okdb-store.js";export default{tag:"files-path-browser",context:e=>({busy:!1,allFiles:[],selected:null,_unsubs:[],async load(){this.busy=!0;try{const n=t.apiBase,i=await fetch(`${n}/files?path=/&recursive=true&limit=5000`);if(!i.ok)throw new Error("failed");const s=await i.json();this.allFiles=s.data??[],e.$dispatch("loaded",this.allFiles)}catch(e){console.error("files-path-browser load error",e)}finally{this.busy=!1}},clearSelection(){this.selected=null},select(t){this.selected=t,e.$dispatch("select",t)},get dirs(){const e=new Map;for(const t of this.allFiles){const n=(t.path??"").match(/^(\/[^/]+)\//);if(!n)continue;const i=n[1];e.set(i,(e.get(i)??0)+1)}return[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0])).map(([e,t])=>({path:e,count:t}))},get totalFiles(){return this.allFiles.length},totalBytes(){const e=this.allFiles.reduce((e,t)=>e+(t.size??0),0);return e<1024?e+" B":e<1048576?(e/1024).toFixed(1)+" KB":e<1073741824?(e/1048576).toFixed(1)+" MB":(e/1073741824).toFixed(2)+" GB"}}),async mount(n){await this.load();const i=()=>this.load();this._unsubs=[e.on("files:uploaded",i),e.on("files:removed",i)],n.$watch(()=>t.selectedEnv,()=>{this.selected=null,this.load()})},unmount(){for(const e of this._unsubs)e();this._unsubs=[]},template:'\n<div style="display:flex; flex-direction:column; gap:4px; height:100%; min-height:0; overflow:hidden;">\n\n \x3c!-- Header --\x3e\n <div style="display:flex; align-items:center; justify-content:space-between; gap:6px; margin-bottom:6px; flex-shrink:0;">\n <div style="font-weight:600; font-size:13px; opacity:.8;">Files</div>\n <button @click="load()" :disabled="busy" style="font-size:11px; opacity:.6;" title="Refresh">↻</button>\n </div>\n\n \x3c!-- Summary --\x3e\n <div style="font-size:11px; opacity:.4; margin-bottom:4px; flex-shrink:0;">\n {{ totalFiles }} file(s) · {{ totalBytes() }}\n </div>\n\n <if :="busy && allFiles.length === 0">\n <div style="font-size:11px; opacity:.4; padding:4px 0;">Loading…</div>\n </if>\n\n \x3c!-- Scrollable dir list --\x3e\n <div style="flex:1; overflow-y:auto; overflow-x:hidden; display:flex; flex-direction:column; gap:2px; min-height:0;">\n\n \x3c!-- All Files row --\x3e\n <button\n :class="selected === \'/\' ? \'dir-row dir-row--on\' : \'dir-row\'"\n @click="select(\'/\')"\n >\n <span style="flex-shrink:0; font-size:11px; opacity:.5;">📁</span>\n <span style="flex:1; text-align:left; font-size:12px; font-family:monospace;">/</span>\n <span style="font-size:10px; opacity:.35; flex-shrink:0; font-family:monospace;">{{ totalFiles }}</span>\n </button>\n\n <if :="dirs.length > 0">\n <div style="border-top:1px solid var(--okdb-app-surface-2); margin:4px 2px;"></div>\n </if>\n\n \x3c!-- Per-dir rows --\x3e\n <each :of="dirs" let:item="dir">\n <button\n :class="selected === dir.path ? \'dir-row dir-row--on\' : \'dir-row\'"\n @click="select(dir.path)"\n :title="dir.path"\n >\n <span style="flex-shrink:0; font-size:11px; opacity:.4;">📂</span>\n <span style="flex:1; text-align:left; font-size:12px; font-family:monospace; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;">\n {{ dir.path }}\n </span>\n <span style="font-size:10px; opacity:.35; flex-shrink:0; font-family:monospace;">{{ dir.count }}</span>\n </button>\n </each>\n\n <if :="allFiles.length === 0 && !busy">\n <div style="font-size:12px; opacity:.3; padding:12px 0; text-align:center; line-height:1.7;">\n No files yet.<br>\n <span style="font-size:11px;">Select / and upload.</span>\n </div>\n </if>\n\n </div>\n\n</div>',style:"\n[tag] .dir-row {\n display: flex;\n align-items: center;\n gap: 6px;\n padding: 5px 8px;\n border-radius: 6px;\n border: 1px solid transparent;\n background: transparent;\n cursor: pointer;\n width: 100%;\n text-align: left;\n transition: background .1s;\n}\n[tag] .dir-row:hover { background: var(--okdb-app-surface); border-color: var(--okdb-app-border); }\n[tag] .dir-row--on { background: var(--okdb-accent-soft-bg); border-color: var(--okdb-accent-soft-border); color: var(--okdb-accent); }\n"};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"../../../stores/okdb-store.js";const i=/\.(txt|text|md|markdown|log|csv|tsv|json|jsonl|ndjson|ya?ml|toml|ini|conf|cfg|env|xml|html?|css|js|mjs|cjs|ts|tsx|jsx|py|rb|go|rs|java|kt|c|h|cc|cpp|hpp|cs|php|sh|bash|zsh|sql|graphql|proto|vue|svelte)$/i;function t(e){return String(e||"").split(";")[0].trim().toLowerCase()}export function previewKind(e){const n=t(e?.mime),r=String(e?.path||"");return"image/svg+xml"===n||!n.startsWith("image/")&&/\.svg$/i.test(r)?"svg":n.startsWith("image/")?"image":"application/pdf"===n?"pdf":n.startsWith("audio/")?"audio":n.startsWith("video/")?"video":n.startsWith("text/")||"application/json"===n||"application/xml"===n||"application/javascript"===n||"application/x-ndjson"===n||"application/yaml"===n||n.endsWith("+json")||n.endsWith("+xml")?"text":n&&"application/octet-stream"!==n||!i.test(r)?"other":"text"}export default{tag:"files-preview",props:["file","highlight"],context:i=>({loading:!1,error:null,text:"",truncated:!1,binary:!1,pretty:!1,svgUrl:null,mediaError:!1,_seq:0,get file(){return i.$attr.file??null},get kind(){return previewKind(this.file)},get inlineUrl(){const i=this.file;return i?`${e.apiBase}/files/${encodeURIComponent(i.id)}?inline=1`:""},get downloadUrl(){const i=this.file;return i?`${e.apiBase}/files/${encodeURIComponent(i.id)}`:""},get filename(){const e=this.file?.path??"";return e?e.split("/").filter(Boolean).pop():this.file?.id??""},get terms(){const e=String(i.$attr.highlight??"").toLowerCase(),t=new Set;for(const i of e.split(/[^\p{L}\p{N}_]+/u))i.length>=2&&t.add(i);return[...t]},get segments(){const e=this.text,i=this.terms;if(!e||0===i.length)return[{t:e,hit:!1}];const t=new RegExp(i.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),"giu"),n=[];let r,a=0,o=0;for(;(r=t.exec(e))&&o<500;)r.index>a&&n.push({t:e.slice(a,r.index),hit:!1}),n.push({t:r[0],hit:!0}),a=r.index+r[0].length,o++;return a<e.length&&n.push({t:e.slice(a),hit:!1}),n},get markCount(){return this.segments.filter(e=>e.hit).length},_revokeSvg(){this.svgUrl&&URL.revokeObjectURL(this.svgUrl),this.svgUrl=null},async load(){const e=++this._seq,i=this.file;if(this.error=null,this.text="",this.truncated=!1,this.binary=!1,this.pretty=!1,this.mediaError=!1,this._revokeSvg(),!i)return;const n=this.kind;if(("text"===n||"svg"===n)&&i.size)if("svg"===n&&i.size>2097152)this.error=`SVG is ${this.fmtSize(i.size)} — too large to preview. Download it instead.`;else{this.loading=!0;try{const r="text"===n?{range:"bytes=0-65535"}:{},a=await fetch(this.inlineUrl,{headers:r});if(!a.ok)throw new Error(`HTTP ${a.status}`);const o=new Uint8Array(await a.arrayBuffer());if(e!==this._seq)return;if("svg"===n)return void(this.svgUrl=URL.createObjectURL(new Blob([o],{type:"image/svg+xml"})));const s=o.subarray(0,65536);this.truncated=(i.size??s.length)>s.length,this.binary=s.subarray(0,8192).includes(0);let d=new TextDecoder("utf-8").decode(s);if(!this.truncated&&function(e){const i=t(e?.mime);return"application/json"===i||i.endsWith("+json")||/\.json$/i.test(String(e?.path||""))}(i))try{d=JSON.stringify(JSON.parse(d),null,2),this.pretty=!0}catch{}this.text=d,this.scrollToMark()}catch(i){e===this._seq&&(this.error=i?.message||String(i))}finally{e===this._seq&&(this.loading=!1)}}},scrollToMark(){this.terms.length&&this.text&&requestAnimationFrame(()=>i.$el?.querySelector?.(".fp-text mark")?.scrollIntoView?.({block:"center"}))},close(){i.$dispatch("close")},fmtSize:e=>null==e?"—":e<1024?e+" B":e<1048576?(e/1024).toFixed(1)+" KB":e<1073741824?(e/1048576).toFixed(1)+" MB":(e/1073741824).toFixed(2)+" GB",fmtDate:e=>e?new Date(e).toLocaleString():"—"}),async mount(e){e.$watch(()=>e.$attr.file?.id,()=>this.load()),e.$watch(()=>e.$attr.highlight,()=>this.scrollToMark()),await this.load()},unmount(){this._seq++,this._revokeSvg()},template:'\n<div class="fp">\n\n \x3c!-- ── Header ──────────────────────────────────────────────────────── --\x3e\n <div class="fp-head">\n <div style="min-width:0; flex:1;">\n <div class="fp-name" :title="file?.path">{{ filename }}</div>\n <div class="fp-sub" :title="file?.path">{{ file?.path || file?.id }}</div>\n </div>\n <div style="display:flex; gap:4px; flex-shrink:0;">\n <a class="fp-btn" :href="inlineUrl" target="_blank" rel="noopener noreferrer" title="Open in a new tab (sandboxed)">↗</a>\n <a class="fp-btn" :href="downloadUrl" :download="filename" title="Download">↓</a>\n <button class="fp-btn" @click="close()" title="Close preview">✕</button>\n </div>\n </div>\n\n \x3c!-- ── Metadata ────────────────────────────────────────────────────── --\x3e\n <div class="fp-meta">\n <span><b>type</b> {{ file?.mime || \'—\' }}</span>\n <span><b>size</b> {{ fmtSize(file?.size) }}</span>\n <span><b>uploaded</b> {{ fmtDate(file?.createdAt) }}</span>\n <span :title="file?.hash"><b>sha256</b> {{ file?.hash ? file.hash.slice(0, 12) + \'…\' : \'—\' }}</span>\n </div>\n\n \x3c!-- ── Body ────────────────────────────────────────────────────────── --\x3e\n <div class="fp-body">\n\n <if :="error">\n <div class="fp-note fp-note--err">{{ error }}</div>\n </if>\n\n <if :="loading">\n <div class="fp-note">Loading preview…</div>\n </if>\n\n \x3c!-- text / JSON --\x3e\n <if :="kind === \'text\' && !loading && !error">\n <if :="!file?.size">\n <div class="fp-note">Empty file.</div>\n </if>\n <if :="file?.size">\n <if :="binary">\n <div class="fp-note fp-note--warn">Looks binary (NUL bytes in the first 8 KB) — shown as UTF-8 anyway.</div>\n </if>\n <if :="terms.length">\n <div class="fp-note">{{ markCount }}{{ markCount >= 500 ? \'+\' : \'\' }} match(es) for <code>{{ terms.join(\' \') }}</code>{{ truncated ? \' in the first 64 KB\' : \'\' }}</div>\n </if>\n <pre class="fp-text"><each :of="segments" let:item="s"><if :="s.hit"><mark>{{ s.t }}</mark></if><if :="!s.hit">{{ s.t }}</if></each></pre>\n <if :="truncated">\n <div class="fp-note">Showing the first 64 KB of {{ fmtSize(file?.size) }} — download for the full file.</div>\n </if>\n </if>\n </if>\n\n \x3c!-- image --\x3e\n <if :="kind === \'image\'">\n <if :="!mediaError">\n <div class="fp-media fp-checker">\n <img :src="inlineUrl" :alt="filename" @error="mediaError = true" />\n </div>\n </if>\n <if :="mediaError">\n <div class="fp-note fp-note--err">The browser could not render this image.</div>\n </if>\n </if>\n\n \x3c!-- SVG (blob: URL inside <img> — scripts never run) --\x3e\n <if :="kind === \'svg\' && svgUrl">\n <div class="fp-media fp-checker">\n <img :src="svgUrl" :alt="filename" />\n </div>\n </if>\n\n \x3c!-- PDF --\x3e\n <if :="kind === \'pdf\'">\n <iframe class="fp-frame" :src="inlineUrl" :title="filename"></iframe>\n </if>\n\n \x3c!-- audio --\x3e\n <if :="kind === \'audio\'">\n <div class="fp-media" style="padding:24px 12px;">\n <audio controls preload="metadata" :src="inlineUrl" style="width:100%;" @error="mediaError = true"></audio>\n </div>\n <if :="mediaError">\n <div class="fp-note fp-note--err">The browser cannot play this audio format.</div>\n </if>\n </if>\n\n \x3c!-- video --\x3e\n <if :="kind === \'video\'">\n <div class="fp-media" style="background:#000;">\n <video controls preload="metadata" :src="inlineUrl" @error="mediaError = true"></video>\n </div>\n <if :="mediaError">\n <div class="fp-note fp-note--err">The browser cannot play this video format.</div>\n </if>\n </if>\n\n \x3c!-- anything else --\x3e\n <if :="kind === \'other\'">\n <div class="fp-empty">\n <div style="font-size:30px;">📎</div>\n <div>No inline preview for <code>{{ file?.mime || \'unknown type\' }}</code>.</div>\n <a class="fp-dl" :href="downloadUrl" :download="filename">↓ Download {{ fmtSize(file?.size) }}</a>\n </div>\n </if>\n\n </div>\n</div>',style:"\n[tag] .fp { display:flex; flex-direction:column; height:100%; min-height:0; border:1px solid var(--okdb-app-border); border-radius:8px; background:var(--okdb-app-bg-deep); overflow:hidden; }\n[tag] .fp-head { display:flex; align-items:flex-start; gap:8px; padding:8px 10px; border-bottom:1px solid var(--okdb-app-border); flex-shrink:0; }\n[tag] .fp-name { font-family:monospace; font-size:12.5px; font-weight:700; color:var(--okdb-app-fg-strong); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n[tag] .fp-sub { font-family:monospace; font-size:10.5px; opacity:.45; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n[tag] .fp-btn { display:inline-flex; align-items:center; justify-content:center; width:26px; height:22px; padding:0; font-size:12px; text-decoration:none; color:var(--okdb-sky); border:1px solid var(--okdb-sky-soft-border); border-radius:4px; background:transparent; cursor:pointer; }\n[tag] .fp-meta { display:flex; flex-wrap:wrap; gap:4px 14px; padding:6px 10px; font-size:11px; font-family:monospace; opacity:.75; border-bottom:1px solid var(--okdb-app-border); flex-shrink:0; }\n[tag] .fp-meta b { font-weight:500; opacity:.55; margin-right:3px; }\n[tag] .fp-body { flex:1; min-height:0; overflow:auto; padding:10px; display:flex; flex-direction:column; gap:8px; }\n[tag] .fp-note { font-size:11.5px; opacity:.6; }\n[tag] .fp-note code { font-size:11px; }\n[tag] .fp-note--err { opacity:1; color:var(--okdb-danger); }\n[tag] .fp-note--warn { opacity:1; color:var(--okdb-warning-text); }\n[tag] .fp-text { margin:0; padding:10px; font-family:'Cascadia Code','Fira Code','Consolas',monospace; font-size:11.5px; line-height:1.5; white-space:pre-wrap; word-break:break-word; background:var(--okdb-app-bg); border:1px solid var(--okdb-app-border); border-radius:6px; color:var(--okdb-app-fg); }\n[tag] .fp-text mark { background:color-mix(in srgb, var(--okdb-warning) 38%, transparent); color:inherit; border-radius:2px; padding:0 1px; }\n[tag] .fp-media { display:flex; align-items:center; justify-content:center; border:1px solid var(--okdb-app-border); border-radius:6px; overflow:hidden; min-height:120px; }\n[tag] .fp-media img, [tag] .fp-media video { max-width:100%; max-height:70vh; display:block; }\n[tag] .fp-checker { background-color:var(--okdb-app-bg); background-image:linear-gradient(45deg, var(--okdb-app-surface) 25%, transparent 25%, transparent 75%, var(--okdb-app-surface) 75%), linear-gradient(45deg, var(--okdb-app-surface) 25%, transparent 25%, transparent 75%, var(--okdb-app-surface) 75%); background-size:16px 16px; background-position:0 0, 8px 8px; }\n[tag] .fp-frame { flex:1; width:100%; min-height:60vh; border:1px solid var(--okdb-app-border); border-radius:6px; background:#fff; }\n[tag] .fp-empty { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:10px; font-size:12.5px; opacity:.7; padding:30px 0; text-align:center; }\n[tag] .fp-dl { font-size:12px; padding:4px 14px; border-radius:999px; text-decoration:none; color:var(--okdb-sky); border:1px solid var(--okdb-sky-soft-border); background:var(--okdb-sky-soft-bg); }\n"};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"../../../components/ok-dropzone.ok.js";import n from"../../../stores/okdb-store.js";export default{tag:"files-upload-panel",props:["path"],dependencies:[e],context:e=>({queue:[],get path(){return e.$attr.path||"/"},onFilesDropped(e){const{files:n}=e.detail;for(const e of n)this.queue.push({file:e,relativePath:e.relativePath||e.name,status:"pending",error:null,record:null});this._flush()},onBrowse(){const e=document.createElement("input");e.type="file",e.multiple=!0,e.onchange=()=>{for(const n of Array.from(e.files))this.queue.push({file:n,relativePath:n.name,status:"pending",error:null,record:null});this._flush()},e.click()},_uploading:!1,async _flush(){if(!this._uploading){this._uploading=!0;try{let e;for(;e=this.queue.find(e=>"pending"===e.status);)await this._uploadOne(e)}finally{this._uploading=!1}}},async _uploadOne(t){t.status="uploading";const o=e.$attr.path||"/";try{const i=(t.relativePath||t.file.name).replace(/^\//,""),s=(o.endsWith("/")?o:o+"/")+i,r=await fetch(`${n.apiBase}/files?path=${encodeURIComponent(s)}`,{method:"POST",headers:{"content-type":t.file.type||"application/octet-stream","content-length":String(t.file.size)},body:t.file}),a=await r.json();if(!r.ok)throw new Error(a?.error?.message||"Upload failed");t.record=a.data,t.status="done",e.$dispatch("uploaded",t.record)}catch(e){t.error=e?.message||String(e),t.status="error"}},retryItem(e){e.status="pending",e.error=null,this._flush()},removeItem(e){const n=this.queue.indexOf(e);-1!==n&&this.queue.splice(n,1)},clearDone(){this.queue=this.queue.filter(e=>"done"!==e.status)},fmtSize:e=>null==e?"—":e<1024?e+" B":e<1048576?(e/1024).toFixed(1)+" KB":(e/1048576).toFixed(1)+" MB",get pendingCount(){return this.queue.filter(e=>"pending"===e.status).length},get uploadingCount(){return this.queue.filter(e=>"uploading"===e.status).length},get doneCount(){return this.queue.filter(e=>"done"===e.status).length},get errorCount(){return this.queue.filter(e=>"error"===e.status).length}}),template:'\n<div style="display:flex; flex-direction:column; gap:10px;">\n\n \x3c!-- Drop zone --\x3e\n <ok-dropzone\n @files-drop="onFilesDropped($event)"\n style="border:2px dashed var(--okdb-app-border); border-radius:8px; padding:24px 12px; text-align:center; cursor:pointer; transition:border-color .15s;"\n @click="onBrowse()"\n >\n <div style="display:flex; flex-direction:column; align-items:center; gap:6px; pointer-events:none;">\n <span style="font-size:28px; opacity:.6;">📁</span>\n <div style="font-size:13px; opacity:.7;">Drop files or folders here, or <span style="color:var(--okdb-accent); text-decoration:underline;">browse</span></div>\n <div style="font-size:11px; opacity:.4;">Uploading to <strong>{{ path }}</strong></div>\n </div>\n </ok-dropzone>\n\n \x3c!-- Summary bar --\x3e\n <if :="queue.length > 0">\n <div style="display:flex; align-items:center; gap:8px; font-size:12px;">\n <span style="opacity:.5;">{{ queue.length }} file(s)</span>\n <if :="uploadingCount > 0">\n <span style="color:var(--okdb-accent);">↑ {{ uploadingCount }} uploading</span>\n </if>\n <if :="doneCount > 0">\n <span style="color:var(--okdb-success);">✓ {{ doneCount }} done</span>\n </if>\n <if :="errorCount > 0">\n <span style="color:var(--okdb-danger);">✗ {{ errorCount }} failed</span>\n </if>\n <span style="flex:1;"></span>\n <if :="doneCount > 0">\n <button @click="clearDone()" style="font-size:11px; padding:2px 8px;">Clear done</button>\n </if>\n </div>\n\n \x3c!-- File list --\x3e\n <div style="max-height:220px; overflow-y:auto; display:flex; flex-direction:column; gap:2px;">\n <each :of="queue" let:item="item">\n <div style="display:flex; align-items:center; gap:8px; padding:5px 8px; border-radius:6px; background:var(--okdb-app-surface); font-size:12px;">\n\n \x3c!-- Status dot --\x3e\n <span :style="\n \'width:7px;height:7px;border-radius:50%;flex-shrink:0;background:\' +\n (item.status === \'done\' ? \'var(--okdb-success)\' :\n item.status === \'error\' ? \'var(--okdb-danger)\' :\n item.status === \'uploading\' ? \'var(--okdb-accent)\' : \'var(--okdb-method-default)\')\n "></span>\n\n \x3c!-- Name --\x3e\n <span style="flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;"\n :title="item.relativePath">{{ item.relativePath }}</span>\n\n \x3c!-- Size --\x3e\n <span style="opacity:.5; font-family:monospace; font-size:11px; flex-shrink:0;">\n {{ fmtSize(item.file.size) }}\n </span>\n\n \x3c!-- Error message --\x3e\n <if :="item.status === \'error\'">\n <span style="color:var(--okdb-danger); font-size:11px; max-width:120px; overflow:hidden; text-overflow:ellipsis;"\n :title="item.error">{{ item.error }}</span>\n <button @click="retryItem(item)" style="font-size:10px; padding:1px 6px;">↻</button>\n </if>\n\n \x3c!-- Spinner for uploading --\x3e\n <if :="item.status === \'uploading\'">\n <span style="color:var(--okdb-accent); font-size:11px; animation:spin 1s linear infinite;">⟳</span>\n </if>\n\n \x3c!-- Remove button --\x3e\n <if :="item.status !== \'uploading\'">\n <button @click="removeItem(item)" style="font-size:10px; padding:1px 6px; opacity:.5;">✕</button>\n </if>\n\n </div>\n </each>\n </div>\n </if>\n\n</div>',style:"\n@keyframes spin { to { transform: rotate(360deg); } }\n"};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<script type="module">import e from"./parts/function-detail.ok.js";import t from"./parts/function-logs.ok.js";import n from"./parts/function-runner.ok.js";import o from"./modals/function-modal.ok.js";import s from"./parts/functions-list.ok.js";export default{tag:"functions-index",unwrap:!0,dependencies:[s,e,n,t,o],context:e=>({get functions(){return e.$ok.stores.functions},get isGlobal(){return this.functions.isGlobalScope},get envName(){return this.functions.envName},get canManage(){return this.functions.canOpenModal},get isDetailView(){return"detail"===this.functions.currentView&&this.functions.hasSelected},get isOverviewView(){return!this.isDetailView},get selectedName(){return this.functions.selectedName},get totalFunctions(){return this.functions.functionsOverview.length},get enabledCount(){return this.functions.functionsOverview.filter(e=>!1!==e.value?.enabled).length},get disabledCount(){return this.functions.functionsOverview.filter(e=>!1===e.value?.enabled).length},get neverRunCount(){return this.functions.functionsOverview.filter(e=>!e.latestRun).length},get recentSuccessCount(){return this.functions.overviewRuns.filter(e=>"success"===e.value?.status).length},get recentErrorCount(){return this.functions.overviewRuns.filter(e=>["error","timeout","killed"].includes(e.value?.status)).length},fmt:e=>Number(e||0).toLocaleString(),relTime(e){if(!e)return"—";const t=Date.now()-e;return t<5e3?"just now":t<6e4?`${Math.round(t/1e3)}s ago`:t<36e5?`${Math.round(t/6e4)}m ago`:t<864e5?`${Math.round(t/36e5)}h ago`:new Date(e).toLocaleDateString()},latestLogLine(e){const t=e?.latestRun?.id||e?.latestRun?.runId;if(!t)return null;const n=this.functions.logsForRun(t);return n.length?n[n.length-1]?.msg:null},getRouteFunctionName(){try{const e=globalThis.location?.hash||"",t=e.includes("?")?e.split("?")[1]:"";return new URLSearchParams(t).get("name")}catch{return null}},goOverview(){const t=e.$ok.stores.functions;t.setView("overview"),t.select(null),e.$vars.$router?.push?.("/functions")},async openFunction(t){t&&(await e.$ok.stores.functions.select(t),e.$vars.$router?.push?.("/functions?name="+encodeURIComponent(t)))},async openCreateModal(){const t=e.$ok.stores.functions;t.canOpenModal&&(t.beginCreateDraft(),await e.$ok.shared.modal.open({owner:e,title:"Create Function",canDrag:!0,content:'<function-modal :modal="modal" mode="create" :on-done="onDone" />',context:n=>({modal:n,onDone:async n=>{await t.hydrateOverview(),n?.name&&await e.openFunction(n.name)}})}))},async openEditModal(){const t=e.$ok.stores.functions;t.hasSelected&&(t.beginEditDraft(),await e.$ok.shared.modal.open({owner:e,title:`Edit Function · ${t.selectedName}`,canDrag:!0,content:'<function-modal :modal="modal" mode="edit" :on-done="onDone" />',context:e=>({modal:e,onDone:async()=>{await t.select(t.selectedName),await t.loadOverviewRuns()}})}))}}),init(e){const t=async()=>{const t=this.getRouteFunctionName();t?await e.$ok.stores.functions.select(t):e.$ok.stores.functions.setView("overview")};e.$watch(()=>e.$ok.stores.okdb.selectedEnv,()=>e.$ok.stores.functions.onEnvChanged()),e.$watch(()=>globalThis.location?.hash,()=>t()),this.functions.onEnvChanged(),t()}};</script><template><component import="../../layouts/_default.ok.html"><template name="header"><div style="display:flex;align-items:center;justify-content:space-between;gap:16px;width:100%"><div><div style="font-size:22px;font-weight:700;color:var(--okdb-app-fg)">Functions</div><div style="margin-top:4px;font-size:12px;color:var(--okdb-app-fg-muted)"><if :="envName">{{ envName }}</if><if :="!envName">No environment selected</if></div><if :="isDetailView"><div style="margin-top:8px;font-size:13px;color:#a7c0d1">Viewing <strong>{{ selectedName }}</strong></div></if></div><div style="font-size:11px;color:var(--okdb-app-fg-muted);text-transform:uppercase;letter-spacing:.08em"><div>{{ envName || '—' }}</div></div></div></template><template name="sidebar"><functions-list @create="openCreateModal()" @overview="goOverview()" @open="openFunction($event.detail)"></functions-list></template><template name="default"><if :="isOverviewView"><div style="display:flex;flex-direction:column;gap:20px;max-width:980px"><div style="display:flex;align-items:center;gap:10px"><div style="font-weight:600;font-size:18px">Functions Overview</div><div style="margin-left:auto"><button @click="openCreateModal()" :disabled="!canManage" style="font-size:12px;padding:5px 12px;opacity:.85">+ New function</button></div></div><div class="fn-ov-stat-row"><div class="fn-ov-stat-card"><div class="fn-ov-stat-label">Functions</div><div class="fn-ov-stat-value" style="color:var(--okdb-accent)">{{ fmt(totalFunctions) }}</div></div><div class="fn-ov-stat-card"><div class="fn-ov-stat-label">Enabled</div><div class="fn-ov-stat-value" style="color:#4ade80">{{ fmt(enabledCount) }}</div></div><div class="fn-ov-stat-card"><div class="fn-ov-stat-label">Recent Success</div><div class="fn-ov-stat-value" style="color:var(--okdb-success)">{{ fmt(recentSuccessCount) }}</div></div><div class="fn-ov-stat-card"><div class="fn-ov-stat-label">Recent Failures</div><div class="fn-ov-stat-value" style="color:var(--okdb-danger)">{{ fmt(recentErrorCount) }}</div></div></div><if :="functions.functionsOverview.length === 0"><div class="fn-ov-empty"><div style="font-size:30px;margin-bottom:12px">ƒ</div><div style="font-weight:600;font-size:15px;margin-bottom:5px">No functions registered yet</div><div style="font-size:13px;opacity:.6;line-height:1.7">Create your first function from the sidebar and use the draft runner to validate it before saving.</div></div></if><if :="functions.functionsOverview.length > 0"><div class="fn-ov-card"><div class="fn-ov-card-head"><span style="font-weight:600;font-size:14px">Functions</span> <span style="font-size:12px;opacity:.45;margin-left:auto">{{ totalFunctions }} total · {{ neverRunCount }} never run</span></div><table class="fn-ov-table"><thead><tr><th>Name</th><th>Status</th><th style="text-align:right">Runs</th><th style="text-align:right">Latest</th><th></th></tr></thead><tbody><tr as="repeat" :of="functions.functionsOverview" let:item="fn" class="fn-ov-row" @click="openFunction(fn.key)"><td><div style="display:flex;flex-direction:column;gap:4px"><span style="font-family:monospace;font-size:13px;color:var(--okdb-app-fg)">{{ fn.key }}</span> <span style="font-size:11px;color:var(--okdb-app-fg-muted);max-width:360px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">{{ fn.value?.metadata?.description || 'No description yet.' }}</span><if :="latestLogLine(fn)"><span style="font-size:11px;color:#8db1c8;max-width:360px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">log: {{ latestLogLine(fn) }}</span></if></div></td><td><span :style="fn.value?.enabled === false ? 'font-size:10px; color:var(--okdb-danger); text-transform:uppercase;' : 'font-size:10px; color:var(--okdb-success); text-transform:uppercase;'">{{ fn.value?.enabled === false ? 'disabled' : (fn.latestRun?.status || 'ready') }}</span></td><td style="text-align:right;color:var(--okdb-accent);font-weight:600">{{ fmt(functions.overviewRuns.filter(row => row.value?.functionName === fn.key).length) }}</td><td style="text-align:right;opacity:.55;font-size:12px">{{ relTime(fn.latestRun?.execution?.finishedAt ?? fn.latestRun?.request?.requestedAt) }}</td><td style="text-align:right;opacity:.3;font-size:11px;padding-right:16px">→</td></tr></tbody></table></div><div class="fn-ov-card"><div class="fn-ov-card-head"><span style="font-weight:600;font-size:14px">Recent Executions</span> <span style="font-size:12px;opacity:.4;margin-left:auto">last {{ functions.overviewRuns.length }}</span></div><table style="width:100%;border-collapse:collapse;font-size:12px"><tbody><tr as="repeat" :of="functions.overviewRuns" let:item="row" class="fn-ov-row fn-ov-row--sm" @click="openFunction(row.value?.functionName)"><td class="fn-ov-td" style="font-family:monospace;font-size:11px;color:var(--okdb-app-fg);padding-left:16px">{{ row.value?.functionName || row.key }}</td><td class="fn-ov-td"><span :style="row.value?.status === 'success' ? 'font-size:10px; color:var(--okdb-success);' : 'font-size:10px; color:var(--okdb-danger);'">{{ row.value?.status || '—' }}</span></td><td class="fn-ov-td" style="font-family:monospace;font-size:11px;opacity:.45;max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">{{ row.value?.id || row.key }}</td><td class="fn-ov-td" style="text-align:right;opacity:.35;white-space:nowrap;font-size:11px;padding-right:16px">{{ relTime(row.value?.execution?.finishedAt ?? row.value?.request?.requestedAt) }}</td></tr></tbody></table></div><function-logs title="Live function logs" empty="Run a function to see logs here."></function-logs></if></div></if><if :="isDetailView"><div style="display:grid;grid-template-columns:minmax(0,1.45fr) minmax(360px,.95fr);gap:16px;height:100%;min-height:0"><div style="display:grid;grid-template-rows:minmax(0,1fr) minmax(260px,.85fr);gap:16px;min-height:0"><div style="min-height:0;overflow:auto"><function-detail :on-edit="() => openEditModal()"></function-detail></div><div style="min-height:0;overflow:auto"><function-logs :run-id="functions.selectedRun?.id || functions.selectedRun?.runId" :entries="functions.selectedLogEntries" title="Selected function live logs" empty="No logs captured for the selected run yet."></function-logs></div></div><div style="min-height:0;overflow:auto"><function-runner></function-runner></div></div></if></template></component></template><style>.fn-ov-stat-row{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.fn-ov-card,.fn-ov-stat-card{border:1px solid var(--okdb-app-border);border-radius:12px;background:var(--okdb-app-bg-deep)}.fn-ov-stat-card{padding:14px}.fn-ov-stat-label{font-size:11px;text-transform:uppercase;color:var(--okdb-app-fg-muted);margin-bottom:6px}.fn-ov-stat-value{font-size:24px;font-weight:700;color:var(--okdb-app-fg)}.fn-ov-empty{border:1px dashed var(--okdb-app-border);border-radius:12px;padding:24px;text-align:center;color:var(--okdb-app-fg-muted);background:var(--okdb-app-bg-deep)}.fn-ov-card-head{display:flex;align-items:center;gap:10px;padding:14px 16px;border-bottom:1px solid var(--okdb-app-border)}.fn-ov-table{width:100%;border-collapse:collapse;font-size:12px}.fn-ov-table thead th{text-align:left;padding:10px 16px;color:var(--okdb-app-fg-muted);font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.05em;border-bottom:1px solid var(--okdb-app-border)}.fn-ov-row{cursor:pointer}.fn-ov-row:hover{background:var(--okdb-app-bg-deep)}.fn-ov-row td,.fn-ov-td{padding:12px 16px;border-bottom:1px solid var(--okdb-app-border)}.fn-ov-row--sm .fn-ov-td,.fn-ov-row--sm td{padding-top:10px;padding-bottom:10px}</style>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"@toolkit/elements/ok-icon.ok.js";import t from"@toolkit/core/ok-overlay.ok.js";import n from"../../../components/ok-js-input.ok.js";import o from"../../../components/ok-text-monaco-input.ok.js";import i from"../parts/function-logs.ok.js";export default{tag:"function-modal",dependencies:[e,t,n,o,i],attr:{modal:{},mode:{},onDone:{}},context:e=>({get store(){return e.$ok.stores.functions},get mode(){return e.$attr.mode||this.store.modalMode||"create"},get saving(){return this.store.saving},get running(){return this.store.modalRunning},get validation(){return this.store.modalValidation||{}},get canSave(){return this.store.canSaveModal},get canRun(){return!!this.store.modalValidation?.ok&&!this.store.modalPayloadError&&!this.store.modalRunning},get modalDryRunMode(){return this.store.modalDryRunMode},get modalDryRunActions(){return this.store.modalPreviewRun?.result?.dryRunActions??null},toggleModalDryRun(){this.store.modalDryRunMode=!this.store.modalDryRunMode},get scopeLabel(){return this.store.envName||"—"},get unsafe(){return!0===this.store.modalUnsafeDraft},get titleLabel(){return"edit"===this.mode?"Edit function":"Create function"},get saveLabel(){return"edit"===this.mode?"Save changes":"Create function"},get descriptionLength(){return String(this.store.modalDescriptionDraft||"").length},get payloadError(){return this.store.modalPayloadError},get previewRun(){return this.store.modalPreviewRun},get previewRunId(){return this.previewRun?.id||this.previewRun?.runId||null},get previewLogs(){return this.store.logsForRun(this.previewRunId)},get previewTriggerKind(){return this.store.modalMaterializerContextDraft?"materializer":this.store.modalProcessorContextDraft?"processor":this.store.modalJobContextDraft?"job":null},get previewTriggerContext(){return this.store.modalMaterializerContextDraft||this.store.modalProcessorContextDraft||this.store.modalJobContextDraft||null},setName(e){this.store.modalNameDraft=e??""},setDescription(e){this.store.modalDescriptionDraft=e??""},setEnabled(e){this.store.modalEnabledDraft=!!e},setUnsafe(e){this.store.modalUnsafeDraft=!!e},setTimeoutMs(e){const t=parseInt(e,10);this.store.modalTimeoutMsDraft=Number.isFinite(t)&&t>0?t:null},setMemoryMb(e){const t=parseInt(e,10);this.store.modalMemoryMbDraft=Number.isFinite(t)&&t>0?t:null},setAllowFetch(e){this.store.modalAllowFetchDraft=!!e},setSource(e){this.store.setModalSourceDraft(e??"")},setPayload(e){this.store.setModalPayloadDraft(e??"{\n \n}")},async submit(){if(this.canSave)try{const t=await this.store.saveModalDefinition();this.store.setPayloadDraft(this.store.modalPayloadDraft),e.$ok.shared?.toast?.success?.("edit"===this.mode?`Function saved: ${t?.name||this.store.selectedName}`:`Function created: ${t?.name||this.store.modalNameDraft}`),await e.$attr.modal.close(),await(e.$attr.onDone?.(t))}catch(t){e.$ok.shared?.toast?.error?.(t?.message||"Failed to save function")}},async runDraft(){if(this.canRun)try{await this.store.runModalDraft(),e.$ok.shared?.toast?.success?.(this.modalDryRunMode?"Dry run complete":"Draft executed")}catch(t){e.$ok.shared?.toast?.error?.(t?.message||"Failed to run draft")}},actionArgs(e){const t=e.args??[];return 0===t.length?"":t.map(e=>JSON.stringify(e)).join(", ")},formatJson(e){try{return JSON.stringify(e,null,2)}catch{return String(e??"")}},cancel(){e.$attr.modal.close()}}),template:'\n<div style="position:relative; width:min(1220px, calc(100vw - 60px)); max-width:calc(100vw - 60px); min-width:900px; min-height:760px; display:flex; flex-direction:column; gap:16px;">\n <if :="saving || running">\n <ok-overlay>\n <div class="loader-center">\n <ok-icon name="loader" class="spin" style="width:32px;height:32px;"></ok-icon>\n </div>\n </ok-overlay>\n </if>\n\n <div style="display:flex; align-items:flex-start; justify-content:space-between; gap:16px;">\n <div>\n <div style="font-size:18px; font-weight:700; color:var(--okdb-app-fg);">{{ titleLabel }}</div>\n <div style="margin-top:4px; font-size:12px; color:var(--okdb-app-fg-muted);">Scope: {{ scopeLabel }}</div>\n </div>\n <div style="display:flex; align-items:center; gap:16px; font-size:12px; color:var(--okdb-app-fg-muted);">\n <label style="display:flex; align-items:center; gap:6px; cursor:pointer; user-select:none;">\n <input type="checkbox" :checked="store.modalEnabledDraft !== false" @change="setEnabled($el.checked)" />\n Enabled\n </label>\n <label :style="unsafe ? \'display:flex; align-items:center; gap:6px; cursor:pointer; user-select:none; color:var(--okdb-orange); font-weight:600;\' : \'display:flex; align-items:center; gap:6px; cursor:pointer; user-select:none;\'">\n <input type="checkbox" :checked="store.modalUnsafeDraft === true" @change="setUnsafe($el.checked)" />\n <span>{{ unsafe ? \'⚠️ Unsafe\' : \'Unsafe\' }}</span>\n </label>\n </div>\n </div>\n\n <if :="unsafe">\n <div style="padding:10px 14px; border:1px solid #92400e; border-radius:10px; background:#1c0f00; color:#fdba74; font-size:12px; line-height:1.6; display:flex; gap:10px; align-items:flex-start;">\n <span style="font-size:16px; flex-shrink:0;">⚠️</span>\n <div>\n <strong style="color:var(--okdb-orange);">Unsafe function</strong> — this function receives\n <code style="color:var(--okdb-warning); background:#2c1800; padding:1px 5px; border-radius:4px;">ctx.okdb</code>\n in addition to <code style="color:var(--okdb-accent-muted); background:var(--okdb-app-bg-deep); padding:1px 5px; border-radius:4px;">ctx.env</code>.\n <code style="color:var(--okdb-warning);">ctx.okdb</code> grants full cross-environment database access including creating and removing environments.\n Only use this for privileged, trusted operations.\n </div>\n </div>\n </if>\n\n <div style="display:grid; grid-template-columns:minmax(320px, 380px) minmax(0, 1fr); gap:16px; min-height:0; flex:1;">\n <div style="display:flex; flex-direction:column; gap:12px; min-height:0;">\n <div style="padding:14px; border:1px solid var(--okdb-app-border); border-radius:12px; background:var(--okdb-app-bg-deep); display:flex; flex-direction:column; gap:12px;">\n <div style="display:flex; flex-direction:column; min-width:0;">\n <div style="font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--okdb-app-fg-muted); margin-bottom:6px;">Function name</div>\n <input\n style="width:100%; box-sizing:border-box;"\n placeholder="e.g. queueFanout"\n :value="store.modalNameDraft"\n :disabled="mode === \'edit\'"\n @input="setName($el.value)"\n />\n <div style="margin-top:6px; font-size:11px; color:var(--okdb-app-fg-muted); line-height:1.5;">\n Name is immutable after creation and becomes the function entry point.\n </div>\n </div>\n\n <div style="display:flex; flex-direction:column; min-width:0;">\n <div style="font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--okdb-app-fg-muted); margin-bottom:6px;">Description</div>\n <textarea\n style="width:100%; box-sizing:border-box; min-height:110px; resize:vertical; background:var(--okdb-app-bg-deep); border:1px solid var(--okdb-app-border); border-radius:8px; color:#cfe6f2; padding:10px; font-size:12px; line-height:1.5;"\n placeholder="What does this function do?"\n :value="store.modalDescriptionDraft"\n @input="setDescription($el.value)"\n ></textarea>\n <div style="margin-top:6px; font-size:11px; color:var(--okdb-app-fg-subtle);">{{ descriptionLength }} chars</div>\n </div>\n </div>\n\n <div style="padding:14px; border:1px solid var(--okdb-app-border); border-radius:12px; background:var(--okdb-app-bg-deep); display:flex; flex-direction:column; gap:10px;">\n <div style="font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--okdb-app-fg-muted);">Runtime</div>\n <div style="display:grid; grid-template-columns:1fr 1fr; gap:10px;">\n <div style="display:flex; flex-direction:column; gap:4px;">\n <div style="font-size:11px; color:var(--okdb-app-fg-muted);">Timeout (ms)</div>\n <input\n type="number"\n min="1"\n step="1000"\n style="width:100%; box-sizing:border-box;"\n placeholder="5000"\n :value="store.modalTimeoutMsDraft ?? \'\'"\n @input="setTimeoutMs($el.value)"\n />\n </div>\n <div style="display:flex; flex-direction:column; gap:4px;">\n <div style="font-size:11px; color:var(--okdb-app-fg-muted);">Memory (MB)</div>\n <input\n type="number"\n min="1"\n step="1"\n style="width:100%; box-sizing:border-box;"\n placeholder="32"\n :value="store.modalMemoryMbDraft ?? \'\'"\n @input="setMemoryMb($el.value)"\n />\n </div>\n </div>\n <label style="display:flex; align-items:center; gap:6px; font-size:12px; color:var(--okdb-app-fg-muted); cursor:pointer; user-select:none;">\n <input type="checkbox" :checked="store.modalAllowFetchDraft !== false" @change="setAllowFetch($el.checked)" />\n Allow fetch\n </label>\n <div style="font-size:11px; color:var(--okdb-app-fg-subtle); line-height:1.5;">\n Leave blank to use system defaults (timeout: 5000ms, memory: 32MB).\n </div>\n </div>\n\n <div style="padding:14px; border:1px solid var(--okdb-app-border); border-radius:12px; background:var(--okdb-app-bg-deep); display:flex; flex-direction:column; gap:10px; min-height:0;">\n <div style="font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--okdb-app-fg-muted);">Run payload</div>\n <div style="font-size:12px; color:var(--okdb-app-fg-muted); line-height:1.55;">\n Define the JSON payload you want to execute right now against this draft before saving it.\n </div>\n <div style="height:220px; min-height:220px; border:1px solid var(--okdb-app-border); border-radius:10px; overflow:hidden; background:var(--okdb-app-bg-deep);">\n <ok-text-monaco-input\n style="height:100%;"\n language="json"\n :value="store.modalPayloadDraft"\n @edit:debounce.150="setPayload($event.detail)"\n ></ok-text-monaco-input>\n </div>\n <if :="payloadError">\n <div style="font-size:12px; color:var(--okdb-danger); line-height:1.5;">{{ payloadError }}</div>\n </if>\n <div style="display:flex; justify-content:flex-end; gap:8px;">\n <button\n @click="toggleModalDryRun()"\n :disabled="running"\n :style="modalDryRunMode\n ? \'font-size:12px; border-color:var(--okdb-accent); color:var(--okdb-accent);\'\n : \'font-size:12px;\'">\n Dry Run{{ modalDryRunMode ? \' ✓\' : \'\' }}\n </button>\n <button @click="runDraft()" :disabled="!canRun">{{ running ? \'Running…\' : (modalDryRunMode ? \'Run draft (dry)\' : \'Run draft\') }}</button>\n </div>\n </div>\n\n <if :="previewTriggerKind && previewTriggerContext">\n <div style="padding:14px; border:1px solid var(--okdb-app-border); border-radius:12px; background:var(--okdb-app-bg-deep); display:flex; flex-direction:column; gap:10px; min-height:0;">\n <div style="display:flex; align-items:center; justify-content:space-between; gap:10px;">\n <div style="font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--okdb-app-fg-muted);">Preview trigger context</div>\n <div style="font-size:11px; color:var(--okdb-accent-muted); font-family:monospace;">ctx.{{ previewTriggerKind }}</div>\n </div>\n <div style="font-size:12px; color:var(--okdb-app-fg-muted); line-height:1.55;">\n This draft run simulates the engine metadata shown below so you can reproduce handler behavior before saving.\n </div>\n <pre style="margin:0; white-space:pre-wrap; word-break:break-word; color:var(--okdb-app-fg-muted); font-size:11px; line-height:1.5; max-height:180px; overflow:auto;">{{ formatJson(previewTriggerContext) }}</pre>\n </div>\n </if>\n\n <div style="padding:14px; border:1px solid var(--okdb-app-border); border-radius:12px; background:var(--okdb-app-bg-deep); display:flex; flex-direction:column; gap:6px;">\n <div style="font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--okdb-app-fg-muted);">Validation</div>\n <if :="validation.ok">\n <div style="font-size:12px; color:var(--okdb-success); line-height:1.55;">Function source is valid and can be saved.</div>\n </if>\n <if :="!validation.ok">\n <div style="font-size:12px; color:var(--okdb-danger); line-height:1.55;">{{ validation.message || \'Function source is invalid\' }}</div>\n <div style="font-size:11px; color:#c38989; font-family:monospace;">{{ validation.code || \'FUNCTION_SCRIPT_INVALID\' }}</div>\n </if>\n <div style="font-size:11px; color:var(--okdb-app-fg-subtle); line-height:1.5;">\n Allowed shape: <span style="font-family:monospace; color:var(--okdb-accent-muted);">[async] (ctx) => { }</span>.\n Forbidden symbols: <span style="font-family:monospace; color:var(--okdb-accent-muted);">require</span>, <span style="font-family:monospace; color:var(--okdb-accent-muted);">import</span>, <span style="font-family:monospace; color:var(--okdb-accent-muted);">console</span>, <span style="font-family:monospace; color:var(--okdb-accent-muted);">process</span>.\n </div>\n </div>\n </div>\n\n <div style="display:grid; grid-template-rows:minmax(0,1.2fr) minmax(220px,.7fr) minmax(240px,.9fr); min-height:0; gap:12px;">\n <div style="display:flex; flex-direction:column; min-height:0; border:1px solid var(--okdb-app-border); border-radius:12px; background:var(--okdb-app-bg-deep); overflow:hidden;">\n <div style="display:flex; align-items:center; justify-content:space-between; gap:10px; padding:12px 14px; border-bottom:1px solid var(--okdb-app-border);">\n <div style="font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--okdb-app-fg-muted);">Implementation</div>\n <div style="font-size:11px; color:var(--okdb-app-fg-muted); font-family:monospace;">async (ctx) => { }</div>\n </div>\n <div style="flex:1; min-height:0; background:var(--okdb-app-bg-deep);">\n <ok-js-input\n style="height:100%;"\n :value="store.modalSourceDraft"\n :unsafe="store.modalUnsafeDraft"\n :options="{ suggest: { showWords: true }, wordBasedSuggestions: \'currentDocument\' }"\n @edit="setSource($event.detail)"\n ></ok-js-input>\n </div>\n <div style="display:flex; justify-content:space-between; align-items:flex-start; gap:12px; font-size:11px; color:var(--okdb-app-fg-subtle); line-height:1.55; padding:10px 14px; border-top:1px solid var(--okdb-app-border);">\n <div>\n Runtime receives <span style="font-family:monospace; color:var(--okdb-accent-muted);">ctx</span> with DB access facades, payload, logs, and execution info.\n <if :="unsafe"><span style="color:var(--okdb-orange);"> ⚠ Unsafe: also exposes <span style="font-family:monospace; color:var(--okdb-warning);">ctx.okdb</span> (full cross-env access).</span></if>\n </div>\n <div style="white-space:nowrap;">JS / Monaco</div>\n </div>\n </div>\n\n <div style="padding:14px; border:1px solid var(--okdb-app-border); border-radius:12px; background:var(--okdb-app-bg-deep); min-height:0; overflow:auto; display:flex; flex-direction:column; gap:8px;">\n <div style="display:flex; align-items:center; justify-content:space-between; gap:8px;">\n <if :="previewRun && modalDryRunActions !== null">\n <div style="font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--okdb-accent);">Dry run — intercepted writes ({{ modalDryRunActions.length }})</div>\n </if>\n <if :="!previewRun || modalDryRunActions === null">\n <div style="font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--okdb-app-fg-muted);">Draft execution result</div>\n </if>\n <if :="previewRun">\n <div style="font-size:11px; color:var(--okdb-app-fg-muted); font-family:monospace;">{{ previewRunId }}</div>\n </if>\n </div>\n <if :="!previewRun">\n <div style="font-size:12px; color:var(--okdb-app-fg-muted); line-height:1.5;">Run the draft to see the latest result before you save.</div>\n </if>\n <if :="previewRun && modalDryRunActions !== null">\n <div style="font-size:12px; color:var(--okdb-app-fg-muted); line-height:1.5;">Status: <strong>{{ previewRun.status || (previewRun.error ? \'error\' : \'ok\') }}</strong></div>\n <if :="modalDryRunActions.length === 0">\n <div style="font-size:12px; color:var(--okdb-app-fg-muted);">No writes intercepted.</div>\n </if>\n <div style="display:flex; flex-direction:column; gap:4px;">\n <each :of="modalDryRunActions" let:item="action">\n <div style="padding:5px 8px; border:1px solid color-mix(in srgb, var(--okdb-accent) 20%, transparent); border-radius:6px; background:color-mix(in srgb, var(--okdb-accent) 4%, transparent); font-family:monospace; font-size:11px; color:var(--okdb-app-fg-muted); line-height:1.45;">\n <span style="color:var(--okdb-accent);">{{ action.scope }}.{{ action.method }}</span>\n <if :="action.envName"><span style="opacity:.6;"> [{{ action.envName }}]</span></if>\n <if :="actionArgs(action)"><span> ({{ actionArgs(action) }})</span></if>\n </div>\n </each>\n </div>\n <if :="previewRun.result?.value !== undefined && previewRun.result?.value !== null">\n <div style="font-size:11px; text-transform:uppercase; color:var(--okdb-app-fg-muted); margin-top:4px;">Return value</div>\n <pre style="margin:0; white-space:pre-wrap; word-break:break-word; color:var(--okdb-app-fg-muted); font-size:11px; line-height:1.5;">{{ formatJson(previewRun.result.value) }}</pre>\n </if>\n </if>\n <if :="previewRun && modalDryRunActions === null">\n <div style="font-size:12px; color:var(--okdb-app-fg-muted); line-height:1.5;">Status: <strong>{{ previewRun.status || (previewRun.error ? \'error\' : \'ok\') }}</strong></div>\n <pre style="margin:0; white-space:pre-wrap; word-break:break-word; color:var(--okdb-app-fg-muted); font-size:11px; line-height:1.5;">{{ formatJson(previewRun.result?.value ?? previewRun.error ?? previewRun) }}</pre>\n </if>\n </div>\n\n <function-logs :run-id="previewRunId" :entries="previewLogs" title="Draft live log" empty="Run the draft to stream function logs here."></function-logs>\n </div>\n </div>\n\n <div style="display:flex; justify-content:flex-end; gap:10px; padding-top:4px;">\n <button @click="cancel()">Cancel</button>\n <button @click="submit()" :disabled="!canSave">{{ saveLabel }}</button>\n </div>\n</div>\n '};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{openLinkedPipelineRoute as e,resolveLinkedPipeline as n}from"../../engines/engine-ui-utils.js";export default{tag:"function-detail",attr:{onEdit:{}},context:i=>({linkedPipelineLookup:null,_linkedPipelineRequestId:0,get store(){return i.$ok.stores.functions},get fn(){return this.store.selected},get runs(){return this.store.runs||[]},get latestRun(){return this.store.latestRun},get activeRun(){return this.store.activeRun},get activeRunLogs(){return this.store.logsForRun(this.activeRun?.id||this.activeRun?.runId).slice(-5)},get selectedName(){return this.store.selectedName},get linkedPipelineRef(){if("queue"===this.linkedPipelineLookup?.targetSection)return null;const e=this.fn?.metadata??{},n=e.pipeline??this.linkedPipelineLookup?.pipelineName??null;return n?{envName:this.linkedPipelineLookup?.envName??this.store.envName??null,pipelineName:n,ownerEngine:e.owner_engine??this.linkedPipelineLookup?.ownerEngine??null,targetSection:this.linkedPipelineLookup?.targetSection??"db"}:null},get hasLinkedPipeline(){return!!this.linkedPipelineRef?.pipelineName},get linkedEngineRef(){if("queue"===this.linkedPipelineLookup?.targetSection)return null;const e=this.linkedPipelineRef;if(e?.pipelineName)return e;const n=this.fn?.metadata?.owner_engine??this.linkedPipelineLookup?.ownerEngine??null;return n?{envName:this.linkedPipelineLookup?.envName??this.store.envName??null,pipelineName:null,ownerEngine:n,sourceType:this.linkedPipelineLookup?.sourceType??null,targetSection:this.linkedPipelineLookup?.targetSection??"db"}:null},get linkedQueueRef(){const e=this.linkedPipelineLookup;return"queue"===e?.targetSection&&e?.jobType?{envName:e.envName??this.store.envName??null,pipelineName:e.pipelineName??this.fn?.metadata?.pipeline??null,ownerEngine:e.ownerEngine??this.fn?.metadata?.owner_engine??null,jobType:e.jobType,targetSection:"queue"}:null},get hasLinkedQueue(){return!!this.linkedQueueRef?.jobType},get hasLinkedEngine(){return!!this.linkedEngineRef?.ownerEngine},formatJson(e){try{return JSON.stringify(e,null,2)}catch{return String(e??"")}},async removeSelected(){if(!this.store.selectedName)return;const e=this.store.selectedName,n=this.store.envName,t=this.fn?.metadata,o=t?.owner_engine||t?.pipeline;let r=[];if(n)try{const i=await fetch(`${__ENV__.API}/env/${encodeURIComponent(n)}/engines`);if(i.ok){const n=await i.json();r=(n?.result??n??[]).filter(n=>n.config?.handler?.name===e).map(e=>e.name||e.key)}}catch{}let a=`Delete function "${e}"?`;if(o||r.length>0){const e=[...new Set([...o?[o]:[],...r])];a+=`\n\n⚠ This function is used by ${e.length} engine(s):\n • ${e.join("\n • ")}\n\nDeleting it will break ${1===e.length?"that pipeline":"those pipelines"}.`}const p=globalThis.confirm?.(a);if(p)try{await this.store.remove(e),i.$vars.$router?.push?.("/functions"),i.$ok.shared?.toast?.success?.("Function deleted")}catch(e){i.$ok.shared?.toast?.error?.(e?.message||"Failed to delete function")}},triggerEdit(){i.$attr.onEdit?.()},get linkedPipelineTitle(){const e=this.linkedPipelineRef;return e?.pipelineName?e.ownerEngine?`Open pipeline ${e.pipelineName} (engine ${e.ownerEngine})`:`Open pipeline ${e.pipelineName}`:"Open linked pipeline"},get linkedEngineTitle(){const e=this.linkedEngineRef;return e?.ownerEngine?e.sourceType?`Open engine ${e.ownerEngine} for type ${e.sourceType}`:`Open engine ${e.ownerEngine}`:"Open linked engine"},get linkedQueueTitle(){const e=this.linkedQueueRef;return e?.jobType?e.ownerEngine?`Open queue workers for ${e.jobType} (worker ${e.ownerEngine})`:`Open queue workers for ${e.jobType}`:"Open linked queue worker"},async refreshLinkedPipeline(){const e=this.fn?.name??this.selectedName??null,t=this.fn?.metadata??{};if(!this.store.envName||!e)return void(this.linkedPipelineLookup=null);const o=++this._linkedPipelineRequestId,r=await n(i,{envName:this.store.envName,pipelineName:t.pipeline??null,ownerEngine:t.owner_engine??null,functionName:e});o===this._linkedPipelineRequestId&&(this.linkedPipelineLookup=r)},async openLinkedPipeline(){const n=this.linkedQueueRef??this.linkedPipelineRef??this.linkedEngineRef;(n?.ownerEngine||n?.pipelineName||n?.jobType)&&(await e(i,{envName:n.envName??this.store.envName,pipelineName:n.pipelineName??null,ownerEngine:n.ownerEngine??null,functionName:this.fn?.name??this.selectedName??null})||i.$ok.shared?.toast?.info?.("Could not resolve the linked pipeline yet"))}}),async init(e){await this.refreshLinkedPipeline(),e.$watch(()=>[e.$ok.stores.functions.envName,e.$ok.stores.functions.selectedName,e.$ok.stores.functions.selected?.metadata?.pipeline,e.$ok.stores.functions.selected?.metadata?.owner_engine].join("||"),()=>this.refreshLinkedPipeline())},template:'\n <if :="!fn">\n <div style="padding:18px; border:1px dashed var(--okdb-app-border); border-radius:10px; color:var(--okdb-app-fg-muted); line-height:1.6;">\n Select a function from the sidebar to inspect or edit it.\n </div>\n </if>\n\n <if :="fn">\n <div style="display:flex; flex-direction:column; gap:12px; min-height:0;">\n <div style="padding:14px; border:1px solid var(--okdb-app-border); border-radius:10px; background:var(--okdb-app-bg-deep);">\n <div style="font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--okdb-app-fg-muted); margin-bottom:10px;">Function overview</div>\n <div style="display:flex; align-items:center; justify-content:space-between; gap:12px;">\n <div>\n <div style="font-size:18px; font-weight:700; color:var(--okdb-app-fg);">{{ fn.name }}</div>\n <div style="margin-top:4px; font-size:12px; color:var(--okdb-app-fg-muted);">\n {{ fn.scope === \'global\' ? \'Global function\' : \'Environment function\' }} · version {{ fn.version }}\n </div>\n </div>\n <div :style="fn.enabled === false ? \'font-size:11px; color:var(--okdb-danger);\' : \'font-size:11px; color:var(--okdb-success);\'">\n {{ fn.enabled === false ? \'Disabled\' : \'Enabled\' }}\n </div>\n </div>\n\n <div style="display:flex; justify-content:flex-end; gap:8px; margin-top:12px;">\n <button style="padding:6px 10px; font-size:12px;" @click="triggerEdit()">Edit</button>\n <button style="padding:6px 10px; font-size:12px; border-color:#5c2a34; color:#fda4af;" @click="removeSelected()">Delete</button>\n </div>\n\n <if :="fn.metadata?.description">\n <div style="margin-top:10px; color:#9bb2c3; font-size:13px; line-height:1.5;">\n {{ fn.metadata.description }}\n </div>\n </if>\n </div>\n\n <div style="display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:12px;">\n <div style="padding:12px; border:1px solid var(--okdb-app-border); border-radius:10px; background:var(--okdb-app-bg-deep);">\n <div style="font-size:11px; text-transform:uppercase; color:var(--okdb-app-fg-muted); margin-bottom:8px;">Runtime</div>\n <div style="display:flex; flex-direction:column; gap:6px; font-size:12px; color:var(--okdb-app-fg-muted);">\n <div>timeoutMs: <strong>{{ fn.runtime?.timeoutMs ?? \'—\' }}</strong></div>\n <div>memoryMb: <strong>{{ fn.runtime?.memoryMb ?? \'—\' }}</strong></div>\n <div>allowFetch: <strong>{{ fn.runtime?.allowFetch === false ? \'false\' : \'true\' }}</strong></div>\n </div>\n </div>\n <div style="padding:12px; border:1px solid var(--okdb-app-border); border-radius:10px; background:var(--okdb-app-bg-deep);">\n <div style="font-size:11px; text-transform:uppercase; color:var(--okdb-app-fg-muted); margin-bottom:8px;">Metadata</div>\n <div style="display:flex; flex-direction:column; gap:6px; font-size:12px; color:var(--okdb-app-fg-muted);">\n <div>createdAt: <strong>{{ fn.metadata?.createdAt ?? \'—\' }}</strong></div>\n <div>updatedAt: <strong>{{ fn.metadata?.updatedAt ?? \'—\' }}</strong></div>\n <div>hash: <strong style="font-family:monospace; font-size:11px;">{{ fn.hash ?? \'—\' }}</strong></div>\n <if :="hasLinkedQueue">\n <button\n @click="openLinkedPipeline()"\n :title="linkedQueueTitle"\n style="margin-top:4px; padding:4px 8px; border:1px solid color-mix(in srgb, var(--okdb-accent) 20%, transparent); border-radius:6px; background:color-mix(in srgb, var(--okdb-accent) 5%, transparent); color:var(--okdb-accent); font-size:11px; text-align:left; cursor:pointer; display:inline-flex; align-items:center; gap:4px; width:fit-content;"\n >\n <span>⇶ Queue:</span>\n <strong>{{ linkedQueueRef.jobType }}</strong>\n <if :="linkedQueueRef?.ownerEngine">\n <span>· Worker:</span>\n <strong>{{ linkedQueueRef.ownerEngine }}</strong>\n </if>\n <span>↗</span>\n </button>\n </if>\n <if :="hasLinkedPipeline">\n <button\n @click="openLinkedPipeline()"\n :title="linkedPipelineTitle"\n style="margin-top:4px; padding:4px 8px; border:1px solid color-mix(in srgb, var(--okdb-accent) 20%, transparent); border-radius:6px; background:color-mix(in srgb, var(--okdb-accent) 5%, transparent); color:var(--okdb-accent); font-size:11px; text-align:left; cursor:pointer; display:inline-flex; align-items:center; gap:4px; width:fit-content;"\n >\n <span>⚡ Pipeline:</span>\n <strong>{{ linkedPipelineRef.pipelineName }}</strong>\n <if :="linkedPipelineRef?.ownerEngine">\n <span>· Engine:</span>\n <strong>{{ linkedPipelineRef.ownerEngine }}</strong>\n </if>\n <span>↗</span>\n </button>\n </if>\n <if :="!hasLinkedQueue && !hasLinkedPipeline && hasLinkedEngine">\n <button\n @click="openLinkedPipeline()"\n :title="linkedEngineTitle"\n style="margin-top:4px; padding:4px 8px; border:1px solid color-mix(in srgb, var(--okdb-accent) 20%, transparent); border-radius:6px; background:color-mix(in srgb, var(--okdb-accent) 5%, transparent); color:var(--okdb-accent); font-size:11px; text-align:left; cursor:pointer; display:inline-flex; align-items:center; gap:4px; width:fit-content;"\n >\n <span>⚙ Engine:</span>\n <strong>{{ linkedEngineRef.ownerEngine }}</strong>\n <span>↗</span>\n </button>\n </if>\n </div>\n </div>\n </div>\n\n <div style="display:grid; grid-template-columns:minmax(0,1.2fr) minmax(280px,.8fr); gap:12px;">\n <div style="padding:12px; border:1px solid var(--okdb-app-border); border-radius:10px; background:var(--okdb-app-bg-deep); min-height:0; overflow:auto;">\n <div style="font-size:11px; text-transform:uppercase; color:var(--okdb-app-fg-muted); margin-bottom:8px;">Implementation</div>\n <pre style="margin:0; white-space:pre-wrap; word-break:break-word; color:var(--okdb-app-fg-muted); font-size:12px; line-height:1.55;">{{ fn.script?.source || \'—\' }}</pre>\n </div>\n <div style="padding:12px; border:1px solid var(--okdb-app-border); border-radius:10px; background:var(--okdb-app-bg-deep); min-height:0; overflow:auto; display:flex; flex-direction:column; gap:10px;">\n <div style="font-size:11px; text-transform:uppercase; color:var(--okdb-app-fg-muted);">Runs</div>\n <div style="font-size:12px; color:var(--okdb-app-fg-muted);">Total persisted runs: <strong>{{ runs.length }}</strong></div>\n <if :="!activeRun">\n <div style="font-size:12px; color:var(--okdb-app-fg-muted); line-height:1.5;">No runs recorded for this function yet.</div>\n </if>\n <if :="activeRun">\n <div style="font-size:12px; color:var(--okdb-app-fg-muted); line-height:1.55;">\n Selected run id: <strong style="font-family:monospace; font-size:11px;">{{ activeRun.id || activeRun.runId || \'—\' }}</strong>\n </div>\n <div style="font-size:12px; color:var(--okdb-app-fg-muted); line-height:1.55;">\n Status: <strong>{{ activeRun.status || (activeRun.error ? \'error\' : \'ok\') }}</strong>\n </div>\n <pre style="margin:0; white-space:pre-wrap; word-break:break-word; color:var(--okdb-app-fg-muted); font-size:11px; line-height:1.5; max-height:180px; overflow:auto;">{{ formatJson(activeRun.result ?? activeRun.error ?? activeRun) }}</pre>\n <if :="activeRunLogs.length > 0">\n <div style="font-size:11px; text-transform:uppercase; color:var(--okdb-app-fg-muted);">Selected run log</div>\n <div style="display:flex; flex-direction:column; gap:6px;">\n <each :of="activeRunLogs" let:item="entry">\n <div style="padding:6px 8px; border:1px solid var(--okdb-app-border); border-radius:8px; background:var(--okdb-app-bg-deep); color:var(--okdb-app-fg-muted); font-size:11px; line-height:1.45;">{{ entry.msg }}</div>\n </each>\n </div>\n </if>\n </if>\n </div>\n </div>\n </div>\n </if>\n '};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"../../../stores/events-store.js";export default{tag:"function-logs",attr:{runId:{},entries:{},title:{default:"Live log"},empty:{default:"No logs for this execution yet."}},context:t=>({get titleText(){const e=t.$attr.title;return"string"==typeof e&&e.trim()&&"undefined"!==e.trim().toLowerCase()?e:"Live log"},get emptyText(){const e=t.$attr.empty;return"string"==typeof e&&e.trim()&&"undefined"!==e.trim().toLowerCase()?e:"No logs for this execution yet."},get entries(){if(Array.isArray(t.$attr.entries))return t.$attr.entries;const r=t.$attr.runId;return r?(e.logs||[]).filter(e=>(e?.runId||e?.meta?.runId)===r):[]},fmtTime(e){if(!e)return"";const t=new Date(e);return t.toTimeString().slice(0,8)+"."+String(t.getMilliseconds()).padStart(3,"0")},fmtMeta(e){if(null==e)return"";if("object"==typeof e&&!Array.isArray(e)){const t=Object.fromEntries(Object.entries(e).filter(([e,t])=>void 0!==t&&"undefined"!==t&&null!=t&&("title"!==e&&"content"!==e||"undefined"!==String(t).toLowerCase())));if(0===Object.keys(t).length)return"";try{return JSON.stringify(t,null,2)}catch{}}try{return"string"==typeof e?e:JSON.stringify(e)}catch{return String(e)}},fmtMsg(e){const t=e?.msg??e?.message??e?.content??e?.title??"";if(null==t)return"";if("string"==typeof t){const e=t.trim();return e&&"undefined"!==e.toLowerCase()?e:""}try{return JSON.stringify(t,null,2)}catch{return String(t)}}}),template:'\n <div style="display:flex; flex-direction:column; min-height:0; height:100%; border:1px solid var(--okdb-app-border); border-radius:10px; background:var(--okdb-app-bg-deep); overflow:hidden;">\n <div style="padding:10px 12px; border-bottom:1px solid var(--okdb-app-border); font-size:11px; text-transform:uppercase; color:var(--okdb-app-fg-muted); letter-spacing:.08em;">{{ titleText }}</div>\n <div style="display:flex; flex-direction:column; gap:8px; padding:12px; min-height:0; overflow:auto;">\n <if :="entries.length === 0">\n <div style="font-size:12px; color:var(--okdb-app-fg-muted); line-height:1.5;">{{ emptyText }}</div>\n </if>\n <each :of="entries" let:item="entry">\n <div style="padding:8px 10px; border:1px solid var(--okdb-app-border); border-radius:8px; background:var(--okdb-app-bg-deep);">\n <div style="display:flex; align-items:center; gap:8px; font-size:11px; color:var(--okdb-app-fg-muted); margin-bottom:6px;">\n <span>{{ fmtTime(entry.ts || entry._ts) }}</span>\n <span :style="entry.level === \'error\' ? \'color:var(--okdb-danger);\' : entry.level === \'warn\' ? \'color:#f5b481;\' : \'color:var(--okdb-success);\'">{{ entry.level || \'info\' }}</span>\n </div>\n <if :="fmtMsg(entry)">\n <div style="font-size:12px; color:#d4e8f4; line-height:1.5;">{{ fmtMsg(entry) }}</div>\n </if>\n <if :="entry.context != null && fmtMeta(entry.context)">\n <pre style="margin:8px 0 0; white-space:pre-wrap; word-break:break-word; font-size:11px; color:var(--okdb-app-fg-muted); font-family:monospace;">{{ fmtMeta(entry.context) }}</pre>\n </if>\n </div>\n </each>\n </div>\n </div>\n '};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import e from"../../../components/ok-text-monaco-input.ok.js";export default{tag:"function-runner",dependencies:[e],context:e=>({get store(){return e.$ok.stores.functions},get payloadDraft(){return this.store.payloadDraft},get selectedRun(){return this.store.activeRun},get runs(){return(this.store.runs||[]).map(e=>e?.value||e)},get running(){return this.store.running},get payloadError(){return this.store.payloadError},get dryRunMode(){return this.store.dryRunMode},get dryRunActions(){return this.selectedRun?.result?.dryRunActions??null},toggleDryRun(){this.store.dryRunMode=!this.store.dryRunMode},runTime(e){const n=e?.execution?.finishedAt??e?.request?.requestedAt??null;return n?new Date(n).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):"—"},isSelected(e){const n=this.selectedRun;return!(!n||!e)&&(n.id||n.runId)===(e.id||e.runId)},setPayload(e){this.store.setPayloadDraft(e??"{\n \n}")},async pickRun(n){if(n)try{await this.store.selectRun(n.id||n.runId)}catch(n){e.$ok.shared?.toast?.error?.(n?.message||"Failed to load run")}},formatJson(e){try{return JSON.stringify(e,null,2)}catch{return String(e??"")}},actionArgs(e){const n=e.args??[];return 0===n.length?"":n.map(e=>JSON.stringify(e)).join(", ")},async runNow(){try{await this.store.runSelected(),e.$ok.shared?.toast?.success?.(this.dryRunMode?"Dry run complete":"Function executed")}catch(n){e.$ok.shared?.toast?.error?.(n?.message||"Function execution failed")}},async refresh(){try{await this.store.refreshSelected(),e.$ok.shared?.toast?.success?.("Function refreshed")}catch(n){e.$ok.shared?.toast?.error?.(n?.message||"Failed to refresh function")}}}),template:'\n <div style="display:flex; flex-direction:column; gap:12px; min-height:0; height:100%;">\n <div style="display:flex; align-items:center; justify-content:space-between; gap:8px;">\n <div style="display:flex; flex-direction:column; gap:4px;">\n <div style="font-size:11px; text-transform:uppercase; color:var(--okdb-app-fg-muted);">Run selected function</div>\n <div style="font-size:12px; color:var(--okdb-app-fg-muted);">Only affects the currently selected function.</div>\n </div>\n <div style="display:flex; gap:8px;">\n <button @click="refresh()" :disabled="!store.selectedName || running" style="padding:6px 10px; font-size:12px;">Refresh</button>\n <button\n @click="toggleDryRun()"\n :disabled="running"\n :style="dryRunMode\n ? \'padding:6px 10px; font-size:12px; border-color:var(--okdb-accent); color:var(--okdb-accent);\'\n : \'padding:6px 10px; font-size:12px;\'">\n Dry Run{{ dryRunMode ? \' ✓\' : \'\' }}\n </button>\n <button @click="runNow()" :disabled="!store.selectedName || running" style="padding:6px 10px; font-size:12px;">\n {{ running ? \'Running…\' : (dryRunMode ? \'Run (dry)\' : \'Run\') }}\n </button>\n </div>\n </div>\n\n <div style="height:220px; min-height:220px; border:1px solid var(--okdb-app-border); border-radius:10px; overflow:hidden; background:var(--okdb-app-bg-deep);">\n <ok-text-monaco-input\n style="height:100%;"\n language="json"\n :value="payloadDraft"\n @edit:debounce.150="setPayload($event.detail)"\n ></ok-text-monaco-input>\n </div>\n\n <if :="payloadError">\n <div style="font-size:12px; color:var(--okdb-danger); line-height:1.5;">{{ payloadError }}</div>\n </if>\n\n <div style="padding:12px; border:1px solid var(--okdb-app-border); border-radius:10px; background:var(--okdb-app-bg-deep); min-height:0; overflow:auto;">\n <div style="font-size:11px; text-transform:uppercase; color:var(--okdb-app-fg-muted); margin-bottom:8px;">Recent runs for this function</div>\n <if :="runs.length === 0">\n <div style="font-size:12px; color:var(--okdb-app-fg-muted);">No runs yet.</div>\n </if>\n <div style="display:flex; flex-direction:column; gap:6px;">\n <each :of="runs.slice(0, 8)" let:item="run" let:index="idx">\n <button\n @click="pickRun(run)"\n :style="isSelected(run)\n ? \'text-align:left; padding:8px 10px; border:1px solid color-mix(in srgb, var(--okdb-accent) 53%, transparent); box-shadow:0 0 0 1px color-mix(in srgb, var(--okdb-accent) 13%, transparent) inset, 0 0 18px color-mix(in srgb, var(--okdb-accent) 9%, transparent); background:var(--okdb-app-bg); color:var(--okdb-app-fg-strong); border-radius:8px;\'\n : \'text-align:left; padding:8px 10px; border:1px solid var(--okdb-app-border); background:var(--okdb-app-bg-deep); color:var(--okdb-app-fg-muted); border-radius:8px;\'">\n <div style="display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:12px;">\n <strong style="font-family:monospace; font-size:11px;">{{ run.id || run.runId || \'run\' }}</strong>\n <div style="display:flex; align-items:center; gap:8px;">\n <if :="idx === 0"><span style="font-size:10px; padding:2px 6px; border-radius:999px; border:1px solid color-mix(in srgb, var(--okdb-accent) 27%, transparent); color:var(--okdb-accent);">Latest</span></if>\n <span>{{ run.status || (run.error ? \'error\' : \'ok\') }}</span>\n </div>\n </div>\n <div style="display:flex; align-items:center; justify-content:space-between; gap:8px; margin-top:6px; font-size:11px; color:var(--okdb-app-fg-muted);">\n <span>{{ runTime(run) }}</span>\n <span>{{ run.execution?.durationMs != null ? run.execution.durationMs + \'ms\' : \'—\' }}</span>\n </div>\n </button>\n </each>\n </div>\n </div>\n\n <div style="padding:12px; border:1px solid var(--okdb-app-border); border-radius:10px; background:var(--okdb-app-bg-deep); min-height:0; overflow:auto;">\n <if :="!selectedRun">\n <div style="font-size:11px; text-transform:uppercase; color:var(--okdb-app-fg-muted); margin-bottom:8px;">Selected run result</div>\n <div style="font-size:12px; color:var(--okdb-app-fg-muted);">No run selected yet.</div>\n </if>\n <if :="selectedRun && dryRunActions !== null">\n <div style="font-size:11px; text-transform:uppercase; color:var(--okdb-accent); margin-bottom:8px;">\n Dry run — intercepted writes ({{ dryRunActions.length }})\n </div>\n <if :="dryRunActions.length === 0">\n <div style="font-size:12px; color:var(--okdb-app-fg-muted); margin-bottom:8px;">No writes intercepted.</div>\n </if>\n <div style="display:flex; flex-direction:column; gap:4px; margin-bottom:10px;">\n <each :of="dryRunActions" let:item="action" let:index="i">\n <div style="padding:6px 8px; border:1px solid color-mix(in srgb, var(--okdb-accent) 20%, transparent); border-radius:6px; background:color-mix(in srgb, var(--okdb-accent) 4%, transparent); font-family:monospace; font-size:11px; color:var(--okdb-app-fg-muted); line-height:1.45;">\n <span style="color:var(--okdb-accent);">{{ action.scope }}.{{ action.method }}</span>\n <if :="action.envName">\n <span style="opacity:.6;"> [{{ action.envName }}]</span>\n </if>\n <if :="actionArgs(action)">\n <span> ({{ actionArgs(action) }})</span>\n </if>\n </div>\n </each>\n </div>\n <if :="selectedRun.result?.value !== undefined && selectedRun.result?.value !== null">\n <div style="font-size:11px; text-transform:uppercase; color:var(--okdb-app-fg-muted); margin-bottom:6px;">Return value</div>\n <pre style="margin:0; white-space:pre-wrap; word-break:break-word; color:var(--okdb-app-fg-muted); font-size:12px; line-height:1.55;">{{ formatJson(selectedRun.result.value) }}</pre>\n </if>\n </if>\n <if :="selectedRun && dryRunActions === null">\n <div style="font-size:11px; text-transform:uppercase; color:var(--okdb-app-fg-muted); margin-bottom:8px;">Selected run result</div>\n <pre style="margin:0; white-space:pre-wrap; word-break:break-word; color:var(--okdb-app-fg-muted); font-size:12px; line-height:1.55;">{{ formatJson(selectedRun) }}</pre>\n </if>\n </div>\n </div>\n '};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<script type="module">import e from"./parts/license-panel.ok.js";export default{tag:"license-index",unwrap:!0,dependencies:[e]};</script><template><component import="../../layouts/_default.ok.html"><template name="header"></template><template name="default"><license-panel/></template></component></template>
|