mindoodb-app-sdk 0.0.16 → 0.0.17
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 +189 -150
- package/dist/index.d.ts +2 -2
- package/dist/index.js +196 -49
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +200 -32
- package/dist/{types-D0vtIHBf.d.ts → types-Dw6YRApH.d.ts} +76 -1
- package/package.json +13 -11
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ The bridge carries RPC calls (documents, views, database info), binary attachmen
|
|
|
49
49
|
## Install
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
|
-
|
|
52
|
+
pnpm add mindoodb-app-sdk
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
## Get started in 5 minutes
|
|
@@ -59,8 +59,8 @@ The fastest way to start building is to clone the **example app**, run it locall
|
|
|
59
59
|
```bash
|
|
60
60
|
git clone https://github.com/klehmann/mindoodb-app-example.git
|
|
61
61
|
cd mindoodb-app-example
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
pnpm install
|
|
63
|
+
pnpm dev:local
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
This spins up a local Vite dev server on `http://localhost:4200` with hot module reload.
|
|
@@ -90,9 +90,12 @@ const session = await bridge.connect();
|
|
|
90
90
|
|
|
91
91
|
// 2. Read the launch context
|
|
92
92
|
const ctx = await session.getLaunchContext();
|
|
93
|
-
console.log("Runtime:", ctx.runtime);
|
|
94
|
-
console.log("Theme:", ctx.theme.mode);
|
|
95
|
-
console.log(
|
|
93
|
+
console.log("Runtime:", ctx.runtime); // "iframe" | "window"
|
|
94
|
+
console.log("Theme:", ctx.theme.mode); // "light" | "dark"
|
|
95
|
+
console.log(
|
|
96
|
+
"Databases:",
|
|
97
|
+
ctx.databases.map((db) => db.title),
|
|
98
|
+
);
|
|
96
99
|
|
|
97
100
|
// 3. Subscribe to live host events
|
|
98
101
|
session.onThemeChange((theme) => {
|
|
@@ -230,15 +233,15 @@ Important constraints:
|
|
|
230
233
|
|
|
231
234
|
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.
|
|
232
235
|
|
|
233
|
-
| Capability
|
|
234
|
-
|
|
235
|
-
| `read`
|
|
236
|
-
| `create`
|
|
237
|
-
| `update`
|
|
238
|
-
| `delete`
|
|
239
|
-
| `history`
|
|
236
|
+
| Capability | Allows |
|
|
237
|
+
| ------------- | ------------------------------------------------------------ |
|
|
238
|
+
| `read` | List and read documents |
|
|
239
|
+
| `create` | Create new documents |
|
|
240
|
+
| `update` | Update existing documents |
|
|
241
|
+
| `delete` | Delete documents |
|
|
242
|
+
| `history` | Access document revision history and historical snapshots |
|
|
240
243
|
| `attachments` | List, upload, download, remove, and preview file attachments |
|
|
241
|
-
| `views`
|
|
244
|
+
| `views` | Create app-defined virtual views for this database |
|
|
242
245
|
|
|
243
246
|
```ts
|
|
244
247
|
const db = ctx.databases[0]!;
|
|
@@ -298,7 +301,11 @@ console.log(result.nextCursor); // opaque changefeed checkpoint or null
|
|
|
298
301
|
|
|
299
302
|
// Continue from the last checkpoint
|
|
300
303
|
const nextPage = result.nextCursor
|
|
301
|
-
? await db.documents.list({
|
|
304
|
+
? await db.documents.list({
|
|
305
|
+
cursor: result.nextCursor,
|
|
306
|
+
limit: 50,
|
|
307
|
+
fields: ["title"],
|
|
308
|
+
})
|
|
302
309
|
: null;
|
|
303
310
|
|
|
304
311
|
// Fast metadata-only listing (IDs + deletion state only)
|
|
@@ -322,7 +329,7 @@ const doc = await db.documents.get(docId);
|
|
|
322
329
|
// Create (MindooDB generates a UUID7 id; optionally use a named document key)
|
|
323
330
|
const created = await db.documents.create({
|
|
324
331
|
set: { title: "Meeting notes", content: "..." },
|
|
325
|
-
decryptionKeyId: "team-key",
|
|
332
|
+
decryptionKeyId: "team-key", // omit to use "default"
|
|
326
333
|
});
|
|
327
334
|
|
|
328
335
|
// Create with a caller-provided id (e.g. a known well-known document the app
|
|
@@ -353,8 +360,8 @@ const merged = await db.documents.update(docId, {
|
|
|
353
360
|
path: ["body"],
|
|
354
361
|
baseHeads: doc!.heads,
|
|
355
362
|
edits: [
|
|
356
|
-
{ index: 0,
|
|
357
|
-
{ index: 12, deleteCount: 5, insert: "team"
|
|
363
|
+
{ index: 0, deleteCount: 0, insert: "Hello, " },
|
|
364
|
+
{ index: 12, deleteCount: 5, insert: "team" },
|
|
358
365
|
],
|
|
359
366
|
},
|
|
360
367
|
],
|
|
@@ -371,15 +378,15 @@ Every `MindooDBAppDocument` snapshot also exposes a `heads?: string[]` field. Th
|
|
|
371
378
|
|
|
372
379
|
`documents.list()` is backed by Haven's internal changefeed, not by a positional offset. The query object supports:
|
|
373
380
|
|
|
374
|
-
| Field
|
|
375
|
-
|
|
376
|
-
| `cursor?: string \| null`
|
|
377
|
-
| `limit?: number`
|
|
378
|
-
| `skip?: number`
|
|
379
|
-
| `status?: "all" \| "existing" \| "deleted"` | Filter by deletion state (default `"existing"`)
|
|
380
|
-
| `metadataOnly?: boolean`
|
|
381
|
-
| `fields?: string[]`
|
|
382
|
-
| `filter?: Record<string, unknown>`
|
|
381
|
+
| Field | Meaning |
|
|
382
|
+
| ------------------------------------------- | ------------------------------------------------------------------------------ |
|
|
383
|
+
| `cursor?: string \| null` | Opaque changefeed checkpoint previously returned by `nextCursor` |
|
|
384
|
+
| `limit?: number` | Maximum number of matching entries to return (default `50`) |
|
|
385
|
+
| `skip?: number` | Skip matching entries after the cursor without loading full document bodies |
|
|
386
|
+
| `status?: "all" \| "existing" \| "deleted"` | Filter by deletion state (default `"existing"`) |
|
|
387
|
+
| `metadataOnly?: boolean` | Return only `{ id, isDeleted }` for speed |
|
|
388
|
+
| `fields?: string[]` | Project specific JSON fields when `metadataOnly` is `false` |
|
|
389
|
+
| `filter?: Record<string, unknown>` | Simple equality filter applied to document data when `metadataOnly` is `false` |
|
|
383
390
|
|
|
384
391
|
`nextCursor` is the latest checkpoint reached by the page. Persist it after each successful call when you are building your own index or sync loop. If there were no changes after the supplied cursor, `nextCursor` is `null`.
|
|
385
392
|
|
|
@@ -413,7 +420,10 @@ const history = await db.documents.listHistory(docId);
|
|
|
413
420
|
// }
|
|
414
421
|
|
|
415
422
|
// Load the document state at an exact DAG revision
|
|
416
|
-
const snapshot = await db.documents.getAtRevision(
|
|
423
|
+
const snapshot = await db.documents.getAtRevision(
|
|
424
|
+
docId,
|
|
425
|
+
history[0]!.revisionId,
|
|
426
|
+
);
|
|
417
427
|
// {
|
|
418
428
|
// id,
|
|
419
429
|
// revisionId,
|
|
@@ -426,7 +436,10 @@ const snapshot = await db.documents.getAtRevision(docId, history[0]!.revisionId)
|
|
|
426
436
|
// }
|
|
427
437
|
|
|
428
438
|
// Timestamp lookup is still available when all you have is a timestamp.
|
|
429
|
-
const pointInTime = await db.documents.getAtTimestamp(
|
|
439
|
+
const pointInTime = await db.documents.getAtTimestamp(
|
|
440
|
+
docId,
|
|
441
|
+
history[0]!.timestamp,
|
|
442
|
+
);
|
|
430
443
|
```
|
|
431
444
|
|
|
432
445
|
Historical snapshots include the document data payload as it existed at that revision. When the snapshot has attachments, `attachments` reflects the historical `_attachments` array for that same revision, including the attachment reference that Haven needs to stop at the correct historical `lastChunkId`.
|
|
@@ -465,14 +478,14 @@ The end-to-end flow is the same in both cases:
|
|
|
465
478
|
|
|
466
479
|
```ts
|
|
467
480
|
interface MindooDBAppTextEdit {
|
|
468
|
-
index: number;
|
|
469
|
-
deleteCount: number;
|
|
470
|
-
insert?: string;
|
|
481
|
+
index: number; // 0-based position in the current string at baseHeads
|
|
482
|
+
deleteCount: number; // number of characters to remove at `index`
|
|
483
|
+
insert?: string; // text to insert at `index` after deletion
|
|
471
484
|
}
|
|
472
485
|
|
|
473
486
|
interface MindooDBAppTextPatch {
|
|
474
487
|
path: Array<string | number>; // path inside `document.data`, e.g. ["body"]
|
|
475
|
-
baseHeads?: string[];
|
|
488
|
+
baseHeads?: string[]; // document version the edits were authored against
|
|
476
489
|
edits: MindooDBAppTextEdit[]; // applied in order
|
|
477
490
|
}
|
|
478
491
|
```
|
|
@@ -488,11 +501,13 @@ const doc = await db.documents.get(docId);
|
|
|
488
501
|
|
|
489
502
|
// User typed "Hello, " at the beginning of the body.
|
|
490
503
|
const result = await db.documents.update(docId, {
|
|
491
|
-
text: [
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
504
|
+
text: [
|
|
505
|
+
{
|
|
506
|
+
path: ["body"],
|
|
507
|
+
baseHeads: doc!.heads,
|
|
508
|
+
edits: [{ index: 0, deleteCount: 0, insert: "Hello, " }],
|
|
509
|
+
},
|
|
510
|
+
],
|
|
496
511
|
});
|
|
497
512
|
|
|
498
513
|
// `result.data.body` -- canonical merged text
|
|
@@ -508,7 +523,7 @@ For WYSIWYG editors that emit a full markdown / plain-text string after each tra
|
|
|
508
523
|
```ts
|
|
509
524
|
import { createMindooDBTextBuffer } from "mindoodb-app-sdk";
|
|
510
525
|
|
|
511
|
-
const doc
|
|
526
|
+
const doc = await db.documents.get(docId);
|
|
512
527
|
const buffer = createMindooDBTextBuffer({
|
|
513
528
|
database: db,
|
|
514
529
|
document: doc!,
|
|
@@ -542,14 +557,14 @@ async function refresh() {
|
|
|
542
557
|
|
|
543
558
|
Buffer API at a glance:
|
|
544
559
|
|
|
545
|
-
| Member
|
|
546
|
-
|
|
547
|
-
| `value` / `toString()`
|
|
548
|
-
| `dirty` / `pendingCount`
|
|
549
|
-
| `splice(index, deleteCount, insert?)` | Record an exact text operation
|
|
550
|
-
| `replaceText(next)`
|
|
551
|
-
| `reconcile(document)`
|
|
552
|
-
| `flush()`
|
|
560
|
+
| Member | Description |
|
|
561
|
+
| ------------------------------------- | -------------------------------------------------------------------------- |
|
|
562
|
+
| `value` / `toString()` | Current local text value |
|
|
563
|
+
| `dirty` / `pendingCount` | Whether/how many local splices are buffered |
|
|
564
|
+
| `splice(index, deleteCount, insert?)` | Record an exact text operation |
|
|
565
|
+
| `replaceText(next)` | Diff `value` against `next` and record one minimal splice |
|
|
566
|
+
| `reconcile(document)` | Adopt a fresh document snapshot, drop pending edits |
|
|
567
|
+
| `flush()` | Send pending edits to Haven; resolves to `{ document, value, reconciled }` |
|
|
553
568
|
|
|
554
569
|
`flush()` always sends the original `baseHeads` captured when the buffer was created (or last reconciled), so two windows editing the same document at the same heads will both produce a clean merge -- they will not overwrite each other.
|
|
555
570
|
|
|
@@ -646,14 +661,27 @@ while (chunk !== null) {
|
|
|
646
661
|
await reader.close();
|
|
647
662
|
|
|
648
663
|
// Upload (push-based write stream)
|
|
649
|
-
const writer = await db.attachments.openWriteStream(
|
|
664
|
+
const writer = await db.attachments.openWriteStream(
|
|
665
|
+
docId,
|
|
666
|
+
"photo.jpg",
|
|
667
|
+
"image/jpeg",
|
|
668
|
+
);
|
|
650
669
|
await writer.write(fileBytes);
|
|
651
670
|
await writer.close();
|
|
652
671
|
|
|
672
|
+
// Host-provided document scanner
|
|
673
|
+
const scan = await db.attachments.scan(docId, {
|
|
674
|
+
defaultFileName: "invoice.pdf",
|
|
675
|
+
preset: "a4-portrait",
|
|
676
|
+
mimeType: "application/pdf",
|
|
677
|
+
});
|
|
678
|
+
|
|
653
679
|
// Remove
|
|
654
680
|
await db.attachments.remove(docId, "old-file.txt");
|
|
655
681
|
```
|
|
656
682
|
|
|
683
|
+
`attachments.scan()` asks Haven to open its document scanner UI. Haven handles camera/file selection, edge detection, manual corner correction, output sizing, and filename confirmation, then writes the resulting image as a normal attachment. Hosts that do not provide scanner UI may reject this method or return `{ ok: false }`.
|
|
684
|
+
|
|
657
685
|
For historical reads, pass the same `revisionId` you received from `documents.listHistory()` or from a `MindooDBAppHistoricalDocument`. This tells Haven to resolve the attachment from that revision's document payload instead of the latest document state:
|
|
658
686
|
|
|
659
687
|
```ts
|
|
@@ -680,17 +708,17 @@ Haven includes a **built-in file viewer** that your app can open for common atta
|
|
|
680
708
|
|
|
681
709
|
**Supported preview formats:**
|
|
682
710
|
|
|
683
|
-
| Mode
|
|
684
|
-
|
|
685
|
-
| `image`
|
|
686
|
-
| `pdf`
|
|
687
|
-
| `markdown`
|
|
688
|
-
| `text`
|
|
689
|
-
| `docx`
|
|
690
|
-
| `pptx`
|
|
691
|
-
| `spreadsheet` | Microsoft Excel (.xls, .xlsx, .xlsm, .xlsb)
|
|
692
|
-
| `video`
|
|
693
|
-
| `audio`
|
|
711
|
+
| Mode | Formats |
|
|
712
|
+
| ------------- | ------------------------------------------------------------------------------------------------------ |
|
|
713
|
+
| `image` | All common image formats (JPEG, PNG, GIF, WebP, SVG, ...) |
|
|
714
|
+
| `pdf` | PDF documents |
|
|
715
|
+
| `markdown` | Markdown rendered to HTML (.md, .markdown, .mdown, .mkd, .mkdn) |
|
|
716
|
+
| `text` | Plain text, CSV, JSON, XML, YAML, SVG, log files |
|
|
717
|
+
| `docx` | Microsoft Word (.docx) |
|
|
718
|
+
| `pptx` | Microsoft PowerPoint (.pptx) |
|
|
719
|
+
| `spreadsheet` | Microsoft Excel (.xls, .xlsx, .xlsm, .xlsb) |
|
|
720
|
+
| `video` | Video files with embedded player, streaming + seek (.mp4, .m4v, .webm, .ogv, .ogg, plus any `video/*`) |
|
|
721
|
+
| `audio` | Audio files with embedded player, streaming + seek (.mp3, .m4a, .wav, .aac, .oga, plus any `audio/*`) |
|
|
694
722
|
|
|
695
723
|
**Open the Haven preview dialog:**
|
|
696
724
|
|
|
@@ -716,7 +744,10 @@ import { canPreviewAttachment } from "mindoodb-app-sdk";
|
|
|
716
744
|
const mode = canPreviewAttachment("slides.pptx", "application/octet-stream");
|
|
717
745
|
// Returns "pptx" -- Haven can preview this file
|
|
718
746
|
|
|
719
|
-
const unsupported = canPreviewAttachment(
|
|
747
|
+
const unsupported = canPreviewAttachment(
|
|
748
|
+
"data.bin",
|
|
749
|
+
"application/octet-stream",
|
|
750
|
+
);
|
|
720
751
|
// Returns null -- no built-in preview available
|
|
721
752
|
```
|
|
722
753
|
|
|
@@ -804,7 +835,10 @@ do {
|
|
|
804
835
|
```ts
|
|
805
836
|
const page1 = await navigator.entriesForward({ limit: 50 });
|
|
806
837
|
const page2 = page1.nextPosition
|
|
807
|
-
? await navigator.entriesForward({
|
|
838
|
+
? await navigator.entriesForward({
|
|
839
|
+
limit: 50,
|
|
840
|
+
startPosition: page1.nextPosition,
|
|
841
|
+
})
|
|
808
842
|
: null;
|
|
809
843
|
```
|
|
810
844
|
|
|
@@ -823,7 +857,11 @@ if (category) {
|
|
|
823
857
|
```ts
|
|
824
858
|
const category = await navigator.findCategoryEntryByParts(["Ada"]);
|
|
825
859
|
if (category) {
|
|
826
|
-
const exact = await navigator.childDocumentsByKey(
|
|
860
|
+
const exact = await navigator.childDocumentsByKey(
|
|
861
|
+
category.key,
|
|
862
|
+
"2026-04-14",
|
|
863
|
+
true,
|
|
864
|
+
);
|
|
827
865
|
const range = await navigator.childDocumentsBetween(category.key, {
|
|
828
866
|
startKey: "2026-04-01",
|
|
829
867
|
endKey: "2026-04-30",
|
|
@@ -886,7 +924,7 @@ MindooDB Apps are standard web applications -- deploy them anywhere you can serv
|
|
|
886
924
|
**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:
|
|
887
925
|
|
|
888
926
|
```bash
|
|
889
|
-
|
|
927
|
+
pnpm build
|
|
890
928
|
wrangler deploy
|
|
891
929
|
```
|
|
892
930
|
|
|
@@ -899,7 +937,7 @@ Other static hosting options work just as well: Netlify, Vercel, any web server
|
|
|
899
937
|
For interactive development with the full Haven host bridge:
|
|
900
938
|
|
|
901
939
|
1. Run Haven locally.
|
|
902
|
-
2. Run your app on its own dev server (e.g. `
|
|
940
|
+
2. Run your app on its own dev server (e.g. `pnpm dev` with Vite).
|
|
903
941
|
3. Register the dev server URL in Haven's Application settings.
|
|
904
942
|
4. Map databases and optionally views to the app.
|
|
905
943
|
5. Launch from Haven -- you get hot reload, real bridge communication, and live theme/viewport events.
|
|
@@ -910,48 +948,48 @@ This is separate from the automated testing workflow above. Running Haven is use
|
|
|
910
948
|
|
|
911
949
|
### MindooDBAppBridge
|
|
912
950
|
|
|
913
|
-
| Method
|
|
914
|
-
|
|
951
|
+
| Method | Returns |
|
|
952
|
+
| ------------------- | ----------------------------- |
|
|
915
953
|
| `connect(options?)` | `Promise<MindooDBAppSession>` |
|
|
916
954
|
|
|
917
955
|
Connect options: `launchId?`, `targetOrigin?`, `connectTimeoutMs?`.
|
|
918
956
|
|
|
919
957
|
### MindooDBAppSession
|
|
920
958
|
|
|
921
|
-
| Method
|
|
922
|
-
|
|
923
|
-
| `getLaunchContext()`
|
|
924
|
-
| `listDatabases()`
|
|
925
|
-
| `openDatabase(databaseId)`
|
|
926
|
-
| `createViewNavigator(input)`
|
|
927
|
-
| `openViewNavigator(viewId, options?)` | `Promise<MindooDBAppViewNavigator>`
|
|
928
|
-
| `menus.show(input)`
|
|
929
|
-
| `menus.hide()`
|
|
930
|
-
| `onThemeChange(listener)`
|
|
931
|
-
| `onViewportChange(listener)`
|
|
932
|
-
| `disconnect()`
|
|
959
|
+
| Method | Returns |
|
|
960
|
+
| ------------------------------------- | ------------------------------------ |
|
|
961
|
+
| `getLaunchContext()` | `Promise<MindooDBAppLaunchContext>` |
|
|
962
|
+
| `listDatabases()` | `Promise<MindooDBAppDatabaseInfo[]>` |
|
|
963
|
+
| `openDatabase(databaseId)` | `Promise<MindooDBAppDatabase>` |
|
|
964
|
+
| `createViewNavigator(input)` | `Promise<MindooDBAppViewNavigator>` |
|
|
965
|
+
| `openViewNavigator(viewId, options?)` | `Promise<MindooDBAppViewNavigator>` |
|
|
966
|
+
| `menus.show(input)` | `Promise<MindooDBAppShowMenuResult>` |
|
|
967
|
+
| `menus.hide()` | `Promise<void>` |
|
|
968
|
+
| `onThemeChange(listener)` | `() => void` (unsubscribe) |
|
|
969
|
+
| `onViewportChange(listener)` | `() => void` (unsubscribe) |
|
|
970
|
+
| `disconnect()` | `Promise<void>` |
|
|
933
971
|
|
|
934
972
|
### MindooDBAppDatabase
|
|
935
973
|
|
|
936
|
-
| Property / Method | Returns
|
|
937
|
-
|
|
938
|
-
| `info()`
|
|
939
|
-
| `documents`
|
|
940
|
-
| `attachments`
|
|
974
|
+
| Property / Method | Returns |
|
|
975
|
+
| ----------------- | ---------------------------------- |
|
|
976
|
+
| `info()` | `Promise<MindooDBAppDatabaseInfo>` |
|
|
977
|
+
| `documents` | `MindooDBAppDocumentApi` |
|
|
978
|
+
| `attachments` | `MindooDBAppAttachmentApi` |
|
|
941
979
|
|
|
942
980
|
### MindooDBAppDocumentApi
|
|
943
981
|
|
|
944
|
-
| Method
|
|
945
|
-
|
|
946
|
-
| `list(query?)`
|
|
947
|
-
| `get(docId)`
|
|
948
|
-
| `create(input)`
|
|
949
|
-
| `update(docId, patch)`
|
|
950
|
-
| `delete(docId)`
|
|
951
|
-
| `undelete(docId)`
|
|
952
|
-
| `listHistory(docId)`
|
|
953
|
-
| `getAtTimestamp(docId, timestamp)` | `Promise<MindooDBAppHistoricalDocument>`
|
|
954
|
-
| `getAtRevision(docId, revisionId)` | `Promise<MindooDBAppHistoricalDocument>`
|
|
982
|
+
| Method | Returns |
|
|
983
|
+
| ---------------------------------- | -------------------------------------------- |
|
|
984
|
+
| `list(query?)` | `Promise<MindooDBAppDocumentListResult>` |
|
|
985
|
+
| `get(docId)` | `Promise<MindooDBAppDocument \| null>` |
|
|
986
|
+
| `create(input)` | `Promise<MindooDBAppDocument>` |
|
|
987
|
+
| `update(docId, patch)` | `Promise<MindooDBAppDocument>` |
|
|
988
|
+
| `delete(docId)` | `Promise<{ ok: true }>` |
|
|
989
|
+
| `undelete(docId)` | `Promise<{ ok: true }>` |
|
|
990
|
+
| `listHistory(docId)` | `Promise<MindooDBAppDocumentHistoryEntry[]>` |
|
|
991
|
+
| `getAtTimestamp(docId, timestamp)` | `Promise<MindooDBAppHistoricalDocument>` |
|
|
992
|
+
| `getAtRevision(docId, revisionId)` | `Promise<MindooDBAppHistoricalDocument>` |
|
|
955
993
|
|
|
956
994
|
`list(query?)` accepts the changefeed query options documented above. The `cursor` value is an opaque checkpoint string managed by Haven and should be stored and passed back unchanged.
|
|
957
995
|
|
|
@@ -963,9 +1001,9 @@ For `update(docId, patch)`, use `MindooDBAppUpdateDocumentInput`:
|
|
|
963
1001
|
|
|
964
1002
|
```ts
|
|
965
1003
|
interface MindooDBAppUpdateDocumentInput {
|
|
966
|
-
set?: Record<string, unknown>;
|
|
967
|
-
unset?: string[];
|
|
968
|
-
text?: MindooDBAppTextPatch[];
|
|
1004
|
+
set?: Record<string, unknown>; // shallow assign top-level fields
|
|
1005
|
+
unset?: string[]; // remove top-level fields entirely
|
|
1006
|
+
text?: MindooDBAppTextPatch[]; // granular collaborative text edits
|
|
969
1007
|
}
|
|
970
1008
|
```
|
|
971
1009
|
|
|
@@ -973,68 +1011,69 @@ interface MindooDBAppUpdateDocumentInput {
|
|
|
973
1011
|
|
|
974
1012
|
### MindooDBAppAttachmentApi
|
|
975
1013
|
|
|
976
|
-
| Method
|
|
977
|
-
|
|
978
|
-
| `list(docId, options?)`
|
|
979
|
-
| `remove(docId, attachmentName)`
|
|
980
|
-
| `openReadStream(docId, attachmentName, options?)`
|
|
981
|
-
| `openWriteStream(docId, attachmentName, contentType?)`
|
|
1014
|
+
| Method | Returns |
|
|
1015
|
+
| -------------------------------------------------------- | ---------------------------------------------- |
|
|
1016
|
+
| `list(docId, options?)` | `Promise<MindooDBAppAttachmentInfo[]>` |
|
|
1017
|
+
| `remove(docId, attachmentName)` | `Promise<{ ok: true }>` |
|
|
1018
|
+
| `openReadStream(docId, attachmentName, options?)` | `Promise<MindooDBAppReadableAttachmentStream>` |
|
|
1019
|
+
| `openWriteStream(docId, attachmentName, contentType?)` | `Promise<MindooDBAppWritableAttachmentStream>` |
|
|
1020
|
+
| `scan(docId, options?)` | `Promise<MindooDBAppScanAttachmentResult>` |
|
|
982
1021
|
| `preparePreviewSession(docId, attachmentName, options?)` | `Promise<MindooDBAppAttachmentPreviewSession>` |
|
|
983
|
-
| `openPreview(docId, attachmentName, options?)`
|
|
1022
|
+
| `openPreview(docId, attachmentName, options?)` | `Promise<{ ok: true }>` |
|
|
984
1023
|
|
|
985
1024
|
`options` accepts `{ timestamp?: number; revisionId?: string }` for read-only historical attachment access. Mutation methods (`openWriteStream`, `remove`) always target the current document.
|
|
986
1025
|
|
|
987
1026
|
### MindooDBAppViewNavigator
|
|
988
1027
|
|
|
989
|
-
| Method
|
|
990
|
-
|
|
991
|
-
| `getDefinition()`
|
|
992
|
-
| `refresh()`
|
|
993
|
-
| `getCurrentEntry()`
|
|
994
|
-
| `gotoFirst()` / `gotoLast()`
|
|
995
|
-
| `gotoNext()` / `gotoPrev()`
|
|
996
|
-
| `gotoNextSibling()` / `gotoPrevSibling()`
|
|
997
|
-
| `gotoParent()`
|
|
998
|
-
| `gotoFirstChild()` / `gotoLastChild()`
|
|
999
|
-
| `gotoPos(position)`
|
|
1000
|
-
| `getPos(position)`
|
|
1001
|
-
| `findCategoryEntryByParts(parts)`
|
|
1002
|
-
| `entriesForward(options?)`
|
|
1003
|
-
| `entriesBackward(options?)`
|
|
1004
|
-
| `gotoNextSelected()` / `gotoPrevSelected()`
|
|
1005
|
-
| `select(origin, docId, selectParentCategories?)`
|
|
1006
|
-
| `deselect(origin, docId)`
|
|
1007
|
-
| `selectAllEntries()` / `deselectAllEntries()`
|
|
1008
|
-
| `isSelected(origin, docId)`
|
|
1009
|
-
| `getSelectionState()`
|
|
1010
|
-
| `setSelectionState(state)`
|
|
1011
|
-
| `expand(origin, docId)` / `collapse(origin, docId)`
|
|
1012
|
-
| `expandAll()` / `collapseAll()`
|
|
1013
|
-
| `expandToLevel(level)`
|
|
1014
|
-
| `isExpanded(entryKey)`
|
|
1015
|
-
| `getExpansionState()`
|
|
1016
|
-
| `setExpansionState(state)`
|
|
1017
|
-
| `childEntries(entryKey, descending?)`
|
|
1018
|
-
| `childCategories(entryKey, descending?)`
|
|
1019
|
-
| `childDocuments(entryKey, descending?)`
|
|
1020
|
-
| `childCategoriesByKey(entryKey, key, exact?, descending?)` | `Promise<MindooDBAppViewEntry[]>`
|
|
1021
|
-
| `childDocumentsByKey(entryKey, key, exact?, descending?)`
|
|
1022
|
-
| `childCategoriesBetween(entryKey, range)`
|
|
1023
|
-
| `childDocumentsBetween(entryKey, range)`
|
|
1024
|
-
| `getSortedDocIds(descending?)`
|
|
1025
|
-
| `getSortedDocIdsScoped(entryKey, descending?)`
|
|
1026
|
-
| `dispose()`
|
|
1028
|
+
| Method | Returns |
|
|
1029
|
+
| ---------------------------------------------------------- | ------------------------------------------------- |
|
|
1030
|
+
| `getDefinition()` | `Promise<MindooDBAppViewDefinition>` |
|
|
1031
|
+
| `refresh()` | `Promise<void>` |
|
|
1032
|
+
| `getCurrentEntry()` | `Promise<MindooDBAppViewEntry \| null>` |
|
|
1033
|
+
| `gotoFirst()` / `gotoLast()` | `Promise<boolean>` |
|
|
1034
|
+
| `gotoNext()` / `gotoPrev()` | `Promise<boolean>` |
|
|
1035
|
+
| `gotoNextSibling()` / `gotoPrevSibling()` | `Promise<boolean>` |
|
|
1036
|
+
| `gotoParent()` | `Promise<boolean>` |
|
|
1037
|
+
| `gotoFirstChild()` / `gotoLastChild()` | `Promise<boolean>` |
|
|
1038
|
+
| `gotoPos(position)` | `Promise<boolean>` |
|
|
1039
|
+
| `getPos(position)` | `Promise<MindooDBAppViewEntry \| null>` |
|
|
1040
|
+
| `findCategoryEntryByParts(parts)` | `Promise<MindooDBAppViewEntry \| null>` |
|
|
1041
|
+
| `entriesForward(options?)` | `Promise<MindooDBAppViewNavigatorPageResult>` |
|
|
1042
|
+
| `entriesBackward(options?)` | `Promise<MindooDBAppViewNavigatorPageResult>` |
|
|
1043
|
+
| `gotoNextSelected()` / `gotoPrevSelected()` | `Promise<boolean>` |
|
|
1044
|
+
| `select(origin, docId, selectParentCategories?)` | `Promise<void>` |
|
|
1045
|
+
| `deselect(origin, docId)` | `Promise<void>` |
|
|
1046
|
+
| `selectAllEntries()` / `deselectAllEntries()` | `Promise<void>` |
|
|
1047
|
+
| `isSelected(origin, docId)` | `Promise<boolean>` |
|
|
1048
|
+
| `getSelectionState()` | `Promise<MindooDBAppViewNavigatorSelectionState>` |
|
|
1049
|
+
| `setSelectionState(state)` | `Promise<void>` |
|
|
1050
|
+
| `expand(origin, docId)` / `collapse(origin, docId)` | `Promise<void>` |
|
|
1051
|
+
| `expandAll()` / `collapseAll()` | `Promise<void>` |
|
|
1052
|
+
| `expandToLevel(level)` | `Promise<void>` |
|
|
1053
|
+
| `isExpanded(entryKey)` | `Promise<boolean>` |
|
|
1054
|
+
| `getExpansionState()` | `Promise<MindooDBAppViewNavigatorExpansionState>` |
|
|
1055
|
+
| `setExpansionState(state)` | `Promise<void>` |
|
|
1056
|
+
| `childEntries(entryKey, descending?)` | `Promise<MindooDBAppViewEntry[]>` |
|
|
1057
|
+
| `childCategories(entryKey, descending?)` | `Promise<MindooDBAppViewEntry[]>` |
|
|
1058
|
+
| `childDocuments(entryKey, descending?)` | `Promise<MindooDBAppViewEntry[]>` |
|
|
1059
|
+
| `childCategoriesByKey(entryKey, key, exact?, descending?)` | `Promise<MindooDBAppViewEntry[]>` |
|
|
1060
|
+
| `childDocumentsByKey(entryKey, key, exact?, descending?)` | `Promise<MindooDBAppViewEntry[]>` |
|
|
1061
|
+
| `childCategoriesBetween(entryKey, range)` | `Promise<MindooDBAppViewEntry[]>` |
|
|
1062
|
+
| `childDocumentsBetween(entryKey, range)` | `Promise<MindooDBAppViewEntry[]>` |
|
|
1063
|
+
| `getSortedDocIds(descending?)` | `Promise<MindooDBAppScopedDocId[]>` |
|
|
1064
|
+
| `getSortedDocIdsScoped(entryKey, descending?)` | `Promise<MindooDBAppScopedDocId[]>` |
|
|
1065
|
+
| `dispose()` | `Promise<void>` |
|
|
1027
1066
|
|
|
1028
1067
|
### Exported functions
|
|
1029
1068
|
|
|
1030
|
-
| Function
|
|
1031
|
-
|
|
1032
|
-
| `createMindooDBAppBridge()`
|
|
1033
|
-
| `createMindooDBTextBuffer(options)`
|
|
1034
|
-
| `canPreviewAttachment(fileName, mimeType)` | Check if Haven can preview a file (returns mode or `null`)
|
|
1035
|
-
| `createViewLanguage<T>()`
|
|
1036
|
-
| `abbreviateCanonicalName(value)`
|
|
1037
|
-
| `expandAbbreviatedName(value)`
|
|
1069
|
+
| Function | Description |
|
|
1070
|
+
| ------------------------------------------ | ------------------------------------------------------------------------------------------- |
|
|
1071
|
+
| `createMindooDBAppBridge()` | Create the bridge object used to connect to Haven |
|
|
1072
|
+
| `createMindooDBTextBuffer(options)` | Create an editor-friendly buffer for granular collaborative text edits on a document field |
|
|
1073
|
+
| `canPreviewAttachment(fileName, mimeType)` | Check if Haven can preview a file (returns mode or `null`) |
|
|
1074
|
+
| `createViewLanguage<T>()` | Create a typed expression builder for view definitions |
|
|
1075
|
+
| `abbreviateCanonicalName(value)` | Convert a canonical Notes-style name like `cn=Jane/ou=Dev/o=Mindoo` to `Jane/Dev/Mindoo` |
|
|
1076
|
+
| `expandAbbreviatedName(value)` | Convert an abbreviated Notes-style name like `Jane/Dev/Mindoo` to `cn=Jane/ou=Dev/o=Mindoo` |
|
|
1038
1077
|
|
|
1039
1078
|
## Permissions and mappings
|
|
1040
1079
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppBridge, b as MindooDBAppDatabase, c as MindooDBAppDocument } from './types-
|
|
2
|
-
export { d as MindooDBAppAttachmentApi, e as MindooDBAppAttachmentChunk, f as MindooDBAppAttachmentInfo, g as MindooDBAppAttachmentPreviewOptions, h as MindooDBAppAttachmentPreviewSession, i as MindooDBAppBridgeConnectMessage, j as MindooDBAppBridgeConnectOptions, k as MindooDBAppBridgeConnectedMessage, l as MindooDBAppBridgeErrorPayload, m as MindooDBAppBridgeHandshakeErrorMessage, n as MindooDBAppBridgePortMessage, o as MindooDBAppBridgeRpcError, p as MindooDBAppBridgeRpcMessage, q as MindooDBAppBridgeRpcRequest, r as MindooDBAppBridgeRpcSuccess, s as MindooDBAppBridgeStreamAbortRequest, t as MindooDBAppBridgeStreamAck, u as MindooDBAppBridgeStreamCloseRequest, v as MindooDBAppBridgeStreamError, w as MindooDBAppBridgeStreamMessage, x as MindooDBAppBridgeStreamOpenResult, y as MindooDBAppBridgeStreamReadRequest, z as MindooDBAppBridgeStreamWriteRequest, A as MindooDBAppBridgeThemeChangedMessage, B as MindooDBAppBridgeUiPreferencesChangedMessage, C as MindooDBAppBridgeViewportChangedMessage, D as MindooDBAppCapability, E as MindooDBAppConfiguredViewCategorizationStyle, F as MindooDBAppConfiguredViewColumn, G as MindooDBAppConfiguredViewColumnRole, H as MindooDBAppConfiguredViewExpressionMode, I as MindooDBAppConfiguredViewFieldExpression, J as MindooDBAppConfiguredViewFilterDefinition, K as MindooDBAppConfiguredViewFilterMode, L as MindooDBAppConfiguredViewFilterRule, N as MindooDBAppConfiguredViewFormulaExpression, O as MindooDBAppConfiguredViewFormulaFilterDefinition, P as MindooDBAppConfiguredViewPreviewMode, Q as MindooDBAppConfiguredViewRuleFilterDefinition, R as MindooDBAppConfiguredViewRuleMatchMode, S as MindooDBAppConfiguredViewRuleOperator, T as MindooDBAppConfiguredViewValueExpression, U as MindooDBAppCreateDocumentInput, V as MindooDBAppCreateViewInput, W as MindooDBAppCreateViewNavigatorInput, X as MindooDBAppDatabaseInfo, Y as MindooDBAppDocumentApi, Z as MindooDBAppDocumentHeadCursorResult, _ as MindooDBAppDocumentHistoryEntry, $ as MindooDBAppDocumentListQuery, a0 as MindooDBAppDocumentListResult, a1 as MindooDBAppDocumentRevisionId, a2 as
|
|
1
|
+
import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppBridge, b as MindooDBAppDatabase, c as MindooDBAppDocument } from './types-Dw6YRApH.js';
|
|
2
|
+
export { d as MindooDBAppAttachmentApi, e as MindooDBAppAttachmentChunk, f as MindooDBAppAttachmentInfo, g as MindooDBAppAttachmentPreviewOptions, h as MindooDBAppAttachmentPreviewSession, i as MindooDBAppBridgeConnectMessage, j as MindooDBAppBridgeConnectOptions, k as MindooDBAppBridgeConnectedMessage, l as MindooDBAppBridgeErrorPayload, m as MindooDBAppBridgeHandshakeErrorMessage, n as MindooDBAppBridgePortMessage, o as MindooDBAppBridgeRpcError, p as MindooDBAppBridgeRpcMessage, q as MindooDBAppBridgeRpcRequest, r as MindooDBAppBridgeRpcSuccess, s as MindooDBAppBridgeStreamAbortRequest, t as MindooDBAppBridgeStreamAck, u as MindooDBAppBridgeStreamCloseRequest, v as MindooDBAppBridgeStreamError, w as MindooDBAppBridgeStreamMessage, x as MindooDBAppBridgeStreamOpenResult, y as MindooDBAppBridgeStreamReadRequest, z as MindooDBAppBridgeStreamWriteRequest, A as MindooDBAppBridgeThemeChangedMessage, B as MindooDBAppBridgeUiPreferencesChangedMessage, C as MindooDBAppBridgeViewportChangedMessage, D as MindooDBAppCapability, E as MindooDBAppConfiguredViewCategorizationStyle, F as MindooDBAppConfiguredViewColumn, G as MindooDBAppConfiguredViewColumnRole, H as MindooDBAppConfiguredViewExpressionMode, I as MindooDBAppConfiguredViewFieldExpression, J as MindooDBAppConfiguredViewFilterDefinition, K as MindooDBAppConfiguredViewFilterMode, L as MindooDBAppConfiguredViewFilterRule, N as MindooDBAppConfiguredViewFormulaExpression, O as MindooDBAppConfiguredViewFormulaFilterDefinition, P as MindooDBAppConfiguredViewPreviewMode, Q as MindooDBAppConfiguredViewRuleFilterDefinition, R as MindooDBAppConfiguredViewRuleMatchMode, S as MindooDBAppConfiguredViewRuleOperator, T as MindooDBAppConfiguredViewValueExpression, U as MindooDBAppCreateDocumentInput, V as MindooDBAppCreateViewInput, W as MindooDBAppCreateViewNavigatorInput, X as MindooDBAppDatabaseInfo, Y as MindooDBAppDocumentApi, Z as MindooDBAppDocumentHeadCursorResult, _ as MindooDBAppDocumentHistoryEntry, $ as MindooDBAppDocumentListQuery, a0 as MindooDBAppDocumentListResult, a1 as MindooDBAppDocumentRevisionId, a2 as MindooDBAppDocumentScanPreset, a3 as MindooDBAppDocumentSummary, a4 as MindooDBAppHistoricalDocument, a5 as MindooDBAppHistoryQuery, a6 as MindooDBAppHostTheme, a7 as MindooDBAppJsonListDeletePatch, a8 as MindooDBAppJsonListInsertPatch, a9 as MindooDBAppJsonPatch, aa as MindooDBAppJsonSetPatch, ab as MindooDBAppJsonUnsetPatch, ac as MindooDBAppLaunchContext, ad as MindooDBAppMenuAnchor, ae as MindooDBAppMenuApi, af as MindooDBAppMenuCommandItem, ag as MindooDBAppMenuDismissReason, ah as MindooDBAppMenuDismissedResult, ai as MindooDBAppMenuItem, aj as MindooDBAppMenuKind, ak as MindooDBAppMenuPlacement, al as MindooDBAppMenuPointAnchor, am as MindooDBAppMenuRect, an as MindooDBAppMenuRectAnchor, ao as MindooDBAppMenuSelectionResult, ap as MindooDBAppMenuSeparatorItem, aq as MindooDBAppReadableAttachmentStream, ar as MindooDBAppResolvedViewDefinition, as as MindooDBAppResolvedViewSource, at as MindooDBAppRuntime, au as MindooDBAppScanAttachmentOptions, av as MindooDBAppScanAttachmentResult, aw as MindooDBAppScopedDocId, ax as MindooDBAppScopedDocumentSummary, ay as MindooDBAppSession, az as MindooDBAppShowMenuInput, aA as MindooDBAppShowMenuResult, aB as MindooDBAppTextEdit, aC as MindooDBAppTextPatch, aD as MindooDBAppThemeMode, aE as MindooDBAppUiPreferences, aF as MindooDBAppUpdateDocumentInput, aG as MindooDBAppViewCursorDocumentListResult, aH as MindooDBAppViewCursorResult, aI as MindooDBAppViewEntry, aJ as MindooDBAppViewEntryKind, aK as MindooDBAppViewNavigator, aL as MindooDBAppViewNavigatorExpansionState, aM as MindooDBAppViewNavigatorOpenOptions, aN as MindooDBAppViewNavigatorPageOptions, aO as MindooDBAppViewNavigatorPageResult, aP as MindooDBAppViewNavigatorRangeQuery, aQ as MindooDBAppViewNavigatorSelectionState, aR as MindooDBAppViewport, aS as MindooDBAppWritableAttachmentStream } from './types-Dw6YRApH.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
|
/**
|