mindoodb-app-sdk 0.0.7 → 0.0.9
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 +198 -29
- package/dist/index.d.ts +2 -2
- package/dist/index.js +165 -68
- package/dist/testing/index.d.ts +4 -4
- package/dist/testing/index.js +347 -89
- package/dist/{types-u5bAeQwY.d.ts → types-Bh1Q2qGN.d.ts} +188 -22
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -137,6 +137,74 @@ interface MindooDBAppLaunchContext {
|
|
|
137
137
|
|
|
138
138
|
`viewport` is the iframe size at launch time. It is `null` when the app runs in `window` mode (separate browser tab). Later changes arrive through `onViewportChange()`.
|
|
139
139
|
|
|
140
|
+
You can use `runtime` to decide when a host-rendered overlay is necessary:
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
const ctx = await session.getLaunchContext();
|
|
144
|
+
|
|
145
|
+
if (ctx.runtime === "iframe") {
|
|
146
|
+
// Prefer host-rendered menus when clipping outside the iframe matters.
|
|
147
|
+
} else {
|
|
148
|
+
// A regular in-app menu is often fine in a separate window.
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Host-rendered menus
|
|
153
|
+
|
|
154
|
+
When your app runs inside an iframe, Haven can render a structured menu above the iframe chrome. This is useful for context menus, toolbar drop-downs, and simple pickers such as font-family or font-size lists.
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
const result = await session.menus.show({
|
|
158
|
+
anchor: {
|
|
159
|
+
type: "point",
|
|
160
|
+
x: event.clientX,
|
|
161
|
+
y: event.clientY,
|
|
162
|
+
},
|
|
163
|
+
kind: "context",
|
|
164
|
+
items: [
|
|
165
|
+
{ id: "rename", label: "Rename" },
|
|
166
|
+
{ separator: true },
|
|
167
|
+
{ id: "delete", label: "Delete", destructive: true },
|
|
168
|
+
],
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
if (result.action === "selected") {
|
|
172
|
+
console.log("Chosen action:", result.itemId);
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Rect anchors work well for button-triggered menus:
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
const bounds = button.getBoundingClientRect();
|
|
180
|
+
const frameBounds = document.documentElement.getBoundingClientRect();
|
|
181
|
+
|
|
182
|
+
await session.menus.show({
|
|
183
|
+
anchor: {
|
|
184
|
+
type: "rect",
|
|
185
|
+
rect: {
|
|
186
|
+
left: bounds.left - frameBounds.left,
|
|
187
|
+
top: bounds.top - frameBounds.top,
|
|
188
|
+
width: bounds.width,
|
|
189
|
+
height: bounds.height,
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
kind: "dropdown",
|
|
193
|
+
placement: "bottom-start",
|
|
194
|
+
items: [
|
|
195
|
+
{ id: "sans", label: "Sans Serif", checked: true },
|
|
196
|
+
{ id: "serif", label: "Serif" },
|
|
197
|
+
],
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Important constraints:
|
|
202
|
+
|
|
203
|
+
- Menus are host-rendered and data-only. Apps cannot pass HTML, CSS, or script.
|
|
204
|
+
- `show()` resolves to either `{ action: "selected", itemId }` or `{ action: "dismissed", reason }`.
|
|
205
|
+
- Call `session.menus.hide()` if your app needs to explicitly dismiss a pending host menu.
|
|
206
|
+
- Host-rendered menus are intended for `runtime === "iframe"`. Window-mode apps can usually show local menus instead.
|
|
207
|
+
|
|
140
208
|
### Databases and capabilities
|
|
141
209
|
|
|
142
210
|
Each database mapped to your app carries a set of **capabilities** that Haven controls. Your app should check capabilities before attempting operations and adapt its UI accordingly.
|
|
@@ -410,20 +478,26 @@ const unsupported = canPreviewAttachment("data.bin", "application/octet-stream")
|
|
|
410
478
|
|
|
411
479
|
### Virtual Views
|
|
412
480
|
|
|
413
|
-
Views let you query documents with categorization, sorting, filtering, and aggregation -- similar to a spreadsheet pivot table.
|
|
481
|
+
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
482
|
|
|
415
|
-
|
|
483
|
+
There are two ways to open one:
|
|
484
|
+
|
|
485
|
+
**App-defined multi-database views** -- create a view definition programmatically and immediately open a navigator:
|
|
416
486
|
|
|
417
487
|
```ts
|
|
418
488
|
import { createViewLanguage } from "mindoodb-app-sdk";
|
|
419
489
|
|
|
420
490
|
const v = createViewLanguage<{ employee: string; hours: number }>();
|
|
421
491
|
|
|
422
|
-
const
|
|
423
|
-
|
|
492
|
+
const navigator = await session.createViewNavigator({
|
|
493
|
+
databaseIds: ["main", "archive"],
|
|
424
494
|
definition: {
|
|
425
495
|
title: "Hours by employee",
|
|
426
496
|
defaultExpand: "collapsed",
|
|
497
|
+
filter: {
|
|
498
|
+
mode: "expression",
|
|
499
|
+
expression: v.gt(v.toNumber(v.field("hours")), v.number(0)),
|
|
500
|
+
},
|
|
427
501
|
columns: [
|
|
428
502
|
{
|
|
429
503
|
name: "employee",
|
|
@@ -442,27 +516,98 @@ const view = await session.createView({
|
|
|
442
516
|
},
|
|
443
517
|
});
|
|
444
518
|
|
|
445
|
-
const
|
|
446
|
-
console.log(
|
|
447
|
-
|
|
519
|
+
const batch = await navigator.entriesForward({ limit: 100 });
|
|
520
|
+
console.log(batch.entries);
|
|
521
|
+
|
|
522
|
+
await navigator.dispose();
|
|
448
523
|
```
|
|
449
524
|
|
|
450
|
-
**Haven-configured views** -- open
|
|
525
|
+
**Haven-configured views** -- open a view that Haven attached to the app registration:
|
|
451
526
|
|
|
452
527
|
```ts
|
|
453
528
|
const viewDefs = ctx.views; // from launch context
|
|
454
529
|
|
|
455
|
-
const
|
|
456
|
-
|
|
530
|
+
const navigator = await session.openViewNavigator(viewDefs[0]!.id, {
|
|
531
|
+
includeCategories: true,
|
|
532
|
+
includeDocuments: true,
|
|
533
|
+
hideEmptyCategories: true,
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
await navigator.gotoFirst();
|
|
537
|
+
const current = await navigator.getCurrentEntry();
|
|
538
|
+
console.log(current);
|
|
539
|
+
|
|
540
|
+
await navigator.dispose();
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
#### Common navigator patterns
|
|
544
|
+
|
|
545
|
+
**Single-step traversal**:
|
|
546
|
+
|
|
547
|
+
```ts
|
|
548
|
+
await navigator.gotoFirst();
|
|
549
|
+
|
|
550
|
+
do {
|
|
551
|
+
const entry = await navigator.getCurrentEntry();
|
|
552
|
+
if (entry) {
|
|
553
|
+
console.log(entry.kind, entry.categoryPath, entry.columnValues);
|
|
554
|
+
}
|
|
555
|
+
} while (await navigator.gotoNext());
|
|
556
|
+
```
|
|
457
557
|
|
|
458
|
-
|
|
459
|
-
await view.expandAll();
|
|
460
|
-
await view.collapse(someCategoryKey);
|
|
558
|
+
**Batch reads for UI rendering**:
|
|
461
559
|
|
|
462
|
-
|
|
560
|
+
```ts
|
|
561
|
+
const page1 = await navigator.entriesForward({ limit: 50 });
|
|
562
|
+
const page2 = page1.nextPosition
|
|
563
|
+
? await navigator.entriesForward({ limit: 50, startPosition: page1.nextPosition })
|
|
564
|
+
: null;
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
**Category lookup plus child traversal**:
|
|
568
|
+
|
|
569
|
+
```ts
|
|
570
|
+
const category = await navigator.findCategoryEntryByParts(["Ada"]);
|
|
571
|
+
if (category) {
|
|
572
|
+
const docs = await navigator.childDocuments(category.key);
|
|
573
|
+
console.log(docs.map((entry) => entry.docId));
|
|
574
|
+
}
|
|
463
575
|
```
|
|
464
576
|
|
|
465
|
-
|
|
577
|
+
**Key lookup and key-range lookup**:
|
|
578
|
+
|
|
579
|
+
```ts
|
|
580
|
+
const category = await navigator.findCategoryEntryByParts(["Ada"]);
|
|
581
|
+
if (category) {
|
|
582
|
+
const exact = await navigator.childDocumentsByKey(category.key, "2026-04-14", true);
|
|
583
|
+
const range = await navigator.childDocumentsBetween(category.key, {
|
|
584
|
+
startKey: "2026-04-01",
|
|
585
|
+
endKey: "2026-04-30",
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
**Expansion and selection state**:
|
|
591
|
+
|
|
592
|
+
```ts
|
|
593
|
+
await navigator.expandAll();
|
|
594
|
+
await navigator.select("main", "doc-123");
|
|
595
|
+
|
|
596
|
+
const expansion = await navigator.getExpansionState();
|
|
597
|
+
const selection = await navigator.getSelectionState();
|
|
598
|
+
|
|
599
|
+
await navigator.setExpansionState(expansion);
|
|
600
|
+
await navigator.setSelectionState(selection);
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
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.
|
|
604
|
+
|
|
605
|
+
#### Performance notes
|
|
606
|
+
|
|
607
|
+
- `goto*()` and `getCurrentEntry()` are lightweight stateful cursor operations. They may still produce many bridge round-trips if you call them for every rendered row.
|
|
608
|
+
- `entriesForward()` and `entriesBackward()` exist specifically to reduce those round-trips for UI rendering.
|
|
609
|
+
- `refresh()` rebuilds or invalidates the host-side navigator state and should be treated as an expensive operation compared to simple cursor movement.
|
|
610
|
+
- Child/key/range helpers operate on the same host-side navigator session. They do not create a separate query engine.
|
|
466
611
|
|
|
467
612
|
Available expression helpers:
|
|
468
613
|
|
|
@@ -534,8 +679,10 @@ Connect options: `launchId?`, `targetOrigin?`, `connectTimeoutMs?`.
|
|
|
534
679
|
| `getLaunchContext()` | `Promise<MindooDBAppLaunchContext>` |
|
|
535
680
|
| `listDatabases()` | `Promise<MindooDBAppDatabaseInfo[]>` |
|
|
536
681
|
| `openDatabase(databaseId)` | `Promise<MindooDBAppDatabase>` |
|
|
537
|
-
| `
|
|
538
|
-
| `
|
|
682
|
+
| `createViewNavigator(input)` | `Promise<MindooDBAppViewNavigator>` |
|
|
683
|
+
| `openViewNavigator(viewId, options?)` | `Promise<MindooDBAppViewNavigator>` |
|
|
684
|
+
| `menus.show(input)` | `Promise<MindooDBAppShowMenuResult>` |
|
|
685
|
+
| `menus.hide()` | `Promise<void>` |
|
|
539
686
|
| `onThemeChange(listener)` | `() => void` (unsubscribe) |
|
|
540
687
|
| `onViewportChange(listener)` | `() => void` (unsubscribe) |
|
|
541
688
|
| `disconnect()` | `Promise<void>` |
|
|
@@ -572,23 +719,45 @@ Connect options: `launchId?`, `targetOrigin?`, `connectTimeoutMs?`.
|
|
|
572
719
|
| `openWriteStream(docId, attachmentName, contentType?)` | `Promise<MindooDBAppWritableAttachmentStream>` |
|
|
573
720
|
| `openPreview(docId, attachmentName, options?)` | `Promise<{ ok: true }>` |
|
|
574
721
|
|
|
575
|
-
###
|
|
722
|
+
### MindooDBAppViewNavigator
|
|
576
723
|
|
|
577
724
|
| Method | Returns |
|
|
578
725
|
|---|---|
|
|
579
726
|
| `getDefinition()` | `Promise<MindooDBAppViewDefinition>` |
|
|
580
727
|
| `refresh()` | `Promise<void>` |
|
|
581
|
-
| `
|
|
582
|
-
| `
|
|
583
|
-
| `
|
|
584
|
-
| `
|
|
585
|
-
| `
|
|
586
|
-
| `
|
|
587
|
-
| `
|
|
588
|
-
| `
|
|
589
|
-
| `
|
|
590
|
-
| `
|
|
591
|
-
| `
|
|
728
|
+
| `getCurrentEntry()` | `Promise<MindooDBAppViewEntry \| null>` |
|
|
729
|
+
| `gotoFirst()` / `gotoLast()` | `Promise<boolean>` |
|
|
730
|
+
| `gotoNext()` / `gotoPrev()` | `Promise<boolean>` |
|
|
731
|
+
| `gotoNextSibling()` / `gotoPrevSibling()` | `Promise<boolean>` |
|
|
732
|
+
| `gotoParent()` | `Promise<boolean>` |
|
|
733
|
+
| `gotoFirstChild()` / `gotoLastChild()` | `Promise<boolean>` |
|
|
734
|
+
| `gotoPos(position)` | `Promise<boolean>` |
|
|
735
|
+
| `getPos(position)` | `Promise<MindooDBAppViewEntry \| null>` |
|
|
736
|
+
| `findCategoryEntryByParts(parts)` | `Promise<MindooDBAppViewEntry \| null>` |
|
|
737
|
+
| `entriesForward(options?)` | `Promise<MindooDBAppViewNavigatorPageResult>` |
|
|
738
|
+
| `entriesBackward(options?)` | `Promise<MindooDBAppViewNavigatorPageResult>` |
|
|
739
|
+
| `gotoNextSelected()` / `gotoPrevSelected()` | `Promise<boolean>` |
|
|
740
|
+
| `select(origin, docId, selectParentCategories?)` | `Promise<void>` |
|
|
741
|
+
| `deselect(origin, docId)` | `Promise<void>` |
|
|
742
|
+
| `selectAllEntries()` / `deselectAllEntries()` | `Promise<void>` |
|
|
743
|
+
| `isSelected(origin, docId)` | `Promise<boolean>` |
|
|
744
|
+
| `getSelectionState()` | `Promise<MindooDBAppViewNavigatorSelectionState>` |
|
|
745
|
+
| `setSelectionState(state)` | `Promise<void>` |
|
|
746
|
+
| `expand(origin, docId)` / `collapse(origin, docId)` | `Promise<void>` |
|
|
747
|
+
| `expandAll()` / `collapseAll()` | `Promise<void>` |
|
|
748
|
+
| `expandToLevel(level)` | `Promise<void>` |
|
|
749
|
+
| `isExpanded(entryKey)` | `Promise<boolean>` |
|
|
750
|
+
| `getExpansionState()` | `Promise<MindooDBAppViewNavigatorExpansionState>` |
|
|
751
|
+
| `setExpansionState(state)` | `Promise<void>` |
|
|
752
|
+
| `childEntries(entryKey, descending?)` | `Promise<MindooDBAppViewEntry[]>` |
|
|
753
|
+
| `childCategories(entryKey, descending?)` | `Promise<MindooDBAppViewEntry[]>` |
|
|
754
|
+
| `childDocuments(entryKey, descending?)` | `Promise<MindooDBAppViewEntry[]>` |
|
|
755
|
+
| `childCategoriesByKey(entryKey, key, exact?, descending?)` | `Promise<MindooDBAppViewEntry[]>` |
|
|
756
|
+
| `childDocumentsByKey(entryKey, key, exact?, descending?)` | `Promise<MindooDBAppViewEntry[]>` |
|
|
757
|
+
| `childCategoriesBetween(entryKey, range)` | `Promise<MindooDBAppViewEntry[]>` |
|
|
758
|
+
| `childDocumentsBetween(entryKey, range)` | `Promise<MindooDBAppViewEntry[]>` |
|
|
759
|
+
| `getSortedDocIds(descending?)` | `Promise<MindooDBAppScopedDocId[]>` |
|
|
760
|
+
| `getSortedDocIdsScoped(entryKey, descending?)` | `Promise<MindooDBAppScopedDocId[]>` |
|
|
592
761
|
| `dispose()` | `Promise<void>` |
|
|
593
762
|
|
|
594
763
|
### Exported functions
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppBridge } from './types-
|
|
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
|
|
1
|
+
import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppBridge } from './types-Bh1Q2qGN.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 MindooDBAppMenuAnchor, a4 as MindooDBAppMenuApi, a5 as MindooDBAppMenuCommandItem, a6 as MindooDBAppMenuDismissReason, a7 as MindooDBAppMenuDismissedResult, a8 as MindooDBAppMenuItem, a9 as MindooDBAppMenuKind, aa as MindooDBAppMenuPlacement, ab as MindooDBAppMenuPointAnchor, ac as MindooDBAppMenuRect, ad as MindooDBAppMenuRectAnchor, ae as MindooDBAppMenuSelectionResult, af as MindooDBAppMenuSeparatorItem, ag as MindooDBAppReadableAttachmentStream, ah as MindooDBAppResolvedViewDefinition, ai as MindooDBAppResolvedViewSource, aj as MindooDBAppRuntime, ak as MindooDBAppScopedDocId, al as MindooDBAppSession, am as MindooDBAppShowMenuInput, an as MindooDBAppShowMenuResult, ao as MindooDBAppThemeMode, ap as MindooDBAppUpdateDocumentInput, aq as MindooDBAppViewEntry, ar as MindooDBAppViewEntryKind, as as MindooDBAppViewNavigator, at as MindooDBAppViewNavigatorExpansionState, au as MindooDBAppViewNavigatorOpenOptions, av as MindooDBAppViewNavigatorPageOptions, aw as MindooDBAppViewNavigatorPageResult, ax as MindooDBAppViewNavigatorRangeQuery, ay as MindooDBAppViewNavigatorSelectionState, az as MindooDBAppViewport, aA as MindooDBAppWritableAttachmentStream } from './types-Bh1Q2qGN.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
|
|
311
|
-
constructor(rpc,
|
|
310
|
+
var MindooDBAppViewNavigatorImpl = class {
|
|
311
|
+
constructor(rpc, navigatorId) {
|
|
312
312
|
this.rpc = rpc;
|
|
313
|
-
this.
|
|
313
|
+
this.navigatorId = navigatorId;
|
|
314
314
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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.
|
|
322
|
-
viewId: this.viewId
|
|
323
|
-
});
|
|
326
|
+
await this.call("viewNavigators.refresh");
|
|
324
327
|
}
|
|
325
|
-
async
|
|
326
|
-
return await this.
|
|
327
|
-
viewId: this.viewId,
|
|
328
|
-
request: input ?? {}
|
|
329
|
-
});
|
|
328
|
+
async getCurrentEntry() {
|
|
329
|
+
return await this.call("viewNavigators.current.get");
|
|
330
330
|
}
|
|
331
|
-
async
|
|
332
|
-
return await this.
|
|
333
|
-
viewId: this.viewId
|
|
334
|
-
});
|
|
331
|
+
async gotoFirst() {
|
|
332
|
+
return await this.call("viewNavigators.goto.first");
|
|
335
333
|
}
|
|
336
|
-
async
|
|
337
|
-
return await this.
|
|
338
|
-
viewId: this.viewId,
|
|
339
|
-
expansion: state
|
|
340
|
-
});
|
|
334
|
+
async gotoLast() {
|
|
335
|
+
return await this.call("viewNavigators.goto.last");
|
|
341
336
|
}
|
|
342
|
-
async
|
|
343
|
-
return await this.
|
|
344
|
-
|
|
345
|
-
|
|
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");
|
|
347
348
|
}
|
|
348
|
-
async
|
|
349
|
-
return await this.
|
|
350
|
-
|
|
351
|
-
|
|
349
|
+
async gotoParent() {
|
|
350
|
+
return await this.call("viewNavigators.goto.parent");
|
|
351
|
+
}
|
|
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
|
-
|
|
356
|
-
viewId: this.viewId
|
|
357
|
-
});
|
|
411
|
+
await this.call("viewNavigators.expansion.expandAll");
|
|
358
412
|
}
|
|
359
413
|
async collapseAll() {
|
|
360
|
-
|
|
361
|
-
viewId: this.viewId
|
|
362
|
-
});
|
|
414
|
+
await this.call("viewNavigators.expansion.collapseAll");
|
|
363
415
|
}
|
|
364
|
-
async
|
|
365
|
-
|
|
366
|
-
viewId: this.viewId,
|
|
367
|
-
rowKey
|
|
368
|
-
});
|
|
416
|
+
async expandToLevel(level) {
|
|
417
|
+
await this.call("viewNavigators.expansion.expandToLevel", { level });
|
|
369
418
|
}
|
|
370
|
-
async
|
|
371
|
-
return await this.
|
|
372
|
-
|
|
373
|
-
|
|
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 });
|
|
375
427
|
}
|
|
376
|
-
async
|
|
377
|
-
return await this.
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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 });
|
|
433
|
+
}
|
|
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
|
|
384
|
-
return await this.
|
|
385
|
-
|
|
386
|
-
|
|
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.
|
|
391
|
-
viewId: this.viewId
|
|
392
|
-
});
|
|
466
|
+
await this.call("viewNavigators.dispose");
|
|
393
467
|
}
|
|
394
468
|
};
|
|
395
469
|
var MindooDBAppReadableAttachmentStreamImpl = class {
|
|
@@ -633,11 +707,19 @@ var MindooDBAppDatabaseImpl = class {
|
|
|
633
707
|
var MindooDBAppSessionImpl = class {
|
|
634
708
|
constructor(rpc) {
|
|
635
709
|
this.rpc = rpc;
|
|
710
|
+
this.menus = {
|
|
711
|
+
show: async (input) => await this.rpc.call("menus.show", input),
|
|
712
|
+
hide: async () => {
|
|
713
|
+
await this.rpc.call("menus.hide", {});
|
|
714
|
+
}
|
|
715
|
+
};
|
|
636
716
|
}
|
|
717
|
+
menus;
|
|
637
718
|
/** Returns the launch context provided by the Administrator host. */
|
|
638
719
|
async getLaunchContext() {
|
|
639
720
|
return await this.rpc.call("session.getLaunchContext", {});
|
|
640
721
|
}
|
|
722
|
+
/** Lists the databases that the host has made available for this app session. */
|
|
641
723
|
async listDatabases() {
|
|
642
724
|
return await this.rpc.call("session.listDatabases", {});
|
|
643
725
|
}
|
|
@@ -646,14 +728,28 @@ var MindooDBAppSessionImpl = class {
|
|
|
646
728
|
await this.rpc.call("session.openDatabase", { databaseId });
|
|
647
729
|
return new MindooDBAppDatabaseImpl(this.rpc, databaseId);
|
|
648
730
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
731
|
+
/**
|
|
732
|
+
* Create a navigator from an ad-hoc view definition and one or more database bindings.
|
|
733
|
+
*
|
|
734
|
+
* The host builds a `VirtualView` from `input.definition`, optionally applying
|
|
735
|
+
* open options (root scoping, category filtering), and returns a `navigatorId`
|
|
736
|
+
* that all subsequent navigator RPCs reference.
|
|
737
|
+
*/
|
|
738
|
+
async createViewNavigator(input) {
|
|
739
|
+
const result = await this.rpc.call("session.createViewNavigator", input);
|
|
740
|
+
return new MindooDBAppViewNavigatorImpl(this.rpc, result.navigatorId);
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Open a navigator for a preconfigured view that the host already knows about.
|
|
744
|
+
*
|
|
745
|
+
* `viewId` must match one of the views declared in the launch context. The
|
|
746
|
+
* host resolves the full view definition and database bindings automatically.
|
|
747
|
+
*/
|
|
748
|
+
async openViewNavigator(viewId, options) {
|
|
749
|
+
const result = await this.rpc.call("session.openViewNavigator", { viewId, options: options ?? {} });
|
|
750
|
+
return new MindooDBAppViewNavigatorImpl(this.rpc, result.navigatorId);
|
|
751
|
+
}
|
|
752
|
+
/** Subscribe to host-pushed theme changes (dark/light mode, color tokens). */
|
|
657
753
|
onThemeChange(listener) {
|
|
658
754
|
return this.rpc.addMessageListener((message) => {
|
|
659
755
|
if (isThemeChangedMessage(message)) {
|
|
@@ -661,6 +757,7 @@ var MindooDBAppSessionImpl = class {
|
|
|
661
757
|
}
|
|
662
758
|
});
|
|
663
759
|
}
|
|
760
|
+
/** Subscribe to host-pushed viewport dimension changes (resize, orientation). */
|
|
664
761
|
onViewportChange(listener) {
|
|
665
762
|
return this.rpc.addMessageListener((message) => {
|
|
666
763
|
if (isViewportChangedMessage(message)) {
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { a2 as MindooDBAppLaunchContext, U as MindooDBAppDatabaseInfo, W as MindooDBAppDocumentApi, S as MindooDBAppCreateViewNavigatorInput, as as MindooDBAppViewNavigator, au as MindooDBAppViewNavigatorOpenOptions, b as MindooDBAppAttachmentApi, a as MindooDBAppBridge, al as MindooDBAppSession, n as MindooDBAppBridgeRpcRequest, a1 as MindooDBAppHostTheme, az as MindooDBAppViewport, k as MindooDBAppBridgePortMessage } from '../types-Bh1Q2qGN.js';
|
|
2
|
+
import 'mindoodb-view-language';
|
|
3
3
|
|
|
4
4
|
type MaybePromise<T> = T | Promise<T>;
|
|
5
5
|
type MockViewApi = {
|
|
6
|
-
create(
|
|
7
|
-
open(viewId: string): MaybePromise<
|
|
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>;
|