mindoodb-app-sdk 0.0.6 → 0.0.8

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/README.md CHANGED
@@ -57,7 +57,7 @@ npm install mindoodb-app-sdk
57
57
  The fastest way to start building is to clone the **example app**, run it locally, and connect it to Haven:
58
58
 
59
59
  ```bash
60
- git clone https://github.com/niclas-niclas/mindoodb-app-example.git
60
+ git clone https://github.com/klehmann/mindoodb-app-example.git
61
61
  cd mindoodb-app-example
62
62
  npm install
63
63
  npm run dev:local
@@ -73,9 +73,9 @@ Then, in Haven:
73
73
 
74
74
  From here, **fork or duplicate** the example project to start building your own app while exploring the platform in a running Haven client.
75
75
 
76
- The example app is also deployed at **https://mindoodb-app-example.mindoo.de** so you can register it in Haven without running anything locally.
76
+ The example app is also deployed at **https://app-example.mindoodb.com** so you can register it in Haven without running anything locally.
77
77
 
78
- > See the [mindoodb-app-example README](https://github.com/niclas-niclas/mindoodb-app-example) for the full project walkthrough.
78
+ > See the [mindoodb-app-example README](https://github.com/klehmann/mindoodb-app-example) for the full project walkthrough.
79
79
 
80
80
  ## Quick start (from scratch)
81
81
 
@@ -410,20 +410,26 @@ const unsupported = canPreviewAttachment("data.bin", "application/octet-stream")
410
410
 
411
411
  ### Virtual Views
412
412
 
413
- Views let you query documents with categorization, sorting, filtering, and aggregation -- similar to a spreadsheet pivot table. There are two ways to work with views:
413
+ Views let you query documents with categorization, sorting, filtering, and aggregation -- similar to a spreadsheet pivot table. The SDK now exposes a **stateful navigator API** that mirrors the core `VirtualViewNavigator` closely.
414
414
 
415
- **App-defined views** -- create a view definition programmatically:
415
+ There are two ways to open one:
416
+
417
+ **App-defined multi-database views** -- create a view definition programmatically and immediately open a navigator:
416
418
 
417
419
  ```ts
418
420
  import { createViewLanguage } from "mindoodb-app-sdk";
419
421
 
420
422
  const v = createViewLanguage<{ employee: string; hours: number }>();
421
423
 
