@lapis-notes/api 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/LICENSE.md +4 -0
- package/README.md +43 -0
- package/dist/__tests__/data-adapter-conformance.js +205 -0
- package/dist/__tests__/lapis-runtime-manifest.js +32 -0
- package/dist/__tests__/svelte-internal-client.d.ts +3 -0
- package/dist/agent-result-views.d.ts +52 -0
- package/dist/agent-result-views.js +89 -0
- package/dist/agent-skills.d.ts +99 -0
- package/dist/agent-skills.js +182 -0
- package/dist/agent-tools.d.ts +92 -0
- package/dist/agent-tools.js +139 -0
- package/dist/app-database-host.d.ts +4 -0
- package/dist/app-database-host.js +4 -0
- package/dist/app-shell-plugin-persistence.d.ts +15 -0
- package/dist/app-shell-plugin-persistence.js +34 -0
- package/dist/app-url.d.ts +54 -0
- package/dist/app-url.js +269 -0
- package/dist/application-compatibility.d.ts +31 -0
- package/dist/application-compatibility.js +64 -0
- package/dist/application-state.svelte.d.ts +14 -0
- package/dist/application-state.svelte.js +30 -0
- package/dist/assets/lapis-logo.svg +471 -0
- package/dist/bases.d.ts +281 -0
- package/dist/bases.js +475 -0
- package/dist/cache.svelte.d.ts +569 -0
- package/dist/cache.svelte.js +1433 -0
- package/dist/command.svelte.d.ts +337 -0
- package/dist/command.svelte.js +571 -0
- package/dist/compat.d.ts +29 -0
- package/dist/compat.js +30 -0
- package/dist/components/configuration/configuration.css +199 -0
- package/dist/components/configuration/date-setting.svelte +71 -0
- package/dist/components/configuration/date-setting.svelte.d.ts +8 -0
- package/dist/components/configuration/list-setting.svelte +128 -0
- package/dist/components/configuration/list-setting.svelte.d.ts +13 -0
- package/dist/components/configuration/object-array-row-grip.svelte +78 -0
- package/dist/components/configuration/object-array-row-grip.svelte.d.ts +9 -0
- package/dist/components/configuration/object-array-row.svelte +163 -0
- package/dist/components/configuration/object-array-row.svelte.d.ts +19 -0
- package/dist/components/configuration/object-array-setting.svelte +196 -0
- package/dist/components/configuration/object-array-setting.svelte.d.ts +15 -0
- package/dist/components/configuration/object-array-table-dnd.d.ts +8 -0
- package/dist/components/configuration/object-array-table-dnd.js +10 -0
- package/dist/components/configuration/object-array-utils.d.ts +11 -0
- package/dist/components/configuration/object-array-utils.js +103 -0
- package/dist/components/configuration/object-grid-setting.svelte +79 -0
- package/dist/components/configuration/object-grid-setting.svelte.d.ts +10 -0
- package/dist/components/configuration/object-map-row.svelte +147 -0
- package/dist/components/configuration/object-map-row.svelte.d.ts +15 -0
- package/dist/components/configuration/object-map-setting.svelte +137 -0
- package/dist/components/configuration/object-map-setting.svelte.d.ts +14 -0
- package/dist/components/configuration/object-map-types.d.ts +5 -0
- package/dist/components/configuration/object-map-types.js +1 -0
- package/dist/components/configuration/options-combobox-setting.svelte +129 -0
- package/dist/components/configuration/options-combobox-setting.svelte.d.ts +12 -0
- package/dist/components/copy-button/button.svelte +93 -0
- package/dist/components/copy-button/button.svelte.d.ts +13 -0
- package/dist/components/copy-button/index.d.ts +2 -0
- package/dist/components/copy-button/index.js +2 -0
- package/dist/components/editor/editor.css +565 -0
- package/dist/components/editor/editor.d.ts +33 -0
- package/dist/components/editor/editor.js +132 -0
- package/dist/components/editor/editor.svelte +176 -0
- package/dist/components/editor/editor.svelte.d.ts +15 -0
- package/dist/components/editor/embedded-editor-surface.d.ts +12 -0
- package/dist/components/editor/embedded-editor-surface.js +22 -0
- package/dist/components/editor/embedded-editor-surface.svelte +115 -0
- package/dist/components/editor/embedded-editor-surface.svelte.d.ts +17 -0
- package/dist/components/editor/extensions/autocomplete/index.d.ts +2 -0
- package/dist/components/editor/extensions/autocomplete/index.js +2 -0
- package/dist/components/editor/extensions/autocomplete/lapis-code-mirror-autocomplete.d.ts +16 -0
- package/dist/components/editor/extensions/autocomplete/lapis-code-mirror-autocomplete.js +34 -0
- package/dist/components/editor/extensions/autocomplete/vault-completion-sources.d.ts +27 -0
- package/dist/components/editor/extensions/autocomplete/vault-completion-sources.js +55 -0
- package/dist/components/editor/extensions/class-highlighter/index.d.ts +1 -0
- package/dist/components/editor/extensions/class-highlighter/index.js +47 -0
- package/dist/components/editor/extensions/fold-gutter/index.d.ts +8 -0
- package/dist/components/editor/extensions/fold-gutter/index.js +40 -0
- package/dist/components/editor/extensions/gutter-line-style-sync/index.d.ts +2 -0
- package/dist/components/editor/extensions/gutter-line-style-sync/index.js +118 -0
- package/dist/components/editor/extensions/lint/index.d.ts +4 -0
- package/dist/components/editor/extensions/lint/index.js +4 -0
- package/dist/components/editor/extensions/lint/lapis-code-mirror-lint.d.ts +26 -0
- package/dist/components/editor/extensions/lint/lapis-code-mirror-lint.js +101 -0
- package/dist/components/editor/extensions/lint/lapis-lint-diagnostic-helpers.d.ts +8 -0
- package/dist/components/editor/extensions/lint/lapis-lint-diagnostic-helpers.js +7 -0
- package/dist/components/editor/extensions/lint/lapis-lint-diagnostic.d.ts +20 -0
- package/dist/components/editor/extensions/lint/lapis-lint-diagnostic.js +47 -0
- package/dist/components/editor/extensions/lint/lapis-lint-hover-tooltip.d.ts +9 -0
- package/dist/components/editor/extensions/lint/lapis-lint-hover-tooltip.js +373 -0
- package/dist/components/editor/extensions/lint/lapis-lint-inline-widget.d.ts +31 -0
- package/dist/components/editor/extensions/lint/lapis-lint-inline-widget.js +191 -0
- package/dist/components/editor/extensions/lint/lapis-lint-tooltip.svelte +176 -0
- package/dist/components/editor/extensions/lint/lapis-lint-tooltip.svelte.d.ts +15 -0
- package/dist/components/editor/extensions/lint/lint-tooltip-actions.d.ts +11 -0
- package/dist/components/editor/extensions/lint/lint-tooltip-actions.js +21 -0
- package/dist/components/editor/extensions/lint/mount-lint-tooltip.d.ts +16 -0
- package/dist/components/editor/extensions/lint/mount-lint-tooltip.js +60 -0
- package/dist/components/editor/extensions/search/dom.d.ts +2 -0
- package/dist/components/editor/extensions/search/dom.js +6 -0
- package/dist/components/editor/extensions/search/index.d.ts +35 -0
- package/dist/components/editor/extensions/search/index.js +44 -0
- package/dist/components/editor/extensions/search/search.svelte +335 -0
- package/dist/components/editor/extensions/search/search.svelte.d.ts +8 -0
- package/dist/components/editor/index.d.ts +9 -0
- package/dist/components/editor/index.js +9 -0
- package/dist/components/editor/language-service/dom.d.ts +1 -0
- package/dist/components/editor/language-service/dom.js +6 -0
- package/dist/components/editor/language-service/index.d.ts +28 -0
- package/dist/components/editor/language-service/index.js +342 -0
- package/dist/components/empty-view/empty-view.css +39 -0
- package/dist/components/empty-view/empty-view.svelte +26 -0
- package/dist/components/empty-view/empty-view.svelte.d.ts +9 -0
- package/dist/components/empty-view/index.d.ts +2 -0
- package/dist/components/empty-view/index.js +2 -0
- package/dist/components/icon/icon-list.css +74 -0
- package/dist/components/icon/icon-list.svelte +213 -0
- package/dist/components/icon/icon-list.svelte.d.ts +11 -0
- package/dist/components/icon/icon.svelte +15 -0
- package/dist/components/icon/icon.svelte.d.ts +7 -0
- package/dist/components/icon/index.d.ts +3 -0
- package/dist/components/icon/index.js +3 -0
- package/dist/components/menu/context-menu.svelte +89 -0
- package/dist/components/menu/context-menu.svelte.d.ts +11 -0
- package/dist/components/menu/drawer-menu.svelte +83 -0
- package/dist/components/menu/drawer-menu.svelte.d.ts +8 -0
- package/dist/components/menu/dropdown-menu.svelte +89 -0
- package/dist/components/menu/dropdown-menu.svelte.d.ts +11 -0
- package/dist/components/menu/index.d.ts +6 -0
- package/dist/components/menu/index.js +6 -0
- package/dist/components/menu/menu.css +139 -0
- package/dist/components/menu/menu.svelte +37 -0
- package/dist/components/menu/menu.svelte.d.ts +11 -0
- package/dist/components/menu/mobile-menu-query.svelte.d.ts +3 -0
- package/dist/components/menu/mobile-menu-query.svelte.js +21 -0
- package/dist/components/menu/popover-menu.svelte +90 -0
- package/dist/components/menu/popover-menu.svelte.d.ts +10 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +2 -0
- package/dist/components/select/select.svelte +72 -0
- package/dist/components/select/select.svelte.d.ts +25 -0
- package/dist/configuration-option-source-providers.d.ts +17 -0
- package/dist/configuration-option-source-providers.js +59 -0
- package/dist/configuration-option-source-registry.d.ts +59 -0
- package/dist/configuration-option-source-registry.js +123 -0
- package/dist/configuration.svelte.d.ts +258 -0
- package/dist/configuration.svelte.js +887 -0
- package/dist/context-keys.svelte.d.ts +42 -0
- package/dist/context-keys.svelte.js +278 -0
- package/dist/context.svelte.d.ts +247 -0
- package/dist/context.svelte.js +540 -0
- package/dist/daily-document-provider.d.ts +38 -0
- package/dist/daily-document-provider.js +176 -0
- package/dist/design-core-button-types.d.ts +7 -0
- package/dist/design-core-button-types.js +1 -0
- package/dist/diagnostics.d.ts +93 -0
- package/dist/diagnostics.js +84 -0
- package/dist/dialog-portal.d.ts +3 -0
- package/dist/dialog-portal.js +3 -0
- package/dist/docs-api.d.ts +44 -0
- package/dist/docs-api.js +29 -0
- package/dist/editor-view-registry.d.ts +35 -0
- package/dist/editor-view-registry.js +112 -0
- package/dist/editor.svelte.d.ts +126 -0
- package/dist/editor.svelte.js +454 -0
- package/dist/embed-registry.d.ts +15 -0
- package/dist/embed-registry.js +16 -0
- package/dist/enhance.d.ts +111 -0
- package/dist/enhance.js +309 -0
- package/dist/events.d.ts +28 -0
- package/dist/events.js +49 -0
- package/dist/file-manager.d.ts +90 -0
- package/dist/file-manager.js +289 -0
- package/dist/file-tools/app-tools.d.ts +3 -0
- package/dist/file-tools/app-tools.js +242 -0
- package/dist/file-tools/index.d.ts +3 -0
- package/dist/file-tools/index.js +3 -0
- package/dist/file-tools/paths.d.ts +14 -0
- package/dist/file-tools/paths.js +33 -0
- package/dist/file-tools/vault-operations.d.ts +3 -0
- package/dist/file-tools/vault-operations.js +60 -0
- package/dist/generated/plugin-host-modules.schema.generated.d.ts +371 -0
- package/dist/generated/plugin-host-modules.schema.generated.js +374 -0
- package/dist/glob.d.ts +15 -0
- package/dist/glob.js +68 -0
- package/dist/history.svelte.d.ts +24 -0
- package/dist/history.svelte.js +74 -0
- package/dist/hooks/createVirtualizer.svelte.d.ts +7 -0
- package/dist/hooks/createVirtualizer.svelte.js +70 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/is-mobile.svelte.d.ts +5 -0
- package/dist/hooks/is-mobile.svelte.js +23 -0
- package/dist/hooks/mountComponent.svelte.d.ts +7 -0
- package/dist/hooks/mountComponent.svelte.js +16 -0
- package/dist/hooks/use-text-highlight.d.ts +17 -0
- package/dist/hooks/use-text-highlight.js +82 -0
- package/dist/hooks/useBoundingRect.svelte.d.ts +11 -0
- package/dist/hooks/useBoundingRect.svelte.js +46 -0
- package/dist/icons/index.d.ts +57 -0
- package/dist/icons/index.js +288 -0
- package/dist/index.d.ts +87 -0
- package/dist/index.js +87 -0
- package/dist/language-service/index.d.ts +9 -0
- package/dist/language-service/index.js +7 -0
- package/dist/language-service/manager.d.ts +47 -0
- package/dist/language-service/manager.js +404 -0
- package/dist/language-service/types.d.ts +92 -0
- package/dist/language-service/types.js +1 -0
- package/dist/language-service/virtual-document.d.ts +11 -0
- package/dist/language-service/virtual-document.js +45 -0
- package/dist/language-service/worker-protocol.d.ts +63 -0
- package/dist/language-service/worker-protocol.js +1 -0
- package/dist/language-service/worker-provider.d.ts +9 -0
- package/dist/language-service/worker-provider.js +38 -0
- package/dist/lapis-extension.d.ts +244 -0
- package/dist/lapis-extension.js +591 -0
- package/dist/links.d.ts +34 -0
- package/dist/links.js +191 -0
- package/dist/loaders.d.ts +9 -0
- package/dist/loaders.js +59 -0
- package/dist/localization-manager.svelte.d.ts +56 -0
- package/dist/localization-manager.svelte.js +157 -0
- package/dist/logging.d.ts +172 -0
- package/dist/logging.js +352 -0
- package/dist/markdown-extension-registry.d.ts +31 -0
- package/dist/markdown-extension-registry.js +31 -0
- package/dist/markdown-file-surface-registry.d.ts +25 -0
- package/dist/markdown-file-surface-registry.js +23 -0
- package/dist/markdown.d.ts +205 -0
- package/dist/markdown.js +147 -0
- package/dist/menu-utils.d.ts +1 -0
- package/dist/menu-utils.js +47 -0
- package/dist/menu.svelte.d.ts +121 -0
- package/dist/menu.svelte.js +295 -0
- package/dist/metadata-value.d.ts +10 -0
- package/dist/metadata-value.js +173 -0
- package/dist/metadata.svelte.d.ts +106 -0
- package/dist/metadata.svelte.js +608 -0
- package/dist/notifications.d.ts +209 -0
- package/dist/notifications.js +338 -0
- package/dist/open-file.d.ts +23 -0
- package/dist/open-file.js +102 -0
- package/dist/platform.d.ts +86 -0
- package/dist/platform.js +86 -0
- package/dist/plugin-asset-server.d.ts +60 -0
- package/dist/plugin-asset-server.js +222 -0
- package/dist/plugin-assets.d.ts +4 -0
- package/dist/plugin-assets.js +3 -0
- package/dist/plugin-capability-facade.d.ts +104 -0
- package/dist/plugin-capability-facade.js +61 -0
- package/dist/plugin-dependency-resolver.d.ts +36 -0
- package/dist/plugin-dependency-resolver.js +54 -0
- package/dist/plugin-dependency-scanner.d.ts +9 -0
- package/dist/plugin-dependency-scanner.js +274 -0
- package/dist/plugin-distribution/canonical-json.d.ts +1 -0
- package/dist/plugin-distribution/canonical-json.js +40 -0
- package/dist/plugin-distribution/compatibility.d.ts +5 -0
- package/dist/plugin-distribution/compatibility.js +38 -0
- package/dist/plugin-distribution/errors.d.ts +11 -0
- package/dist/plugin-distribution/errors.js +13 -0
- package/dist/plugin-distribution/hashes.d.ts +2 -0
- package/dist/plugin-distribution/hashes.js +17 -0
- package/dist/plugin-distribution/index.d.ts +18 -0
- package/dist/plugin-distribution/index.js +18 -0
- package/dist/plugin-distribution/installed-plugin-state.d.ts +20 -0
- package/dist/plugin-distribution/installed-plugin-state.js +73 -0
- package/dist/plugin-distribution/installer.d.ts +89 -0
- package/dist/plugin-distribution/installer.js +395 -0
- package/dist/plugin-distribution/manager.d.ts +128 -0
- package/dist/plugin-distribution/manager.js +358 -0
- package/dist/plugin-distribution/path-safety.d.ts +2 -0
- package/dist/plugin-distribution/path-safety.js +20 -0
- package/dist/plugin-distribution/plugin-bundle-verifier.d.ts +28 -0
- package/dist/plugin-distribution/plugin-bundle-verifier.js +96 -0
- package/dist/plugin-distribution/plugin-bundle-worker.d.ts +34 -0
- package/dist/plugin-distribution/plugin-bundle-worker.js +99 -0
- package/dist/plugin-distribution/plugin-bundle.d.ts +16 -0
- package/dist/plugin-distribution/plugin-bundle.js +244 -0
- package/dist/plugin-distribution/plugin-bundle.worker.d.ts +1 -0
- package/dist/plugin-distribution/plugin-bundle.worker.js +38 -0
- package/dist/plugin-distribution/registry-cache.d.ts +26 -0
- package/dist/plugin-distribution/registry-cache.js +85 -0
- package/dist/plugin-distribution/registry-client.d.ts +36 -0
- package/dist/plugin-distribution/registry-client.js +115 -0
- package/dist/plugin-distribution/reserved-ids.d.ts +4 -0
- package/dist/plugin-distribution/reserved-ids.js +10 -0
- package/dist/plugin-distribution/runtime-validation.d.ts +14 -0
- package/dist/plugin-distribution/runtime-validation.js +388 -0
- package/dist/plugin-distribution/schemas.d.ts +4895 -0
- package/dist/plugin-distribution/schemas.js +299 -0
- package/dist/plugin-distribution/signing.d.ts +5 -0
- package/dist/plugin-distribution/signing.js +38 -0
- package/dist/plugin-distribution/types.d.ts +217 -0
- package/dist/plugin-distribution/types.js +1 -0
- package/dist/plugin-install-progress.d.ts +15 -0
- package/dist/plugin-install-progress.js +86 -0
- package/dist/plugin-manager.d.ts +306 -0
- package/dist/plugin-manager.js +2848 -0
- package/dist/plugin-runtime-entry.d.ts +19 -0
- package/dist/plugin-runtime-entry.js +135 -0
- package/dist/plugin.d.ts +350 -0
- package/dist/plugin.js +754 -0
- package/dist/popover.d.ts +20 -0
- package/dist/popover.js +32 -0
- package/dist/promise-worker.d.ts +22 -0
- package/dist/promise-worker.js +65 -0
- package/dist/prompt-confirm.d.ts +9 -0
- package/dist/prompt-confirm.js +33 -0
- package/dist/search-document-provider.d.ts +45 -0
- package/dist/search-document-provider.js +54 -0
- package/dist/search-query/index.d.ts +78 -0
- package/dist/search-query/index.js +426 -0
- package/dist/search-query/parser.d.ts +3 -0
- package/dist/search-query/parser.js +16 -0
- package/dist/search-query/parser.terms.js +26 -0
- package/dist/search-query/search-query.grammar +128 -0
- package/dist/search.d.ts +19 -0
- package/dist/search.js +104 -0
- package/dist/setting-section-layout.d.ts +19 -0
- package/dist/setting-section-layout.js +194 -0
- package/dist/settings.svelte.d.ts +474 -0
- package/dist/settings.svelte.js +1421 -0
- package/dist/source-text-file-view.d.ts +25 -0
- package/dist/source-text-file-view.js +78 -0
- package/dist/status-bar.svelte.d.ts +29 -0
- package/dist/status-bar.svelte.js +72 -0
- package/dist/storage/app-database.d.ts +860 -0
- package/dist/storage/app-database.js +2372 -0
- package/dist/storage/blob-store.d.ts +12 -0
- package/dist/storage/blob-store.js +1 -0
- package/dist/storage/browser-app-database-coordination.d.ts +35 -0
- package/dist/storage/browser-app-database-coordination.js +207 -0
- package/dist/storage/browser-coordinated-app-database.d.ts +109 -0
- package/dist/storage/browser-coordinated-app-database.js +704 -0
- package/dist/storage/browser.d.ts +153 -0
- package/dist/storage/browser.js +794 -0
- package/dist/storage/desktop-native.d.ts +184 -0
- package/dist/storage/desktop-native.js +415 -0
- package/dist/storage/fs.d.ts +188 -0
- package/dist/storage/fs.js +307 -0
- package/dist/storage/index-projection.d.ts +236 -0
- package/dist/storage/index-projection.js +402 -0
- package/dist/storage/index.d.ts +17 -0
- package/dist/storage/index.js +17 -0
- package/dist/storage/keyval.d.ts +94 -0
- package/dist/storage/keyval.js +199 -0
- package/dist/storage/memory-vault-adapter.d.ts +44 -0
- package/dist/storage/memory-vault-adapter.js +351 -0
- package/dist/storage/native-vault-bootstrap-kv.d.ts +22 -0
- package/dist/storage/native-vault-bootstrap-kv.js +96 -0
- package/dist/storage/path.d.ts +22 -0
- package/dist/storage/path.js +110 -0
- package/dist/storage/search-embedding-provider.d.ts +75 -0
- package/dist/storage/search-embedding-provider.js +446 -0
- package/dist/storage/search-embedding-worker.d.ts +1 -0
- package/dist/storage/search-embedding-worker.js +63 -0
- package/dist/storage/search-query-evaluator.d.ts +14 -0
- package/dist/storage/search-query-evaluator.js +678 -0
- package/dist/storage/task-projection.d.ts +152 -0
- package/dist/storage/task-projection.js +154 -0
- package/dist/storage/turso-app-database.d.ts +150 -0
- package/dist/storage/turso-app-database.js +2671 -0
- package/dist/storage/vault-session.d.ts +37 -0
- package/dist/storage/vault-session.js +196 -0
- package/dist/storage/vault-state.d.ts +74 -0
- package/dist/storage/vault-state.js +181 -0
- package/dist/storage/vault.svelte.d.ts +257 -0
- package/dist/storage/vault.svelte.js +661 -0
- package/dist/suggest.d.ts +193 -0
- package/dist/suggest.js +391 -0
- package/dist/tasks.d.ts +7 -0
- package/dist/tasks.js +18 -0
- package/dist/telemetry.d.ts +116 -0
- package/dist/telemetry.js +103 -0
- package/dist/utils.d.ts +55 -0
- package/dist/utils.js +314 -0
- package/dist/vault-api.d.ts +5 -0
- package/dist/vault-api.js +3 -0
- package/dist/vault-maintenance-commands.d.ts +5 -0
- package/dist/vault-maintenance-commands.js +32 -0
- package/dist/view.svelte.d.ts +215 -0
- package/dist/view.svelte.js +381 -0
- package/dist/vite-env.d.ts +2 -0
- package/dist/workspace-host-internal.d.ts +7 -0
- package/dist/workspace-host-internal.js +7 -0
- package/dist/workspace-host.d.ts +10 -0
- package/dist/workspace-host.js +14 -0
- package/dist/workspace-layout-commands.d.ts +3 -0
- package/dist/workspace-layout-commands.js +72 -0
- package/dist/workspace-layout-normalizer.d.ts +92 -0
- package/dist/workspace-layout-normalizer.js +301 -0
- package/dist/workspace-layouts.d.ts +7 -0
- package/dist/workspace-layouts.js +23 -0
- package/dist/workspace-trust.d.ts +32 -0
- package/dist/workspace-trust.js +72 -0
- package/dist/workspace.svelte.d.ts +796 -0
- package/dist/workspace.svelte.js +4380 -0
- package/package.json +240 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
export declare const PUBLIC_TASKS_PROJECTION_ID = "tasks/task";
|
|
2
|
+
export declare const PUBLIC_TASK_OCCURRENCES_PROJECTION_ID = "tasks/occurrence";
|
|
3
|
+
export declare const PUBLIC_ROLES_PROJECTION_ID = "roles/role";
|
|
4
|
+
export declare const MAX_PROJECTION_ROWS_PER_SOURCE = 64;
|
|
5
|
+
export declare const MAX_PROJECTION_INDEXED_FIELDS = 64;
|
|
6
|
+
export declare const MAX_PROJECTION_VALUE_CHARS = 4096;
|
|
7
|
+
export type IndexScalar = string | number | boolean | null;
|
|
8
|
+
export type IndexCompareOp = "eq" | "ne" | "lt" | "lte" | "gt" | "gte";
|
|
9
|
+
export type IndexFieldType = "string" | "number" | "boolean" | "date" | "datetime" | "path" | "json";
|
|
10
|
+
export type IndexProjectionVisibility = "public" | "private";
|
|
11
|
+
export type IndexProjectionSourceStatus = "ready" | "building" | "error";
|
|
12
|
+
export type IndexStatus = "ready" | "building" | "error";
|
|
13
|
+
export type IndexFilter = {
|
|
14
|
+
op: "and";
|
|
15
|
+
operands: IndexFilter[];
|
|
16
|
+
} | {
|
|
17
|
+
op: "or";
|
|
18
|
+
operands: IndexFilter[];
|
|
19
|
+
} | {
|
|
20
|
+
op: "not";
|
|
21
|
+
operand: IndexFilter;
|
|
22
|
+
} | {
|
|
23
|
+
op: "compare";
|
|
24
|
+
field: string;
|
|
25
|
+
comparison: IndexCompareOp;
|
|
26
|
+
value: IndexScalar;
|
|
27
|
+
} | {
|
|
28
|
+
op: "in";
|
|
29
|
+
field: string;
|
|
30
|
+
values: IndexScalar[];
|
|
31
|
+
} | {
|
|
32
|
+
op: "exists";
|
|
33
|
+
field: string;
|
|
34
|
+
} | {
|
|
35
|
+
op: "not-exists";
|
|
36
|
+
field: string;
|
|
37
|
+
};
|
|
38
|
+
export interface IndexOrderBy {
|
|
39
|
+
field: string;
|
|
40
|
+
direction?: "asc" | "desc";
|
|
41
|
+
nulls?: "first" | "last";
|
|
42
|
+
}
|
|
43
|
+
export interface IndexQuery {
|
|
44
|
+
where?: IndexFilter;
|
|
45
|
+
select?: string[];
|
|
46
|
+
orderBy?: IndexOrderBy[];
|
|
47
|
+
limit?: number;
|
|
48
|
+
after?: string;
|
|
49
|
+
includeStale?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface IndexQueryResult<T = Record<string, unknown>> {
|
|
52
|
+
rows: T[];
|
|
53
|
+
nextCursor?: string;
|
|
54
|
+
revision: number;
|
|
55
|
+
complete: boolean;
|
|
56
|
+
indexStatus: IndexStatus;
|
|
57
|
+
}
|
|
58
|
+
export interface IndexRelatedQuery {
|
|
59
|
+
projectionId: string;
|
|
60
|
+
rowId: string;
|
|
61
|
+
relation: string;
|
|
62
|
+
direction?: "out" | "in";
|
|
63
|
+
targetWhere?: IndexFilter;
|
|
64
|
+
limit?: number;
|
|
65
|
+
}
|
|
66
|
+
export interface IndexFieldDefinition {
|
|
67
|
+
type: IndexFieldType;
|
|
68
|
+
indexed?: boolean;
|
|
69
|
+
sortable?: boolean;
|
|
70
|
+
unique?: boolean;
|
|
71
|
+
cardinality?: "one" | "many";
|
|
72
|
+
}
|
|
73
|
+
export interface IndexProjectionSourceFilter {
|
|
74
|
+
extensions?: string[];
|
|
75
|
+
pathPrefix?: string;
|
|
76
|
+
basename?: string;
|
|
77
|
+
propertyEquals?: Record<string, IndexScalar>;
|
|
78
|
+
}
|
|
79
|
+
export interface IndexProjectionRowInput {
|
|
80
|
+
id: string;
|
|
81
|
+
kind: string;
|
|
82
|
+
ordinal?: number;
|
|
83
|
+
data: Record<string, unknown>;
|
|
84
|
+
}
|
|
85
|
+
export interface IndexProjectionEdgeInput {
|
|
86
|
+
sourceRowId: string;
|
|
87
|
+
relation: string;
|
|
88
|
+
targetProjectionId?: string | null;
|
|
89
|
+
targetRowId?: string | null;
|
|
90
|
+
targetPath?: string | null;
|
|
91
|
+
targetText?: string | null;
|
|
92
|
+
ordinal: number;
|
|
93
|
+
data?: Record<string, unknown> | null;
|
|
94
|
+
}
|
|
95
|
+
export interface IndexProjectionDefinitionRecord {
|
|
96
|
+
projectionId: string;
|
|
97
|
+
ownerPluginId: string;
|
|
98
|
+
schemaVersion: number;
|
|
99
|
+
configHash: string;
|
|
100
|
+
visibility: IndexProjectionVisibility;
|
|
101
|
+
fields: Record<string, IndexFieldDefinition>;
|
|
102
|
+
active: boolean;
|
|
103
|
+
updatedAt: number;
|
|
104
|
+
}
|
|
105
|
+
export interface IndexProjectionSourceRecord {
|
|
106
|
+
projectionId: string;
|
|
107
|
+
sourcePath: string;
|
|
108
|
+
sourceHash: string;
|
|
109
|
+
schemaVersion: number;
|
|
110
|
+
configHash: string;
|
|
111
|
+
status: IndexProjectionSourceStatus;
|
|
112
|
+
error?: string | null;
|
|
113
|
+
indexedAt: number;
|
|
114
|
+
}
|
|
115
|
+
export interface IndexProjectionRowRecord {
|
|
116
|
+
projectionId: string;
|
|
117
|
+
rowId: string;
|
|
118
|
+
sourcePath: string;
|
|
119
|
+
kind: string;
|
|
120
|
+
ordinal: number;
|
|
121
|
+
data: Record<string, unknown>;
|
|
122
|
+
}
|
|
123
|
+
export interface IndexProjectionValueRecord {
|
|
124
|
+
projectionId: string;
|
|
125
|
+
rowId: string;
|
|
126
|
+
field: string;
|
|
127
|
+
ordinal: number;
|
|
128
|
+
valueType: IndexFieldType;
|
|
129
|
+
textValue?: string | null;
|
|
130
|
+
numberValue?: number | null;
|
|
131
|
+
booleanValue?: boolean | null;
|
|
132
|
+
dateValue?: string | null;
|
|
133
|
+
datetimeValue?: number | null;
|
|
134
|
+
}
|
|
135
|
+
export interface IndexProjectionEdgeRecord {
|
|
136
|
+
projectionId: string;
|
|
137
|
+
sourceRowId: string;
|
|
138
|
+
relation: string;
|
|
139
|
+
targetProjectionId?: string | null;
|
|
140
|
+
targetRowId?: string | null;
|
|
141
|
+
targetPath?: string | null;
|
|
142
|
+
targetText?: string | null;
|
|
143
|
+
ordinal: number;
|
|
144
|
+
data?: Record<string, unknown> | null;
|
|
145
|
+
}
|
|
146
|
+
export interface ReplaceProjectionSourceInput {
|
|
147
|
+
projectionId: string;
|
|
148
|
+
sourcePath: string;
|
|
149
|
+
sourceHash: string;
|
|
150
|
+
rows: IndexProjectionRowInput[];
|
|
151
|
+
edges?: IndexProjectionEdgeInput[];
|
|
152
|
+
writerPluginId?: string;
|
|
153
|
+
}
|
|
154
|
+
export interface MarkProjectionSourceErrorInput {
|
|
155
|
+
projectionId: string;
|
|
156
|
+
sourcePath: string;
|
|
157
|
+
sourceHash: string;
|
|
158
|
+
error: string;
|
|
159
|
+
writerPluginId?: string;
|
|
160
|
+
}
|
|
161
|
+
export declare function and(...operands: IndexFilter[]): IndexFilter;
|
|
162
|
+
export declare function or(...operands: IndexFilter[]): IndexFilter;
|
|
163
|
+
export declare function not(operand: IndexFilter): IndexFilter;
|
|
164
|
+
export declare function eq(field: string, value: IndexScalar): IndexFilter;
|
|
165
|
+
export declare function ne(field: string, value: IndexScalar): IndexFilter;
|
|
166
|
+
export declare function lt(field: string, value: IndexScalar): IndexFilter;
|
|
167
|
+
export declare function lte(field: string, value: IndexScalar): IndexFilter;
|
|
168
|
+
export declare function gt(field: string, value: IndexScalar): IndexFilter;
|
|
169
|
+
export declare function gte(field: string, value: IndexScalar): IndexFilter;
|
|
170
|
+
export declare function isIn(field: string, values: IndexScalar[]): IndexFilter;
|
|
171
|
+
export declare function exists(field: string): IndexFilter;
|
|
172
|
+
export declare function notExists(field: string): IndexFilter;
|
|
173
|
+
export declare function isNull(field: string): IndexFilter;
|
|
174
|
+
export declare function qualifyProjectionId(pluginId: string, localId: string): string;
|
|
175
|
+
export declare function projectionOwnerId(projectionId: string): string;
|
|
176
|
+
export declare function assertProjectionWriteAccess(projectionId: string, writerPluginId?: string): void;
|
|
177
|
+
export declare function assertProjectionReadAccess(definition: IndexProjectionDefinitionRecord | undefined, readerPluginId?: string): void;
|
|
178
|
+
export declare function fieldValue(data: Record<string, unknown>, field: string): unknown;
|
|
179
|
+
export declare function matchesIndexFilter(data: Record<string, unknown>, filter?: IndexFilter): boolean;
|
|
180
|
+
export declare function selectProjectionRow<T>(data: Record<string, unknown>, select?: string[]): T;
|
|
181
|
+
export declare function evaluateProjectionQuery<T>(rows: IndexProjectionRowRecord[], query: IndexQuery, revision: number, indexStatus: IndexStatus): IndexQueryResult<T>;
|
|
182
|
+
export declare function indexedValuesForRow(projectionId: string, row: IndexProjectionRowInput, fields: Record<string, IndexFieldDefinition>): IndexProjectionValueRecord[];
|
|
183
|
+
export declare function compileProjectionQuerySql(projectionId: string, query: IndexQuery, definition: IndexProjectionDefinitionRecord): {
|
|
184
|
+
sql: string;
|
|
185
|
+
args: unknown[];
|
|
186
|
+
};
|
|
187
|
+
export declare function projectionIndexStatus(sources: IndexProjectionSourceRecord[]): IndexStatus;
|
|
188
|
+
export interface IndexProjectionFileRef {
|
|
189
|
+
path: string;
|
|
190
|
+
extension: string;
|
|
191
|
+
name: string;
|
|
192
|
+
}
|
|
193
|
+
export interface IndexProjectionProjectContext {
|
|
194
|
+
file: IndexProjectionFileRef;
|
|
195
|
+
content: string;
|
|
196
|
+
cache?: {
|
|
197
|
+
frontmatter?: Record<string, unknown> | null;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
export interface IndexProjectionProjectResult {
|
|
201
|
+
rows: IndexProjectionRowInput[];
|
|
202
|
+
edges?: IndexProjectionEdgeInput[];
|
|
203
|
+
}
|
|
204
|
+
export interface IndexProjectionRegistration {
|
|
205
|
+
id: string;
|
|
206
|
+
version: number;
|
|
207
|
+
visibility?: IndexProjectionVisibility;
|
|
208
|
+
configurationHash?: string;
|
|
209
|
+
fields: Record<string, IndexFieldDefinition>;
|
|
210
|
+
source?: IndexProjectionSourceFilter;
|
|
211
|
+
project(context: IndexProjectionProjectContext): IndexProjectionProjectResult | Promise<IndexProjectionProjectResult>;
|
|
212
|
+
}
|
|
213
|
+
export interface RegisteredIndexProjection<T = Record<string, unknown>> {
|
|
214
|
+
projectionId: string;
|
|
215
|
+
ownerPluginId: string;
|
|
216
|
+
registration: IndexProjectionRegistration;
|
|
217
|
+
}
|
|
218
|
+
export interface RegisteredIndexProjectionHandle<T = Record<string, unknown>> {
|
|
219
|
+
id: string;
|
|
220
|
+
query(query: IndexQuery): Promise<IndexQueryResult<T>>;
|
|
221
|
+
get(id: string): Promise<T | null>;
|
|
222
|
+
queryRelated(query: Omit<IndexRelatedQuery, "projectionId">): Promise<IndexQueryResult<T>>;
|
|
223
|
+
}
|
|
224
|
+
export declare function matchesProjectionSource(file: IndexProjectionFileRef, cache: {
|
|
225
|
+
frontmatter?: Record<string, unknown> | null;
|
|
226
|
+
} | undefined, source?: IndexProjectionSourceFilter): boolean;
|
|
227
|
+
export declare class IndexProjectionRegistry {
|
|
228
|
+
private readonly registrations;
|
|
229
|
+
register(ownerPluginId: string, registration: IndexProjectionRegistration): RegisteredIndexProjection;
|
|
230
|
+
unregister(projectionId: string): void;
|
|
231
|
+
get(projectionId: string): RegisteredIndexProjection | undefined;
|
|
232
|
+
matching(file: IndexProjectionFileRef, cache?: {
|
|
233
|
+
frontmatter?: Record<string, unknown> | null;
|
|
234
|
+
}): RegisteredIndexProjection[];
|
|
235
|
+
}
|
|
236
|
+
export declare function sourceIsCurrent(source: IndexProjectionSourceRecord, fileHash: string | undefined, definition: IndexProjectionDefinitionRecord, includeStale?: boolean): boolean;
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
export const PUBLIC_TASKS_PROJECTION_ID = "tasks/task";
|
|
2
|
+
export const PUBLIC_TASK_OCCURRENCES_PROJECTION_ID = "tasks/occurrence";
|
|
3
|
+
export const PUBLIC_ROLES_PROJECTION_ID = "roles/role";
|
|
4
|
+
export const MAX_PROJECTION_ROWS_PER_SOURCE = 64;
|
|
5
|
+
export const MAX_PROJECTION_INDEXED_FIELDS = 64;
|
|
6
|
+
export const MAX_PROJECTION_VALUE_CHARS = 4096;
|
|
7
|
+
export function and(...operands) {
|
|
8
|
+
return { op: "and", operands };
|
|
9
|
+
}
|
|
10
|
+
export function or(...operands) {
|
|
11
|
+
return { op: "or", operands };
|
|
12
|
+
}
|
|
13
|
+
export function not(operand) {
|
|
14
|
+
return { op: "not", operand };
|
|
15
|
+
}
|
|
16
|
+
export function eq(field, value) {
|
|
17
|
+
return { op: "compare", field, comparison: "eq", value };
|
|
18
|
+
}
|
|
19
|
+
export function ne(field, value) {
|
|
20
|
+
return { op: "compare", field, comparison: "ne", value };
|
|
21
|
+
}
|
|
22
|
+
export function lt(field, value) {
|
|
23
|
+
return { op: "compare", field, comparison: "lt", value };
|
|
24
|
+
}
|
|
25
|
+
export function lte(field, value) {
|
|
26
|
+
return { op: "compare", field, comparison: "lte", value };
|
|
27
|
+
}
|
|
28
|
+
export function gt(field, value) {
|
|
29
|
+
return { op: "compare", field, comparison: "gt", value };
|
|
30
|
+
}
|
|
31
|
+
export function gte(field, value) {
|
|
32
|
+
return { op: "compare", field, comparison: "gte", value };
|
|
33
|
+
}
|
|
34
|
+
export function isIn(field, values) {
|
|
35
|
+
return { op: "in", field, values };
|
|
36
|
+
}
|
|
37
|
+
export function exists(field) {
|
|
38
|
+
return { op: "exists", field };
|
|
39
|
+
}
|
|
40
|
+
export function notExists(field) {
|
|
41
|
+
return { op: "not-exists", field };
|
|
42
|
+
}
|
|
43
|
+
export function isNull(field) {
|
|
44
|
+
return { op: "compare", field, comparison: "eq", value: null };
|
|
45
|
+
}
|
|
46
|
+
export function qualifyProjectionId(pluginId, localId) {
|
|
47
|
+
const plugin = pluginId.trim();
|
|
48
|
+
const local = localId.trim();
|
|
49
|
+
if (!plugin || !local) {
|
|
50
|
+
throw new Error("Projection ids must include a plugin id and local id.");
|
|
51
|
+
}
|
|
52
|
+
if (local.includes("/")) {
|
|
53
|
+
throw new Error("Local projection ids must not contain '/'.");
|
|
54
|
+
}
|
|
55
|
+
return `${plugin}/${local}`;
|
|
56
|
+
}
|
|
57
|
+
export function projectionOwnerId(projectionId) {
|
|
58
|
+
const [owner] = projectionId.split("/", 1);
|
|
59
|
+
return owner ?? "";
|
|
60
|
+
}
|
|
61
|
+
export function assertProjectionWriteAccess(projectionId, writerPluginId) {
|
|
62
|
+
if (!writerPluginId)
|
|
63
|
+
return;
|
|
64
|
+
if (projectionOwnerId(projectionId) !== writerPluginId) {
|
|
65
|
+
throw new Error(`Plugin ${writerPluginId} cannot write ${projectionId}.`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function assertProjectionReadAccess(definition, readerPluginId) {
|
|
69
|
+
if (!definition?.active) {
|
|
70
|
+
throw new Error("Projection is not registered.");
|
|
71
|
+
}
|
|
72
|
+
if (definition.visibility === "public")
|
|
73
|
+
return;
|
|
74
|
+
if (readerPluginId && readerPluginId === definition.ownerPluginId)
|
|
75
|
+
return;
|
|
76
|
+
throw new Error(`Projection ${definition.projectionId} is private.`);
|
|
77
|
+
}
|
|
78
|
+
export function fieldValue(data, field) {
|
|
79
|
+
if (Object.hasOwn(data, field))
|
|
80
|
+
return data[field];
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
function scalarOf(value) {
|
|
84
|
+
if (value === undefined)
|
|
85
|
+
return undefined;
|
|
86
|
+
if (value === null || typeof value === "string" || typeof value === "number") {
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
if (typeof value === "boolean")
|
|
90
|
+
return value;
|
|
91
|
+
return String(value);
|
|
92
|
+
}
|
|
93
|
+
function compareScalars(left, right) {
|
|
94
|
+
if (left == null && right == null)
|
|
95
|
+
return 0;
|
|
96
|
+
if (left == null)
|
|
97
|
+
return 1;
|
|
98
|
+
if (right == null)
|
|
99
|
+
return -1;
|
|
100
|
+
if (typeof left === "number" && typeof right === "number")
|
|
101
|
+
return left - right;
|
|
102
|
+
if (typeof left === "boolean" && typeof right === "boolean") {
|
|
103
|
+
return Number(left) - Number(right);
|
|
104
|
+
}
|
|
105
|
+
return String(left).localeCompare(String(right));
|
|
106
|
+
}
|
|
107
|
+
export function matchesIndexFilter(data, filter) {
|
|
108
|
+
if (!filter)
|
|
109
|
+
return true;
|
|
110
|
+
switch (filter.op) {
|
|
111
|
+
case "and":
|
|
112
|
+
return filter.operands.every((operand) => matchesIndexFilter(data, operand));
|
|
113
|
+
case "or":
|
|
114
|
+
return filter.operands.some((operand) => matchesIndexFilter(data, operand));
|
|
115
|
+
case "not":
|
|
116
|
+
return !matchesIndexFilter(data, filter.operand);
|
|
117
|
+
case "exists":
|
|
118
|
+
return fieldValue(data, filter.field) != null;
|
|
119
|
+
case "not-exists":
|
|
120
|
+
return fieldValue(data, filter.field) == null;
|
|
121
|
+
case "in": {
|
|
122
|
+
const value = scalarOf(fieldValue(data, filter.field));
|
|
123
|
+
return filter.values.some((candidate) => compareScalars(value, candidate) === 0);
|
|
124
|
+
}
|
|
125
|
+
case "compare": {
|
|
126
|
+
const left = scalarOf(fieldValue(data, filter.field));
|
|
127
|
+
if (filter.comparison === "eq") {
|
|
128
|
+
if (filter.value == null)
|
|
129
|
+
return left == null;
|
|
130
|
+
return compareScalars(left, filter.value) === 0;
|
|
131
|
+
}
|
|
132
|
+
if (filter.comparison === "ne") {
|
|
133
|
+
if (filter.value == null)
|
|
134
|
+
return left != null;
|
|
135
|
+
return compareScalars(left, filter.value) !== 0;
|
|
136
|
+
}
|
|
137
|
+
if (left == null)
|
|
138
|
+
return false;
|
|
139
|
+
const comparison = compareScalars(left, filter.value);
|
|
140
|
+
if (filter.comparison === "lt")
|
|
141
|
+
return comparison < 0;
|
|
142
|
+
if (filter.comparison === "lte")
|
|
143
|
+
return comparison <= 0;
|
|
144
|
+
if (filter.comparison === "gt")
|
|
145
|
+
return comparison > 0;
|
|
146
|
+
return comparison >= 0;
|
|
147
|
+
}
|
|
148
|
+
default:
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function encodeCursor(values, rowId) {
|
|
153
|
+
return btoa(unescape(encodeURIComponent(JSON.stringify({ values, rowId }))));
|
|
154
|
+
}
|
|
155
|
+
function decodeCursor(cursor) {
|
|
156
|
+
return JSON.parse(decodeURIComponent(escape(atob(cursor))));
|
|
157
|
+
}
|
|
158
|
+
function afterCursor(sortValues, rowId, after, orderBy) {
|
|
159
|
+
const cursor = decodeCursor(after);
|
|
160
|
+
const length = Math.max(sortValues.length, cursor.values.length, orderBy.length);
|
|
161
|
+
for (let index = 0; index < length; index += 1) {
|
|
162
|
+
const spec = orderBy[index] ?? { field: "id", direction: "asc" };
|
|
163
|
+
const direction = spec.direction === "desc" ? -1 : 1;
|
|
164
|
+
const comparison = compareScalars(sortValues[index] ?? null, cursor.values[index] ?? null);
|
|
165
|
+
if (comparison === 0)
|
|
166
|
+
continue;
|
|
167
|
+
return comparison * direction > 0;
|
|
168
|
+
}
|
|
169
|
+
return rowId > cursor.rowId;
|
|
170
|
+
}
|
|
171
|
+
export function selectProjectionRow(data, select) {
|
|
172
|
+
if (!select?.length)
|
|
173
|
+
return data;
|
|
174
|
+
const picked = {};
|
|
175
|
+
for (const field of select)
|
|
176
|
+
picked[field] = data[field];
|
|
177
|
+
return picked;
|
|
178
|
+
}
|
|
179
|
+
export function evaluateProjectionQuery(rows, query, revision, indexStatus) {
|
|
180
|
+
const orderBy = query.orderBy ?? [];
|
|
181
|
+
const filtered = rows.filter((row) => matchesIndexFilter(row.data, query.where));
|
|
182
|
+
filtered.sort((left, right) => {
|
|
183
|
+
for (const spec of orderBy) {
|
|
184
|
+
const direction = spec.direction === "desc" ? -1 : 1;
|
|
185
|
+
const comparison = compareScalars(scalarOf(fieldValue(left.data, spec.field)), scalarOf(fieldValue(right.data, spec.field)) ?? null);
|
|
186
|
+
if (comparison !== 0) {
|
|
187
|
+
if (spec.nulls === "first" && fieldValue(left.data, spec.field) == null)
|
|
188
|
+
return -1;
|
|
189
|
+
if (spec.nulls === "first" && fieldValue(right.data, spec.field) == null)
|
|
190
|
+
return 1;
|
|
191
|
+
if (spec.nulls === "last" && fieldValue(left.data, spec.field) == null)
|
|
192
|
+
return 1;
|
|
193
|
+
if (spec.nulls === "last" && fieldValue(right.data, spec.field) == null)
|
|
194
|
+
return -1;
|
|
195
|
+
return comparison * direction;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return left.rowId.localeCompare(right.rowId);
|
|
199
|
+
});
|
|
200
|
+
const after = query.after
|
|
201
|
+
? filtered.filter((row) => afterCursor(orderBy.map((spec) => scalarOf(fieldValue(row.data, spec.field)) ?? null), row.rowId, query.after, orderBy))
|
|
202
|
+
: filtered;
|
|
203
|
+
const limit = query.limit && query.limit > 0 ? query.limit : after.length;
|
|
204
|
+
const page = after.slice(0, limit);
|
|
205
|
+
const last = page.at(-1);
|
|
206
|
+
return {
|
|
207
|
+
rows: page.map((row) => selectProjectionRow(row.data, query.select)),
|
|
208
|
+
nextCursor: last && after.length > page.length
|
|
209
|
+
? encodeCursor(orderBy.map((spec) => scalarOf(fieldValue(last.data, spec.field)) ?? null), last.rowId)
|
|
210
|
+
: undefined,
|
|
211
|
+
revision,
|
|
212
|
+
complete: indexStatus !== "building",
|
|
213
|
+
indexStatus,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
export function indexedValuesForRow(projectionId, row, fields) {
|
|
217
|
+
const values = [];
|
|
218
|
+
let fieldCount = 0;
|
|
219
|
+
for (const [field, definition] of Object.entries(fields)) {
|
|
220
|
+
if (!definition.indexed && !definition.sortable)
|
|
221
|
+
continue;
|
|
222
|
+
fieldCount += 1;
|
|
223
|
+
if (fieldCount > MAX_PROJECTION_INDEXED_FIELDS)
|
|
224
|
+
break;
|
|
225
|
+
const raw = row.data[field];
|
|
226
|
+
const items = definition.cardinality === "many" && Array.isArray(raw) ? raw : [raw];
|
|
227
|
+
items.forEach((item, ordinal) => {
|
|
228
|
+
const scalar = scalarOf(item);
|
|
229
|
+
const record = {
|
|
230
|
+
projectionId,
|
|
231
|
+
rowId: row.id,
|
|
232
|
+
field,
|
|
233
|
+
ordinal,
|
|
234
|
+
valueType: definition.type,
|
|
235
|
+
};
|
|
236
|
+
if (scalar == null) {
|
|
237
|
+
values.push(record);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (definition.type === "number")
|
|
241
|
+
record.numberValue = Number(scalar);
|
|
242
|
+
else if (definition.type === "boolean")
|
|
243
|
+
record.booleanValue = Boolean(scalar);
|
|
244
|
+
else if (definition.type === "datetime")
|
|
245
|
+
record.datetimeValue = Number(scalar);
|
|
246
|
+
else if (definition.type === "date")
|
|
247
|
+
record.dateValue = String(scalar).slice(0, MAX_PROJECTION_VALUE_CHARS);
|
|
248
|
+
else
|
|
249
|
+
record.textValue = String(scalar).slice(0, MAX_PROJECTION_VALUE_CHARS);
|
|
250
|
+
values.push(record);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
return values;
|
|
254
|
+
}
|
|
255
|
+
export function compileProjectionQuerySql(projectionId, query, definition) {
|
|
256
|
+
const args = [projectionId, definition.schemaVersion, definition.configHash];
|
|
257
|
+
const where = query.includeStale
|
|
258
|
+
? "r.projection_id = ? AND s.schema_version = ? AND s.config_hash = ?"
|
|
259
|
+
: `r.projection_id = ?
|
|
260
|
+
AND s.status = 'ready'
|
|
261
|
+
AND s.schema_version = ?
|
|
262
|
+
AND s.config_hash = ?
|
|
263
|
+
AND (f.path IS NULL OR (f.hash = s.source_hash AND f.deleted = 0))`;
|
|
264
|
+
const filter = query.where
|
|
265
|
+
? ` AND (${compileFilterSql(query.where, args)})`
|
|
266
|
+
: "";
|
|
267
|
+
const orderBy = compileOrderBySql(query.orderBy ?? [], args);
|
|
268
|
+
const limit = query.limit && query.limit > 0 ? " LIMIT ?" : "";
|
|
269
|
+
if (limit)
|
|
270
|
+
args.push(query.limit);
|
|
271
|
+
return {
|
|
272
|
+
sql: `SELECT r.row_id, r.source_path, r.kind, r.ordinal, r.data_json
|
|
273
|
+
FROM index_projection_rows r
|
|
274
|
+
INNER JOIN index_projection_sources s
|
|
275
|
+
ON s.projection_id = r.projection_id AND s.source_path = r.source_path
|
|
276
|
+
LEFT JOIN files f ON f.path = r.source_path
|
|
277
|
+
WHERE ${where}${filter}
|
|
278
|
+
${orderBy}${limit}`,
|
|
279
|
+
args,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function jsonExtract(field) {
|
|
283
|
+
return `json_extract(r.data_json, '$.${field.replaceAll("'", "''")}')`;
|
|
284
|
+
}
|
|
285
|
+
function compileFilterSql(filter, args) {
|
|
286
|
+
switch (filter.op) {
|
|
287
|
+
case "and":
|
|
288
|
+
return filter.operands.map((operand) => `(${compileFilterSql(operand, args)})`).join(" AND ");
|
|
289
|
+
case "or":
|
|
290
|
+
return filter.operands.map((operand) => `(${compileFilterSql(operand, args)})`).join(" OR ");
|
|
291
|
+
case "not":
|
|
292
|
+
return `NOT (${compileFilterSql(filter.operand, args)})`;
|
|
293
|
+
case "exists":
|
|
294
|
+
return `${jsonExtract(filter.field)} IS NOT NULL`;
|
|
295
|
+
case "not-exists":
|
|
296
|
+
return `${jsonExtract(filter.field)} IS NULL`;
|
|
297
|
+
case "in": {
|
|
298
|
+
if (filter.values.length === 0)
|
|
299
|
+
return "0";
|
|
300
|
+
const placeholders = filter.values.map(() => "?").join(", ");
|
|
301
|
+
args.push(...filter.values);
|
|
302
|
+
return `${jsonExtract(filter.field)} IN (${placeholders})`;
|
|
303
|
+
}
|
|
304
|
+
case "compare": {
|
|
305
|
+
const expr = jsonExtract(filter.field);
|
|
306
|
+
if (filter.comparison === "eq" && filter.value == null)
|
|
307
|
+
return `${expr} IS NULL`;
|
|
308
|
+
if (filter.comparison === "ne" && filter.value == null)
|
|
309
|
+
return `${expr} IS NOT NULL`;
|
|
310
|
+
const operator = filter.comparison === "eq"
|
|
311
|
+
? "="
|
|
312
|
+
: filter.comparison === "ne"
|
|
313
|
+
? "!="
|
|
314
|
+
: filter.comparison === "lt"
|
|
315
|
+
? "<"
|
|
316
|
+
: filter.comparison === "lte"
|
|
317
|
+
? "<="
|
|
318
|
+
: filter.comparison === "gt"
|
|
319
|
+
? ">"
|
|
320
|
+
: ">=";
|
|
321
|
+
args.push(filter.value);
|
|
322
|
+
return `${expr} ${operator} ?`;
|
|
323
|
+
}
|
|
324
|
+
default:
|
|
325
|
+
return "0";
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function compileOrderBySql(orderBy, _args) {
|
|
329
|
+
if (orderBy.length === 0)
|
|
330
|
+
return "ORDER BY r.row_id ASC";
|
|
331
|
+
const clauses = orderBy.map((spec) => {
|
|
332
|
+
const expr = jsonExtract(spec.field);
|
|
333
|
+
const direction = spec.direction === "desc" ? "DESC" : "ASC";
|
|
334
|
+
const nulls = spec.nulls === "first" ? "NULLS FIRST" : "NULLS LAST";
|
|
335
|
+
return `${expr} ${direction} ${nulls}`;
|
|
336
|
+
});
|
|
337
|
+
clauses.push("r.row_id ASC");
|
|
338
|
+
return `ORDER BY ${clauses.join(", ")}`;
|
|
339
|
+
}
|
|
340
|
+
export function projectionIndexStatus(sources) {
|
|
341
|
+
if (sources.some((source) => source.status === "building"))
|
|
342
|
+
return "building";
|
|
343
|
+
if (sources.some((source) => source.status === "error"))
|
|
344
|
+
return "error";
|
|
345
|
+
return "ready";
|
|
346
|
+
}
|
|
347
|
+
export function matchesProjectionSource(file, cache, source) {
|
|
348
|
+
if (!source)
|
|
349
|
+
return true;
|
|
350
|
+
if (source.extensions?.length) {
|
|
351
|
+
const extension = file.extension.replace(/^\./, "").toLowerCase();
|
|
352
|
+
if (!source.extensions.some((entry) => entry.replace(/^\./, "").toLowerCase() === extension)) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
if (source.basename && file.name !== source.basename)
|
|
357
|
+
return false;
|
|
358
|
+
if (source.pathPrefix) {
|
|
359
|
+
const prefix = source.pathPrefix.replace(/^\/+|\/+$/g, "");
|
|
360
|
+
if (file.path !== prefix && !file.path.startsWith(`${prefix}/`))
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
if (source.propertyEquals) {
|
|
364
|
+
const frontmatter = cache?.frontmatter ?? {};
|
|
365
|
+
for (const [key, value] of Object.entries(source.propertyEquals)) {
|
|
366
|
+
if (frontmatter[key] !== value)
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
export class IndexProjectionRegistry {
|
|
373
|
+
registrations = new Map();
|
|
374
|
+
register(ownerPluginId, registration) {
|
|
375
|
+
const projectionId = qualifyProjectionId(ownerPluginId, registration.id);
|
|
376
|
+
const record = { projectionId, ownerPluginId, registration };
|
|
377
|
+
this.registrations.set(projectionId, record);
|
|
378
|
+
return record;
|
|
379
|
+
}
|
|
380
|
+
unregister(projectionId) {
|
|
381
|
+
this.registrations.delete(projectionId);
|
|
382
|
+
}
|
|
383
|
+
get(projectionId) {
|
|
384
|
+
return this.registrations.get(projectionId);
|
|
385
|
+
}
|
|
386
|
+
matching(file, cache) {
|
|
387
|
+
return [...this.registrations.values()].filter((entry) => matchesProjectionSource(file, cache, entry.registration.source));
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
export function sourceIsCurrent(source, fileHash, definition, includeStale = false) {
|
|
391
|
+
if (includeStale)
|
|
392
|
+
return true;
|
|
393
|
+
if (source.status !== "ready")
|
|
394
|
+
return false;
|
|
395
|
+
if (source.schemaVersion !== definition.schemaVersion)
|
|
396
|
+
return false;
|
|
397
|
+
if (source.configHash !== definition.configHash)
|
|
398
|
+
return false;
|
|
399
|
+
if (fileHash == null)
|
|
400
|
+
return true;
|
|
401
|
+
return source.sourceHash === fileHash;
|
|
402
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from "./fs";
|
|
2
|
+
export * from "./memory-vault-adapter";
|
|
3
|
+
export * from "./blob-store";
|
|
4
|
+
export * from "./app-database";
|
|
5
|
+
export * from "./task-projection";
|
|
6
|
+
export * from "./index-projection";
|
|
7
|
+
export * from "./turso-app-database";
|
|
8
|
+
export * from "./search-embedding-provider";
|
|
9
|
+
export * from "./path";
|
|
10
|
+
export * from "./keyval";
|
|
11
|
+
export * from "./vault-state";
|
|
12
|
+
export * from "./native-vault-bootstrap-kv";
|
|
13
|
+
export * from "./vault-session";
|
|
14
|
+
export * from "./desktop-native";
|
|
15
|
+
export * from "./browser";
|
|
16
|
+
export * from "./browser-coordinated-app-database";
|
|
17
|
+
export * from "./vault.svelte";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from "./fs";
|
|
2
|
+
export * from "./memory-vault-adapter";
|
|
3
|
+
export * from "./blob-store";
|
|
4
|
+
export * from "./app-database";
|
|
5
|
+
export * from "./task-projection";
|
|
6
|
+
export * from "./index-projection";
|
|
7
|
+
export * from "./turso-app-database";
|
|
8
|
+
export * from "./search-embedding-provider";
|
|
9
|
+
export * from "./path";
|
|
10
|
+
export * from "./keyval";
|
|
11
|
+
export * from "./vault-state";
|
|
12
|
+
export * from "./native-vault-bootstrap-kv";
|
|
13
|
+
export * from "./vault-session";
|
|
14
|
+
export * from "./desktop-native";
|
|
15
|
+
export * from "./browser";
|
|
16
|
+
export * from "./browser-coordinated-app-database";
|
|
17
|
+
export * from "./vault.svelte";
|