mindoodb-app-sdk 0.0.36 → 0.0.38

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
@@ -326,7 +326,7 @@ const window = await db.documents.list({
326
326
  // Read
327
327
  const doc = await db.documents.get(docId);
328
328
 
329
- // Create (MindooDB generates a UUID7 id; optionally use a named document key)
329
+ // Create (MindooDB generates an ObjectId; optionally use a named document key)
330
330
  const created = await db.documents.create({
331
331
  set: { title: "Meeting notes", content: "..." },
332
332
  decryptionKeyId: "team-key", // omit to use "default"
@@ -335,15 +335,16 @@ const created = await db.documents.create({
335
335
  // Create with a caller-provided id (e.g. a known well-known document the app
336
336
  // always loads on launch, or migrating an id from another system).
337
337
  const settings = await db.documents.create({
338
- id: "AppSettings",
338
+ id: "appsettings",
339
339
  set: { theme: "dark" },
340
340
  });
341
341
  // Subsequent calls with the same id return the existing document and DO NOT
342
342
  // overwrite `set`, so `documents.create({ id })` is safe to call on every app
343
343
  // launch as a "create-if-missing" primitive. Custom ids must match
344
- // /^[A-Za-z][A-Za-z0-9_]*$/ (first char must be a letter, subsequent chars
345
- // may be letters, digits, or `_`). Documents created with the same custom id
346
- // on different replicas merge correctly when synced.
344
+ // /^[a-z][a-z0-9_]*$/ (lowercase only — ids become on-disk filenames, which are
345
+ // case-insensitive: first char must be a lowercase letter, subsequent chars may
346
+ // be lowercase letters, digits, or `_`). Documents created with the same custom
347
+ // id on different replicas merge correctly when synced.
347
348
 
348
349
  // Update top-level fields
349
350
  const updated = await db.documents.update(docId, {
@@ -1487,14 +1488,20 @@ Connect options: `launchId?`, `targetOrigin?`, `connectTimeoutMs?`.
1487
1488
  | `query(query?)` | `Promise<MindooDBAppQueryResult>` |
1488
1489
  | `liveQuery(query, onResult)` | `Promise<MindooDBAppLiveQuerySubscription>` |
1489
1490
  | `list(query?)` | `Promise<MindooDBAppDocumentListResult>` |
1491
+ | `listInaccessible(query?)` | `Promise<MindooDBAppInaccessibleDocumentListResult>` |
1490
1492
  | `get(docId)` | `Promise<MindooDBAppDocument \| null>` |
1491
1493
  | `getRichText(docId, path, opts?)` | `Promise<MindooDBAppRichTextSnapshot>` |
1492
1494
  | `getAutomergeSnapshot(docId, opts?)` | `Promise<MindooDBAppAutomergeSnapshot>` |
1493
1495
  | `applyAutomergeChanges(docId, patch)` | `Promise<MindooDBAppAutomergePatchResult>` |
1494
1496
  | `create(input)` | `Promise<MindooDBAppDocument>` |
1495
1497
  | `update(docId, patch)` | `Promise<MindooDBAppDocument>` |
1498
+ | `addRecipients(docId, recipients)` | `Promise<MindooDBAppDocument>` |
1499
+ | `removeRecipients(docId, recipients)` | `Promise<MindooDBAppDocument>` |
1500
+ | `setRecipients(docId, recipients)` | `Promise<MindooDBAppDocument>` |
1496
1501
  | `delete(docId)` | `Promise<{ ok: true }>` |
1497
1502
  | `undelete(docId)` | `Promise<{ ok: true }>` |
1503
+ | `getDefaultCreateKeyId()` | `Promise<string>` |
1504
+ | `listCreateKeys()` | `Promise<MindooDBAppCreateKeyInfo[]>` |
1498
1505
  | `listHistory(docId)` | `Promise<MindooDBAppDocumentHistoryEntry[]>` |
1499
1506
  | `getAtTimestamp(docId, timestamp)` | `Promise<MindooDBAppHistoricalDocument>` |
1500
1507
  | `getAtRevision(docId, revisionId, opts?)` | `Promise<MindooDBAppHistoricalDocument>` |
@@ -1504,7 +1511,9 @@ Connect options: `launchId?`, `targetOrigin?`, `connectTimeoutMs?`.
1504
1511
 
1505
1512
  `list(query?)` accepts the changefeed query options documented above. The `cursor` value is an opaque checkpoint string managed by Haven and should be stored and passed back unchanged.
1506
1513
 
1507
- For `create(input)`, use `MindooDBAppCreateDocumentInput` with shape `{ set: Record<string, unknown>; decryptionKeyId?: string; id?: string }`. The optional `id` lets the app pick the document id instead of letting MindooDB generate a UUID7; when provided it must match `/^[A-Za-z][A-Za-z0-9_]*$/` and existing live documents with that id are returned as-is (idempotent create-if-missing). If an existing custom-id document is deleted, `create({ id })` undeletes it and preserves the previous document body. Documents created with the same custom id on different replicas converge correctly when synced.
1514
+ `listInaccessible(query?)` returns documents that exist locally but the current user cannot decrypt (not a recipient, or missing the document key). Those ids never appear in `list` / `get`. Each row is unsigned store metadata only (`id`, `createdAt`, `decryptionKeyId`, optional `authorLabel`) — the app does not get CAS access. Use it to distinguish an empty database from one sealed to someone else.
1515
+
1516
+ For `create(input)`, use `MindooDBAppCreateDocumentInput` with shape `{ set: Record<string, unknown>; decryptionKeyId?: string; recipients?: string[]; recipientOptions?: { includeSelf?: boolean }; id?: string }`. Omit both `decryptionKeyId` and `recipients` to use the database default shared key (`getDefaultCreateKeyId()` / `listCreateKeys()`). Pass `recipients` to encrypt the document for specific directory users (the launching user is included unless `recipientOptions.includeSelf` is `false`). Use `includeSelf: false` to write initial `set` values and hand the document to someone else — empty `recipients` with `includeSelf: false` is rejected. Changing that list later is `addRecipients` / `removeRecipients` / `setRecipients` — do not write `_encryptFor` via `update`. The optional `id` lets the app pick the document id instead of letting MindooDB generate an ObjectId; when provided it must match `/^[a-z][a-z0-9_]*$/` (lowercase only, since ids become on-disk filenames) and existing live documents with that id are returned as-is (idempotent create-if-missing). If an existing custom-id document is deleted, `create({ id })` undeletes it and preserves the previous document body. Documents created with the same custom id on different replicas converge correctly when synced.
1508
1517
 
1509
1518
  `delete(docId)` writes a lifecycle tombstone; it does not erase the document body from the append-only history. Use `undelete(docId)` to make the latest document state live again. If you want to record a deletion reason, first call `update(docId, { set: { intendedDeletionReason: "..." } })`, then call `delete(docId)`.
1510
1519
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppBridge, b as MindooDBAppDatabase, c as MindooDBAppDocument, d as MindooDBAppRichTextSpan, e as MindooDBAppRichTextSnapshot } from './types-qW1XwmiZ.js';
2
- export { f as MINDOODB_APP_SEAL_SIGNING_DOMAIN, g as MindooDBAppAccessDecision, h as MindooDBAppAccessTier, i as MindooDBAppAttachmentApi, j as MindooDBAppAttachmentChunk, k as MindooDBAppAttachmentInfo, l as MindooDBAppAttachmentPreviewOptions, m as MindooDBAppAttachmentPreviewSession, n as MindooDBAppAutomergeChangesPatch, o as MindooDBAppAutomergeChangesSince, p as MindooDBAppAutomergeGetOptions, q as MindooDBAppAutomergePatchResult, r as MindooDBAppAutomergeSnapshot, s as MindooDBAppBridgeConnectMessage, t as MindooDBAppBridgeConnectOptions, u as MindooDBAppBridgeConnectedMessage, v as MindooDBAppBridgeErrorPayload, w as MindooDBAppBridgeHandshakeErrorMessage, x as MindooDBAppBridgeLocaleChangedMessage, y as MindooDBAppBridgePortMessage, z as MindooDBAppBridgeQueryResultMessage, A as MindooDBAppBridgeRpcError, B as MindooDBAppBridgeRpcMessage, C as MindooDBAppBridgeRpcRequest, D as MindooDBAppBridgeRpcSuccess, E as MindooDBAppBridgeStreamAbortRequest, F as MindooDBAppBridgeStreamAck, G as MindooDBAppBridgeStreamCloseRequest, H as MindooDBAppBridgeStreamError, I as MindooDBAppBridgeStreamMessage, J as MindooDBAppBridgeStreamOpenResult, K as MindooDBAppBridgeStreamReadRequest, L as MindooDBAppBridgeStreamWriteRequest, N as MindooDBAppBridgeThemeChangedMessage, O as MindooDBAppBridgeUiPreferencesChangedMessage, P as MindooDBAppBridgeViewChangedMessage, Q as MindooDBAppBridgeViewportChangedMessage, R as MindooDBAppCapability, S as MindooDBAppConfiguredViewCategorizationStyle, T as MindooDBAppConfiguredViewColumn, U as MindooDBAppConfiguredViewColumnRole, V as MindooDBAppConfiguredViewExpressionMode, W as MindooDBAppConfiguredViewFieldExpression, X as MindooDBAppConfiguredViewFilterDefinition, Y as MindooDBAppConfiguredViewFilterMode, Z as MindooDBAppConfiguredViewFilterRule, _ as MindooDBAppConfiguredViewFormulaExpression, $ as MindooDBAppConfiguredViewFormulaFilterDefinition, a0 as MindooDBAppConfiguredViewPreviewMode, a1 as MindooDBAppConfiguredViewRuleFilterDefinition, a2 as MindooDBAppConfiguredViewRuleMatchMode, a3 as MindooDBAppConfiguredViewRuleOperator, a4 as MindooDBAppConfiguredViewValueExpression, a5 as MindooDBAppCreateDocumentInput, a6 as MindooDBAppCreateViewInput, a7 as MindooDBAppCreateViewNavigatorInput, a8 as MindooDBAppDatabaseInfo, a9 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 MindooDBAppEntryAttachmentRef, al as MindooDBAppEntryProvenance, am as MindooDBAppExtractDocumentTextInput, an as MindooDBAppExtractDocumentTextResult, ao as MindooDBAppExtractTextFormat, ap as MindooDBAppExtractionSetup, aq as MindooDBAppFulltextSetup, ar as MindooDBAppHistoricalDocument, as as MindooDBAppHistoryQuery, at as MindooDBAppHostTheme, au as MindooDBAppIdentityApi, av as MindooDBAppJsonListDeletePatch, aw as MindooDBAppJsonListInsertPatch, ax as MindooDBAppJsonPatch, ay as MindooDBAppJsonSetPatch, az as MindooDBAppJsonTextMarkPatch, aA as MindooDBAppJsonTextSplicePatch, aB as MindooDBAppJsonTextUnmarkPatch, aC as MindooDBAppJsonUnsetPatch, aD as MindooDBAppLaunchContext, aE as MindooDBAppLiveQuerySubscription, 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 MindooDBAppQueryCoverage, aT as MindooDBAppQueryResult, aU as MindooDBAppQueryRow, aV as MindooDBAppQuerySortKey, aW as MindooDBAppQueryTextClause, aX as MindooDBAppReadableAttachmentStream, aY as MindooDBAppResolvedViewDefinition, aZ as MindooDBAppResolvedViewSource, a_ as MindooDBAppRevisionPhase, a$ as MindooDBAppRevisionVerification, b0 as MindooDBAppRichTextBlockSpan, b1 as MindooDBAppRichTextGetOptions, b2 as MindooDBAppRichTextImmutableString, b3 as MindooDBAppRichTextMarkRange, b4 as MindooDBAppRichTextMaterializeValue, b5 as MindooDBAppRichTextPatch, b6 as MindooDBAppRichTextScalar, b7 as MindooDBAppRichTextSpliceStep, b8 as MindooDBAppRichTextStep, b9 as MindooDBAppRichTextStepPatch, ba as MindooDBAppRichTextTextSpan, bb as MindooDBAppRuntime, bc as MindooDBAppScanAttachmentOptions, bd as MindooDBAppScanAttachmentResult, be as MindooDBAppScopedDocId, bf as MindooDBAppScopedDocumentSummary, bg as MindooDBAppSealIntent, bh as MindooDBAppSession, bi as MindooDBAppShowMenuInput, bj as MindooDBAppShowMenuResult, bk as MindooDBAppSignPreview, bl as MindooDBAppSignPreviewScope, bm as MindooDBAppSignStatementInput, bn as MindooDBAppSignStatementResult, bo as MindooDBAppTextEdit, bp as MindooDBAppTextPatch, bq as MindooDBAppThemeMode, br as MindooDBAppTimestampApi, bs as MindooDBAppTimestampInput, bt as MindooDBAppTimestampProvider, bu as MindooDBAppTimestampResult, bv as MindooDBAppUiPreferences, bw as MindooDBAppUpdateDocumentInput, bx as MindooDBAppViewCursorDocumentListResult, by as MindooDBAppViewCursorResult, bz as MindooDBAppViewEntry, bA as MindooDBAppViewEntryKind, bB as MindooDBAppViewNavigator, bC as MindooDBAppViewNavigatorExpansionState, bD as MindooDBAppViewNavigatorOpenOptions, bE as MindooDBAppViewNavigatorPageOptions, bF as MindooDBAppViewNavigatorPageResult, bG as MindooDBAppViewNavigatorRangeQuery, bH as MindooDBAppViewNavigatorSelectionState, bI as MindooDBAppViewUpdateStats, bJ as MindooDBAppViewport, bK as MindooDBAppWritableAttachmentStream } from './types-qW1XwmiZ.js';
1
+ import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppBridge, b as MindooDBAppDatabase, c as MindooDBAppDocument, d as MindooDBAppRichTextSpan, e as MindooDBAppRichTextSnapshot } from './types-SPuW5xnS.js';
2
+ export { f as MINDOODB_APP_SEAL_SIGNING_DOMAIN, g as MindooDBAppAccessDecision, h as MindooDBAppAccessTier, i as MindooDBAppAttachmentApi, j as MindooDBAppAttachmentChunk, k as MindooDBAppAttachmentInfo, l as MindooDBAppAttachmentPreviewOptions, m as MindooDBAppAttachmentPreviewSession, n as MindooDBAppAutomergeChangesPatch, o as MindooDBAppAutomergeChangesSince, p as MindooDBAppAutomergeGetOptions, q as MindooDBAppAutomergePatchResult, r as MindooDBAppAutomergeSnapshot, s as MindooDBAppBridgeConnectMessage, t as MindooDBAppBridgeConnectOptions, u as MindooDBAppBridgeConnectedMessage, v as MindooDBAppBridgeErrorPayload, w as MindooDBAppBridgeHandshakeErrorMessage, x as MindooDBAppBridgeLocaleChangedMessage, y as MindooDBAppBridgePortMessage, z as MindooDBAppBridgeQueryResultMessage, A as MindooDBAppBridgeRpcError, B as MindooDBAppBridgeRpcMessage, C as MindooDBAppBridgeRpcRequest, D as MindooDBAppBridgeRpcSuccess, E as MindooDBAppBridgeStreamAbortRequest, F as MindooDBAppBridgeStreamAck, G as MindooDBAppBridgeStreamCloseRequest, H as MindooDBAppBridgeStreamError, I as MindooDBAppBridgeStreamMessage, J as MindooDBAppBridgeStreamOpenResult, K as MindooDBAppBridgeStreamReadRequest, L as MindooDBAppBridgeStreamWriteRequest, N as MindooDBAppBridgeThemeChangedMessage, O as MindooDBAppBridgeUiPreferencesChangedMessage, P as MindooDBAppBridgeViewChangedMessage, Q as MindooDBAppBridgeViewportChangedMessage, R as MindooDBAppCapability, S as MindooDBAppConfiguredViewCategorizationStyle, T as MindooDBAppConfiguredViewColumn, U as MindooDBAppConfiguredViewColumnRole, V as MindooDBAppConfiguredViewExpressionMode, W as MindooDBAppConfiguredViewFieldExpression, X as MindooDBAppConfiguredViewFilterDefinition, Y as MindooDBAppConfiguredViewFilterMode, Z as MindooDBAppConfiguredViewFilterRule, _ as MindooDBAppConfiguredViewFormulaExpression, $ as MindooDBAppConfiguredViewFormulaFilterDefinition, a0 as MindooDBAppConfiguredViewPreviewMode, a1 as MindooDBAppConfiguredViewRuleFilterDefinition, a2 as MindooDBAppConfiguredViewRuleMatchMode, a3 as MindooDBAppConfiguredViewRuleOperator, a4 as MindooDBAppConfiguredViewValueExpression, a5 as MindooDBAppCreateDocumentInput, a6 as MindooDBAppCreateKeyInfo, a7 as MindooDBAppCreateViewInput, a8 as MindooDBAppCreateViewNavigatorInput, a9 as MindooDBAppDatabaseInfo, aa as MindooDBAppDirectoryApi, ab as MindooDBAppDirectoryEntry, ac as MindooDBAppDocumentApi, ad as MindooDBAppDocumentHeadCursorResult, ae as MindooDBAppDocumentHistoryEntry, af as MindooDBAppDocumentListQuery, ag as MindooDBAppDocumentListResult, ah as MindooDBAppDocumentQuery, ai as MindooDBAppDocumentRevisionId, aj as MindooDBAppDocumentScanPreset, ak as MindooDBAppDocumentSummary, al as MindooDBAppEntryAttachmentRef, am as MindooDBAppEntryProvenance, an as MindooDBAppExtractDocumentTextInput, ao as MindooDBAppExtractDocumentTextResult, ap as MindooDBAppExtractTextFormat, aq as MindooDBAppExtractionSetup, ar as MindooDBAppFulltextSetup, as as MindooDBAppHistoricalDocument, at as MindooDBAppHistoryQuery, au as MindooDBAppHostTheme, av as MindooDBAppIdentityApi, aw as MindooDBAppInaccessibleDocument, ax as MindooDBAppInaccessibleDocumentListQuery, ay as MindooDBAppInaccessibleDocumentListResult, az as MindooDBAppJsonListDeletePatch, aA as MindooDBAppJsonListInsertPatch, aB as MindooDBAppJsonPatch, aC as MindooDBAppJsonSetPatch, aD as MindooDBAppJsonTextMarkPatch, aE as MindooDBAppJsonTextSplicePatch, aF as MindooDBAppJsonTextUnmarkPatch, aG as MindooDBAppJsonUnsetPatch, aH as MindooDBAppLaunchContext, aI as MindooDBAppLiveQuerySubscription, aJ as MindooDBAppMenuAnchor, aK as MindooDBAppMenuApi, aL as MindooDBAppMenuCommandItem, aM as MindooDBAppMenuDismissReason, aN as MindooDBAppMenuDismissedResult, aO as MindooDBAppMenuItem, aP as MindooDBAppMenuKind, aQ as MindooDBAppMenuPlacement, aR as MindooDBAppMenuPointAnchor, aS as MindooDBAppMenuRect, aT as MindooDBAppMenuRectAnchor, aU as MindooDBAppMenuSelectionResult, aV as MindooDBAppMenuSeparatorItem, aW as MindooDBAppQueryCoverage, aX as MindooDBAppQueryResult, aY as MindooDBAppQueryRow, aZ as MindooDBAppQuerySortKey, a_ as MindooDBAppQueryTextClause, a$ as MindooDBAppReadableAttachmentStream, b0 as MindooDBAppRecipientOptions, b1 as MindooDBAppResolvedViewDefinition, b2 as MindooDBAppResolvedViewSource, b3 as MindooDBAppRevisionPhase, b4 as MindooDBAppRevisionVerification, b5 as MindooDBAppRichTextBlockSpan, b6 as MindooDBAppRichTextGetOptions, b7 as MindooDBAppRichTextImmutableString, b8 as MindooDBAppRichTextMarkRange, b9 as MindooDBAppRichTextMaterializeValue, ba as MindooDBAppRichTextPatch, bb as MindooDBAppRichTextScalar, bc as MindooDBAppRichTextSpliceStep, bd as MindooDBAppRichTextStep, be as MindooDBAppRichTextStepPatch, bf as MindooDBAppRichTextTextSpan, bg as MindooDBAppRuntime, bh as MindooDBAppScanAttachmentOptions, bi as MindooDBAppScanAttachmentResult, bj as MindooDBAppScopedDocId, bk as MindooDBAppScopedDocumentSummary, bl as MindooDBAppSealIntent, bm as MindooDBAppSession, bn as MindooDBAppShowMenuInput, bo as MindooDBAppShowMenuResult, bp as MindooDBAppSignPreview, bq as MindooDBAppSignPreviewScope, br as MindooDBAppSignStatementInput, bs as MindooDBAppSignStatementResult, bt as MindooDBAppTextEdit, bu as MindooDBAppTextPatch, bv as MindooDBAppThemeMode, bw as MindooDBAppTimestampApi, bx as MindooDBAppTimestampInput, by as MindooDBAppTimestampProvider, bz as MindooDBAppTimestampResult, bA as MindooDBAppUiPreferences, bB as MindooDBAppUpdateDocumentInput, bC as MindooDBAppViewCursorDocumentListResult, bD as MindooDBAppViewCursorResult, bE as MindooDBAppViewEntry, bF as MindooDBAppViewEntryKind, bG as MindooDBAppViewNavigator, bH as MindooDBAppViewNavigatorExpansionState, bI as MindooDBAppViewNavigatorOpenOptions, bJ as MindooDBAppViewNavigatorPageOptions, bK as MindooDBAppViewNavigatorPageResult, bL as MindooDBAppViewNavigatorRangeQuery, bM as MindooDBAppViewNavigatorSelectionState, bN as MindooDBAppViewUpdateStats, bO as MindooDBAppViewport, bP as MindooDBAppWritableAttachmentStream } from './types-SPuW5xnS.js';
3
3
  import { MindooDBAppBooleanExpression } from 'mindoodb-view-language';
4
4
  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';
5
5
  import { MindooDB, MindooQuerySortKey, MindooQueryOptions, MindooQueryResult } from 'mindoodb';
package/dist/index.js CHANGED
@@ -758,6 +758,10 @@ var MindooDBAppDatabaseImpl = class {
758
758
  databaseId: this.databaseId,
759
759
  query: query ?? {}
760
760
  }),
761
+ listInaccessible: async (query) => await this.rpc.call("documents.listInaccessible", {
762
+ databaseId: this.databaseId,
763
+ query: query ?? {}
764
+ }),
761
765
  query: async (query) => await this.rpc.call("documents.query", {
762
766
  databaseId: this.databaseId,
763
767
  query: normalizeDocumentQuery(query)
@@ -852,6 +856,22 @@ var MindooDBAppDatabaseImpl = class {
852
856
  docId,
853
857
  patch
854
858
  }),
859
+ addRecipients: async (docId, recipients) => await this.rpc.call("documents.addRecipients", {
860
+ databaseId: this.databaseId,
861
+ docId,
862
+ recipients
863
+ }),
864
+ removeRecipients: async (docId, recipients) => await this.rpc.call("documents.removeRecipients", {
865
+ databaseId: this.databaseId,
866
+ docId,
867
+ recipients
868
+ }),
869
+ setRecipients: async (docId, recipients, options) => await this.rpc.call("documents.setRecipients", {
870
+ databaseId: this.databaseId,
871
+ docId,
872
+ recipients,
873
+ recipientOptions: options
874
+ }),
855
875
  delete: async (docId) => await this.rpc.call("documents.delete", {
856
876
  databaseId: this.databaseId,
857
877
  docId
@@ -901,6 +921,21 @@ var MindooDBAppDatabaseImpl = class {
901
921
  getDefaultCreateKeyId: async () => await this.rpc.call("documents.getDefaultCreateKeyId", {
902
922
  databaseId: this.databaseId
903
923
  }),
924
+ listCreateKeys: async () => {
925
+ try {
926
+ return await this.rpc.call("documents.listCreateKeys", {
927
+ databaseId: this.databaseId
928
+ });
929
+ } catch (error) {
930
+ if (!isMethodNotFoundError(error)) {
931
+ throw error;
932
+ }
933
+ const keyId = await this.rpc.call("documents.getDefaultCreateKeyId", {
934
+ databaseId: this.databaseId
935
+ });
936
+ return [{ keyId, isDefault: true }];
937
+ }
938
+ },
904
939
  listHistory: async (docId) => await this.rpc.call("documents.history.list", {
905
940
  databaseId: this.databaseId,
906
941
  docId
@@ -946,7 +981,19 @@ var MindooDBAppDatabaseImpl = class {
946
981
  excerpt: async (publicKeys) => await this.rpc.call("directory.excerpt", {
947
982
  databaseId: this.databaseId,
948
983
  publicKeys
949
- })
984
+ }),
985
+ listUsers: async () => {
986
+ try {
987
+ return await this.rpc.call("directory.listUsers", {
988
+ databaseId: this.databaseId
989
+ });
990
+ } catch (error) {
991
+ if (!isMethodNotFoundError(error)) {
992
+ throw error;
993
+ }
994
+ return [];
995
+ }
996
+ }
950
997
  };
951
998
  this.attachments = {
952
999
  list: async (docId, options) => await this.rpc.call("attachments.list", {
@@ -1,4 +1,4 @@
1
- import { a7 as MindooDBAppCreateViewNavigatorInput, bB as MindooDBAppViewNavigator, aD as MindooDBAppLaunchContext, a8 as MindooDBAppDatabaseInfo, ab as MindooDBAppDocumentApi, bD as MindooDBAppViewNavigatorOpenOptions, i as MindooDBAppAttachmentApi, au as MindooDBAppIdentityApi, br as MindooDBAppTimestampApi, a9 as MindooDBAppDirectoryApi, c as MindooDBAppDocument, aq as MindooDBAppFulltextSetup, ap as MindooDBAppExtractionSetup, a as MindooDBAppBridge, bh as MindooDBAppSession, C as MindooDBAppBridgeRpcRequest, at as MindooDBAppHostTheme, bJ as MindooDBAppViewport, bv as MindooDBAppUiPreferences, aT as MindooDBAppQueryResult, bI as MindooDBAppViewUpdateStats, y as MindooDBAppBridgePortMessage } from '../types-qW1XwmiZ.js';
1
+ import { a8 as MindooDBAppCreateViewNavigatorInput, bG as MindooDBAppViewNavigator, aH as MindooDBAppLaunchContext, a9 as MindooDBAppDatabaseInfo, ac as MindooDBAppDocumentApi, bI as MindooDBAppViewNavigatorOpenOptions, i as MindooDBAppAttachmentApi, av as MindooDBAppIdentityApi, bw as MindooDBAppTimestampApi, aa as MindooDBAppDirectoryApi, c as MindooDBAppDocument, ar as MindooDBAppFulltextSetup, aq as MindooDBAppExtractionSetup, a as MindooDBAppBridge, bm as MindooDBAppSession, C as MindooDBAppBridgeRpcRequest, au as MindooDBAppHostTheme, bO as MindooDBAppViewport, bA as MindooDBAppUiPreferences, aX as MindooDBAppQueryResult, bN as MindooDBAppViewUpdateStats, y as MindooDBAppBridgePortMessage } from '../types-SPuW5xnS.js';
2
2
  import * as mindoodb from 'mindoodb';
3
3
  import 'mindoodb-view-language';
4
4
 
@@ -38,7 +38,12 @@ interface MockSeedDocument {
38
38
  id: string;
39
39
  data: Record<string, unknown>;
40
40
  updatedAt?: string;
41
+ createdAt?: string;
41
42
  isDeleted?: boolean;
43
+ /** When true the doc is hidden from `list`/`get` and returned by `listInaccessible`. */
44
+ inaccessible?: boolean;
45
+ decryptionKeyId?: string;
46
+ authorLabel?: string;
42
47
  heads?: string[];
43
48
  attachments?: MindooDBAppDocument["attachments"];
44
49
  }
@@ -942,7 +942,7 @@ function runMockDocumentQuery(storedDocuments, databaseId, query) {
942
942
  const sortBy = query?.sortBy && query.sortBy.length > 0 ? query.sortBy : query?.text ? [{ special: "textScore", direction: "descending" }] : [];
943
943
  const matches = [];
944
944
  for (const document of storedDocuments.values()) {
945
- if (document.isDeleted) {
945
+ if (document.isDeleted || document.inaccessible) {
946
946
  continue;
947
947
  }
948
948
  let textScore;
@@ -1228,7 +1228,11 @@ function createDatabaseHandle(definition) {
1228
1228
  heads: seed.heads ? [...seed.heads] : void 0,
1229
1229
  attachments: seed.attachments ? structuredClone(seed.attachments) : [],
1230
1230
  updatedAt: seed.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
1231
- isDeleted: seed.isDeleted ?? false
1231
+ isDeleted: seed.isDeleted ?? false,
1232
+ inaccessible: seed.inaccessible ?? false,
1233
+ decryptionKeyId: seed.decryptionKeyId,
1234
+ authorLabel: seed.authorLabel,
1235
+ createdAt: seed.createdAt
1232
1236
  });
1233
1237
  }
1234
1238
  const liveQuerySubscriptions = /* @__PURE__ */ new Set();
@@ -1246,6 +1250,43 @@ function createDatabaseHandle(definition) {
1246
1250
  }
1247
1251
  }
1248
1252
  };
1253
+ function mockEncryptForMap(names) {
1254
+ const encryptFor = {};
1255
+ for (const name of names) {
1256
+ const trimmed = name.trim();
1257
+ if (trimmed) {
1258
+ encryptFor[trimmed] = { kind: "user" };
1259
+ }
1260
+ }
1261
+ return encryptFor;
1262
+ }
1263
+ function persistEncryptFor(docId, nextEncryptFor) {
1264
+ const existing = storedDocuments.get(docId);
1265
+ if (!existing || existing.isDeleted) {
1266
+ throw new Error(`Recipient mutators require an existing document (${docId})`);
1267
+ }
1268
+ const raw = existing.data._encryptFor;
1269
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
1270
+ throw new Error("Recipient mutators require a document created with `recipients`");
1271
+ }
1272
+ const updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1273
+ const updated = {
1274
+ id: docId,
1275
+ data: { ...existing.data, _encryptFor: nextEncryptFor },
1276
+ heads: [`mock-head-${++changeCounter}`],
1277
+ attachments: existing.attachments ? structuredClone(existing.attachments) : [],
1278
+ updatedAt
1279
+ };
1280
+ storedDocuments.set(docId, {
1281
+ ...updated,
1282
+ data: structuredClone(updated.data),
1283
+ attachments: updated.attachments ? structuredClone(updated.attachments) : [],
1284
+ isDeleted: false,
1285
+ automergeBinary: void 0
1286
+ });
1287
+ notifyLiveQueries();
1288
+ return updated;
1289
+ }
1249
1290
  const defaultDocuments = {
1250
1291
  async query(query) {
1251
1292
  return runMockDocumentQuery(storedDocuments, definition.info.id, query);
@@ -1288,7 +1329,7 @@ function createDatabaseHandle(definition) {
1288
1329
  const offset = decodeMockListCursor(query?.cursor) + skip;
1289
1330
  const metadataOnly = query?.metadataOnly ?? false;
1290
1331
  const idPrefix = query?.idPrefix;
1291
- const items = Array.from(storedDocuments.values()).filter(
1332
+ const items = Array.from(storedDocuments.values()).filter((document) => !document.inaccessible).filter(
1292
1333
  (document) => status === "all" ? true : status === "deleted" ? document.isDeleted : !document.isDeleted
1293
1334
  ).filter((document) => matchesMockIdPrefix(document.id, idPrefix)).filter(
1294
1335
  (document) => metadataOnly ? true : matchesDocumentFilter(document, query?.filter)
@@ -1325,9 +1366,19 @@ function createDatabaseHandle(definition) {
1325
1366
  cursor: String(storedDocuments.size)
1326
1367
  };
1327
1368
  },
1369
+ async listInaccessible(query) {
1370
+ const idPrefix = query?.idPrefix;
1371
+ const items = Array.from(storedDocuments.values()).filter((document) => document.inaccessible).filter((document) => matchesMockIdPrefix(document.id, idPrefix)).sort((left, right) => left.id.localeCompare(right.id)).map((document) => ({
1372
+ id: document.id,
1373
+ createdAt: document.createdAt ?? document.updatedAt ?? (/* @__PURE__ */ new Date(0)).toISOString(),
1374
+ decryptionKeyId: document.decryptionKeyId ?? "sealed",
1375
+ authorLabel: document.authorLabel
1376
+ }));
1377
+ return { items };
1378
+ },
1328
1379
  async get(_docId) {
1329
1380
  const document = storedDocuments.get(_docId);
1330
- if (!document || document.isDeleted) {
1381
+ if (!document || document.isDeleted || document.inaccessible) {
1331
1382
  return null;
1332
1383
  }
1333
1384
  return {
@@ -1433,9 +1484,17 @@ function createDatabaseHandle(definition) {
1433
1484
  id = `doc-${createCounter}`;
1434
1485
  }
1435
1486
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
1487
+ if (Array.isArray(input.recipients) && input.recipientOptions?.includeSelf === false && input.recipients.every((name) => name.trim().length === 0)) {
1488
+ throw new Error(
1489
+ "recipients: [] with includeSelf: false would produce a document nobody can read"
1490
+ );
1491
+ }
1436
1492
  const created = {
1437
1493
  id,
1438
- data: { ...input.set },
1494
+ data: {
1495
+ ...input.set,
1496
+ ...Array.isArray(input.recipients) ? { _encryptFor: mockEncryptForMap(input.recipients) } : {}
1497
+ },
1439
1498
  heads: [`mock-head-${++changeCounter}`],
1440
1499
  attachments: [],
1441
1500
  updatedAt: createdAt
@@ -1479,6 +1538,49 @@ function createDatabaseHandle(definition) {
1479
1538
  notifyLiveQueries();
1480
1539
  return updated;
1481
1540
  },
1541
+ async addRecipients(docId, recipients) {
1542
+ const existing = storedDocuments.get(docId);
1543
+ const current = existing?.data._encryptFor && typeof existing.data._encryptFor === "object" && !Array.isArray(existing.data._encryptFor) ? { ...existing.data._encryptFor } : null;
1544
+ if (!current) {
1545
+ throw new Error("Recipient mutators require a document created with `recipients`");
1546
+ }
1547
+ for (const name of recipients) {
1548
+ const trimmed = name.trim();
1549
+ if (!trimmed) {
1550
+ continue;
1551
+ }
1552
+ const key = Object.keys(current).find(
1553
+ (entry) => entry.trim().toLowerCase() === trimmed.toLowerCase()
1554
+ );
1555
+ if (key) {
1556
+ delete current[key].removedAt;
1557
+ } else {
1558
+ current[trimmed] = { kind: "user" };
1559
+ }
1560
+ }
1561
+ return persistEncryptFor(docId, current);
1562
+ },
1563
+ async removeRecipients(docId, recipients) {
1564
+ const existing = storedDocuments.get(docId);
1565
+ const current = existing?.data._encryptFor && typeof existing.data._encryptFor === "object" && !Array.isArray(existing.data._encryptFor) ? { ...existing.data._encryptFor } : {};
1566
+ const drop = new Set(
1567
+ recipients.map((name) => name.trim().toLowerCase()).filter(Boolean)
1568
+ );
1569
+ for (const key of Object.keys(current)) {
1570
+ if (drop.has(key.trim().toLowerCase())) {
1571
+ delete current[key];
1572
+ }
1573
+ }
1574
+ return persistEncryptFor(docId, current);
1575
+ },
1576
+ async setRecipients(docId, recipients, options) {
1577
+ if (options?.includeSelf === false && recipients.every((name) => name.trim().length === 0)) {
1578
+ throw new Error(
1579
+ "recipients: [] with includeSelf: false would produce a document nobody can read"
1580
+ );
1581
+ }
1582
+ return persistEncryptFor(docId, mockEncryptForMap(recipients));
1583
+ },
1482
1584
  async delete(_docId) {
1483
1585
  const existing = storedDocuments.get(_docId);
1484
1586
  if (existing) {
@@ -1525,6 +1627,9 @@ function createDatabaseHandle(definition) {
1525
1627
  async getDefaultCreateKeyId() {
1526
1628
  return "default";
1527
1629
  },
1630
+ async listCreateKeys() {
1631
+ return [{ keyId: "default", isDefault: true }];
1632
+ },
1528
1633
  async listHistory(_docId) {
1529
1634
  return [];
1530
1635
  },
@@ -1610,6 +1715,9 @@ function createDatabaseHandle(definition) {
1610
1715
  fingerprint: "0".repeat(64),
1611
1716
  status: "unknown"
1612
1717
  }));
1718
+ },
1719
+ async listUsers() {
1720
+ return [];
1613
1721
  }
1614
1722
  };
1615
1723
  const defaultViews = {
@@ -1709,7 +1817,7 @@ function createDatabaseHandle(definition) {
1709
1817
  };
1710
1818
  return {
1711
1819
  handle: databaseHandle,
1712
- listViewDocuments: () => Array.from(storedDocuments.values()).filter((document) => !document.isDeleted).map((document) => ({
1820
+ listViewDocuments: () => Array.from(storedDocuments.values()).filter((document) => !document.isDeleted && !document.inaccessible).map((document) => ({
1713
1821
  origin: definition.info.id,
1714
1822
  docId: document.id,
1715
1823
  data: structuredClone(document.data),
@@ -2153,6 +2261,10 @@ function createFakeBridgeHost(options = {}) {
2153
2261
  return await state.getDatabase(String(params.databaseId)).documents.list(
2154
2262
  params.query
2155
2263
  );
2264
+ case "documents.listInaccessible":
2265
+ return await state.getDatabase(String(params.databaseId)).documents.listInaccessible(
2266
+ params.query
2267
+ );
2156
2268
  case "documents.getHeadCursor":
2157
2269
  return await state.getDatabase(String(params.databaseId)).documents.getHeadCursor();
2158
2270
  case "database.getFulltextSetup":
@@ -2237,6 +2349,22 @@ function createFakeBridgeHost(options = {}) {
2237
2349
  String(params.docId),
2238
2350
  params.patch
2239
2351
  );
2352
+ case "documents.addRecipients":
2353
+ return await state.getDatabase(String(params.databaseId)).documents.addRecipients(
2354
+ String(params.docId),
2355
+ Array.isArray(params.recipients) ? params.recipients.map(String) : []
2356
+ );
2357
+ case "documents.removeRecipients":
2358
+ return await state.getDatabase(String(params.databaseId)).documents.removeRecipients(
2359
+ String(params.docId),
2360
+ Array.isArray(params.recipients) ? params.recipients.map(String) : []
2361
+ );
2362
+ case "documents.setRecipients":
2363
+ return await state.getDatabase(String(params.databaseId)).documents.setRecipients(
2364
+ String(params.docId),
2365
+ Array.isArray(params.recipients) ? params.recipients.map(String) : [],
2366
+ params.recipientOptions && typeof params.recipientOptions === "object" && !Array.isArray(params.recipientOptions) ? params.recipientOptions : void 0
2367
+ );
2240
2368
  case "documents.delete":
2241
2369
  return await state.getDatabase(String(params.databaseId)).documents.delete(String(params.docId));
2242
2370
  case "documents.undelete":
@@ -2253,6 +2381,8 @@ function createFakeBridgeHost(options = {}) {
2253
2381
  return await state.getDatabase(String(params.databaseId)).documents.canUndelete(String(params.docId));
2254
2382
  case "documents.getDefaultCreateKeyId":
2255
2383
  return await state.getDatabase(String(params.databaseId)).documents.getDefaultCreateKeyId();
2384
+ case "documents.listCreateKeys":
2385
+ return await state.getDatabase(String(params.databaseId)).documents.listCreateKeys();
2256
2386
  case "documents.history.list":
2257
2387
  return await state.getDatabase(String(params.databaseId)).documents.listHistory(String(params.docId));
2258
2388
  case "documents.history.getAtTimestamp":
@@ -2292,6 +2422,8 @@ function createFakeBridgeHost(options = {}) {
2292
2422
  return await state.getDatabase(String(params.databaseId)).directory.excerpt(
2293
2423
  Array.isArray(params.publicKeys) ? params.publicKeys.map(String) : []
2294
2424
  );
2425
+ case "directory.listUsers":
2426
+ return await state.getDatabase(String(params.databaseId)).directory.listUsers();
2295
2427
  case "attachments.list":
2296
2428
  return await state.getDatabase(String(params.databaseId)).attachments.list(
2297
2429
  String(params.docId),
@@ -359,6 +359,30 @@ interface MindooDBAppDocumentListQuery {
359
359
  */
360
360
  idPrefix?: string;
361
361
  }
362
+ /** Query options for {@link MindooDBAppDocumentApi.listInaccessible}. */
363
+ interface MindooDBAppInaccessibleDocumentListQuery {
364
+ /**
365
+ * Restrict the listing to documents whose id matches this prefix. Matching is
366
+ * the same boundary-aware rule as {@link MindooDBAppDocumentListQuery.idPrefix}.
367
+ */
368
+ idPrefix?: string;
369
+ }
370
+ /**
371
+ * A document that exists in the local store but the current user cannot open.
372
+ * Built from unsigned `doc_create` (or `doc_snapshot`) metadata — no payload
373
+ * and no CAS access for the app.
374
+ */
375
+ interface MindooDBAppInaccessibleDocument {
376
+ id: string;
377
+ createdAt: string;
378
+ decryptionKeyId: string;
379
+ /** Directory display name of the origin author, when the host can resolve it. */
380
+ authorLabel?: string;
381
+ }
382
+ /** Result of {@link MindooDBAppDocumentApi.listInaccessible}. */
383
+ interface MindooDBAppInaccessibleDocumentListResult {
384
+ items: MindooDBAppInaccessibleDocument[];
385
+ }
362
386
  /** Paged result returned by `documents.list()`. */
363
387
  interface MindooDBAppDocumentListResult {
364
388
  items: MindooDBAppDocumentSummary[];
@@ -406,6 +430,22 @@ interface MindooDBAppAccessDecision {
406
430
  tier: MindooDBAppAccessTier;
407
431
  matchedRuleId?: string;
408
432
  }
433
+ /**
434
+ * Options for person-bound (`recipients`) encryption.
435
+ *
436
+ * Matches MindooDB `recipientOptions`. The launching user is included as a
437
+ * reader unless {@link includeSelf} is `false`.
438
+ */
439
+ interface MindooDBAppRecipientOptions {
440
+ /**
441
+ * When `false`, the launching user is not added as a reader. Use this to
442
+ * create a document for someone else (a drop box): `set` still writes the
443
+ * initial values, then only `recipients` can decrypt later. Defaults to
444
+ * `true`. Empty `recipients` with `includeSelf: false` is rejected by the
445
+ * host — it would produce a document nobody can read.
446
+ */
447
+ includeSelf?: boolean;
448
+ }
409
449
  /**
410
450
  * Payload used when creating a new document.
411
451
  *
@@ -416,11 +456,22 @@ interface MindooDBAppCreateDocumentInput {
416
456
  set: Record<string, unknown>;
417
457
  /** Optional named document key. Defaults to `"default"` when omitted. */
418
458
  decryptionKeyId?: string;
459
+ /**
460
+ * Usernames to encrypt this new document for (person-bound User-Keys).
461
+ * Mutually exclusive with {@link decryptionKeyId}. The launching user is
462
+ * included by the host unless {@link recipientOptions}.includeSelf is
463
+ * `false`.
464
+ */
465
+ recipients?: string[];
466
+ /** Sealed-create options. Only used when {@link recipients} is set. */
467
+ recipientOptions?: MindooDBAppRecipientOptions;
419
468
  /**
420
469
  * Optional caller-provided document id. When omitted, MindooDB generates a
421
- * UUID7. When provided, the id must match `^[A-Za-z][A-Za-z0-9_]*$`: the
422
- * first character is an ASCII letter and subsequent characters may be ASCII
423
- * letters, ASCII digits, or `_`.
470
+ * MongoDB-style ObjectId (24 lowercase hex characters). When provided, the id
471
+ * must match `^[a-z][a-z0-9_]*$`: the first character is a lowercase ASCII
472
+ * letter and subsequent characters may be lowercase ASCII letters, ASCII
473
+ * digits, or `_`. Uppercase is rejected because ids end up in on-disk
474
+ * filenames, and those file systems are case-insensitive.
424
475
  *
425
476
  * If a document with this id already exists locally, MindooDB returns the
426
477
  * existing document instead of creating a new one (idempotent create), and
@@ -1150,6 +1201,14 @@ interface MindooDBAppDocumentApi {
1150
1201
  * {@link query}. Requires the `read` capability.
1151
1202
  */
1152
1203
  list(query?: MindooDBAppDocumentListQuery): Promise<MindooDBAppDocumentListResult>;
1204
+ /**
1205
+ * Documents present in this database that the current user cannot decrypt
1206
+ * (not a recipient, or missing `decryptionKeyId`). They do not appear in
1207
+ * {@link list} or {@link get}. Each row is store-metadata only: id,
1208
+ * origin timestamp, key id, and the author's directory label when known.
1209
+ * Requires the `read` capability.
1210
+ */
1211
+ listInaccessible(query?: MindooDBAppInaccessibleDocumentListQuery): Promise<MindooDBAppInaccessibleDocumentListResult>;
1153
1212
  /**
1154
1213
  * The database's latest changefeed cursor without loading any documents.
1155
1214
  * Useful as a baseline checkpoint before starting an incremental
@@ -1221,6 +1280,27 @@ interface MindooDBAppDocumentApi {
1221
1280
  * each other. Requires the `update` capability.
1222
1281
  */
1223
1282
  update(docId: string, patch: MindooDBAppUpdateDocumentInput): Promise<MindooDBAppDocument>;
1283
+ /**
1284
+ * Add readers to a document created with {@link MindooDBAppCreateDocumentInput.recipients}.
1285
+ * One key wrap per new user, no rotation — new readers can decrypt the
1286
+ * whole history. The launching user is already on the list and does not
1287
+ * need to be passed. Requires the `update` capability.
1288
+ */
1289
+ addRecipients(docId: string, recipients: string[]): Promise<MindooDBAppDocument>;
1290
+ /**
1291
+ * Drop readers from a sealed document. Rotates the document key so
1292
+ * removed readers keep what they already have and cannot read later
1293
+ * changes. Do not write `_encryptFor` via {@link update}. Requires the
1294
+ * `update` capability.
1295
+ */
1296
+ removeRecipients(docId: string, recipients: string[]): Promise<MindooDBAppDocument>;
1297
+ /**
1298
+ * Replace the extra-recipient list of a sealed document. Diffs against
1299
+ * the current set (additions wrap, removals rotate). The launching user
1300
+ * stays on the list unless {@link MindooDBAppRecipientOptions.includeSelf}
1301
+ * is `false`. Requires the `update` capability.
1302
+ */
1303
+ setRecipients(docId: string, recipients: string[], options?: MindooDBAppRecipientOptions): Promise<MindooDBAppDocument>;
1224
1304
  /**
1225
1305
  * Mark a document as deleted by writing a lifecycle tombstone. The
1226
1306
  * append-only history keeps the document body, so {@link undelete} can
@@ -1257,6 +1337,8 @@ interface MindooDBAppDocumentApi {
1257
1337
  */
1258
1338
  canCreate(input?: {
1259
1339
  decryptionKeyId?: string;
1340
+ recipients?: string[];
1341
+ recipientOptions?: MindooDBAppRecipientOptions;
1260
1342
  }): Promise<MindooDBAppAccessDecision>;
1261
1343
  /**
1262
1344
  * Predict whether `update` would be allowed for the given document, without
@@ -1275,6 +1357,12 @@ interface MindooDBAppDocumentApi {
1275
1357
  * and falls back to `"default"`.
1276
1358
  */
1277
1359
  getDefaultCreateKeyId(): Promise<string>;
1360
+ /**
1361
+ * Shared document keys this user can create with in this database, plus
1362
+ * which one {@link getDefaultCreateKeyId} would pick. Use this to populate a
1363
+ * "New document" key picker. Requires the `create` capability.
1364
+ */
1365
+ listCreateKeys(): Promise<MindooDBAppCreateKeyInfo[]>;
1278
1366
  /**
1279
1367
  * List the document's revision timeline (newest first), including author
1280
1368
  * identity metadata and the stable `revisionId` per entry. Entries are
@@ -1358,6 +1446,13 @@ interface MindooDBAppTimestampApi {
1358
1446
  /** Providers this host can currently reach, best first. */
1359
1447
  listProviders(): Promise<MindooDBAppTimestampProvider[]>;
1360
1448
  }
1449
+ /** A shared document key the launching user can create with. */
1450
+ interface MindooDBAppCreateKeyInfo {
1451
+ /** Key id as stored on the document (`"default"`, `"$publicinfos"`, …). */
1452
+ keyId: string;
1453
+ /** True when this is the database/tenant default for new documents. */
1454
+ isDefault: boolean;
1455
+ }
1361
1456
  /** Read-only lookups against the tenant's user directory. */
1362
1457
  interface MindooDBAppDirectoryApi {
1363
1458
  /**
@@ -1368,6 +1463,11 @@ interface MindooDBAppDirectoryApi {
1368
1463
  * name the keys it could not resolve. Requires the `directory` capability.
1369
1464
  */
1370
1465
  excerpt(publicKeys: string[]): Promise<MindooDBAppDirectoryEntry[]>;
1466
+ /**
1467
+ * Active directory usernames in this tenant, for recipient pickers.
1468
+ * Requires the `directory` capability.
1469
+ */
1470
+ listUsers(): Promise<string[]>;
1371
1471
  }
1372
1472
  /**
1373
1473
  * The only signing domain apps may request today. Domain separation is not
@@ -1958,4 +2058,4 @@ interface MindooDBAppBridge {
1958
2058
  connect(options?: MindooDBAppBridgeConnectOptions): Promise<MindooDBAppSession>;
1959
2059
  }
1960
2060
 
1961
- export { type MindooDBAppConfiguredViewFormulaFilterDefinition as $, type MindooDBAppBridgeRpcError as A, type MindooDBAppBridgeRpcMessage as B, type MindooDBAppBridgeRpcRequest as C, type MindooDBAppBridgeRpcSuccess as D, type MindooDBAppBridgeStreamAbortRequest as E, type MindooDBAppBridgeStreamAck as F, type MindooDBAppBridgeStreamCloseRequest as G, type MindooDBAppBridgeStreamError as H, type MindooDBAppBridgeStreamMessage as I, type MindooDBAppBridgeStreamOpenResult as J, type MindooDBAppBridgeStreamReadRequest as K, type MindooDBAppBridgeStreamWriteRequest as L, type MindooDBAppAttachmentPreviewMode as M, type MindooDBAppBridgeThemeChangedMessage as N, type MindooDBAppBridgeUiPreferencesChangedMessage as O, type MindooDBAppBridgeViewChangedMessage as P, type MindooDBAppBridgeViewportChangedMessage as Q, type MindooDBAppCapability as R, type MindooDBAppConfiguredViewCategorizationStyle as S, type MindooDBAppConfiguredViewColumn as T, type MindooDBAppConfiguredViewColumnRole as U, type MindooDBAppConfiguredViewExpressionMode as V, type MindooDBAppConfiguredViewFieldExpression as W, type MindooDBAppConfiguredViewFilterDefinition as X, type MindooDBAppConfiguredViewFilterMode as Y, type MindooDBAppConfiguredViewFilterRule as Z, type MindooDBAppConfiguredViewFormulaExpression as _, type MindooDBAppBridge as a, type MindooDBAppRevisionVerification as a$, type MindooDBAppConfiguredViewPreviewMode as a0, type MindooDBAppConfiguredViewRuleFilterDefinition as a1, type MindooDBAppConfiguredViewRuleMatchMode as a2, type MindooDBAppConfiguredViewRuleOperator as a3, type MindooDBAppConfiguredViewValueExpression as a4, type MindooDBAppCreateDocumentInput as a5, type MindooDBAppCreateViewInput as a6, type MindooDBAppCreateViewNavigatorInput as a7, type MindooDBAppDatabaseInfo as a8, type MindooDBAppDirectoryApi as a9, type MindooDBAppJsonTextSplicePatch as aA, type MindooDBAppJsonTextUnmarkPatch as aB, type MindooDBAppJsonUnsetPatch as aC, type MindooDBAppLaunchContext as aD, type MindooDBAppLiveQuerySubscription as aE, type MindooDBAppMenuAnchor as aF, type MindooDBAppMenuApi as aG, type MindooDBAppMenuCommandItem as aH, type MindooDBAppMenuDismissReason as aI, type MindooDBAppMenuDismissedResult as aJ, type MindooDBAppMenuItem as aK, type MindooDBAppMenuKind as aL, type MindooDBAppMenuPlacement as aM, type MindooDBAppMenuPointAnchor as aN, type MindooDBAppMenuRect as aO, type MindooDBAppMenuRectAnchor as aP, type MindooDBAppMenuSelectionResult as aQ, type MindooDBAppMenuSeparatorItem as aR, type MindooDBAppQueryCoverage as aS, type MindooDBAppQueryResult as aT, type MindooDBAppQueryRow as aU, type MindooDBAppQuerySortKey as aV, type MindooDBAppQueryTextClause as aW, type MindooDBAppReadableAttachmentStream as aX, type MindooDBAppResolvedViewDefinition as aY, type MindooDBAppResolvedViewSource as aZ, type MindooDBAppRevisionPhase as a_, type MindooDBAppDirectoryEntry as aa, type MindooDBAppDocumentApi as ab, type MindooDBAppDocumentHeadCursorResult as ac, type MindooDBAppDocumentHistoryEntry as ad, type MindooDBAppDocumentListQuery as ae, type MindooDBAppDocumentListResult as af, type MindooDBAppDocumentQuery as ag, type MindooDBAppDocumentRevisionId as ah, type MindooDBAppDocumentScanPreset as ai, type MindooDBAppDocumentSummary as aj, type MindooDBAppEntryAttachmentRef as ak, type MindooDBAppEntryProvenance as al, type MindooDBAppExtractDocumentTextInput as am, type MindooDBAppExtractDocumentTextResult as an, type MindooDBAppExtractTextFormat as ao, type MindooDBAppExtractionSetup as ap, type MindooDBAppFulltextSetup as aq, type MindooDBAppHistoricalDocument as ar, type MindooDBAppHistoryQuery as as, type MindooDBAppHostTheme as at, type MindooDBAppIdentityApi as au, type MindooDBAppJsonListDeletePatch as av, type MindooDBAppJsonListInsertPatch as aw, type MindooDBAppJsonPatch as ax, type MindooDBAppJsonSetPatch as ay, type MindooDBAppJsonTextMarkPatch as az, type MindooDBAppDatabase as b, type MindooDBAppRichTextBlockSpan as b0, type MindooDBAppRichTextGetOptions as b1, type MindooDBAppRichTextImmutableString as b2, type MindooDBAppRichTextMarkRange as b3, type MindooDBAppRichTextMaterializeValue as b4, type MindooDBAppRichTextPatch as b5, type MindooDBAppRichTextScalar as b6, type MindooDBAppRichTextSpliceStep as b7, type MindooDBAppRichTextStep as b8, type MindooDBAppRichTextStepPatch as b9, type MindooDBAppViewEntryKind as bA, type MindooDBAppViewNavigator as bB, type MindooDBAppViewNavigatorExpansionState as bC, type MindooDBAppViewNavigatorOpenOptions as bD, type MindooDBAppViewNavigatorPageOptions as bE, type MindooDBAppViewNavigatorPageResult as bF, type MindooDBAppViewNavigatorRangeQuery as bG, type MindooDBAppViewNavigatorSelectionState as bH, type MindooDBAppViewUpdateStats as bI, type MindooDBAppViewport as bJ, type MindooDBAppWritableAttachmentStream as bK, type MindooDBAppRichTextTextSpan as ba, type MindooDBAppRuntime as bb, type MindooDBAppScanAttachmentOptions as bc, type MindooDBAppScanAttachmentResult as bd, type MindooDBAppScopedDocId as be, type MindooDBAppScopedDocumentSummary as bf, type MindooDBAppSealIntent as bg, type MindooDBAppSession as bh, type MindooDBAppShowMenuInput as bi, type MindooDBAppShowMenuResult as bj, type MindooDBAppSignPreview as bk, type MindooDBAppSignPreviewScope as bl, type MindooDBAppSignStatementInput as bm, type MindooDBAppSignStatementResult as bn, type MindooDBAppTextEdit as bo, type MindooDBAppTextPatch as bp, type MindooDBAppThemeMode as bq, type MindooDBAppTimestampApi as br, type MindooDBAppTimestampInput as bs, type MindooDBAppTimestampProvider as bt, type MindooDBAppTimestampResult as bu, type MindooDBAppUiPreferences as bv, type MindooDBAppUpdateDocumentInput as bw, type MindooDBAppViewCursorDocumentListResult as bx, type MindooDBAppViewCursorResult as by, type MindooDBAppViewEntry as bz, type MindooDBAppDocument as c, type MindooDBAppRichTextSpan as d, type MindooDBAppRichTextSnapshot as e, MINDOODB_APP_SEAL_SIGNING_DOMAIN as f, type MindooDBAppAccessDecision as g, type MindooDBAppAccessTier as h, type MindooDBAppAttachmentApi as i, type MindooDBAppAttachmentChunk as j, type MindooDBAppAttachmentInfo as k, type MindooDBAppAttachmentPreviewOptions as l, type MindooDBAppAttachmentPreviewSession as m, type MindooDBAppAutomergeChangesPatch as n, type MindooDBAppAutomergeChangesSince as o, type MindooDBAppAutomergeGetOptions as p, type MindooDBAppAutomergePatchResult as q, type MindooDBAppAutomergeSnapshot as r, type MindooDBAppBridgeConnectMessage as s, type MindooDBAppBridgeConnectOptions as t, type MindooDBAppBridgeConnectedMessage as u, type MindooDBAppBridgeErrorPayload as v, type MindooDBAppBridgeHandshakeErrorMessage as w, type MindooDBAppBridgeLocaleChangedMessage as x, type MindooDBAppBridgePortMessage as y, type MindooDBAppBridgeQueryResultMessage as z };
2061
+ export { type MindooDBAppConfiguredViewFormulaFilterDefinition as $, type MindooDBAppBridgeRpcError as A, type MindooDBAppBridgeRpcMessage as B, type MindooDBAppBridgeRpcRequest as C, type MindooDBAppBridgeRpcSuccess as D, type MindooDBAppBridgeStreamAbortRequest as E, type MindooDBAppBridgeStreamAck as F, type MindooDBAppBridgeStreamCloseRequest as G, type MindooDBAppBridgeStreamError as H, type MindooDBAppBridgeStreamMessage as I, type MindooDBAppBridgeStreamOpenResult as J, type MindooDBAppBridgeStreamReadRequest as K, type MindooDBAppBridgeStreamWriteRequest as L, type MindooDBAppAttachmentPreviewMode as M, type MindooDBAppBridgeThemeChangedMessage as N, type MindooDBAppBridgeUiPreferencesChangedMessage as O, type MindooDBAppBridgeViewChangedMessage as P, type MindooDBAppBridgeViewportChangedMessage as Q, type MindooDBAppCapability as R, type MindooDBAppConfiguredViewCategorizationStyle as S, type MindooDBAppConfiguredViewColumn as T, type MindooDBAppConfiguredViewColumnRole as U, type MindooDBAppConfiguredViewExpressionMode as V, type MindooDBAppConfiguredViewFieldExpression as W, type MindooDBAppConfiguredViewFilterDefinition as X, type MindooDBAppConfiguredViewFilterMode as Y, type MindooDBAppConfiguredViewFilterRule as Z, type MindooDBAppConfiguredViewFormulaExpression as _, type MindooDBAppBridge as a, type MindooDBAppReadableAttachmentStream as a$, type MindooDBAppConfiguredViewPreviewMode as a0, type MindooDBAppConfiguredViewRuleFilterDefinition as a1, type MindooDBAppConfiguredViewRuleMatchMode as a2, type MindooDBAppConfiguredViewRuleOperator as a3, type MindooDBAppConfiguredViewValueExpression as a4, type MindooDBAppCreateDocumentInput as a5, type MindooDBAppCreateKeyInfo as a6, type MindooDBAppCreateViewInput as a7, type MindooDBAppCreateViewNavigatorInput as a8, type MindooDBAppDatabaseInfo as a9, type MindooDBAppJsonListInsertPatch as aA, type MindooDBAppJsonPatch as aB, type MindooDBAppJsonSetPatch as aC, type MindooDBAppJsonTextMarkPatch as aD, type MindooDBAppJsonTextSplicePatch as aE, type MindooDBAppJsonTextUnmarkPatch as aF, type MindooDBAppJsonUnsetPatch as aG, type MindooDBAppLaunchContext as aH, type MindooDBAppLiveQuerySubscription as aI, type MindooDBAppMenuAnchor as aJ, type MindooDBAppMenuApi as aK, type MindooDBAppMenuCommandItem as aL, type MindooDBAppMenuDismissReason as aM, type MindooDBAppMenuDismissedResult as aN, type MindooDBAppMenuItem as aO, type MindooDBAppMenuKind as aP, type MindooDBAppMenuPlacement as aQ, type MindooDBAppMenuPointAnchor as aR, type MindooDBAppMenuRect as aS, type MindooDBAppMenuRectAnchor as aT, type MindooDBAppMenuSelectionResult as aU, type MindooDBAppMenuSeparatorItem as aV, type MindooDBAppQueryCoverage as aW, type MindooDBAppQueryResult as aX, type MindooDBAppQueryRow as aY, type MindooDBAppQuerySortKey as aZ, type MindooDBAppQueryTextClause as a_, type MindooDBAppDirectoryApi as aa, type MindooDBAppDirectoryEntry as ab, type MindooDBAppDocumentApi as ac, type MindooDBAppDocumentHeadCursorResult as ad, type MindooDBAppDocumentHistoryEntry as ae, type MindooDBAppDocumentListQuery as af, type MindooDBAppDocumentListResult as ag, type MindooDBAppDocumentQuery as ah, type MindooDBAppDocumentRevisionId as ai, type MindooDBAppDocumentScanPreset as aj, type MindooDBAppDocumentSummary as ak, type MindooDBAppEntryAttachmentRef as al, type MindooDBAppEntryProvenance as am, type MindooDBAppExtractDocumentTextInput as an, type MindooDBAppExtractDocumentTextResult as ao, type MindooDBAppExtractTextFormat as ap, type MindooDBAppExtractionSetup as aq, type MindooDBAppFulltextSetup as ar, type MindooDBAppHistoricalDocument as as, type MindooDBAppHistoryQuery as at, type MindooDBAppHostTheme as au, type MindooDBAppIdentityApi as av, type MindooDBAppInaccessibleDocument as aw, type MindooDBAppInaccessibleDocumentListQuery as ax, type MindooDBAppInaccessibleDocumentListResult as ay, type MindooDBAppJsonListDeletePatch as az, type MindooDBAppDatabase as b, type MindooDBAppRecipientOptions as b0, type MindooDBAppResolvedViewDefinition as b1, type MindooDBAppResolvedViewSource as b2, type MindooDBAppRevisionPhase as b3, type MindooDBAppRevisionVerification as b4, type MindooDBAppRichTextBlockSpan as b5, type MindooDBAppRichTextGetOptions as b6, type MindooDBAppRichTextImmutableString as b7, type MindooDBAppRichTextMarkRange as b8, type MindooDBAppRichTextMaterializeValue as b9, type MindooDBAppUiPreferences as bA, type MindooDBAppUpdateDocumentInput as bB, type MindooDBAppViewCursorDocumentListResult as bC, type MindooDBAppViewCursorResult as bD, type MindooDBAppViewEntry as bE, type MindooDBAppViewEntryKind as bF, type MindooDBAppViewNavigator as bG, type MindooDBAppViewNavigatorExpansionState as bH, type MindooDBAppViewNavigatorOpenOptions as bI, type MindooDBAppViewNavigatorPageOptions as bJ, type MindooDBAppViewNavigatorPageResult as bK, type MindooDBAppViewNavigatorRangeQuery as bL, type MindooDBAppViewNavigatorSelectionState as bM, type MindooDBAppViewUpdateStats as bN, type MindooDBAppViewport as bO, type MindooDBAppWritableAttachmentStream as bP, type MindooDBAppRichTextPatch as ba, type MindooDBAppRichTextScalar as bb, type MindooDBAppRichTextSpliceStep as bc, type MindooDBAppRichTextStep as bd, type MindooDBAppRichTextStepPatch as be, type MindooDBAppRichTextTextSpan as bf, type MindooDBAppRuntime as bg, type MindooDBAppScanAttachmentOptions as bh, type MindooDBAppScanAttachmentResult as bi, type MindooDBAppScopedDocId as bj, type MindooDBAppScopedDocumentSummary as bk, type MindooDBAppSealIntent as bl, type MindooDBAppSession as bm, type MindooDBAppShowMenuInput as bn, type MindooDBAppShowMenuResult as bo, type MindooDBAppSignPreview as bp, type MindooDBAppSignPreviewScope as bq, type MindooDBAppSignStatementInput as br, type MindooDBAppSignStatementResult as bs, type MindooDBAppTextEdit as bt, type MindooDBAppTextPatch as bu, type MindooDBAppThemeMode as bv, type MindooDBAppTimestampApi as bw, type MindooDBAppTimestampInput as bx, type MindooDBAppTimestampProvider as by, type MindooDBAppTimestampResult as bz, type MindooDBAppDocument as c, type MindooDBAppRichTextSpan as d, type MindooDBAppRichTextSnapshot as e, MINDOODB_APP_SEAL_SIGNING_DOMAIN as f, type MindooDBAppAccessDecision as g, type MindooDBAppAccessTier as h, type MindooDBAppAttachmentApi as i, type MindooDBAppAttachmentChunk as j, type MindooDBAppAttachmentInfo as k, type MindooDBAppAttachmentPreviewOptions as l, type MindooDBAppAttachmentPreviewSession as m, type MindooDBAppAutomergeChangesPatch as n, type MindooDBAppAutomergeChangesSince as o, type MindooDBAppAutomergeGetOptions as p, type MindooDBAppAutomergePatchResult as q, type MindooDBAppAutomergeSnapshot as r, type MindooDBAppBridgeConnectMessage as s, type MindooDBAppBridgeConnectOptions as t, type MindooDBAppBridgeConnectedMessage as u, type MindooDBAppBridgeErrorPayload as v, type MindooDBAppBridgeHandshakeErrorMessage as w, type MindooDBAppBridgeLocaleChangedMessage as x, type MindooDBAppBridgePortMessage as y, type MindooDBAppBridgeQueryResultMessage as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindoodb-app-sdk",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "engines": {
5
5
  "node": ">=22.13.0"
6
6
  },
@@ -36,11 +36,11 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "mindoodb-view-language": "0.0.15"
39
+ "mindoodb-view-language": "0.0.16"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@automerge/automerge": "^3.3.2",
43
- "mindoodb": ">=0.0.48"
43
+ "mindoodb": ">=0.0.55"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "@automerge/automerge": {
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "devDependencies": {
54
54
  "@automerge/automerge": "^3.3.2",
55
- "mindoodb": "^0.0.48",
55
+ "mindoodb": "^0.0.55",
56
56
  "@types/node": "25.5.0",
57
57
  "tsup": "^8.5.1",
58
58
  "typescript": "^6.0.2",