mindoodb-app-sdk 0.0.49 → 0.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -229,6 +229,35 @@ Important constraints:
229
229
  - Call `session.menus.hide()` if your app needs to explicitly dismiss a pending host menu.
230
230
  - Host-rendered menus are intended for `runtime === "iframe"`. Window-mode apps can usually show local menus instead.
231
231
 
232
+ ### Host focus and notifications
233
+
234
+ A click inside the iframe already asks Haven to focus this launch. Call `requestHostFocus()` when the app should take focus without a click.
235
+
236
+ `hasHostFocus()` is true only when this launch is the surface the user is looking at: the focused tile on the active workspace page, or this launch open as a standalone runner. A background tile, another page, or another app is false. `onHostFocusChange()` fires when that answer changes, so a long task can decide whether to notify without polling.
237
+
238
+ ```ts
239
+ const stop = session.onHostFocusChange((focused) => {
240
+ if (!focused) {
241
+ void session.notify({
242
+ id: "sync",
243
+ severity: "info",
244
+ text: "Sync finished",
245
+ });
246
+ }
247
+ });
248
+
249
+ await session.notify({
250
+ id: "progress",
251
+ severity: "info",
252
+ text: "10%",
253
+ durationMs: 1500,
254
+ });
255
+ ```
256
+
257
+ Show a notice when the app does not have host focus, or when a long task finishes and the user may have looked away. Do not notify while `hasHostFocus()` is true and the user is already looking at the app.
258
+
259
+ Haven uses the app's registration label as the headline and ignores any title from the app. Pass the same `id` to update that notice in place. Omit `id` to add another notice. An id only matches notices from this launch. Omit `durationMs` and the notice stays until the user dismisses it or clicks it. A duration is clamped to about 1–8 seconds, which fits a short progress step such as "10%". Clicking the notice brings that launch back. The close button only dismisses it.
260
+
232
261
  ### Host-owned drag
233
262
 
234
263
  When two apps run as visible workspace chicklets, native HTML5 drag dies at the iframe boundary. The SDK therefore hands the gesture to Haven: the source starts it, Haven draws a PNG ghost above every frame, and the target hit-tests the drop.
@@ -458,7 +487,7 @@ A snapshot also carries `decryptionKeyId?: string` — the named shared key its
458
487
 
459
488
  - `set` -- assign top-level fields (shallow JSON merge).
460
489
  - `unset` -- remove top-level fields entirely.
461
- - `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.
490
+ - `json` -- a **granular JSON patch** of `set` / `unset` / `listInsert` / `listDelete` operations (plus text splices/marks and `counterIncrement`) applied at specific paths inside `document.data`, against a `baseHeads` version. See [Granular JSON edits](#granular-json-edits) and [Typed values](#typed-values-atomic-strings-counters-timestamps) below.
462
491
  - `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.
463
492
  - `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.
464
493
 
@@ -614,6 +643,109 @@ Haven applies the patch causally at `baseHeads` and merges it with any concurren
614
643
 
615
644
  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.
616
645
 
646
+ ### Typed values: atomic strings, counters, timestamps
647
+
648
+ `document.data` is JSON, and JSON has one kind of string and one kind of number. For collaborative data that is not enough, so the SDK adds three **typed values**. You create them with `MindooDBAppValue` and use them anywhere you write a value: `documents.create({ set })`, `documents.update({ set })`, and `set` / `listInsert` values of a JSON patch, also nested inside objects and arrays.
649
+
650
+ ```ts
651
+ import { MindooDBAppValue } from "mindoodb-app-sdk";
652
+
653
+ const task = await db.documents.create({
654
+ set: {
655
+ title: "Write release notes", // collaborative text
656
+ status: MindooDBAppValue.atomic("open"), // atomic string
657
+ votes: MindooDBAppValue.counter(0), // counter
658
+ dueAt: MindooDBAppValue.timestamp("2026-10-01T12:00:00Z"),
659
+ assignee: { userId: MindooDBAppValue.atomic("u-42"), name: "Ada" },
660
+ },
661
+ });
662
+
663
+ task.data.status; // "open"
664
+ task.data.votes; // 0
665
+ task.data.dueAt; // "2026-10-01T12:00:00.000Z"
666
+ ```
667
+
668
+ | Helper | Use it for | Reads back as |
669
+ |---|---|---|
670
+ | `MindooDBAppValue.atomic(string)` | ids, status and enum values, URLs, hashes, stored text cursors | `string` |
671
+ | `MindooDBAppValue.counter(initial = 0)` | tallies several people change: votes, likes, stock, seats | `number` |
672
+ | `MindooDBAppValue.timestamp(Date \| ms \| ISO string)` | dates and times | ISO 8601 string (UTC, with ms) |
673
+
674
+ Why they matter:
675
+
676
+ - **Plain strings are collaborative text.** Concurrent edits are merged character by character, which is right for titles, notes and bodies. For a status that one user changes from `"open"` to `"closed"` while another changes it to `"blocked"`, text merging can produce a mix of both words. An **atomic** string is replaced as a whole: one of the two values wins. It is also cheaper to store.
677
+ - **Plain numbers are last-writer-wins.** If two users both read `votes: 4` and each save `5`, one vote is lost. A **counter** sums concurrent increments, so the result is `6`.
678
+ - **An ISO string written as a plain string is text**, not a date. A **timestamp** stays a date for everyone who reads the document.
679
+
680
+ The helpers produce plain JSON (`{ "$mindoo": "atomic", "value": "open" }`), so the values pass the bridge unchanged, and Haven converts them into the matching collaborative type. The key `$mindoo` is reserved: an object carrying it must be one of these values, otherwise the write is rejected.
681
+
682
+ Reads return plain JSON, so **a value keeps its type only if you write it again with the helper.** Writing `status: "done"` stores text; write `status: MindooDBAppValue.atomic("done")`. Haven's database browser keeps the type when a user edits such a field in the JSON view.
683
+
684
+ #### Counters
685
+
686
+ Create a counter once, then change it only with `counterIncrement`:
687
+
688
+ ```ts
689
+ interface MindooDBAppJsonCounterIncrementPatch {
690
+ path: Array<string | number>;
691
+ delta: number; // safe integer, negative to decrement
692
+ }
693
+
694
+ await db.documents.update(docId, {
695
+ json: { counterIncrement: [{ path: ["votes"], delta: 1 }] },
696
+ });
697
+ ```
698
+
699
+ - Writing `MindooDBAppValue.counter(n)` or a plain number over an existing counter resets it. That is an assignment and does not merge with concurrent increments, so use it for creation and deliberate resets only.
700
+ - `counterIncrement` on a missing field creates the counter with value `delta`. If two devices do that concurrently for the same field, only one creation survives, so create shared counters up front, ideally in `documents.create`.
701
+ - `counterIncrement` on a plain number is rejected: the field is not a counter.
702
+ - `counterIncrement` runs after the other operations of the same JSON patch, so a patch may create an object with `set` and increment a counter inside it.
703
+ - In Haven's database browser a counter can be edited in the JSON view: the new value is saved as the difference to the loaded value, so increments made by others in the meantime are kept.
704
+
705
+ ### Text cursors (anchors for comments and highlights)
706
+
707
+ An index like "character 120" breaks as soon as another user inserts text before it. A **text cursor** identifies a character instead of a position, so it keeps pointing at the same spot while the text around it changes. Use cursors for comment and review anchors, highlights, bookmarks, "continue reading here" markers or links into a long text.
708
+
709
+ ```ts
710
+ // Anchor a comment to characters 120..134 of the body (end exclusive: 135).
711
+ // The end cursor names the LAST character of the range, see below.
712
+ const doc = await db.documents.get(docId);
713
+ const { cursors } = await db.documents.getTextCursors(docId, ["body"], [120, 134], {
714
+ heads: doc!.heads, // the version the user selected in
715
+ });
716
+ await db.documents.update(docId, {
717
+ json: {
718
+ listInsert: [{
719
+ path: ["comments"],
720
+ index: 0,
721
+ values: [{
722
+ text: "Source?",
723
+ from: MindooDBAppValue.atomic(cursors[0]!),
724
+ to: MindooDBAppValue.atomic(cursors[1]!),
725
+ }],
726
+ }],
727
+ },
728
+ });
729
+
730
+ // Later, after other users edited the body
731
+ const current = (await db.documents.get(docId))!;
732
+ const comment = current.data.comments[0];
733
+ const { positions } = await db.documents.resolveTextCursors(docId, ["body"], [comment.from, comment.to], {
734
+ heads: current.heads, // resolve in the version you are about to render
735
+ });
736
+ const [start, last] = positions;
737
+ const quoted = current.data.body.slice(start, last + 1);
738
+ ```
739
+
740
+ Details:
741
+
742
+ - A cursor names the character at its index. Text inserted exactly at that index lands in front of the character, so the cursor moves right. For a range, anchor the start on its first character and the end on its **last** character, then add 1 after resolving. An end cursor on the character after the range would grow the range whenever someone types at its end.
743
+ - `positions` accepts character indexes (clamped to the text length) and `"start"` / `"end"`. An `"end"` cursor stays at the end when text is appended.
744
+ - A cursor whose character was deleted resolves to where the character used to be. `move: "before"` makes it resolve towards the start of the text instead of the end.
745
+ - `heads` (or `revisionId`) creates or resolves cursors against that document version. Pass the heads your editor rendered from so positions the user selected are interpreted in the text they saw.
746
+ - Cursors only work on collaborative text: plain strings and rich text. Atomic strings, numbers and missing fields are rejected. Store the cursor strings themselves as atomic strings.
747
+ - Both calls need the `read` capability. The mock bridge from `mindoodb-app-sdk/testing` returns cursors that do not follow later edits; test anchoring behavior against Haven.
748
+
617
749
  ### Collaborative text editing
618
750
 
619
751
  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.
@@ -1060,6 +1192,18 @@ const setup = await db.getFulltextSetup(); // null when never configured
1060
1192
  - `attachments: true` indexes attachment text under the synthetic `_attachments` field using the host's extractors (Haven ships anydoc for Office/PDF/… plus plain-text extractors). Restrict a query to attachment content with `text: { query, fields: ["_attachments"] }`.
1061
1193
  - Changing the configuration (including `language`) rebuilds the index in the background; queries during the rebuild report `coverage: "rebuilding"`.
1062
1194
 
1195
+ **Making nested fields queryable** — `query()` only sees fields in the database's summary buffer. By default that is every top-level scalar or array of scalars up to 1 KB; nested objects and arrays of objects are skipped. Include what your list UIs need so they don't have to `documents.get` each document:
1196
+
1197
+ ```ts
1198
+ // Idempotent, synced via the `dbsetup` document. Requires the `update` capability.
1199
+ const current = await db.getSummarySetup(); // null = default auto-include
1200
+ const include = [...new Set([...(current?.include ?? []), "phases"])];
1201
+ await db.setSummarySetup({ ...current, include });
1202
+ ```
1203
+
1204
+ - `include` paths may be nested (`"meta.author"`) or non-scalar and bypass the size cap; `exclude` wins over both.
1205
+ - A change re-extracts all documents in the background; queries report `coverage: "rebuilding"` until the backfill finishes, so keep a fallback for missing fields.
1206
+
1063
1207
  **Extracting text from bytes you already have** (requires `attachments`):
1064
1208
 
1065
1209
  ```ts
