mindoodb-app-sdk 0.0.19 → 0.0.26

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.
@@ -1,780 +0,0 @@
1
- import { MindooDBAppBooleanExpression, MindooDBAppExpression, MindooDBAppViewSortDirection, MindooDBAppViewTotalMode, MindooDBAppViewDefinition } from 'mindoodb-view-language';
2
-
3
- /** Launch target used by the Haven when opening an app. */
4
- type MindooDBAppRuntime = "iframe" | "window";
5
- /** Theme mode currently active in the Haven host UI. */
6
- type MindooDBAppThemeMode = "light" | "dark";
7
- /** Host theme snapshot exposed to running apps. */
8
- interface MindooDBAppHostTheme {
9
- mode: MindooDBAppThemeMode;
10
- preset: string;
11
- }
12
- /** Iframe viewport dimensions reported by the Haven host. */
13
- interface MindooDBAppViewport {
14
- width: number;
15
- height: number;
16
- }
17
- /** Host-controlled UI preferences exposed to embedded apps. */
18
- interface MindooDBAppUiPreferences {
19
- iosMultitaskingOptimized: boolean;
20
- }
21
- /** Saved categorization mode for Haven-managed view mappings delivered at launch time. */
22
- type MindooDBAppConfiguredViewCategorizationStyle = "document_then_category" | "category_then_document";
23
- /** Preferred preview layout for a Haven-managed view mapping. */
24
- type MindooDBAppConfiguredViewPreviewMode = "tree" | "table";
25
- /** Column role used by Haven-managed view mappings. */
26
- type MindooDBAppConfiguredViewColumnRole = "category" | "sort" | "display" | "total";
27
- /** Filter authoring mode used by Haven-managed view mappings. */
28
- type MindooDBAppConfiguredViewFilterMode = "rules" | "formula";
29
- /** Rule match mode used by visual-rule filters. */
30
- type MindooDBAppConfiguredViewRuleMatchMode = "all" | "any";
31
- /** Visual-rule operator supported by Haven-managed view mappings. */
32
- type MindooDBAppConfiguredViewRuleOperator = "eq" | "neq" | "contains" | "notContains" | "gt" | "gte" | "lt" | "lte" | "exists" | "notExists";
33
- /** Field/formula authoring modes for Haven-managed view columns. */
34
- type MindooDBAppConfiguredViewExpressionMode = "field" | "formula";
35
- /** One visual filter rule inside a Haven-managed view mapping. */
36
- interface MindooDBAppConfiguredViewFilterRule {
37
- id: string;
38
- field: string;
39
- operator: MindooDBAppConfiguredViewRuleOperator;
40
- value?: string;
41
- }
42
- /** Field-based value expression used by Haven-managed view mappings. */
43
- interface MindooDBAppConfiguredViewFieldExpression {
44
- mode: "field";
45
- field: string;
46
- }
47
- /** Formula-based value expression used by Haven-managed view mappings. */
48
- interface MindooDBAppConfiguredViewFormulaExpression {
49
- mode: "formula";
50
- expression: MindooDBAppExpression;
51
- }
52
- /** Column expression authoring shape used by Haven-managed view mappings. */
53
- type MindooDBAppConfiguredViewValueExpression = MindooDBAppConfiguredViewFieldExpression | MindooDBAppConfiguredViewFormulaExpression;
54
- /** Rule-based filter stored by Haven for app-owned view mappings. */
55
- interface MindooDBAppConfiguredViewRuleFilterDefinition {
56
- mode: "rules";
57
- match: MindooDBAppConfiguredViewRuleMatchMode;
58
- rules: MindooDBAppConfiguredViewFilterRule[];
59
- }
60
- /** Formula-based filter stored by Haven for app-owned view mappings. */
61
- interface MindooDBAppConfiguredViewFormulaFilterDefinition {
62
- mode: "formula";
63
- expression: MindooDBAppBooleanExpression;
64
- }
65
- /** Full filter authoring shape stored for Haven-managed app view mappings. */
66
- type MindooDBAppConfiguredViewFilterDefinition = MindooDBAppConfiguredViewRuleFilterDefinition | MindooDBAppConfiguredViewFormulaFilterDefinition;
67
- /** Column definition stored for a Haven-managed app view mapping. */
68
- interface MindooDBAppConfiguredViewColumn {
69
- id: string;
70
- title: string;
71
- name: string;
72
- role: MindooDBAppConfiguredViewColumnRole;
73
- expression: MindooDBAppConfiguredViewValueExpression;
74
- sorting: MindooDBAppViewSortDirection;
75
- totalMode: MindooDBAppViewTotalMode;
76
- hidden: boolean;
77
- }
78
- /** One resolved source binding for an app-owned Haven view mapping. */
79
- interface MindooDBAppResolvedViewSource {
80
- origin: string;
81
- databaseId: string;
82
- title: string;
83
- targetMode: "local" | "server";
84
- connectionId?: string;
85
- tenantId: string;
86
- databaseName: string;
87
- }
88
- /** Full Haven-managed view mapping delivered to the running application at launch time. */
89
- interface MindooDBAppResolvedViewDefinition {
90
- id: string;
91
- description?: string;
92
- categorizationStyle: MindooDBAppConfiguredViewCategorizationStyle;
93
- previewMode: MindooDBAppConfiguredViewPreviewMode;
94
- sources: MindooDBAppResolvedViewSource[];
95
- filter: MindooDBAppConfiguredViewFilterDefinition;
96
- columns: MindooDBAppConfiguredViewColumn[];
97
- }
98
- /** Permission/capability flags exposed for a database binding inside the app session. */
99
- type MindooDBAppCapability = "read" | "create" | "update" | "delete" | "history" | "attachments" | "views";
100
- /** Metadata about the current app launch supplied by the Haven host. */
101
- interface MindooDBAppLaunchContext {
102
- appId: string;
103
- appInstanceId: string;
104
- appVersion?: string;
105
- launchId: string;
106
- runtime: MindooDBAppRuntime;
107
- theme: MindooDBAppHostTheme;
108
- viewport: MindooDBAppViewport | null;
109
- uiPreferences: MindooDBAppUiPreferences;
110
- tenantId?: string;
111
- preferredDatabaseId?: string;
112
- /**
113
- * Epoch-millisecond cutoff when the host opened app databases in time travel
114
- * read-only mode. Absent/null means the app is looking at live data.
115
- */
116
- timeTravelDate?: number | null;
117
- user: {
118
- id: string;
119
- username: string;
120
- };
121
- launchParameters: Record<string, string>;
122
- databases: MindooDBAppDatabaseInfo[];
123
- views: MindooDBAppResolvedViewDefinition[];
124
- }
125
- /** Attachment metadata returned by the attachment APIs. */
126
- interface MindooDBAppAttachmentInfo {
127
- attachmentId: string;
128
- fileName: string;
129
- mimeType: string;
130
- size: number;
131
- }
132
- /** Preview modes supported by the Haven-hosted attachment preview dialog. */
133
- type MindooDBAppAttachmentPreviewMode = "image" | "pdf" | "text" | "markdown" | "docx" | "pptx" | "spreadsheet" | "video" | "audio";
134
- /** Optional parameters for opening an attachment preview in Haven. */
135
- interface MindooDBAppAttachmentPreviewOptions {
136
- /** Historical snapshot timestamp previously obtained from `documents.history.getAtTimestamp()`. */
137
- timestamp?: number;
138
- /** Stable revision id previously obtained from `documents.listHistory()`. */
139
- revisionId?: MindooDBAppDocumentRevisionId;
140
- }
141
- type MindooDBAppDocumentScanPreset = "auto" | "a4-portrait" | "a4-landscape" | "letter-portrait" | "letter-landscape";
142
- interface MindooDBAppScanAttachmentOptions {
143
- defaultFileName?: string;
144
- preset?: MindooDBAppDocumentScanPreset;
145
- mimeType?: "image/jpeg" | "image/png" | "application/pdf";
146
- }
147
- interface MindooDBAppScanAttachmentResult {
148
- ok: boolean;
149
- attachment?: MindooDBAppAttachmentInfo | null;
150
- }
151
- /** Resolved Haven preview session prepared for opening in a separate tab or window. */
152
- interface MindooDBAppAttachmentPreviewSession {
153
- sessionId: string;
154
- previewUrl: string;
155
- }
156
- /** Database entry visible to the app during launch and database listing. */
157
- interface MindooDBAppDatabaseInfo {
158
- id: string;
159
- title: string;
160
- role?: string;
161
- capabilities: MindooDBAppCapability[];
162
- }
163
- /** Lightweight document row returned by list operations. */
164
- interface MindooDBAppDocumentSummary {
165
- id: string;
166
- data?: Record<string, unknown>;
167
- attachmentCount?: number;
168
- createdAt?: string;
169
- updatedAt?: string;
170
- identityLabel?: string;
171
- publicKeyFingerprint?: string;
172
- isDeleted?: boolean;
173
- }
174
- /** Fully loaded document returned by `get()`, `create()`, or `update()`. */
175
- interface MindooDBAppDocument {
176
- id: string;
177
- data: Record<string, unknown>;
178
- /** Current Automerge heads for causal text edit reconciliation. */
179
- heads?: string[];
180
- attachments?: MindooDBAppAttachmentInfo[];
181
- createdAt?: string;
182
- updatedAt?: string;
183
- }
184
- /** Opaque persisted id for a document revision in the MindooDB DAG. */
185
- type MindooDBAppDocumentRevisionId = string;
186
- /** One entry in the document history timeline. */
187
- interface MindooDBAppDocumentHistoryEntry {
188
- revisionId: MindooDBAppDocumentRevisionId;
189
- timestamp: number;
190
- heads?: string[];
191
- publicKey: string;
192
- publicKeyFingerprint?: string;
193
- identityLabel?: string;
194
- isDeleted: boolean;
195
- isCurrent: boolean;
196
- summary?: string;
197
- }
198
- /** Historical snapshot returned for a document at a specific timestamp. */
199
- interface MindooDBAppHistoricalDocument {
200
- id: string;
201
- revisionId?: MindooDBAppDocumentRevisionId;
202
- timestamp: number;
203
- heads?: string[];
204
- state: "missing" | "deleted" | "exists";
205
- data: Record<string, unknown> | null;
206
- attachments?: MindooDBAppAttachmentInfo[];
207
- attachmentSnapshotRevisionId?: MindooDBAppDocumentRevisionId | null;
208
- }
209
- /** Query options for paging through changefeed-backed document listings in a database. */
210
- interface MindooDBAppDocumentListQuery {
211
- cursor?: string | null;
212
- limit?: number;
213
- skip?: number;
214
- status?: "all" | "existing" | "deleted";
215
- metadataOnly?: boolean;
216
- fields?: string[];
217
- filter?: Record<string, unknown>;
218
- }
219
- /** Paged result returned by `documents.list()`. */
220
- interface MindooDBAppDocumentListResult {
221
- items: MindooDBAppDocumentSummary[];
222
- nextCursor: string | null;
223
- }
224
- /** Latest known changefeed cursor for a database. */
225
- interface MindooDBAppDocumentHeadCursorResult {
226
- cursor: string | null;
227
- }
228
- /** Opaque cursor representing the DB state reflected in a bridge-built view snapshot. */
229
- interface MindooDBAppViewCursorResult {
230
- viewCursor: string | null;
231
- }
232
- /** Lightweight document row returned by multi-source view-cursor delta queries. */
233
- interface MindooDBAppScopedDocumentSummary extends MindooDBAppDocumentSummary {
234
- origin: string;
235
- databaseId: string;
236
- }
237
- /** Result returned when querying document changes since a view snapshot cursor. */
238
- interface MindooDBAppViewCursorDocumentListResult {
239
- items: MindooDBAppScopedDocumentSummary[];
240
- nextCursor: string | null;
241
- }
242
- /**
243
- * Payload used when creating a new document.
244
- *
245
- * `set` becomes the initial top-level document state, mirroring the update
246
- * API's field-assignment language while still creating a brand-new document.
247
- */
248
- interface MindooDBAppCreateDocumentInput {
249
- set: Record<string, unknown>;
250
- /** Optional named document key. Defaults to `"default"` when omitted. */
251
- decryptionKeyId?: string;
252
- /**
253
- * Optional caller-provided document id. When omitted, MindooDB generates a
254
- * UUID7. When provided, the id must match `^[A-Za-z][A-Za-z0-9_]*$`: the
255
- * first character is an ASCII letter and subsequent characters may be ASCII
256
- * letters, ASCII digits, or `_`.
257
- *
258
- * If a document with this id already exists locally, MindooDB returns the
259
- * existing document instead of creating a new one (idempotent create), and
260
- * the values in `set` are NOT applied. Caller-provided ids are useful for
261
- * loading a known well-known document directly without first building a
262
- * view, and for migrations that want to preserve external ids.
263
- *
264
- * Documents created with the same caller-provided id on independent replicas
265
- * share Automerge ancestry, so subsequent edits on either replica still
266
- * merge correctly when the replicas sync.
267
- */
268
- id?: string;
269
- }
270
- interface MindooDBAppTextEdit {
271
- index: number;
272
- deleteCount: number;
273
- insert?: string;
274
- }
275
- interface MindooDBAppTextPatch {
276
- path: Array<string | number>;
277
- baseHeads?: string[];
278
- edits: MindooDBAppTextEdit[];
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
- }
317
- /**
318
- * Sets the value at `path` inside the document payload.
319
- *
320
- * Creates the field if it does not exist, or replaces the existing value.
321
- * `path` addresses a property using object keys and list indices, for example
322
- * `["workbook", "worksheetsById", "ws-1", "title"]`.
323
- */
324
- interface MindooDBAppJsonSetPatch {
325
- path: Array<string | number>;
326
- value: unknown;
327
- }
328
- /**
329
- * Removes the value at `path` from the document payload.
330
- *
331
- * For object properties this deletes the key; for list entries the host
332
- * decides whether unset is supported and may reject the patch.
333
- */
334
- interface MindooDBAppJsonUnsetPatch {
335
- path: Array<string | number>;
336
- }
337
- /**
338
- * Inserts one or more values into the list located at `path`.
339
- *
340
- * `index` is the insertion point within the current list, where `0` prepends
341
- * and `list.length` appends. Existing entries at or after `index` shift right.
342
- */
343
- interface MindooDBAppJsonListInsertPatch {
344
- path: Array<string | number>;
345
- index: number;
346
- values: unknown[];
347
- }
348
- /**
349
- * Deletes a contiguous run of entries from the list located at `path`.
350
- *
351
- * Removes `deleteCount` entries starting at `index`. Subsequent entries shift
352
- * left to fill the gap.
353
- */
354
- interface MindooDBAppJsonListDeletePatch {
355
- path: Array<string | number>;
356
- index: number;
357
- deleteCount: number;
358
- }
359
- interface MindooDBAppJsonPatch {
360
- /**
361
- * Automerge heads of the document snapshot this JSON patch was authored
362
- * against. Hosts can use this to apply order-sensitive edits at the original
363
- * causal version and merge them with concurrent changes.
364
- */
365
- baseHeads?: string[];
366
- set?: MindooDBAppJsonSetPatch[];
367
- unset?: MindooDBAppJsonUnsetPatch[];
368
- listInsert?: MindooDBAppJsonListInsertPatch[];
369
- listDelete?: MindooDBAppJsonListDeletePatch[];
370
- }
371
- /**
372
- * Sparse patch payload used when updating an existing document.
373
- *
374
- * Prefer targeted `set` / `unset` operations over whole-document rewrites so
375
- * MindooDB can preserve more meaningful change history and Automerge can merge
376
- * smaller, more intentional updates.
377
- */
378
- interface MindooDBAppUpdateDocumentInput {
379
- /** Top-level fields to assign on the document. */
380
- set?: Record<string, unknown>;
381
- /** Top-level fields to remove from the document entirely. */
382
- unset?: string[];
383
- /** Granular JSON operations to apply at document paths. */
384
- json?: MindooDBAppJsonPatch;
385
- /** Granular text edits to apply at document paths. */
386
- text?: MindooDBAppTextPatch[];
387
- /** Rich-text span snapshots to apply at document paths. */
388
- richText?: MindooDBAppRichTextPatch[];
389
- }
390
- /** Query used for history lookups at a specific timestamp. */
391
- interface MindooDBAppHistoryQuery {
392
- timestamp: number;
393
- }
394
- /** Optional parameters for establishing the app bridge connection. */
395
- interface MindooDBAppBridgeConnectOptions {
396
- launchId?: string;
397
- targetOrigin?: string;
398
- connectTimeoutMs?: number;
399
- }
400
- /** Initial postMessage handshake sent from the app to the Haven. */
401
- interface MindooDBAppBridgeConnectMessage {
402
- protocol: "mindoodb-app-bridge";
403
- type: "mindoodb-app:connect";
404
- launchId: string;
405
- }
406
- /** Handshake acknowledgement returned by the Haven host. */
407
- interface MindooDBAppBridgeConnectedMessage {
408
- protocol: "mindoodb-app-bridge";
409
- type: "mindoodb-app:connected";
410
- }
411
- /** Handshake error returned when the Haven host rejects a launch. */
412
- interface MindooDBAppBridgeHandshakeErrorMessage {
413
- protocol: "mindoodb-app-bridge";
414
- type: "mindoodb-app:error";
415
- error: string;
416
- }
417
- /** Structured error payload transported over bridge RPC or stream messages. */
418
- interface MindooDBAppBridgeErrorPayload {
419
- code: string;
420
- message: string;
421
- }
422
- /** Request envelope used by the port-based RPC transport. */
423
- interface MindooDBAppBridgeRpcRequest<TParams = unknown> {
424
- protocol: "mindoodb-app-bridge";
425
- kind: "request";
426
- id: string;
427
- method: string;
428
- params: TParams;
429
- }
430
- /** Successful RPC response envelope. */
431
- interface MindooDBAppBridgeRpcSuccess<TResult = unknown> {
432
- protocol: "mindoodb-app-bridge";
433
- kind: "success";
434
- id: string;
435
- result: TResult;
436
- }
437
- /** Failed RPC response envelope. */
438
- interface MindooDBAppBridgeRpcError {
439
- protocol: "mindoodb-app-bridge";
440
- kind: "error";
441
- id: string;
442
- error: MindooDBAppBridgeErrorPayload;
443
- }
444
- /** Union of all RPC-level bridge messages. */
445
- type MindooDBAppBridgeRpcMessage = MindooDBAppBridgeRpcRequest | MindooDBAppBridgeRpcSuccess | MindooDBAppBridgeRpcError;
446
- /** Result returned when the host opens a streamed attachment channel. */
447
- interface MindooDBAppBridgeStreamOpenResult {
448
- streamId: string;
449
- }
450
- /** Request asking the host for the next chunk on a read stream. */
451
- interface MindooDBAppBridgeStreamReadRequest {
452
- protocol: "mindoodb-app-bridge";
453
- kind: "stream-read";
454
- streamId: string;
455
- }
456
- /** Request sending one chunk over a write stream. */
457
- interface MindooDBAppBridgeStreamWriteRequest {
458
- protocol: "mindoodb-app-bridge";
459
- kind: "stream-write";
460
- streamId: string;
461
- chunk: ArrayBuffer;
462
- }
463
- /** Request closing a stream gracefully. */
464
- interface MindooDBAppBridgeStreamCloseRequest {
465
- protocol: "mindoodb-app-bridge";
466
- kind: "stream-close";
467
- streamId: string;
468
- }
469
- /** Request aborting a stream due to cancellation or failure. */
470
- interface MindooDBAppBridgeStreamAbortRequest {
471
- protocol: "mindoodb-app-bridge";
472
- kind: "stream-abort";
473
- streamId: string;
474
- }
475
- /** Streamed attachment payload delivered over the message port. */
476
- interface MindooDBAppAttachmentChunk {
477
- protocol: "mindoodb-app-bridge";
478
- kind: "stream-chunk";
479
- streamId: string;
480
- chunk?: ArrayBuffer;
481
- done: boolean;
482
- }
483
- /** Host acknowledgement for a write/close/abort stream request. */
484
- interface MindooDBAppBridgeStreamAck {
485
- protocol: "mindoodb-app-bridge";
486
- kind: "stream-ack";
487
- streamId: string;
488
- }
489
- /** Stream-level error message. */
490
- interface MindooDBAppBridgeStreamError {
491
- protocol: "mindoodb-app-bridge";
492
- kind: "stream-error";
493
- streamId: string;
494
- error: MindooDBAppBridgeErrorPayload;
495
- }
496
- /** Union of all non-RPC stream transport messages. */
497
- type MindooDBAppBridgeStreamMessage = MindooDBAppBridgeStreamReadRequest | MindooDBAppBridgeStreamWriteRequest | MindooDBAppBridgeStreamCloseRequest | MindooDBAppBridgeStreamAbortRequest | MindooDBAppAttachmentChunk | MindooDBAppBridgeStreamAck | MindooDBAppBridgeStreamError;
498
- /** Host-pushed event emitted when the Haven theme changes. */
499
- interface MindooDBAppBridgeThemeChangedMessage {
500
- protocol: "mindoodb-app-bridge";
501
- kind: "theme-changed";
502
- theme: MindooDBAppHostTheme;
503
- }
504
- /** Host-pushed event emitted when the Haven iframe viewport changes. */
505
- interface MindooDBAppBridgeViewportChangedMessage {
506
- protocol: "mindoodb-app-bridge";
507
- kind: "viewport-changed";
508
- viewport: MindooDBAppViewport;
509
- }
510
- /** Host-pushed event emitted when host-controlled UI preferences change. */
511
- interface MindooDBAppBridgeUiPreferencesChangedMessage {
512
- protocol: "mindoodb-app-bridge";
513
- kind: "ui-preferences-changed";
514
- uiPreferences: MindooDBAppUiPreferences;
515
- }
516
- /** Any message that can travel across the dedicated bridge MessagePort. */
517
- type MindooDBAppBridgePortMessage = MindooDBAppBridgeRpcMessage | MindooDBAppBridgeStreamMessage | MindooDBAppBridgeThemeChangedMessage | MindooDBAppBridgeViewportChangedMessage | MindooDBAppBridgeUiPreferencesChangedMessage;
518
- /** Placement hint for a host-rendered overlay menu. */
519
- type MindooDBAppMenuPlacement = "auto" | "bottom-start" | "bottom-end" | "top-start" | "top-end" | "right-start" | "left-start";
520
- /** Semantic hint allowing Haven to tune menu behavior or styling. */
521
- type MindooDBAppMenuKind = "context" | "dropdown" | "picker";
522
- /** Rectangle expressed in app-viewport coordinates. */
523
- interface MindooDBAppMenuRect {
524
- left: number;
525
- top: number;
526
- width: number;
527
- height: number;
528
- }
529
- /** Point anchor used for context menus or other click-triggered overlays. */
530
- interface MindooDBAppMenuPointAnchor {
531
- type: "point";
532
- x: number;
533
- y: number;
534
- }
535
- /** Rectangle anchor used for toolbar menus or picker buttons. */
536
- interface MindooDBAppMenuRectAnchor {
537
- type: "rect";
538
- rect: MindooDBAppMenuRect;
539
- }
540
- /** Anchor describing where the host should position the rendered menu. */
541
- type MindooDBAppMenuAnchor = MindooDBAppMenuPointAnchor | MindooDBAppMenuRectAnchor;
542
- /** Visual separator between menu groups. */
543
- interface MindooDBAppMenuSeparatorItem {
544
- separator: true;
545
- }
546
- /** One actionable entry in a structured host-rendered menu. */
547
- interface MindooDBAppMenuCommandItem {
548
- id: string;
549
- label: string;
550
- enabled?: boolean;
551
- destructive?: boolean;
552
- checked?: boolean;
553
- items?: MindooDBAppMenuItem[];
554
- }
555
- /** Structured menu item transported over the app bridge. */
556
- type MindooDBAppMenuItem = MindooDBAppMenuSeparatorItem | MindooDBAppMenuCommandItem;
557
- /** Request payload for a host-rendered overlay menu. */
558
- interface MindooDBAppShowMenuInput {
559
- anchor: MindooDBAppMenuAnchor;
560
- placement?: MindooDBAppMenuPlacement;
561
- kind?: MindooDBAppMenuKind;
562
- items: MindooDBAppMenuItem[];
563
- dismissOnOutsideClick?: boolean;
564
- dismissOnEscape?: boolean;
565
- dismissOnViewportChange?: boolean;
566
- }
567
- /** Reason why a host-rendered menu was dismissed without a selection. */
568
- type MindooDBAppMenuDismissReason = "outside_click" | "escape" | "app_blur" | "viewport_change" | "hide" | "replaced";
569
- /** Successful selection result returned from a host-rendered menu. */
570
- interface MindooDBAppMenuSelectionResult {
571
- action: "selected";
572
- itemId: string;
573
- }
574
- /** Dismissal result returned from a host-rendered menu. */
575
- interface MindooDBAppMenuDismissedResult {
576
- action: "dismissed";
577
- reason: MindooDBAppMenuDismissReason;
578
- }
579
- /** Result returned when Haven closes or resolves a host-rendered menu. */
580
- type MindooDBAppShowMenuResult = MindooDBAppMenuSelectionResult | MindooDBAppMenuDismissedResult;
581
- /** Overlay menu operations exposed by the host session. */
582
- interface MindooDBAppMenuApi {
583
- show(input: MindooDBAppShowMenuInput): Promise<MindooDBAppShowMenuResult>;
584
- hide(): Promise<void>;
585
- }
586
- /** Pull-based read stream for document attachments. */
587
- interface MindooDBAppReadableAttachmentStream {
588
- read(): Promise<Uint8Array | null>;
589
- close(): Promise<void>;
590
- }
591
- /** Push-based write stream for document attachments. */
592
- interface MindooDBAppWritableAttachmentStream {
593
- write(chunk: Uint8Array): Promise<void>;
594
- close(): Promise<void>;
595
- abort(): Promise<void>;
596
- }
597
- /** Document operations exposed by an opened database handle. */
598
- interface MindooDBAppDocumentApi {
599
- list(query?: MindooDBAppDocumentListQuery): Promise<MindooDBAppDocumentListResult>;
600
- getHeadCursor(): Promise<MindooDBAppDocumentHeadCursorResult>;
601
- get(docId: string): Promise<MindooDBAppDocument | null>;
602
- getRichText(docId: string, path: Array<string | number>, options?: MindooDBAppRichTextGetOptions): Promise<MindooDBAppRichTextSnapshot>;
603
- create(input: MindooDBAppCreateDocumentInput): Promise<MindooDBAppDocument>;
604
- update(docId: string, patch: MindooDBAppUpdateDocumentInput): Promise<MindooDBAppDocument>;
605
- delete(docId: string): Promise<{
606
- ok: true;
607
- }>;
608
- undelete(docId: string): Promise<{
609
- ok: true;
610
- }>;
611
- listHistory(docId: string): Promise<MindooDBAppDocumentHistoryEntry[]>;
612
- getAtTimestamp(docId: string, timestamp: number): Promise<MindooDBAppHistoricalDocument>;
613
- getAtRevision(docId: string, revisionId: MindooDBAppDocumentRevisionId): Promise<MindooDBAppHistoricalDocument>;
614
- }
615
- type MindooDBAppViewEntryKind = "category" | "document";
616
- /** Unique document identity within a multi-source view. */
617
- interface MindooDBAppScopedDocId {
618
- origin: string;
619
- docId: string;
620
- }
621
- /** Serialized view entry returned by the navigator APIs. */
622
- interface MindooDBAppViewEntry {
623
- /** Unique occurrence key within the current navigator session. */
624
- key: string;
625
- kind: MindooDBAppViewEntryKind;
626
- origin: string;
627
- docId: string | null;
628
- level: number;
629
- parentKey: string | null;
630
- categoryPath: unknown[];
631
- categoryValue: unknown | null;
632
- columnValues: Record<string, unknown>;
633
- childCount?: number;
634
- descendantDocumentCount?: number;
635
- descendantCount?: number;
636
- descendantCategoryCount?: number;
637
- childCategoryCount?: number;
638
- childDocumentCount?: number;
639
- siblingCount?: number;
640
- /** Stable continuation token for the current occurrence. */
641
- position: string | null;
642
- expanded: boolean;
643
- selected: boolean;
644
- isVisible: boolean;
645
- }
646
- /** Options that shape which subtree and entry kinds a navigator exposes. */
647
- interface MindooDBAppViewNavigatorOpenOptions {
648
- includeCategories?: boolean;
649
- includeDocuments?: boolean;
650
- hideEmptyCategories?: boolean;
651
- rootCategoryPath?: unknown[];
652
- rootEntryKey?: string;
653
- }
654
- /** Input used when creating a dynamic view and immediately opening a navigator. */
655
- interface MindooDBAppCreateViewNavigatorInput {
656
- databaseIds: string[];
657
- definition: MindooDBAppViewDefinition;
658
- categorizationStyle?: MindooDBAppConfiguredViewCategorizationStyle;
659
- options?: MindooDBAppViewNavigatorOpenOptions;
660
- }
661
- /** @deprecated Use `MindooDBAppCreateViewNavigatorInput`. */
662
- type MindooDBAppCreateViewInput = MindooDBAppCreateViewNavigatorInput;
663
- /** Range query options for key and key-range lookups within a category. */
664
- interface MindooDBAppViewNavigatorRangeQuery {
665
- startKey?: unknown;
666
- endKey?: unknown;
667
- descending?: boolean;
668
- exact?: boolean;
669
- }
670
- /** Options for batched navigator reads. */
671
- interface MindooDBAppViewNavigatorPageOptions {
672
- limit?: number;
673
- selectedOnly?: boolean;
674
- startPosition?: string | null;
675
- }
676
- /** Paged batch of navigator entries. */
677
- interface MindooDBAppViewNavigatorPageResult {
678
- entries: MindooDBAppViewEntry[];
679
- nextPosition: string | null;
680
- hasMore: boolean;
681
- }
682
- /** Serializable selection state for restoring a navigator session. */
683
- interface MindooDBAppViewNavigatorSelectionState {
684
- selectAllByDefault: boolean;
685
- entryKeys: string[];
686
- }
687
- /** Serializable expansion state for restoring a navigator session. */
688
- interface MindooDBAppViewNavigatorExpansionState {
689
- expandAllByDefault: boolean;
690
- expandLevel: number;
691
- entryKeys: string[];
692
- }
693
- /** Stateful view navigator that closely mirrors the core VirtualViewNavigator. */
694
- interface MindooDBAppViewNavigator {
695
- getDefinition(): Promise<MindooDBAppViewDefinition>;
696
- getViewCursor(): Promise<string | null>;
697
- refresh(): Promise<string | null>;
698
- getCurrentEntry(): Promise<MindooDBAppViewEntry | null>;
699
- gotoFirst(): Promise<boolean>;
700
- gotoLast(): Promise<boolean>;
701
- gotoNext(): Promise<boolean>;
702
- gotoPrev(): Promise<boolean>;
703
- gotoNextSibling(): Promise<boolean>;
704
- gotoPrevSibling(): Promise<boolean>;
705
- gotoParent(): Promise<boolean>;
706
- gotoFirstChild(): Promise<boolean>;
707
- gotoLastChild(): Promise<boolean>;
708
- gotoPos(position: string): Promise<boolean>;
709
- getPos(position: string): Promise<MindooDBAppViewEntry | null>;
710
- findCategoryEntryByParts(parts: unknown[]): Promise<MindooDBAppViewEntry | null>;
711
- entriesForward(options?: MindooDBAppViewNavigatorPageOptions): Promise<MindooDBAppViewNavigatorPageResult>;
712
- entriesBackward(options?: MindooDBAppViewNavigatorPageOptions): Promise<MindooDBAppViewNavigatorPageResult>;
713
- gotoNextSelected(): Promise<boolean>;
714
- gotoPrevSelected(): Promise<boolean>;
715
- select(origin: string, docId: string, selectParentCategories?: boolean): Promise<void>;
716
- deselect(origin: string, docId: string): Promise<void>;
717
- selectAllEntries(): Promise<void>;
718
- deselectAllEntries(): Promise<void>;
719
- isSelected(origin: string, docId: string): Promise<boolean>;
720
- getSelectionState(): Promise<MindooDBAppViewNavigatorSelectionState>;
721
- setSelectionState(state: MindooDBAppViewNavigatorSelectionState): Promise<void>;
722
- expand(origin: string, docId: string): Promise<void>;
723
- collapse(origin: string, docId: string): Promise<void>;
724
- expandAll(): Promise<void>;
725
- collapseAll(): Promise<void>;
726
- expandToLevel(level: number): Promise<void>;
727
- isExpanded(entryKey: string): Promise<boolean>;
728
- getExpansionState(): Promise<MindooDBAppViewNavigatorExpansionState>;
729
- setExpansionState(state: MindooDBAppViewNavigatorExpansionState): Promise<void>;
730
- childEntries(entryKey: string, descending?: boolean): Promise<MindooDBAppViewEntry[]>;
731
- childCategories(entryKey: string, descending?: boolean): Promise<MindooDBAppViewEntry[]>;
732
- childDocuments(entryKey: string, descending?: boolean): Promise<MindooDBAppViewEntry[]>;
733
- childCategoriesByKey(entryKey: string, key: unknown, exact?: boolean, descending?: boolean): Promise<MindooDBAppViewEntry[]>;
734
- childDocumentsByKey(entryKey: string, key: unknown, exact?: boolean, descending?: boolean): Promise<MindooDBAppViewEntry[]>;
735
- childCategoriesBetween(entryKey: string, range: MindooDBAppViewNavigatorRangeQuery): Promise<MindooDBAppViewEntry[]>;
736
- childDocumentsBetween(entryKey: string, range: MindooDBAppViewNavigatorRangeQuery): Promise<MindooDBAppViewEntry[]>;
737
- getSortedDocIds(descending?: boolean): Promise<MindooDBAppScopedDocId[]>;
738
- getSortedDocIdsScoped(entryKey: string, descending?: boolean): Promise<MindooDBAppScopedDocId[]>;
739
- dispose(): Promise<void>;
740
- }
741
- /** Attachment operations exposed by an opened database handle. */
742
- interface MindooDBAppAttachmentApi {
743
- list(docId: string, options?: MindooDBAppAttachmentPreviewOptions): Promise<MindooDBAppAttachmentInfo[]>;
744
- remove(docId: string, attachmentName: string): Promise<{
745
- ok: true;
746
- }>;
747
- openReadStream(docId: string, attachmentName: string, options?: MindooDBAppAttachmentPreviewOptions): Promise<MindooDBAppReadableAttachmentStream>;
748
- openWriteStream(docId: string, attachmentName: string, contentType?: string): Promise<MindooDBAppWritableAttachmentStream>;
749
- scan(docId: string, options?: MindooDBAppScanAttachmentOptions): Promise<MindooDBAppScanAttachmentResult>;
750
- preparePreviewSession(docId: string, attachmentName: string, options?: MindooDBAppAttachmentPreviewOptions): Promise<MindooDBAppAttachmentPreviewSession>;
751
- openPreview(docId: string, attachmentName: string, options?: MindooDBAppAttachmentPreviewOptions): Promise<{
752
- ok: true;
753
- }>;
754
- }
755
- /** Database handle returned from `session.openDatabase()`. */
756
- interface MindooDBAppDatabase {
757
- info(): Promise<MindooDBAppDatabaseInfo>;
758
- documents: MindooDBAppDocumentApi;
759
- attachments: MindooDBAppAttachmentApi;
760
- }
761
- /** Connected session between the running app and the Haven host. */
762
- interface MindooDBAppSession {
763
- getLaunchContext(): Promise<MindooDBAppLaunchContext>;
764
- listDatabases(): Promise<MindooDBAppDatabaseInfo[]>;
765
- openDatabase(databaseId: string): Promise<MindooDBAppDatabase>;
766
- listDocumentsSinceViewCursor(cursor: string | null): Promise<MindooDBAppViewCursorDocumentListResult>;
767
- createViewNavigator(input: MindooDBAppCreateViewNavigatorInput): Promise<MindooDBAppViewNavigator>;
768
- openViewNavigator(viewId: string, options?: MindooDBAppViewNavigatorOpenOptions): Promise<MindooDBAppViewNavigator>;
769
- menus: MindooDBAppMenuApi;
770
- onThemeChange(listener: (theme: MindooDBAppHostTheme) => void): () => void;
771
- onViewportChange(listener: (viewport: MindooDBAppViewport) => void): () => void;
772
- onUiPreferencesChange(listener: (uiPreferences: MindooDBAppUiPreferences) => void): () => void;
773
- disconnect(): Promise<void>;
774
- }
775
- /** Root SDK bridge object used to establish a session. */
776
- interface MindooDBAppBridge {
777
- connect(options?: MindooDBAppBridgeConnectOptions): Promise<MindooDBAppSession>;
778
- }
779
-
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 };