mindoodb-app-sdk 0.0.18 → 0.0.19
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 +232 -4
- package/dist/index.d.ts +47 -3
- package/dist/index.js +143 -0
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +29 -0
- package/dist/{types-jzokkBX5.d.ts → types-nFt-aryL.d.ts} +41 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -390,11 +390,13 @@ Every `MindooDBAppDocument` snapshot also exposes a `heads?: string[]` field. Th
|
|
|
390
390
|
|
|
391
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`.
|
|
392
392
|
|
|
393
|
-
`documents.update()` accepts
|
|
393
|
+
`documents.update()` accepts five independent kinds of operations on the same call, applied atomically to one new document revision:
|
|
394
394
|
|
|
395
395
|
- `set` -- assign top-level fields (shallow JSON merge).
|
|
396
396
|
- `unset` -- remove top-level fields entirely.
|
|
397
|
-
- `
|
|
397
|
+
- `json` -- a **granular JSON patch** of `set` / `unset` / `listInsert` / `listDelete` operations applied at specific paths inside `document.data`, against a `baseHeads` version. See [Granular JSON edits](#granular-json-edits) below.
|
|
398
|
+
- `text` -- one or more **granular text patches** applied to specific string paths. Each patch carries the `baseHeads` version it was authored against and is merged on the Haven side with any concurrent changes that arrived since. This is the recommended way to edit collaborative text fields like a markdown body. See [Collaborative text editing](#collaborative-text-editing) below.
|
|
399
|
+
- `richText` -- one or more **rich-text span snapshots** for formatted-document fields (Word/.docx style). See [Collaborative rich-text editing](#collaborative-rich-text-editing) below.
|
|
398
400
|
|
|
399
401
|
Prefer sending small, intentional field-level changes instead of rewriting whole documents when only a few fields changed. This keeps MindooDB change tracking more meaningful and helps Automerge produce cleaner merge results.
|
|
400
402
|
|
|
@@ -444,6 +446,85 @@ const pointInTime = await db.documents.getAtTimestamp(
|
|
|
444
446
|
|
|
445
447
|
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`.
|
|
446
448
|
|
|
449
|
+
### Granular JSON edits
|
|
450
|
+
|
|
451
|
+
When you need to edit nested objects or lists inside a document — not just top-level fields — describe the change as a **granular JSON patch** rather than rewriting the whole document. This is the model behind structured collaborative editing in apps like [`mindoodb-app-teamgrid`](https://github.com/klehmann/mindoodb-app-teamgrid), where two users can insert different rows into the same worksheet on different devices and the merge keeps both sides cleanly.
|
|
452
|
+
|
|
453
|
+
A JSON patch is a bag of four operation kinds applied at specific JSON paths inside `document.data`, all carried with the document version (`baseHeads`) the app was looking at when it composed them:
|
|
454
|
+
|
|
455
|
+
- `set` — assign or replace a value at a path
|
|
456
|
+
- `unset` — remove a key (or list entry, when the host accepts it) at a path
|
|
457
|
+
- `listInsert` — splice values into a list at a position
|
|
458
|
+
- `listDelete` — remove a contiguous run of entries from a list
|
|
459
|
+
|
|
460
|
+
```ts
|
|
461
|
+
interface MindooDBAppJsonSetPatch {
|
|
462
|
+
path: Array<string | number>;
|
|
463
|
+
value: unknown;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
interface MindooDBAppJsonUnsetPatch {
|
|
467
|
+
path: Array<string | number>;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
interface MindooDBAppJsonListInsertPatch {
|
|
471
|
+
path: Array<string | number>;
|
|
472
|
+
index: number;
|
|
473
|
+
values: unknown[];
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
interface MindooDBAppJsonListDeletePatch {
|
|
477
|
+
path: Array<string | number>;
|
|
478
|
+
index: number;
|
|
479
|
+
deleteCount: number;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
interface MindooDBAppJsonPatch {
|
|
483
|
+
baseHeads?: string[];
|
|
484
|
+
set?: MindooDBAppJsonSetPatch[];
|
|
485
|
+
unset?: MindooDBAppJsonUnsetPatch[];
|
|
486
|
+
listInsert?: MindooDBAppJsonListInsertPatch[];
|
|
487
|
+
listDelete?: MindooDBAppJsonListDeletePatch[];
|
|
488
|
+
}
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
Send the patch through `documents.update({ json })`:
|
|
492
|
+
|
|
493
|
+
```ts
|
|
494
|
+
const doc = await db.documents.get(docId);
|
|
495
|
+
|
|
496
|
+
await db.documents.update(docId, {
|
|
497
|
+
json: {
|
|
498
|
+
baseHeads: doc!.heads,
|
|
499
|
+
set: [
|
|
500
|
+
{ path: ["worksheets", "ws-1", "title"], value: "Q1 numbers" },
|
|
501
|
+
{
|
|
502
|
+
path: ["worksheets", "ws-1", "cellsByRowCol", "row-3:col-2", "value"],
|
|
503
|
+
value: 42,
|
|
504
|
+
},
|
|
505
|
+
],
|
|
506
|
+
listInsert: [
|
|
507
|
+
{
|
|
508
|
+
path: ["worksheets", "ws-1", "rowOrder"],
|
|
509
|
+
index: 5,
|
|
510
|
+
values: ["row-new"],
|
|
511
|
+
},
|
|
512
|
+
],
|
|
513
|
+
listDelete: [
|
|
514
|
+
{
|
|
515
|
+
path: ["worksheets", "ws-1", "tombstoneRows"],
|
|
516
|
+
index: 0,
|
|
517
|
+
deleteCount: 1,
|
|
518
|
+
},
|
|
519
|
+
],
|
|
520
|
+
},
|
|
521
|
+
});
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
Haven applies the patch causally at `baseHeads` and merges it with any concurrent changes that arrived since, the same way the text and rich-text APIs do. List inserts authored against the same `baseHeads` interleave cleanly via Automerge's list CRDT instead of overwriting each other — which is exactly what makes two users inserting different rows on the same worksheet at the same time merge into a consistent grid rather than a last-writer-wins.
|
|
525
|
+
|
|
526
|
+
Patch flavors compose. `set`/`unset` (top-level fields), `json`, `text`, and `richText` can all appear in the same `documents.update()` call and are applied atomically to one new document revision. Prefer small, intentional operations over whole-document rewrites so MindooDB change tracking stays meaningful and Automerge produces cleaner merges.
|
|
527
|
+
|
|
447
528
|
### Collaborative text editing
|
|
448
529
|
|
|
449
530
|
MindooDB stores collaborative text fields as Automerge text CRDTs internally, but apps never touch Automerge directly -- the SDK bridge is JSON-only. Instead, your app describes text changes as **granular splice operations** against a known document version, and Haven applies and merges them on its side.
|
|
@@ -579,6 +660,120 @@ Buffer API at a glance:
|
|
|
579
660
|
|
|
580
661
|
The [`mindoodb-app-teamedit`](https://github.com/klehmann/mindoodb-app-teamedit) sample wires `MindooDBTextBuffer` to a Milkdown markdown editor with Save / Refresh / preview pane, and is the recommended starting point for building your own collaborative text app.
|
|
581
662
|
|
|
663
|
+
### Collaborative rich-text editing
|
|
664
|
+
|
|
665
|
+
For structured documents that need formatting — headings, bold/italic runs, lists, tables, fonts, colors — use the **rich-text patch API**. This is the surface behind the Word/.docx mode in [`mindoodb-app-teamedit`](https://github.com/klehmann/mindoodb-app-teamedit), where two users can edit the same document at the same time and Haven merges both formatting and structure on its side via Automerge's rich-text CRDT.
|
|
666
|
+
|
|
667
|
+
Rich-text fields are stored internally as Automerge rich-text, but apps never see Automerge directly. The bridge speaks JSON and represents a rich-text field as an ordered list of **spans** — text runs with marks for inline formatting, plus block markers for paragraphs, headings, lists, and tables:
|
|
668
|
+
|
|
669
|
+
```ts
|
|
670
|
+
interface MindooDBAppRichTextTextSpan {
|
|
671
|
+
type: "text";
|
|
672
|
+
value: string;
|
|
673
|
+
// Inline marks: bold, italic, underline, font, color, link, ...
|
|
674
|
+
marks?: Record<string, MindooDBAppRichTextMaterializeValue>;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
interface MindooDBAppRichTextBlockSpan {
|
|
678
|
+
type: "block";
|
|
679
|
+
// Block markers: paragraph, heading, list item, table cell, ...
|
|
680
|
+
value: Record<string, MindooDBAppRichTextMaterializeValue>;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
type MindooDBAppRichTextSpan =
|
|
684
|
+
| MindooDBAppRichTextTextSpan
|
|
685
|
+
| MindooDBAppRichTextBlockSpan;
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
#### Reading the current spans
|
|
689
|
+
|
|
690
|
+
```ts
|
|
691
|
+
const snapshot = await db.documents.getRichText(docId, ["body"]);
|
|
692
|
+
// snapshot = { path: ["body"], heads: ["<commit>"], spans: [...] }
|
|
693
|
+
|
|
694
|
+
editor.loadFromSpans(snapshot.spans);
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
`getRichText(docId, path, options?)` also accepts `{ revisionId }` so you can load the rich-text spans of an exact historical document revision (handy for read-only revision pickers).
|
|
698
|
+
|
|
699
|
+
#### Writing back a span snapshot
|
|
700
|
+
|
|
701
|
+
The simplest write is a full snapshot — replace the field's spans with the editor's current state:
|
|
702
|
+
|
|
703
|
+
```ts
|
|
704
|
+
await db.documents.update(docId, {
|
|
705
|
+
richText: [
|
|
706
|
+
{
|
|
707
|
+
path: ["body"],
|
|
708
|
+
baseHeads: snapshot.heads,
|
|
709
|
+
spans: editor.toSpans(),
|
|
710
|
+
},
|
|
711
|
+
],
|
|
712
|
+
});
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
Haven applies the snapshot via Automerge's `updateSpans` and merges it with any concurrent rich-text changes that arrived since `baseHeads`. The optional `updateSpansConfig` field is forwarded to Automerge for editors that need to tune merge behavior at the span level.
|
|
716
|
+
|
|
717
|
+
#### High-level: `createMindooDBRichTextHandle`
|
|
718
|
+
|
|
719
|
+
For editors that emit a complete spans array after each transaction, the SDK ships a buffer helper that mirrors `MindooDBTextBuffer`:
|
|
720
|
+
|
|
721
|
+
```ts
|
|
722
|
+
import { createMindooDBRichTextHandle } from "mindoodb-app-sdk";
|
|
723
|
+
|
|
724
|
+
const doc = await db.documents.get(docId);
|
|
725
|
+
const initial = await db.documents.getRichText(doc!.id, ["body"]);
|
|
726
|
+
|
|
727
|
+
const handle = createMindooDBRichTextHandle({
|
|
728
|
+
database: db,
|
|
729
|
+
document: doc!,
|
|
730
|
+
path: ["body"],
|
|
731
|
+
spans: initial.spans,
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
editor.loadFromSpans(handle.spans);
|
|
735
|
+
|
|
736
|
+
// Editor reports a fresh spans array after every change.
|
|
737
|
+
editor.on("change", (spans) => {
|
|
738
|
+
handle.replaceSpans(spans);
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
// On save (e.g. Cmd+S) flush the local snapshot to Haven.
|
|
742
|
+
async function save() {
|
|
743
|
+
const result = await handle.flush();
|
|
744
|
+
if (result.reconciled) {
|
|
745
|
+
// Haven merged in concurrent rich-text edits; show the canonical merged spans.
|
|
746
|
+
editor.loadFromSpans(result.snapshot.spans);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
// Optional: poll for remote changes while the editor is idle.
|
|
751
|
+
handle.startPolling(2000);
|
|
752
|
+
handle.on("change", (snapshot) => {
|
|
753
|
+
if (!handle.dirty) editor.loadFromSpans(snapshot.spans);
|
|
754
|
+
});
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
Handle API at a glance:
|
|
758
|
+
|
|
759
|
+
| Member | Description |
|
|
760
|
+
| ------------------------------------ | ----------------------------------------------------------------------------- |
|
|
761
|
+
| `spans` | Current local span snapshot |
|
|
762
|
+
| `dirty` | Whether local edits are buffered |
|
|
763
|
+
| `baseHeads` | Heads the local snapshot was authored against |
|
|
764
|
+
| `replaceSpans(spans)` | Replace the local spans buffer with a fresh snapshot |
|
|
765
|
+
| `refresh()` | Re-read `getRichText` and return the canonical snapshot |
|
|
766
|
+
| `pollOnce()` | Re-read and reconcile if the document advanced and there are no local edits |
|
|
767
|
+
| `startPolling(ms)` / `stopPolling()` | Poll `pollOnce` on a timer |
|
|
768
|
+
| `flush(updateSpansConfig?)` | Send pending spans to Haven; resolves to `{ document, snapshot, reconciled }` |
|
|
769
|
+
| `on/off("change", listener)` | Subscribe to local or reconciled-change events |
|
|
770
|
+
|
|
771
|
+
Like the text buffer, the rich-text handle always sends the original `baseHeads` captured when it was created or last reconciled, so two windows editing the same document at the same heads merge correctly without overwriting each other.
|
|
772
|
+
|
|
773
|
+
#### End-to-end sample
|
|
774
|
+
|
|
775
|
+
The Word/.docx mode in [`mindoodb-app-teamedit`](https://github.com/klehmann/mindoodb-app-teamedit) wires `MindooDBRichTextHandle` to an `@eigenpal/docx-editor-vue` editor and is the recommended starting point for building your own collaborative rich-text app.
|
|
776
|
+
|
|
582
777
|
### Incremental sync
|
|
583
778
|
|
|
584
779
|
The changefeed-backed `documents.list()` API is also the right primitive for app-side indexes, search, and other derived caches.
|
|
@@ -675,12 +870,41 @@ const scan = await db.attachments.scan(docId, {
|
|
|
675
870
|
preset: "a4-portrait",
|
|
676
871
|
mimeType: "application/pdf",
|
|
677
872
|
});
|
|
873
|
+
// scan = { ok: true, attachment: { attachmentId, fileName, mimeType, size } }
|
|
874
|
+
// or { ok: false } if the user cancelled the scanner
|
|
875
|
+
// or rejected with an error if the host has no scanner UI
|
|
678
876
|
|
|
679
877
|
// Remove
|
|
680
878
|
await db.attachments.remove(docId, "old-file.txt");
|
|
681
879
|
```
|
|
682
880
|
|
|
683
|
-
`attachments.scan()` asks Haven to open its document scanner UI. Haven handles camera
|
|
881
|
+
`attachments.scan()` asks Haven to open its document scanner UI on top of your app. Haven handles camera or file selection, runs edge detection through a slim on-device OpenCV WebAssembly pipeline, lets the user fine-tune the corners, applies the perspective correction to the chosen output size, and writes the resulting bytes as a normal MindooDoc attachment via the same path `openWriteStream` would have taken. The scanner runs entirely locally — the picked image and the perspective-corrected result never leave the browser tab.
|
|
882
|
+
|
|
883
|
+
Options shape:
|
|
884
|
+
|
|
885
|
+
```ts
|
|
886
|
+
type MindooDBAppDocumentScanPreset =
|
|
887
|
+
| "auto" // free-form, keep the detected aspect ratio
|
|
888
|
+
| "a4-portrait"
|
|
889
|
+
| "a4-landscape"
|
|
890
|
+
| "letter-portrait"
|
|
891
|
+
| "letter-landscape";
|
|
892
|
+
|
|
893
|
+
interface MindooDBAppScanAttachmentOptions {
|
|
894
|
+
defaultFileName?: string; // suggested filename in the dialog
|
|
895
|
+
preset?: MindooDBAppDocumentScanPreset; // output page geometry
|
|
896
|
+
mimeType?: "image/jpeg" | "image/png" | "application/pdf"; // output format
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
interface MindooDBAppScanAttachmentResult {
|
|
900
|
+
ok: boolean;
|
|
901
|
+
attachment?: MindooDBAppAttachmentInfo | null;
|
|
902
|
+
}
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
Apps need both the `attachments` and `update` capabilities for this method, because the scanner writes the resulting bytes back to the document. Hosts that do not provide scanner UI may reject this method or return `{ ok: false }`.
|
|
906
|
+
|
|
907
|
+
The same scanner is also reachable as a top-level **Quick Scan** entry in Haven's sidebar. There it runs detached from any document — the user can download the resulting file or hand it to the operating system's share sheet, but the "Add to document" action is hidden because there is no document context. Apps do not need to do anything to support this; it is part of Haven, not the SDK.
|
|
684
908
|
|
|
685
909
|
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:
|
|
686
910
|
|
|
@@ -983,6 +1207,7 @@ Connect options: `launchId?`, `targetOrigin?`, `connectTimeoutMs?`.
|
|
|
983
1207
|
| ---------------------------------- | -------------------------------------------- |
|
|
984
1208
|
| `list(query?)` | `Promise<MindooDBAppDocumentListResult>` |
|
|
985
1209
|
| `get(docId)` | `Promise<MindooDBAppDocument \| null>` |
|
|
1210
|
+
| `getRichText(docId, path, opts?)` | `Promise<MindooDBAppRichTextSnapshot>` |
|
|
986
1211
|
| `create(input)` | `Promise<MindooDBAppDocument>` |
|
|
987
1212
|
| `update(docId, patch)` | `Promise<MindooDBAppDocument>` |
|
|
988
1213
|
| `delete(docId)` | `Promise<{ ok: true }>` |
|
|
@@ -1003,11 +1228,13 @@ For `update(docId, patch)`, use `MindooDBAppUpdateDocumentInput`:
|
|
|
1003
1228
|
interface MindooDBAppUpdateDocumentInput {
|
|
1004
1229
|
set?: Record<string, unknown>; // shallow assign top-level fields
|
|
1005
1230
|
unset?: string[]; // remove top-level fields entirely
|
|
1231
|
+
json?: MindooDBAppJsonPatch; // granular structured edits at JSON paths
|
|
1006
1232
|
text?: MindooDBAppTextPatch[]; // granular collaborative text edits
|
|
1233
|
+
richText?: MindooDBAppRichTextPatch[]; // collaborative rich-text span snapshots
|
|
1007
1234
|
}
|
|
1008
1235
|
```
|
|
1009
1236
|
|
|
1010
|
-
`set` and `unset` apply to top-level fields only. `text` patches operate
|
|
1237
|
+
`set` and `unset` apply to top-level fields only. `json`, `text`, and `richText` patches operate at any JSON path inside `document.data` and are merged on the Haven side using the document's Automerge heads. See [Granular JSON edits](#granular-json-edits), [Collaborative text editing](#collaborative-text-editing), and [Collaborative rich-text editing](#collaborative-rich-text-editing).
|
|
1011
1238
|
|
|
1012
1239
|
### MindooDBAppAttachmentApi
|
|
1013
1240
|
|
|
@@ -1070,6 +1297,7 @@ interface MindooDBAppUpdateDocumentInput {
|
|
|
1070
1297
|
| ------------------------------------------ | ------------------------------------------------------------------------------------------- |
|
|
1071
1298
|
| `createMindooDBAppBridge()` | Create the bridge object used to connect to Haven |
|
|
1072
1299
|
| `createMindooDBTextBuffer(options)` | Create an editor-friendly buffer for granular collaborative text edits on a document field |
|
|
1300
|
+
| `createMindooDBRichTextHandle(options)` | Create an editor-friendly handle for collaborative rich-text span snapshots on a document field |
|
|
1073
1301
|
| `canPreviewAttachment(fileName, mimeType)` | Check if Haven can preview a file (returns mode or `null`) |
|
|
1074
1302
|
| `createViewLanguage<T>()` | Create a typed expression builder for view definitions |
|
|
1075
1303
|
| `abbreviateCanonicalName(value)` | Convert a canonical Notes-style name like `cn=Jane/ou=Dev/o=Mindoo` to `Jane/Dev/Mindoo` |
|
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 {
|
|
1
|
+
import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppBridge, b as MindooDBAppDatabase, c as MindooDBAppDocument, d as MindooDBAppRichTextSpan, e as MindooDBAppRichTextSnapshot } from './types-nFt-aryL.js';
|
|
2
|
+
export { f as MindooDBAppAttachmentApi, g as MindooDBAppAttachmentChunk, h as MindooDBAppAttachmentInfo, i as MindooDBAppAttachmentPreviewOptions, j as MindooDBAppAttachmentPreviewSession, k as MindooDBAppBridgeConnectMessage, l as MindooDBAppBridgeConnectOptions, m as MindooDBAppBridgeConnectedMessage, n as MindooDBAppBridgeErrorPayload, o as MindooDBAppBridgeHandshakeErrorMessage, p as MindooDBAppBridgePortMessage, q as MindooDBAppBridgeRpcError, r as MindooDBAppBridgeRpcMessage, s as MindooDBAppBridgeRpcRequest, t as MindooDBAppBridgeRpcSuccess, u as MindooDBAppBridgeStreamAbortRequest, v as MindooDBAppBridgeStreamAck, w as MindooDBAppBridgeStreamCloseRequest, x as MindooDBAppBridgeStreamError, y as MindooDBAppBridgeStreamMessage, z as MindooDBAppBridgeStreamOpenResult, A as MindooDBAppBridgeStreamReadRequest, B as MindooDBAppBridgeStreamWriteRequest, C as MindooDBAppBridgeThemeChangedMessage, D as MindooDBAppBridgeUiPreferencesChangedMessage, E as MindooDBAppBridgeViewportChangedMessage, F as MindooDBAppCapability, G as MindooDBAppConfiguredViewCategorizationStyle, H as MindooDBAppConfiguredViewColumn, I as MindooDBAppConfiguredViewColumnRole, J as MindooDBAppConfiguredViewExpressionMode, K as MindooDBAppConfiguredViewFieldExpression, L as MindooDBAppConfiguredViewFilterDefinition, N as MindooDBAppConfiguredViewFilterMode, O as MindooDBAppConfiguredViewFilterRule, P as MindooDBAppConfiguredViewFormulaExpression, Q as MindooDBAppConfiguredViewFormulaFilterDefinition, R as MindooDBAppConfiguredViewPreviewMode, S as MindooDBAppConfiguredViewRuleFilterDefinition, T as MindooDBAppConfiguredViewRuleMatchMode, U as MindooDBAppConfiguredViewRuleOperator, V as MindooDBAppConfiguredViewValueExpression, W as MindooDBAppCreateDocumentInput, X as MindooDBAppCreateViewInput, Y as MindooDBAppCreateViewNavigatorInput, Z as MindooDBAppDatabaseInfo, _ as MindooDBAppDocumentApi, $ as MindooDBAppDocumentHeadCursorResult, a0 as MindooDBAppDocumentHistoryEntry, a1 as MindooDBAppDocumentListQuery, a2 as MindooDBAppDocumentListResult, a3 as MindooDBAppDocumentRevisionId, a4 as MindooDBAppDocumentScanPreset, a5 as MindooDBAppDocumentSummary, a6 as MindooDBAppHistoricalDocument, a7 as MindooDBAppHistoryQuery, a8 as MindooDBAppHostTheme, a9 as MindooDBAppJsonListDeletePatch, aa as MindooDBAppJsonListInsertPatch, ab as MindooDBAppJsonPatch, ac as MindooDBAppJsonSetPatch, ad as MindooDBAppJsonUnsetPatch, ae as MindooDBAppLaunchContext, af as MindooDBAppMenuAnchor, ag as MindooDBAppMenuApi, ah as MindooDBAppMenuCommandItem, ai as MindooDBAppMenuDismissReason, aj as MindooDBAppMenuDismissedResult, ak as MindooDBAppMenuItem, al as MindooDBAppMenuKind, am as MindooDBAppMenuPlacement, an as MindooDBAppMenuPointAnchor, ao as MindooDBAppMenuRect, ap as MindooDBAppMenuRectAnchor, aq as MindooDBAppMenuSelectionResult, ar as MindooDBAppMenuSeparatorItem, as as MindooDBAppReadableAttachmentStream, at as MindooDBAppResolvedViewDefinition, au as MindooDBAppResolvedViewSource, av as MindooDBAppRichTextBlockSpan, aw as MindooDBAppRichTextGetOptions, ax as MindooDBAppRichTextImmutableString, ay as MindooDBAppRichTextMaterializeValue, az as MindooDBAppRichTextPatch, aA as MindooDBAppRichTextScalar, aB as MindooDBAppRichTextTextSpan, aC as MindooDBAppRuntime, aD as MindooDBAppScanAttachmentOptions, aE as MindooDBAppScanAttachmentResult, aF as MindooDBAppScopedDocId, aG as MindooDBAppScopedDocumentSummary, aH as MindooDBAppSession, aI as MindooDBAppShowMenuInput, aJ as MindooDBAppShowMenuResult, aK as MindooDBAppTextEdit, aL as MindooDBAppTextPatch, aM as MindooDBAppThemeMode, aN as MindooDBAppUiPreferences, aO as MindooDBAppUpdateDocumentInput, aP as MindooDBAppViewCursorDocumentListResult, aQ as MindooDBAppViewCursorResult, aR as MindooDBAppViewEntry, aS as MindooDBAppViewEntryKind, aT as MindooDBAppViewNavigator, aU as MindooDBAppViewNavigatorExpansionState, aV as MindooDBAppViewNavigatorOpenOptions, aW as MindooDBAppViewNavigatorPageOptions, aX as MindooDBAppViewNavigatorPageResult, aY as MindooDBAppViewNavigatorRangeQuery, aZ as MindooDBAppViewNavigatorSelectionState, a_ as MindooDBAppViewport, a$ as MindooDBAppWritableAttachmentStream } from './types-nFt-aryL.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
|
/**
|
|
@@ -37,6 +37,50 @@ declare function expandAbbreviatedName(value: string): string;
|
|
|
37
37
|
*/
|
|
38
38
|
declare function createMindooDBAppBridge(): MindooDBAppBridge;
|
|
39
39
|
|
|
40
|
+
interface CreateMindooDBRichTextHandleOptions {
|
|
41
|
+
database: MindooDBAppDatabase;
|
|
42
|
+
document: MindooDBAppDocument;
|
|
43
|
+
path: Array<string | number>;
|
|
44
|
+
spans?: MindooDBAppRichTextSpan[];
|
|
45
|
+
pollIntervalMs?: number;
|
|
46
|
+
}
|
|
47
|
+
interface MindooDBRichTextHandleFlushResult {
|
|
48
|
+
document: MindooDBAppDocument;
|
|
49
|
+
snapshot: MindooDBAppRichTextSnapshot;
|
|
50
|
+
reconciled: boolean;
|
|
51
|
+
}
|
|
52
|
+
type MindooDBRichTextHandleChangeListener = (snapshot: MindooDBAppRichTextSnapshot) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Local rich-text span buffer for SDK apps.
|
|
55
|
+
*
|
|
56
|
+
* The helper deliberately mirrors the causal shape of `MindooDBTextBuffer`:
|
|
57
|
+
* local editor code replaces the current span snapshot, then `flush()` sends a
|
|
58
|
+
* separate `richText` patch with the document heads the snapshot was based on.
|
|
59
|
+
*/
|
|
60
|
+
declare class MindooDBRichTextHandle {
|
|
61
|
+
private readonly options;
|
|
62
|
+
private spansInternal;
|
|
63
|
+
private heads;
|
|
64
|
+
private dirtyInternal;
|
|
65
|
+
private listeners;
|
|
66
|
+
private pollTimer;
|
|
67
|
+
constructor(options: CreateMindooDBRichTextHandleOptions);
|
|
68
|
+
get spans(): MindooDBAppRichTextSpan[];
|
|
69
|
+
get dirty(): boolean;
|
|
70
|
+
get baseHeads(): string[];
|
|
71
|
+
on(event: "change", listener: MindooDBRichTextHandleChangeListener): void;
|
|
72
|
+
off(event: "change", listener: MindooDBRichTextHandleChangeListener): void;
|
|
73
|
+
replaceSpans(spans: MindooDBAppRichTextSpan[]): void;
|
|
74
|
+
startPolling(intervalMs?: number): void;
|
|
75
|
+
stopPolling(): void;
|
|
76
|
+
reconcile(document: MindooDBAppDocument, snapshot: MindooDBAppRichTextSnapshot): boolean;
|
|
77
|
+
refresh(): Promise<MindooDBAppRichTextSnapshot>;
|
|
78
|
+
pollOnce(): Promise<boolean>;
|
|
79
|
+
flush(updateSpansConfig?: Record<string, unknown>): Promise<MindooDBRichTextHandleFlushResult>;
|
|
80
|
+
private emitChange;
|
|
81
|
+
}
|
|
82
|
+
declare function createMindooDBRichTextHandle(options: CreateMindooDBRichTextHandleOptions): MindooDBRichTextHandle;
|
|
83
|
+
|
|
40
84
|
/**
|
|
41
85
|
* Options used to create a text buffer for one string field in a MindooDB
|
|
42
86
|
* document.
|
|
@@ -130,4 +174,4 @@ declare class MindooDBTextBuffer {
|
|
|
130
174
|
/** Create a local text buffer for one string field in a document. */
|
|
131
175
|
declare function createMindooDBTextBuffer(options: CreateMindooDBTextBufferOptions): MindooDBTextBuffer;
|
|
132
176
|
|
|
133
|
-
export { type CreateMindooDBTextBufferOptions, MindooDBAppAttachmentPreviewMode, MindooDBAppBridge, MindooDBAppDatabase, MindooDBAppDocument, MindooDBTextBuffer, type MindooDBTextBufferFlushResult, abbreviateCanonicalName, canPreviewAttachment, createMindooDBAppBridge, createMindooDBTextBuffer, expandAbbreviatedName };
|
|
177
|
+
export { type CreateMindooDBRichTextHandleOptions, type CreateMindooDBTextBufferOptions, MindooDBAppAttachmentPreviewMode, MindooDBAppBridge, MindooDBAppDatabase, MindooDBAppDocument, MindooDBAppRichTextSnapshot, MindooDBAppRichTextSpan, MindooDBRichTextHandle, type MindooDBRichTextHandleChangeListener, type MindooDBRichTextHandleFlushResult, MindooDBTextBuffer, type MindooDBTextBufferFlushResult, abbreviateCanonicalName, canPreviewAttachment, createMindooDBAppBridge, createMindooDBRichTextHandle, createMindooDBTextBuffer, expandAbbreviatedName };
|
package/dist/index.js
CHANGED
|
@@ -726,6 +726,12 @@ var MindooDBAppDatabaseImpl = class {
|
|
|
726
726
|
databaseId: this.databaseId,
|
|
727
727
|
docId
|
|
728
728
|
}),
|
|
729
|
+
getRichText: async (docId, path, options) => await this.rpc.call("documents.richText.get", {
|
|
730
|
+
databaseId: this.databaseId,
|
|
731
|
+
docId,
|
|
732
|
+
path,
|
|
733
|
+
revisionId: options?.revisionId
|
|
734
|
+
}),
|
|
729
735
|
create: async (input) => await this.rpc.call("documents.create", {
|
|
730
736
|
databaseId: this.databaseId,
|
|
731
737
|
input
|
|
@@ -987,6 +993,141 @@ function createMindooDBAppBridge() {
|
|
|
987
993
|
};
|
|
988
994
|
}
|
|
989
995
|
|
|
996
|
+
// src/richTextHandle.ts
|
|
997
|
+
var MindooDBRichTextHandle = class {
|
|
998
|
+
constructor(options) {
|
|
999
|
+
this.options = options;
|
|
1000
|
+
this.spansInternal = cloneSpans(options.spans ?? []);
|
|
1001
|
+
this.heads = options.document.heads ? [...options.document.heads] : [];
|
|
1002
|
+
}
|
|
1003
|
+
options;
|
|
1004
|
+
spansInternal;
|
|
1005
|
+
heads;
|
|
1006
|
+
dirtyInternal = false;
|
|
1007
|
+
listeners = /* @__PURE__ */ new Set();
|
|
1008
|
+
pollTimer = null;
|
|
1009
|
+
get spans() {
|
|
1010
|
+
return cloneSpans(this.spansInternal);
|
|
1011
|
+
}
|
|
1012
|
+
get dirty() {
|
|
1013
|
+
return this.dirtyInternal;
|
|
1014
|
+
}
|
|
1015
|
+
get baseHeads() {
|
|
1016
|
+
return [...this.heads];
|
|
1017
|
+
}
|
|
1018
|
+
on(event, listener) {
|
|
1019
|
+
this.listeners.add(listener);
|
|
1020
|
+
}
|
|
1021
|
+
off(event, listener) {
|
|
1022
|
+
this.listeners.delete(listener);
|
|
1023
|
+
}
|
|
1024
|
+
replaceSpans(spans) {
|
|
1025
|
+
this.spansInternal = cloneSpans(spans);
|
|
1026
|
+
this.dirtyInternal = true;
|
|
1027
|
+
this.emitChange();
|
|
1028
|
+
}
|
|
1029
|
+
startPolling(intervalMs = this.options.pollIntervalMs ?? 2e3) {
|
|
1030
|
+
this.stopPolling();
|
|
1031
|
+
this.pollTimer = setInterval(() => {
|
|
1032
|
+
void this.pollOnce();
|
|
1033
|
+
}, intervalMs);
|
|
1034
|
+
}
|
|
1035
|
+
stopPolling() {
|
|
1036
|
+
if (this.pollTimer) {
|
|
1037
|
+
clearInterval(this.pollTimer);
|
|
1038
|
+
this.pollTimer = null;
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
reconcile(document, snapshot) {
|
|
1042
|
+
const previous = JSON.stringify(this.spansInternal);
|
|
1043
|
+
this.spansInternal = cloneSpans(snapshot.spans);
|
|
1044
|
+
this.heads = snapshot.heads ?? document.heads ?? [];
|
|
1045
|
+
this.dirtyInternal = false;
|
|
1046
|
+
const changed = JSON.stringify(this.spansInternal) !== previous;
|
|
1047
|
+
if (changed) {
|
|
1048
|
+
this.emitChange();
|
|
1049
|
+
}
|
|
1050
|
+
return changed;
|
|
1051
|
+
}
|
|
1052
|
+
async refresh() {
|
|
1053
|
+
const snapshot = await this.options.database.documents.getRichText(
|
|
1054
|
+
this.options.document.id,
|
|
1055
|
+
this.options.path
|
|
1056
|
+
);
|
|
1057
|
+
return snapshot;
|
|
1058
|
+
}
|
|
1059
|
+
async pollOnce() {
|
|
1060
|
+
if (this.dirtyInternal) {
|
|
1061
|
+
return false;
|
|
1062
|
+
}
|
|
1063
|
+
const document = await this.options.database.documents.get(
|
|
1064
|
+
this.options.document.id
|
|
1065
|
+
);
|
|
1066
|
+
if (!document) {
|
|
1067
|
+
return false;
|
|
1068
|
+
}
|
|
1069
|
+
const snapshot = await this.refresh();
|
|
1070
|
+
return this.reconcile(document, snapshot);
|
|
1071
|
+
}
|
|
1072
|
+
async flush(updateSpansConfig) {
|
|
1073
|
+
if (!this.dirtyInternal) {
|
|
1074
|
+
return {
|
|
1075
|
+
document: this.options.document,
|
|
1076
|
+
snapshot: {
|
|
1077
|
+
path: [...this.options.path],
|
|
1078
|
+
heads: [...this.heads],
|
|
1079
|
+
spans: cloneSpans(this.spansInternal)
|
|
1080
|
+
},
|
|
1081
|
+
reconciled: false
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
const localSpansAtFlush = JSON.stringify(this.spansInternal);
|
|
1085
|
+
const document = await this.options.database.documents.update(
|
|
1086
|
+
this.options.document.id,
|
|
1087
|
+
{
|
|
1088
|
+
richText: [{
|
|
1089
|
+
path: this.options.path,
|
|
1090
|
+
baseHeads: this.heads,
|
|
1091
|
+
spans: cloneSpans(this.spansInternal),
|
|
1092
|
+
updateSpansConfig
|
|
1093
|
+
}]
|
|
1094
|
+
}
|
|
1095
|
+
);
|
|
1096
|
+
const snapshot = await this.options.database.documents.getRichText(
|
|
1097
|
+
this.options.document.id,
|
|
1098
|
+
this.options.path
|
|
1099
|
+
);
|
|
1100
|
+
const reconciled = JSON.stringify(snapshot.spans) !== localSpansAtFlush;
|
|
1101
|
+
this.spansInternal = cloneSpans(snapshot.spans);
|
|
1102
|
+
this.heads = snapshot.heads ?? document.heads ?? [];
|
|
1103
|
+
this.dirtyInternal = false;
|
|
1104
|
+
if (reconciled) {
|
|
1105
|
+
this.emitChange();
|
|
1106
|
+
}
|
|
1107
|
+
return {
|
|
1108
|
+
document,
|
|
1109
|
+
snapshot,
|
|
1110
|
+
reconciled
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
emitChange() {
|
|
1114
|
+
const snapshot = {
|
|
1115
|
+
path: [...this.options.path],
|
|
1116
|
+
heads: [...this.heads],
|
|
1117
|
+
spans: cloneSpans(this.spansInternal)
|
|
1118
|
+
};
|
|
1119
|
+
for (const listener of this.listeners) {
|
|
1120
|
+
listener(snapshot);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
function createMindooDBRichTextHandle(options) {
|
|
1125
|
+
return new MindooDBRichTextHandle(options);
|
|
1126
|
+
}
|
|
1127
|
+
function cloneSpans(spans) {
|
|
1128
|
+
return structuredClone(spans);
|
|
1129
|
+
}
|
|
1130
|
+
|
|
990
1131
|
// src/textBuffer.ts
|
|
991
1132
|
var MindooDBTextBuffer = class {
|
|
992
1133
|
constructor(options) {
|
|
@@ -1135,10 +1276,12 @@ import {
|
|
|
1135
1276
|
mindooDBViewLanguageHelpersByName
|
|
1136
1277
|
} from "mindoodb-view-language";
|
|
1137
1278
|
export {
|
|
1279
|
+
MindooDBRichTextHandle,
|
|
1138
1280
|
MindooDBTextBuffer,
|
|
1139
1281
|
abbreviateCanonicalName,
|
|
1140
1282
|
canPreviewAttachment,
|
|
1141
1283
|
createMindooDBAppBridge,
|
|
1284
|
+
createMindooDBRichTextHandle,
|
|
1142
1285
|
createMindooDBTextBuffer,
|
|
1143
1286
|
createViewLanguage,
|
|
1144
1287
|
expandAbbreviatedName
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ae as MindooDBAppLaunchContext, Z as MindooDBAppDatabaseInfo, _ as MindooDBAppDocumentApi, Y as MindooDBAppCreateViewNavigatorInput, aT as MindooDBAppViewNavigator, aV as MindooDBAppViewNavigatorOpenOptions, f as MindooDBAppAttachmentApi, a as MindooDBAppBridge, aH as MindooDBAppSession, s as MindooDBAppBridgeRpcRequest, a8 as MindooDBAppHostTheme, a_ as MindooDBAppViewport, aN as MindooDBAppUiPreferences, p as MindooDBAppBridgePortMessage } from '../types-nFt-aryL.js';
|
|
2
2
|
import 'mindoodb-view-language';
|
|
3
3
|
|
|
4
4
|
type MaybePromise<T> = T | Promise<T>;
|
package/dist/testing/index.js
CHANGED
|
@@ -26,6 +26,9 @@ function applyDocumentUpdatePatch(current, patch) {
|
|
|
26
26
|
for (const textPatch of patch.text ?? []) {
|
|
27
27
|
applyMockTextPatch(next, textPatch.path, textPatch.edits);
|
|
28
28
|
}
|
|
29
|
+
for (const richTextPatch of patch.richText ?? []) {
|
|
30
|
+
setValueAtPath(next, richTextPatch.path, structuredClone(richTextPatch.spans));
|
|
31
|
+
}
|
|
29
32
|
return next;
|
|
30
33
|
}
|
|
31
34
|
function applyMockJsonPatch(target, patch) {
|
|
@@ -125,6 +128,16 @@ function applyMockTextPatch(target, path, edits) {
|
|
|
125
128
|
}
|
|
126
129
|
parent[leaf] = value;
|
|
127
130
|
}
|
|
131
|
+
function readRichTextSpansAtPath(target, path) {
|
|
132
|
+
let value = target;
|
|
133
|
+
for (const segment of path) {
|
|
134
|
+
if (value == null || typeof value !== "object") {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
value = value[segment];
|
|
138
|
+
}
|
|
139
|
+
return Array.isArray(value) ? value : [];
|
|
140
|
+
}
|
|
128
141
|
function mergeLaunchContext(current, patch) {
|
|
129
142
|
if (!patch) {
|
|
130
143
|
return {
|
|
@@ -567,6 +580,17 @@ function createDatabaseHandle(definition) {
|
|
|
567
580
|
updatedAt: document.updatedAt
|
|
568
581
|
};
|
|
569
582
|
},
|
|
583
|
+
async getRichText(docId, path, _options) {
|
|
584
|
+
const document = storedDocuments.get(docId);
|
|
585
|
+
if (!document || document.isDeleted) {
|
|
586
|
+
throw new Error(`Document ${docId} was not found.`);
|
|
587
|
+
}
|
|
588
|
+
return {
|
|
589
|
+
path: [...path],
|
|
590
|
+
heads: document.heads ? [...document.heads] : void 0,
|
|
591
|
+
spans: structuredClone(readRichTextSpansAtPath(document.data, path))
|
|
592
|
+
};
|
|
593
|
+
},
|
|
570
594
|
async create(input) {
|
|
571
595
|
const callerId = typeof input.id === "string" && input.id.length > 0 ? input.id : null;
|
|
572
596
|
if (callerId) {
|
|
@@ -1140,6 +1164,11 @@ function createFakeBridgeHost(options = {}) {
|
|
|
1140
1164
|
return await state.getDatabase(String(params.databaseId)).documents.getHeadCursor();
|
|
1141
1165
|
case "documents.get":
|
|
1142
1166
|
return await state.getDatabase(String(params.databaseId)).documents.get(String(params.docId));
|
|
1167
|
+
case "documents.richText.get":
|
|
1168
|
+
return await state.getDatabase(String(params.databaseId)).documents.getRichText(
|
|
1169
|
+
String(params.docId),
|
|
1170
|
+
params.path
|
|
1171
|
+
);
|
|
1143
1172
|
case "documents.create":
|
|
1144
1173
|
return await state.getDatabase(String(params.databaseId)).documents.create(
|
|
1145
1174
|
params.input
|
|
@@ -277,6 +277,43 @@ interface MindooDBAppTextPatch {
|
|
|
277
277
|
baseHeads?: string[];
|
|
278
278
|
edits: MindooDBAppTextEdit[];
|
|
279
279
|
}
|
|
280
|
+
type MindooDBAppRichTextScalar = string | number | boolean | null;
|
|
281
|
+
interface MindooDBAppRichTextImmutableString {
|
|
282
|
+
type: "immutableString";
|
|
283
|
+
value: string;
|
|
284
|
+
}
|
|
285
|
+
type MindooDBAppRichTextMaterializeValue = MindooDBAppRichTextScalar | MindooDBAppRichTextImmutableString | MindooDBAppRichTextMaterializeValue[] | {
|
|
286
|
+
[key: string]: MindooDBAppRichTextMaterializeValue;
|
|
287
|
+
};
|
|
288
|
+
interface MindooDBAppRichTextTextSpan {
|
|
289
|
+
type: "text";
|
|
290
|
+
value: string;
|
|
291
|
+
marks?: Record<string, MindooDBAppRichTextMaterializeValue>;
|
|
292
|
+
}
|
|
293
|
+
interface MindooDBAppRichTextBlockSpan {
|
|
294
|
+
type: "block";
|
|
295
|
+
value: Record<string, MindooDBAppRichTextMaterializeValue>;
|
|
296
|
+
}
|
|
297
|
+
type MindooDBAppRichTextSpan = MindooDBAppRichTextTextSpan | MindooDBAppRichTextBlockSpan;
|
|
298
|
+
interface MindooDBAppRichTextPatch {
|
|
299
|
+
/** Path to the Automerge rich-text field inside the document payload. */
|
|
300
|
+
path: Array<string | number>;
|
|
301
|
+
/** Automerge heads of the document state this rich-text snapshot was based on. */
|
|
302
|
+
baseHeads?: string[];
|
|
303
|
+
/** Full JSON-safe span snapshot to apply with Automerge `updateSpans`. */
|
|
304
|
+
spans: MindooDBAppRichTextSpan[];
|
|
305
|
+
/** Optional Automerge `updateSpans` configuration, kept JSON-safe over the bridge. */
|
|
306
|
+
updateSpansConfig?: Record<string, unknown>;
|
|
307
|
+
}
|
|
308
|
+
interface MindooDBAppRichTextSnapshot {
|
|
309
|
+
path: Array<string | number>;
|
|
310
|
+
heads?: string[];
|
|
311
|
+
spans: MindooDBAppRichTextSpan[];
|
|
312
|
+
}
|
|
313
|
+
interface MindooDBAppRichTextGetOptions {
|
|
314
|
+
/** Stable revision id previously obtained from `documents.listHistory()`. */
|
|
315
|
+
revisionId?: MindooDBAppDocumentRevisionId;
|
|
316
|
+
}
|
|
280
317
|
/**
|
|
281
318
|
* Sets the value at `path` inside the document payload.
|
|
282
319
|
*
|
|
@@ -347,6 +384,8 @@ interface MindooDBAppUpdateDocumentInput {
|
|
|
347
384
|
json?: MindooDBAppJsonPatch;
|
|
348
385
|
/** Granular text edits to apply at document paths. */
|
|
349
386
|
text?: MindooDBAppTextPatch[];
|
|
387
|
+
/** Rich-text span snapshots to apply at document paths. */
|
|
388
|
+
richText?: MindooDBAppRichTextPatch[];
|
|
350
389
|
}
|
|
351
390
|
/** Query used for history lookups at a specific timestamp. */
|
|
352
391
|
interface MindooDBAppHistoryQuery {
|
|
@@ -560,6 +599,7 @@ interface MindooDBAppDocumentApi {
|
|
|
560
599
|
list(query?: MindooDBAppDocumentListQuery): Promise<MindooDBAppDocumentListResult>;
|
|
561
600
|
getHeadCursor(): Promise<MindooDBAppDocumentHeadCursorResult>;
|
|
562
601
|
get(docId: string): Promise<MindooDBAppDocument | null>;
|
|
602
|
+
getRichText(docId: string, path: Array<string | number>, options?: MindooDBAppRichTextGetOptions): Promise<MindooDBAppRichTextSnapshot>;
|
|
563
603
|
create(input: MindooDBAppCreateDocumentInput): Promise<MindooDBAppDocument>;
|
|
564
604
|
update(docId: string, patch: MindooDBAppUpdateDocumentInput): Promise<MindooDBAppDocument>;
|
|
565
605
|
delete(docId: string): Promise<{
|
|
@@ -737,4 +777,4 @@ interface MindooDBAppBridge {
|
|
|
737
777
|
connect(options?: MindooDBAppBridgeConnectOptions): Promise<MindooDBAppSession>;
|
|
738
778
|
}
|
|
739
779
|
|
|
740
|
-
export type {
|
|
780
|
+
export type { MindooDBAppDocumentHeadCursorResult as $, MindooDBAppBridgeStreamReadRequest as A, MindooDBAppBridgeStreamWriteRequest as B, MindooDBAppBridgeThemeChangedMessage as C, MindooDBAppBridgeUiPreferencesChangedMessage as D, MindooDBAppBridgeViewportChangedMessage as E, MindooDBAppCapability as F, MindooDBAppConfiguredViewCategorizationStyle as G, MindooDBAppConfiguredViewColumn as H, MindooDBAppConfiguredViewColumnRole as I, MindooDBAppConfiguredViewExpressionMode as J, MindooDBAppConfiguredViewFieldExpression as K, MindooDBAppConfiguredViewFilterDefinition as L, MindooDBAppAttachmentPreviewMode as M, MindooDBAppConfiguredViewFilterMode as N, MindooDBAppConfiguredViewFilterRule as O, MindooDBAppConfiguredViewFormulaExpression as P, MindooDBAppConfiguredViewFormulaFilterDefinition as Q, MindooDBAppConfiguredViewPreviewMode as R, MindooDBAppConfiguredViewRuleFilterDefinition as S, MindooDBAppConfiguredViewRuleMatchMode as T, MindooDBAppConfiguredViewRuleOperator as U, MindooDBAppConfiguredViewValueExpression as V, MindooDBAppCreateDocumentInput as W, MindooDBAppCreateViewInput as X, MindooDBAppCreateViewNavigatorInput as Y, MindooDBAppDatabaseInfo as Z, MindooDBAppDocumentApi as _, MindooDBAppBridge as a, MindooDBAppWritableAttachmentStream as a$, MindooDBAppDocumentHistoryEntry as a0, MindooDBAppDocumentListQuery as a1, MindooDBAppDocumentListResult as a2, MindooDBAppDocumentRevisionId as a3, MindooDBAppDocumentScanPreset as a4, MindooDBAppDocumentSummary as a5, MindooDBAppHistoricalDocument as a6, MindooDBAppHistoryQuery as a7, MindooDBAppHostTheme as a8, MindooDBAppJsonListDeletePatch as a9, MindooDBAppRichTextScalar as aA, MindooDBAppRichTextTextSpan as aB, MindooDBAppRuntime as aC, MindooDBAppScanAttachmentOptions as aD, MindooDBAppScanAttachmentResult as aE, MindooDBAppScopedDocId as aF, MindooDBAppScopedDocumentSummary as aG, MindooDBAppSession as aH, MindooDBAppShowMenuInput as aI, MindooDBAppShowMenuResult as aJ, MindooDBAppTextEdit as aK, MindooDBAppTextPatch as aL, MindooDBAppThemeMode as aM, MindooDBAppUiPreferences as aN, MindooDBAppUpdateDocumentInput as aO, MindooDBAppViewCursorDocumentListResult as aP, MindooDBAppViewCursorResult as aQ, MindooDBAppViewEntry as aR, MindooDBAppViewEntryKind as aS, MindooDBAppViewNavigator as aT, MindooDBAppViewNavigatorExpansionState as aU, MindooDBAppViewNavigatorOpenOptions as aV, MindooDBAppViewNavigatorPageOptions as aW, MindooDBAppViewNavigatorPageResult as aX, MindooDBAppViewNavigatorRangeQuery as aY, MindooDBAppViewNavigatorSelectionState as aZ, MindooDBAppViewport as a_, MindooDBAppJsonListInsertPatch as aa, MindooDBAppJsonPatch as ab, MindooDBAppJsonSetPatch as ac, MindooDBAppJsonUnsetPatch as ad, MindooDBAppLaunchContext as ae, MindooDBAppMenuAnchor as af, MindooDBAppMenuApi as ag, MindooDBAppMenuCommandItem as ah, MindooDBAppMenuDismissReason as ai, MindooDBAppMenuDismissedResult as aj, MindooDBAppMenuItem as ak, MindooDBAppMenuKind as al, MindooDBAppMenuPlacement as am, MindooDBAppMenuPointAnchor as an, MindooDBAppMenuRect as ao, MindooDBAppMenuRectAnchor as ap, MindooDBAppMenuSelectionResult as aq, MindooDBAppMenuSeparatorItem as ar, MindooDBAppReadableAttachmentStream as as, MindooDBAppResolvedViewDefinition as at, MindooDBAppResolvedViewSource as au, MindooDBAppRichTextBlockSpan as av, MindooDBAppRichTextGetOptions as aw, MindooDBAppRichTextImmutableString as ax, MindooDBAppRichTextMaterializeValue as ay, MindooDBAppRichTextPatch as az, MindooDBAppDatabase as b, MindooDBAppDocument as c, MindooDBAppRichTextSpan as d, MindooDBAppRichTextSnapshot as e, MindooDBAppAttachmentApi as f, MindooDBAppAttachmentChunk as g, MindooDBAppAttachmentInfo as h, MindooDBAppAttachmentPreviewOptions as i, MindooDBAppAttachmentPreviewSession as j, MindooDBAppBridgeConnectMessage as k, MindooDBAppBridgeConnectOptions as l, MindooDBAppBridgeConnectedMessage as m, MindooDBAppBridgeErrorPayload as n, MindooDBAppBridgeHandshakeErrorMessage as o, MindooDBAppBridgePortMessage as p, MindooDBAppBridgeRpcError as q, MindooDBAppBridgeRpcMessage as r, MindooDBAppBridgeRpcRequest as s, MindooDBAppBridgeRpcSuccess as t, MindooDBAppBridgeStreamAbortRequest as u, MindooDBAppBridgeStreamAck as v, MindooDBAppBridgeStreamCloseRequest as w, MindooDBAppBridgeStreamError as x, MindooDBAppBridgeStreamMessage as y, MindooDBAppBridgeStreamOpenResult as z };
|