422
- const view = await session.createView({
423
- databaseId: "main",
424
+ const navigator = await session.createViewNavigator({
425
+ databaseIds: ["main", "archive"],
424
426
  definition: {
425
427
  title: "Hours by employee",
426
428
  defaultExpand: "collapsed",
429
+ filter: {
430
+ mode: "expression",
431
+ expression: v.gt(v.toNumber(v.field("hours")), v.number(0)),
432
+ },
427
433
  columns: [
428
434
  {
429
435
  name: "employee",
@@ -442,27 +448,98 @@ const view = await session.createView({
442
448
  },
443
449
  });
444
450
 
445
- const page = await view.page({ pageSize: 100 });
446
- console.log(page.rows);
447
- await view.dispose();
451
+ const batch = await navigator.entriesForward({ limit: 100 });
452
+ console.log(batch.entries);
453
+
454
+ await navigator.dispose();
448
455
  ```
449
456
 
450
- **Haven-configured views** -- open views that the Haven administrator attached to the app registration:
457
+ **Haven-configured views** -- open a view that Haven attached to the app registration:
451
458
 
452
459
  ```ts
453
460
  const viewDefs = ctx.views; // from launch context
454
461
 
455
- const view = await session.openView(viewDefs[0]!.id);
456
- const page = await view.page({ pageSize: 50 });
462
+ const navigator = await session.openViewNavigator(viewDefs[0]!.id, {
463
+ includeCategories: true,
464
+ includeDocuments: true,
465
+ hideEmptyCategories: true,
466
+ });
467
+
468
+ await navigator.gotoFirst();
469
+ const current = await navigator.getCurrentEntry();
470
+ console.log(current);
471
+
472
+ await navigator.dispose();
473
+ ```
474
+
475
+ #### Common navigator patterns
476
+
477
+ **Single-step traversal**:
478
+
479
+ ```ts
480
+ await navigator.gotoFirst();
481
+
482
+ do {
483
+ const entry = await navigator.getCurrentEntry();
484
+ if (entry) {
485
+ console.log(entry.kind, entry.categoryPath, entry.columnValues);
486
+ }
487
+ } while (await navigator.gotoNext());
488
+ ```
489
+
490
+ **Batch reads for UI rendering**:
491
+
492
+ ```ts
493
+ const page1 = await navigator.entriesForward({ limit: 50 });
494
+ const page2 = page1.nextPosition
495
+ ? await navigator.entriesForward({ limit: 50, startPosition: page1.nextPosition })
496
+ : null;
497
+ ```
498
+
499
+ **Category lookup plus child traversal**:
457
500
 
458
- // Expand/collapse categories
459
- await view.expandAll();
460
- await view.collapse(someCategoryKey);
501
+ ```ts
502
+ const category = await navigator.findCategoryEntryByParts(["Ada"]);
503
+ if (category) {
504
+ const docs = await navigator.childDocuments(category.key);
505
+ console.log(docs.map((entry) => entry.docId));
506
+ }
507
+ ```
461
508
 
462
- await view.dispose();
509
+ **Key lookup and key-range lookup**:
510
+
511
+ ```ts
512
+ const category = await navigator.findCategoryEntryByParts(["Ada"]);
513
+ if (category) {
514
+ const exact = await navigator.childDocumentsByKey(category.key, "2026-04-14", true);
515
+ const range = await navigator.childDocumentsBetween(category.key, {
516
+ startKey: "2026-04-01",
517
+ endKey: "2026-04-30",
518
+ });
519
+ }
463
520
  ```
464
521
 
465
- The expression language is fully declarative -- apps define filter and column logic through a typed builder API that compiles to JSON-safe expression objects. No app-provided JavaScript runs inside the bridge host.
522
+ **Expansion and selection state**:
523
+
524
+ ```ts
525
+ await navigator.expandAll();
526
+ await navigator.select("main", "doc-123");
527
+
528
+ const expansion = await navigator.getExpansionState();
529
+ const selection = await navigator.getSelectionState();
530
+
531
+ await navigator.setExpansionState(expansion);
532
+ await navigator.setSelectionState(selection);
533
+ ```
534
+
535
+ The expression language is fully declarative: apps define filter and column logic through a typed builder API that compiles to JSON-safe expression objects. No app-provided JavaScript runs inside the bridge host.
536
+
537
+ #### Performance notes
538
+
539
+ - `goto*()` and `getCurrentEntry()` are lightweight stateful cursor operations. They may still produce many bridge round-trips if you call them for every rendered row.
540
+ - `entriesForward()` and `entriesBackward()` exist specifically to reduce those round-trips for UI rendering.
541
+ - `refresh()` rebuilds or invalidates the host-side navigator state and should be treated as an expensive operation compared to simple cursor movement.
542
+ - Child/key/range helpers operate on the same host-side navigator session. They do not create a separate query engine.
466
543
 
467
544
  Available expression helpers:
468
545
 
@@ -494,7 +571,7 @@ See [`TESTING.md`](./TESTING.md) for setup instructions and Vitest examples.
494
571
 
495
572
  MindooDB Apps are standard web applications -- deploy them anywhere you can serve static files.
496
573
 
497
- **Cloudflare Pages / Workers** is one of the easiest options. The [example app](https://github.com/niclas-niclas/mindoodb-app-example) is deployed this way at https://mindoodb-app-example.mindoo.de using a simple `wrangler.jsonc` configuration:
574
+ **Cloudflare Pages / Workers** is one of the easiest options. The [example app](https://github.com/klehmann/mindoodb-app-example) is deployed this way at https://app-example.mindoodb.com using a simple `wrangler.jsonc` configuration:
498
575
 
499
576
  ```bash
500
577
  npm run build
@@ -534,8 +611,8 @@ Connect options: `launchId?`, `targetOrigin?`, `connectTimeoutMs?`.
534
611
  | `getLaunchContext()` | `Promise<MindooDBAppLaunchContext>` |
535
612
  | `listDatabases()` | `Promise<MindooDBAppDatabaseInfo[]>` |
536
613
  | `openDatabase(databaseId)` | `Promise<MindooDBAppDatabase>` |
537
- | `createView(input)` | `Promise<MindooDBAppViewHandle>` |
538
- | `openView(viewId)` | `Promise<MindooDBAppViewHandle>` |
614
+ | `createViewNavigator(input)` | `Promise<MindooDBAppViewNavigator>` |
615
+ | `openViewNavigator(viewId, options?)` | `Promise<MindooDBAppViewNavigator>` |
539
616
  | `onThemeChange(listener)` | `() => void` (unsubscribe) |
540
617
  | `onViewportChange(listener)` | `() => void` (unsubscribe) |
541
618
  | `disconnect()` | `Promise<void>` |
@@ -572,23 +649,45 @@ Connect options: `launchId?`, `targetOrigin?`, `connectTimeoutMs?`.
572
649
  | `openWriteStream(docId, attachmentName, contentType?)` | `Promise<MindooDBAppWritableAttachmentStream>` |
573
650
  | `openPreview(docId, attachmentName, options?)` | `Promise<{ ok: true }>` |
574
651
 
575
- ### MindooDBAppViewHandle
652
+ ### MindooDBAppViewNavigator
576
653
 
577
654
  | Method | Returns |
578
655
  |---|---|
579
656
  | `getDefinition()` | `Promise<MindooDBAppViewDefinition>` |
580
657
  | `refresh()` | `Promise<void>` |
581
- | `page(input?)` | `Promise<MindooDBAppViewPageResult>` |
582
- | `getExpansionState()` | `Promise<MindooDBAppViewExpansionState>` |
583
- | `setExpansionState(state)` | `Promise<MindooDBAppViewExpansionState>` |
584
- | `expand(rowKey)` | `Promise<MindooDBAppViewExpansionState>` |
585
- | `collapse(rowKey)` | `Promise<MindooDBAppViewExpansionState>` |
586
- | `expandAll()` | `Promise<MindooDBAppViewExpansionState>` |
587
- | `collapseAll()` | `Promise<MindooDBAppViewExpansionState>` |
588
- | `getRow(rowKey)` | `Promise<MindooDBAppViewRow \| null>` |
589
- | `getCategory(input)` | `Promise<MindooDBAppViewRow \| null>` |
590
- | `pageCategory(categoryKey, input?)` | `Promise<MindooDBAppViewPageResult>` |
591
- | `listCategoryDocumentIds(categoryKey)` | `Promise<string[]>` |
658
+ | `getCurrentEntry()` | `Promise<MindooDBAppViewEntry \| null>` |
659
+ | `gotoFirst()` / `gotoLast()` | `Promise<boolean>` |
660
+ | `gotoNext()` / `gotoPrev()` | `Promise<boolean>` |
661
+ | `gotoNextSibling()` / `gotoPrevSibling()` | `Promise<boolean>` |
662
+ | `gotoParent()` | `Promise<boolean>` |
663
+ | `gotoFirstChild()` / `gotoLastChild()` | `Promise<boolean>` |
664
+ | `gotoPos(position)` | `Promise<boolean>` |
665
+ | `getPos(position)` | `Promise<MindooDBAppViewEntry \| null>` |
666
+ | `findCategoryEntryByParts(parts)` | `Promise<MindooDBAppViewEntry \| null>` |
667
+ | `entriesForward(options?)` | `Promise<MindooDBAppViewNavigatorPageResult>` |
668
+ | `entriesBackward(options?)` | `Promise<MindooDBAppViewNavigatorPageResult>` |
669
+ | `gotoNextSelected()` / `gotoPrevSelected()` | `Promise<boolean>` |
670
+ | `select(origin, docId, selectParentCategories?)` | `Promise<void>` |
671
+ | `deselect(origin, docId)` | `Promise<void>` |
672
+ | `selectAllEntries()` / `deselectAllEntries()` | `Promise<void>` |
673
+ | `isSelected(origin, docId)` | `Promise<boolean>` |
674
+ | `getSelectionState()` | `Promise<MindooDBAppViewNavigatorSelectionState>` |
675
+ | `setSelectionState(state)` | `Promise<void>` |
676
+ | `expand(origin, docId)` / `collapse(origin, docId)` | `Promise<void>` |
677
+ | `expandAll()` / `collapseAll()` | `Promise<void>` |
678
+ | `expandToLevel(level)` | `Promise<void>` |
679
+ | `isExpanded(entryKey)` | `Promise<boolean>` |
680
+ | `getExpansionState()` | `Promise<MindooDBAppViewNavigatorExpansionState>` |
681
+ | `setExpansionState(state)` | `Promise<void>` |
682
+ | `childEntries(entryKey, descending?)` | `Promise<MindooDBAppViewEntry[]>` |
683
+ | `childCategories(entryKey, descending?)` | `Promise<MindooDBAppViewEntry[]>` |
684
+ | `childDocuments(entryKey, descending?)` | `Promise<MindooDBAppViewEntry[]>` |
685
+ | `childCategoriesByKey(entryKey, key, exact?, descending?)` | `Promise<MindooDBAppViewEntry[]>` |
686
+ | `childDocumentsByKey(entryKey, key, exact?, descending?)` | `Promise<MindooDBAppViewEntry[]>` |
687
+ | `childCategoriesBetween(entryKey, range)` | `Promise<MindooDBAppViewEntry[]>` |
688
+ | `childDocumentsBetween(entryKey, range)` | `Promise<MindooDBAppViewEntry[]>` |
689
+ | `getSortedDocIds(descending?)` | `Promise<MindooDBAppScopedDocId[]>` |
690
+ | `getSortedDocIdsScoped(entryKey, descending?)` | `Promise<MindooDBAppScopedDocId[]>` |
592
691
  | `dispose()` | `Promise<void>` |
593
692
 
594
693
  ### Exported functions
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppBridge } from './types-BDY_80wd.js';
2
- export { b as MindooDBAppAttachmentApi, c as MindooDBAppAttachmentChunk, d as MindooDBAppAttachmentInfo, e as MindooDBAppAttachmentPreviewOptions, f as MindooDBAppBridgeConnectMessage, g as MindooDBAppBridgeConnectOptions, h as MindooDBAppBridgeConnectedMessage, i as MindooDBAppBridgeErrorPayload, j as MindooDBAppBridgePortMessage, k as MindooDBAppBridgeRpcError, l as MindooDBAppBridgeRpcMessage, m as MindooDBAppBridgeRpcRequest, n as MindooDBAppBridgeRpcSuccess, o as MindooDBAppBridgeStreamAbortRequest, p as MindooDBAppBridgeStreamAck, q as MindooDBAppBridgeStreamCloseRequest, r as MindooDBAppBridgeStreamError, s as MindooDBAppBridgeStreamMessage, t as MindooDBAppBridgeStreamOpenResult, u as MindooDBAppBridgeStreamReadRequest, v as MindooDBAppBridgeStreamWriteRequest, w as MindooDBAppBridgeThemeChangedMessage, x as MindooDBAppBridgeViewportChangedMessage, y as MindooDBAppCapability, z as MindooDBAppConfiguredViewCategorizationStyle, A as MindooDBAppConfiguredViewColumn, B as MindooDBAppConfiguredViewColumnRole, C as MindooDBAppConfiguredViewExpressionMode, D as MindooDBAppConfiguredViewFieldExpression, E as MindooDBAppConfiguredViewFilterDefinition, F as MindooDBAppConfiguredViewFilterMode, G as MindooDBAppConfiguredViewFilterRule, H as MindooDBAppConfiguredViewFormulaExpression, I as MindooDBAppConfiguredViewFormulaFilterDefinition, J as MindooDBAppConfiguredViewPreviewMode, K as MindooDBAppConfiguredViewRuleFilterDefinition, L as MindooDBAppConfiguredViewRuleMatchMode, N as MindooDBAppConfiguredViewRuleOperator, O as MindooDBAppConfiguredViewValueExpression, P as MindooDBAppCreateDocumentInput, Q as MindooDBAppCreateViewInput, R as MindooDBAppDatabase, S as MindooDBAppDatabaseInfo, T as MindooDBAppDocument, U as MindooDBAppDocumentApi, V as MindooDBAppDocumentHistoryEntry, W as MindooDBAppDocumentListQuery, X as MindooDBAppDocumentListResult, Y as MindooDBAppDocumentSummary, Z as MindooDBAppHistoricalDocument, _ as MindooDBAppHistoryQuery, $ as MindooDBAppHostTheme, a0 as MindooDBAppLaunchContext, a1 as MindooDBAppReadableAttachmentStream, a2 as MindooDBAppResolvedViewDefinition, a3 as MindooDBAppResolvedViewSource, a4 as MindooDBAppRuntime, a5 as MindooDBAppSession, a6 as MindooDBAppThemeMode, a7 as MindooDBAppUpdateDocumentInput, a8 as MindooDBAppViewHandle, a9 as MindooDBAppViewport, aa as MindooDBAppWritableAttachmentStream } from './types-BDY_80wd.js';
1
+ import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppBridge } from './types-C_kZcG24.js';
2
+ export { b as MindooDBAppAttachmentApi, c as MindooDBAppAttachmentChunk, d as MindooDBAppAttachmentInfo, e as MindooDBAppAttachmentPreviewOptions, f as MindooDBAppAttachmentPreviewSession, g as MindooDBAppBridgeConnectMessage, h as MindooDBAppBridgeConnectOptions, i as MindooDBAppBridgeConnectedMessage, j as MindooDBAppBridgeErrorPayload, k as MindooDBAppBridgePortMessage, l as MindooDBAppBridgeRpcError, m as MindooDBAppBridgeRpcMessage, n as MindooDBAppBridgeRpcRequest, o as MindooDBAppBridgeRpcSuccess, p as MindooDBAppBridgeStreamAbortRequest, q as MindooDBAppBridgeStreamAck, r as MindooDBAppBridgeStreamCloseRequest, s as MindooDBAppBridgeStreamError, t as MindooDBAppBridgeStreamMessage, u as MindooDBAppBridgeStreamOpenResult, v as MindooDBAppBridgeStreamReadRequest, w as MindooDBAppBridgeStreamWriteRequest, x as MindooDBAppBridgeThemeChangedMessage, y as MindooDBAppBridgeViewportChangedMessage, z as MindooDBAppCapability, A as MindooDBAppConfiguredViewCategorizationStyle, B as MindooDBAppConfiguredViewColumn, C as MindooDBAppConfiguredViewColumnRole, D as MindooDBAppConfiguredViewExpressionMode, E as MindooDBAppConfiguredViewFieldExpression, F as MindooDBAppConfiguredViewFilterDefinition, G as MindooDBAppConfiguredViewFilterMode, H as MindooDBAppConfiguredViewFilterRule, I as MindooDBAppConfiguredViewFormulaExpression, J as MindooDBAppConfiguredViewFormulaFilterDefinition, K as MindooDBAppConfiguredViewPreviewMode, L as MindooDBAppConfiguredViewRuleFilterDefinition, N as MindooDBAppConfiguredViewRuleMatchMode, O as MindooDBAppConfiguredViewRuleOperator, P as MindooDBAppConfiguredViewValueExpression, Q as MindooDBAppCreateDocumentInput, R as MindooDBAppCreateViewInput, S as MindooDBAppCreateViewNavigatorInput, T as MindooDBAppDatabase, U as MindooDBAppDatabaseInfo, V as MindooDBAppDocument, W as MindooDBAppDocumentApi, X as MindooDBAppDocumentHistoryEntry, Y as MindooDBAppDocumentListQuery, Z as MindooDBAppDocumentListResult, _ as MindooDBAppDocumentSummary, $ as MindooDBAppHistoricalDocument, a0 as MindooDBAppHistoryQuery, a1 as MindooDBAppHostTheme, a2 as MindooDBAppLaunchContext, a3 as MindooDBAppReadableAttachmentStream, a4 as MindooDBAppResolvedViewDefinition, a5 as MindooDBAppResolvedViewSource, a6 as MindooDBAppRuntime, a7 as MindooDBAppScopedDocId, a8 as MindooDBAppSession, a9 as MindooDBAppThemeMode, aa as MindooDBAppUpdateDocumentInput, ab as MindooDBAppViewEntry, ac as MindooDBAppViewEntryKind, ad as MindooDBAppViewNavigator, ae as MindooDBAppViewNavigatorExpansionState, af as MindooDBAppViewNavigatorOpenOptions, ag as MindooDBAppViewNavigatorPageOptions, ah as MindooDBAppViewNavigatorPageResult, ai as MindooDBAppViewNavigatorRangeQuery, aj as MindooDBAppViewNavigatorSelectionState, ak as MindooDBAppViewport, al as MindooDBAppWritableAttachmentStream } from './types-C_kZcG24.js';
3
3
  export { MindooDBAppBooleanExpression, MindooDBAppExpression, MindooDBAppFilterDefinition, MindooDBAppViewCategoryChildrenPageRequest, MindooDBAppViewColumn, MindooDBAppViewColumnRole, MindooDBAppViewDefinition, MindooDBAppViewExpansionState, MindooDBAppViewExpressionBase, MindooDBAppViewExpressionDatePart, MindooDBAppViewExpressionOperation, MindooDBAppViewFieldExpression, MindooDBAppViewIfExpression, MindooDBAppViewLetExpression, MindooDBAppViewLiteralExpression, MindooDBAppViewLookupByPath, MindooDBAppViewOperationExpression, MindooDBAppViewOriginExpression, MindooDBAppViewPageRequest, MindooDBAppViewPageResult, MindooDBAppViewRow, MindooDBAppViewSortDirection, MindooDBAppViewTotalMode, MindooDBAppViewValueExpressionRef, MindooDBAppViewVariableExpression, createViewLanguage } from 'mindoodb-view-language';
4
4
 
5
5
  /**
package/dist/index.js CHANGED
@@ -307,89 +307,163 @@ function waitForConnectedPort(options, launchId) {
307
307
  targetWindow.postMessage(message, targetOrigin, [channel.port2]);
308
308
  });
309
309
  }
310
- var MindooDBAppViewHandleImpl = class {
311
- constructor(rpc, viewId) {
310
+ var MindooDBAppViewNavigatorImpl = class {
311
+ constructor(rpc, navigatorId) {
312
312
  this.rpc = rpc;
313
- this.viewId = viewId;
313
+ this.navigatorId = navigatorId;
314
314
  }
315
- async getDefinition() {
316
- return await this.rpc.call("views.getDefinition", {
317
- viewId: this.viewId
315
+ /** Shorthand: call an RPC method with the navigator ID automatically injected. */
316
+ async call(method, params = {}) {
317
+ return await this.rpc.call(method, {
318
+ navigatorId: this.navigatorId,
319
+ ...params
318
320
  });
319
321
  }
322
+ async getDefinition() {
323
+ return await this.call("viewNavigators.getDefinition");
324
+ }
320
325
  async refresh() {
321
- await this.rpc.call("views.refresh", {
322
- viewId: this.viewId
323
- });
326
+ await this.call("viewNavigators.refresh");
324
327
  }
325
- async page(input) {
326
- return await this.rpc.call("views.page", {
327
- viewId: this.viewId,
328
- request: input ?? {}
329
- });
328
+ async getCurrentEntry() {
329
+ return await this.call("viewNavigators.current.get");
330
330
  }
331
- async getExpansionState() {
332
- return await this.rpc.call("views.expansion.get", {
333
- viewId: this.viewId
334
- });
331
+ async gotoFirst() {
332
+ return await this.call("viewNavigators.goto.first");
335
333
  }
336
- async setExpansionState(state) {
337
- return await this.rpc.call("views.expansion.set", {
338
- viewId: this.viewId,
339
- expansion: state
340
- });
334
+ async gotoLast() {
335
+ return await this.call("viewNavigators.goto.last");
341
336
  }
342
- async expand(rowKey) {
343
- return await this.rpc.call("views.expansion.expand", {
344
- viewId: this.viewId,
345
- rowKey
346
- });
337
+ async gotoNext() {
338
+ return await this.call("viewNavigators.goto.next");
339
+ }
340
+ async gotoPrev() {
341
+ return await this.call("viewNavigators.goto.prev");
342
+ }
343
+ async gotoNextSibling() {
344
+ return await this.call("viewNavigators.goto.nextSibling");
345
+ }
346
+ async gotoPrevSibling() {
347
+ return await this.call("viewNavigators.goto.prevSibling");
348
+ }
349
+ async gotoParent() {
350
+ return await this.call("viewNavigators.goto.parent");
347
351
  }
348
- async collapse(rowKey) {
349
- return await this.rpc.call("views.expansion.collapse", {
350
- viewId: this.viewId,
351
- rowKey
352
+ async gotoFirstChild() {
353
+ return await this.call("viewNavigators.goto.firstChild");
354
+ }
355
+ async gotoLastChild() {
356
+ return await this.call("viewNavigators.goto.lastChild");
357
+ }
358
+ async gotoPos(position) {
359
+ return await this.call("viewNavigators.goto.pos", { position });
360
+ }
361
+ async getPos(position) {
362
+ return await this.call("viewNavigators.pos.get", { position });
363
+ }
364
+ async findCategoryEntryByParts(parts) {
365
+ return await this.call("viewNavigators.category.findByParts", { parts });
366
+ }
367
+ async entriesForward(options) {
368
+ return await this.call("viewNavigators.entries.forward", { options: options ?? {} });
369
+ }
370
+ async entriesBackward(options) {
371
+ return await this.call("viewNavigators.entries.backward", { options: options ?? {} });
372
+ }
373
+ async gotoNextSelected() {
374
+ return await this.call("viewNavigators.goto.nextSelected");
375
+ }
376
+ async gotoPrevSelected() {
377
+ return await this.call("viewNavigators.goto.prevSelected");
378
+ }
379
+ async select(origin, docId, selectParentCategories) {
380
+ await this.call("viewNavigators.selection.select", {
381
+ origin,
382
+ docId,
383
+ selectParentCategories
352
384
  });
353
385
  }
386
+ async deselect(origin, docId) {
387
+ await this.call("viewNavigators.selection.deselect", { origin, docId });
388
+ }
389
+ async selectAllEntries() {
390
+ await this.call("viewNavigators.selection.selectAll");
391
+ }
392
+ async deselectAllEntries() {
393
+ await this.call("viewNavigators.selection.deselectAll");
394
+ }
395
+ async isSelected(origin, docId) {
396
+ return await this.call("viewNavigators.selection.isSelected", { origin, docId });
397
+ }
398
+ async getSelectionState() {
399
+ return await this.call("viewNavigators.selection.get");
400
+ }
401
+ async setSelectionState(state) {
402
+ await this.call("viewNavigators.selection.set", { state });
403
+ }
404
+ async expand(origin, docId) {
405
+ await this.call("viewNavigators.expansion.expand", { origin, docId });
406
+ }
407
+ async collapse(origin, docId) {
408
+ await this.call("viewNavigators.expansion.collapse", { origin, docId });
409
+ }
354
410
  async expandAll() {
355
- return await this.rpc.call("views.expansion.expandAll", {
356
- viewId: this.viewId
357
- });
411
+ await this.call("viewNavigators.expansion.expandAll");
358
412
  }
359
413
  async collapseAll() {
360
- return await this.rpc.call("views.expansion.collapseAll", {
361
- viewId: this.viewId
362
- });
414
+ await this.call("viewNavigators.expansion.collapseAll");
363
415
  }
364
- async getRow(rowKey) {
365
- return await this.rpc.call("views.row.get", {
366
- viewId: this.viewId,
367
- rowKey
368
- });
416
+ async expandToLevel(level) {
417
+ await this.call("viewNavigators.expansion.expandToLevel", { level });
369
418
  }
370
- async getCategory(input) {
371
- return await this.rpc.call("views.category.get", {
372
- viewId: this.viewId,
373
- lookup: input
374
- });
419
+ async isExpanded(entryKey) {
420
+ return await this.call("viewNavigators.expansion.isExpanded", { entryKey });
421
+ }
422
+ async getExpansionState() {
423
+ return await this.call("viewNavigators.expansion.get");
424
+ }
425
+ async setExpansionState(state) {
426
+ await this.call("viewNavigators.expansion.set", { state });
427
+ }
428
+ async childEntries(entryKey, descending) {
429
+ return await this.call("viewNavigators.children.entries", { entryKey, descending });
430
+ }
431
+ async childCategories(entryKey, descending) {
432
+ return await this.call("viewNavigators.children.categories", { entryKey, descending });
375
433
  }
376
- async pageCategory(categoryKey, input) {
377
- return await this.rpc.call("views.category.page", {
378
- viewId: this.viewId,
379
- categoryKey,
380
- request: input ?? {}
434
+ async childDocuments(entryKey, descending) {
435
+ return await this.call("viewNavigators.children.documents", { entryKey, descending });
436
+ }
437
+ async childCategoriesByKey(entryKey, key, exact, descending) {
438
+ return await this.call("viewNavigators.children.categoriesByKey", {
439
+ entryKey,
440
+ key,
441
+ exact,
442
+ descending
381
443
  });
382
444
  }
383
- async listCategoryDocumentIds(categoryKey) {
384
- return await this.rpc.call("views.category.documentIds", {
385
- viewId: this.viewId,
386
- categoryKey
445
+ async childDocumentsByKey(entryKey, key, exact, descending) {
446
+ return await this.call("viewNavigators.children.documentsByKey", {
447
+ entryKey,
448
+ key,
449
+ exact,
450
+ descending
387
451
  });
388
452
  }
453
+ async childCategoriesBetween(entryKey, range) {
454
+ return await this.call("viewNavigators.children.categoriesBetween", { entryKey, range });
455
+ }
456
+ async childDocumentsBetween(entryKey, range) {
457
+ return await this.call("viewNavigators.children.documentsBetween", { entryKey, range });
458
+ }
459
+ async getSortedDocIds(descending) {
460
+ return await this.call("viewNavigators.sortedDocIds.get", { descending });
461
+ }
462
+ async getSortedDocIdsScoped(entryKey, descending) {
463
+ return await this.call("viewNavigators.sortedDocIds.scoped", { entryKey, descending });
464
+ }
389
465
  async dispose() {
390
- await this.rpc.call("views.dispose", {
391
- viewId: this.viewId
392
- });
466
+ await this.call("viewNavigators.dispose");
393
467
  }
394
468
  };
395
469
  var MindooDBAppReadableAttachmentStreamImpl = class {
@@ -607,6 +681,12 @@ var MindooDBAppDatabaseImpl = class {
607
681
  });
608
682
  return new MindooDBAppWritableAttachmentStreamImpl(this.rpc, result.streamId);
609
683
  },
684
+ preparePreviewSession: async (docId, attachmentName, options) => await this.rpc.call("attachments.preparePreviewSession", {
685
+ databaseId: this.databaseId,
686
+ docId,
687
+ attachmentName,
688
+ timestamp: options?.timestamp
689
+ }),
610
690
  openPreview: async (docId, attachmentName, options) => await this.rpc.call("attachments.openPreview", {
611
691
  databaseId: this.databaseId,
612
692
  docId,
@@ -632,6 +712,7 @@ var MindooDBAppSessionImpl = class {
632
712
  async getLaunchContext() {
633
713
  return await this.rpc.call("session.getLaunchContext", {});
634
714
  }
715
+ /** Lists the databases that the host has made available for this app session. */
635
716
  async listDatabases() {
636
717
  return await this.rpc.call("session.listDatabases", {});
637
718
  }
@@ -640,14 +721,28 @@ var MindooDBAppSessionImpl = class {
640
721
  await this.rpc.call("session.openDatabase", { databaseId });
641
722
  return new MindooDBAppDatabaseImpl(this.rpc, databaseId);
642
723
  }
643
- async createView(input) {
644
- const result = await this.rpc.call("session.createView", input);
645
- return new MindooDBAppViewHandleImpl(this.rpc, result.viewId);
646
- }
647
- async openView(viewId) {
648
- await this.rpc.call("session.openView", { viewId });
649
- return new MindooDBAppViewHandleImpl(this.rpc, viewId);
650
- }
724
+ /**
725
+ * Create a navigator from an ad-hoc view definition and one or more database bindings.
726
+ *
727
+ * The host builds a `VirtualView` from `input.definition`, optionally applying
728
+ * open options (root scoping, category filtering), and returns a `navigatorId`
729
+ * that all subsequent navigator RPCs reference.
730
+ */
731
+ async createViewNavigator(input) {
732
+ const result = await this.rpc.call("session.createViewNavigator", input);
733
+ return new MindooDBAppViewNavigatorImpl(this.rpc, result.navigatorId);
734
+ }
735
+ /**
736
+ * Open a navigator for a preconfigured view that the host already knows about.
737
+ *
738
+ * `viewId` must match one of the views declared in the launch context. The
739
+ * host resolves the full view definition and database bindings automatically.
740
+ */
741
+ async openViewNavigator(viewId, options) {
742
+ const result = await this.rpc.call("session.openViewNavigator", { viewId, options: options ?? {} });
743
+ return new MindooDBAppViewNavigatorImpl(this.rpc, result.navigatorId);
744
+ }
745
+ /** Subscribe to host-pushed theme changes (dark/light mode, color tokens). */
651
746
  onThemeChange(listener) {
652
747
  return this.rpc.addMessageListener((message) => {
653
748
  if (isThemeChangedMessage(message)) {
@@ -655,6 +750,7 @@ var MindooDBAppSessionImpl = class {
655
750
  }
656
751
  });
657
752
  }
753
+ /** Subscribe to host-pushed viewport dimension changes (resize, orientation). */
658
754
  onViewportChange(listener) {
659
755
  return this.rpc.addMessageListener((message) => {
660
756
  if (isViewportChangedMessage(message)) {
@@ -1,10 +1,10 @@
1
- import { a0 as MindooDBAppLaunchContext, S as MindooDBAppDatabaseInfo, U as MindooDBAppDocumentApi, a8 as MindooDBAppViewHandle, b as MindooDBAppAttachmentApi, a as MindooDBAppBridge, a5 as MindooDBAppSession, m as MindooDBAppBridgeRpcRequest, $ as MindooDBAppHostTheme, a9 as MindooDBAppViewport, j as MindooDBAppBridgePortMessage } from '../types-BDY_80wd.js';
2
- import { MindooDBAppViewDefinition } from 'mindoodb-view-language';
1
+ import { a2 as MindooDBAppLaunchContext, U as MindooDBAppDatabaseInfo, W as MindooDBAppDocumentApi, S as MindooDBAppCreateViewNavigatorInput, ad as MindooDBAppViewNavigator, af as MindooDBAppViewNavigatorOpenOptions, b as MindooDBAppAttachmentApi, a as MindooDBAppBridge, a8 as MindooDBAppSession, n as MindooDBAppBridgeRpcRequest, a1 as MindooDBAppHostTheme, ak as MindooDBAppViewport, k as MindooDBAppBridgePortMessage } from '../types-C_kZcG24.js';
2
+ import 'mindoodb-view-language';
3
3
 
4
4
  type MaybePromise<T> = T | Promise<T>;
5
5
  type MockViewApi = {
6
- create(definition: MindooDBAppViewDefinition): MaybePromise<MindooDBAppViewHandle>;
7
- open(viewId: string): MaybePromise<MindooDBAppViewHandle>;
6
+ create(input: MindooDBAppCreateViewNavigatorInput): MaybePromise<MindooDBAppViewNavigator>;
7
+ open(viewId: string, options?: MindooDBAppViewNavigatorOpenOptions): MaybePromise<MindooDBAppViewNavigator>;
8
8
  };
9
9
  type MockDatabaseMethods = {
10
10
  documents?: Partial<MindooDBAppDocumentApi>;