@kedem/okdb 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/LICENSE +57 -0
  2. package/README.md +344 -0
  3. package/banner.jpg +0 -0
  4. package/bin/okdb.js +2 -0
  5. package/docs/OKDB-ARCHITECTURE.md +1036 -0
  6. package/docs/auth-and-sync.md +558 -0
  7. package/docs/auth-permissions.md +143 -0
  8. package/docs/change-log.md +169 -0
  9. package/docs/data-model.md +174 -0
  10. package/docs/embeddings.md +338 -0
  11. package/docs/files.md +131 -0
  12. package/docs/fts.md +139 -0
  13. package/docs/functions.md +514 -0
  14. package/docs/getting-started.md +233 -0
  15. package/docs/http-api.md +705 -0
  16. package/docs/index.md +115 -0
  17. package/docs/indexes.md +207 -0
  18. package/docs/logging.md +116 -0
  19. package/docs/manifest.json +38 -0
  20. package/docs/migration.md +154 -0
  21. package/docs/pipelines.md +598 -0
  22. package/docs/plugins.md +144 -0
  23. package/docs/querying.md +204 -0
  24. package/docs/queue.md +637 -0
  25. package/docs/sync.md +156 -0
  26. package/docs/transactions.md +140 -0
  27. package/docs/ttl.md +375 -0
  28. package/okdb.js +1 -0
  29. package/package.json +26 -0
  30. package/public/admin-app.js +1 -0
  31. package/public/android-chrome-192x192.png +0 -0
  32. package/public/android-chrome-512x512.png +0 -0
  33. package/public/apple-touch-icon.png +0 -0
  34. package/public/components/admin-route-host.ok.js +1 -0
  35. package/public/components/env-picker.ok.js +1 -0
  36. package/public/components/field-path-input.ok.js +1 -0
  37. package/public/components/field.html +6 -0
  38. package/public/components/geo-map.ok.js +1 -0
  39. package/public/components/ok-cron-input.ok.js +1 -0
  40. package/public/components/ok-dropzone.ok.js +1 -0
  41. package/public/components/ok-js-input.ok.js +1 -0
  42. package/public/components/ok-json-input.ok.js +1 -0
  43. package/public/components/ok-text-monaco-input.ok.js +1 -0
  44. package/public/components/theme-toggle.ok.js +1 -0
  45. package/public/favicon-16x16.png +0 -0
  46. package/public/favicon-32x32.png +0 -0
  47. package/public/favicon.ico +0 -0
  48. package/public/images/logo.png +0 -0
  49. package/public/images/logo.svg +333 -0
  50. package/public/index.html +6 -0
  51. package/public/layouts/_default.ok.html +1 -0
  52. package/public/layouts/okdb-cube.ok.html +1 -0
  53. package/public/login-app.js +1 -0
  54. package/public/login.html +1 -0
  55. package/public/modules/ok.js +1 -0
  56. package/public/sections/api/index.ok.html +1 -0
  57. package/public/sections/api/parts/api-endpoint.ok.js +1 -0
  58. package/public/sections/auth/index.ok.html +1 -0
  59. package/public/sections/auth/modals/create-token-modal.ok.js +1 -0
  60. package/public/sections/auth/modals/edit-token-modal.ok.js +1 -0
  61. package/public/sections/auth/modals/perm-info-popover.ok.js +1 -0
  62. package/public/sections/auth/parts/token-detail.ok.js +1 -0
  63. package/public/sections/auth/parts/token-list.ok.js +1 -0
  64. package/public/sections/db/index.ok.html +1 -0
  65. package/public/sections/db/modals/add-item-modal.ok.js +1 -0
  66. package/public/sections/db/modals/create-env-modal.ok.js +1 -0
  67. package/public/sections/db/modals/create-fts-modal.ok.js +1 -0
  68. package/public/sections/db/modals/create-index-modal.ok.js +1 -0
  69. package/public/sections/db/modals/create-pipeline-modal.ok.js +1 -0
  70. package/public/sections/db/modals/demo-env-modal.ok.js +1 -0
  71. package/public/sections/db/modals/remove-env-modal.ok.js +1 -0
  72. package/public/sections/db/modals/schema-edit-modal.ok.js +1 -0
  73. package/public/sections/db/parts/db-overview.ok.js +1 -0
  74. package/public/sections/db/parts/db-pipelines-panel.ok.js +1 -0
  75. package/public/sections/db/parts/edit-row.ok.js +1 -0
  76. package/public/sections/db/parts/tm-timeline.ok.js +1 -0
  77. package/public/sections/db/parts/type-changelog.ok.js +1 -0
  78. package/public/sections/db/parts/type-list.ok.js +1 -0
  79. package/public/sections/db/parts/type-pipelines-tab.ok.js +1 -0
  80. package/public/sections/db/parts/type-schema-tab.ok.js +1 -0
  81. package/public/sections/db/parts/type-viewer.ok.js +1 -0
  82. package/public/sections/db/parts/type-violations-tab.ok.js +1 -0
  83. package/public/sections/docs/index.ok.html +1 -0
  84. package/public/sections/embeddings/index.ok.html +1 -0
  85. package/public/sections/embeddings/modals/register-model-modal.ok.js +1 -0
  86. package/public/sections/embeddings/parts/embed-create-panel.ok.js +1 -0
  87. package/public/sections/embeddings/parts/embed-embedder-panel.ok.js +1 -0
  88. package/public/sections/embeddings/parts/embed-engine-declaration-editor.ok.js +1 -0
  89. package/public/sections/embeddings/parts/embed-engine-list.ok.js +1 -0
  90. package/public/sections/embeddings/parts/embed-indexer-panel.ok.js +1 -0
  91. package/public/sections/embeddings/parts/embed-lifecycle-bar.ok.js +1 -0
  92. package/public/sections/embeddings/parts/embed-model-catalog.ok.js +1 -0
  93. package/public/sections/embeddings/parts/embed-overview.ok.js +1 -0
  94. package/public/sections/embeddings/parts/embed-search-panel.ok.js +1 -0
  95. package/public/sections/embeddings/parts/embed-worker-panel.ok.js +1 -0
  96. package/public/sections/embeddings/parts/embeddings-engine-panel.ok.js +1 -0
  97. package/public/sections/embeddings/parts/engines-overview.ok.js +1 -0
  98. package/public/sections/embeddings/parts/pipeline-create-panel.ok.js +1 -0
  99. package/public/sections/engines/engine-panel-shared-style.js +1 -0
  100. package/public/sections/engines/engine-ui-utils.js +1 -0
  101. package/public/sections/engines/index.ok.html +1 -0
  102. package/public/sections/engines/modals/engine-modal.ok.js +1 -0
  103. package/public/sections/engines/parts/engine-declaration-editor.ok.js +1 -0
  104. package/public/sections/engines/parts/engine-lifecycle-actions.ok.js +1 -0
  105. package/public/sections/engines/parts/engine-panel-shell.ok.js +1 -0
  106. package/public/sections/engines/parts/engine-resource-card.ok.js +1 -0
  107. package/public/sections/engines/parts/engine-row-item.ok.js +1 -0
  108. package/public/sections/engines/parts/generic-engine-panel.ok.js +1 -0
  109. package/public/sections/files/index.ok.html +1 -0
  110. package/public/sections/files/parts/files-blob-status.ok.js +1 -0
  111. package/public/sections/files/parts/files-collection-list.ok.js +1 -0
  112. package/public/sections/files/parts/files-collection-panel.ok.js +1 -0
  113. package/public/sections/files/parts/files-file-list.ok.js +1 -0
  114. package/public/sections/files/parts/files-overview.ok.js +1 -0
  115. package/public/sections/files/parts/files-path-browser.ok.js +1 -0
  116. package/public/sections/files/parts/files-upload-panel.ok.js +1 -0
  117. package/public/sections/functions/index.ok.html +1 -0
  118. package/public/sections/functions/modals/function-modal.ok.js +1 -0
  119. package/public/sections/functions/parts/function-detail.ok.js +1 -0
  120. package/public/sections/functions/parts/function-logs.ok.js +1 -0
  121. package/public/sections/functions/parts/function-runner.ok.js +1 -0
  122. package/public/sections/functions/parts/functions-list.ok.js +1 -0
  123. package/public/sections/license/index.ok.html +1 -0
  124. package/public/sections/license/parts/license-panel.ok.js +1 -0
  125. package/public/sections/processors/index.ok.html +1 -0
  126. package/public/sections/queue/index.ok.html +1 -0
  127. package/public/sections/queue/modals/create-bucket-modal.ok.js +1 -0
  128. package/public/sections/queue/modals/edit-bucket-modal.ok.js +1 -0
  129. package/public/sections/queue/modals/edit-job-modal.ok.js +1 -0
  130. package/public/sections/queue/modals/enqueue-job-modal.ok.js +1 -0
  131. package/public/sections/queue/modals/job-type-modal.ok.js +1 -0
  132. package/public/sections/queue/parts/ok-job-form.ok.js +1 -0
  133. package/public/sections/queue/parts/queue-buckets.ok.js +1 -0
  134. package/public/sections/queue/parts/queue-job-types.ok.js +1 -0
  135. package/public/sections/queue/parts/queue-jobs.ok.js +1 -0
  136. package/public/sections/queue/parts/queue-types.ok.js +1 -0
  137. package/public/sections/queue/parts/queue-workers.ok.js +1 -0
  138. package/public/sections/sync/index.ok.html +5 -0
  139. package/public/sections/sync/parts/sync-node-detail.ok.js +1 -0
  140. package/public/sections/sync/parts/sync-retention.ok.js +1 -0
  141. package/public/sections/sync/parts/sync-topology.ok.js +1 -0
  142. package/public/sections/system/index.ok.html +1 -0
  143. package/public/sections/system/modals/data-ops-modal.ok.js +1 -0
  144. package/public/sections/system/parts/system-api-panel.ok.js +1 -0
  145. package/public/sections/system/parts/system-auth-panel.ok.js +1 -0
  146. package/public/sections/system/parts/system-log-history.ok.js +1 -0
  147. package/public/sections/system/parts/system-log.ok.js +1 -0
  148. package/public/sections/system/parts/system-status.ok.js +1 -0
  149. package/public/sections/system/parts/system-sync-panel.ok.js +1 -0
  150. package/public/sections/views/index.ok.html +1 -0
  151. package/public/sections/views/modals/create-view-modal.ok.js +1 -0
  152. package/public/sections/views/parts/view-detail.ok.js +1 -0
  153. package/public/sections/views/parts/views-list.ok.js +1 -0
  154. package/public/sections/views/parts/views-overview.ok.js +1 -0
  155. package/public/setup-app.js +1 -0
  156. package/public/setup.html +1 -0
  157. package/public/site.webmanifest +1 -0
  158. package/public/stores/auth-store.js +1 -0
  159. package/public/stores/events-store.js +1 -0
  160. package/public/stores/functions-store.js +1 -0
  161. package/public/stores/okdb-store.js +1 -0
  162. package/public/stores/theme-store.js +1 -0
  163. package/public/styles.css +1 -0
  164. package/public/test-cron-input.html +10 -0
  165. package/public/test-json-input.html +101 -0
  166. package/public/util/permissions.js +1 -0
  167. package/public/util/sift-schema.js +1 -0
  168. package/public/vendor/okjs/ok.esm.min.js +2 -0
  169. package/public/vendor/okjs/toolkit/behavior/async.ok.js +1 -0
  170. package/public/vendor/okjs/toolkit/components/ok-chart.ok.js +1 -0
  171. package/public/vendor/okjs/toolkit/components/ok-doc-viewer.ok.js +1 -0
  172. package/public/vendor/okjs/toolkit/components/ok-marked.ok.js +1 -0
  173. package/public/vendor/okjs/toolkit/components/ok-monaco.ok.js +1 -0
  174. package/public/vendor/okjs/toolkit/core/ok-layer-service.ok.js +1 -0
  175. package/public/vendor/okjs/toolkit/core/ok-layer.ok.js +1 -0
  176. package/public/vendor/okjs/toolkit/core/ok-overlay.ok.js +1 -0
  177. package/public/vendor/okjs/toolkit/core/ok-sandbox.ok.js +1 -0
  178. package/public/vendor/okjs/toolkit/core/transition.ok.js +1 -0
  179. package/public/vendor/okjs/toolkit/core/virtualized.ok.js +1 -0
  180. package/public/vendor/okjs/toolkit/devtools/ok-console-service.ok.js +1 -0
  181. package/public/vendor/okjs/toolkit/devtools/ok-console.ok.js +1 -0
  182. package/public/vendor/okjs/toolkit/devtools/ok-fps-monitor-service.ok.js +1 -0
  183. package/public/vendor/okjs/toolkit/devtools/ok-fps-monitor.ok.js +1 -0
  184. package/public/vendor/okjs/toolkit/devtools/ok-inspector-service.ok.js +1 -0
  185. package/public/vendor/okjs/toolkit/devtools/ok-inspector.ok.js +1 -0
  186. package/public/vendor/okjs/toolkit/devtools/ok-js-tree.ok.js +1 -0
  187. package/public/vendor/okjs/toolkit/devtools/ok-timeline-service.ok.js +1 -0
  188. package/public/vendor/okjs/toolkit/devtools/ok-timeline.ok.js +1 -0
  189. package/public/vendor/okjs/toolkit/docs/doc-viewer.ok.js +1 -0
  190. package/public/vendor/okjs/toolkit/editor/ok-live-component.ok.js +1 -0
  191. package/public/vendor/okjs/toolkit/editor/ok-live-example.ok.js +1 -0
  192. package/public/vendor/okjs/toolkit/editor/ok-live-shell.ok.js +1 -0
  193. package/public/vendor/okjs/toolkit/elements/ok-dropdown.ok.js +1 -0
  194. package/public/vendor/okjs/toolkit/elements/ok-icon.ok.js +1 -0
  195. package/public/vendor/okjs/toolkit/elements/ok-select.ok.js +1 -0
  196. package/public/vendor/okjs/toolkit/elements/ok-table.ok.js +1 -0
  197. package/public/vendor/okjs/toolkit/errors/ok-crash-boundary.ok.js +1 -0
  198. package/public/vendor/okjs/toolkit/errors/ok-crash-info.ok.js +1 -0
  199. package/public/vendor/okjs/toolkit/i18n/i18n-editor-examples.ok.js +1 -0
  200. package/public/vendor/okjs/toolkit/i18n/i18n-editor.ok.js +1 -0
  201. package/public/vendor/okjs/toolkit/i18n/i18n-key-editor-tips.ok.js +1 -0
  202. package/public/vendor/okjs/toolkit/i18n/i18n-key-editor.ok.js +1 -0
  203. package/public/vendor/okjs/toolkit/i18n/i18n-service.ok.js +1 -0
  204. package/public/vendor/okjs/toolkit/i18n/ok-i18n.js +1 -0
  205. package/public/vendor/okjs/toolkit/interaction/ok-contextmenu.ok.js +1 -0
  206. package/public/vendor/okjs/toolkit/interaction/ok-dismiss-service.ok.js +1 -0
  207. package/public/vendor/okjs/toolkit/interaction/ok-draggable.ok.js +1 -0
  208. package/public/vendor/okjs/toolkit/interaction/ok-flyover-panel.ok.js +1 -0
  209. package/public/vendor/okjs/toolkit/interaction/ok-flyover.ok.js +1 -0
  210. package/public/vendor/okjs/toolkit/interaction/ok-highlight-service.ok.js +1 -0
  211. package/public/vendor/okjs/toolkit/interaction/ok-highlight.ok.js +1 -0
  212. package/public/vendor/okjs/toolkit/interaction/ok-hotkeys-service.ok.js +1 -0
  213. package/public/vendor/okjs/toolkit/interaction/ok-picker-service.ok.js +1 -0
  214. package/public/vendor/okjs/toolkit/interaction/ok-popout-service.ok.js +1 -0
  215. package/public/vendor/okjs/toolkit/interaction/ok-popout.ok.js +1 -0
  216. package/public/vendor/okjs/toolkit/interaction/ok-portal-service.ok.js +1 -0
  217. package/public/vendor/okjs/toolkit/interaction/ok-submenu.ok.js +1 -0
  218. package/public/vendor/okjs/toolkit/layout/ok-resizer.ok.js +1 -0
  219. package/public/vendor/okjs/toolkit/manifest.js +1 -0
  220. package/public/vendor/okjs/toolkit/modals/ok-modal-service.ok.js +1 -0
  221. package/public/vendor/okjs/toolkit/modals/ok-modal.ok.js +1 -0
  222. package/public/vendor/okjs/toolkit/modals/ok-toast-service.ok.js +1 -0
  223. package/public/vendor/okjs/toolkit/modals/ok-window.ok.js +1 -0
  224. package/public/vendor/okjs/toolkit/navigation/hash-router.ok.js +1 -0
  225. package/public/vendor/okjs/toolkit/navigation/history-router.ok.js +1 -0
  226. package/public/vendor/okjs/toolkit/navigation/router.ok.js +1 -0
  227. package/public/vendor/okjs/toolkit/sync/reactive-sync-service.ok.js +1 -0
  228. package/public/vendor/okjs/toolkit/sync/reactive-sync.js +1 -0
  229. package/public/vendor/okjs/toolkit/theming/blocks/ok-design-button.css.js +1 -0
  230. package/public/vendor/okjs/toolkit/theming/blocks/ok-design-input.css.js +1 -0
  231. package/public/vendor/okjs/toolkit/theming/ok-design-style.js +1 -0
  232. package/public/vendor/okjs/toolkit/theming/ok-design-vars.js +1 -0
  233. package/public/vendor/okjs/toolkit/theming/ok-design.ok.js +1 -0
  234. package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-input.ok.js +1 -0
  235. package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-service.ok.js +1 -0
  236. package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-style.js +1 -0
  237. package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-utils.js +1 -0
  238. package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-variable.ok.js +1 -0
  239. package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor-vm.js +1 -0
  240. package/public/vendor/okjs/toolkit/theming/ok-theme-editor/ok-theme-editor.ok.js +1 -0
  241. package/public/vendor/okjs/toolkit/theming/ok-theme.ok.js +1 -0
  242. package/public/view-models/type-query-vm.js +1 -0
  243. package/types/environment.d.ts +130 -0
  244. package/types/errors.d.ts +98 -0
  245. package/types/features/admin.d.ts +4 -0
  246. package/types/features/api.d.ts +18 -0
  247. package/types/features/auth.d.ts +31 -0
  248. package/types/features/embeddings.d.ts +39 -0
  249. package/types/features/engines.d.ts +23 -0
  250. package/types/features/files.d.ts +29 -0
  251. package/types/features/fts.d.ts +25 -0
  252. package/types/features/functions.d.ts +23 -0
  253. package/types/features/mcp.d.ts +17 -0
  254. package/types/features/pipelines.d.ts +19 -0
  255. package/types/features/queue.d.ts +189 -0
  256. package/types/features/sync.d.ts +34 -0
  257. package/types/features/time-machine.d.ts +32 -0
  258. package/types/features/views.d.ts +16 -0
  259. package/types/index.d.ts +153 -0
  260. package/types/options.d.ts +202 -0