@@ -1636,6 +1780,10 @@ Connect options: `launchId?`, `targetOrigin?`, `connectTimeoutMs?`.
1636
1780
  | `closeSealedChannel(channelId)` | `Promise<void>` |
1637
1781
  | `menus.show(input)` | `Promise<MindooDBAppShowMenuResult>` |
1638
1782
  | `menus.hide()` | `Promise<void>` |
1783
+ | `requestHostFocus()` | `Promise<void>` |
1784
+ | `hasHostFocus()` | `Promise<boolean>` |
1785
+ | `onHostFocusChange(listener)` | `() => void` (unsubscribe) |
1786
+ | `notify(input)` | `Promise<{ id: string }>` |
1639
1787
  | `drag.setProfile(profile)` | `Promise<void>` |
1640
1788
  | `drag.start(input)` | `Promise<MindooDBAppDragStartResult>` |
1641
1789
  | `drag.cancel()` | `Promise<void>` |
@@ -1670,6 +1818,8 @@ Host-kept key/value state, the only durable storage a hosted app has. See [Stora
1670
1818
  | `attachments` | `MindooDBAppAttachmentApi` |
1671
1819
  | `getFulltextSetup()` | `Promise<MindooDBAppFulltextSetup \| null>` |
1672
1820
  | `setFulltextSetup(config)` | `Promise<void>` |
1821
+ | `getSummarySetup()` | `Promise<MindooDBAppSummarySetup \| null>` |
1822
+ | `setSummarySetup(config)` | `Promise<void>` |
1673
1823
 
1674
1824
  ### MindooDBAppDocumentApi
1675
1825
 
package/TESTING.md CHANGED
@@ -107,6 +107,7 @@ Each database entry can provide:
107
107
  - `methods.views` for session-level `createView()` and `openView()` calls (overrides the default evaluating navigator)
108
108
  - `methods.attachments`
109
109
  - `fulltextSetup` — the initial config returned by `db.getFulltextSetup()`; `db.setFulltextSetup()` overwrites it for the lifetime of the handle. Use this to test your app's full-text bootstrap logic. Note the mock evaluates `text` query clauses regardless of this config.
110
+ - `summarySetup` — the initial config returned by `db.getSummarySetup()`; `db.setSummarySetup()` overwrites it for the lifetime of the handle. The mock's `query()` reads seeded documents directly and ignores this config; use it to test your app's summary bootstrap logic.
110
111
 
111
112
  ### Evaluating VirtualViews
112
113
 
@@ -1,3 +1,45 @@
1
+ // src/values.ts
2
+ var MINDOODB_APP_VALUE_TAG = "$mindoo";
3
+ var MindooDBAppValue = {
4
+ /**
5
+ * An atomic string for identifiers, status and enum values, URLs, hashes
6
+ * and stored text cursors. Plain strings are collaborative text, where two
7
+ * concurrent changes of `"open"` to `"closed"` and `"blocked"` can
8
+ * interleave into a mix of both words.
9
+ */
10
+ atomic(value) {
11
+ if (typeof value !== "string") {
12
+ throw new Error("MindooDBAppValue.atomic value must be a string");
13
+ }
14
+ return { $mindoo: "atomic", value };
15
+ },
16
+ /**
17
+ * A collaborative counter with an initial value (a safe integer). Create it
18
+ * once, then change it only with `json.counterIncrement`: writing a new
19
+ * counter is an assignment that does not merge with concurrent increments.
20
+ */
21
+ counter(value = 0) {
22
+ if (!Number.isSafeInteger(value)) {
23
+ throw new Error("MindooDBAppValue.counter value must be a safe integer");
24
+ }
25
+ return { $mindoo: "counter", value };
26
+ },
27
+ /** A timestamp from a `Date`, epoch milliseconds or an ISO 8601 string. */
28
+ timestamp(value) {
29
+ const date = value instanceof Date ? new Date(value.getTime()) : new Date(value);
30
+ if (typeof value === "string" && value.trim() === "" || Number.isNaN(date.getTime())) {
31
+ throw new Error(
32
+ "MindooDBAppValue.timestamp value must be a Date, epoch milliseconds or an ISO 8601 date-time string"
33
+ );
34
+ }
35
+ return { $mindoo: "timestamp", value: date.toISOString() };
36
+ },
37
+ /** Whether `value` is a tagged typed value (any kind). */
38
+ isTyped(value) {
39
+ return value !== null && typeof value === "object" && !Array.isArray(value) && Object.prototype.hasOwnProperty.call(value, MINDOODB_APP_VALUE_TAG);
40
+ }
41
+ };
42
+
1
43
  // src/drag.ts
2
44
  var MINDOODB_APP_MAX_DRAG_TYPES = 8;
3
45
  var MINDOODB_APP_MAX_DRAG_PAYLOAD_BYTES = 32 * 1024;
@@ -392,11 +434,13 @@ function bindDragSource(element, options, start, follow) {
392
434
  // src/hostShortcuts.ts
393
435
  var DEFAULT_HAVEN_HOST_SHORTCUTS = [
394
436
  { action: "open-workspace", code: "Enter", shiftKey: true, metaOrCtrl: true },
395
- { action: "toggle-app-drawer", code: "Space", shiftKey: true, metaOrCtrl: true }
437
+ { action: "toggle-app-drawer", code: "Space", shiftKey: true, metaOrCtrl: true },
438
+ { action: "toggle-workspace-maximize", code: "KeyM", shiftKey: true, metaOrCtrl: true }
396
439
  ];
397
440
  var HOST_SHORTCUT_ACTIONS = /* @__PURE__ */ new Set([
398
441
  "open-workspace",
399
- "toggle-app-drawer"
442
+ "toggle-app-drawer",
443
+ "toggle-workspace-maximize"
400
444
  ]);
401
445
  function normalizeShortcutCode(code) {
402
446
  return code === "NumpadEnter" ? "Enter" : code;
@@ -627,6 +671,21 @@ var PortRpcClient = class {
627
671
  }
628
672
  };
629
673
 
674
+ // src/hostFocus.ts
675
+ function installHostFocusCapture(options) {
676
+ const target = options.target ?? (typeof document === "undefined" ? void 0 : document);
677
+ if (!target) {
678
+ return () => void 0;
679
+ }
680
+ const onPointerDown = () => {
681
+ options.onPointerDown();
682
+ };
683
+ target.addEventListener("pointerdown", onPointerDown, true);
684
+ return () => {
685
+ target.removeEventListener("pointerdown", onPointerDown, true);
686
+ };
687
+ }
688
+
630
689
  // src/client/createMindooDBAppBridge.ts
631
690
  var PROTOCOL2 = "mindoodb-app-bridge";
632
691
  var DEFAULT_CONNECT_TIMEOUT_MS = 1e4;
@@ -1226,6 +1285,23 @@ var MindooDBAppDatabaseImpl = class {
1226
1285
  path,
1227
1286
  revisionId: options?.revisionId
1228
1287
  }),
1288
+ getTextCursors: async (docId, path, positions, options) => await this.rpc.call("documents.textCursors.get", {
1289
+ databaseId: this.databaseId,
1290
+ docId,
1291
+ path,
1292
+ positions,
1293
+ heads: options?.heads,
1294
+ move: options?.move,
1295
+ revisionId: options?.revisionId
1296
+ }),
1297
+ resolveTextCursors: async (docId, path, cursors, options) => await this.rpc.call("documents.textCursors.resolve", {
1298
+ databaseId: this.databaseId,
1299
+ docId,
1300
+ path,
1301
+ cursors,
1302
+ heads: options?.heads,
1303
+ revisionId: options?.revisionId
1304
+ }),
1229
1305
  getAutomergeSnapshot: async (docId, options) => await this.rpc.call("documents.automerge.getSnapshot", {
1230
1306
  databaseId: this.databaseId,
1231
1307
  docId,
@@ -1236,6 +1312,26 @@ var MindooDBAppDatabaseImpl = class {
1236
1312
  docId,
1237
1313
  patch
1238
1314
  }),
1315
+ applyAutomergeChangesBatch: async (items) => {
1316
+ if (items.length === 0) return [];
1317
+ try {
1318
+ return await this.rpc.call("documents.automerge.applyChangesBatch", {
1319
+ databaseId: this.databaseId,
1320
+ items
1321
+ });
1322
+ } catch (error) {
1323
+ if (!isMethodNotFoundError(error)) throw error;
1324
+ const results = [];
1325
+ for (const item of items) {
1326
+ results.push(await this.rpc.call("documents.automerge.applyChanges", {
1327
+ databaseId: this.databaseId,
1328
+ docId: item.docId,
1329
+ patch: item.patch
1330
+ }));
1331
+ }
1332
+ return results;
1333
+ }
1334
+ },
1239
1335
  create: async (input) => await this.rpc.call("documents.create", {
1240
1336
  databaseId: this.databaseId,
1241
1337
  input
@@ -1576,6 +1672,21 @@ var MindooDBAppDatabaseImpl = class {
1576
1672
  config
1577
1673
  });
1578
1674
  }
1675
+ /** Reads the summary buffer configuration from the synced `dbsetup` document. */
1676
+ async getSummarySetup() {
1677
+ const result = await this.rpc.call(
1678
+ "database.getSummarySetup",
1679
+ { databaseId: this.databaseId }
1680
+ );
1681
+ return result.config;
1682
+ }
1683
+ /** Writes (or removes, with `null`) the summary buffer configuration. */
1684
+ async setSummarySetup(config) {
1685
+ await this.rpc.call("database.setSummarySetup", {
1686
+ databaseId: this.databaseId,
1687
+ config
1688
+ });
1689
+ }
1579
1690
  };
1580
1691
  var MindooDBAppDragApiImpl = class {
1581
1692
  constructor(rpc) {
@@ -1718,6 +1829,18 @@ var MindooDBAppSessionImpl = class {
1718
1829
  }
1719
1830
  }
1720
1831
  }) : () => void 0;
