mindoodb-app-sdk 0.0.13 → 0.0.14
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
|
@@ -321,13 +321,14 @@ const doc = await db.documents.get(docId);
|
|
|
321
321
|
|
|
322
322
|
// Create (optionally with a named document key)
|
|
323
323
|
const created = await db.documents.create({
|
|
324
|
-
|
|
324
|
+
set: { title: "Meeting notes", content: "..." },
|
|
325
325
|
decryptionKeyId: "team-key", // omit to use "default"
|
|
326
326
|
});
|
|
327
327
|
|
|
328
328
|
// Update
|
|
329
329
|
const updated = await db.documents.update(docId, {
|
|
330
|
-
|
|
330
|
+
set: { title: "Updated title" },
|
|
331
|
+
unset: ["legacyField"],
|
|
331
332
|
});
|
|
332
333
|
|
|
333
334
|
// Delete
|
|
@@ -348,6 +349,8 @@ await db.documents.delete(docId);
|
|
|
348
349
|
|
|
349
350
|
`nextCursor` is the latest checkpoint reached by the page. Persist it after each successful call when you are building your own index or sync loop. If there were no changes after the supplied cursor, `nextCursor` is `null`.
|
|
350
351
|
|
|
352
|
+
`documents.update()` accepts top-level `set` and `unset` operations. Prefer sending small, intentional field-level changes instead of rewriting whole documents when only a few fields changed. This keeps MindooDB change tracking more meaningful and helps Automerge produce cleaner merge results.
|
|
353
|
+
|
|
351
354
|
When Haven can resolve the signing identity from the tenant directory, list items may also include `identityLabel` and `publicKeyFingerprint` for the latest visible change. Apps can use this to show who last touched a document without loading the full revision history first.
|
|
352
355
|
|
|
353
356
|
### Document history
|
|
@@ -731,6 +734,8 @@ Connect options: `launchId?`, `targetOrigin?`, `connectTimeoutMs?`.
|
|
|
731
734
|
|
|
732
735
|
`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.
|
|
733
736
|
|
|
737
|
+
For `update(docId, patch)`, use `{ set?: Record<string, unknown>; unset?: string[] }`. Both operations are shallow and apply to top-level document fields only.
|
|
738
|
+
|
|
734
739
|
### MindooDBAppAttachmentApi
|
|
735
740
|
|
|
736
741
|
| Method | Returns |
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppBridge } from './types-
|
|
2
|
-
export { b as MindooDBAppAttachmentApi, c as MindooDBAppAttachmentChunk, d as MindooDBAppAttachmentInfo, e as MindooDBAppAttachmentPreviewOptions, f as MindooDBAppAttachmentPreviewSession, g as MindooDBAppBridgeConnectMessage, h as MindooDBAppBridgeConnectOptions, i as MindooDBAppBridgeConnectedMessage, j as MindooDBAppBridgeErrorPayload, k as MindooDBAppBridgePortMessage, l as MindooDBAppBridgeRpcError, m as MindooDBAppBridgeRpcMessage, n as MindooDBAppBridgeRpcRequest, o as MindooDBAppBridgeRpcSuccess, p as MindooDBAppBridgeStreamAbortRequest, q as MindooDBAppBridgeStreamAck, r as MindooDBAppBridgeStreamCloseRequest, s as MindooDBAppBridgeStreamError, t as MindooDBAppBridgeStreamMessage, u as MindooDBAppBridgeStreamOpenResult, v as MindooDBAppBridgeStreamReadRequest, w as MindooDBAppBridgeStreamWriteRequest, x as MindooDBAppBridgeThemeChangedMessage, y as MindooDBAppBridgeUiPreferencesChangedMessage, z as MindooDBAppBridgeViewportChangedMessage, A as MindooDBAppCapability, B as MindooDBAppConfiguredViewCategorizationStyle, C as MindooDBAppConfiguredViewColumn, D as MindooDBAppConfiguredViewColumnRole, E as MindooDBAppConfiguredViewExpressionMode, F as MindooDBAppConfiguredViewFieldExpression, G as MindooDBAppConfiguredViewFilterDefinition, H as MindooDBAppConfiguredViewFilterMode, I as MindooDBAppConfiguredViewFilterRule, J as MindooDBAppConfiguredViewFormulaExpression, K as MindooDBAppConfiguredViewFormulaFilterDefinition, L as MindooDBAppConfiguredViewPreviewMode, N as MindooDBAppConfiguredViewRuleFilterDefinition, O as MindooDBAppConfiguredViewRuleMatchMode, P as MindooDBAppConfiguredViewRuleOperator, Q as MindooDBAppConfiguredViewValueExpression, R as MindooDBAppCreateDocumentInput, S as MindooDBAppCreateViewInput, T as MindooDBAppCreateViewNavigatorInput, U as MindooDBAppDatabase, V as MindooDBAppDatabaseInfo, W as MindooDBAppDocument, X as MindooDBAppDocumentApi, Y as MindooDBAppDocumentHeadCursorResult, Z as MindooDBAppDocumentHistoryEntry, _ as MindooDBAppDocumentListQuery, $ as MindooDBAppDocumentListResult, a0 as MindooDBAppDocumentSummary, a1 as MindooDBAppHistoricalDocument, a2 as MindooDBAppHistoryQuery, a3 as MindooDBAppHostTheme, a4 as MindooDBAppLaunchContext, a5 as MindooDBAppMenuAnchor, a6 as MindooDBAppMenuApi, a7 as MindooDBAppMenuCommandItem, a8 as MindooDBAppMenuDismissReason, a9 as MindooDBAppMenuDismissedResult, aa as MindooDBAppMenuItem, ab as MindooDBAppMenuKind, ac as MindooDBAppMenuPlacement, ad as MindooDBAppMenuPointAnchor, ae as MindooDBAppMenuRect, af as MindooDBAppMenuRectAnchor, ag as MindooDBAppMenuSelectionResult, ah as MindooDBAppMenuSeparatorItem, ai as MindooDBAppReadableAttachmentStream, aj as MindooDBAppResolvedViewDefinition, ak as MindooDBAppResolvedViewSource, al as MindooDBAppRuntime, am as MindooDBAppScopedDocId, an as MindooDBAppScopedDocumentSummary, ao as MindooDBAppSession, ap as MindooDBAppShowMenuInput, aq as MindooDBAppShowMenuResult, ar as MindooDBAppThemeMode, as as MindooDBAppUiPreferences, at as MindooDBAppUpdateDocumentInput, au as MindooDBAppViewCursorDocumentListResult, av as MindooDBAppViewCursorResult, aw as MindooDBAppViewEntry, ax as MindooDBAppViewEntryKind, ay as MindooDBAppViewNavigator, az as MindooDBAppViewNavigatorExpansionState, aA as MindooDBAppViewNavigatorOpenOptions, aB as MindooDBAppViewNavigatorPageOptions, aC as MindooDBAppViewNavigatorPageResult, aD as MindooDBAppViewNavigatorRangeQuery, aE as MindooDBAppViewNavigatorSelectionState, aF as MindooDBAppViewport, aG as MindooDBAppWritableAttachmentStream } from './types-
|
|
1
|
+
import { M as MindooDBAppAttachmentPreviewMode, a as MindooDBAppBridge } from './types-B1iKRIuy.js';
|
|
2
|
+
export { b as MindooDBAppAttachmentApi, c as MindooDBAppAttachmentChunk, d as MindooDBAppAttachmentInfo, e as MindooDBAppAttachmentPreviewOptions, f as MindooDBAppAttachmentPreviewSession, g as MindooDBAppBridgeConnectMessage, h as MindooDBAppBridgeConnectOptions, i as MindooDBAppBridgeConnectedMessage, j as MindooDBAppBridgeErrorPayload, k as MindooDBAppBridgePortMessage, l as MindooDBAppBridgeRpcError, m as MindooDBAppBridgeRpcMessage, n as MindooDBAppBridgeRpcRequest, o as MindooDBAppBridgeRpcSuccess, p as MindooDBAppBridgeStreamAbortRequest, q as MindooDBAppBridgeStreamAck, r as MindooDBAppBridgeStreamCloseRequest, s as MindooDBAppBridgeStreamError, t as MindooDBAppBridgeStreamMessage, u as MindooDBAppBridgeStreamOpenResult, v as MindooDBAppBridgeStreamReadRequest, w as MindooDBAppBridgeStreamWriteRequest, x as MindooDBAppBridgeThemeChangedMessage, y as MindooDBAppBridgeUiPreferencesChangedMessage, z as MindooDBAppBridgeViewportChangedMessage, A as MindooDBAppCapability, B as MindooDBAppConfiguredViewCategorizationStyle, C as MindooDBAppConfiguredViewColumn, D as MindooDBAppConfiguredViewColumnRole, E as MindooDBAppConfiguredViewExpressionMode, F as MindooDBAppConfiguredViewFieldExpression, G as MindooDBAppConfiguredViewFilterDefinition, H as MindooDBAppConfiguredViewFilterMode, I as MindooDBAppConfiguredViewFilterRule, J as MindooDBAppConfiguredViewFormulaExpression, K as MindooDBAppConfiguredViewFormulaFilterDefinition, L as MindooDBAppConfiguredViewPreviewMode, N as MindooDBAppConfiguredViewRuleFilterDefinition, O as MindooDBAppConfiguredViewRuleMatchMode, P as MindooDBAppConfiguredViewRuleOperator, Q as MindooDBAppConfiguredViewValueExpression, R as MindooDBAppCreateDocumentInput, S as MindooDBAppCreateViewInput, T as MindooDBAppCreateViewNavigatorInput, U as MindooDBAppDatabase, V as MindooDBAppDatabaseInfo, W as MindooDBAppDocument, X as MindooDBAppDocumentApi, Y as MindooDBAppDocumentHeadCursorResult, Z as MindooDBAppDocumentHistoryEntry, _ as MindooDBAppDocumentListQuery, $ as MindooDBAppDocumentListResult, a0 as MindooDBAppDocumentSummary, a1 as MindooDBAppHistoricalDocument, a2 as MindooDBAppHistoryQuery, a3 as MindooDBAppHostTheme, a4 as MindooDBAppLaunchContext, a5 as MindooDBAppMenuAnchor, a6 as MindooDBAppMenuApi, a7 as MindooDBAppMenuCommandItem, a8 as MindooDBAppMenuDismissReason, a9 as MindooDBAppMenuDismissedResult, aa as MindooDBAppMenuItem, ab as MindooDBAppMenuKind, ac as MindooDBAppMenuPlacement, ad as MindooDBAppMenuPointAnchor, ae as MindooDBAppMenuRect, af as MindooDBAppMenuRectAnchor, ag as MindooDBAppMenuSelectionResult, ah as MindooDBAppMenuSeparatorItem, ai as MindooDBAppReadableAttachmentStream, aj as MindooDBAppResolvedViewDefinition, ak as MindooDBAppResolvedViewSource, al as MindooDBAppRuntime, am as MindooDBAppScopedDocId, an as MindooDBAppScopedDocumentSummary, ao as MindooDBAppSession, ap as MindooDBAppShowMenuInput, aq as MindooDBAppShowMenuResult, ar as MindooDBAppThemeMode, as as MindooDBAppUiPreferences, at as MindooDBAppUpdateDocumentInput, au as MindooDBAppViewCursorDocumentListResult, av as MindooDBAppViewCursorResult, aw as MindooDBAppViewEntry, ax as MindooDBAppViewEntryKind, ay as MindooDBAppViewNavigator, az as MindooDBAppViewNavigatorExpansionState, aA as MindooDBAppViewNavigatorOpenOptions, aB as MindooDBAppViewNavigatorPageOptions, aC as MindooDBAppViewNavigatorPageResult, aD as MindooDBAppViewNavigatorRangeQuery, aE as MindooDBAppViewNavigatorSelectionState, aF as MindooDBAppViewport, aG as MindooDBAppWritableAttachmentStream } from './types-B1iKRIuy.js';
|
|
3
3
|
export { MindooDBAppBooleanExpression, MindooDBAppExpression, MindooDBAppFilterDefinition, MindooDBAppViewCategoryChildrenPageRequest, MindooDBAppViewColumn, MindooDBAppViewColumnRole, MindooDBAppViewDefinition, MindooDBAppViewExpansionState, MindooDBAppViewExpressionBase, MindooDBAppViewExpressionDatePart, MindooDBAppViewExpressionOperation, MindooDBAppViewFieldExpression, MindooDBAppViewIfExpression, MindooDBAppViewLetExpression, MindooDBAppViewLiteralExpression, MindooDBAppViewLookupByPath, MindooDBAppViewOperationExpression, MindooDBAppViewOriginExpression, MindooDBAppViewPageRequest, MindooDBAppViewPageResult, MindooDBAppViewRow, MindooDBAppViewSortDirection, MindooDBAppViewTotalMode, MindooDBAppViewValueExpressionRef, MindooDBAppViewVariableExpression, createViewLanguage } from 'mindoodb-view-language';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a4 as MindooDBAppLaunchContext, V as MindooDBAppDatabaseInfo, X as MindooDBAppDocumentApi, T as MindooDBAppCreateViewNavigatorInput, ay as MindooDBAppViewNavigator, aA as MindooDBAppViewNavigatorOpenOptions, b as MindooDBAppAttachmentApi, a as MindooDBAppBridge, ao as MindooDBAppSession, n as MindooDBAppBridgeRpcRequest, a3 as MindooDBAppHostTheme, aF as MindooDBAppViewport, as as MindooDBAppUiPreferences, k as MindooDBAppBridgePortMessage } from '../types-
|
|
1
|
+
import { a4 as MindooDBAppLaunchContext, V as MindooDBAppDatabaseInfo, X as MindooDBAppDocumentApi, T as MindooDBAppCreateViewNavigatorInput, ay as MindooDBAppViewNavigator, aA as MindooDBAppViewNavigatorOpenOptions, b as MindooDBAppAttachmentApi, a as MindooDBAppBridge, ao as MindooDBAppSession, n as MindooDBAppBridgeRpcRequest, a3 as MindooDBAppHostTheme, aF as MindooDBAppViewport, as as MindooDBAppUiPreferences, k as MindooDBAppBridgePortMessage } from '../types-B1iKRIuy.js';
|
|
2
2
|
import 'mindoodb-view-language';
|
|
3
3
|
|
|
4
4
|
type MaybePromise<T> = T | Promise<T>;
|
package/dist/testing/index.js
CHANGED
|
@@ -12,6 +12,16 @@ function createBridgeErrorPayload(error, fallbackCode = "bridge-error") {
|
|
|
12
12
|
function cloneBytes(chunk) {
|
|
13
13
|
return new Uint8Array(chunk.buffer.slice(chunk.byteOffset, chunk.byteOffset + chunk.byteLength));
|
|
14
14
|
}
|
|
15
|
+
function applyDocumentUpdatePatch(current, patch) {
|
|
16
|
+
const next = {
|
|
17
|
+
...structuredClone(current),
|
|
18
|
+
...patch.set ? structuredClone(patch.set) : {}
|
|
19
|
+
};
|
|
20
|
+
for (const key of patch.unset ?? []) {
|
|
21
|
+
Reflect.deleteProperty(next, key);
|
|
22
|
+
}
|
|
23
|
+
return next;
|
|
24
|
+
}
|
|
15
25
|
function mergeLaunchContext(current, patch) {
|
|
16
26
|
if (!patch) {
|
|
17
27
|
return {
|
|
@@ -437,7 +447,7 @@ function createDatabaseHandle(definition) {
|
|
|
437
447
|
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
438
448
|
const created = {
|
|
439
449
|
id: `doc-${createCounter}`,
|
|
440
|
-
data: { ...input.
|
|
450
|
+
data: { ...input.set },
|
|
441
451
|
attachments: [],
|
|
442
452
|
updatedAt: createdAt
|
|
443
453
|
};
|
|
@@ -456,7 +466,7 @@ function createDatabaseHandle(definition) {
|
|
|
456
466
|
const existing = storedDocuments.get(docId);
|
|
457
467
|
const updated = {
|
|
458
468
|
id: docId,
|
|
459
|
-
data:
|
|
469
|
+
data: applyDocumentUpdatePatch(existing?.data ?? {}, patch),
|
|
460
470
|
attachments: existing?.attachments ? structuredClone(existing.attachments) : [],
|
|
461
471
|
updatedAt
|
|
462
472
|
};
|
|
@@ -210,15 +210,29 @@ interface MindooDBAppViewCursorDocumentListResult {
|
|
|
210
210
|
items: MindooDBAppScopedDocumentSummary[];
|
|
211
211
|
nextCursor: string | null;
|
|
212
212
|
}
|
|
213
|
-
/**
|
|
213
|
+
/**
|
|
214
|
+
* Payload used when creating a new document.
|
|
215
|
+
*
|
|
216
|
+
* `set` becomes the initial top-level document state, mirroring the update
|
|
217
|
+
* API's field-assignment language while still creating a brand-new document.
|
|
218
|
+
*/
|
|
214
219
|
interface MindooDBAppCreateDocumentInput {
|
|
215
|
-
|
|
220
|
+
set: Record<string, unknown>;
|
|
216
221
|
/** Optional named document key. Defaults to `"default"` when omitted. */
|
|
217
222
|
decryptionKeyId?: string;
|
|
218
223
|
}
|
|
219
|
-
/**
|
|
224
|
+
/**
|
|
225
|
+
* Sparse patch payload used when updating an existing document.
|
|
226
|
+
*
|
|
227
|
+
* Prefer targeted `set` / `unset` operations over whole-document rewrites so
|
|
228
|
+
* MindooDB can preserve more meaningful change history and Automerge can merge
|
|
229
|
+
* smaller, more intentional updates.
|
|
230
|
+
*/
|
|
220
231
|
interface MindooDBAppUpdateDocumentInput {
|
|
221
|
-
|
|
232
|
+
/** Top-level fields to assign on the document. */
|
|
233
|
+
set?: Record<string, unknown>;
|
|
234
|
+
/** Top-level fields to remove from the document entirely. */
|
|
235
|
+
unset?: string[];
|
|
222
236
|
}
|
|
223
237
|
/** Query used for history lookups at a specific timestamp. */
|
|
224
238
|
interface MindooDBAppHistoryQuery {
|