@@ -0,0 +1 @@
1
+ var e={"--ok_fg":{type:"color",category:"Colors",default:"#000"},"--ok_bg":{type:"color",category:"Colors",default:"#fff"},"--ok_border":{type:"border",category:"Colors",default:"1px solid #ccc"},"--ok_fg-accent":{type:"color",category:"Colors",default:"#007bff"},"--ok_bg-accent":{type:"color",category:"Colors",default:"#e0f0ff"},"--ok_border-accent":{type:"border",category:"Colors",default:"1px solid #0055cc"},"--ok_fg-muted":{type:"color",category:"Colors",default:"#666"},"--ok_bg-muted":{type:"color",category:"Colors",default:"#f5f5f5"},"--ok_border-muted":{type:"border",category:"Colors",default:"1px solid #ddd"},"--ok_fg-secondary":{type:"color",category:"Colors",default:"#444"},"--ok_bg-secondary":{type:"color",category:"Colors",default:"#f8f8f8"},"--ok_border-secondary":{type:"border",category:"Colors",default:"1px solid #ccc"},"--ok_space":{type:"length",category:"Layout",default:"8px"},"--ok_space-xs":{type:"length",category:"Layout",default:"calc(var(--ok_space) * .5)"},"--ok_space-sm":{type:"length",category:"Layout",default:"calc(var(--ok_space) * .75)"},"--ok_space-md":{type:"length",category:"Layout",default:"var(--ok_space)"},"--ok_space-lg":{type:"length",category:"Layout",default:"calc(var(--ok_space) * 1.5)"},"--ok_space-xl":{type:"length",category:"Layout",default:"calc(var(--ok_space) * 2)"},"--ok_shadow-x":{type:"length",category:"Effects",default:"0px"},"--ok_shadow-y":{type:"length",category:"Effects",default:"var(--ok_space-xs)"},"--ok_shadow-blur":{type:"length",category:"Effects",default:"var(--ok_space-sm)"},"--ok_shadow-spread":{type:"length",category:"Effects",default:"0px"},"--ok_shadow-color":{type:"color",category:"Effects",default:"rgba(0,0,0,0.1)"},"--ok_shadow":{type:"box-shadow",category:"Effects",default:"var(--ok_shadow-x) var(--ok_shadow-y) var(--ok_shadow-blur) var(--ok_shadow-spread) var(--ok_shadow-color)"},"--ok_shadow-strong":{type:"box-shadow",category:"Effects",default:"var(--ok_shadow-x) calc(var(--ok_shadow-y) * 2) calc(var(--ok_shadow-blur) * 2) var(--ok_shadow-spread) var(--ok_shadow-color)"},"--ok_font-size":{type:"length",category:"Layout",default:"1rem"},"--ok_size-xs":{type:"length",category:"Layout",default:"calc(var(--ok_font-size) * .75)"},"--ok_size-sm":{type:"length",category:"Layout",default:"calc(var(--ok_font-size) * .875)"},"--ok_size-md":{type:"length",category:"Layout",default:"var(--ok_font-size)"},"--ok_size-lg":{type:"length",category:"Layout",default:"calc(var(--ok_font-size) * 1.25)"},"--ok_size-xl":{type:"length",category:"Layout",default:"calc(var(--ok_font-size) * 1.5)"},"--ok_font-family":{type:"string",category:"Typography",default:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'},"--ok_font-weight-light":{type:"number",category:"Typography",default:"300"},"--ok_font-weight-regular":{type:"number",category:"Typography",default:"400"},"--ok_font-weight-bold":{type:"number",category:"Typography",default:"700"},"--ok_line-height-base":{type:"number",category:"Typography",default:"1.5"},"--ok_transition":{type:"string",category:"Behavior",default:"0.2s ease"},"--ok_focus-ring":{type:"string",category:"Behavior",default:"0 0 0 3px rgba(0, 123, 255, 0.5)"},"--ok_breakpoint-xs":{type:"length",category:"Breakpoints",default:"0px"},"--ok_breakpoint-sm":{type:"length",category:"Breakpoints",default:"480px"},"--ok_breakpoint-md":{type:"length",category:"Breakpoints",default:"768px"},"--ok_breakpoint-lg":{type:"length",category:"Breakpoints",default:"1024px"},"--ok_breakpoint-xl":{type:"length",category:"Breakpoints",default:"1280px"},"--ok_success":{type:"color",category:"States",default:"#2e7d32"},"--ok_error":{type:"color",category:"States",default:"#c62828"},"--ok_warning":{type:"color",category:"States",default:"#f9a825"},"--ok_info":{type:"color",category:"States",default:"#1565c0"}};export{e as default};
@@ -0,0 +1 @@
1
+ import e from"./ok-design-style.js";import t from"./ok-design-vars.js";import o from"./blocks/ok-design-button.css.js";import s from"./blocks/ok-design-input.css.js";import n from"./ok-theme.ok.js";let r=null;function i(e){e.$vars.$okDesignApplied||(e.$setInnerVars({$okDesignApplied:{get:()=>!0}}),e.$ok.shared.theme._registerDef({tag:"button",plugins:{theme:{define:{default:{"--ok_bg":"var(--ok_bg-accent)"},"default:hover":{"--ok_bg":"var(--ok_bg-accent)"}}}}}),e.$ok.shared.theme.init(),e.$el.setAttribute("data-ok-design",""))}var a={tag:"ok-design",dependencies:[n],get style(){return r||(r=[e,o,s].map(e=>e.replaceAll("~",":where([data-ok-design])")).join("\n"),r)},plugins:{theme:{expose:t}},async prepareDep(e,t){const o=e.$ok.componentRegistry.cache.get(t.id);await e.$ok.componentRegistry.activate(o,e),i(e)},prepare(e){i(e)},template:"<slot/>"};export{a as default};
@@ -0,0 +1 @@
1
+ var t={tag:"ok-theme-editor-input",attr:{value:{},default:{},type:{default:"string"}},context:t=>({get defaultValue(){return t.$attr.default},get value(){return t.$attr.value},get type(){return t.$attr.type},get isUsable(){const t=this.value??this.defaultValue??"";return""!==t&&"revert"!==t&&"inherit"!==t},get isOverridden(){return void 0!==this.value&&this.value!==this.defaultValue},extractRGB(t=""){if(!t||"revert"===t||"inherit"===t)return"#ffffff";if(t.startsWith("rgb")){const e=t.match(/rgba?\(([^)]+)\)/);if(e){const[t,a,r]=e[1].split(",").slice(0,3).map(t=>parseInt(t,10));return`#${[t,a,r].map(t=>(0|t).toString(16).padStart(2,"0")).join("")}`}}if(t.startsWith("#")){if(4===t.length)return"#"+[...t.slice(1)].map(t=>t+t).join("");if(5===t.length)return"#"+[...t.slice(1,4)].map(t=>t+t).join("");if(7===t.length)return t;if(9===t.length)return t.slice(0,7)}return"#ffffff"},extractAlpha(t=""){if(t.startsWith("rgba")){const e=t.match(/rgba?\(([^)]+)\)/);if(e){const t=e[1].split(",").map(t=>t.trim());return Math.max(0,Math.min(1,parseFloat(t[3]??"1")))}}if(t.startsWith("#")){if(9===t.length)return parseInt(t.slice(7,9),16)/255;if(5===t.length)return parseInt(t[4]+t[4],16)/255}return 1},updateAlpha(t,e){const a=Math.max(0,Math.min(1,+e||0));if(t.startsWith("#"))return(7===t.length?t:this.extractRGB(t))+Math.round(255*a).toString(16).padStart(2,"0");const r=t.match(/rgba?\(([^)]+)\)/);if(r){const[t,e,i]=r[1].split(",").slice(0,3).map(t=>parseInt(t,10));return`rgba(${t}, ${e}, ${i}, ${a})`}return this.extractRGB(t)+Math.round(255*a).toString(16).padStart(2,"0")},set(e){t.$dispatch("value",e??"")}}),template:'<div class="ok-theme-editor__var-input"><switch :value="type"><case value="color"><div class="ok-theme-editor__color-row"><div class="ok-theme-editor__color-box-wrapper" :class="{ \'ok-theme-editor__color-box-wrapper--unset\': !isOverridden }"><input type="color" :value="extractRGB(value || defaultValue)" :title="isOverridden ? \'Overridden\' : \'Using default\'" @input="set(updateAlpha($event.target.value, extractAlpha(value || defaultValue)))"><if :="!isUsable"><span class="ok-theme-editor__color-box-hint">?</span></if></div><input class="ok-theme-editor__alpha" type="range" min="0" max="1" step="0.01" :value="extractAlpha(value || defaultValue)" :disabled="!isUsable" @input="set(updateAlpha(extractRGB(value || defaultValue), $event.target.value))"></div></case><case value="string"><input type="text" :value="value ?? \'\'" @input="set($event.target.value)"></case><case value="border"><textarea :value="value ?? \'\'" @input="set($event.target.value)"/></case><case value="box-shadow"><textarea :value="value ?? \'\'" @input="set($event.target.value)"/></case><default><textarea :value="value ?? \'\'" @input="set($event.target.value)"/></default></switch><button class="ok-theme-editor__reset" title="Reset to default" @click="$cmp.$dispatch(\'reset\')">Reset</button> <button class="ok-theme-editor__clear" title="Clear from current scope" @click="$cmp.$dispatch(\'clear\')">Clear</button></div>',style:"[tag] .ok-theme-editor__color-row,[tag] .ok-theme-editor__var-input{display:grid;grid-template-columns:1fr auto auto;gap:.5rem;align-items:center}[tag] .ok-theme-editor__color-row{grid-template-columns:42px 1fr}[tag] .ok-theme-editor__alpha{width:100%}[tag] .ok-theme-editor__color-box-wrapper{position:relative;width:42px;height:32px}[tag] .ok-theme-editor__color-box-wrapper input[type=color]{width:100%;height:100%;padding:0;border:0;background:0 0}[tag] .ok-theme-editor__color-box-wrapper--unset input[type=color]{outline:1px dashed #aaa;outline-offset:-2px}[tag] .ok-theme-editor__color-box-hint{position:absolute;inset:0;display:grid;place-items:center;color:#666;background:#fffa;font-weight:700;pointer-events:none}[tag] .ok-theme-editor__clear,[tag] .ok-theme-editor__reset{justify-self:end}"};export{t as default};
@@ -0,0 +1 @@
1
+ import e from"../../interaction/ok-hotkeys-service.ok.js";import t from"../../modals/ok-window.ok.js";import o from"./ok-theme-editor.ok.js";import r from"../../interaction/ok-picker-service.ok.js";var s={tag:"ok-theme-editor-service",dependencies:[e,t,o,r],register(e,t){e.shared.themeEditor={target:null,deepClone:e=>e&&"object"==typeof e?JSON.parse(JSON.stringify(e)):e,deepMerge(e,t){if(!t||"object"!=typeof t)return e;for(const o in t){const r=t[o];null===r?delete e[o]:"object"!=typeof r||Array.isArray(r)?e[o]=r:(e[o]=e[o]||{},this.deepMerge(e[o],r))}return e},mergePreset(t,o){const r=e.shared.theme.presets.get(t),s=this.deepClone(r||{define:{},components:{}});if(s.define=s.define||{},s.components=s.components||{},o?.define&&this.deepMerge(s.define,o.define),o?.components)for(const[e,t]of Object.entries(o.components))s.components[e]=s.components[e]||{},this.deepMerge(s.components[e],t);if(0===Object.keys(s.define).length&&delete s.define,s.components){for(const[e,t]of Object.entries(s.components)){for(const[o,r]of Object.entries(t))0===Object.keys(r).length&&delete s.components[e][o];0===Object.keys(s.components[e]).length&&delete s.components[e]}0===Object.keys(s.components).length&&delete s.components}return s},getSavedPresets(){const e=[];for(let t=0;t<localStorage.length;t++){const o=localStorage.key(t);o.startsWith("ok-theme-preset:")&&e.push(o.replace("ok-theme-preset:",""))}return e.sort()},loadAllSavedPresets(){const t=this.getSavedPresets();for(const o of t){const t=localStorage.getItem(`ok-theme-preset:${o}`);if(t)try{const r=JSON.parse(t);e.shared.theme.presets.set(o,r)}catch(e){}}},async open(o=null){this.target=o,this.loadAllSavedPresets(),await e.shared.layer.toggle("ok-theme-editor-service",!0,{registration:t,tier:"window"})},async close(){this.target=null,await e.shared.layer.toggle("ok-theme-editor-service",!1)}},"dev"===e.config.env&&e.shared.hotkeys.register(["ctrl","alt","t"],{description:"Toggle theme editor",keydown(t){t.repeat||e.shared.picker.start({onPick:async t=>{await e.shared.themeEditor.open(t)}})},keyup(){e.shared.picker.stop()}})},template:'<ok-window no-portal @close="$ok.shared.themeEditor.close()"><ok-theme-editor :target="$ok.shared.themeEditor.target"/></ok-window>'};export{s as default};
@@ -0,0 +1 @@
1
+ var n="\n[tag] { display: block; }\n\n[tag] .ok-theme-editor__header {\n display: flex; align-items: center; justify-content: space-between;\n margin-bottom: var(--ok_margin, 1rem);\n}\n\n[tag] .ok-theme-editor__title {\n display: flex;\n align-items: center;\n gap: .5rem;\n}\n\n[tag] .ok-theme-editor__preset-name {\n color: var(--ok_fg-accent);\n font-weight: 600;\n}\n\n[tag] .ok-theme-editor__modified {\n color: var(--ok_fg-error, #f44);\n font-size: 1.5em;\n}\n\n[tag] .ok-theme-editor__actions { display: flex; gap: .5rem; }\n\n[tag] .ok-theme-editor__delete-btn {\n background: var(--ok_bg-error, #fee);\n color: var(--ok_fg-error, #c33);\n border-color: var(--ok_fg-error, #c33);\n}\n\n[tag] .ok-theme-editor__delete-btn:hover {\n background: var(--ok_fg-error, #c33);\n color: var(--ok_bg, white);\n}\n\n[tag] .ok-theme-editor__filter-bar {\n display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;\n margin: .75rem 0;\n min-width: 200px;\n padding: var(--ok_space-xs) var(--ok_space);\n border: var(--ok_border);\n border-radius: var(--ok_space-xs);\n background: var(--ok_bg);\n color: var(--ok_fg);\n font-size: inherit;\n cursor: pointer;\n}\n\n[tag] .ok-theme-editor__select {\n min-width: 200px;\n padding: var(--ok_space-xs) var(--ok_space);\n border: var(--ok_border);\n border-radius: var(--ok_space-xs);\n background: var(--ok_bg);\n color: var(--ok_fg);\n font-size: inherit;\n cursor: pointer;\n}\n\n[tag] .ok-theme-editor__select:focus {\n outline: 2px solid var(--ok_fg-accent);\n outline-offset: 2px;\n}\n\n[tag] .ok-theme-editor__info {\n padding: var(--ok_space);\n background: var(--ok_bg-accent);\n border-radius: var(--ok_space-xs);\n margin: var(--ok_space) 0;\n border-left: 3px solid var(--ok_fg-accent);\n}\n\n[tag] .ok-theme-editor__variant-label {\n color: var(--ok_fg-accent);\n font-weight: 600;\n}\n\n[tag] .ok-theme-editor__empty,\n[tag] .ok-theme-editor__empty-state {\n color: var(--ok_fg-muted);\n font-style: italic;\n padding: var(--ok_space);\n}\n\n[tag] .ok-theme-editor__empty-state {\n grid-column: 1 / -1;\n text-align: center;\n border: 1px dashed var(--ok_border);\n border-radius: var(--ok_space-xs);\n background: var(--ok_bg-muted);\n margin: var(--ok_space) 0;\n}\n\n[tag] .ok-theme-editor__grid {\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));\n gap: var(--ok_space-sm);\n margin-top: 1rem;\n}\n\n[tag] .ok-theme-editor__var-card {\n border: var(--ok_border);\n border-radius: var(--ok_space-sm);\n background: var(--ok_bg-muted);\n box-shadow: var(--ok_shadow);\n padding: var(--ok_space);\n}\n\n[tag] .ok-theme-editor__var-head {\n display: flex;\n gap: .5rem;\n justify-content: space-between;\n align-items: flex-start;\n margin-bottom: .5rem;\n}\n\n[tag] .ok-theme-editor__var-title {\n display: flex;\n flex-direction: column;\n gap: .25rem;\n flex: 1;\n}\n\n[tag] .ok-theme-editor__var-name {\n font-weight: 600;\n word-break: break-all;\n}\n\n[tag] .ok-theme-editor__var-source {\n font-size: var(--ok_size-xs);\n padding: 2px 6px;\n border-radius: var(--ok_space-xs);\n background: var(--ok_bg);\n width: fit-content;\n display: inline-flex;\n align-items: center;\n gap: 4px;\n}\n\n[tag] .ok-theme-editor__scope {\n display: inline-flex;\n gap: 2px;\n margin-left: 6px;\n vertical-align: middle;\n}\n\n[tag] .scope-btn {\n background: none;\n border: 1px solid var(--ok_border);\n border-radius: 3px;\n padding: 2px 6px;\n cursor: pointer;\n opacity: 0.5;\n transition: opacity 0.2s, background 0.2s;\n font-size: 12px;\n line-height: 1;\n position: relative;\n display: inline-flex;\n align-items: center;\n gap: 2px;\n}\n\n[tag] .scope-btn .scope-check {\n font-size: 10px;\n color: var(--ok_fg-success, #4ade80);\n font-weight: bold;\n}\n\n[tag] .scope-btn.has-value {\n opacity: 0.8;\n border-color: var(--ok_fg-muted);\n}\n\n[tag] .scope-btn.active {\n opacity: 1;\n background: var(--ok_bg-accent);\n color: var(--ok_fg-accent);\n border-color: var(--ok_fg-accent);\n}\n\n[tag] .scope-btn.active .scope-check {\n color: var(--ok_fg-accent);\n}\n\n[tag] .scope-btn:hover:not(.active) {\n opacity: 0.7;\n}\n\n[tag] .ok-theme-editor__lock-icon-btn {\n padding: 0;\n margin: 0;\n border: none;\n background: none;\n cursor: pointer;\n font-size: 0.85em;\n line-height: 1;\n opacity: 0.6;\n transition: opacity 0.2s ease;\n}\n\n[tag] .ok-theme-editor__lock-icon-btn:hover {\n opacity: 1;\n}\n\n[tag] .ok-theme-editor__input {\n width: 100%;\n}\n\n[tag] button.active {\n background: var(--ok_bg-accent);\n color: var(--ok_fg-accent);\n font-weight: 600;\n}\n";export{n as default};
@@ -0,0 +1 @@
1
+ function e(t,o=new Set){if(Array.isArray(t))for(let n of t)e(n,o);else if(t instanceof HTMLStyleElement)e(t.innerHTML,o);else if("string"==typeof t)for(let e of t.matchAll(/var\(\s*(--[\w-]+)\s*(?:,[^)]+)?\)/g))o.add(e[1]);return o}function t(t,o,n={}){const a=e(o.style);for(let e of a)if(!t[e]){const a=t[e]?{...t[e]}:{ghost:!0,component:"__ghost__",default:"",values:{}};a.values[o.tag]??={},a.values[o.tag].default="",(a.styleOrigin??=[]).push(o.tag),n[e]=a}}function o(e,o,n={}){t(e,o,n),function(e,t,o={}){const n=t?.plugins?.theme?.define;if(n)for(const a of Object.keys(n))for(const r of Object.keys(n[a])){if(e[r]&&(void 0!==e[r].values?.[t.tag]?.[a]||e[r].component===t.tag))continue;const s=e[r]?{...e[r]}:{ghost:!0,component:"__ghost__",default:"",values:{}};s.values[t.tag]??={},s.values[t.tag][a]=n[a][r]||"",(s.defineOrigin??=[]).push(t.tag),o[r]=s}}(e,o,n)}const n=e=>`g|-|-|${e}`,a=(e,t,o)=>`c|${e}|${t||"default"}|${o}`,r=e=>e.startsWith("g|"),s=e=>e.startsWith("c|"),l=e=>{const[t,o,n,a]=e.split("|");return{scope:"g"===t?"global":"component",component:"-"!==o?o:null,variant:"-"!==n?n:null,var:a}};function i(e){const t={},o={};for(const[n,a]of e){if(null===a)continue;const{scope:e,component:r,variant:s,var:i}=l(n);"global"===e?t[i]=a:(o[r]??={},o[r][s||"default"]??={},o[r][s||"default"][i]=a)}return{define:t,components:o}}function u({meta:e,ghostsMeta:t,live:o,preset:r,selectedComponent:s,selectedVariant:l,varName:i,scope:u,mode:c="value"}){u??="default"!==l||s?"component":"global";const f=e[i]||t[i];if("component"===u){if("default"!==l){const e=o.get(a(s,l,i));if("default"===c);else if(null!=e)return{value:e,source:{scope:u,origin:"live",variant:l,key:i,component:s}};if(null!==e){const e=r?.components?.[s]?.[l]?.[i];if(void 0!==e)return{value:e,source:{scope:u,origin:"preset",variant:l,key:i,component:s,preset:r}}}}const e=o.get(a(s,"default",i));if("default"===c&&"default"===l);else if(null!=e)return{value:e,source:{scope:u,origin:"live",variant:"default",key:i,component:s}};if(null!==e){const e=r?.components?.[s]?.default?.[i];if(void 0!==e)return{value:e,source:{scope:u,origin:"preset",variant:"default",key:i,component:s,preset:r}}}if("default"!==l){const e=o.get(n(i));if(null!=e)return{value:e,source:{scope:"global",origin:"live",key:i,component:s}}}const t=f?.values[s]?.default;if(void 0!==t)return{value:t,source:{scope:u,origin:"meta",variant:"default",key:i,component:s}};if("default"!==l){const e=f?.values[s]?.[l];if(null!=e)return{value:e,source:{scope:u,origin:"meta",variant:l,key:i,component:s}}}}const d=o.get(n(i));if("default"===c&&"global"===u);else if(null!=d)return{value:d,source:{scope:"global",origin:"live",key:i,component:e.component}};if(null!==d){const t=r?.define?.[i];if(void 0!==t)return{value:t,source:{scope:"global",origin:"preset",key:i,component:e.component,preset:r}}}return{value:f?.default??"",source:{scope:"global",origin:"meta",key:i,component:e.component}}}function c(e=document.body){let t=e;for(;t&&t.parentNode;){if(t.parentNode instanceof ShadowRoot)return t.parentNode;if(t.parentNode instanceof Document)return t.parentNode;t=t.parentNode}return document}function f(e,t){const o=c(e),n=o.body||o;n.setAttribute("data-ok-theme-editor",String(t));const a=n;let r=a.querySelector(`style[data-ok-theme-editor-style="${t}"]`);return r||(r=o.createElement?o.createElement("style"):document.createElement("style"),r.setAttribute("data-ok-theme-editor-style",String(t)),a.appendChild(r)),r}function d(e,t){const o=c(e),n=o.head||o.querySelector("head")||o,a=o.body||o;a.removeAttribute("data-ok-theme-editor");const r=n||a,s=r.querySelector(`style[data-ok-theme-editor-style="${t}"]`);s&&r.removeChild(s)}function p({live:e,themeAttr:t,editorId:o}){const n=[],a=[];for(const[t,o]of e)null!==o&&r(t)&&a.push([l(t).var,o]);if(a.length){n.push("/* @ok-theme-editor: live define */");const e=t?`[data-ok-theme="${t}"][data-ok-theme-editor="${o}"]`:`[data-ok-theme-editor="${o}"]`;n.push(`${e} {`);for(const[e,t]of a)n.push(` ${e}: ${t};`);n.push("}\n")}const i=new Map;for(const[t,o]of e){if(null===o||!s(t))continue;const{component:e,variant:n,var:a}=l(t),r=`${e}|${n||"default"}`;(i.get(r)??i.set(r,[]).get(r)).push([a,o])}for(const[e,a]of i){const[r,s]=e.split("|"),[l,i]=s.split(":"),u=r+(i?`:${i}`:"")+("default"!==l?'[data-ok-variant="'+l+'"]':"");n.push(`/* @ok-theme-editor: ${r} (${s}) */`);const c=`${t?`[data-ok-theme="${t}"][data-ok-theme-editor="${o}"]`:`[data-ok-theme-editor="${o}"]`} ${u}`;n.push(`${c} {`);for(const[e,t]of a)n.push(` ${e}: ${t};`);n.push("}\n")}return n.join("\n")}export{f as ensureOverlay,o as extractGhosts,c as getOverlayHost,s as isC,r as isG,a as keyC,n as keyG,l as pkey,d as removeOverlay,p as renderOverlayCSS,u as resolveValueFull,i as unflattenLive};
@@ -0,0 +1 @@
1
+ import e from"./ok-theme-editor-input.ok.js";import{keyG as t,keyC as s,resolveValueFull as a}from"./ok-theme-editor-utils.js";var i={tag:"ok-theme-editor-variable",dependencies:[e],attr:{vm:{type:"object",required:!0},variable:{type:"string",required:!0}},context:e=>({scopeOverride:null,get vm(){return e.$attr.vm},get varName(){return e.$attr.variable},get meta(){return this.vm.meta[this.varName]||this.vm.ghostsMeta[this.varName]||{}},get category(){return this.meta.category||"General"},get type(){return this.meta.type||"string"},get isDefaultVariant(){return!this.vm.selectedVariant||"default"===this.vm.selectedVariant},get activeScope(){return this.isDefaultVariant&&this.scopeOverride||"component"},get resolved(){return e.$memo(()=>a({meta:this.vm.meta,ghostsMeta:this.vm.ghostsMeta,live:this.vm.live,preset:this.vm.getPreset(),selectedComponent:this.vm.selectedComponent,selectedVariant:this.vm.selectedVariant||"default",varName:this.varName,scope:this.activeScope,mode:"value"})).value},get resolvedDefault(){return e.$memo(()=>a({meta:this.vm.meta,ghostsMeta:this.vm.ghostsMeta,live:this.vm.live,preset:this.vm.getPreset(),selectedComponent:this.vm.selectedComponent,selectedVariant:this.vm.selectedVariant||"default",varName:this.varName,scope:this.activeScope,mode:"default"})).value},get value(){return this.resolved.value},get defaultValue(){return this.resolvedDefault.value},get source(){return this.resolved.source},get formattedSource(){const e=this.source;switch(e.scope){case"global":switch(e.origin){case"live":return"📝 Modified (global)";case"preset":return"🔵 Preset (global)";default:return`🟢 ${this.meta.component} (global)`}case"component":switch(e.origin){case"live":return`📝 Modified (${e.variant})`;case"preset":return`🔵 ${this.vm.currentPresetName} (${e.variant})`;case"meta":return`🟢 ${e.component} (${e.variant})`}default:return"Unknown source"}},get isLive(){return"live"===this.source.origin},get isLockable(){return!this.isLive||this.source.variant!==this.vm.selectedVariant||this.source.component!==this.vm.selectedComponent},get isLocked(){return this.isLive},get hasPresetHere(){const e=this.vm.getPreset();if(!e)return!1;if("global"===this.activeScope)return void 0!==e.define?.[this.varName];{const t=this.vm.selectedVariant||"default";return void 0!==e.components?.[this.vm.selectedComponent]?.[t]?.[this.varName]}},toggleScope(e){this.scopeOverride=e},hasValueIn(e){const a=this.vm.selectedVariant||"default",i="global"===e?t(this.varName):s(this.vm.selectedComponent,a,this.varName);if(this.vm.live.has(i)){if(null!=this.vm.live.get(i))return!0}const n=this.vm.getPreset();return!!n&&("global"===e?void 0!==n.define?.[this.varName]:void 0!==n.components?.[this.vm.selectedComponent]?.[a]?.[this.varName])},setValue(e){void 0===e||""===e||e===this.defaultValue?this.deleteLive():this.setLive(e)},reset(){this.deleteLive()},clear(){this.hasPresetHere?this.setLive(null):this.deleteLive()},lock(){this.setLive(this.value)},setLive(e){const a=this.vm.selectedVariant||"default",i="global"===this.activeScope?t(this.varName):s(this.vm.selectedComponent,a,this.varName);void 0===e?this.vm.live.delete(i):this.vm.live.set(i,e),this.vm.updateStyle()},deleteLive(){const e=this.vm.selectedVariant||"default",a="global"===this.activeScope?t(this.varName):s(this.vm.selectedComponent,e,this.varName);this.vm.live.delete(a),this.vm.updateStyle()}}),template:'\n <div class="ok-theme-editor__var-card">\n <div class="ok-theme-editor__var-head">\n <div class="ok-theme-editor__var-title">\n <strong class="ok-theme-editor__var-name">{{ varName }}</strong>\n\n <if :="isDefaultVariant">\n <span class="ok-theme-editor__scope">\n <button class="scope-btn"\n :class="{ active: activeScope===\'global\', \'has-value\': hasValueIn(\'global\') }"\n @click="toggleScope(\'global\')" title="Edit global">\n 🌐<if :="hasValueIn(\'global\')"><span class="scope-check">✓</span></if>\n </button>\n <button class="scope-btn"\n :class="{ active: activeScope===\'component\', \'has-value\': hasValueIn(\'component\') }"\n @click="toggleScope(\'component\')" title="Edit component">\n 🧩<if :="hasValueIn(\'component\')"><span class="scope-check">✓</span></if>\n </button>\n </span>\n </if>\n\n <span class="ok-theme-editor__var-source">\n {{ formattedSource }}\n <if :="isLockable && !isLocked">\n <button class="ok-theme-editor__lock-icon-btn" @click="lock" title="Lock current value">🔒</button>\n </if>\n </span>\n </div>\n <span class="ok-theme-editor__var-meta">{{ category }}</span>\n </div>\n\n <ok-theme-editor-input\n class="ok-theme-editor__input"\n :type="type"\n :value="value"\n :default="defaultValue"\n @value="setValue($event.detail)"\n @reset="reset"\n @clear="clear">\n </ok-theme-editor-input>\n </div>'};export{i as default};
@@ -0,0 +1 @@
1
+ import{removeOverlay as e,ensureOverlay as t,extractGhosts as s,renderOverlayCSS as r,unflattenLive as a,pkey as o,getOverlayHost as n}from"./ok-theme-editor-utils.js";const l="data-ok-theme";let c=0;function d(d){const i=++c,u=d.$ok.proxy({id:i,overrideStyle:null,ghostsMeta:{},live:new Map,selectedPreset:null,basePresetName:null,basePresetSource:null,selectedComponent:null,selectedVariant:"default",selectedCategory:null,_savedPresetsVersion:0,activateBusy:!1}),m=d.$ok.shared.theme,g=d.$ok.shared.themeEditor,P=d.$ok.shared.toast,v=d.$ok.shared.modal,p={id:i,get target(){return d.$memo(()=>d.$attr.target?"string"==typeof d.$attr.target?d.$el.closest(d.$attr.target):d.$attr.target:d.$ok.config.body).value},get host(){return n(this.target)},get overrideStyle(){return u.overrideStyle},get meta(){return d.$ok.shared.theme.meta},get ghostsMeta(){return u.ghostsMeta},get live(){return u.live},get selectedPreset(){return u.selectedPreset},get basePresetName(){return u.basePresetName},get currentPresetName(){return u.basePresetName},get basePresetSource(){return u.basePresetSource},get selectedComponent(){return u.selectedComponent},set selectedComponent(e){u.selectedComponent=e},get selectedVariant(){return u.selectedVariant},set selectedVariant(e){u.selectedVariant=e},get selectedCategory(){return u.selectedCategory},set selectedCategory(e){u.selectedCategory=e},get isModified(){return u.live.size>0},get isDOMPreset(){return"dom"===u.basePresetSource},get isLocalPreset(){return"local"===u.basePresetSource},get canSave(){return p.isLocalPreset&&p.isModified&&!!p.basePresetName},get canDelete(){return p.isLocalPreset&&!!p.basePresetName},get activateBusy(){return u.activateBusy},get presets(){u._savedPresetsVersion;const e=[...m.presets.keys()],t=new Set(g.getSavedPresets());return e.filter(e=>!t.has(e)).sort()},get savedPresets(){return u._savedPresetsVersion,g.getSavedPresets()},get components(){const e=new Set;for(const t of Object.values(p.meta)){e.add(t.component||"__ghost__");for(const[s,r]of Object.entries(t.values||{}))e.add(s)}for(const t of Object.values(u.ghostsMeta)){e.add(t.component||"__ghost__");for(const[s,r]of Object.entries(t.values||{}))e.add(s)}return[...e].sort()},get variants(){const e=u.selectedComponent;if(!e)return["default"];const t=new Set(["default"]);for(const s of d.$ok.componentRegistry.cache.values()){const r=s.ready||s.raw;if(r?.tag!==e)continue;const a=r?.plugins?.theme?.define;a&&"object"==typeof a&&Object.keys(a).forEach(e=>t.add(e))}if(u.basePresetName){const s=m.presets.get(u.basePresetName),r=s?.components?.[e];r&&Object.keys(r).forEach(e=>t.add(e))}for(const s of u.live.keys()){const r=o(s);"component"===r.scope&&r.component===e&&t.add(r.variant||"default")}return[...t].sort()},get categories(){const e=u.selectedComponent;if(!e)return[];const t=new Set;for(const s of Object.values(p.meta))s.component===e&&t.add(s.category||"General");for(const s of Object.values(u.ghostsMeta))s.component===e&&t.add(s.category||"General");return[...t].sort()},get variables(){const e=u.selectedComponent,t=u.selectedCategory;if(!e)return[];const s=new Set;for(const[r,a]of Object.entries(p.meta))a.component===e&&(t&&a.category!==t||s.add(r));for(const[r,a]of Object.entries(p.meta))a.component!==e&&a.values?.[e]&&(t&&a.category!==t||s.add(r));for(const[r,a]of Object.entries(u.ghostsMeta))a.values&&e in a.values&&(t&&a.category!==t||s.add(r));return[...s].sort()},getPreset:()=>function(){const e=u.basePresetName;return e?m.presets.get(e):null}(),getThemeAttr:()=>p.host.body.getAttribute(l),selectPreset(e){const t=!e||e===u.selectedPreset;u.selectedPreset=t?null:e,u.selectedPreset?m.presets.get(u.selectedPreset)&&(u.basePresetName=u.selectedPreset,u.basePresetSource="dom",u.live.clear(),p.host.body.setAttribute(l,u.selectedPreset)):(u.basePresetName=null,u.basePresetSource=null,u.live.clear(),p.host.body.removeAttribute(l)),p.updateStyle()},selectComponent(e){u.selectedComponent=e,u.selectedVariant="default",u.selectedCategory=null},async loadSavedPreset(e){const t=localStorage.getItem(`ok-theme-preset:${e}`);if(t)try{const s=JSON.parse(t);m.presets.set(e,s),u.basePresetName=e,u.basePresetSource="local",u.selectedPreset=null,u.live.clear(),p.host.body.setAttribute(l,e),p.updateStyle(),u._savedPresetsVersion++,P?.success?.(`Preset "${e}" loaded`)}catch(e){P?.error?.(`Failed to load preset: ${e.message}`)}},async savePreset(){if(!p.isLocalPreset||!p.isModified||!p.basePresetName)return;const e=g.mergePreset(u.basePresetName,a(u.live));localStorage.setItem(`ok-theme-preset:${u.basePresetName}`,JSON.stringify(e,null,2)),m.presets.set(u.basePresetName,e),u.live.clear(),p.updateStyle(),u._savedPresetsVersion++,P?.success?.(`Preset "${u.basePresetName}" saved`)},async saveAsPreset(){const e=(()=>{if(p.isLocalPreset&&p.basePresetName)return p.basePresetName;if(p.isDOMPreset&&p.basePresetName){const e=new Set(g.getSavedPresets()),t=p.basePresetName;let s=`${t}-copy`,r=2;for(;e.has(s);)s=`${t}-copy-${r++}`;return s}return"my-theme"})(),t=await(v.prompt?.("",{value:e,required:!0,canDrag:!0,placeholder:"preset-name",title:"Save Preset As",pattern:/^[a-zA-Z0-9-_]+$/,validate:e=>e.startsWith("-")?"Cannot start with dash":!(e.length>50)||"Name too long (max 50 chars)"}));if(!t)return;const s=g.mergePreset(u.basePresetName,a(u.live));localStorage.setItem(`ok-theme-preset:${t}`,JSON.stringify(s,null,2)),m.presets.set(t,s),u.basePresetName=t,u.basePresetSource="local",u.selectedPreset=null,u.live.clear(),p.host.body.setAttribute(l,t),p.updateStyle(),u._savedPresetsVersion++,P?.success?.(`Preset saved as "${t}"`)},async deletePreset(){const e=u.basePresetName;e&&(new Set(g.getSavedPresets()).has(e)?await(v.confirm?.(`Delete preset "${e}"?`,{title:"Delete Preset",canDrag:!0}))&&(localStorage.removeItem(`ok-theme-preset:${e}`),m.presets.delete(e),u.basePresetName=null,u.basePresetSource=null,u.selectedPreset=null,u.live.clear(),p.host.body.removeAttribute(l),p.updateStyle(),u._savedPresetsVersion++,P?.success?.(`Preset "${e}" deleted`)):P?.error?.("Cannot delete built-in presets"))},async exportPreset(){const e=await(v.prompt?.("",{value:u.basePresetName||"theme-preset",required:!0,canDrag:!0,placeholder:"filename",title:"Export Preset",pattern:/^[a-zA-Z0-9-_]+$/,validate:e=>e.startsWith("-")?"Cannot start with dash":!(e.length>50)||"Name too long (max 50 chars)"}));if(!e)return;const t=g.mergePreset(u.basePresetName,a(u.live)),s=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),r=URL.createObjectURL(s),o=document.createElement("a");o.href=r,o.download=`${e}.json`,o.click(),URL.revokeObjectURL(r),P?.success?.(`Preset exported as ${e}.json`)},updateStyle(){(u.overrideStyle||=t(p.target,i)).textContent=r({live:u.live,themeAttr:p.getThemeAttr(),editorId:i})},async activateAll(){u.activateBusy=!0;for(const e of[...d.$ok.componentRegistry.cache.values()])await d.$ok.componentRegistry.init(e),s(p.meta,e.raw,u.ghostsMeta);u.activateBusy=!1},init(){u.overrideStyle||(u.overrideStyle=t(p.host,i),p.host.body.setAttribute("data-ok-theme-editor",String(i))),p.updateStyle()},removeOverlay(){u.overrideStyle?.remove(),e(p.host,i)}};return p}export{d as default};
@@ -0,0 +1 @@
1
+ import e from"./ok-theme-editor-input.ok.js";import t from"./ok-theme-editor-variable.ok.js";import n from"../ok-design.ok.js";import s from"./ok-theme-editor-vm.js";import a from"./ok-theme-editor-style.js";var o={tag:"ok-theme-editor",dependencies:[n,e,t],attr:{target:{}},context:e=>s(e),mount(e){e.$observe(e.$ok.shared.theme.meta,null,()=>{e.$ok.proxyInstance.notify(()=>e.$ok.shared.theme.meta)}),this.init()},unmount(e){this.removeOverlay()},template:'<div class="ok-theme-editor">\n <div class="ok-theme-editor__header"><strong class="ok-theme-editor__title"> Theme Editor\n <if :="currentPresetName && basePresetSource === \'local\'"><span class="ok-theme-editor__preset-name">[{{ currentPresetName }}]</span>\n </if>\n <if :="currentPresetName && basePresetSource === \'dom\'"><span class="ok-theme-editor__preset-name">[🌐 {{ currentPresetName }}]</span>\n </if>\n <if :="isModified"><span class="ok-theme-editor__modified" title="You have unsaved changes">*</span></if>\n </strong>\n <div class="ok-theme-editor__actions">\n <if :="canSave">\n <button @click="savePreset" title="Save changes to current preset">💾 Save</button>\n </if>\n <if :="!canSave && isDOMPreset">\n <button disabled title="Built-in presets can\'t be modified. Use Save As… to create a copy">💾 Save</button>\n </if>\n <button @click="saveAsPreset" title="Save as new preset">💾 Save As...</button>\n <if :="canDelete">\n <button @click="deletePreset" class="ok-theme-editor__delete-btn" title="Delete this preset">🗑️ Delete\n </button>\n </if>\n <button @click="exportPreset" title="Export preset as JSON file">📥 Export</button>\n <button @click="activateAll" :disabled="activateBusy">{{ activateBusy ? \'Activating…\' : \'Activate All\' }}\n </button>\n </div>\n </div>\n <if :="savedPresets.length">\n <div class="ok-theme-editor__filter-bar"><strong>💾 Saved Presets:</strong>\n <each :="savedPresets" let:item="preset">\n <button @click="loadSavedPreset(preset)"\n :class="{ active: currentPresetName === preset && basePresetSource === \'local\' }"\n class="ok-theme-editor__preset-btn"\n :title="\'Load local preset: \' + preset"> {{ preset }}\n </button>\n </each>\n </div>\n </if>\n <div class="ok-theme-editor__filter-bar"><strong class="ok-theme-editor__label">🌐 Base Presets (DOM):</strong>\n <each :="presets" let:item="preset">\n <button @click="selectPreset(preset)" \n :class="{ active: selectedPreset === preset }"\n :title="\'Load DOM preset: \' + preset"> {{ preset }}</button>\n </each>\n <if :="!presets.length"><span class="ok-theme-editor__empty">No presets available</span></if>\n </div>\n <div class="ok-theme-editor__filter-bar"><label class="ok-theme-editor__label"> <strong>Component:</strong> <select\n @change="selectComponent($event.target.value)" class="ok-theme-editor__select">\n <option value="">Select a component...</option>\n <option as="repeat" :of="components" let:item="component" :value="component" :selected="component === selectedComponent">{{ component }}</option>\n </select> </label></div>\n <if :="selectedComponent">\n <div class="ok-theme-editor__filter-bar"><strong>Variant:</strong>\n <each :="variants" let:item="variant">\n <button @click="selectedVariant = variant" :class="{ active: variant === selectedVariant }"> {{ variant\n }}\n </button>\n </each>\n </div>\n <if :="categories.length > 1">\n <div class="ok-theme-editor__filter-bar"><strong>Category:</strong>\n <button @click="selectedCategory = null" :class="{ active: !selectedCategory }"> All</button>\n <each :="categories" let:item="category">\n <button @click="selectedCategory = category" :class="{ active: category === selectedCategory }"> {{\n category }}\n </button>\n </each>\n </div>\n </if>\n <div class="ok-theme-editor__info"><strong>Editing:</strong> {{ selectedComponent }}\n <if :="selectedVariant && selectedVariant !== \'default\'"><span class="ok-theme-editor__variant-label">({{ selectedVariant }} variant)</span>\n </if>\n </div>\n <div class="ok-theme-editor__grid">\n <each :="variables" let:item="variable">\n <ok-theme-editor-variable :vm="$context" :variable />\n </each>\n <if :="!variables.length">\n <div class="ok-theme-editor__empty-state"> No variables found for this component\n <if :="selectedCategory"> in category "{{ selectedCategory }}"</if>\n .\n </div>\n </if>\n </div>\n </if>\n <if :="!selectedComponent">\n <div class="ok-theme-editor__empty-state"><p>👆 Select a component above to start editing its theme\n variables.</p></div>\n </if>\n</div>',style:a};export{o as default};
@@ -0,0 +1 @@
1
+ function e(t){return"string"==typeof t?t.trim().split(/\s+/).filter(Boolean):Array.isArray(t)?t.flatMap(t=>e(t)):[]}var t={tag:"ok-theme",register(t){function o(e="ok-theme-injected",o=t.config.head,s="prepend"){const n="data-"+e;let a=o.querySelector(`[${n}]`);return a||(a=document.createElement("style"),a.setAttribute(n,""),"append"===s?o.append(a):o.prepend(a)),a}const s=new WeakMap,n=new Set;function a(e){let t=s.get(e);return t||(t={defaultsEl:null,presetEls:new Map},s.set(e,t),n.add(e)),t}const r=t.shared.theme={meta:t.proxy({}),loadedDefs:new Set,presets:new Map,initialized:!1,inspect(e){const t=new Set;for(;e&&1===e.nodeType;){if(e.hasAttribute("data-ok-theme")){const o=e.getAttribute("data-ok-theme")?.trim()||"",s=""===o||o.split(/\s+/).includes("default");s&&t.clear();for(const e of o.split(/\s+/))e&&"default"!==e&&t.add(e);if(s)break}e=e.parentElement}return[...t]},_verifyPresets(e,o){for(const s of o)r.presets.has(s)||t.log.warn(["ok-theme"],{error:t.error("OK_THEME_PRESET_NOT_REGISTERED",`Preset "${s}" is not registered`),node:e})},apply(t,o){const s=e(o);this._verifyPresets(t,s),t.setAttribute("data-ok-theme",s.join(" "))},append(t,o){const s=new Set(this.inspect(t));this._verifyPresets(t,o);for(const t of e(o))s.add(t);t.setAttribute("data-ok-theme",[...s].join(" "))},remove(t,o){const s=new Set(this.inspect(t));for(const t of e(o))s.delete(t);t.setAttribute("data-ok-theme",[...s].join(" "))},reset(e){e.setAttribute("data-ok-theme","")},_renderDefaults({head:e=t.config.head}={}){if(!Object.keys(r.meta).length)return;const s=a(e);s.defaultsEl||(s.defaultsEl=o("ok-theme-defaults",e,"prepend"));const n="undefined"!=typeof ShadowRoot&&e.getRootNode()instanceof ShadowRoot,i={};for(const[e,t]of Object.entries(r.meta)){for(const[o,s]of Object.entries(t.values)){const t=i[o]??={defaults:{},overrides:{},variants:{}};for(const[o,n]of Object.entries(s))"default"===o?t.overrides[e]=n:(t.variants[o]??={})[e]=n}if(!t.ghost){const o=t.def?.tag;(i[o]??={defaults:{},overrides:{},variants:{}}).defaults[e]=null!=t.default&&""!==t.default?t.default:"inherit"}if(t.variants&&t.variants.size){const o=t.def?.tag;if(!o)continue;const s=i[o]??={defaults:{},overrides:{},variants:{}},n=t.def?.plugins?.theme?.define||{};for(const o of t.variants){const t=n[o];if(!t)continue;const a=t[e];null!=a&&((s.variants[o]??={})[e]=a)}}}const f=[];for(const e of r.loadedDefs.values()){const t=i[e];if(t){if(Object.keys(t.defaults).length){f.push(`/* @ok-theme: defaults ${e} */`),f.push(n?":host {":":root {");for(const[e,o]of Object.entries(t.defaults))f.push(`\t${e}: ${o};`);f.push("}")}if(Object.keys(t.overrides).length){f.push(`/* @ok-theme-override: defaults ${e} */`),f.push(`${e} {`);for(const[e,o]of Object.entries(t.overrides))f.push(`\t${e}: ${o};`);f.push("}")}for(const[o,s]of Object.entries(t.variants||{})){if(!Object.keys(s).length)continue;const[t,n]=o.split(":"),a=`${e}${n?`:${n}`:""}${"default"===t?"":`[data-ok-variant="${t}"]`}`;f.push(`/* @ok-theme-variant: defaults ${e}--${o} */`),f.push(`${a} {`);for(const[e,t]of Object.entries(s))f.push(`\t${e}: ${t};`);f.push("}")}}}s.defaultsEl.innerHTML=f.join("\n")},_renderPresetIntoHead(e,s=t.config.head){const n=r.presets.get(e);if(!n)return;const i=a(s);let f=i.presetEls.get(e);f||(f=o(`ok-theme-preset_${e}`,s,"append"),i.presetEls.set(e,f));const d=[],c=`[data-ok-theme~="${e}"], :root[data-ok-theme~="${e}"]`;if(n.define&&Object.keys(n.define).length){d.push(`/* @ok-theme-preset: ${e} */`),d.push(`${c} {`);for(const[e,t]of Object.entries(n.define))null!=t&&""!==t&&d.push(`\t${e}: ${t};`);d.push("}\n")}const l=n.components||{};for(const[t,o]of Object.entries(l)){if(!o||"object"!=typeof o)continue;const s=o.default;if(s&&Object.keys(s).length){const o=[`[data-ok-theme~="${e}"] ${t}`,`:root[data-ok-theme~="${e}"] ${t}`,`${t}[data-ok-theme~="${e}"]`].join(", ");d.push(`/* @ok-theme-preset-override: ${e} ${t} */`),d.push(`${o} {`);for(const[e,t]of Object.entries(s))null!=t&&""!==t&&d.push(`\t${e}: ${t};`);d.push("}\n")}for(const[s,n]of Object.entries(o)){if("default"===s)continue;if(!n||!Object.keys(n).length)continue;const o=[`[data-ok-theme~="${e}"] ${t}[data-ok-variant="${s}"]`,`:root[data-ok-theme~="${e}"] ${t}[data-ok-variant="${s}"]`,`${t}[data-ok-variant="${s}"][data-ok-theme~="${e}"]`].join(", ");d.push(`/* @ok-theme-preset-variant: ${e} ${t}:${s} */`),d.push(`${o} {`);for(const[e,t]of Object.entries(n))null!=t&&""!==t&&d.push(`\t${e}: ${t};`);d.push("}\n")}}f.innerHTML=d.join("\n")},_renderPresetToAllHeads(e){for(const t of n)this._renderPresetIntoHead(e,t)},_registerDef(e){const o=e.plugins?.theme;if(!o)return;const{expose:s,define:n}=o;if(s&&Object.keys(s).length)for(const[o,n]of Object.entries(s)){const s=null!=n.default&&""!==n.default?n.default:"inherit";if(r.meta[o]){if(r.meta[o]?.def?.tag===e.tag)continue;if(r.meta[o].ghost){t.log.warn(["ok-theme","OK_THEME_VAR_UPGRADED_FROM_GHOST"],{message:`${e.tag} is upgrading ghost variable '${o}' to a real variable. used by ${Object.keys(r.meta[o].values)}`}),r.meta[o]={...r.meta[o],...n,ghost:!1,def:e,component:e.tag};continue}throw t.error("OK_THEME_VAR_ALREADY_REGISTERED",`${e.tag} cannot register '${o}' which was already registered by ${r.meta[o].component}`)}r.meta[o]={...n,default:s,def:e,component:e.tag,values:{}}}if(n&&Object.keys(n).length)for(const[o,s]of Object.entries(n))if(s&&"object"==typeof s)for(const[n,a]of Object.entries(s))r.meta[n]||(t.log.warn(["ok-theme","OK_THEME_VAR_IS_UNDEFINED"],`${e.tag} sets undefined variable ${n}`),r.meta[n]={ghost:!0,component:"__ghost__",values:{}}),r.meta[n].values[e.tag]??={},r.meta[n].values[e.tag][o]=a;r.loadedDefs.add(e.tag)},register(e,o={}){if(r.presets.has(e))throw t.error("OK_THEME_PRESET_ALREADY_REGISTERED",`Preset ${e} already exists`);if(o.define&&"object"!=typeof o.define&&t.log.warn(["ok-theme"],`Preset "${e}" has invalid "define" section`),o.components&&"object"!=typeof o.components&&t.log.warn(["ok-theme"],`Preset "${e}" has invalid "components" section`),o.components)for(const[s,n]of Object.entries(o.components))if("object"==typeof n)for(const[o,a]of Object.entries(n))"object"!=typeof a&&t.log.warn(["ok-theme"],`Preset "${e}" component "${s}" variant "${o}" must be an object`);else t.log.warn(["ok-theme"],`Preset "${e}" component "${s}" must be an object`);r.presets.set(e,o),this._renderPresetToAllHeads(e)},_attachHead(e=t.config.head){a(e),this._renderDefaults({head:e});for(const t of r.presets.keys())this._renderPresetIntoHead(t,e)},init(){if(!this.initialized){this._attachHead(t.config.head);for(const e of t.componentRegistry.cache.values())e.ready&&r._registerDef(e.ready);this._renderDefaults({head:t.config.head}),t.componentRegistry.on("initialized",e=>{e?.plugins?.theme&&r._registerDef(e)}),t.componentRegistry.on("activated-head",(e,t)=>{r._attachHead(t),setTimeout(()=>{for(const e of n)r._renderDefaults({head:e})},0)}),t.componentRegistry.on("unregistered",e=>{const t=e.raw;if(t?.plugins?.theme){r.loadedDefs.delete(t.tag);for(const[e,o]of Object.entries(t.plugins.theme.expose))r.meta[e]&&r.meta[e].def.url===t.url&&t.tag===r.meta[e].def.tag&&delete r.meta[e];setTimeout(()=>{for(const e of n)r._renderDefaults({head:e})},0)}}),this.initialized=!0}}};r.init()},template:"<slot/>"};export{t as default};
@@ -0,0 +1 @@
1
+ const _0x1fea4d=_0x313a;function _0x3d09(){const _0xe87261=['length','endIndex','items','load','TypeQueryVM\x20FTS\x20load\x20error','desc','nextPage','_load','2932006BUgTaV','message','selectedVectorEngine','pageSize','selectedDirection','9jqxEDG','_backStack','ftsScoreMap','push','selectedFtsIndex','selectedIndexStart','__key','restore','selectedIndexEnd','startKey','time','queryMode','application/json','308344dyRZQH','next','numTerms','prevPage','key','pop','busy','maxScore','data','total','json','selectedIndex','value','object','resetPaging','last','10JFPajK','TypeQueryVM\x20load\x20error','4469552mvnEbA','map','statusText','hasPrev','stringify','slice','vectorText','TypeQueryVM\x20vector\x20load\x20error','prefix','/type/','ftsText','and','defineProperty','startIndex','values','_current','error','352STuGUN','POST','_apiBase','function','then','score','query','156522tmPoMA','selectedPrefix','first','vectorChunkMetaMap','vectorLimit','9YTJdUL','ftsMode','vectorScoreMap','chunkHash','hasNext','1109006nzvIUo','1125288uSKGTc','_loadVector','/query','type','_loadFts','/count','API','442230KIXqFM'];_0x3d09=function(){return _0xe87261;};return _0x3d09();}(function(_0x102cd3,_0x7b00a){const _0x30c6f9=_0x313a,_0x48b90b=_0x102cd3();while(!![]){try{const _0x4c1b73=parseInt(_0x30c6f9(0x163))/0x1+parseInt(_0x30c6f9(0x164))/0x2+-parseInt(_0x30c6f9(0x179))/0x3*(-parseInt(_0x30c6f9(0x186))/0x4)+parseInt(_0x30c6f9(0x13f))/0x5*(-parseInt(_0x30c6f9(0x159))/0x6)+-parseInt(_0x30c6f9(0x174))/0x7+-parseInt(_0x30c6f9(0x141))/0x8*(-parseInt(_0x30c6f9(0x15e))/0x9)+-parseInt(_0x30c6f9(0x16b))/0xa*(parseInt(_0x30c6f9(0x152))/0xb);if(_0x4c1b73===_0x7b00a)break;else _0x48b90b['push'](_0x48b90b['shift']());}catch(_0xa5e85f){_0x48b90b['push'](_0x48b90b['shift']());}}}(_0x3d09,0x8c7ca));function _0x313a(_0x5d0aaf,_0x38b5f2){_0x5d0aaf=_0x5d0aaf-0x136;const _0x3d0983=_0x3d09();let _0x313a1f=_0x3d0983[_0x5d0aaf];return _0x313a1f;}export default class t{constructor({type:_0x26358f,pageSize:_0x2c9fa8=0x32,apiBase:_0x33ab40}){const _0x2aa9c2=_0x313a;this[_0x2aa9c2(0x167)]=_0x26358f,this['_apiBaseFn']=_0x2aa9c2(0x155)==typeof _0x33ab40?_0x33ab40:()=>_0x33ab40||__ENV__[_0x2aa9c2(0x16a)],this[_0x2aa9c2(0x18c)]=!0x1,this[_0x2aa9c2(0x16e)]=[],this[_0x2aa9c2(0x14f)]=[],this['total']=0x0,this[_0x2aa9c2(0x183)]=null,this['query']={},this[_0x2aa9c2(0x13a)]=null,this['selectedDirection']=_0x2aa9c2(0x171),this[_0x2aa9c2(0x184)]=_0x2aa9c2(0x149),this[_0x2aa9c2(0x15a)]=void 0x0,this[_0x2aa9c2(0x17e)]=void 0x0,this[_0x2aa9c2(0x181)]=void 0x0,this['selectedFtsIndex']=null,this[_0x2aa9c2(0x14b)]='',this['ftsMode']=_0x2aa9c2(0x14c),this['ftsPrefix']=!0x1,this[_0x2aa9c2(0x17b)]={},this[_0x2aa9c2(0x176)]=null,this[_0x2aa9c2(0x147)]='',this['vectorLimit']=0x14,this[_0x2aa9c2(0x160)]={},this[_0x2aa9c2(0x15c)]={},this[_0x2aa9c2(0x177)]=_0x2c9fa8,this[_0x2aa9c2(0x162)]=!0x1,this['hasPrev']=!0x1,this[_0x2aa9c2(0x150)]=null,this[_0x2aa9c2(0x17a)]=[];}get['_apiBase'](){return this['_apiBaseFn']();}[_0x1fea4d(0x13d)](){const _0x4026fb=_0x1fea4d;this[_0x4026fb(0x150)]=null,this[_0x4026fb(0x17a)]=[],this['hasNext']=!0x1,this['hasPrev']=!0x1;}[_0x1fea4d(0x172)](){const _0x1c4199=_0x1fea4d;if(!this[_0x1c4199(0x18c)]&&this['hasNext'])return this['_load'](_0x1c4199(0x187));}[_0x1fea4d(0x189)](){const _0x4e001f=_0x1fea4d;if(this[_0x4e001f(0x18c)]||!this[_0x4e001f(0x144)])return;const _0x3c8d26=this[_0x4e001f(0x17a)][_0x4e001f(0x18b)]();return _0x3c8d26?(this[_0x4e001f(0x150)]=_0x3c8d26,this[_0x4e001f(0x173)]('restore')):void 0x0;}async[_0x1fea4d(0x16f)](){const _0xe03c8d=_0x1fea4d;return this['resetPaging'](),this[_0xe03c8d(0x17d)]?this[_0xe03c8d(0x168)]():this[_0xe03c8d(0x176)]?this[_0xe03c8d(0x165)]():this['_load'](null);}async[_0x1fea4d(0x168)](){const _0x115e20=_0x1fea4d;if(this[_0x115e20(0x167)]&&this[_0x115e20(0x17d)]){this[_0x115e20(0x18c)]=!0x0;try{const _0x31da15=await fetch(this['_apiBase']+_0x115e20(0x14a)+this[_0x115e20(0x167)]+'/query',{'method':_0x115e20(0x153),'headers':{'Content-Type':'application/json'},'body':JSON['stringify']({'filter':this[_0x115e20(0x158)],'options':{'fts':{'name':this[_0x115e20(0x17d)],'query':this['ftsText'],'mode':this[_0x115e20(0x15f)],'prefix':this['ftsPrefix'],'limit':this['pageSize']}}})});if(!_0x31da15['ok'])throw new Error(_0x31da15[_0x115e20(0x143)]);const {data:_0x38a7fa,meta:_0x1aabfe}=await _0x31da15[_0x115e20(0x139)](),_0xb296d9=_0x38a7fa??[];this['items']=_0xb296d9,this[_0x115e20(0x17b)]={},this[_0x115e20(0x14f)]=_0xb296d9[_0x115e20(0x142)](_0x37f353=>(e(_0x37f353[_0x115e20(0x13b)],_0x37f353['key']),null!=_0x37f353['score']&&(this[_0x115e20(0x17b)][_0x37f353[_0x115e20(0x18a)]]={'score':_0x37f353[_0x115e20(0x157)],'numTerms':_0x37f353[_0x115e20(0x188)],'maxScore':_0x37f353[_0x115e20(0x136)]}),_0x37f353['value'])),this[_0x115e20(0x162)]=!0x1,this[_0x115e20(0x144)]=!0x1,this[_0x115e20(0x150)]=null,this['_backStack']=[],this[_0x115e20(0x183)]=_0x1aabfe?.[_0x115e20(0x183)]??null,this[_0x115e20(0x138)]=_0xb296d9['length'];}catch(_0xc13355){console[_0x115e20(0x151)](_0x115e20(0x170),_0xc13355);}finally{this['busy']=!0x1;}}}async[_0x1fea4d(0x165)](){const _0x28e333=_0x1fea4d;if(this[_0x28e333(0x167)]&&this[_0x28e333(0x176)]){this[_0x28e333(0x18c)]=!0x0;try{const _0x264ec2=await fetch(this['_apiBase']+_0x28e333(0x14a)+this[_0x28e333(0x167)]+_0x28e333(0x166),{'method':_0x28e333(0x153),'headers':{'Content-Type':_0x28e333(0x185)},'body':JSON[_0x28e333(0x145)]({'filter':this[_0x28e333(0x158)],'options':{'vectorSearch':{'name':this[_0x28e333(0x176)],'query':this['vectorText'],'limit':this[_0x28e333(0x15d)]}}})});if(!_0x264ec2['ok'])throw new Error((await _0x264ec2[_0x28e333(0x139)]())?.['error']?.[_0x28e333(0x175)]||_0x264ec2['statusText']);const {data:_0x40292b,meta:_0x4262dc}=await _0x264ec2[_0x28e333(0x139)](),_0x4b9f1a=_0x40292b??[];this[_0x28e333(0x16e)]=_0x4b9f1a,this[_0x28e333(0x160)]={},this['vectorChunkMetaMap']={},this[_0x28e333(0x14f)]=_0x4b9f1a['map'](_0x41e1bb=>(e(_0x41e1bb['value'],_0x41e1bb['key']),null!=_0x41e1bb[_0x28e333(0x157)]&&(this['vectorScoreMap'][_0x41e1bb[_0x28e333(0x18a)]]=_0x41e1bb['score']),_0x41e1bb[_0x28e333(0x161)]&&(this[_0x28e333(0x15c)][_0x41e1bb[_0x28e333(0x18a)]]={'chunkHash':_0x41e1bb['chunkHash'],..._0x41e1bb['chunk']??{}}),_0x41e1bb['value'])),this['hasNext']=!0x1,this[_0x28e333(0x144)]=!0x1,this[_0x28e333(0x150)]=null,this[_0x28e333(0x17a)]=[],this[_0x28e333(0x183)]=_0x4262dc?.['time']??null,this[_0x28e333(0x138)]=_0x4b9f1a[_0x28e333(0x16c)];}catch(_0x2c40d6){console[_0x28e333(0x151)](_0x28e333(0x148),_0x2c40d6);}finally{this['busy']=!0x1;}}}async['_load'](_0x5ad338){const _0x3421c0=_0x1fea4d;if(!this[_0x3421c0(0x167)])return;this[_0x3421c0(0x18c)]=!0x0,this[_0x3421c0(0x17b)]={},this['vectorScoreMap']={},this[_0x3421c0(0x15c)]={};const _0x498b20='desc'===this[_0x3421c0(0x178)];this[_0x3421c0(0x13a)];try{const _0x337568={'index':this[_0x3421c0(0x13a)],'reverse':_0x498b20,'limit':this['pageSize']+0x1};if(this[_0x3421c0(0x13a)]&&(_0x3421c0(0x149)===this['queryMode']?void 0x0!==this[_0x3421c0(0x15a)]&&(_0x337568[_0x3421c0(0x149)]=this[_0x3421c0(0x15a)]):(void 0x0!==this[_0x3421c0(0x17e)]&&(_0x337568[_0x3421c0(0x14e)]=this['selectedIndexStart']),void 0x0!==this[_0x3421c0(0x181)]&&(_0x337568[_0x3421c0(0x16d)]=this[_0x3421c0(0x181)]))),_0x3421c0(0x187)===_0x5ad338&&this[_0x3421c0(0x150)]){const _0x45cbc1=this[_0x3421c0(0x150)][_0x3421c0(0x13e)];_0x337568[_0x3421c0(0x182)]=_0x45cbc1,this[_0x3421c0(0x17a)][_0x3421c0(0x17c)](this[_0x3421c0(0x150)]);}if(_0x3421c0(0x180)===_0x5ad338&&this[_0x3421c0(0x150)]){const _0x41d56b=this[_0x3421c0(0x150)][_0x3421c0(0x15b)];_0x337568[_0x3421c0(0x182)]=_0x41d56b;}const _0x1650b0=await fetch(this[_0x3421c0(0x154)]+_0x3421c0(0x14a)+this[_0x3421c0(0x167)]+'/query',{'method':'POST','headers':{'Content-Type':'application/json'},'body':JSON[_0x3421c0(0x145)]({'filter':this['query'],'options':_0x337568})});if(!_0x1650b0['ok'])throw new Error(_0x1650b0[_0x3421c0(0x143)]);const {data:_0x232cc7,meta:_0x2aebe2}=await _0x1650b0[_0x3421c0(0x139)](),_0x549994=_0x232cc7??[];this[_0x3421c0(0x162)]=_0x549994[_0x3421c0(0x16c)]>this[_0x3421c0(0x177)];const _0x3f15d3=_0x549994[_0x3421c0(0x146)](0x0,this['pageSize']);this[_0x3421c0(0x16e)]=_0x3f15d3,this[_0x3421c0(0x14f)]=_0x3f15d3[_0x3421c0(0x142)](_0x5090db=>(e(_0x5090db[_0x3421c0(0x13b)],_0x5090db[_0x3421c0(0x18a)]),_0x5090db[_0x3421c0(0x13b)]));const _0x2f7809=_0x3f15d3[0x0],_0x3678eb=_0x3f15d3[_0x3f15d3[_0x3421c0(0x16c)]-0x1],_0x85e2c7=_0x2f4172=>_0x2f4172?.[_0x3421c0(0x18a)];this[_0x3421c0(0x150)]={'first':_0x85e2c7(_0x2f7809),'last':_0x85e2c7(_0x3678eb)},this[_0x3421c0(0x144)]=this[_0x3421c0(0x17a)][_0x3421c0(0x16c)]>0x0,this['time']=_0x2aebe2?.[_0x3421c0(0x183)]??null,this['total']='…';const _0x91838e={'index':this['selectedIndex'],'reverse':_0x498b20};this['selectedIndex']&&('prefix'===this[_0x3421c0(0x184)]?void 0x0!==this[_0x3421c0(0x15a)]&&(_0x91838e['prefix']=this[_0x3421c0(0x15a)]):(void 0x0!==this['selectedIndexStart']&&(_0x91838e['startIndex']=this[_0x3421c0(0x17e)]),void 0x0!==this[_0x3421c0(0x181)]&&(_0x91838e[_0x3421c0(0x16d)]=this['selectedIndexEnd']))),fetch(this[_0x3421c0(0x154)]+_0x3421c0(0x14a)+this['type']+_0x3421c0(0x169),{'method':_0x3421c0(0x153),'headers':{'Content-Type':_0x3421c0(0x185)},'body':JSON[_0x3421c0(0x145)]({'filter':this[_0x3421c0(0x158)],'options':_0x91838e})})[_0x3421c0(0x156)](_0x274718=>_0x274718['json']())['then'](_0x4a3806=>this[_0x3421c0(0x138)]=_0x4a3806[_0x3421c0(0x137)])['catch'](_0x2c2456=>this[_0x3421c0(0x138)]=_0x2c2456[_0x3421c0(0x175)]);}catch(_0x2e2167){console['error'](_0x3421c0(0x140),_0x2e2167);}finally{this['busy']=!0x1;}}}function e(_0x49b508,_0x26d1e3){const _0x2221f1=_0x1fea4d;_0x49b508&&_0x2221f1(0x13c)==typeof _0x49b508&&_0x49b508[_0x2221f1(0x17f)]!==_0x26d1e3&&Object[_0x2221f1(0x14d)](_0x49b508,_0x2221f1(0x17f),{'value':_0x26d1e3,'enumerable':!0x1,'configurable':!0x1,'writable':!0x1});}
@@ -0,0 +1,130 @@
1
+ import type {
2
+ OKDBPrimaryKey,
3
+ OKDBIndexKey,
4
+ OKDBFilter,
5
+ OKDBRangeOptions,
6
+ OKDBQueryOptions,
7
+ OKDBGeoQueryOptions,
8
+ OKDBFtsQueryOptions,
9
+ OKDBWriteOptions,
10
+ OKDBEntry,
11
+ OKDBIndexEntry,
12
+ OKDBChangeEntry,
13
+ OKDBEnvironmentConfig,
14
+ OKDBIndexDefinition,
15
+ OKDBTypeSchema,
16
+ OKDBCompactResult,
17
+ OKDBTtlListOptions,
18
+ } from './options';
19
+
20
+ import type { OKDBQueue } from './features/queue';
21
+ import type { OKDBFiles } from './features/files';
22
+ import type { OKDBTimeMachine } from './features/time-machine';
23
+ import type { OKDBEngines } from './features/engines';
24
+ import type { OKDBPipelines } from './features/pipelines';
25
+ import type { OKDBFunctions } from './features/functions';
26
+ import type { OKDBViews } from './features/views';
27
+
28
+ /** Transaction object for batching writes without auto-commit. */
29
+ export interface OKDBTransaction {
30
+ put(type: string, key: OKDBPrimaryKey, value: unknown, options?: OKDBWriteOptions): void;
31
+ update(type: string, key: OKDBPrimaryKey, value: unknown, options?: OKDBWriteOptions): void;
32
+ patch(type: string, key: OKDBPrimaryKey, patch: Record<string, unknown>, options?: OKDBWriteOptions): void;
33
+ create(type: string, key: OKDBPrimaryKey, value: unknown, options?: OKDBWriteOptions): void;
34
+ remove(type: string, key: OKDBPrimaryKey, options?: Pick<OKDBWriteOptions, 'ifVersion'>): void;
35
+ commit(): Promise<void>;
36
+ }
37
+
38
+ /**
39
+ * An OKDB environment — a named LMDB database within a single OKDB instance.
40
+ * All data operations are scoped to this environment.
41
+ * Returned by `okdb.env(name)` and `okdb.default`.
42
+ */
43
+ export interface OKDBEnvironment {
44
+ readonly name: string;
45
+ readonly path: string;
46
+ readonly config: OKDBEnvironmentConfig;
47
+ readonly id: string;
48
+
49
+ // ── Per-env subsystems ────────────────────────────────────────────────────
50
+ queue: OKDBQueue;
51
+ files: OKDBFiles;
52
+ timeMachine?: OKDBTimeMachine;
53
+ engines: OKDBEngines;
54
+ pipelines: OKDBPipelines;
55
+ functions: OKDBFunctions;
56
+ views: OKDBViews;
57
+
58
+ // ── Transactions ──────────────────────────────────────────────────────────
59
+ transaction(options?: Record<string, unknown>): OKDBTransaction;
60
+ txn<T = void>(work: (txn: OKDBTransaction) => T | Promise<T>, options?: Record<string, unknown>): Promise<T>;
61
+
62
+ // ── CRUD ──────────────────────────────────────────────────────────────────
63
+ put(type: string, key: OKDBPrimaryKey, value: unknown, options?: OKDBWriteOptions): Promise<void>;
64
+ update(type: string, key: OKDBPrimaryKey, value: unknown, options?: OKDBWriteOptions): Promise<void>;
65
+ patch(type: string, key: OKDBPrimaryKey, patch: Record<string, unknown>, options?: OKDBWriteOptions): Promise<void>;
66
+ create(type: string, key: OKDBPrimaryKey, value: unknown, options?: OKDBWriteOptions): Promise<void>;
67
+ remove(type: string, key: OKDBPrimaryKey, options?: Pick<OKDBWriteOptions, 'ifVersion'>): Promise<void>;
68
+
69
+ // ── Read ──────────────────────────────────────────────────────────────────
70
+ get<T = unknown>(type: string, key: OKDBPrimaryKey, options?: Record<string, unknown>): T | undefined;
71
+ getMany<T = unknown>(type: string, keys: OKDBPrimaryKey[], options?: Record<string, unknown>): (T | undefined)[];
72
+ getEntry<T = unknown>(type: string, key: OKDBPrimaryKey, options?: Record<string, unknown>): OKDBEntry<T> | undefined;
73
+ getRange<T = unknown>(type: string, options?: OKDBRangeOptions): Iterable<OKDBEntry<T>>;
74
+ getValues<T = unknown>(type: string, options?: OKDBRangeOptions): Iterable<T>;
75
+ getKeys(type: string, options?: OKDBRangeOptions): Iterable<OKDBPrimaryKey>;
76
+ getCount(type: string, options?: OKDBRangeOptions): number;
77
+ getByPrefix<T = unknown>(type: string, prefix: OKDBPrimaryKey, options?: OKDBRangeOptions): Iterable<OKDBEntry<T>>;
78
+
79
+ // ── Index queries ─────────────────────────────────────────────────────────
80
+ getIndex<T = unknown>(type: string, index: string[], options?: OKDBQueryOptions): Iterable<OKDBIndexEntry<T>>;
81
+ byIndex<T = unknown>(type: string, index: string[], options?: OKDBQueryOptions): Iterable<OKDBIndexEntry<T>>;
82
+ query<T = unknown>(type: string, filter: OKDBFilter, options?: OKDBQueryOptions): Iterable<OKDBIndexEntry<T>>;
83
+ geoQuery<T = unknown>(type: string, field: string, options: OKDBGeoQueryOptions): Iterable<OKDBEntry<T>>;
84
+ ftsQuery<T = unknown>(type: string, name: string, text: string, filter?: OKDBFilter, options?: OKDBFtsQueryOptions): Iterable<OKDBEntry<T>>;
85
+
86
+ // ── Type management ───────────────────────────────────────────────────────
87
+ registerType(type: string, timestamp?: number): Promise<void>;
88
+ ensureType(type: string, options?: { timestamp?: number; indexes?: Array<string[] | OKDBIndexDefinition> }): Promise<void>;
89
+ hasType(type: string): boolean;
90
+ dropType(type: string, timestamp?: number): Promise<void>;
91
+
92
+ // ── Schema ────────────────────────────────────────────────────────────────
93
+ setSchema(type: string, schema: OKDBTypeSchema): Promise<void>;
94
+ getSchema(type: string): OKDBTypeSchema | null;
95
+ dropSchema(type: string): Promise<void>;
96
+
97
+ // ── Index management ──────────────────────────────────────────────────────
98
+ registerIndex(type: string, index: string[], options?: { type?: 'geo'; precision?: number; unique?: boolean; timestamp?: number }): Promise<void>;
99
+ hasIndex(type: string, index: string[]): boolean;
100
+ dropIndex(type: string, index: string[], timestamp?: number): Promise<void>;
101
+ resetIndex(type: string, index: string[], clear?: boolean): Promise<void>;
102
+ indexReady(type: string, index: string[]): Promise<boolean>;
103
+ getIndexStatus(type: string, index: string[]): string;
104
+ getUniqueViolations(type: string, index: string[]): unknown[];
105
+ hasUniqueViolations(type: string, index: string[]): boolean;
106
+ getUniqueViolation(type: string, index: string[], key: OKDBPrimaryKey): unknown;
107
+
108
+ // ── Change tracking ───────────────────────────────────────────────────────
109
+ getClock(type?: string, options?: Record<string, unknown>): number;
110
+ getChanges(type?: string, from?: number, to?: number, options?: Record<string, unknown>): Iterable<OKDBChangeEntry>;
111
+
112
+ // ── TTL ───────────────────────────────────────────────────────────────────
113
+ setTTL(type: string, key: OKDBPrimaryKey, ttlMs: number): Promise<void>;
114
+ getTTL(type: string, key: OKDBPrimaryKey): number | null;
115
+ clearTTL(type: string, key: OKDBPrimaryKey): Promise<void>;
116
+ sweepExpiredTTL(batchSize?: number): Promise<number>;
117
+ listTTL(options?: OKDBTtlListOptions): Iterable<{ type: string; key: OKDBPrimaryKey; expiresAt: number }>;
118
+ ttlStats(type?: string): unknown;
119
+ setDefaultTTL(type: string, ttlMs: number): Promise<void>;
120
+ getDefaultTTL(type: string): number | null;
121
+ clearDefaultTTL(type: string): Promise<void>;
122
+
123
+ // ── Utilities ─────────────────────────────────────────────────────────────
124
+ count(iterable: Iterable<unknown>): number;
125
+ range(iterable: Iterable<unknown>): Generator<unknown>;
126
+ now(): number;
127
+ getResolvedOptions(): { durability: string; lmdbOptions: unknown; warnings: string[] };
128
+ compact(): Promise<OKDBCompactResult>;
129
+ refreshReadTxn(): void;
130
+ }
@@ -0,0 +1,98 @@
1
+ import type { OKDBPrimaryKey } from './options';
2
+
3
+ export declare class OKDBError extends Error {
4
+ name: string;
5
+ code: string;
6
+ details: Record<string, unknown>;
7
+ cause?: Error;
8
+ constructor(message: string, code: string, details?: Record<string, unknown>);
9
+ }
10
+
11
+ export declare class OKDBVersionMismatchError extends OKDBError {
12
+ constructor(type: string, key: OKDBPrimaryKey, expectedVersion: number, actualVersion: number);
13
+ }
14
+
15
+ export declare class OKDBNotFoundError extends OKDBError {
16
+ constructor(type: string, key: OKDBPrimaryKey);
17
+ }
18
+
19
+ export declare class OKDBAlreadyExistsError extends OKDBError {
20
+ constructor(type: string, key: OKDBPrimaryKey);
21
+ }
22
+
23
+ export declare class OKDBInvalidIndexKeyError extends OKDBError {
24
+ constructor(index: string, key: unknown);
25
+ }
26
+
27
+ export declare class OKDBInvalidPrimaryKeyError extends OKDBError {
28
+ constructor(key: unknown);
29
+ }
30
+
31
+ export declare class OKDBTypeNotRegisteredError extends OKDBError {
32
+ constructor(type: string);
33
+ }
34
+
35
+ export declare class OKDBTypeAlreadyRegisteredError extends OKDBError {
36
+ constructor(type: string);
37
+ }
38
+
39
+ export declare class OKDBIndexNotRegisteredError extends OKDBError {
40
+ constructor(type: string, index: string);
41
+ }
42
+
43
+ export declare class OKDBIndexAlreadyRegisteredError extends OKDBError {
44
+ constructor(type: string, index: string);
45
+ }
46
+
47
+ export declare class OKDBInvalidValueError extends OKDBError {
48
+ constructor(message: string, details?: Record<string, unknown>);
49
+ }
50
+
51
+ export declare class OKDBUniqueConstraintError extends OKDBError {
52
+ constructor(
53
+ type: string,
54
+ index: string,
55
+ indexKey: unknown,
56
+ existingKey: OKDBPrimaryKey,
57
+ conflictingKey: OKDBPrimaryKey,
58
+ );
59
+ }
60
+
61
+ export declare class OKDBSchemaValidationError extends OKDBError {
62
+ type: string;
63
+ key: OKDBPrimaryKey;
64
+ errors: unknown[];
65
+ constructor(type: string, key: OKDBPrimaryKey, errors: unknown[]);
66
+ }
67
+
68
+ export declare class OKDBSchemaCollectionError extends OKDBError {
69
+ type: string;
70
+ failures: unknown[];
71
+ constructor(type: string, failures: unknown[]);
72
+ }
73
+
74
+ export declare class OKDBForeignKeyError extends OKDBError {
75
+ sourceType: string;
76
+ sourceKey: OKDBPrimaryKey;
77
+ fieldPath: string;
78
+ targetType: string;
79
+ targetKey: OKDBPrimaryKey;
80
+ constructor(
81
+ sourceType: string,
82
+ sourceKey: OKDBPrimaryKey,
83
+ fieldPath: string,
84
+ targetType: string,
85
+ targetKey: OKDBPrimaryKey,
86
+ );
87
+ }
88
+
89
+ export declare class OKDBForeignKeyDeleteError extends OKDBError {
90
+ targetType: string;
91
+ targetKey: OKDBPrimaryKey;
92
+ references: unknown[];
93
+ constructor(targetType: string, targetKey: OKDBPrimaryKey, references: unknown[]);
94
+ }
95
+
96
+ export declare class OKDBIndexHasConsumersError extends OKDBError {
97
+ constructor(type: string, index: string, usedBy: Array<{ kind: string; name: string }>);
98
+ }
@@ -0,0 +1,4 @@
1
+ export declare class OKDBAdmin {
2
+ /** Registers admin UI HTTP routes on the parent OKDB's HTTP server. */
3
+ start(): void;
4
+ }
@@ -0,0 +1,18 @@
1
+ export interface OKDBApiSchemaField {
2
+ name: string;
3
+ types: string[];
4
+ }
5
+
6
+ export interface OKDBApiTypeSchema {
7
+ type: string;
8
+ fields: OKDBApiSchemaField[];
9
+ indexes: string[][];
10
+ count: number;
11
+ }
12
+
13
+ export declare class OKDBApi {
14
+ /** Registers REST API HTTP routes on the parent OKDB's HTTP server. */
15
+ start(): void;
16
+ /** Sample documents from a type and infer a field schema. */
17
+ inferSchema(type: string, limit?: number): Promise<OKDBApiTypeSchema>;
18
+ }
@@ -0,0 +1,31 @@
1
+ export interface OKDBToken {
2
+ id: string;
3
+ sub: string;
4
+ roles: string[];
5
+ createdAt: number;
6
+ expiresAt: number | null;
7
+ [key: string]: unknown;
8
+ }
9
+
10
+ export interface OKDBAuthContext {
11
+ authenticated: boolean;
12
+ sub?: string;
13
+ roles?: string[];
14
+ token?: OKDBToken;
15
+ [key: string]: unknown;
16
+ }
17
+
18
+ export interface OKDBLoginResult {
19
+ token: string;
20
+ expiresAt: number;
21
+ }
22
+
23
+ export declare class OKDBAuth {
24
+ start(systemEnv: unknown, options?: Record<string, unknown>): Promise<void>;
25
+ authenticateRequest(req: unknown): Promise<OKDBAuthContext>;
26
+ login(username: string, password: string): Promise<OKDBLoginResult>;
27
+ createToken(options: { sub: string; roles?: string[]; ttl?: number }): Promise<string>;
28
+ revokeToken(tokenId: string): Promise<boolean>;
29
+ listTokens(options?: { limit?: number }): Promise<OKDBToken[]>;
30
+ getToken(tokenId: string): OKDBToken | null;
31
+ }
@@ -0,0 +1,39 @@
1
+ export interface OKDBEmbeddingsPipeline {
2
+ name: string;
3
+ sourceType: string;
4
+ sourceField: string;
5
+ model: string;
6
+ algorithm: string;
7
+ [key: string]: unknown;
8
+ }
9
+
10
+ export interface OKDBEmbeddingsSearchResult {
11
+ key: string | number;
12
+ score: number;
13
+ value?: unknown;
14
+ }
15
+
16
+ export interface OKDBEmbeddingsSearchOptions {
17
+ limit?: number;
18
+ filter?: Record<string, unknown>;
19
+ includeValues?: boolean;
20
+ }
21
+
22
+ export interface OKDBEmbeddingsAddPipelineOptions {
23
+ sourceField: string;
24
+ model: string;
25
+ algorithm?: string;
26
+ dims?: number;
27
+ [key: string]: unknown;
28
+ }
29
+
30
+ export declare class OKDBEmbeddings {
31
+ addPipeline(name: string, sourceType: string, options: OKDBEmbeddingsAddPipelineOptions): Promise<OKDBEmbeddingsPipeline>;
32
+ removePipeline(name: string, sourceType: string): Promise<void>;
33
+ getPipeline(name: string, sourceType: string): OKDBEmbeddingsPipeline | null;
34
+ listPipelines(sourceType?: string): OKDBEmbeddingsPipeline[];
35
+ search(name: string, sourceType: string, query: string | number[], options?: OKDBEmbeddingsSearchOptions): Promise<OKDBEmbeddingsSearchResult[]>;
36
+ embed(model: string, text: string | string[]): Promise<number[] | number[][]>;
37
+ start(): Promise<void>;
38
+ stop(): Promise<void>;
39
+ }
@@ -0,0 +1,23 @@
1
+ export interface OKDBEngineDefinition {
2
+ name: string;
3
+ source: string;
4
+ affinity?: string[];
5
+ [key: string]: unknown;
6
+ }
7
+
8
+ export interface OKDBEngineRunOptions {
9
+ args?: unknown[];
10
+ timeout?: number;
11
+ env?: string;
12
+ [key: string]: unknown;
13
+ }
14
+
15
+ export declare class OKDBEngines {
16
+ register(definition: OKDBEngineDefinition): Promise<void>;
17
+ unregister(name: string): Promise<void>;
18
+ run(name: string, options?: OKDBEngineRunOptions): Promise<unknown>;
19
+ list(): OKDBEngineDefinition[];
20
+ start(): Promise<void>;
21
+ stop(): Promise<void>;
22
+ bootSyncedEngines(): Promise<void>;
23
+ }
@@ -0,0 +1,29 @@
1
+ import type { Readable } from 'stream';
2
+ import type { ReadStream } from 'fs';
3
+
4
+ export interface OKDBFileRecord {
5
+ id: string;
6
+ hash: string;
7
+ size: number;
8
+ mime: string;
9
+ path: string;
10
+ createdAt: number;
11
+ }
12
+
13
+ export interface OKDBUploadOptions {
14
+ id: string;
15
+ stream: Readable;
16
+ mime?: string;
17
+ path?: string;
18
+ txn?: unknown;
19
+ }
20
+
21
+ export declare class OKDBFiles {
22
+ upload(options: OKDBUploadOptions): Promise<OKDBFileRecord>;
23
+ stream(id: string): Promise<{ stream: ReadStream; record: OKDBFileRecord }>;
24
+ delete(id: string): Promise<boolean>;
25
+ get(id: string): OKDBFileRecord | null;
26
+ list(options?: { limit?: number; path?: string }): Iterable<OKDBFileRecord>;
27
+ start(): Promise<void>;
28
+ stop(): void;
29
+ }
@@ -0,0 +1,25 @@
1
+ export interface OKDBFtsIndex {
2
+ name: string;
3
+ type: string;
4
+ fields: string[];
5
+ [key: string]: unknown;
6
+ }
7
+
8
+ export interface OKDBFtsQueryResult {
9
+ key: string | number;
10
+ score: number;
11
+ value?: unknown;
12
+ }
13
+
14
+ export interface OKDBFtsRegisterOptions {
15
+ fields?: string[];
16
+ [key: string]: unknown;
17
+ }
18
+
19
+ export declare class OKDBFts {
20
+ registerIndex(type: string, name: string, options?: OKDBFtsRegisterOptions): Promise<void>;
21
+ dropIndex(type: string, name: string): Promise<void>;
22
+ hasIndex(type: string, name: string): boolean;
23
+ query(type: string, name: string, text: string, filter?: Record<string, unknown>, options?: { limit?: number; offset?: number }): Iterable<OKDBFtsQueryResult>;
24
+ drain(): Promise<void>;
25
+ }
@@ -0,0 +1,23 @@
1
+ export interface OKDBFunctionDefinition {
2
+ name: string;
3
+ source: string;
4
+ runtime?: string;
5
+ timeout?: number;
6
+ [key: string]: unknown;
7
+ }
8
+
9
+ export interface OKDBFunctionCallOptions {
10
+ timeout?: number;
11
+ env?: string;
12
+ args?: unknown[];
13
+ [key: string]: unknown;
14
+ }
15
+
16
+ export declare class OKDBFunctions {
17
+ register(definition: OKDBFunctionDefinition): Promise<void>;
18
+ unregister(name: string): Promise<void>;
19
+ call(name: string, args?: unknown[], options?: OKDBFunctionCallOptions): Promise<unknown>;
20
+ get(name: string): OKDBFunctionDefinition | null;
21
+ list(): OKDBFunctionDefinition[];
22
+ stop(): Promise<void>;
23
+ }
@@ -0,0 +1,17 @@
1
+ export interface OKDBMcpTool {
2
+ name: string;
3
+ description?: string;
4
+ inputSchema?: Record<string, unknown>;
5
+ [key: string]: unknown;
6
+ }
7
+
8
+ export interface OKDBMcpOptions {
9
+ tools?: OKDBMcpTool[];
10
+ [key: string]: unknown;
11
+ }
12
+
13
+ export declare class OKDBMcp {
14
+ configure(options: OKDBMcpOptions): void;
15
+ listTools(): OKDBMcpTool[];
16
+ callTool(name: string, input: unknown): Promise<unknown>;
17
+ }