1832
+ this.stopHostFocus = installHostFocusCapture({
1833
+ onPointerDown: () => {
1834
+ try {
1835
+ this.rpc.postMessage({
1836
+ protocol: PROTOCOL2,
1837
+ kind: "workspace-focus-requested"
1838
+ });
1839
+ } catch (error) {
1840
+ console.warn("[mindoodb-app-sdk] Could not request host focus.", error);
1841
+ }
1842
+ }
1843
+ });
1721
1844
  }
1722
1845
  rpc;
1723
1846
  onDisconnect;
@@ -1727,6 +1850,7 @@ var MindooDBAppSessionImpl = class {
1727
1850
  beforeCloseListeners = /* @__PURE__ */ new Set();
1728
1851
  hostShortcuts = DEFAULT_HAVEN_HOST_SHORTCUTS;
1729
1852
  stopHostShortcuts;
1853
+ stopHostFocus;
1730
1854
  /**
1731
1855
  * Lets every listener finish, then tells the host it may proceed.
1732
1856
  *
@@ -1862,6 +1986,27 @@ var MindooDBAppSessionImpl = class {
1862
1986
  }
1863
1987
  });
1864
1988
  }
1989
+ /** Ask Haven to treat this launch as the focused surface. */
1990
+ async requestHostFocus() {
1991
+ await this.rpc.call("session.requestHostFocus", {});
1992
+ }
1993
+ /** Whether this launch is the surface the user is looking at. */
1994
+ async hasHostFocus() {
1995
+ const result = await this.rpc.call("session.hasHostFocus", {});
1996
+ return result?.focused === true;
1997
+ }
1998
+ /** Fires when the host-focus answer for this launch changes. */
1999
+ onHostFocusChange(listener) {
2000
+ return this.rpc.addMessageListener((message) => {
2001
+ if (message.kind === "host-focus-changed") {
2002
+ listener(message.focused);
2003
+ }
2004
+ });
2005
+ }
2006
+ /** Ask Haven to show or update a notice for this launch. */
2007
+ async notify(input) {
2008
+ return await this.rpc.call("notifications.show", input);
2009
+ }
1865
2010
  /** Register work to run before the host tears this launch down. */
1866
2011
  onBeforeClose(listener) {
1867
2012
  this.beforeCloseListeners.add(listener);
@@ -1872,6 +2017,7 @@ var MindooDBAppSessionImpl = class {
1872
2017
  /** Disconnects from the host and always disposes the underlying port client. */
1873
2018
  async disconnect() {
1874
2019
  this.stopHostShortcuts();
2020
+ this.stopHostFocus();
1875
2021
  this.drag.dispose();
1876
2022
  try {
1877
2023
  await this.rpc.call("session.disconnect", {});
@@ -1925,6 +2071,8 @@ function createMindooDBAppBridge() {
1925
2071
  }
1926
2072
 
1927
2073
  export {
2074
+ MINDOODB_APP_VALUE_TAG,
2075
+ MindooDBAppValue,
1928
2076
  MINDOODB_APP_MAX_DRAG_TYPES,
1929
2077
  MINDOODB_APP_MAX_DRAG_PAYLOAD_BYTES,
1930
2078
  MINDOODB_APP_MAX_DRAG_PREVIEW_BYTES,
package/dist/index.d.ts CHANGED
@@ -1,10 +1,62 @@
1
- import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppDragBindSourceOptions, b as MindooDBAppDragStartInput, c as MindooDBAppDragStartResult, d as MindooDBAppDragPreview, e as MindooDBAppBridge, f as MindooDBAppHostShortcutBinding, g as MindooDBAppHostShortcutAction, h as MindooDBAppHostingMode, i as MindooDBAppDatabase, j as MindooDBAppDocument, k as MindooDBAppRichTextSpan, l as MindooDBAppRichTextSnapshot } from './types-C-eyC839.js';
2
- export { m as MINDOODB_APP_DEFINITION_FILE_NAME, n as MINDOODB_APP_DEFINITION_FORMAT, o as MINDOODB_APP_DEFINITION_PERMISSIONS, p as MINDOODB_APP_DEFINITION_REGISTRATION_PERMISSIONS, q as MINDOODB_APP_DEFINITION_VERSION, r as MINDOODB_APP_SEAL_SIGNING_DOMAIN, s as MINDOODB_APP_WELL_KNOWN_DRAG_TYPES, t as MindooDBAppAccessDecision, u as MindooDBAppAccessTier, v as MindooDBAppAttachmentApi, w as MindooDBAppAttachmentChunk, x as MindooDBAppAttachmentInfo, y as MindooDBAppAttachmentPreviewOptions, z as MindooDBAppAttachmentPreviewSession, A as MindooDBAppAutomergeChangesPatch, B as MindooDBAppAutomergeChangesSince, C as MindooDBAppAutomergeGetOptions, D as MindooDBAppAutomergePatchResult, E as MindooDBAppAutomergeSnapshot, F as MindooDBAppBridgeBeforeCloseAck, G as MindooDBAppBridgeBeforeCloseMessage, H as MindooDBAppBridgeConnectMessage, I as MindooDBAppBridgeConnectOptions, J as MindooDBAppBridgeConnectedMessage, K as MindooDBAppBridgeDragDropMessage, L as MindooDBAppBridgeDragLeaveMessage, N as MindooDBAppBridgeDragOverMessage, O as MindooDBAppBridgeErrorPayload, P as MindooDBAppBridgeHandshakeErrorMessage, Q as MindooDBAppBridgeLocaleChangedMessage, R as MindooDBAppBridgePortMessage, S as MindooDBAppBridgeQueryResultMessage, T as MindooDBAppBridgeRpcError, U as MindooDBAppBridgeRpcMessage, V as MindooDBAppBridgeRpcRequest, W as MindooDBAppBridgeRpcSuccess, X as MindooDBAppBridgeShortcutInvokedMessage, Y as MindooDBAppBridgeShortcutsChangedMessage, Z as MindooDBAppBridgeStreamAbortRequest, _ as MindooDBAppBridgeStreamAck, $ as MindooDBAppBridgeStreamCloseRequest, a0 as MindooDBAppBridgeStreamError, a1 as MindooDBAppBridgeStreamMessage, a2 as MindooDBAppBridgeStreamOpenResult, a3 as MindooDBAppBridgeStreamReadRequest, a4 as MindooDBAppBridgeStreamWriteRequest, a5 as MindooDBAppBridgeThemeChangedMessage, a6 as MindooDBAppBridgeUiPreferencesChangedMessage, a7 as MindooDBAppBridgeViewChangedMessage, a8 as MindooDBAppBridgeViewportChangedMessage, a9 as MindooDBAppCapability, aa as MindooDBAppConfiguredViewCategorizationStyle, ab as MindooDBAppConfiguredViewColumn, ac as MindooDBAppConfiguredViewColumnRole, ad as MindooDBAppConfiguredViewExpressionMode, ae as MindooDBAppConfiguredViewFieldExpression, af as MindooDBAppConfiguredViewFilterDefinition, ag as MindooDBAppConfiguredViewFilterMode, ah as MindooDBAppConfiguredViewFilterRule, ai as MindooDBAppConfiguredViewFormulaExpression, aj as MindooDBAppConfiguredViewFormulaFilterDefinition, ak as MindooDBAppConfiguredViewPreviewMode, al as MindooDBAppConfiguredViewRuleFilterDefinition, am as MindooDBAppConfiguredViewRuleMatchMode, an as MindooDBAppConfiguredViewRuleOperator, ao as MindooDBAppConfiguredViewValueExpression, ap as MindooDBAppCreateDocumentInput, aq as MindooDBAppCreateKeyInfo, ar as MindooDBAppCreateViewInput, as as MindooDBAppCreateViewNavigatorInput, at as MindooDBAppDatabaseInfo, au as MindooDBAppDefinition, av as MindooDBAppDefinitionDatabase, aw as MindooDBAppDefinitionPermission, ax as MindooDBAppDefinitionRegistrationPermission, ay as MindooDBAppDefinitionValidation, az as MindooDBAppDirectoryApi, aA as MindooDBAppDirectoryEntry, aB as MindooDBAppDocumentApi, aC as MindooDBAppDocumentHeadCursorResult, aD as MindooDBAppDocumentHistoryEntry, aE as MindooDBAppDocumentListQuery, aF as MindooDBAppDocumentListResult, aG as MindooDBAppDocumentQuery, aH as MindooDBAppDocumentRevisionId, aI as MindooDBAppDocumentScanPreset, aJ as MindooDBAppDocumentSummary, aK as MindooDBAppDragApi, aL as MindooDBAppDragCancelReason, aM as MindooDBAppDragDropEvent, aN as MindooDBAppDragEffect, aO as MindooDBAppDragHoverResult, aP as MindooDBAppDragOffer, aQ as MindooDBAppDragOverEvent, aR as MindooDBAppDragPointer, aS as MindooDBAppDragProfile, aT as MindooDBAppEntryAttachmentRef, aU as MindooDBAppEntryProvenance, aV as MindooDBAppExtractDocumentTextInput, aW as MindooDBAppExtractDocumentTextResult, aX as MindooDBAppExtractTextFormat, aY as MindooDBAppExtractionSetup, aZ as MindooDBAppFulltextSetup, a_ as MindooDBAppHistoricalDocument, a$ as MindooDBAppHistoryQuery, b0 as MindooDBAppHostTheme, b1 as MindooDBAppIdentityApi, b2 as MindooDBAppInaccessibleDocument, b3 as MindooDBAppInaccessibleDocumentListQuery, b4 as MindooDBAppInaccessibleDocumentListResult, b5 as MindooDBAppJsonListDeletePatch, b6 as MindooDBAppJsonListInsertPatch, b7 as MindooDBAppJsonPatch, b8 as MindooDBAppJsonSetPatch, b9 as MindooDBAppJsonTextMarkPatch, ba as MindooDBAppJsonTextSplicePatch, bb as MindooDBAppJsonTextUnmarkPatch, bc as MindooDBAppJsonUnsetPatch, bd as MindooDBAppLaunchContext, be as MindooDBAppLiveQuerySubscription, bf as MindooDBAppMenuAnchor, bg as MindooDBAppMenuApi, bh as MindooDBAppMenuCommandItem, bi as MindooDBAppMenuDismissReason, bj as MindooDBAppMenuDismissedResult, bk as MindooDBAppMenuItem, bl as MindooDBAppMenuKind, bm as MindooDBAppMenuPlacement, bn as MindooDBAppMenuPointAnchor, bo as MindooDBAppMenuRect, bp as MindooDBAppMenuRectAnchor, bq as MindooDBAppMenuSelectionResult, br as MindooDBAppMenuSeparatorItem, bs as MindooDBAppProposeAppInput, bt as MindooDBAppProposeAppResult, bu as MindooDBAppQueryCoverage, bv as MindooDBAppQueryInclude, bw as MindooDBAppQueryIncludeCardinality, bx as MindooDBAppQueryIncludeSlots, by as MindooDBAppQueryResult, bz as MindooDBAppQueryRow, bA as MindooDBAppQuerySortKey, bB as MindooDBAppQueryTextClause, bC as MindooDBAppReadableAttachmentStream, bD as MindooDBAppRecipientOptions, bE as MindooDBAppResolvedViewDefinition, bF as MindooDBAppResolvedViewSource, bG as MindooDBAppRevisionPhase, bH as MindooDBAppRevisionVerification, bI as MindooDBAppRichTextBlockSpan, bJ as MindooDBAppRichTextGetOptions, bK as MindooDBAppRichTextImmutableString, bL as MindooDBAppRichTextMarkRange, bM as MindooDBAppRichTextMaterializeValue, bN as MindooDBAppRichTextPatch, bO as MindooDBAppRichTextScalar, bP as MindooDBAppRichTextSpliceStep, bQ as MindooDBAppRichTextStep, bR as MindooDBAppRichTextStepPatch, bS as MindooDBAppRichTextTextSpan, bT as MindooDBAppRuntime, bU as MindooDBAppScanAttachmentOptions, bV as MindooDBAppScanAttachmentResult, bW as MindooDBAppScopedDocId, bX as MindooDBAppScopedDocumentSummary, bY as MindooDBAppSealIntent, bZ as MindooDBAppSealedChannelOpenInput, b_ as MindooDBAppSealedChannelOpenResult, b$ as MindooDBAppSealedChannelRequestInput, c0 as MindooDBAppSession, c1 as MindooDBAppShowMenuInput, c2 as MindooDBAppShowMenuResult, c3 as MindooDBAppSignPreview, c4 as MindooDBAppSignPreviewScope, c5 as MindooDBAppSignStatementInput, c6 as MindooDBAppSignStatementResult, c7 as MindooDBAppStorageApi, c8 as MindooDBAppTextEdit, c9 as MindooDBAppTextPatch, ca as MindooDBAppThemeMode, cb as MindooDBAppTimestampApi, cc as MindooDBAppTimestampInput, cd as MindooDBAppTimestampProvider, ce as MindooDBAppTimestampResult, cf as MindooDBAppUiPreferences, cg as MindooDBAppUpdateDocumentInput, ch as MindooDBAppViewCursorDocumentListResult, ci as MindooDBAppViewCursorResult, cj as MindooDBAppViewEntry, ck as MindooDBAppViewEntryKind, cl as MindooDBAppViewNavigator, cm as MindooDBAppViewNavigatorExpansionState, cn as MindooDBAppViewNavigatorOpenOptions, co as MindooDBAppViewNavigatorPageOptions, cp as MindooDBAppViewNavigatorPageResult, cq as MindooDBAppViewNavigatorRangeQuery, cr as MindooDBAppViewNavigatorSelectionState, cs as MindooDBAppViewUpdateStats, ct as MindooDBAppViewport, cu as MindooDBAppWellKnownDragType, cv as MindooDBAppWritableAttachmentStream, cw as resolveMindooDBAppDefinitionUrl, cx as validateMindooDBAppDefinition } from './types-C-eyC839.js';
1
+ import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppDragBindSourceOptions, b as MindooDBAppDragStartInput, c as MindooDBAppDragStartResult, d as MindooDBAppDragPreview, e as MindooDBAppBridge, f as MindooDBAppHostShortcutBinding, g as MindooDBAppHostShortcutAction, h as MindooDBAppHostingMode, i as MindooDBAppDatabase, j as MindooDBAppDocument, k as MindooDBAppRichTextSpan, l as MindooDBAppRichTextSnapshot, m as MindooDBAppCreateDocumentInput } from './types-BLyV6Ejy.js';
2
+ export { n as MINDOODB_APP_DEFINITION_FILE_NAME, o as MINDOODB_APP_DEFINITION_FORMAT, p as MINDOODB_APP_DEFINITION_PERMISSIONS, q as MINDOODB_APP_DEFINITION_REGISTRATION_PERMISSIONS, r as MINDOODB_APP_DEFINITION_VERSION, s as MINDOODB_APP_SEAL_SIGNING_DOMAIN, t as MINDOODB_APP_WELL_KNOWN_DRAG_TYPES, u as MindooDBAppAccessDecision, v as MindooDBAppAccessTier, w as MindooDBAppAttachmentApi, x as MindooDBAppAttachmentChunk, y as MindooDBAppAttachmentInfo, z as MindooDBAppAttachmentPreviewOptions, A as MindooDBAppAttachmentPreviewSession, B as MindooDBAppAutomergeChangesPatch, C as MindooDBAppAutomergeChangesSince, D as MindooDBAppAutomergeGetOptions, E as MindooDBAppAutomergePatchResult, F as MindooDBAppAutomergeSnapshot, G as MindooDBAppBridgeBeforeCloseAck, H as MindooDBAppBridgeBeforeCloseMessage, I as MindooDBAppBridgeConnectMessage, J as MindooDBAppBridgeConnectOptions, K as MindooDBAppBridgeConnectedMessage, L as MindooDBAppBridgeDragDropMessage, N as MindooDBAppBridgeDragLeaveMessage, O as MindooDBAppBridgeDragOverMessage, P as MindooDBAppBridgeErrorPayload, Q as MindooDBAppBridgeHandshakeErrorMessage, R as MindooDBAppBridgeHostFocusChangedMessage, S as MindooDBAppBridgeLocaleChangedMessage, T as MindooDBAppBridgePortMessage, U as MindooDBAppBridgeQueryResultMessage, V as MindooDBAppBridgeRpcError, W as MindooDBAppBridgeRpcMessage, X as MindooDBAppBridgeRpcRequest, Y as MindooDBAppBridgeRpcSuccess, Z as MindooDBAppBridgeShortcutInvokedMessage, _ as MindooDBAppBridgeShortcutsChangedMessage, $ as MindooDBAppBridgeStreamAbortRequest, a0 as MindooDBAppBridgeStreamAck, a1 as MindooDBAppBridgeStreamCloseRequest, a2 as MindooDBAppBridgeStreamError, a3 as MindooDBAppBridgeStreamMessage, a4 as MindooDBAppBridgeStreamOpenResult, a5 as MindooDBAppBridgeStreamReadRequest, a6 as MindooDBAppBridgeStreamWriteRequest, a7 as MindooDBAppBridgeThemeChangedMessage, a8 as MindooDBAppBridgeUiPreferencesChangedMessage, a9 as MindooDBAppBridgeViewChangedMessage, aa as MindooDBAppBridgeViewportChangedMessage, ab as MindooDBAppBridgeWorkspaceFocusRequestedMessage, ac as MindooDBAppCapability, ad as MindooDBAppConfiguredViewCategorizationStyle, ae as MindooDBAppConfiguredViewColumn, af as MindooDBAppConfiguredViewColumnRole, ag as MindooDBAppConfiguredViewExpressionMode, ah as MindooDBAppConfiguredViewFieldExpression, ai as MindooDBAppConfiguredViewFilterDefinition, aj as MindooDBAppConfiguredViewFilterMode, ak as MindooDBAppConfiguredViewFilterRule, al as MindooDBAppConfiguredViewFormulaExpression, am as MindooDBAppConfiguredViewFormulaFilterDefinition, an as MindooDBAppConfiguredViewPreviewMode, ao as MindooDBAppConfiguredViewRuleFilterDefinition, ap as MindooDBAppConfiguredViewRuleMatchMode, aq as MindooDBAppConfiguredViewRuleOperator, ar as MindooDBAppConfiguredViewValueExpression, as as MindooDBAppCreateKeyInfo, at as MindooDBAppCreateViewInput, au as MindooDBAppCreateViewNavigatorInput, av as MindooDBAppDatabaseInfo, aw as MindooDBAppDefinition, ax as MindooDBAppDefinitionDatabase, ay as MindooDBAppDefinitionPermission, az as MindooDBAppDefinitionRegistrationPermission, aA as MindooDBAppDefinitionValidation, aB as MindooDBAppDirectoryApi, aC as MindooDBAppDirectoryEntry, aD as MindooDBAppDocumentApi, aE as MindooDBAppDocumentHeadCursorResult, aF as MindooDBAppDocumentHistoryEntry, aG as MindooDBAppDocumentListQuery, aH as MindooDBAppDocumentListResult, aI as MindooDBAppDocumentQuery, aJ as MindooDBAppDocumentRevisionId, aK as MindooDBAppDocumentScanPreset, aL as MindooDBAppDocumentSummary, aM as MindooDBAppDragApi, aN as MindooDBAppDragCancelReason, aO as MindooDBAppDragDropEvent, aP as MindooDBAppDragEffect, aQ as MindooDBAppDragHoverResult, aR as MindooDBAppDragOffer, aS as MindooDBAppDragOverEvent, aT as MindooDBAppDragPointer, aU as MindooDBAppDragProfile, aV as MindooDBAppEntryAttachmentRef, aW as MindooDBAppEntryProvenance, aX as MindooDBAppExtractDocumentTextInput, aY as MindooDBAppExtractDocumentTextResult, aZ as MindooDBAppExtractTextFormat, a_ as MindooDBAppExtractionSetup, a$ as MindooDBAppFulltextSetup, b0 as MindooDBAppHistoricalDocument, b1 as MindooDBAppHistoryQuery, b2 as MindooDBAppHostTheme, b3 as MindooDBAppIdentityApi, b4 as MindooDBAppInaccessibleDocument, b5 as MindooDBAppInaccessibleDocumentListQuery, b6 as MindooDBAppInaccessibleDocumentListResult, b7 as MindooDBAppJsonCounterIncrementPatch, b8 as MindooDBAppJsonListDeletePatch, b9 as MindooDBAppJsonListInsertPatch, ba as MindooDBAppJsonPatch, bb as MindooDBAppJsonSetPatch, bc as MindooDBAppJsonTextMarkPatch, bd as MindooDBAppJsonTextSplicePatch, be as MindooDBAppJsonTextUnmarkPatch, bf as MindooDBAppJsonUnsetPatch, bg as MindooDBAppLaunchContext, bh as MindooDBAppLiveQuerySubscription, bi as MindooDBAppMenuAnchor, bj as MindooDBAppMenuApi, bk as MindooDBAppMenuCommandItem, bl as MindooDBAppMenuDismissReason, bm as MindooDBAppMenuDismissedResult, bn as MindooDBAppMenuItem, bo as MindooDBAppMenuKind, bp as MindooDBAppMenuPlacement, bq as MindooDBAppMenuPointAnchor, br as MindooDBAppMenuRect, bs as MindooDBAppMenuRectAnchor, bt as MindooDBAppMenuSelectionResult, bu as MindooDBAppMenuSeparatorItem, bv as MindooDBAppNotificationSeverity, bw as MindooDBAppNotifyInput, bx as MindooDBAppNotifyResult, by as MindooDBAppProposeAppInput, bz as MindooDBAppProposeAppResult, bA as MindooDBAppQueryCoverage, bB as MindooDBAppQueryInclude, bC as MindooDBAppQueryIncludeCardinality, bD as MindooDBAppQueryIncludeSlots, bE as MindooDBAppQueryResult, bF as MindooDBAppQueryRow, bG as MindooDBAppQuerySortKey, bH as MindooDBAppQueryTextClause, bI as MindooDBAppReadableAttachmentStream, bJ as MindooDBAppRecipientOptions, bK as MindooDBAppResolvedViewDefinition, bL as MindooDBAppResolvedViewSource, bM as MindooDBAppRevisionPhase, bN as MindooDBAppRevisionVerification, bO as MindooDBAppRichTextBlockSpan, bP as MindooDBAppRichTextGetOptions, bQ as MindooDBAppRichTextImmutableString, bR as MindooDBAppRichTextMarkRange, bS as MindooDBAppRichTextMaterializeValue, bT as MindooDBAppRichTextPatch, bU as MindooDBAppRichTextScalar, bV as MindooDBAppRichTextSpliceStep, bW as MindooDBAppRichTextStep, bX as MindooDBAppRichTextStepPatch, bY as MindooDBAppRichTextTextSpan, bZ as MindooDBAppRuntime, b_ as MindooDBAppScanAttachmentOptions, b$ as MindooDBAppScanAttachmentResult, c0 as MindooDBAppScopedDocId, c1 as MindooDBAppScopedDocumentSummary, c2 as MindooDBAppSealIntent, c3 as MindooDBAppSealedChannelOpenInput, c4 as MindooDBAppSealedChannelOpenResult, c5 as MindooDBAppSealedChannelRequestInput, c6 as MindooDBAppSession, c7 as MindooDBAppShowMenuInput, c8 as MindooDBAppShowMenuResult, c9 as MindooDBAppSignPreview, ca as MindooDBAppSignPreviewScope, cb as MindooDBAppSignStatementInput, cc as MindooDBAppSignStatementResult, cd as MindooDBAppStorageApi, ce as MindooDBAppSummarySetup, cf as MindooDBAppTextCursorOptions, cg as MindooDBAppTextCursorPosition, ch as MindooDBAppTextCursorPositionsResult, ci as MindooDBAppTextCursorsResult, cj as MindooDBAppTextEdit, ck as MindooDBAppTextPatch, cl as MindooDBAppThemeMode, cm as MindooDBAppTimestampApi, cn as MindooDBAppTimestampInput, co as MindooDBAppTimestampProvider, cp as MindooDBAppTimestampResult, cq as MindooDBAppUiPreferences, cr as MindooDBAppUpdateDocumentInput, cs as MindooDBAppViewCursorDocumentListResult, ct as MindooDBAppViewCursorResult, cu as MindooDBAppViewEntry, cv as MindooDBAppViewEntryKind, cw as MindooDBAppViewNavigator, cx as MindooDBAppViewNavigatorExpansionState, cy as MindooDBAppViewNavigatorOpenOptions, cz as MindooDBAppViewNavigatorPageOptions, cA as MindooDBAppViewNavigatorPageResult, cB as MindooDBAppViewNavigatorRangeQuery, cC as MindooDBAppViewNavigatorSelectionState, cD as MindooDBAppViewUpdateStats, cE as MindooDBAppViewport, cF as MindooDBAppWellKnownDragType, cG as MindooDBAppWritableAttachmentStream, cH as resolveMindooDBAppDefinitionUrl, cI as validateMindooDBAppDefinition } from './types-BLyV6Ejy.js';
3
3
  export { M as MINDOODB_APP_BUNDLE_ARCHIVE_FILE_NAME, a as MINDOODB_APP_BUNDLE_MANIFEST_FILE_NAME, b as MINDOODB_APP_BUNDLE_MANIFEST_FORMAT, c as MINDOODB_APP_BUNDLE_MANIFEST_VERSION, d as MindooDBAppBundleArchive, e as MindooDBAppBundleFileEntry, f as MindooDBAppBundleHash, g as MindooDBAppBundleManifest, h as MindooDBAppBundleManifestValidation, i as buildMindooDBAppBundleContentHashInput, j as isMindooDBAppBundleHash, n as normalizeMindooDBAppBundlePath, v as validateMindooDBAppBundleManifest } from './appBundleManifest-B0xfpaXG.js';
4
4
  import { MindooDBAppBooleanExpression } from 'mindoodb-view-language';
5
5
  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';
6
6
  import { MindooDB, MindooQuerySortKey, MindooQueryOptions, MindooQueryResult } from 'mindoodb';
7
7
 
8
+ /**
9
+ * Typed document values that plain JSON cannot express.
10
+ *
11
+ * Each helper returns a tagged plain object such as
12
+ * `{ $mindoo: "counter", value: 0 }`. Use it anywhere a value is written:
13
+ * `documents.create({ set })`, `documents.update({ set })`, JSON patch `set`
14
+ * and `listInsert` values, also nested inside objects and arrays. Haven turns
15
+ * the tags into the matching collaborative type. Reads return plain JSON:
16
+ * atomic strings as strings, counters as numbers, timestamps as ISO 8601
17
+ * strings.
18
+ *
19
+ * The object key `$mindoo` is reserved; an object carrying it must be one of
20
+ * these values, otherwise the write is rejected.
21
+ */
22
+ /** Reserved object key that marks a typed value. */
23
+ declare const MINDOODB_APP_VALUE_TAG = "$mindoo";
24
+ /** A string that is replaced as a whole on concurrent writes. */
25
+ interface MindooDBAppAtomicValue {
26
+ $mindoo: "atomic";
27
+ value: string;
28
+ }
29
+ /** A number whose concurrent increments are summed on merge. */
30
+ interface MindooDBAppCounterValue {
31
+ $mindoo: "counter";
32
+ value: number;
33
+ }
34
+ /** A point in time: epoch milliseconds or an ISO 8601 date-time string. */
35
+ interface MindooDBAppTimestampValue {
36
+ $mindoo: "timestamp";
37
+ value: number | string;
38
+ }
39
+ type MindooDBAppTypedValue = MindooDBAppAtomicValue | MindooDBAppCounterValue | MindooDBAppTimestampValue;
40
+ declare const MindooDBAppValue: {
41
+ /**
42
+ * An atomic string for identifiers, status and enum values, URLs, hashes
43
+ * and stored text cursors. Plain strings are collaborative text, where two
44
+ * concurrent changes of `"open"` to `"closed"` and `"blocked"` can
45
+ * interleave into a mix of both words.
46
+ */
47
+ readonly atomic: (value: string) => MindooDBAppAtomicValue;
48
+ /**
49
+ * A collaborative counter with an initial value (a safe integer). Create it
50
+ * once, then change it only with `json.counterIncrement`: writing a new
51
+ * counter is an assignment that does not merge with concurrent increments.
52
+ */
53
+ readonly counter: (value?: number) => MindooDBAppCounterValue;
54
+ /** A timestamp from a `Date`, epoch milliseconds or an ISO 8601 string. */
55
+ readonly timestamp: (value: Date | number | string) => MindooDBAppTimestampValue;
56
+ /** Whether `value` is a tagged typed value (any kind). */
57
+ readonly isTyped: (value: unknown) => value is MindooDBAppTypedValue;
58
+ };
59
+
8
60
  /**
9
61
  * Resolves whether Haven can render a built-in preview for an attachment.
10
62
  *
@@ -366,4 +418,16 @@ declare function createMindooDBTextBuffer(options: CreateMindooDBTextBufferOptio
366
418
  */
367
419
  declare function queryDocuments(db: Pick<MindooDB, "query">, filter: MindooDBAppBooleanExpression | string, sortBy?: MindooQuerySortKey[], options?: MindooQueryOptions): Promise<MindooQueryResult>;
368
420
 
369
- export { type CreateMindooDBRichTextHandleOptions, type CreateMindooDBTextBufferOptions, DEFAULT_DRAG_LONG_PRESS_MS, DEFAULT_DRAG_POINTER_THRESHOLD_PX, DEFAULT_HAVEN_HOST_SHORTCUTS, type HavenStorageShimHandle, type InstallHavenStorageShimOptions, MINDOODB_APP_HOSTING_QUERY_PARAM, MINDOODB_APP_MAX_DRAG_PAYLOAD_BYTES, MINDOODB_APP_MAX_DRAG_PREVIEW_BYTES, MINDOODB_APP_MAX_DRAG_PREVIEW_EDGE, MINDOODB_APP_MAX_DRAG_TYPES, MINIMAL_DRAG_PREVIEW_PNG, MindooDBAppAttachmentPreviewMode, MindooDBAppBridge, MindooDBAppDatabase, MindooDBAppDocument, MindooDBAppDragBindSourceOptions, MindooDBAppDragInputError, MindooDBAppDragPreview, MindooDBAppDragStartInput, MindooDBAppDragStartResult, MindooDBAppHostShortcutAction, MindooDBAppHostShortcutBinding, MindooDBAppHostingMode, MindooDBAppRichTextSnapshot, MindooDBAppRichTextSpan, MindooDBRichTextHandle, type MindooDBRichTextHandleChangeListener, type MindooDBRichTextHandleFlushResult, MindooDBTextBuffer, type MindooDBTextBufferFlushResult, abbreviateCanonicalName, applyHostedDocumentOverscrollContain, bindDragSource, canPreviewAttachment, createMindooDBAppBridge, createMindooDBRichTextHandle, createMindooDBTextBuffer, expandAbbreviatedName, installHavenStorageShim, installHostShortcutCapture, isHostShortcutAction, isHostedBundleRuntime, isMindooDBAppDragType, matchHostShortcut, normalizeDragAccepts, normalizeDragPointerInput, normalizeDragStartInput, queryDocuments, readMindooDBAppHostingMode, releaseMindooDBAppBridgeSessions, sanitizeHostShortcutBindings, snapshotElementToPng };
421
+ /**
422
+ * Copy the parent's named key onto a chunk create when the caller did not
423
+ * choose a key. Person-bound documents pass `recipients` explicitly.
424
+ */
425
+ declare function inheritDocumentEncryption(parent: Pick<MindooDBAppDocument, "decryptionKeyId">, input: MindooDBAppCreateDocumentInput): MindooDBAppCreateDocumentInput;
426
+ /**
427
+ * Watch every Word chunk that belongs to `parentId`.
428
+ * The listener receives the chunk ids currently visible, including chunks
429
+ * another person inserted.
430
+ */
431
+ declare function watchWordChunks(database: MindooDBAppDatabase, parentId: string, listener: (docIds: string[]) => void): Promise<() => Promise<void>>;
432
+
433
+ export { type CreateMindooDBRichTextHandleOptions, type CreateMindooDBTextBufferOptions, DEFAULT_DRAG_LONG_PRESS_MS, DEFAULT_DRAG_POINTER_THRESHOLD_PX, DEFAULT_HAVEN_HOST_SHORTCUTS, type HavenStorageShimHandle, type InstallHavenStorageShimOptions, MINDOODB_APP_HOSTING_QUERY_PARAM, MINDOODB_APP_MAX_DRAG_PAYLOAD_BYTES, MINDOODB_APP_MAX_DRAG_PREVIEW_BYTES, MINDOODB_APP_MAX_DRAG_PREVIEW_EDGE, MINDOODB_APP_MAX_DRAG_TYPES, MINDOODB_APP_VALUE_TAG, MINIMAL_DRAG_PREVIEW_PNG, type MindooDBAppAtomicValue, MindooDBAppAttachmentPreviewMode, MindooDBAppBridge, type MindooDBAppCounterValue, MindooDBAppCreateDocumentInput, MindooDBAppDatabase, MindooDBAppDocument, MindooDBAppDragBindSourceOptions, MindooDBAppDragInputError, MindooDBAppDragPreview, MindooDBAppDragStartInput, MindooDBAppDragStartResult, MindooDBAppHostShortcutAction, MindooDBAppHostShortcutBinding, MindooDBAppHostingMode, MindooDBAppRichTextSnapshot, MindooDBAppRichTextSpan, type MindooDBAppTimestampValue, type MindooDBAppTypedValue, MindooDBAppValue, MindooDBRichTextHandle, type MindooDBRichTextHandleChangeListener, type MindooDBRichTextHandleFlushResult, MindooDBTextBuffer, type MindooDBTextBufferFlushResult, abbreviateCanonicalName, applyHostedDocumentOverscrollContain, bindDragSource, canPreviewAttachment, createMindooDBAppBridge, createMindooDBRichTextHandle, createMindooDBTextBuffer, expandAbbreviatedName, inheritDocumentEncryption, installHavenStorageShim, installHostShortcutCapture, isHostShortcutAction, isHostedBundleRuntime, isMindooDBAppDragType, matchHostShortcut, normalizeDragAccepts, normalizeDragPointerInput, normalizeDragStartInput, queryDocuments, readMindooDBAppHostingMode, releaseMindooDBAppBridgeSessions, sanitizeHostShortcutBindings, snapshotElementToPng, watchWordChunks };
package/dist/index.js CHANGED
@@ -6,8 +6,10 @@ import {
6
6
  MINDOODB_APP_MAX_DRAG_PREVIEW_BYTES,
7
7
  MINDOODB_APP_MAX_DRAG_PREVIEW_EDGE,
8
8
  MINDOODB_APP_MAX_DRAG_TYPES,
9
+ MINDOODB_APP_VALUE_TAG,
9
10
  MINIMAL_DRAG_PREVIEW_PNG,
10
11
  MindooDBAppDragInputError,
12
+ MindooDBAppValue,
11
13
  applyHostedDocumentOverscrollContain,
12
14
  bindDragSource,
13
15
  createMindooDBAppBridge,
@@ -21,7 +23,7 @@ import {
21
23
  releaseMindooDBAppBridgeSessions,
22
24
  sanitizeHostShortcutBindings,
23
25
  snapshotElementToPng
24
- } from "./chunk-TPYDERAK.js";
26
+ } from "./chunk-R76XXRJ6.js";
25
27
  import {
26
28
  MINDOODB_APP_BUNDLE_ARCHIVE_FILE_NAME,
27
29
  MINDOODB_APP_BUNDLE_MANIFEST_FILE_NAME,
@@ -1031,6 +1033,24 @@ async function queryDocuments(db, filter, sortBy, options) {
1031
1033
  const expression = typeof filter === "string" ? parseMindooDBFormulaBooleanExpression(filter) : filter;
1032
1034
  return db.query({ filter: expression, sortBy }, options);
1033
1035
  }
1036
+
1037
+ // src/wordChunks.ts
1038
+ function inheritDocumentEncryption(parent, input) {
1039
+ if (input.decryptionKeyId || input.recipients) return input;
1040
+ if (!parent.decryptionKeyId) return input;
1041
+ return { ...input, decryptionKeyId: parent.decryptionKeyId };
1042
+ }
1043
+ async function watchWordChunks(database, parentId, listener) {
1044
+ const subscription = await database.documents.liveQuery(
1045
+ {
1046
+ filter: `v.and(v.eq(v.field("type"), "wordChunk"), v.eq(v.field("parentId"), ${JSON.stringify(parentId)}))`
1047
+ },
1048
+ (result) => {
1049
+ listener(result.rows.map((row) => row.docId));
1050
+ }
1051
+ );
1052
+ return () => subscription.dispose();
1053
+ }
1034
1054
  export {
1035
1055
  DEFAULT_DRAG_LONG_PRESS_MS,
1036
1056
  DEFAULT_DRAG_POINTER_THRESHOLD_PX,
@@ -1050,9 +1070,11 @@ export {
1050
1070
  MINDOODB_APP_MAX_DRAG_PREVIEW_EDGE,
1051
1071
  MINDOODB_APP_MAX_DRAG_TYPES,
1052
1072
  MINDOODB_APP_SEAL_SIGNING_DOMAIN,
1073
+ MINDOODB_APP_VALUE_TAG,
1053
1074
  MINDOODB_APP_WELL_KNOWN_DRAG_TYPES,
1054
1075
  MINIMAL_DRAG_PREVIEW_PNG,
1055
1076
  MindooDBAppDragInputError,
1077
+ MindooDBAppValue,
1056
1078
  MindooDBRichTextHandle,
1057
1079
  MindooDBTextBuffer,
1058
1080
  abbreviateCanonicalName,
@@ -1065,6 +1087,7 @@ export {
1065
1087
  createMindooDBTextBuffer,
1066
1088
  createViewLanguage,
1067
1089
  expandAbbreviatedName,
1090
+ inheritDocumentEncryption,
1068
1091
  installHavenStorageShim,
1069
1092
  installHostShortcutCapture,
1070
1093
  isHostShortcutAction,
@@ -1083,5 +1106,6 @@ export {
1083
1106
  sanitizeHostShortcutBindings,
1084
1107
  snapshotElementToPng,
1085
1108
  validateMindooDBAppBundleManifest,
1086
- validateMindooDBAppDefinition
1109
+ validateMindooDBAppDefinition,
1110
+ watchWordChunks
1087
1111
  };