mindoodb-app-sdk 0.0.10 → 0.0.12
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 +25 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +24 -1
- package/dist/testing/index.d.ts +3 -1
- package/dist/testing/index.js +34 -1
- package/dist/{types-Bh1Q2qGN.d.ts → types-DNQi5FbH.d.ts} +21 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -107,10 +107,31 @@ session.onViewportChange((viewport) => {
|
|
|
107
107
|
const db = await session.openDatabase(ctx.databases[0]!.id);
|
|
108
108
|
const result = await db.documents.list({ limit: 25 });
|
|
109
109
|
console.log("Documents:", result.items);
|
|
110
|
+
|
|
111
|
+
// 5. Open a Haven-configured view
|
|
112
|
+
//
|
|
113
|
+
// A "view" is a pre-built, categorized query that a Haven administrator
|
|
114
|
+
// attaches to your app (think: a pivot table over one or more databases).
|
|
115
|
+
// `ctx.views` is the list of views that were made available at launch time.
|
|
116
|
+
// `openViewNavigator()` returns a stateful "cursor" over the view's rows
|
|
117
|
+
// that you can page through and navigate entry by entry.
|
|
118
|
+
if (ctx.views[0]) {
|
|
119
|
+
const viewNav = await session.openViewNavigator(ctx.views[0].id);
|
|
120
|
+
|
|
121
|
+
// Move the cursor to the first row and read a batch of visible entries.
|
|
122
|
+
await viewNav.gotoFirst();
|
|
123
|
+
const page = await viewNav.entriesForward({ limit: 50 });
|
|
124
|
+
console.log("View rows:", page.entries);
|
|
125
|
+
|
|
126
|
+
// Always dispose when you are done -- this frees the host-side navigator.
|
|
127
|
+
await viewNav.dispose();
|
|
128
|
+
}
|
|
110
129
|
```
|
|
111
130
|
|
|
112
131
|
When Haven launches your app it injects a `mindoodbAppLaunchId` query parameter into the URL. `connect()` reads it automatically -- no manual wiring needed.
|
|
113
132
|
|
|
133
|
+
> New to views? They are optional. If your app only needs raw document access you can stop at step 4. The full navigator API (paging, category expand/collapse, selection, child lookups, dynamic app-defined views via `session.createViewNavigator()`) is documented in the [Virtual Views](#virtual-views) section below, and the [`mindoodb-app-example`](https://github.com/klehmann/mindoodb-app-example) repo shows an end-to-end UI built on top of it.
|
|
134
|
+
|
|
114
135
|
## Core concepts
|
|
115
136
|
|
|
116
137
|
### Launch context
|
|
@@ -443,12 +464,13 @@ Haven includes a **built-in file viewer** that your app can open for common atta
|
|
|
443
464
|
|---|---|
|
|
444
465
|
| `image` | All common image formats (JPEG, PNG, GIF, WebP, SVG, ...) |
|
|
445
466
|
| `pdf` | PDF documents |
|
|
446
|
-
| `
|
|
467
|
+
| `markdown` | Markdown rendered to HTML (.md, .markdown, .mdown, .mkd, .mkdn) |
|
|
468
|
+
| `text` | Plain text, CSV, JSON, XML, YAML, SVG, log files |
|
|
447
469
|
| `docx` | Microsoft Word (.docx) |
|
|
448
470
|
| `pptx` | Microsoft PowerPoint (.pptx) |
|
|
449
471
|
| `spreadsheet` | Microsoft Excel (.xls, .xlsx, .xlsm, .xlsb) |
|
|
450
|
-
| `video` | Video files with embedded player
|
|
451
|
-
| `audio` | Audio files with embedded player
|
|
472
|
+
| `video` | Video files with embedded player, streaming + seek (.mp4, .m4v, .webm, .ogv, .ogg, plus any `video/*`) |
|
|
473
|
+
| `audio` | Audio files with embedded player, streaming + seek (.mp3, .m4a, .wav, .aac, .oga, plus any `audio/*`) |
|
|
452
474
|
|
|
453
475
|
**Open the Haven preview dialog:**
|
|
454
476
|
|
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
|
|
1
|
+
import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppBridge } from './types-DNQi5FbH.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 MindooDBAppBridgeUiPreferencesChangedMessage, z as MindooDBAppBridgeViewportChangedMessage, A as MindooDBAppCapability, B as MindooDBAppConfiguredViewCategorizationStyle, C as MindooDBAppConfiguredViewColumn, D as MindooDBAppConfiguredViewColumnRole, E as MindooDBAppConfiguredViewExpressionMode, F as MindooDBAppConfiguredViewFieldExpression, G as MindooDBAppConfiguredViewFilterDefinition, H as MindooDBAppConfiguredViewFilterMode, I as MindooDBAppConfiguredViewFilterRule, J as MindooDBAppConfiguredViewFormulaExpression, K as MindooDBAppConfiguredViewFormulaFilterDefinition, L as MindooDBAppConfiguredViewPreviewMode, N as MindooDBAppConfiguredViewRuleFilterDefinition, O as MindooDBAppConfiguredViewRuleMatchMode, P as MindooDBAppConfiguredViewRuleOperator, Q as MindooDBAppConfiguredViewValueExpression, R as MindooDBAppCreateDocumentInput, S as MindooDBAppCreateViewInput, T as MindooDBAppCreateViewNavigatorInput, U as MindooDBAppDatabase, V as MindooDBAppDatabaseInfo, W as MindooDBAppDocument, X as MindooDBAppDocumentApi, Y as MindooDBAppDocumentHeadCursorResult, Z as MindooDBAppDocumentHistoryEntry, _ as MindooDBAppDocumentListQuery, $ as MindooDBAppDocumentListResult, a0 as MindooDBAppDocumentSummary, a1 as MindooDBAppHistoricalDocument, a2 as MindooDBAppHistoryQuery, a3 as MindooDBAppHostTheme, a4 as MindooDBAppLaunchContext, a5 as MindooDBAppMenuAnchor, a6 as MindooDBAppMenuApi, a7 as MindooDBAppMenuCommandItem, a8 as MindooDBAppMenuDismissReason, a9 as MindooDBAppMenuDismissedResult, aa as MindooDBAppMenuItem, ab as MindooDBAppMenuKind, ac as MindooDBAppMenuPlacement, ad as MindooDBAppMenuPointAnchor, ae as MindooDBAppMenuRect, af as MindooDBAppMenuRectAnchor, ag as MindooDBAppMenuSelectionResult, ah as MindooDBAppMenuSeparatorItem, ai as MindooDBAppReadableAttachmentStream, aj as MindooDBAppResolvedViewDefinition, ak as MindooDBAppResolvedViewSource, al as MindooDBAppRuntime, am as MindooDBAppScopedDocId, an as MindooDBAppSession, ao as MindooDBAppShowMenuInput, ap as MindooDBAppShowMenuResult, aq as MindooDBAppThemeMode, ar as MindooDBAppUiPreferences, as as MindooDBAppUpdateDocumentInput, at as MindooDBAppViewEntry, au as MindooDBAppViewEntryKind, av as MindooDBAppViewNavigator, aw as MindooDBAppViewNavigatorExpansionState, ax as MindooDBAppViewNavigatorOpenOptions, ay as MindooDBAppViewNavigatorPageOptions, az as MindooDBAppViewNavigatorPageResult, aA as MindooDBAppViewNavigatorRangeQuery, aB as MindooDBAppViewNavigatorSelectionState, aC as MindooDBAppViewport, aD as MindooDBAppWritableAttachmentStream } from './types-DNQi5FbH.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
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
function canPreviewAttachment(fileName, mimeType) {
|
|
3
3
|
const normalizedMimeType = mimeType.toLowerCase();
|
|
4
4
|
const normalizedFileName = fileName.toLowerCase();
|
|
5
|
+
if (normalizedMimeType === "text/markdown" || normalizedMimeType === "text/x-markdown" || normalizedMimeType === "application/markdown" || normalizedMimeType === "application/x-markdown" || normalizedFileName.endsWith(".md") || normalizedFileName.endsWith(".markdown") || normalizedFileName.endsWith(".mdown") || normalizedFileName.endsWith(".mkd") || normalizedFileName.endsWith(".mkdn")) {
|
|
6
|
+
return "markdown";
|
|
7
|
+
}
|
|
5
8
|
if (normalizedMimeType.startsWith("image/")) {
|
|
6
9
|
return "image";
|
|
7
10
|
}
|
|
@@ -11,6 +14,12 @@ function canPreviewAttachment(fileName, mimeType) {
|
|
|
11
14
|
if (normalizedMimeType.startsWith("audio/")) {
|
|
12
15
|
return "audio";
|
|
13
16
|
}
|
|
17
|
+
if (normalizedFileName.endsWith(".mp4") || normalizedFileName.endsWith(".m4v") || normalizedFileName.endsWith(".webm") || normalizedFileName.endsWith(".ogv") || normalizedFileName.endsWith(".ogg")) {
|
|
18
|
+
return "video";
|
|
19
|
+
}
|
|
20
|
+
if (normalizedFileName.endsWith(".m4a") || normalizedFileName.endsWith(".mp3") || normalizedFileName.endsWith(".wav") || normalizedFileName.endsWith(".aac") || normalizedFileName.endsWith(".oga")) {
|
|
21
|
+
return "audio";
|
|
22
|
+
}
|
|
14
23
|
if (normalizedMimeType === "application/pdf" || normalizedFileName.endsWith(".pdf")) {
|
|
15
24
|
return "pdf";
|
|
16
25
|
}
|
|
@@ -23,7 +32,7 @@ function canPreviewAttachment(fileName, mimeType) {
|
|
|
23
32
|
if (normalizedMimeType === "application/vnd.openxmlformats-officedocument.presentationml.presentation" || normalizedFileName.endsWith(".pptx")) {
|
|
24
33
|
return "pptx";
|
|
25
34
|
}
|
|
26
|
-
if (normalizedMimeType.startsWith("text/") || normalizedMimeType === "application/json" || normalizedMimeType === "application/xml" || normalizedMimeType === "image/svg+xml" || normalizedFileName.endsWith(".json") || normalizedFileName.endsWith(".txt") || normalizedFileName.endsWith(".
|
|
35
|
+
if (normalizedMimeType.startsWith("text/") || normalizedMimeType === "application/json" || normalizedMimeType === "application/xml" || normalizedMimeType === "image/svg+xml" || normalizedFileName.endsWith(".json") || normalizedFileName.endsWith(".txt") || normalizedFileName.endsWith(".csv") || normalizedFileName.endsWith(".log") || normalizedFileName.endsWith(".xml") || normalizedFileName.endsWith(".yaml") || normalizedFileName.endsWith(".yml") || normalizedFileName.endsWith(".svg")) {
|
|
27
36
|
return "text";
|
|
28
37
|
}
|
|
29
38
|
return null;
|
|
@@ -240,6 +249,9 @@ function isThemeChangedMessage(message) {
|
|
|
240
249
|
function isViewportChangedMessage(message) {
|
|
241
250
|
return message.kind === "viewport-changed";
|
|
242
251
|
}
|
|
252
|
+
function isUiPreferencesChangedMessage(message) {
|
|
253
|
+
return message.kind === "ui-preferences-changed";
|
|
254
|
+
}
|
|
243
255
|
function toStreamError(message) {
|
|
244
256
|
const error = new Error(message.error.message);
|
|
245
257
|
error.name = message.error.code || "MindooDBAppBridgeStreamError";
|
|
@@ -627,6 +639,9 @@ var MindooDBAppDatabaseImpl = class {
|
|
|
627
639
|
databaseId: this.databaseId,
|
|
628
640
|
query: query ?? {}
|
|
629
641
|
}),
|
|
642
|
+
getHeadCursor: async () => await this.rpc.call("documents.getHeadCursor", {
|
|
643
|
+
databaseId: this.databaseId
|
|
644
|
+
}),
|
|
630
645
|
get: async (docId) => await this.rpc.call("documents.get", {
|
|
631
646
|
databaseId: this.databaseId,
|
|
632
647
|
docId
|
|
@@ -765,6 +780,14 @@ var MindooDBAppSessionImpl = class {
|
|
|
765
780
|
}
|
|
766
781
|
});
|
|
767
782
|
}
|
|
783
|
+
/** Subscribe to host-pushed embedded UI preference changes. */
|
|
784
|
+
onUiPreferencesChange(listener) {
|
|
785
|
+
return this.rpc.addMessageListener((message) => {
|
|
786
|
+
if (isUiPreferencesChangedMessage(message)) {
|
|
787
|
+
listener(message.uiPreferences);
|
|
788
|
+
}
|
|
789
|
+
});
|
|
790
|
+
}
|
|
768
791
|
/** Disconnects from the host and always disposes the underlying port client. */
|
|
769
792
|
async disconnect() {
|
|
770
793
|
try {
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a4 as MindooDBAppLaunchContext, V as MindooDBAppDatabaseInfo, X as MindooDBAppDocumentApi, T as MindooDBAppCreateViewNavigatorInput, av as MindooDBAppViewNavigator, ax as MindooDBAppViewNavigatorOpenOptions, b as MindooDBAppAttachmentApi, a as MindooDBAppBridge, an as MindooDBAppSession, n as MindooDBAppBridgeRpcRequest, a3 as MindooDBAppHostTheme, aC as MindooDBAppViewport, ar as MindooDBAppUiPreferences, k as MindooDBAppBridgePortMessage } from '../types-DNQi5FbH.js';
|
|
2
2
|
import 'mindoodb-view-language';
|
|
3
3
|
|
|
4
4
|
type MaybePromise<T> = T | Promise<T>;
|
|
@@ -29,6 +29,7 @@ interface MockMindooDBAppSessionController {
|
|
|
29
29
|
setDatabases(definitions: MockMindooDBAppDatabaseDefinition[]): void;
|
|
30
30
|
emitThemeChange(theme: MindooDBAppHostTheme): void;
|
|
31
31
|
emitViewportChange(viewport: MindooDBAppViewport): void;
|
|
32
|
+
emitUiPreferencesChange(uiPreferences: MindooDBAppUiPreferences): void;
|
|
32
33
|
}
|
|
33
34
|
declare function createMockMindooDBAppSession(options?: CreateMockMindooDBAppSessionOptions): MockMindooDBAppSessionController;
|
|
34
35
|
declare function createMockMindooDBAppBridge(options?: CreateMockMindooDBAppSessionOptions): MockMindooDBAppSessionController;
|
|
@@ -55,6 +56,7 @@ interface FakeBridgeHostController {
|
|
|
55
56
|
dispose(): void;
|
|
56
57
|
emitThemeChange(theme: MindooDBAppHostTheme): void;
|
|
57
58
|
emitViewportChange(viewport: MindooDBAppViewport): void;
|
|
59
|
+
emitUiPreferencesChange(uiPreferences: MindooDBAppUiPreferences): void;
|
|
58
60
|
postPortMessage(message: MindooDBAppBridgePortMessage, transfer?: Transferable[]): void;
|
|
59
61
|
setRequestHandler(method: string, handler: FakeBridgeRequestHandler): void;
|
|
60
62
|
clearRequestHandler(method: string): void;
|
package/dist/testing/index.js
CHANGED
|
@@ -18,6 +18,7 @@ function mergeLaunchContext(current, patch) {
|
|
|
18
18
|
...current,
|
|
19
19
|
theme: { ...current.theme },
|
|
20
20
|
viewport: current.viewport ? { ...current.viewport } : null,
|
|
21
|
+
uiPreferences: { ...current.uiPreferences },
|
|
21
22
|
user: { ...current.user },
|
|
22
23
|
launchParameters: { ...current.launchParameters },
|
|
23
24
|
databases: current.databases.map((database) => ({
|
|
@@ -47,6 +48,7 @@ function mergeLaunchContext(current, patch) {
|
|
|
47
48
|
...patch,
|
|
48
49
|
theme: patch.theme ? { ...current.theme, ...patch.theme } : { ...current.theme },
|
|
49
50
|
viewport: patch.viewport === void 0 ? current.viewport ? { ...current.viewport } : null : patch.viewport ? { ...patch.viewport } : null,
|
|
51
|
+
uiPreferences: patch.uiPreferences ? { ...current.uiPreferences, ...patch.uiPreferences } : { ...current.uiPreferences },
|
|
50
52
|
user: patch.user ? { ...current.user, ...patch.user } : { ...current.user },
|
|
51
53
|
launchParameters: patch.launchParameters ? { ...current.launchParameters, ...patch.launchParameters } : { ...current.launchParameters },
|
|
52
54
|
databases: patch.databases ? patch.databases.map((database) => ({
|
|
@@ -104,6 +106,9 @@ function createDefaultLaunchContext(patch) {
|
|
|
104
106
|
width: 1024,
|
|
105
107
|
height: 768
|
|
106
108
|
},
|
|
109
|
+
uiPreferences: {
|
|
110
|
+
iosMultitaskingOptimized: false
|
|
111
|
+
},
|
|
107
112
|
user: {
|
|
108
113
|
id: "user-1",
|
|
109
114
|
username: "Test User"
|
|
@@ -405,6 +410,11 @@ function createDatabaseHandle(definition) {
|
|
|
405
410
|
nextCursor
|
|
406
411
|
};
|
|
407
412
|
},
|
|
413
|
+
async getHeadCursor() {
|
|
414
|
+
return {
|
|
415
|
+
cursor: String(storedDocuments.size)
|
|
416
|
+
};
|
|
417
|
+
},
|
|
408
418
|
async get(_docId) {
|
|
409
419
|
const document = storedDocuments.get(_docId);
|
|
410
420
|
if (!document || document.isDeleted) {
|
|
@@ -526,6 +536,7 @@ function createMockSessionState(options = {}) {
|
|
|
526
536
|
let launchContext = createDefaultLaunchContext(options.launchContext);
|
|
527
537
|
const themeListeners = /* @__PURE__ */ new Set();
|
|
528
538
|
const viewportListeners = /* @__PURE__ */ new Set();
|
|
539
|
+
const uiPreferencesListeners = /* @__PURE__ */ new Set();
|
|
529
540
|
const databaseHandles = /* @__PURE__ */ new Map();
|
|
530
541
|
const databaseViewApis = /* @__PURE__ */ new Map();
|
|
531
542
|
const sessionViews = /* @__PURE__ */ new Map();
|
|
@@ -634,6 +645,12 @@ function createMockSessionState(options = {}) {
|
|
|
634
645
|
viewportListeners.delete(listener);
|
|
635
646
|
};
|
|
636
647
|
},
|
|
648
|
+
onUiPreferencesChange(listener) {
|
|
649
|
+
uiPreferencesListeners.add(listener);
|
|
650
|
+
return () => {
|
|
651
|
+
uiPreferencesListeners.delete(listener);
|
|
652
|
+
};
|
|
653
|
+
},
|
|
637
654
|
async disconnect() {
|
|
638
655
|
await options.onDisconnect?.();
|
|
639
656
|
}
|
|
@@ -676,6 +693,10 @@ function createMockSessionState(options = {}) {
|
|
|
676
693
|
emitViewportChange(viewport) {
|
|
677
694
|
launchContext = mergeLaunchContext(launchContext, { viewport });
|
|
678
695
|
viewportListeners.forEach((listener) => listener({ ...viewport }));
|
|
696
|
+
},
|
|
697
|
+
emitUiPreferencesChange(uiPreferences) {
|
|
698
|
+
launchContext = mergeLaunchContext(launchContext, { uiPreferences });
|
|
699
|
+
uiPreferencesListeners.forEach((listener) => listener({ ...launchContext.uiPreferences }));
|
|
679
700
|
}
|
|
680
701
|
};
|
|
681
702
|
}
|
|
@@ -689,7 +710,8 @@ function createMockMindooDBAppSession(options = {}) {
|
|
|
689
710
|
listDatabases: state.listDatabaseInfos,
|
|
690
711
|
setDatabases: state.setDatabases,
|
|
691
712
|
emitThemeChange: state.emitThemeChange,
|
|
692
|
-
emitViewportChange: state.emitViewportChange
|
|
713
|
+
emitViewportChange: state.emitViewportChange,
|
|
714
|
+
emitUiPreferencesChange: state.emitUiPreferencesChange
|
|
693
715
|
};
|
|
694
716
|
}
|
|
695
717
|
function createMockMindooDBAppBridge(options = {}) {
|
|
@@ -875,6 +897,8 @@ function createFakeBridgeHost(options = {}) {
|
|
|
875
897
|
return { ok: true };
|
|
876
898
|
case "documents.list":
|
|
877
899
|
return await state.getDatabase(String(params.databaseId)).documents.list(params.query);
|
|
900
|
+
case "documents.getHeadCursor":
|
|
901
|
+
return await state.getDatabase(String(params.databaseId)).documents.getHeadCursor();
|
|
878
902
|
case "documents.get":
|
|
879
903
|
return await state.getDatabase(String(params.databaseId)).documents.get(String(params.docId));
|
|
880
904
|
case "documents.create":
|
|
@@ -1198,6 +1222,15 @@ function createFakeBridgeHost(options = {}) {
|
|
|
1198
1222
|
};
|
|
1199
1223
|
connectedPorts.forEach((port) => port.postMessage(payload));
|
|
1200
1224
|
},
|
|
1225
|
+
emitUiPreferencesChange(uiPreferences) {
|
|
1226
|
+
state.emitUiPreferencesChange(uiPreferences);
|
|
1227
|
+
const payload = {
|
|
1228
|
+
protocol: PROTOCOL,
|
|
1229
|
+
kind: "ui-preferences-changed",
|
|
1230
|
+
uiPreferences
|
|
1231
|
+
};
|
|
1232
|
+
connectedPorts.forEach((port) => port.postMessage(payload));
|
|
1233
|
+
},
|
|
1201
1234
|
postPortMessage(message, transfer = []) {
|
|
1202
1235
|
connectedPorts.forEach((port) => port.postMessage(message, transfer));
|
|
1203
1236
|
},
|
|
@@ -14,6 +14,10 @@ interface MindooDBAppViewport {
|
|
|
14
14
|
width: number;
|
|
15
15
|
height: number;
|
|
16
16
|
}
|
|
17
|
+
/** Host-controlled UI preferences exposed to embedded apps. */
|
|
18
|
+
interface MindooDBAppUiPreferences {
|
|
19
|
+
iosMultitaskingOptimized: boolean;
|
|
20
|
+
}
|
|
17
21
|
/** Saved categorization mode for Haven-managed view mappings delivered at launch time. */
|
|
18
22
|
type MindooDBAppConfiguredViewCategorizationStyle = "document_then_category" | "category_then_document";
|
|
19
23
|
/** Preferred preview layout for a Haven-managed view mapping. */
|
|
@@ -93,7 +97,7 @@ interface MindooDBAppResolvedViewDefinition {
|
|
|
93
97
|
}
|
|
94
98
|
/** Permission/capability flags exposed for a database binding inside the app session. */
|
|
95
99
|
type MindooDBAppCapability = "read" | "create" | "update" | "delete" | "history" | "attachments" | "views";
|
|
96
|
-
/** Metadata about the current app launch supplied by the
|
|
100
|
+
/** Metadata about the current app launch supplied by the Haven host. */
|
|
97
101
|
interface MindooDBAppLaunchContext {
|
|
98
102
|
appId: string;
|
|
99
103
|
appInstanceId: string;
|
|
@@ -102,6 +106,7 @@ interface MindooDBAppLaunchContext {
|
|
|
102
106
|
runtime: MindooDBAppRuntime;
|
|
103
107
|
theme: MindooDBAppHostTheme;
|
|
104
108
|
viewport: MindooDBAppViewport | null;
|
|
109
|
+
uiPreferences: MindooDBAppUiPreferences;
|
|
105
110
|
tenantId?: string;
|
|
106
111
|
preferredDatabaseId?: string;
|
|
107
112
|
user: {
|
|
@@ -120,7 +125,7 @@ interface MindooDBAppAttachmentInfo {
|
|
|
120
125
|
size: number;
|
|
121
126
|
}
|
|
122
127
|
/** Preview modes supported by the Haven-hosted attachment preview dialog. */
|
|
123
|
-
type MindooDBAppAttachmentPreviewMode = "image" | "pdf" | "text" | "docx" | "pptx" | "spreadsheet" | "video" | "audio";
|
|
128
|
+
type MindooDBAppAttachmentPreviewMode = "image" | "pdf" | "text" | "markdown" | "docx" | "pptx" | "spreadsheet" | "video" | "audio";
|
|
124
129
|
/** Optional parameters for opening an attachment preview in Haven. */
|
|
125
130
|
interface MindooDBAppAttachmentPreviewOptions {
|
|
126
131
|
/** Historical snapshot timestamp previously obtained from `documents.history.getAtTimestamp()`. */
|
|
@@ -187,6 +192,10 @@ interface MindooDBAppDocumentListResult {
|
|
|
187
192
|
items: MindooDBAppDocumentSummary[];
|
|
188
193
|
nextCursor: string | null;
|
|
189
194
|
}
|
|
195
|
+
/** Latest known changefeed cursor for a database. */
|
|
196
|
+
interface MindooDBAppDocumentHeadCursorResult {
|
|
197
|
+
cursor: string | null;
|
|
198
|
+
}
|
|
190
199
|
/** Payload used when creating a new document. */
|
|
191
200
|
interface MindooDBAppCreateDocumentInput {
|
|
192
201
|
data: Record<string, unknown>;
|
|
@@ -311,8 +320,14 @@ interface MindooDBAppBridgeViewportChangedMessage {
|
|
|
311
320
|
kind: "viewport-changed";
|
|
312
321
|
viewport: MindooDBAppViewport;
|
|
313
322
|
}
|
|
323
|
+
/** Host-pushed event emitted when host-controlled UI preferences change. */
|
|
324
|
+
interface MindooDBAppBridgeUiPreferencesChangedMessage {
|
|
325
|
+
protocol: "mindoodb-app-bridge";
|
|
326
|
+
kind: "ui-preferences-changed";
|
|
327
|
+
uiPreferences: MindooDBAppUiPreferences;
|
|
328
|
+
}
|
|
314
329
|
/** Any message that can travel across the dedicated bridge MessagePort. */
|
|
315
|
-
type MindooDBAppBridgePortMessage = MindooDBAppBridgeRpcMessage | MindooDBAppBridgeStreamMessage | MindooDBAppBridgeThemeChangedMessage | MindooDBAppBridgeViewportChangedMessage;
|
|
330
|
+
type MindooDBAppBridgePortMessage = MindooDBAppBridgeRpcMessage | MindooDBAppBridgeStreamMessage | MindooDBAppBridgeThemeChangedMessage | MindooDBAppBridgeViewportChangedMessage | MindooDBAppBridgeUiPreferencesChangedMessage;
|
|
316
331
|
/** Placement hint for a host-rendered overlay menu. */
|
|
317
332
|
type MindooDBAppMenuPlacement = "auto" | "bottom-start" | "bottom-end" | "top-start" | "top-end" | "right-start" | "left-start";
|
|
318
333
|
/** Semantic hint allowing Haven to tune menu behavior or styling. */
|
|
@@ -395,6 +410,7 @@ interface MindooDBAppWritableAttachmentStream {
|
|
|
395
410
|
/** Document operations exposed by an opened database handle. */
|
|
396
411
|
interface MindooDBAppDocumentApi {
|
|
397
412
|
list(query?: MindooDBAppDocumentListQuery): Promise<MindooDBAppDocumentListResult>;
|
|
413
|
+
getHeadCursor(): Promise<MindooDBAppDocumentHeadCursorResult>;
|
|
398
414
|
get(docId: string): Promise<MindooDBAppDocument | null>;
|
|
399
415
|
create(input: MindooDBAppCreateDocumentInput): Promise<MindooDBAppDocument>;
|
|
400
416
|
update(docId: string, patch: MindooDBAppUpdateDocumentInput): Promise<MindooDBAppDocument>;
|
|
@@ -552,6 +568,7 @@ interface MindooDBAppSession {
|
|
|
552
568
|
menus: MindooDBAppMenuApi;
|
|
553
569
|
onThemeChange(listener: (theme: MindooDBAppHostTheme) => void): () => void;
|
|
554
570
|
onViewportChange(listener: (viewport: MindooDBAppViewport) => void): () => void;
|
|
571
|
+
onUiPreferencesChange(listener: (uiPreferences: MindooDBAppUiPreferences) => void): () => void;
|
|
555
572
|
disconnect(): Promise<void>;
|
|
556
573
|
}
|
|
557
574
|
/** Root SDK bridge object used to establish a session. */
|
|
@@ -559,4 +576,4 @@ interface MindooDBAppBridge {
|
|
|
559
576
|
connect(options?: MindooDBAppBridgeConnectOptions): Promise<MindooDBAppSession>;
|
|
560
577
|
}
|
|
561
578
|
|
|
562
|
-
export type {
|
|
579
|
+
export type { MindooDBAppDocumentListResult as $, MindooDBAppCapability as A, MindooDBAppConfiguredViewCategorizationStyle as B, MindooDBAppConfiguredViewColumn as C, MindooDBAppConfiguredViewColumnRole as D, MindooDBAppConfiguredViewExpressionMode as E, MindooDBAppConfiguredViewFieldExpression as F, MindooDBAppConfiguredViewFilterDefinition as G, MindooDBAppConfiguredViewFilterMode as H, MindooDBAppConfiguredViewFilterRule as I, MindooDBAppConfiguredViewFormulaExpression as J, MindooDBAppConfiguredViewFormulaFilterDefinition as K, MindooDBAppConfiguredViewPreviewMode as L, MindooDBAppAttachmentPreviewMode as M, MindooDBAppConfiguredViewRuleFilterDefinition as N, MindooDBAppConfiguredViewRuleMatchMode as O, MindooDBAppConfiguredViewRuleOperator as P, MindooDBAppConfiguredViewValueExpression as Q, MindooDBAppCreateDocumentInput as R, MindooDBAppCreateViewInput as S, MindooDBAppCreateViewNavigatorInput as T, MindooDBAppDatabase as U, MindooDBAppDatabaseInfo as V, MindooDBAppDocument as W, MindooDBAppDocumentApi as X, MindooDBAppDocumentHeadCursorResult as Y, MindooDBAppDocumentHistoryEntry as Z, MindooDBAppDocumentListQuery as _, MindooDBAppBridge as a, MindooDBAppDocumentSummary as a0, MindooDBAppHistoricalDocument as a1, MindooDBAppHistoryQuery as a2, MindooDBAppHostTheme as a3, MindooDBAppLaunchContext as a4, MindooDBAppMenuAnchor as a5, MindooDBAppMenuApi as a6, MindooDBAppMenuCommandItem as a7, MindooDBAppMenuDismissReason as a8, MindooDBAppMenuDismissedResult as a9, MindooDBAppViewNavigatorRangeQuery as aA, MindooDBAppViewNavigatorSelectionState as aB, MindooDBAppViewport as aC, MindooDBAppWritableAttachmentStream as aD, MindooDBAppMenuItem as aa, MindooDBAppMenuKind as ab, MindooDBAppMenuPlacement as ac, MindooDBAppMenuPointAnchor as ad, MindooDBAppMenuRect as ae, MindooDBAppMenuRectAnchor as af, MindooDBAppMenuSelectionResult as ag, MindooDBAppMenuSeparatorItem as ah, MindooDBAppReadableAttachmentStream as ai, MindooDBAppResolvedViewDefinition as aj, MindooDBAppResolvedViewSource as ak, MindooDBAppRuntime as al, MindooDBAppScopedDocId as am, MindooDBAppSession as an, MindooDBAppShowMenuInput as ao, MindooDBAppShowMenuResult as ap, MindooDBAppThemeMode as aq, MindooDBAppUiPreferences as ar, MindooDBAppUpdateDocumentInput as as, MindooDBAppViewEntry as at, MindooDBAppViewEntryKind as au, MindooDBAppViewNavigator as av, MindooDBAppViewNavigatorExpansionState as aw, MindooDBAppViewNavigatorOpenOptions as ax, MindooDBAppViewNavigatorPageOptions as ay, MindooDBAppViewNavigatorPageResult as az, MindooDBAppAttachmentApi as b, MindooDBAppAttachmentChunk as c, MindooDBAppAttachmentInfo as d, MindooDBAppAttachmentPreviewOptions as e, MindooDBAppAttachmentPreviewSession as f, MindooDBAppBridgeConnectMessage as g, MindooDBAppBridgeConnectOptions as h, MindooDBAppBridgeConnectedMessage as i, MindooDBAppBridgeErrorPayload as j, MindooDBAppBridgePortMessage as k, MindooDBAppBridgeRpcError as l, MindooDBAppBridgeRpcMessage as m, MindooDBAppBridgeRpcRequest as n, MindooDBAppBridgeRpcSuccess as o, MindooDBAppBridgeStreamAbortRequest as p, MindooDBAppBridgeStreamAck as q, MindooDBAppBridgeStreamCloseRequest as r, MindooDBAppBridgeStreamError as s, MindooDBAppBridgeStreamMessage as t, MindooDBAppBridgeStreamOpenResult as u, MindooDBAppBridgeStreamReadRequest as v, MindooDBAppBridgeStreamWriteRequest as w, MindooDBAppBridgeThemeChangedMessage as x, MindooDBAppBridgeUiPreferencesChangedMessage as y, MindooDBAppBridgeViewportChangedMessage as z };
|